Skip to content

Commit

Permalink
Many Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alphalaneous committed Jun 30, 2024
1 parent 80964ef commit f90e817
Show file tree
Hide file tree
Showing 74 changed files with 645 additions and 336 deletions.
Binary file modified assets/panorama/panorama_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/panorama/panorama_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/panorama/panorama_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/panorama/panorama_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/panorama/panorama_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/panorama/panorama_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/textures/button-hd.png
Binary file not shown.
Binary file removed assets/textures/button-uhd.png
Binary file not shown.
Binary file removed assets/textures/button_disabled-uhd.png
Binary file not shown.
Binary file removed assets/textures/button_highlighted-hd.png
Binary file not shown.
Binary file removed assets/textures/button_highlighted-uhd.png
Binary file not shown.
Binary file added assets/textures/draft_report.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/textures/edition-hd.png
Binary file not shown.
Binary file removed assets/textures/edition-uhd.png
Binary file not shown.
Binary file removed assets/textures/language-hd.png
Binary file not shown.
Binary file removed assets/textures/language-uhd.png
Binary file not shown.
Binary file added assets/textures/link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/textures/minceraft-title-hd.png
Binary file not shown.
Binary file removed assets/textures/minceraft-title-uhd.png
Binary file not shown.
Binary file removed assets/textures/minecraft-title-hd.png
Binary file not shown.
Binary file removed assets/textures/minecraft-title-uhd.png
Binary file not shown.
Binary file added assets/textures/pink_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/pink_progress.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/scroller.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/scroller_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/search.png
Binary file removed assets/textures/select-hd.png
Diff not rendered.
Binary file removed assets/textures/select-uhd.png
Diff not rendered.
File renamed without changes
Binary file added assets/textures/slider_handle.png
Binary file added assets/textures/slider_handle_highlighted.png
Binary file added assets/textures/slider_highlighted.png
Binary file added assets/textures/social_interactions.png
Binary file added assets/textures/teleport_to_player.png
Binary file added assets/textures/text_field.png
Binary file added assets/textures/text_field_highlighted.png
Binary file added assets/textures/tooltip.png
Binary file added assets/textures/ui_background.png
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"gd": {
"win": "2.206"
},
"version": "v0.6.9",
"version": "v0.7.0",
"id": "zalphalaneous.minecraft",
"name": "Minecraftify!",
"developer": "Alphalaneous",
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "ui/hooks/CCDirector.h"
#include "ui/hooks/CCMenuItemSpriteExtra.h"
#include "ui/hooks/CCMenuItemToggler.h"
#include "ui/hooks/FLAlertLayer.h"

$execute{
setlocale( LC_ALL, "en_US.utf8" );
Expand Down
12 changes: 12 additions & 0 deletions src/ui/hooks/CCDirector.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@

class $modify(MyCCDirector, CCDirector){

/*void popScene(){
CCScene* currentScene = CCDirector::get()->getRunningScene();
if(!currentScene->getChildByIDRecursive("settings-layer"_spr)){
if(!currentScene->getChildByIDRecursive("MenuLayer")){
CCDirector::popScene();
}
}
else{
currentScene->getChildByIDRecursive("settings-layer"_spr)->removeFromParent();
}
}*/

bool replaceScene(CCScene *pScene){

if(!GlobalVars::getSharedInstance()->isInitialLaunch){
Expand Down
24 changes: 24 additions & 0 deletions src/ui/hooks/CCMenuItemSpriteExtra.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,37 @@ class $modify(MyCCMenuItemSpriteExtra, CCMenuItemSpriteExtra){
struct Fields {
cocos2d::SEL_MenuHandler m_buttonCallback;
CCObject* m_buttonTarget;
bool m_isMCButton = false;
};

bool init(cocos2d::CCNode* p0, cocos2d::CCNode* p1, cocos2d::CCObject* p2, cocos2d::SEL_MenuHandler p3){
m_fields->m_buttonCallback = p3;
m_fields->m_buttonTarget = p2;
return CCMenuItemSpriteExtra::init(p0, p1, p2, p3);
}

void selected(){
if(!m_fields->m_isMCButton){
CCMenuItemSpriteExtra::selected();
}
else {
FMODAudioEngine::sharedEngine()->playEffect("click.ogg"_spr);
(m_pListener->*m_pfnSelector)(this);
}
}

void unselected(){
if(!m_fields->m_isMCButton){
CCMenuItemSpriteExtra::unselected();
}
}

void activate(){
if(!m_fields->m_isMCButton){
CCMenuItemSpriteExtra::activate();
}
}

};

#endif
15 changes: 11 additions & 4 deletions src/ui/hooks/CCMenuItemToggler.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,25 @@
#ifndef MYCCMENUITEMTOGGLER_H
#define MYCCMENUITEMTOGGLER_H

using namespace geode::prelude;

class $modify(MyCCMenuItemToggler, CCMenuItemToggler){

struct Fields {
cocos2d::SEL_MenuHandler m_buttonCallback;
CCObject* m_buttonTarget;
};

bool init(cocos2d::CCNode* p0, cocos2d::CCNode* p1, cocos2d::CCObject* p2, cocos2d::SEL_MenuHandler p3){
m_fields->m_buttonCallback = p3;
m_fields->m_buttonTarget = p2;
return CCMenuItemToggler::init(p0, p1, p2, p3);
static CCMenuItemToggler* create(cocos2d::CCNode* p0, cocos2d::CCNode* p1, cocos2d::CCObject* p2, cocos2d::SEL_MenuHandler p3){
auto ret = CCMenuItemToggler::create(p0, p1, p2, p3);
auto myRet = static_cast<MyCCMenuItemToggler*>(ret);

myRet->m_fields->m_buttonCallback = p3;
myRet->m_fields->m_buttonTarget = p2;
return ret;
}


};

#endif
185 changes: 185 additions & 0 deletions src/ui/hooks/FLAlertLayer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
#include <Geode/Geode.hpp>
#include <Geode/modify/FLAlertLayer.hpp>

class $modify(MyFLAlertLayer, FLAlertLayer){

bool init(FLAlertLayerProtocol* p0, char const* p1, gd::string p2, char const* p3, char const* p4, float p5, bool p6, float p7, float p8){

if(!FLAlertLayer::init(p0, p1, p2, p3, p4, p5, p6, p7, p8)){
return false;
}

if(!Loader::get()->isModLoaded("geode.node-ids")) return true;

CCNode* mainLayer = getChildByID("main-layer");

float scale = CCDirector::sharedDirector()->getContentScaleFactor()/4;

if(CCScale9Sprite* background = typeinfo_cast<CCScale9Sprite*>(mainLayer->getChildByID("background"))){
CCScale9Sprite* newBackground = CCScale9Sprite::create("ui_background.png"_spr);
newBackground->setColor(background->getColor());
newBackground->setContentSize(background->getContentSize() / 4 / scale);
newBackground->setScale(background->getScale() * 4 * scale);
newBackground->setPosition({mainLayer->getContentSize().width/2, mainLayer->getContentSize().height/2});
newBackground->setAnchorPoint(background->getAnchorPoint());
newBackground->setOpacity(background->getOpacity());
newBackground->setLayout(background->getLayout());
newBackground->setLayoutOptions(background->getLayoutOptions());
newBackground->setID(background->getID());
newBackground->setRotation(background->getRotation());
newBackground->setVisible(background->isVisible());
newBackground->setZOrder(background->getZOrder());

CCSpriteBatchNode* batchNode = getChildOfType<CCSpriteBatchNode>(newBackground, 0);
ccTexParams params = {GL_NEAREST, GL_NEAREST, GL_REPEAT, GL_REPEAT};
batchNode->getTexture()->setTexParameters(&params);

background->removeFromParent();
mainLayer->addChild(newBackground);

CCSize textBGSize = {newBackground->getContentSize().width - 8, newBackground->getContentSize().height - 24};

CCScale9Sprite* textBackground = CCScale9Sprite::create("text_field.png"_spr);
CCSpriteBatchNode* batchNodeA = getChildOfType<CCSpriteBatchNode>(textBackground, 0);
ccTexParams paramsA = {GL_NEAREST, GL_NEAREST, GL_REPEAT, GL_REPEAT};
batchNodeA->getTexture()->setTexParameters(&paramsA);

textBackground->setScale(4 * scale);
textBackground->setContentSize(textBGSize / scale);
textBackground->setZOrder(5);
textBackground->setPosition({mainLayer->getContentSize().width/2, mainLayer->getContentSize().height/2});
mainLayer->addChild(textBackground);

}

if(CCNode* contentTextArea = mainLayer->getChildByID("content-text-area")) {
contentTextArea->setPosition({mainLayer->getContentSize().width/2, mainLayer->getContentSize().height/2});
contentTextArea->setZOrder(7);
for(CCLabelBMFont* text : CCArrayExt<CCLabelBMFont*>(getChildOfType<MultilineBitmapFont>(contentTextArea, 0)->getChildren())){
text->setFntFile("minecraft.fnt"_spr);
text->setAnchorPoint({0.5, 0});
text->setScale(0.6f);
text->setPosition({0, text->getPosition().y});
}
}

if(CCNode* scrollingLayer = mainLayer->getChildByID("scroll-layer")) {

if(CCLayer* contentLayer = getChildOfType<CCLayer>(scrollingLayer, 1)) {

if(CCNode* textArea = contentLayer->getChildByID("content-text-area")){
textArea->ignoreAnchorPointForPosition(false);
textArea->setAnchorPoint({0.5, 0});
textArea->setPosition({textArea->getPosition().x, 0});

for(CCLabelBMFont* text : CCArrayExt<CCLabelBMFont*>(getChildOfType<MultilineBitmapFont>(textArea, 0)->getChildren())){
text->setFntFile("minecraft.fnt"_spr);
text->setAnchorPoint({0.5, 1});
text->setScale(0.6f);
text->setPosition({0, text->getPosition().y});
}

contentLayer->setContentSize(textArea->getScaledContentSize());
}

CCSize size = contentLayer->getContentSize();

ScrollLayer* scrollLayer = ScrollLayer::create({0, 0, mainLayer->getContentSize().width, 180}, true, true);
scrollLayer->setID("scroll-layer"_spr);
scrollLayer->setTouchEnabled(true);
scrollLayer->setZOrder(6);

contentLayer->setPosition({0, 0});
contentLayer->setAnchorPoint({0, 0});
contentLayer->ignoreAnchorPointForPosition(false);
contentLayer->removeFromParent();
scrollLayer->m_contentLayer->setContentSize(contentLayer->getContentSize());
scrollLayer->m_contentLayer->addChild(contentLayer);

scrollLayer->setContentSize({mainLayer->getContentSize().width, 180});
scrollLayer->setPosition({0, mainLayer->getContentSize().height/2 - scrollLayer->getContentSize().height/2});
scrollLayer->setScale(scrollingLayer->getScale());

scrollLayer->moveToTop();

scrollingLayer->setVisible(false);

mainLayer->addChild(scrollLayer);
}
}

if(CCLabelBMFont* title = typeinfo_cast<CCLabelBMFont*>(mainLayer->getChildByID("title"))){
title->setFntFile("minecraft.fnt"_spr);
title->setScale(0.6f);
title->setPosition({title->getPosition().x, title->getPosition().y - 6.0f});
}


if(CCNode* menu = mainLayer->getChildByID("main-menu")){

RowLayout* rowLayout = RowLayout::create();
rowLayout->ignoreInvisibleChildren(true);

CCMenu* innerButtonMenu = CCMenu::create();

innerButtonMenu->setContentSize({400, 30});
innerButtonMenu->setLayout(rowLayout);
innerButtonMenu->setAnchorPoint({0.5, 0.5});
innerButtonMenu->setZOrder(1);
innerButtonMenu->setID("button-menu"_spr);

mainLayer->addChild(innerButtonMenu);

if(CCNode* bg = mainLayer->getChildByID("background")) {
innerButtonMenu->setPosition({bg->getPosition().x, bg->getPosition().y - bg->getScaledContentSize().height/2 + innerButtonMenu->getContentSize().height/2 + 4});
}


if(MyCCMenuItemSpriteExtra* button = static_cast<MyCCMenuItemSpriteExtra*>(getChildOfType<CCMenuItemSpriteExtra>(menu, 0))){
std::string text = "";

if(ButtonSprite* spr = getChildOfType<ButtonSprite>(button, 0)) {
if(CCLabelBMFont* label = getChildOfType<CCLabelBMFont>(spr, 0)) {
text = std::string(label->getString());
}
}

MCButton* btn1 = MCButton::create(text.c_str(), 39.1f, button->m_fields->m_buttonTarget, button->m_fields->m_buttonCallback);
btn1->setID(button->getID());
button->setVisible(false);
innerButtonMenu->addChild(btn1);
}
if(MyCCMenuItemSpriteExtra* button = static_cast<MyCCMenuItemSpriteExtra*>(getChildOfType<CCMenuItemSpriteExtra>(menu, 1))){
std::string text = "";

if(ButtonSprite* spr = getChildOfType<ButtonSprite>(button, 0)) {
if(CCLabelBMFont* label = getChildOfType<CCLabelBMFont>(spr, 0)) {
text = std::string(label->getString());
}
}

MCButton* btn2 = MCButton::create(text.c_str(), 39.1f, button->m_fields->m_buttonTarget, button->m_fields->m_buttonCallback);
btn2->setID(button->getID());
button->setVisible(false);
innerButtonMenu->addChild(btn2);
}

innerButtonMenu->updateLayout();
}

handleTouchPriority(this);

return true;
}

void show(){
FLAlertLayer::show();
if(CCNode* mainLayer = getChildByID("main-layer")) {
stopAllActions();
mainLayer->stopAllActions();
mainLayer->setScale(1);
setColor({20, 20, 20});
setOpacity(200);
}
}
};
16 changes: 9 additions & 7 deletions src/ui/hooks/MenuLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "../nodes/MCLabel.h"
#include "../nodes/MCButton.h"
#include "../layers/MCOptionsLayer.h"
#include "../layers/MCOptionsOuterLayer.h"
#include "../layers/ExtrasLayer.h"
#include "../layers/settings/VideoSettings.h"

Expand Down Expand Up @@ -87,15 +88,13 @@ class $modify(MyMenuLayer, MenuLayer) {
MCButton* profileButton = MCButton::create("", 5.0f, this, menu_selector(MyMenuLayer::onMyProfile));
MCButton* extrasButton = MCButton::create("", 5.0f, this, menu_selector(MyMenuLayer::onExtras));

CCSprite* profileSprite = Utils::createPixelSprite("language.png"_spr);
CCSprite* profileSprite = Utils::createPixelSprite("teleport_to_player.png"_spr);
profileSprite->setZOrder(1);
profileSprite->setScale(profileSprite->getScale());
profileSprite->setPosition({profileButton->getContentSize().width/2, profileButton->getContentSize().height/2});
profileButton->addSprite(profileSprite);

CCSprite* extrasSprite = Utils::createPixelSprite("select.png"_spr);
CCSprite* extrasSprite = Utils::createPixelSprite("search.png"_spr);
extrasSprite->setZOrder(1);
extrasSprite->setScale(extrasSprite->getScale()/2);
extrasSprite->setPosition({extrasButton->getContentSize().width/2, extrasButton->getContentSize().height/2});
extrasButton->addSprite(extrasSprite);

Expand Down Expand Up @@ -288,9 +287,12 @@ class $modify(MyMenuLayer, MenuLayer) {
}

void onMCOptions(CCObject* sender) {
CCScene* scene = MCOptionsLayer::scene();
auto transition = CCTransitionFade::create(0.0f, scene);
CCDirector::sharedDirector()->pushScene(transition);
MCOptionsOuterLayer* outerLayer = MCOptionsOuterLayer::create();
outerLayer->setLayer(MCOptionsLayer::create(outerLayer));

CCScene* scene = CCScene::create();
scene->addChild(outerLayer);
CCDirector::sharedDirector()->pushScene(scene);
}

void onMyProfile(CCObject* sender) {
Expand Down
53 changes: 53 additions & 0 deletions src/ui/layers/MCOptionsInnerLayer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include "MCOptionsInnerLayer.h"
#include "MCOptionsOuterLayer.h"

MCOptionsInnerLayer::~MCOptionsInnerLayer(){
if(m_prevLayer) m_prevLayer->release();
}

bool MCOptionsInnerLayer::init(MCOptionsOuterLayer* topLayer, CCLayer* prevLayer){
m_topLayer = topLayer;
m_prevLayer = prevLayer;
if(m_prevLayer) m_prevLayer->retain();

setKeypadEnabled(true);
setKeyboardEnabled(true);

log::info("start {}", m_prevLayer);

return true;
}

void MCOptionsInnerLayer::keyBackClicked() {
log::info("pressed back");
goBack();
}

void MCOptionsInnerLayer::onBack(CCObject* object) {
keyBackClicked();
}

void MCOptionsInnerLayer::goBack(){

m_topLayer->removeAllChildrenWithCleanup(false);
log::info("{}", m_prevLayer);

if(m_prevLayer){
m_topLayer->addChild(m_prevLayer);
}
else{
CCDirector::get()->popScene();
}

}

static MCOptionsInnerLayer* create(MCOptionsOuterLayer* topLayer, CCLayer* prevLayer){
auto ret = new MCOptionsInnerLayer();
if (ret && ret->init(topLayer, prevLayer)) {
ret->autorelease();
} else {
delete ret;
ret = nullptr;
}
return ret;
}
Loading

0 comments on commit f90e817

Please sign in to comment.