Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CreateOptionsMenu()
- {
- //resolution
- //fullscreen
- //sound volume
- //music volume
- //Main Menu button
- GuiHelper gh;
- gh.base.x_ = GetSubsystem<Graphics>()->GetWidth();
- gh.base.y_ = GetSubsystem<Graphics>()->GetHeight();
- OptionsMenu = GetSubsystem<UI>()->GetRoot()->CreateChild<UIElement>("UIElement");
- OptionsMenu->SetStyleAuto();
- OptionsMenu->SetVisible(false);
- Button* backButton = CreateButton("Back", OptionsMenu, 0.5, 0.64, 0.2, 0.05);
- SubscribeToEvent(backButton, E_RELEASED, URHO3D_HANDLER(Game, backButtonHandle));
- ///Screen Resolution
- Text* resText = new Text(context_);
- resText->SetText("Screen Resolution");
- resText->SetStyleAuto();
- resText->SetHorizontalAlignment(HorizontalAlignment::HA_CENTER);
- gh.SetControlSizePos(resText, 0.5, 0.37, 0.2, 0.03, false);
- OptionsMenu->AddChild(resText);
- DropDownList* list = new DropDownList(context_);
- unsigned selection = M_MAX_UNSIGNED;
- list->SetSelection(selection);
- list->SetStyleAuto();
- gh.SetControlSizePos(list, 0.5, 0.4, 0.2, 0.025,true);
- list->SetResizePopup(true);
- list->SetName("SR");
- OptionsMenu->AddChild(list);
- VideoModes = GetSubsystem<Graphics>()->GetResolutions();
- for (int i = 0; i < VideoModes.Size(); ++i)
- {
- String str = String(VideoModes[i].x_) + " x " + String(VideoModes[i].y_);
- Text * t = new Text(context_);
- t->SetText(str);
- t->SetHorizontalAlignment(HorizontalAlignment::HA_CENTER);
- t->SetStyle("ConsoleText");
- list->AddItem(t);
- }
- ///Fullscreen
- Text* fsText = new Text(context_);
- fsText->SetText("Fullscreen");
- fsText->SetStyleAuto();
- fsText->SetHorizontalAlignment(HorizontalAlignment::HA_RIGHT);
- gh.SetControlSizePos(fsText, 0.5, 0.44, 0.2, 0.03, false);
- OptionsMenu->AddChild(fsText);
- CheckBox* fsBox = new CheckBox(context_);
- fsBox->SetStyleAuto();
- fsBox->SetName("FS");
- gh.SetControlSizePos(fsBox, 0.4, 0.44, 0.2, 0.03, false);
- OptionsMenu->AddChild(fsBox);
- SubscribeToEvent(fsBox, E_CLICK, URHO3D_HANDLER(Game, fsHandle));
- ///sound
- Text* st = new Text(context_);
- st->SetText("Sound Volume");
- st->SetStyleAuto();
- st->SetHorizontalAlignment(HorizontalAlignment::HA_CENTER);
- gh.SetControlSizePos(st, 0.5, 0.48, 0.2, 0.03, false);
- OptionsMenu->AddChild(st);
- Slider* sound = new Slider(context_);
- gh.SetControlSizePos(sound, 0.5, 0.52, 0.2, 0.03, true);
- sound->SetName("sound");
- sound->SetStyleAuto();
- sound->SetRange(10);
- sound->SetMinWidth(sound->GetWidth());
- OptionsMenu->AddChild(sound);
- //slider->SetValue(audio->GetMasterGain(SOUND_EFFECT));
- //SubscribeToEvent(slider, E_SLIDERCHANGED, URHO3D_HANDLER(SoundEffects, HandleSoundVolume));
- ///music
- Text* mt = new Text(context_);
- mt->SetText("Music Volume");
- mt->SetStyleAuto();
- mt->SetHorizontalAlignment(HorizontalAlignment::HA_CENTER);
- gh.SetControlSizePos(mt, 0.5, 0.56, 0.2, 0.03, false);
- OptionsMenu->AddChild(mt);
- Slider* music = new Slider(context_);
- gh.SetControlSizePos(music, 0.5, 0.60, 0.2, 0.03, true);
- music->SetName("music");
- music->SetStyleAuto();
- music->SetRange(10);
- music->SetMinWidth(music->GetWidth());
- OptionsMenu->AddChild(music);
- OptionsMenu->Remove();
- OptionsMenu->SetVisible(true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement