/** GuiOptionBrowser * Constructor for the GuiOptionBrowser class. */ GuiOptionBrowser::GuiOptionBrowser(int w, int h, OptionList * l, const char * custombg) : scrollBar(h-10) { width = w; height = h; options = l; selectable = true; selectedItem = 0; oldSelectedItem = -1; coL2 = 50; listOffset = 0; trigA = new GuiTrigger; trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); bgOptions = Resources::GetImageData(custombg); bgOptionsImg = new GuiImage(bgOptions); bgOptionsImg->SetParent(this); bgOptionsImg->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); bgOptionsEntry = Resources::GetImageData("bg_options_entry.png"); scrollBar.SetParent(this); scrollBar.SetAlignment(thAlign("right - options browser scrollbar align hor"), thAlign("top - options browser scrollbar align ver")); scrollBar.SetPosition(thInt("0 - options browser scrollbar pos x"), thInt("5 - options browser scrollbar pos y")); scrollBar.listChanged.connect(this, &GuiOptionBrowser::onListChange); optionBtn.resize(PAGESIZE); optionBg.resize(PAGESIZE); optionTxt.resize(PAGESIZE); optionVal.resize(PAGESIZE); for (int i = 0; i < PAGESIZE; i++) { optionTxt[i] = new GuiText((wchar_t *) NULL, 20, thColor("r=0 g=0 b=0 a=255 - settings text color")); optionTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); optionTxt[i]->SetPosition(24, 0); optionTxt[i]->SetMaxWidth(bgOptionsImg->GetWidth()-scrollBar.GetWidth()-40, DOTTED); optionBg[i] = new GuiImage(bgOptionsEntry); optionVal[i] = new GuiText((wchar_t *) NULL, 20, thColor("r=0 g=0 b=0 a=255 - settings text color")); optionVal[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); optionBtn[i] = new GuiButton(width - scrollBar.GetWidth(), GAMESELECTSIZE); optionBtn[i]->SetParent(this); optionBtn[i]->SetLabel(optionTxt[i], 0); optionBtn[i]->SetLabel(optionVal[i], 1); optionBtn[i]->SetImageOver(optionBg[i]); optionBtn[i]->SetPosition(10, GAMESELECTSIZE * i + 4); optionBtn[i]->SetRumble(false); optionBtn[i]->SetTrigger(trigA); optionBtn[i]->SetSoundClick(btnSoundClick); } }
SettingsMenu::SettingsMenu(const char * title, OptionList * opts, int returnTo) : GuiWindow(screenwidth, screenheight) { Options = opts; returnToMenu = returnTo; trigA = NULL; trigB = NULL; backBtnTxt = NULL; backBtnImg = NULL; backBtn = NULL; btnOutline = NULL; //! Skipping back button if there is no menu defined to go back to if(returnToMenu != MENU_NONE) { btnOutline = Resources::GetImageData("button_dialogue_box.png"); trigA = new GuiTrigger(); trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trigB = new GuiTrigger(); trigB->SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); backBtnTxt = new GuiText(tr("Back"), 22, (GXColor){0, 0, 0, 255}); backBtnImg = new GuiImage(btnOutline); backBtn = new GuiButton(backBtnImg, backBtnImg, 2, 3, -180, 400, trigA, btnSoundOver, btnSoundClick2, 1); backBtn->SetLabel(backBtnTxt); backBtn->SetTrigger(trigB); Append(backBtn); } optionBrowser = new GuiOptionBrowser(396, 280, Options, "bg_options_settings.png"); optionBrowser->SetAlignment(thAlign("center - settings option browser align hor"), thAlign("top - settings option browser align ver")); optionBrowser->SetPosition(thInt("0 - settings option browser pos x"), thInt("90 - settings option browser pos y")); titleTxt = new GuiText(title, 28, thColor("r=0 g=0 b=0 a=255 - settings title text color")); titleTxt->SetAlignment(thAlign("center - settings title text align hor"), thAlign("top - settings title text align ver")); titleTxt->SetPosition(thInt("0 - settings title text pos x"), thInt("40 - settings title text pos y")); titleTxt->SetMaxWidth(thInt("310 - settings title text max width"), SCROLL_HORIZONTAL); Append(optionBrowser); Append(titleTxt); SetEffect(EFFECT_FADE, 50); }
SettingsMenu::SettingsMenu() : GuiFrame(screenwidth, screenheight) { globalSettings = NULL; settingsBrowser = NULL; BtnSoundClick = Resources::GetSound("button_click.wav"); BtnSoundOver = Resources::GetSound("button_over.wav"); BtnSoundClick->SetVolume(Settings.SFXVolume); BtnSoundOver->SetVolume(Settings.SFXVolume); trigA.SetSimpleTrigger(-1, WiiControls.ClickButton | ClassicControls.ClickButton << 16, GCControls.ClickButton); trigB.SetButtonOnlyTrigger(-1, WiiControls.BackButton | ClassicControls.BackButton << 16, GCControls.BackButton); BgImgData = Resources::GetImageData("settings_background.png"); BgImg = new GuiImage(BgImgData); Title = new GuiText(tr("Global Settings"), 28, thColor("r=0 g=0 b=0 a=255 - settings menu title text color")); Title->SetAlignment(ALIGN_LEFT | ALIGN_TOP); Title->SetPosition(170, 38); Title->SetMaxWidth(310, SCROLL_HORIZONTAL); BackBtnTxt = new GuiText(tr( "Back" ), 22, thColor("r=0 g=0 b=0 a=255 - settings menu back button text color")); BackBtn = new PictureButton("settings_menu_button.png", "settings_menu_button.png", BtnSoundClick, BtnSoundOver); BackBtn->SetAlignment(thAlign("center - settings menu back button align hor") | thAlign("top - settings menu back button align ver")); BackBtn->SetPosition(thInt("-195 - settings menu back button pos x"), thInt("400 - settings menu back button pos y")); BackBtn->SetLabel(BackBtnTxt); BackBtn->SetTrigger(&trigA); BackBtn->SetTrigger(&trigB); BackBtn->Clicked.connect(this, &SettingsMenu::OnBackButtonClick); globalSettings = new GlobalSettings(); globalSettings->FlyingBtnMenuClicked.connect(this, &SettingsMenu::OnFlyingButtonClick); Append(BgImg); Append(Title); Append(BackBtn); Append(globalSettings); SetEffect(EFFECT_FADE, 20); }