diff --git a/api/api.cpp b/api/api.cpp index c2b8a16..e72fd2a 100644 --- a/api/api.cpp +++ b/api/api.cpp @@ -8,7 +8,7 @@ namespace gdl { static std::unordered_map> apiStrings; Language getCurrentLanguage() { - return (Language)Mod::get()->getSavedValue("language-id"); + return (Language)Mod::get()->getSavedValue("language-id", Language::GDL_RUSSIAN); } const char* getLanguageName(Language language) { diff --git a/libs/utf8 b/libs/utf8 index aed5828..b26a5f7 160000 --- a/libs/utf8 +++ b/libs/utf8 @@ -1 +1 @@ -Subproject commit aed58281cf45838bdb7296e3109bd5a633d677ed +Subproject commit b26a5f718f4f370af1852a0d5c6ae8fa031ba7d0 diff --git a/libs/zydis b/libs/zydis index 5a68f63..bffbb61 160000 --- a/libs/zydis +++ b/libs/zydis @@ -1 +1 @@ -Subproject commit 5a68f639e4f01604cc7bfc8d313f583a8137e3d3 +Subproject commit bffbb610cfea643b98e87658b9058382f7522807 diff --git a/src/hooks.cpp b/src/hooks.cpp index 0942bd2..01f1fd5 100644 --- a/src/hooks.cpp +++ b/src/hooks.cpp @@ -16,121 +16,121 @@ using namespace geode::prelude; -class $modify(MultilineBitmapFont) { - struct Fields { - float m_textScale; - std::string m_fontName; - float m_maxWidth; - }; - - gd::string readColorInfo(gd::string s) { - std::string str = s; - - std::string str2; - for (auto it = str.begin(); it != str.end();) { - auto cp = utf8::next(it, str.end()); - str2 += __isascii(cp) ? (char)cp : 'W'; - } - - return MultilineBitmapFont::readColorInfo(str2); - } - - // bool initWithFont(const char* p0, gd::string p1, float p2, float p3, cocos2d::CCPoint p4, int p5, bool colorsDisabled) { - // log::debug("string!!! {} {} {}", p1.size(), p1.capacity(), p1.c_str()); - // m_fields->m_textScale = p2; - // m_fields->m_fontName = p0; - // m_fields->m_maxWidth = p3; - // // log::debug("MBF;{};{};{};{}", m_fields->m_textScale, m_fields->m_fontName, (std::string)p1, p3); - - // auto notags = std::regex_replace((std::string)p1, std::regex("()|(<\\/c>)|()|()|(<\\/s>)|()|(<\\/i>)"), ""); - // if (!MultilineBitmapFont::initWithFont(p0, notags, p2, p3, p4, p5, true)) - // return false; - - // if (!colorsDisabled) { - // m_tagsArray = CCArray::create(); - // m_tagsArray->retain(); - - // MultilineBitmapFont::readColorInfo(p1); - - // for (auto i = 0u; i < m_tagsArray->count(); i++) { - // auto tag = (TextStyleSection*)(m_tagsArray->objectAtIndex(i)); - - // if (tag->m_end == -1 && tag->m_type == 4) { - // auto child = (CCFontSprite*)m_lettersArray->objectAtIndex(tag->m_start); - // if (child) { - // child->m_delayTime = tag->m_delayTime; - // } - // } else { - // for (auto i = tag->m_start; i <= tag->m_end; i++) { - // auto child = (CCFontSprite*)(m_lettersArray->objectAtIndex(i)); - // if (!child) - // continue; - - // switch (tag->m_type) { - // case 1: { - // child->setColor(tag->m_col); - // } break; - // case 2: { - // child->m_isInstant = true; - // child->m_instantValue = tag->m_instantNum; - // } break; - // case 3: { - // child->m_thisTagNumber = i; - // child->m_shakeVal1 = (float)tag->m_shakeNum1; - // child->m_shakeVal2 = tag->m_shakeNum2 <= 0 ? 0.0f : 1.0f / tag->m_shakeNum2; - // } break; - // default: - // break; - // } - // } - // } - // } - - // m_tagsArray->release(); - // m_tagsArray = nullptr; - // } - - // return true; - // } - - gd::string stringWithMaxWidth(gd::string p0, float scale, float scaledW) { - auto width = m_fields->m_maxWidth; - - std::string str = p0; - if (auto pos = str.find('\n'); pos != std::string::npos) { - str = str.substr(0, pos); - } - - auto lbl = CCLabelBMFont::create("", m_fields->m_fontName.c_str()); - lbl->setScale(m_fields->m_textScale); - - bool overflown = false; - std::string current; - for (auto it = str.begin(); it < str.end();) { - auto cp = utf8::next(it, str.end()); - utf8::append(cp, current); - - // auto x = cocos2d::FNTConfigLoadFile("chatFont.fnt"); - // auto y = x->m_pFontDefDictionary; - - lbl->setString(current.c_str()); - if (lbl->getScaledContentSize().width > width) { - overflown = true; - break; - } - } - - if (overflown) { - if (auto pos = current.rfind(' '); pos != std::string::npos) { - current.erase(current.begin() + pos, current.end()); - } - } else { - current += " "; - } - - return current; - } -}; +// class $modify(MultilineBitmapFont) { +// struct Fields { +// float m_textScale; +// std::string m_fontName; +// float m_maxWidth; +// }; + +// gd::string readColorInfo(gd::string s) { +// std::string str = s; + +// std::string str2; +// for (auto it = str.begin(); it != str.end();) { +// auto cp = utf8::next(it, str.end()); +// str2 += __isascii(cp) ? (char)cp : 'W'; +// } + +// return MultilineBitmapFont::readColorInfo(str2); +// } + +// // bool initWithFont(const char* p0, gd::string p1, float p2, float p3, cocos2d::CCPoint p4, int p5, bool colorsDisabled) { +// // log::debug("string!!! {} {} {}", p1.size(), p1.capacity(), p1.c_str()); +// // m_fields->m_textScale = p2; +// // m_fields->m_fontName = p0; +// // m_fields->m_maxWidth = p3; +// // // log::debug("MBF;{};{};{};{}", m_fields->m_textScale, m_fields->m_fontName, (std::string)p1, p3); + +// // auto notags = std::regex_replace((std::string)p1, std::regex("()|(<\\/c>)|()|()|(<\\/s>)|()|(<\\/i>)"), ""); +// // if (!MultilineBitmapFont::initWithFont(p0, notags, p2, p3, p4, p5, true)) +// // return false; + +// // if (!colorsDisabled) { +// // m_tagsArray = CCArray::create(); +// // m_tagsArray->retain(); + +// // MultilineBitmapFont::readColorInfo(p1); + +// // for (auto i = 0u; i < m_tagsArray->count(); i++) { +// // auto tag = (TextStyleSection*)(m_tagsArray->objectAtIndex(i)); + +// // if (tag->m_end == -1 && tag->m_type == 4) { +// // auto child = (CCFontSprite*)m_lettersArray->objectAtIndex(tag->m_start); +// // if (child) { +// // child->m_delayTime = tag->m_delayTime; +// // } +// // } else { +// // for (auto i = tag->m_start; i <= tag->m_end; i++) { +// // auto child = (CCFontSprite*)(m_lettersArray->objectAtIndex(i)); +// // if (!child) +// // continue; + +// // switch (tag->m_type) { +// // case 1: { +// // child->setColor(tag->m_col); +// // } break; +// // case 2: { +// // child->m_isInstant = true; +// // child->m_instantValue = tag->m_instantNum; +// // } break; +// // case 3: { +// // child->m_thisTagNumber = i; +// // child->m_shakeVal1 = (float)tag->m_shakeNum1; +// // child->m_shakeVal2 = tag->m_shakeNum2 <= 0 ? 0.0f : 1.0f / tag->m_shakeNum2; +// // } break; +// // default: +// // break; +// // } +// // } +// // } +// // } + +// // m_tagsArray->release(); +// // m_tagsArray = nullptr; +// // } + +// // return true; +// // } + +// gd::string stringWithMaxWidth(gd::string p0, float scale, float scaledW) { +// auto width = m_fields->m_maxWidth; + +// std::string str = p0; +// if (auto pos = str.find('\n'); pos != std::string::npos) { +// str = str.substr(0, pos); +// } + +// auto lbl = CCLabelBMFont::create("", m_fields->m_fontName.c_str()); +// lbl->setScale(m_fields->m_textScale); + +// bool overflown = false; +// std::string current; +// for (auto it = str.begin(); it < str.end();) { +// auto cp = utf8::next(it, str.end()); +// utf8::append(cp, current); + +// // auto x = cocos2d::FNTConfigLoadFile("chatFont.fnt"); +// // auto y = x->m_pFontDefDictionary; + +// lbl->setString(current.c_str()); +// if (lbl->getScaledContentSize().width > width) { +// overflown = true; +// break; +// } +// } + +// if (overflown) { +// if (auto pos = current.rfind(' '); pos != std::string::npos) { +// current.erase(current.begin() + pos, current.end()); +// } +// } else { +// current += " "; +// } + +// return current; +// } +// }; class $modify(CCTextureCache) { cocos2d::CCTexture2D* addImage(const char* name, bool idk) { @@ -166,7 +166,9 @@ class $modify(CCLabelBMFont) { class $modify(LoadingLayer){ void loadAssets(){ + log::debug("load step {}", this->m_loadStep); if(this->m_loadStep == 11 && gdl::getCurrentLanguage() != gdl::GDL_ENGLISH){ + log::error("hiii"); auto plist = Mod::get()->getResourcesDir() / fmt::format("GDL_TranslatedFrames-{}.plist", gdl::getLanguageCodename(gdl::getCurrentLanguage())); auto png = Mod::get()->getResourcesDir() / fmt::format("GDL_TranslatedFrames-{}.png", gdl::getLanguageCodename(gdl::getCurrentLanguage())); @@ -211,12 +213,13 @@ void gd_string_assign_hk(void* self, char* src, size_t len) { $execute { #ifdef GEODE_IS_WINDOWS - constexpr auto GD_STR_ASSIGN_ADDR = 0x3BE50; - gd_string_assign_o = reinterpret_cast(base::get() + GD_STR_ASSIGN_ADDR); - auto res2 = Mod::get()->hook((void*)(base::get() + GD_STR_ASSIGN_ADDR), gd_string_assign_hk, "gd::string::assign", tulip::hook::TulipConvention::Thiscall).err(); - if (res2 != std::nullopt) { - log::error("Failed to hook gd::string::assign because of: {}", res2); - } + // constexpr auto GD_STR_ASSIGN_ADDR = 0x3BE50; // OLD (2.206?) + // constexpr auto GD_STR_ASSIGN_ADDR = 0x3cca0; + // gd_string_assign_o = reinterpret_cast(base::get() + GD_STR_ASSIGN_ADDR); + // auto res2 = Mod::get()->hook((void*)(base::get() + GD_STR_ASSIGN_ADDR), gd_string_assign_hk, "gd::string::assign", tulip::hook::TulipConvention::Thiscall).err(); + // if (res2 != std::nullopt) { + // log::error("Failed to hook gd::string::assign because of: {}", res2); + // } // constexpr auto GD_STR_APPEND_ADDR = 0x21DE0; // gd_string_append_o = reinterpret_cast(base::get() + GD_STR_APPEND_ADDR); diff --git a/src/main.cpp b/src/main.cpp index 24316d3..5d824e3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,6 +42,6 @@ using namespace geode::prelude; // #endif patches::patchStrings(); - gdl::addTranslations("language", {{gdl::GDL_ENGLISH, "Language"}, {gdl::GDL_RUSSIAN, "Язык"}}); - gdl::addTranslations("apply", {{gdl::GDL_ENGLISH, "Apply"}, {gdl::GDL_RUSSIAN, "Применить"}}); + // gdl::addTranslations("language", {{gdl::GDL_ENGLISH, "Language"}, {gdl::GDL_RUSSIAN, "Язык"}}); + // gdl::addTranslations("apply", {{gdl::GDL_ENGLISH, "Apply"}, {gdl::GDL_RUSSIAN, "Применить"}}); }; \ No newline at end of file diff --git a/src/menu.cpp b/src/menu.cpp index 0494297..b50970c 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -4,37 +4,37 @@ using namespace geode::prelude; -class $modify(GDLOptionsLayer, OptionsLayer) { - struct Fields { - bool m_clickedLanguage = false; - }; - - void onLanguage(CCObject* sender) { - m_fields->m_clickedLanguage = true; - this->hideLayer(false); - } - - virtual void customSetup() { - OptionsLayer::customSetup(); - - auto buttonsMenu = (CCMenu*)this->m_mainLayer->getChildren()->objectAtIndex(4); - if(!buttonsMenu) - return; - - auto languageBtn = CCMenuItemSpriteExtra::create(ButtonSprite::create("language"_gdl, "goldFont.fnt", "GJ_button_01.png"), this, SEL_MenuHandler(&GDLOptionsLayer::onLanguage)); - languageBtn->setPosition(0, -115); - buttonsMenu->addChild(languageBtn); - } - - virtual void layerHidden() { - if(m_fields->m_clickedLanguage) { - auto languageLayer = LanguageLayer::create(); - this->getParent()->addChild(languageLayer); - languageLayer->setZOrder(100); - languageLayer->showLayer(false); - m_fields->m_clickedLanguage = false; - } - - OptionsLayer::layerHidden(); - } -}; +// class $modify(GDLOptionsLayer, OptionsLayer) { +// struct Fields { +// bool m_clickedLanguage = false; +// }; + +// void onLanguage(CCObject* sender) { +// m_fields->m_clickedLanguage = true; +// this->hideLayer(false); +// } + +// virtual void customSetup() { +// OptionsLayer::customSetup(); + +// auto buttonsMenu = (CCMenu*)this->m_mainLayer->getChildren()->objectAtIndex(4); +// if(!buttonsMenu) +// return; + +// auto languageBtn = CCMenuItemSpriteExtra::create(ButtonSprite::create("language"_gdl, "goldFont.fnt", "GJ_button_01.png"), this, SEL_MenuHandler(&GDLOptionsLayer::onLanguage)); +// languageBtn->setPosition(0, -115); +// buttonsMenu->addChild(languageBtn); +// } + +// virtual void layerHidden() { +// if(m_fields->m_clickedLanguage) { +// auto languageLayer = LanguageLayer::create(); +// this->getParent()->addChild(languageLayer); +// languageLayer->setZOrder(100); +// languageLayer->showLayer(false); +// m_fields->m_clickedLanguage = false; +// } + +// OptionsLayer::layerHidden(); +// } +// }; diff --git a/src/patches.cpp b/src/patches.cpp index 208b7f5..a1733e8 100644 --- a/src/patches.cpp +++ b/src/patches.cpp @@ -10,11 +10,12 @@ void patches::fixCyrillicP() { // this fixes a bug when comments with cyrillic Р (and other letters containing byte 0xA0) are replaced with something by robtop and break the unicode sequence. // We patch any other unused byte instead of 0xA0. #if defined(GEODE_IS_WINDOWS) - auto res = Mod::get()->patch((void*)(base::get() + 0xB44E6), {0x48, 0xC7, 0xC0, 0x01, 0x00, 0x00, 0x00}); // mov rax, 0x01 + // old address: 0xB44E6 + auto res = Mod::get()->patch((void*)(base::get() + 0xb61d6), {0x48, 0xC7, 0xC0, 0x01, 0x00, 0x00, 0x00}); // mov rax, 0x01 #elif defined(GEODE_IS_ANDROID32) - auto res = Mod::get()->patch((void*)(base::get() + 0x93E795), {0x01}); + // auto res = Mod::get()->patch((void*)(base::get() + 0x93E795), {0x01}); #elif defined(GEODE_IS_ANDROID64) - auto res = Mod::get()->patch((void*)(base::get() + 0xE7F440), {0x01}); + // auto res = Mod::get()->patch((void*)(base::get() + 0xE7F440), {0x01}); #else #error "Unsupported platform" #endif @@ -51,13 +52,13 @@ void patches::patchStrings() { // // res2 = gdl::patchStdStringRel("This is a very very long string1!This is a very very long string2!This is a very very long string3!This is a very very long string4!This is a very very long string5!", 0x31561F, 0x31562F, 0x315638, {0x315641, 0x315648, 0x31564B, 0x315652, 0x315656, 0x31565C, 0x31565F, 0x315666, 0x31566A}); // log::debug("res {}", res2); - bool res2; - res2 = gdl::patchStdString2("Hello world! This is a long enough string!", {{base::get() + 0x31561F, 0x4F}}, base::get() + 0x31562A); // quit text - log::debug("res {}", res2); - res2 = gdl::patchStdString2("Test!", {{base::get() + 0x461B64, 0x24}}, base::get() + 0x461B76); // cancel btn in comments posting menu - log::debug("res {}", res2); - res2 = gdl::patchStdString2("Hello!", {{base::get() + 0x67032, 0x2a}}, base::get() + 0x67052); // "Ease Out" which is inlined - log::debug("res {}", res2); + // bool res2; + // res2 = gdl::patchStdString2("Hello world! This is a long enough string!", {{base::get() + 0x31561F, 0x4F}}, base::get() + 0x31562A); // quit text + // log::debug("res {}", res2); + // res2 = gdl::patchStdString2("Test!", {{base::get() + 0x461B64, 0x24}}, base::get() + 0x461B76); // cancel btn in comments posting menu + // log::debug("res {}", res2); + // res2 = gdl::patchStdString2("Hello!", {{base::get() + 0x67032, 0x2a}}, base::get() + 0x67052); // "Ease Out" which is inlined + // log::debug("res {}", res2); #endif auto languageID = gdl::getCurrentLanguage();