| 75 | } |
| 76 | |
| 77 | OptionMenu::OptionMenu(Plugin *workPlugin, ui::Widget *root, vector<Button> *buttons) |
| 78 | { |
| 79 | Plugin::TemplateOpenParam tmpParam; |
| 80 | ui::Widget *closeButton = NULL; |
| 81 | ui::Widget *button = NULL; |
| 82 | |
| 83 | m_parentRoot = root; |
| 84 | m_plugin = workPlugin; |
| 85 | m_buttonCount = buttons->size(); |
| 86 | |
| 87 | Plugin::PageOpenParam openParam; |
| 88 | openParam.option = Plugin::PageOption_Create; |
| 89 | openParam.overwrite_draw_priority = 8; |
| 90 | openParam.graphics_flag = 0x80; |
| 91 | m_rootScene = m_plugin->PageOpen(page_option_menu, openParam); |
| 92 | if (!m_rootScene) |
| 93 | { |
| 94 | SCE_DBG_LOG_ERROR("[OPTION_MENU] Attempt to create option menu twice!\n"); |
| 95 | return; |
| 96 | } |
| 97 | |
| 98 | m_parentRoot->SetActivate(false); |
| 99 | |
| 100 | m_plugin->TemplateOpen(m_rootScene, template_option_menu_base, tmpParam); |
| 101 | |
| 102 | closeButton = m_rootScene->FindChild(button_option_menu_close); |
| 103 | closeButton->AddEventCallback(ui::Button::CB_BTN_DECIDE, |
| 104 | [](int32_t type, ui::Handler *self, ui::Event *e, void *userdata) |
| 105 | { |
| 106 | reinterpret_cast<OptionMenu *>(userdata)->OnButton(static_cast<ui::Widget *>(self)); |
| 107 | }, this); |
| 108 | |
| 109 | closeButton->SetKeycode(inputdevice::pad::Data::PAD_ESCAPE | inputdevice::pad::Data::PAD_MENU); |
| 110 | |
| 111 | m_optPlaneRoot = closeButton->FindChild(plane_option_menu_base); |
| 112 | ui::Widget *optRoot = m_optPlaneRoot->FindChild(box_option_menu); |
| 113 | |
| 114 | uint32_t maxLen = 0; |
| 115 | uint32_t curLen = 0; |
| 116 | uint32_t maxLenIdx = 0; |
| 117 | uint32_t idhash = 0; |
| 118 | |
| 119 | for (int i = 0; i < m_buttonCount; i++) |
| 120 | { |
| 121 | Button btItem = buttons->at(i); |
| 122 | |
| 123 | if (i == 0) |
| 124 | { |
| 125 | if (m_buttonCount == 1) |
| 126 | { |
| 127 | idhash = template_option_menu_button_single; |
| 128 | } |
| 129 | else |
| 130 | { |
| 131 | idhash = template_option_menu_button_top; |
| 132 | } |
| 133 | } |
| 134 | else if (i == m_buttonCount - 1) |