Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <dokkan/defs.h>
- #include <dokkan/files.h>
- #include <dokkan/cards.h>
- #include <unidokkan/log.h>
- #include <unidokkan/hook.h>
- #include <unidokkan/errors.h>
- #include <dokkan/instances.h>
- #include "cocos/base/CCData.h"
- #include <cocos/ui/UIWidget.h>
- #include <cocos/ui/UIButton.h>
- #include <cocos/ui/UILayout.h>
- #include <unidokkan/ui/button.h>
- #include <restclient-cpp/restclient.h>
- using namespace UniDokkan::UI;
- using json = nlohmann::json;
- namespace cocos2d = ud_cocos2d;
- int Clicked_Category = -1;
- int Clicked_Status = 0;
- int Generated = 0;
- std::vector<int> Categories_List;
- auto setFlash = DokkanFunction<void(void *flash_view, const std::string lwf_path, const std::string scene_name)>("_ZN7cocos2d2ui9FlashView8setFlashERKNSt6__ndk112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEESA_");
- auto setPositionX = DokkanFunction<void *(void *, float)>("_ZN7cocos2d4Node12setPositionXEf");
- auto setPositionY = DokkanFunction<void *(void *, float)>("_ZN7cocos2d4Node12setPositionYEf");
- auto setVisible = DokkanFunction<void(void *, bool)>("_ZN7cocos2d4Node10setVisibleEb");
- auto setZOrder = DokkanFunction<void(void *, int)>("_ZN7cocos2d4Node9setZOrderEi");
- auto getZOrderEv = DokkanFunction<int (void *)>("_ZNK7cocos2d4Node9getZOrderEv");
- auto getChildByName = DokkanFunction<void *(void *, std::string)>("_ZNK7cocos2d4Node14getChildByNameERKNSt6__ndk112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE");
- static auto FileUtilsCustom_CpkLoader = DokkanFunction<ud_cocos2d::Data (const std::string &filename, bool text_file)>("_Z25FileUtilsCustom_CpkLoaderRKNSt6__ndk112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEb");
- std::string ReadTextFile(const std::string &filepath) {
- auto data = FileUtilsCustom_CpkLoader(filepath, true);
- ssize_t data_size;
- auto buf = data.takeBuffer(&data_size);
- return {buf, buf+data_size};
- }
- void *(*ori_DialogCardCategorySelector)(void *, const std::shared_ptr<UniDokkan::Dokkan::CardCategory> &, bool) = nullptr;
- void *DialogCardCategorySelector(void *self, const std::shared_ptr<UniDokkan::Dokkan::CardCategory> &category, bool selected) {
- Clicked_Category = category->id; //Global Variable of category ID
- auto DialogCardCatSel = ori_DialogCardCategorySelector(self, category, selected);
- int b2i = 0;
- int category_id = category->id;
- std::string category_name = category->name;
- if (!selected){ b2i = 0; } else { b2i = 1; }
- Clicked_Status = b2i;
- auto file_utils = UniDokkan::Dokkan::cocos2d_FileUtils_getInstance();
- std::string Json_path = "outgame/effect/animated_categories/ID.json";
- auto json_data = nlohmann::json::parse(ReadTextFile(Json_path));
- if (json_data["Categories_supported"].is_null() == false && Generated == 0){
- for (auto& it : json_data["Categories_supported"]){
- Categories_List.push_back(it.get<int>());
- }
- Generated = 1;
- }
- return DialogCardCatSel;
- }
- ud_cocos2d::ui::Button *(*ori__LayoutCharactermenuChaCategoryChaCategoryLabelSort_getFlaButton)(ud_cocos2d::ui::Widget *self, bool created) = nullptr;
- ud_cocos2d::ui::Button *LayoutCharactermenuChaCategoryChaCategoryLabelSort_getFlaButton(ud_cocos2d::ui::Widget *self, bool created) {
- auto flash_button = ori__LayoutCharactermenuChaCategoryChaCategoryLabelSort_getFlaButton(self, created);
- auto setFlash = DokkanFunction<void(void *flash_view, const std::string lwf_path, const std::string scene_name)>("_ZN7cocos2d2ui9FlashView8setFlashERKNSt6__ndk112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEESA_");
- auto getFlaEb = DokkanFunction<void *(void *, bool)>("_ZN21LayoutMypageMypBanner10getFlaLoadEb");
- if (Clicked_Category >= 1) {
- auto HasAChild = getChildByName(self,"fla_load");
- if (HasAChild == nullptr) {
- std::string LWF_Path = "outgame/effect/animated_categories/cat_00000.lwf";
- std::string scene_name = "cat_" + std::to_string(Clicked_Category);
- auto FlashStnBgEb = getFlaEb(self, true);
- setPositionX(FlashStnBgEb, 148.0f);
- setPositionY(FlashStnBgEb, 42.0f);
- setFlash(FlashStnBgEb,LWF_Path,scene_name);
- setZOrder(FlashStnBgEb,1);
- if (std::find(Categories_List.begin(), Categories_List.end(), Clicked_Category) != Categories_List.end()) {
- setZOrder(FlashStnBgEb,1);
- }
- } else {
- UD_LOGI("child found - L:64");
- int Curr_Zorder = getZOrderEv(HasAChild);
- if (Curr_Zorder == 1) {
- setZOrder(HasAChild,-1);
- } else if (Curr_Zorder == -1) {
- if (std::find(Categories_List.begin(), Categories_List.end(), Clicked_Category) != Categories_List.end()) {
- setZOrder(HasAChild,1);
- }
- }
- }
- }
- Clicked_Category = -1;
- return flash_button;
- }
- extern "C" {
- [[maybe_unused]] __attribute__ ((visibility ("default")))
- int unidokkan_init_v4(HookLibV4* hook_lib) {
- UD_LOGI("Animated categories filter label 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, "_ZN12FilterDialog26DialogCardCategorySelectorINSt6__ndk110shared_ptrI14UserCardFilterEEE21refreshCategoryButtonERKNS2_I12CardCategoryEEb", DialogCardCategorySelector, &ori_DialogCardCategorySelector},
- {DOKKAN_LIB, "_ZN50LayoutCharactermenuChaCategoryChaCategoryLabelSort12getFlaButtonEb", LayoutCharactermenuChaCategoryChaCategoryLabelSort_getFlaButton, &ori__LayoutCharactermenuChaCategoryChaCategoryLabelSort_getFlaButton},
- });
- if (!res) { return UD_MODULE_ERROR; }
- UD_LOGI("Animated categories filter label successfully loaded.");
- return UD_MODULE_SUCCESS;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement