Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fmt/format.h>
- #include <dokkan/files.h>
- #include <dokkan/instances.h>
- #include <unidokkan/ui/defs.h>
- #include <unidokkan/ui/scene.h>
- #include <unidokkan/ui/button.h>
- #include <unidokkan/ui/layout.h>
- #include <unidokkan/ui/imageview.h>
- #include <unidokkan/ui/progresstimer.h>
- #include <cocos/ui/UIButton.h>
- #include <cocos/base/CCDirector.h>
- #include <cocos/2d/CCActionInterval.h>
- #include "main.h"
- #include <string>
- using namespace UniDokkan::UI;
- namespace cocos2d = ud_cocos2d;
- auto PlayBGM = DokkanFunction<void *(void*, int, double, bool)>("_ZNK22OutGameSoundPlayerBase7playBgmEidb");
- auto SetMute = DokkanFunction<void *(void*, bool)>("_ZN5Sound3Bgm4muteEb");
- int counter = 0;
- int in_line = 0;
- void(*ori__CharacterMenuScene_onEnter)(void *self)= nullptr;
- void CharacterMenuScene_onEnter(void *self) {
- ori__CharacterMenuScene_onEnter(self);
- auto screen_size = cocos2d_Director_getVisibleSize(UniDokkan::Dokkan::cocos2d_Director_getInstance());
- auto Music_player_1 = new Scene();
- Music_player_1->retain();
- //Scene music Player
- auto background_image = new ImageView("background", Music_player_1);
- background_image->loadImage("layout/image/common/com_bg_menu.png");
- background_image->setAnchorPoint(Node::AnchorCenter);
- auto insets = cocos2d::Rect(0, 0, 0, 0);
- background_image->scale9(&insets);
- background_image->setContentSize(screen_size);
- background_image->setPosition({screen_size.width/2,screen_size.height/2});
- auto layout = new Layout("Absolute_sized", Music_player_1, cocos2d::ui::Layout::Type::ABSOLUTE);
- layout->setContentSize(screen_size - cocos2d::Size(100, 100));
- layout->setPosition({50, 50});
- //{line_h/2, 10.0f} bottom left + margin
- // Add title :)
- float line_v = screen_size.height - 180.0f; // header
- float line_h = screen_size.width/4;
- line_h = line_h - 10.0f;
- float add_h = 140.0f; // guessing width of btn
- auto firststpos = background_image->getPosition();
- float middlef = screen_size.width/2;
- for (int i = 1; i < 999; i++) {
- auto path = fmt::format("bgm/bgm_{:#03d}.awb", i);
- UD_LOGI("Check file test : %s", path.c_str());
- auto file_utils = UniDokkan::Dokkan::cocos2d_FileUtils_getInstance();
- if (UniDokkan::Dokkan::cocos2d_FileUtils_isFileExistWithoutCpk(file_utils, path)) {
- if (in_line == 7) {
- in_line = 0;
- counter = 0;
- line_v = line_v - 30.0f;
- line_h = screen_size.width/4;
- line_h = line_h - 10.0f;
- }
- if (counter == 0) {
- line_h = screen_size.width/4;
- } else {
- line_h = line_h + add_h;
- }
- counter++;
- in_line++;
- int curr_id = i;
- std::string curr_id_str = std::to_string(i);
- auto play_bgm = new Button(curr_id_str, layout);
- play_bgm->setDefaultImage("layout/image/common/btn/com_btn_16_yellow.png");
- play_bgm->setCaption(curr_id_str);
- play_bgm->setFontSize(30.0f);
- play_bgm->setPosition({line_h/2, line_v});
- play_bgm->setScale(0.8, 0.8);
- play_bgm->setAnchorPoint(Node::AnchorCenter);
- play_bgm->setFontColor(cocos2d::Color3B::BLACK);
- play_bgm->addClickEventListener([=](Widget*) {
- PlayBGM(self,curr_id,0,true);
- });
- } else {
- //UD_LOGI("File Not Exist : %s", path.c_str());
- }
- }
- auto close_list = new Button("close_list", layout);
- close_list->setDefaultImage("layout/image/common/btn/com_btn_01_orange.png");
- close_list->setCaption("Fermer");
- close_list->setFontSize(30.0f);
- close_list->setPosition({middlef - 5.0f, 15.0f});
- close_list->setAnchorPoint(Node::AnchorCenter);
- close_list->setFontColor(cocos2d::Color3B::BLACK);
- close_list->addClickEventListener([=](Widget*) {
- //Scene::popCurrent();
- TransitionFade transition_fade(1.0f, cocos2d::Color3B::BLACK);
- ori__CharacterMenuScene_onEnter(self);
- Music_player_1->popCurrent();
- });
- //Home Menu button
- auto left_icon = new ImageView("menu_icon_addon", self, 200);
- left_icon->loadImage("layout/image/common/btn/menu_icon_addon.png");
- left_icon->setAnchorPoint(Node::AnchorCenter);
- left_icon->setPosition({370.0f, 277.0f});
- auto btn_label = new ImageView("menu_title_addon", self, 200);
- btn_label->loadImage("layout/image/common/btn/menu_title_addon.png");
- btn_label->setAnchorPoint(Node::AnchorCenter);
- btn_label->setPosition({510.0f, 277.0f});
- auto open_player = new Button("open_playerbtn", self, 100);
- open_player->setDefaultImage("llayout/image/common/btn/com_btn_menu_chara_gray.png");
- open_player->setGravity(cocos2d::ui::LinearLayoutParameter::LinearGravity::CENTER_HORIZONTAL);
- open_player->setPosition({482.0f, 277.0f});
- open_player->addClickEventListener([=](Widget*) {
- TransitionFade transition_fade(1.0f, cocos2d::Color3B::BLACK);
- Music_player_1->push();
- });
- //useless junks
- /*for(int i=1; i<999; i++){
- auto progress = progress_bar->getPercentage() + 10.0f;
- progress_bar->setPercentage(progress, 0.1f);
- auto id = std::to_string(i);
- if (i <= 9) {id = "0" + id;};
- if (i <= 99) {id = "0" + id;};
- auto Path = "bgm/bgm_"+id+".awb";
- std::ifstream fin(Path);
- if (fin.fail()) {
- std::string logstring = Path;
- UD_LOGI("File Not Exist : %s", logstring.c_str());
- } else {
- std::string logstring = id;
- UD_LOGI("File Exist : %s", logstring.c_str());
- }
- }*/
- }
- extern "C" {
- int unidokkan_init_v2(HookLib *hook_lib) {
- auto res = hook_lib->applyHooks(
- {
- {DOKKAN_LIB, "_ZN18CharacterMenuScene7onEnterEv", reinterpret_cast<void *>(CharacterMenuScene_onEnter), reinterpret_cast<void **>(&ori__CharacterMenuScene_onEnter)},
- }
- );
- if (!res) {
- return 1;
- }
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement