Advertisement
Baoulettes

dokkan_stuff

Mar 14th, 2020
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.58 KB | None | 0 0
  1. #include <fmt/format.h>
  2. #include <dokkan/files.h>
  3. #include <dokkan/instances.h>
  4. #include <unidokkan/ui/defs.h>
  5. #include <unidokkan/ui/scene.h>
  6. #include <unidokkan/ui/button.h>
  7. #include <unidokkan/ui/layout.h>
  8. #include <unidokkan/ui/imageview.h>
  9. #include <unidokkan/ui/progresstimer.h>
  10. #include <cocos/ui/UIButton.h>
  11. #include <cocos/base/CCDirector.h>
  12. #include <cocos/2d/CCActionInterval.h>
  13. #include "main.h"
  14. #include <string>
  15. using namespace UniDokkan::UI;
  16. namespace cocos2d = ud_cocos2d;
  17. auto PlayBGM    =   DokkanFunction<void *(void*, int, double, bool)>("_ZNK22OutGameSoundPlayerBase7playBgmEidb");
  18. auto SetMute    =   DokkanFunction<void *(void*, bool)>("_ZN5Sound3Bgm4muteEb");
  19. int counter     =   0;
  20. int in_line     =   0;
  21. void(*ori__CharacterMenuScene_onEnter)(void *self)= nullptr;
  22. void CharacterMenuScene_onEnter(void *self) {
  23.     ori__CharacterMenuScene_onEnter(self);
  24.     auto screen_size = cocos2d_Director_getVisibleSize(UniDokkan::Dokkan::cocos2d_Director_getInstance());
  25.     auto Music_player_1 = new Scene();
  26.     Music_player_1->retain();
  27.     //Scene music Player
  28.     auto background_image = new ImageView("background", Music_player_1);
  29.     background_image->loadImage("layout/image/common/com_bg_menu.png");
  30.     background_image->setAnchorPoint(Node::AnchorCenter);
  31.     auto insets = cocos2d::Rect(0, 0, 0, 0);
  32.     background_image->scale9(&insets);
  33.     background_image->setContentSize(screen_size);
  34.     background_image->setPosition({screen_size.width/2,screen_size.height/2});
  35.     auto layout = new Layout("Absolute_sized", Music_player_1, cocos2d::ui::Layout::Type::ABSOLUTE);
  36.     layout->setContentSize(screen_size - cocos2d::Size(100, 100));
  37.     layout->setPosition({50, 50});
  38.     //{line_h/2, 10.0f} bottom left + margin
  39.    
  40.     // Add title :)
  41.    
  42.     float line_v    =   screen_size.height - 180.0f; // header
  43.     float line_h    =   screen_size.width/4;
  44.     line_h          =   line_h - 10.0f;
  45.     float add_h     =   140.0f; // guessing width of btn
  46.     auto firststpos =   background_image->getPosition();
  47.     float middlef   =   screen_size.width/2;
  48.    
  49.     for (int i = 1; i < 999; i++) {
  50.         auto path = fmt::format("bgm/bgm_{:#03d}.awb", i);
  51.         UD_LOGI("Check file test : %s", path.c_str());
  52.         auto file_utils = UniDokkan::Dokkan::cocos2d_FileUtils_getInstance();
  53.         if (UniDokkan::Dokkan::cocos2d_FileUtils_isFileExistWithoutCpk(file_utils, path)) {
  54.             if (in_line == 7) {
  55.                 in_line = 0;
  56.                 counter = 0;
  57.                 line_v  =   line_v - 30.0f;
  58.                 line_h  =   screen_size.width/4;
  59.                 line_h  =   line_h - 10.0f;
  60.             }
  61.             if (counter == 0) {
  62.                 line_h  =   screen_size.width/4;
  63.             } else {
  64.                 line_h  =   line_h + add_h;
  65.             }
  66.             counter++;
  67.             in_line++;
  68.             int curr_id                 =   i;
  69.             std::string curr_id_str     =   std::to_string(i);
  70.             auto play_bgm = new Button(curr_id_str, layout);
  71.             play_bgm->setDefaultImage("layout/image/common/btn/com_btn_16_yellow.png");
  72.             play_bgm->setCaption(curr_id_str);
  73.             play_bgm->setFontSize(30.0f);
  74.             play_bgm->setPosition({line_h/2, line_v});
  75.             play_bgm->setScale(0.8, 0.8);
  76.             play_bgm->setAnchorPoint(Node::AnchorCenter);
  77.             play_bgm->setFontColor(cocos2d::Color3B::BLACK);
  78.             play_bgm->addClickEventListener([=](Widget*) {
  79.                 PlayBGM(self,curr_id,0,true);
  80.             });
  81.         } else {
  82.             //UD_LOGI("File Not Exist : %s", path.c_str());
  83.         }
  84.     }
  85.  
  86.     auto close_list = new Button("close_list", layout);
  87.     close_list->setDefaultImage("layout/image/common/btn/com_btn_01_orange.png");
  88.     close_list->setCaption("Fermer");
  89.     close_list->setFontSize(30.0f);
  90.     close_list->setPosition({middlef - 5.0f, 15.0f});
  91.     close_list->setAnchorPoint(Node::AnchorCenter);
  92.     close_list->setFontColor(cocos2d::Color3B::BLACK);
  93.     close_list->addClickEventListener([=](Widget*) {
  94.         //Scene::popCurrent();
  95.         TransitionFade transition_fade(1.0f, cocos2d::Color3B::BLACK);
  96.         ori__CharacterMenuScene_onEnter(self);
  97.         Music_player_1->popCurrent();
  98.     });
  99.        
  100.     //Home Menu button
  101.     auto left_icon = new ImageView("menu_icon_addon", self, 200);
  102.     left_icon->loadImage("layout/image/common/btn/menu_icon_addon.png");
  103.     left_icon->setAnchorPoint(Node::AnchorCenter);
  104.     left_icon->setPosition({370.0f, 277.0f});
  105.     auto btn_label = new ImageView("menu_title_addon", self, 200);
  106.     btn_label->loadImage("layout/image/common/btn/menu_title_addon.png");
  107.     btn_label->setAnchorPoint(Node::AnchorCenter);
  108.     btn_label->setPosition({510.0f, 277.0f});
  109.     auto open_player = new Button("open_playerbtn", self, 100);
  110.     open_player->setDefaultImage("llayout/image/common/btn/com_btn_menu_chara_gray.png");
  111.     open_player->setGravity(cocos2d::ui::LinearLayoutParameter::LinearGravity::CENTER_HORIZONTAL);
  112.     open_player->setPosition({482.0f, 277.0f});
  113.     open_player->addClickEventListener([=](Widget*) {
  114.         TransitionFade transition_fade(1.0f, cocos2d::Color3B::BLACK);
  115.         Music_player_1->push();
  116.     });
  117.     //useless junks
  118.     /*for(int i=1; i<999; i++){
  119.         auto progress = progress_bar->getPercentage() + 10.0f;
  120.         progress_bar->setPercentage(progress, 0.1f);
  121.         auto id = std::to_string(i);
  122.         if (i <= 9) {id = "0" + id;};
  123.         if (i <= 99) {id = "0" + id;};
  124.         auto Path = "bgm/bgm_"+id+".awb";
  125.         std::ifstream fin(Path);
  126.         if (fin.fail()) {
  127.             std::string logstring = Path;
  128.             UD_LOGI("File Not Exist : %s", logstring.c_str()); 
  129.         } else {
  130.             std::string logstring = id;
  131.             UD_LOGI("File Exist : %s", logstring.c_str()); 
  132.         }
  133.     }*/
  134. }
  135. extern "C" {
  136. int unidokkan_init_v2(HookLib *hook_lib) {
  137.     auto res = hook_lib->applyHooks(
  138.         {
  139.             {DOKKAN_LIB, "_ZN18CharacterMenuScene7onEnterEv", reinterpret_cast<void *>(CharacterMenuScene_onEnter), reinterpret_cast<void **>(&ori__CharacterMenuScene_onEnter)},
  140.         }
  141.     );
  142.     if (!res) {
  143.         return 1;
  144.     }
  145.     return 0;
  146. }
  147.  
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement