Skip to content

Commit c2ec736

Browse files
committed
Fix loadinglayer lmao
1 parent e7676f6 commit c2ec736

File tree

2 files changed

+78
-91
lines changed

2 files changed

+78
-91
lines changed

mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"win": "2.206",
55
"android": "2.206"
66
},
7-
"version": "v0.9.4",
7+
"version": "v0.9.5",
88
"id": "zalphalaneous.minecraft",
99
"name": "Minecraftify!",
1010
"developer": "Alphalaneous",

src/ui/hooks/LoadingLayer.h

Lines changed: 77 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -62,105 +62,92 @@ class $modify(MyLoadingLayer, LoadingLayer){
6262
this->m_fields->lastWidth = currentWidth;
6363
}
6464
}
65+
bool init(bool p0){
6566

66-
};
67+
if(!LoadingLayer::init(p0)){
68+
return false;
69+
}
6770

68-
bool LoadingLayer_init(LoadingLayer* self, bool p0){
71+
MyLoadingLayer* myself = static_cast<MyLoadingLayer*>(this);
72+
myself->m_fields->didHook = true;
6973

70-
log::info("hooked");
74+
#ifndef GEODE_IS_ANDROID
7175

72-
if(!self->init(p0)){
73-
return false;
74-
}
76+
auto hwnd = FindWindowW(NULL, L"Geometry Dash");
77+
SetWindowTextA(hwnd, "Minecraft* 2.2");
78+
79+
std::string path = Mod::get()->getResourcesDir().append("logo.ico").string();
80+
81+
HICON hIcon = (HICON)LoadImage(NULL, path.c_str(), IMAGE_ICON, 32, 32, LR_LOADFROMFILE);
82+
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
83+
84+
#endif
85+
86+
if(CCLabelBMFont* loadingTextOrig = typeinfo_cast<CCLabelBMFont*>(this->getChildByID("geode-small-label"))) {
87+
loadingTextOrig->setVisible(false);
88+
}
89+
90+
Utils::getNodeSafe(this, "bg-texture")->setVisible(false);
91+
Utils::getNodeSafe(this, "loading-text")->setVisible(false);
92+
Utils::getNodeSafe(this, "text-area")->setVisible(false);
93+
Utils::getNodeSafe(this, "robtop-logo")->setVisible(false);
94+
Utils::getNodeSafe(this, "gd-logo")->setVisible(false);
95+
Utils::getNodeSafe(this, "fmod-logo")->setVisible(false);
96+
Utils::getNodeSafe(this, "cocos2d-logo")->setVisible(false);
97+
Utils::getNodeSafe(this, "progress-slider")->setVisible(false);
98+
this->m_sliderBar->setVisible(false);
7599

76-
MyLoadingLayer* myself = static_cast<MyLoadingLayer*>(self);
77-
myself->m_fields->didHook = true;
100+
auto winSize = CCDirector::sharedDirector()->getWinSize();
78101

79-
#ifndef GEODE_IS_ANDROID
102+
CCLayerColor* layerColor = CCLayerColor::create(ccColor4B{239,50,61,255});
103+
layerColor->setContentSize(winSize);
80104

81-
auto hwnd = FindWindowW(NULL, L"Geometry Dash");
82-
SetWindowTextA(hwnd, "Minecraft* 2.2");
105+
this->addChild(layerColor);
83106

84-
std::string path = Mod::get()->getResourcesDir().append("logo.ico").string();
107+
CCLayerColor* loadingBarBG2 = CCLayerColor::create(ccColor4B{255,255,255,255});
108+
loadingBarBG2->setContentSize({myself->m_fields->loadingScaleX*200+4, myself->m_fields->loadingScaleY*5+4});
109+
loadingBarBG2->ignoreAnchorPointForPosition(false);
110+
loadingBarBG2->setAnchorPoint({0, 0.5});
111+
loadingBarBG2->setID("loading-bar-bg2"_spr);
112+
loadingBarBG2->setPosition({winSize.width/2-100*myself->m_fields->loadingScaleX-2, 60});
113+
this->addChild(loadingBarBG2);
85114

86-
HICON hIcon = (HICON)LoadImage(NULL, path.c_str(), IMAGE_ICON, 32, 32, LR_LOADFROMFILE);
87-
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
115+
CCLayerColor* loadingBarBG1 = CCLayerColor::create(ccColor4B{239,50,61,255});
116+
loadingBarBG1->setContentSize({myself->m_fields->loadingScaleX*200+2, myself->m_fields->loadingScaleY*5+2});
117+
loadingBarBG1->ignoreAnchorPointForPosition(false);
118+
loadingBarBG1->setAnchorPoint({0, 0.5});
119+
loadingBarBG1->setID("loading-bar-bg1"_spr);
88120

89-
#endif
121+
loadingBarBG1->setPosition({winSize.width/2-100*myself->m_fields->loadingScaleX-1.0f, 60});
122+
this->addChild(loadingBarBG1);
90123

91-
if(CCLabelBMFont* loadingTextOrig = typeinfo_cast<CCLabelBMFont*>(self->getChildByID("geode-small-label"))) {
92-
loadingTextOrig->setVisible(false);
124+
CCLayerColor* loadingBar = CCLayerColor::create(ccColor4B{255,255,255,255});
125+
loadingBar->setContentSize({1, 5});
126+
loadingBar->ignoreAnchorPointForPosition(false);
127+
loadingBar->setAnchorPoint({0, 0.5});
128+
loadingBar->setScaleX(myself->m_fields->loadingScaleX);
129+
loadingBar->setScaleY(myself->m_fields->loadingScaleY);
130+
131+
loadingBar->setPosition({winSize.width/2-100*myself->m_fields->loadingScaleX, 60});
132+
loadingBar->setID("loading-bar"_spr);
133+
this->addChild(loadingBar);
134+
135+
CCSprite* titleSprite = Utils::createSprite("/geode/unzipped/zalphalaneous.minecraft/resources/zalphalaneous.minecraft/mojangstudios.png");
136+
137+
titleSprite->setPosition({winSize.width/2, winSize.height/2});
138+
titleSprite->setScale(titleSprite->getScale()*0.3f);
139+
140+
this->addChild(titleSprite);
141+
142+
MCLabel* loadingText = MCLabel::create("", "/geode/unzipped/zalphalaneous.minecraft/resources/zalphalaneous.minecraft/minecraft.fnt");
143+
loadingText->setScale(0.4f);
144+
loadingText->setPosition({winSize.width/2, 30});
145+
146+
this->addChild(loadingText);
147+
loadingText->setID("loading-text"_spr);
148+
149+
CCScheduler::get()->scheduleSelector(schedule_selector(MyLoadingLayer::myUpdate), this, 0.0, false);
150+
151+
return true;
93152
}
94-
95-
Utils::getNodeSafe(self, "bg-texture")->setVisible(false);
96-
Utils::getNodeSafe(self, "loading-text")->setVisible(false);
97-
Utils::getNodeSafe(self, "text-area")->setVisible(false);
98-
Utils::getNodeSafe(self, "robtop-logo")->setVisible(false);
99-
Utils::getNodeSafe(self, "gd-logo")->setVisible(false);
100-
Utils::getNodeSafe(self, "fmod-logo")->setVisible(false);
101-
Utils::getNodeSafe(self, "cocos2d-logo")->setVisible(false);
102-
Utils::getNodeSafe(self, "progress-slider")->setVisible(false);
103-
self->m_sliderBar->setVisible(false);
104-
105-
auto winSize = CCDirector::sharedDirector()->getWinSize();
106-
107-
CCLayerColor* layerColor = CCLayerColor::create(ccColor4B{239,50,61,255});
108-
layerColor->setContentSize(winSize);
109-
110-
self->addChild(layerColor);
111-
112-
CCLayerColor* loadingBarBG2 = CCLayerColor::create(ccColor4B{255,255,255,255});
113-
loadingBarBG2->setContentSize({myself->m_fields->loadingScaleX*200+4, myself->m_fields->loadingScaleY*5+4});
114-
loadingBarBG2->ignoreAnchorPointForPosition(false);
115-
loadingBarBG2->setAnchorPoint({0, 0.5});
116-
loadingBarBG2->setID("loading-bar-bg2"_spr);
117-
loadingBarBG2->setPosition({winSize.width/2-100*myself->m_fields->loadingScaleX-2, 60});
118-
self->addChild(loadingBarBG2);
119-
120-
CCLayerColor* loadingBarBG1 = CCLayerColor::create(ccColor4B{239,50,61,255});
121-
loadingBarBG1->setContentSize({myself->m_fields->loadingScaleX*200+2, myself->m_fields->loadingScaleY*5+2});
122-
loadingBarBG1->ignoreAnchorPointForPosition(false);
123-
loadingBarBG1->setAnchorPoint({0, 0.5});
124-
loadingBarBG1->setID("loading-bar-bg1"_spr);
125-
126-
loadingBarBG1->setPosition({winSize.width/2-100*myself->m_fields->loadingScaleX-1.0f, 60});
127-
self->addChild(loadingBarBG1);
128-
129-
CCLayerColor* loadingBar = CCLayerColor::create(ccColor4B{255,255,255,255});
130-
loadingBar->setContentSize({1, 5});
131-
loadingBar->ignoreAnchorPointForPosition(false);
132-
loadingBar->setAnchorPoint({0, 0.5});
133-
loadingBar->setScaleX(myself->m_fields->loadingScaleX);
134-
loadingBar->setScaleY(myself->m_fields->loadingScaleY);
135-
136-
loadingBar->setPosition({winSize.width/2-100*myself->m_fields->loadingScaleX, 60});
137-
loadingBar->setID("loading-bar"_spr);
138-
self->addChild(loadingBar);
139-
140-
CCSprite* titleSprite = Utils::createSprite("/geode/unzipped/zalphalaneous.minecraft/resources/zalphalaneous.minecraft/mojangstudios.png");
141-
142-
titleSprite->setPosition({winSize.width/2, winSize.height/2});
143-
titleSprite->setScale(titleSprite->getScale()*0.3f);
144-
145-
self->addChild(titleSprite);
146-
147-
MCLabel* loadingText = MCLabel::create("", "/geode/unzipped/zalphalaneous.minecraft/resources/zalphalaneous.minecraft/minecraft.fnt");
148-
loadingText->setScale(0.4f);
149-
loadingText->setPosition({winSize.width/2, 30});
150-
151-
self->addChild(loadingText);
152-
loadingText->setID("loading-text"_spr);
153-
154-
CCScheduler::get()->scheduleSelector(schedule_selector(MyLoadingLayer::myUpdate), self, 0.0, false);
155-
156-
return true;
157-
}
158-
159-
$on_mod(Loaded) {
160-
Result<Hook*> hook = Mod::get()->hook(
161-
reinterpret_cast<void*>(geode::base::get() + 0x30db60),
162-
&LoadingLayer_init,
163-
"LoadingLayer::init",
164-
tulip::hook::TulipConvention::Thiscall
165-
);
166-
}
153+
};

0 commit comments

Comments
 (0)