Skip to content

Commit

Permalink
better mh compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
cgytrus committed May 29, 2022
1 parent 89d88e6 commit 709a7a7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ add_subdirectory(libraries/boost/regex)
target_link_libraries(${PROJECT_NAME} boost_regex)

target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/libraries/hackpro/hackpro.lib)
target_link_options(${PROJECT_NAME} PRIVATE "/DELAYLOAD:hackpro.dll")

target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/libraries/cocos-headers/cocos2dx/libcocos2d.lib)
# not needed most of the time
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ A Geometry Dash mod that makes your game very uwu

partially based on [Daniel-Liu-c0deb0t/uwu](https://github.com/Daniel-Liu-c0deb0t/uwu), [cos8oih/owoifiew](https://github.com/cos8oih/owoifiew), [@Black_is_Back/OWOifier](https://replit.com/@Black_is_Back/OWOifier) and me

requires mhv6 to change settings
requires mhv7 to change settings

## Features
- uwu
Expand Down
1 change: 1 addition & 0 deletions libraries/boost/regex
Submodule regex added at 177ee2
18 changes: 14 additions & 4 deletions src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,22 @@
#include "extensions2.h"
#include "uwuifier.h"

static inline bool mhLoaded() { return GetModuleHandle(TEXT("hackpro.dll")); }

bool enabled = true;
bool enabledInLevels = false;

bool ignoreUwuifying = false;
void (__thiscall* CCLabelBMFont_setString)(CCLabelBMFont* self, const char *newString, bool needUpdateLabel);
void __fastcall CCLabelBMFont_setString_H(CCLabelBMFont* self, void*, const char *newString, bool needUpdateLabel) {
void __fastcall CCLabelBMFont_setCString_H(CCLabelBMFont* self, void*, const char *newString, bool needUpdateLabel) {
auto parent = self->getParent();
// same as comment on the hook below
if(!enabled || !enabledInLevels && (ignoreUwuifying || parent != nullptr && typeid(*parent) == typeid(gd::GameObject))) {
// best if statement i've ever written
if(!enabled ||
// if we have megahack installed, don't change the "Progress Bar" text,
// let mh change it to "Bar" first
mhLoaded() && strcmp(newString, "Progress Bar") == 0 ||
// don't uwuify in levels
!enabledInLevels && (ignoreUwuifying || parent != nullptr && typeid(*parent) == typeid(gd::GameObject))) {
CCLabelBMFont_setString(self, newString, needUpdateLabel);
return;
}
Expand Down Expand Up @@ -65,7 +72,7 @@ DWORD WINAPI mainThread(void* hModule) {

MH_CreateHook(
reinterpret_cast<void*>(cocos2dBase + 0x9fb60),
CCLabelBMFont_setString_H,
CCLabelBMFont_setCString_H,
reinterpret_cast<void**>(&CCLabelBMFont_setString)
);

Expand All @@ -89,6 +96,9 @@ DWORD WINAPI mainThread(void* hModule) {

MH_EnableHook(MH_ALL_HOOKS);

if(!mhLoaded())
return 0;

auto ext = MegaHackExt::Window::Create(uwuifier::uwuify("uwuifier").c_str());

auto duplicateCharactersAmountUi = MegaHackExt::Spinner::Create("", "");
Expand Down

0 comments on commit 709a7a7

Please sign in to comment.