KeyPadMenu::KeyPadMenu(int w, int h, const std::string & strTitle, const std::string & prefil) : GuiFrame(w, h) , buttonClickSound(Resources::GetSound("settings_click_2.mp3")) , backImageData(Resources::GetImageData("keyPadBackButton.png")) , backImage(backImageData) , backButton(backImage.getWidth(), backImage.getHeight()) , okImageData(Resources::GetImageData("keyPadOkButton.png")) , okImage(okImageData) , okButton(okImage.getWidth(), okImage.getHeight()) , okText("O.K.", 46, glm::vec4(0.8f, 0.8f, 0.8f, 1.0f)) , touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH) , wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A) , buttonATrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_A, true) , buttonBTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_B, true) , keyPadBgImageData(Resources::GetImageData("keyPadBg.png")) , keyPadButtonImgData(Resources::GetImageData("keyPadButton.png")) , keyPadButtonClickImgData(Resources::GetImageData("keyPadButtonClicked.png")) , deleteButtonImgData(Resources::GetImageData("keyPadDeleteButton.png")) , deleteButtonClickImgData(Resources::GetImageData("keyPadDeleteClicked.png")) , fieldImageData(Resources::GetImageData("keyPadField.png")) , fieldBlinkerImageData(Resources::GetImageData("keyPadFieldBlinker.png")) , bgImage(keyPadBgImageData) , fieldBlinkerImg(fieldBlinkerImageData) , deleteButtonImg(deleteButtonImgData) , deleteButtonImgClick(deleteButtonClickImgData) , deleteButton(deleteButtonImgData->getWidth(), deleteButtonImgData->getHeight()) , DPADButtons(w,h) { lastFrameCount = 0; currentText = prefil; if(currentText.size() > MAX_FIELDS) currentText.resize(MAX_FIELDS); textPosition = currentText.size(); bgImage.setAlignment(ALIGN_CENTER | ALIGN_BOTTOM); append(&bgImage); backButton.setImage(&backImage); backButton.setAlignment(ALIGN_BOTTOM | ALIGN_LEFT); backButton.clicked.connect(this, &KeyPadMenu::OnBackButtonClick); backButton.setTrigger(&touchTrigger); backButton.setTrigger(&wpadTouchTrigger); backButton.setSoundClick(buttonClickSound); backButton.setEffectGrow(); append(&backButton); okText.setPosition(0, -10); okButton.setLabel(&okText); okButton.setImage(&okImage); okButton.setAlignment(ALIGN_BOTTOM | ALIGN_RIGHT); okButton.clicked.connect(this, &KeyPadMenu::OnOkButtonClick); okButton.setTrigger(&touchTrigger); okButton.setTrigger(&wpadTouchTrigger); okButton.setSoundClick(buttonClickSound); okButton.setEffectGrow(); append(&okButton); titleText.setColor(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)); titleText.setFontSize(46); titleText.setPosition(0, 230); titleText.setBlurGlowColor(5.0f, glm::vec4(0.0, 0.0, 0.0f, 1.0f)); titleText.setText(strTitle.c_str()); append(&titleText); deleteButton.setImage(&deleteButtonImg); deleteButton.setImageOver(&deleteButtonImgClick); deleteButton.setTrigger(&touchTrigger); deleteButton.setTrigger(&wpadTouchTrigger); deleteButton.setSoundClick(buttonClickSound); deleteButton.setPosition(-(keyPadButtonImgData->getWidth() + 5) * (MAX_COLS - 1) * 0.5f + (keyPadButtonImgData->getWidth() + 5) * MAX_COLS, -60); deleteButton.setEffectGrow(); deleteButton.clicked.connect(this, &KeyPadMenu::OnDeleteButtonClick); append(&deleteButton); for(int i = 0; i < MAX_FIELDS; i++) { char fieldTxt[2]; fieldTxt[0] = (i < (int)currentText.size()) ? currentText[i] : 0; fieldTxt[1] = 0; GuiText *text = new GuiText(fieldTxt, 46, glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); GuiImage *image = new GuiImage(fieldImageData); GuiButton *button = new GuiButton(image->getWidth(), image->getHeight()); button->setImage(image); button->setLabel(text); button->setPosition(-(image->getWidth() + 8) * (MAX_FIELDS - 1) * 0.5f + (image->getWidth() + 8) * i, 120); button->setTrigger(&touchTrigger); button->setTrigger(&wpadTouchTrigger); button->setSoundClick(buttonClickSound); button->clicked.connect(this, &KeyPadMenu::OnTextPositionChange); append(button); textFieldText.push_back(text); textFieldImg.push_back(image); textFieldBtn.push_back(button); } fieldBlinkerImg.setAlignment(ALIGN_LEFT | ALIGN_LEFT); fieldBlinkerImg.setPosition(5, 0); if(textPosition < MAX_FIELDS) textFieldBtn[textPosition]->setIcon(&fieldBlinkerImg); int row = 0, column = 0; for(int i = 0; cpKeyPadButtons[i]; i++) { char buttonTxt[2]; buttonTxt[0] = cpKeyPadButtons[i]; buttonTxt[1] = 0; GuiImage *image = new GuiImage(keyPadButtonImgData); GuiImage *imageClick = new GuiImage(keyPadButtonClickImgData); GuiButton *button = new GuiButton(image->getWidth(), image->getHeight()); GuiText *text = new GuiText(buttonTxt, 46, glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); text->setTextBlur(5.0f); button->setImage(image); button->setImageOver(imageClick); button->setLabel(text); button->setPosition(-(image->getWidth() + 5) * (MAX_COLS - 1) * 0.5f + (image->getWidth() + 5) * column, -60 - (image->getHeight() + 5) * row); button->setTrigger(&touchTrigger); button->setTrigger(&wpadTouchTrigger); button->setSoundClick(buttonClickSound); button->setEffectGrow(); button->clicked.connect(this, &KeyPadMenu::OnKeyPadButtonClick); append(button); keyText.push_back(text); keyButton.push_back(button); keyImg.push_back(image); keyImgOver.push_back(imageClick); column++; if(column >= MAX_COLS) { column = 0; row++; } } DPADButtons.setTrigger(&buttonATrigger); DPADButtons.setTrigger(&buttonBTrigger); DPADButtons.clicked.connect(this, &KeyPadMenu::OnDPADClick); append(&DPADButtons); UpdateTextFields(); }
SettingsMenu::SettingsMenu(int w, int h) : GuiFrame(w, h) , categorySelectionFrame(w, h) , particleBgImage(w, h, 50) , buttonClickSound(Resources::GetSound("settings_click_2.mp3")) , quitImageData(Resources::GetImageData("quitButton.png")) , categoryImageData(Resources::GetImageData("settingsCategoryButton.png")) , categoryBgImageData(Resources::GetImageData("settingsCategoryBg.png")) , quitImage(quitImageData) , quitButton(quitImage.getWidth(), quitImage.getHeight()) , touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH) , wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A) , buttonATrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_A, true) , buttonBTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_B, true) , buttonLTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_L, true) , buttonRTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_R, true) , buttonLeftTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_LEFT | GuiTrigger::STICK_L_LEFT, true) , buttonRightTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_RIGHT | GuiTrigger::STICK_L_RIGHT, true) , leftArrowImageData(Resources::GetImageData("leftArrow.png")) , rightArrowImageData(Resources::GetImageData("rightArrow.png")) , leftArrowImage(leftArrowImageData) , rightArrowImage(rightArrowImageData) , leftArrowButton(leftArrowImage.getWidth(), leftArrowImage.getHeight()) , rightArrowButton(rightArrowImage.getWidth(), rightArrowImage.getHeight()) , DPADButtons(w,h) { currentPosition = 0; targetPosition = 0; selectedCategory = 0; animationSpeed = 25; bUpdatePositions = true; quitButton.setImage(&quitImage); quitButton.setAlignment(ALIGN_BOTTOM | ALIGN_LEFT); quitButton.clicked.connect(this, &SettingsMenu::OnQuitButtonClick); quitButton.setTrigger(&touchTrigger); quitButton.setTrigger(&wpadTouchTrigger); quitButton.setEffectGrow(); quitButton.setSoundClick(buttonClickSound); categorySelectionFrame.append(&quitButton); versionText.setColor(glm::vec4(0.6f, 0.6f, 0.6f, 1.0f)); versionText.setFontSize(42); versionText.setAlignment(ALIGN_TOP | ALIGN_RIGHT); versionText.setPosition(-50, -80); versionText.setText("Loadiine GX2 " LOADIINE_VERSION); categorySelectionFrame.append(&versionText); const u32 cuCategoriesCount = sizeof(stSettingsCategories) / sizeof(stSettingsCategories[0]); if(cuCategoriesCount > 0) selectedCategory = 0; for(u32 idx = 0; idx < cuCategoriesCount; idx++) { settingsCategories.resize(idx + 1); GuiSettingsCategory & category = settingsCategories[idx]; std::vector<std::string> splitDescriptions = stringSplit(stSettingsCategories[idx].descriptions, "\n"); category.categoryIconData = Resources::GetImageData(stSettingsCategories[idx].icon); category.categoryIconGlowData = Resources::GetImageData(stSettingsCategories[idx].iconGlow); category.categoryLabel = new GuiText(tr(stSettingsCategories[idx].name), 46, glm::vec4(0.8f, 0.8f, 0.8f, 1.0f)); category.categoryLabel->setPosition(0, -120); category.categoryBgImage = new GuiImage(categoryBgImageData); category.categoryImages = new GuiImage(categoryImageData); category.categoryIcon = new GuiImage(category.categoryIconData); category.categoryIconGlow = new GuiImage(category.categoryIconGlowData); category.categoryButton = new GuiButton(category.categoryImages->getWidth(), category.categoryImages->getHeight()); category.categoryIcon->setPosition(0, 40); category.categoryIconGlow->setPosition(0, 40); category.categoryButton->setLabel(category.categoryLabel); category.categoryButton->setImage(category.categoryImages); category.categoryButton->setPosition(-300, 0); category.categoryButton->setIcon(category.categoryIcon); category.categoryButton->setIconOver(category.categoryIconGlow); category.categoryButton->setTrigger(&touchTrigger); category.categoryButton->setTrigger(&wpadTouchTrigger); category.categoryButton->setSoundClick(buttonClickSound); category.categoryButton->setEffectGrow(); category.categoryButton->clicked.connect(this, &SettingsMenu::OnCategoryClick); categorySelectionFrame.append(category.categoryBgImage); categorySelectionFrame.append(category.categoryButton); category.categoryButton->setParent(category.categoryBgImage); category.categoryBgImage->setPosition(currentPosition + (category.categoryBgImage->getWidth() + 40) * idx, 0); for(u32 n = 0; n < splitDescriptions.size(); n++) { GuiText * descr = new GuiText(tr(splitDescriptions[n].c_str()), 46, glm::vec4(0.8f, 0.8f, 0.8f, 1.0f)); descr->setAlignment(ALIGN_MIDDLE | ALIGN_LEFT); descr->setPosition(category.categoryBgImage->getWidth() * 0.5f - 50.0f, category.categoryBgImage->getHeight() * 0.5f - 100.0f - n * 60.0f); categorySelectionFrame.append(descr); descr->setParent(category.categoryBgImage); category.descriptions.push_back(descr); } GuiImage *smallIconOver = new GuiImage(category.categoryIconGlowData); GuiImage *smallIcon = new GuiImage(category.categoryIconData); GuiButton *smallIconButton = new GuiButton(smallIcon->getWidth() * smallIconScale, smallIcon->getHeight() * smallIconScale); smallIcon->setScale(smallIconScale); smallIconOver->setScale(smallIconScale); smallIconButton->setImage(smallIcon); smallIconButton->setEffectGrow(); smallIconButton->setTrigger(&touchTrigger); smallIconButton->setTrigger(&wpadTouchTrigger); smallIconButton->setSoundClick(buttonClickSound); smallIconButton->clicked.connect(this, &SettingsMenu::OnSmallIconClick); categorySelectionFrame.append(smallIconButton); categorySmallImages.push_back(smallIcon); categorySmallImagesOver.push_back(smallIconOver); categorySmallButtons.push_back(smallIconButton); } leftArrowButton.setImage(&leftArrowImage); leftArrowButton.setEffectGrow(); leftArrowButton.setPosition(40, 0); leftArrowButton.setAlignment(ALIGN_LEFT | ALIGN_MIDDLE); leftArrowButton.setTrigger(&touchTrigger); leftArrowButton.setTrigger(&wpadTouchTrigger); leftArrowButton.setSoundClick(buttonClickSound); leftArrowButton.clicked.connect(this, &SettingsMenu::OnCategoryLeftClick); categorySelectionFrame.append(&leftArrowButton); rightArrowButton.setImage(&rightArrowImage); rightArrowButton.setEffectGrow(); rightArrowButton.setPosition(-40, 0); rightArrowButton.setAlignment(ALIGN_RIGHT | ALIGN_MIDDLE); rightArrowButton.setTrigger(&touchTrigger); rightArrowButton.setTrigger(&wpadTouchTrigger); rightArrowButton.setSoundClick(buttonClickSound); rightArrowButton.clicked.connect(this, &SettingsMenu::OnCategoryRightClick); categorySelectionFrame.append(&rightArrowButton); DPADButtons.setTrigger(&buttonATrigger); DPADButtons.setTrigger(&buttonBTrigger); DPADButtons.setTrigger(&buttonLTrigger); DPADButtons.setTrigger(&buttonRTrigger); DPADButtons.setTrigger(&buttonLeftTrigger); DPADButtons.setTrigger(&buttonRightTrigger); DPADButtons.clicked.connect(this, &SettingsMenu::OnDPADClick); append(&DPADButtons); categorySelectionFrame.append(&DPADButtons); setTargetPosition(0); moving = false; //! the particle BG is always appended in all sub menus append(&particleBgImage); append(&categorySelectionFrame); }