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/label.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 <unidokkan/errors.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) {
- UD_LOGI("init");
- 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("baou_jukebox/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({0, 0});
- //{line_h/2, 10.0f} bottom left + margin
- std::string fntfile = "baou_jukebox/fonts/ja/custom/btn_normal/btn_normal.fnt";
- auto file_utils = UniDokkan::Dokkan::cocos2d_FileUtils_getInstance();
- if (UniDokkan::Dokkan::cocos2d_FileUtils_isFileExistWithoutCpk(file_utils, fntfile)) {
- fntfile = "baou_jukebox/fonts/ja/custom/btn_normal/btn_normal.fnt";
- UD_LOGI("Using : %s", fntfile.c_str());
- } else {
- fntfile = "baou_jukebox/fonts/fonts/fr/custom/btn_normal/btn_normal.fnt";
- UD_LOGI("Using : %s", fntfile.c_str());
- }
- UD_LOGI("creating : BGMList");
- auto Title = new Label("BGMList", layout,1000);
- Title->setBMFont(fntfile, 15.0f, {0.0f,0.0f});
- Title->setCaption("Liste des BGM");
- Title->setFontSize(30.0f);
- Title->setPosition({screen_size.width/2, screen_size.height - 50.0f});
- Title->setAnchorPoint(Node::AnchorCenter);
- UD_LOGI("creating : CurrPlaying");
- auto CurrentlyPlaying = new Label("CurrPlaying", layout,1000);
- CurrentlyPlaying->setBMFont(fntfile, 15.0f, {0.0f,0.0f});
- CurrentlyPlaying->setCaption("En cours de lecture : Rien");
- CurrentlyPlaying->setFontSize(16.0f);
- CurrentlyPlaying->setPosition({screen_size.width/2, screen_size.height - 120.0f});
- CurrentlyPlaying->setAnchorPoint(Node::AnchorCenter);
- UD_LOGI("setting");
- float line_v = screen_size.height - 200.0f; // header
- float line_h = screen_size.width/4;
- line_h = line_h - 20.0f;
- float add_h = 160.0f; // guessing width of btn
- auto firststpos = background_image->getPosition();
- float middlef = screen_size.width/2;
- UD_LOGI("listing bgms");
- for (int i = 1; i < 999; i++) {
- auto path = fmt::format("bgm/bgm_{:#03d}.awb", i);
- if (UniDokkan::Dokkan::cocos2d_FileUtils_isFileExistWithoutCpk(file_utils, path)) {
- if (in_line == 7) {
- in_line = 0;
- counter = 0;
- line_v = line_v - 40.0f;
- line_h = screen_size.width/4;
- line_h = line_h - 25.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);
- std::string curr_id_str_l = std::to_string(i)+"_label";
- auto play_bgm = new Button(curr_id_str, layout,1000);
- UD_LOGI("creating btn bgm");
- play_bgm->setDefaultImage("baou_jukebox/layout/image/common/btn/com_btn_16_yellow.png");
- //play_bgm->setCaption(curr_id_str);
- auto IDLabel = new Label(curr_id_str_l, layout,1000);
- auto YPosLab = line_v + 10.0f;
- IDLabel->setBMFont(fntfile, 15.0f, {0.0f,-500.0f});
- IDLabel->setPosition({line_h/2, YPosLab});
- IDLabel->setCaption(curr_id_str);
- IDLabel->setFontSize(14.0f);
- UD_LOGI("position btn bgm");
- play_bgm->setPosition({line_h/2, line_v});
- play_bgm->setScale(1.0, 1.0);
- play_bgm->setAnchorPoint(Node::AnchorCenter);
- play_bgm->setFontColor(cocos2d::Color3B::BLACK);
- play_bgm->addClickEventListener([=](Widget*) {
- CurrentlyPlaying->setCaption("En cours de lecture : " + curr_id_str);
- PlayBGM(self,curr_id,0,true);
- });
- } else {
- //UD_LOGI("File Not Exist : %s", path.c_str());
- }
- }
- UD_LOGI("Fermerbtn");
- auto Fermer = new Label("Fermerbtn", layout,1000);
- Fermer->setBMFont(fntfile, 15.0f, {0.0f,0.0f});
- Fermer->setCaption("Fermer");
- Fermer->setFontSize(18.0f);
- Fermer->setPosition({middlef, 93.0f});
- Fermer->setAnchorPoint(Node::AnchorCenter);
- UD_LOGI("close_list");
- auto close_list = new Button("close_list", layout);
- close_list->setDefaultImage("baou_jukebox/layout/image/common/btn/com_btn_01_orange.png");
- close_list->setPosition({middlef, 80.0f});
- close_list->setAnchorPoint(Node::AnchorCenter);
- close_list->setFontColor(cocos2d::Color3B::BLACK);
- close_list->addClickEventListener([=](Widget*) {
- //Scene::popCurrent();
- in_line = 0;
- counter = 0;
- TransitionFade transition_fade(1.0f, cocos2d::Color3B::BLACK);
- // ori__CharacterMenuScene_onEnter(self);
- Music_player_1->popCurrent();
- });
- UD_LOGI("pathdb");
- //Home Menu button
- //Check if glb or japan :
- auto pathdb = "sqlite/current/database.db";
- auto OriW = screen_size.width;
- auto OriH = screen_size.height;
- float Ypos = OriH/2;
- float YposN = Ypos;
- float XPos = OriW/2;
- if (UniDokkan::Dokkan::cocos2d_FileUtils_isFileExistWithoutCpk(file_utils, pathdb)) {
- YposN = Ypos-292.0f;
- } else {
- YposN = Ypos-169.0f;
- }
- UD_LOGI("menu_icon_addon");
- auto left_icon = new ImageView("menu_icon_addon", self, 200);
- left_icon->loadImage("baou_jukebox/layout/image/common/btn/menu_icon_addon.png");
- left_icon->setAnchorPoint(Node::AnchorCenter);;
- left_icon->setPosition({XPos+54.0f, YposN+4.0f});
- UD_LOGI("menu_title_addon");
- auto btn_label = new ImageView("menu_title_addon", self, 200);
- btn_label->loadImage("baou_jukebox/layout/image/common/btn/menu_title_addon.png");
- btn_label->setAnchorPoint(Node::AnchorCenter);
- btn_label->setPosition({XPos+194.0f, YposN});
- UD_LOGI("open_playerbtn");
- auto open_player = new Button("open_playerbtn", self, 100);
- open_player->setDefaultImage("baou_jukebox/layout/image/common/btn/com_btn_menu_chara_gray.png");
- open_player->setGravity(cocos2d::ui::LinearLayoutParameter::LinearGravity::CENTER_HORIZONTAL);
- open_player->setPosition({XPos+162.0f, YposN});
- open_player->addClickEventListener([=](Widget*) {
- TransitionFade transition_fade(1.0f, cocos2d::Color3B::BLACK);
- Music_player_1->push();
- });
- UD_LOGI("End of functions");
- }
- extern "C" {
- __attribute__ ((visibility ("default")))
- int unidokkan_init_v3(HookLibV3 *hook_lib) {
- UD_LOGI("Jukebox custom module loading...");
- if (hook_lib->size < sizeof(HookLibV3)) {
- return UD_MODULE_INVALID_SIZE;
- }
- if (hook_lib->version < kMinPatcherVer) {
- return UD_MODULE_INVALID_VERSION;
- }
- auto res = hook_lib->applyHooks({
- // {DOKKAN_LIB, "_ZN24LayoutIngameIngameBattle4initEv", (bool*)CharacterMenuScene_onEnter},
- {DOKKAN_LIB, "_ZN16InGameFooterView7onEnterEv", reinterpret_cast<void *>(CharacterMenuScene_onEnter), reinterpret_cast<void **>(&ori__CharacterMenuScene_onEnter)},
- // {DOKKAN_LIB, "_ZThn8_N16InGameFooterView4initEv", <void*>(CharacterMenuScene_onEnter), <void**>(&ori__CharacterMenuScene_onEnter)},
- // {DOKKAN_LIB, "_ZN18CharacterMenuScene7onEnterEv", reinterpret_cast<void *>(CharacterMenuScene_onEnter), reinterpret_cast<void **>(&ori__CharacterMenuScene_onEnter)},
- });
- if (!res) {
- return UD_MODULE_ERROR;
- }
- UD_LOGI("Jukebox module successfully loaded.");
- return UD_MODULE_SUCCESS;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement