Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unidokkan/log.h>
- #include <unidokkan/hook.h>
- #include <cocos/base/ccTypes.h>
- #include <cocos/ui/UIWidget.h>
- #include <cocos/2d/CCProgressTimer.h>
- #include <cocos/ui/UILayout.h>
- #include <cocos/base/CCDirector.h>
- #include <cocos/2d/CCLabel.h>
- #include <unidokkan/errors.h>
- #include <tuple>
- auto setKerning = DokkanFunction<void *(void *, float)>("_ZN7cocos2d5Label20setAdditionalKerningEf");
- auto getKerning = DokkanFunction<float(void *)>("_ZNK7cocos2d5Label20getAdditionalKerningEv");
- auto getVirtualRenderer = DokkanFunction<void *(void *)>("_ZN7cocos2d2ui4Text18getVirtualRendererEv");
- auto getVirtualRendererBM = DokkanFunction<void *(void *)>("_ZN7cocos2d2ui10TextBMFont18getVirtualRendererEv");
- auto getDescription = DokkanFunction<std::string (void *)>("_ZNK7cocos2d2ui10TextBMFont14getDescriptionEv");
- auto getBMFontSize = DokkanFunction<float (void *)>("_ZNK7cocos2d5Label13getBMFontSizeEv");
- auto setLineBreakNoSpace = DokkanFunction<void *(void *, bool)>("_ZN7cocos2d5Label24setLineBreakWithoutSpaceEb");
- auto setLineSpacing = DokkanFunction<void *(void *, float)>("_ZN7cocos2d5Label14setLineSpacingEf");
- auto setFontSizeBmFont = DokkanFunction<void *(void *, float)>("_ZN7cocos2d5Label13setBMFontSizeEf");
- auto setLineHeight = DokkanFunction<void *(void *, float)>("_ZN7cocos2d5Label13setLineHeightEf");
- bool Debug = false;
- void (*ori__cocos2d2ui4Text_generic)(void *, std::string) = nullptr;
- void cocos2d2ui4Text_generic(void *self, std::string string) {
- if (Debug == true) { UD_LOGI("cocos2d2ui4Text_generic : called"); }
- auto Description = getDescription(self);
- if (Debug == true) { UD_LOGI("cocos2d2ui4Text_generic : %s", Description.c_str()); }
- if (Description != "TextBMFont") {
- auto labelRenderer = getVirtualRenderer(self);
- if (Debug == true) { UD_LOGI("cocos2d2ui4Text_generic : getKerning"); }
- static float getKerning = getKerning(labelRenderer);
- if (Debug == true) { UD_LOGI("cocos2d2ui4Text_generic : %f", getKerning); }
- if (Debug == true) { UD_LOGI("cocos2d2ui4Text_generic : setKerning"); }
- static float getKerning = getKerning/2;
- setKerning(labelRenderer, getKerning);
- if (Debug == true) { UD_LOGI("cocos2d2ui4Text_generic : %f", getKerning); }
- if (Debug == true) { UD_LOGI("cocos2d2ui4Text_generic : Finishing !"); }
- } else {
- auto labelRenderer = getVirtualRenderer(self);
- if (Debug == true) { UD_LOGI("cocos2d2ui4Text_generic : TextBMFont : getKerning"); }
- static float getKerning = getKerning(labelRenderer);
- if (Debug == true) { UD_LOGI("cocos2d2ui4Text_generic : TextBMFont : %f", getKerning); }
- if (getKerning != BMKerning) {
- static float getKerning = getKerning/4;
- setKerning(labelRenderer, getKerning);
- if (Debug == true) { UD_LOGI("cocos2d2ui4Text_generic : TextBMFont : %f", getKerning); }
- }
- ori__cocos2d2ui4Text_generic(self, string);
- }
- }
- void (*ori__setBMFontSize_generic)(void *, const std::string &, const ud_cocos2d::Vec2 &, float) = nullptr;
- void setBMFontSize_generic(void *self, const std::string &fntfile, const ud_cocos2d::Vec2 &unk, float unk2) {
- if (Debug == true) { UD_LOGI("setup_Label_BMFont_generic : called"); }
- ori__setBMFontSize_generic(self,fntfile,unk,unk2);
- if (Debug == true) { UD_LOGI("setup_Label_BMFont_generic : getDescription"); }
- auto Description = getDescription(self);
- if (Debug == true) { UD_LOGI("setup_Label_BMFont_generic : %s", Description.c_str()); }
- if (Description == "TextBMFont") {
- if (Debug == true) { UD_LOGI("setup_Label_BMFont_generic : Thie is a TextBMFont let continue !"); }
- if (Debug == true) { UD_LOGI("setup_Label_BMFont_generic : %s", fntfile.c_str()); }
- if (fntfile == "fonts/ja/custom/btn_normal/btn_normal.fnt") {
- if (Debug == true) { UD_LOGI("setup_Label_BMFont_generic : Thie is a btn_normal let continue !"); }
- if (Debug == true) { UD_LOGI("setup_Label_BMFont_generic : getVirtualRendererBM"); }
- auto labelRendererBM = getVirtualRendererBM(self);
- if (Debug == true) { UD_LOGI("setup_Label_BMFont_generic : getBMFontSize"); }
- static float Font_size = getBMFontSize(labelRendererBM);
- if (Debug == true) { UD_LOGI("setup_Label_BMFont_generic : Calculate new Fontsize"); }
- static float FontSizeBmFont = (Font_size*100)/115;
- if (Debug == true) { UD_LOGI("setup_Label_BMFont_generic : setBMFontSize"); }
- setFontSizeBmFont(labelRendererBM, FontSizeBmFont);
- if (Debug == true) { UD_LOGI("setup_Label_BMFont_generic : setLineBreakNoSpace"); }
- setLineBreakNoSpace(labelRendererBM, true);
- float LineSpacing = (Font_size * 1.8) - FontSizeBmFont;
- if (Debug == true) { UD_LOGI("setup_Label_BMFont_generic : setLineSpacing"); }
- setLineSpacing(labelRendererBM, -10.0f);
- if (Debug == true) { UD_LOGI("setup_Label_BMFont_generic : setLineHeight"); }
- float LineHeight = FontSizeBmFont * 2.6;
- setLineHeight(labelRendererBM, LineHeight);
- if (Debug == true) { UD_LOGI("setup_Label_BMFont_generic : setKerning"); }
- setKerning(labelRendererBM, BMKerning);
- if (Debug == true) { UD_LOGI("setup_Label_BMFont_generic : Finishing [btn_normal]!"); }
- } else {
- if (Debug == true) { UD_LOGI("setup_Label_BMFont_generic : Thie is not a btn_normal !"); }
- }
- } else {
- if (Debug == true) { UD_LOGI("setup_Label_BMFont_generic : Thie is not a TextBMFont!"); }
- }
- }
- void (*ori__setAdditionalKerning_generic)(void *, float) = nullptr;
- void setAdditionalKerning_generic(void *self, float passed_kerning) {
- UD_LOGI("setAdditionalKerning_generic : called");
- UD_LOGI("setAdditionalKerning_generic : size is : %f", passed_kerning);
- UD_LOGI("setAdditionalKerning_generic : BMKerning is: %f", BMKerning);
- if (passed_kerning != BMKerning) {
- passed_kerning = 100.0f;
- }
- UD_LOGI("setAdditionalKerning_generic : newvalue is : %f", passed_kerning);
- ori__setAdditionalKerning_generic(self, passed_kerning);
- }
- void (*ori__setLineSpacing_generic)(void *, float) = nullptr;
- void setLineSpacing_generic(void *self, float LineSpacing) {
- if (Debug == true) { UD_LOGI("setLineSpacing_generic : called"); }
- auto Description = getDescription(self);
- if (Debug == true) { UD_LOGI("setLineSpacing_generic : %s", Description.c_str()); }
- if (LineSpacing != -10.0f) {
- LineSpacing = 0.0f;
- }
- ori__setLineSpacing_generic(self, LineSpacing);
- }
- void (*ori__enableOutline_generic)(void *, ud_cocos2d::Color4B &, int) = nullptr;
- void enableOutline_generic(void *self, ud_cocos2d::Color4B &outlineColor, int outlineSize) {
- if (Debug == true) { UD_LOGI("enableOutline_generic : called"); }
- if (Debug == true) { UD_LOGI("enableOutline_generic : size is : %d", outlineSize); }
- if (outlineSize >= 2) { outlineSize = outlineSize/2; }
- if (Debug == true) { UD_LOGI("enableOutline_generic : newvalue is : %d", outlineSize); }
- ori__enableOutline_generic(self, outlineColor, outlineSize);
- }
- extern "C" {
- [[maybe_unused]] __attribute__ ((visibility ("default")))
- int unidokkan_init_v4(HookLibV4* hook_lib) {
- UD_LOGI("English Buttons module loading...");
- if (hook_lib->size < sizeof(HookLibV4)) {
- return UD_MODULE_INVALID_SIZE;
- }
- if (hook_lib->version < kMinPatcherVer) {
- return UD_MODULE_INVALID_VERSION;
- }
- auto res = hook_lib->applyHooks(
- {
- {DOKKAN_LIB, "_ZN7cocos2d2ui4Text9setStringERKNSt6__ndk112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE", cocos2d2ui4Text_generic, &ori__cocos2d2ui4Text_generic},
- {DOKKAN_LIB, "_ZN7cocos2d5Label13enableOutlineERKNS_7Color4BEi", enableOutline_generic, &ori__enableOutline_generic},
- {DOKKAN_LIB, "_ZN7cocos2d5Label14setLineSpacingEf", setLineSpacing_generic, &ori__setLineSpacing_generic},
- {DOKKAN_LIB, "_ZN7cocos2d2ui10TextBMFont10setFntFileERKNSt6__ndk112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE", setBMFontSize_generic, &ori__setBMFontSize_generic},
- }
- );
- if (!res) {
- return UD_MODULE_ERROR;
- }
- UD_LOGI("English Buttons successfully loaded.");
- return UD_MODULE_SUCCESS;
- }
- }
Add Comment
Please, Sign In to add comment