// // CPT operator / SondeerGame // This source file is (c) by Deltares. // - October 2014 // // ************************************************************************************************ // This menu is separated so it can be used as ingame Settings Menu as well as in the Main Menu // // ------------------------------------------------------------ // // © 2008, Deltares // // 2008-08-21 wsl Created by copying from LeveePatroller-MenuOptions (and its tabs) // ************************************************************************************************ #exec OBJ LOAD FILE=Geodelft.utx class MenuSettings extends GeoGUIPage; var automated GeoFrame DialogBackground; var automated GeoTitle TitleLabel; var automated GeoLabel LanguageLabel; var automated GeoImageButton LanguageButtonEN; var automated GeoImageButton LanguageButtonNL; var automated GeoLabel ResolutionLabel; var automated GeoComboBox ResolutionCombo; var automated GeoLabel FullScreenLabel; var automated GeoCheckBox FullScreenCheck; var automated GeoLabel DetailLabel; var automated GeoComboBox DetailCombo; var automated GeoButton ApplyButton; var automated GeoLabel MouseSensitivityLabel; var automated GeoSlider MouseSensitivitySlider; var automated GeoButton BackButton; struct DisplayMode { var int Width, Height; }; var DisplayMode DisplayModes[8]; var float SavedPitch; function InitComponent(GUIController MyController, GUIComponent MyOwner) { Super.InitComponent(MyController, MyOwner); ResolutionCombo.MyComboBox.MyListBox.StyleName = "GeoListBox"; ResolutionCombo.MyComboBox.MyListBox.List.StyleName = "GeoListBox"; DetailCombo.MyComboBox.MyListBox.StyleName = "GeoComboListBox"; MouseSensitivitySlider.SetValue(class'PlayerInput'.default.MouseSensitivity); MouseSensitivitySlider.SetCaptionVisibility(false); //Controls[1].SetFocus(none); FullScreenCheck.MyCheckBox.Style = Controller.GetStyle("GeoCheckBox"); FullscreenCheck.MyCheckBox.Graphic = Material'GeoGUIContent.Icons.checkmark_selected'; ApplyButton.bVisible = false; // see also event Opened() below } // when menu opened (first time, but also when returning from other menu) // make sure all texts are in the right language event Opened(GUIComponent Sender) { Super.Opened(Sender); InitLanguages(GeoPlayerController(PlayerOwner()).GetLanguage()); InternalOnLoadINI(ResolutionCombo,""); InternalOnLoadINI(FullScreenCheck,""); InternalOnLoadINI(DetailCombo,""); } function InitLanguages(string lang) { local int i; // All texts configured by INIOption property super.InitLanguages(lang); if (lang == "NL") { LanguageButtonNL.Graphic = Material'GeoDelft.NL_on'; LanguageButtonEN.Graphic = Material'GeoDelft.EN'; } else { LanguageButtonNL.Graphic = Material'GeoDelft.NL'; LanguageButtonEN.Graphic = Material'GeoDelft.EN_on'; } for(i = DetailCombo.ItemCount() - 1; i > -1; i--) { DetailCombo.RemoveItem(i); } for(i = 0; i < 3; i++) { DetailCombo.AddItem(GeoPC.IL8N("detailmode" $ i, "GeoInterface.MenuSettings", false)); } /// Determine setting: CheckDetailSettings(); } function InternalOnClose(optional Bool bCanceled) { Super.OnClose(bCanceled); } function bool MyKeyEvent(out byte Key,out byte State,float delta) { if(Key == 0x1B && State == 1) // Escape pressed { Controller.CloseMenu(); return true; } else return false; } event NotifyLevelChange() { Controller.CloseMenu(true); } function bool ButtonClick(GUIComponent Sender) { local int i; local bool found; local GUIPage page; local string DesiredRes, DesiredDetail; if(Sender == BackButton) { Controller.CloseMenu(); } else if (Sender == LanguageButtonEN) { if (GeoPlayerController(PlayerOwner()).GetLanguage() == "NL") { LanguageButtonNL.Graphic = Material'GeoDelft.NL'; LanguageButtonEN.Graphic = Material'GeoDelft.EN_on'; GeoPlayerController(PlayerOwner()).ChangeLanguage("EN"); InitLanguages(GeoPlayerController(PlayerOwner()).GetLanguage()); } } else if (Sender == LanguageButtonNL) { if (GeoPlayerController(PlayerOwner()).GetLanguage() == "EN") { LanguageButtonNL.Graphic = Material'GeoDelft.NL_on'; LanguageButtonEN.Graphic = Material'GeoDelft.EN'; GeoPlayerController(PlayerOwner()).ChangeLanguage("NL"); InitLanguages(GeoPlayerController(PlayerOwner()).GetLanguage()); } } else if(Sender == ApplyButton) { DesiredRes = ResolutionCombo.MyComboBox.Edit.GetText(); DesiredRes = DesiredRes$"x32"; if(DetailCombo.GetIndex()==0) { DesiredDetail="Low"; } else if(DetailCombo.GetIndex()==1) { DesiredDetail="Medium" ; } else if(DetailCombo.GetIndex()==2) { DesiredDetail="High"; } if (FullScreenCheck.IsChecked()) DesiredRes = DesiredRes$"f"; else DesiredRes = DesiredRes$"w"; ApplyButton.bVisible = false; /// Replace any videochangeok windows which MIGHT already be visible. found = false; for (i = 0; i < Controller.MenuStack.Length; i++ ) { if (Controller.MenuStack[i].class == class'GeoInterface.dialogVideoChangeOK') { found = true; page = Controller.MenuStack[i]; } } /// The menu was found before: if (found == true) { /// Focus confirmation menu again page.SetFocus(none); /// Replace menu: if ( Controller.ReplaceMenu("GeoInterface.dialogVideoChangeOK") ) dialogVideoChangeOK(Controller.TopPage()).Execute(DesiredRes, DesiredDetail); } else { if ( Controller.OpenMenu("GeoInterface.dialogVideoChangeOK") ) dialogVideoChangeOK(Controller.TopPage()).Execute(DesiredRes, DesiredDetail); } } return true; } //============================================================================= // Date Id Modification // 2006-10-07 The Created //============================================================================= function CheckSupportedResolutions() { local int HighestRes; local int Index; local int BitDepth; local string CurrentSelection; BitDepth =32; CurrentSelection = ResolutionCombo.MyComboBox.Edit.GetText(); //empty the combobox when there are elements in it. if(ResolutionCombo.ItemCount() > 0) ResolutionCombo.RemoveItem(0, ResolutionCombo.ItemCount()); // Don't let user create non-fullscreen window bigger than highest // supported resolution, or MacOS X client crashes. --ryan. if(!FullscreenCheck.IsChecked()) // Controls[2] == fs toggle. { HighestRes = 0; for(Index = 0;Index < ArrayCount(DisplayModes);Index++) { if (PlayerOwner().ConsoleCommand( "SupportedResolution"$ " WIDTH="$DisplayModes[Index].Width$ " HEIGHT="$DisplayModes[Index].Height$ " BITDEPTH="$BitDepth) == "1") { HighestRes = Index; // biggest resolution hardware supports. } else { log("SupportedResolution"$ " WIDTH="$DisplayModes[Index].Width$ " HEIGHT="$DisplayModes[Index].Height$ " BITDEPTH="$BitDepth); } } for(Index = 0;Index <= HighestRes;Index++) { ResolutionCombo.AddItem(DisplayModes[Index].Width$"x"$DisplayModes[Index].Height); } } else // Set dropdown for fullscreen modes... { for(Index = 0;Index < ArrayCount(DisplayModes);Index++) { if (PlayerOwner().ConsoleCommand( "SupportedResolution"$ " WIDTH="$DisplayModes[Index].Width$ " HEIGHT="$DisplayModes[Index].Height$ " BITDEPTH="$BitDepth) == "1") { ResolutionCombo.AddItem(DisplayModes[Index].Width$"x"$DisplayModes[Index].Height); } } } ResolutionCombo.SetText(CurrentSelection); } //============================================================================= // Date Id Modification // 2006-10-07 The Created this header //============================================================================= function CheckDetailSettings() { if(GeoPC.DetailSetting == "Low") { DetailCombo.SetText(DetailCombo.GetItem(0)); } else if(GeoPC.DetailSetting == "Medium") { DetailCombo.SetText(DetailCombo.GetItem(1)); } else { // GeoPC.DetailSettings are High or not set DetailCombo.SetText(DetailCombo.GetItem(2)); } } //============================================================================= // Date Id Modification // 2006-10-07 The Created this header //============================================================================= function InternalOnLoadINI(GUIComponent Sender, string s) { local string temp; if (Sender == ResolutionCombo) { // Resolution if(Controller.GameResolution != "") ResolutionCombo.SetText(Controller.GameResolution); else ResolutionCombo.SetText(Controller.GetCurrentRes()); } else if (Sender == FullScreenCheck) { Temp = Sender.PlayerOwner().ConsoleCommand("ISFULLSCREEN"); FullScreenCheck.Checked(bool(Temp)); CheckSupportedResolutions(); } else if (Sender == DetailCombo) { CheckDetailSettings(); } } //============================================================================= // Date Id Modification // 2006-10-07 The Created this header //============================================================================= //function string InternalOnSaveINI(GUIComponent Sender); // Do the actual work here //============================================================================= // Date Id Modification // 2006-10-07 The Created this header //============================================================================= function InternalOnChange(GUIComponent Sender) { if (!Controller.bCurMenuInitialized) return; if (Sender == ResolutionCombo || Sender == FullScreenCheck || Sender == DetailCombo) { ApplyButton.bVisible = true; if(Sender != ResolutionCombo) CheckSupportedResolutions(); } else if (Sender == MouseSensitivitySlider) { if (MouseSensitivitySlider.Value > MouseSensitivitySlider.MaxValue) { MouseSensitivitySlider.SetValue(class'PlayerInput'.default.MouseSensitivity); } class'PlayerInput'.default.MouseSensitivity = MouseSensitivitySlider.Value; PlayerOwner().ConsoleCommand("set PlayerInput MouseSensitivity "$MouseSensitivitySlider.Value); class'PlayerInput'.static.StaticSaveConfig(); Controller.MenuMouseSens = MouseSensitivitySlider.Value; Controller.SaveConfig(); } } /// Add .00 automatically after slider changes... check if this is good for anything function OnDeActivateSlider() { MouseSensitivitySlider.SetValue(MouseSensitivitySlider.Value); } defaultproperties { Begin Object Class=GeoFrame name=TDialogBackground WinWidth=0.7 WinHeight=0.84 WinTop=0.08 WinLeft=0.15 End Object Begin Object class=GeoTitle name=TTitleLabel IniOption="TTitleLabel" WinWidth=1 WinLeft=0 WinTop=0.15 WinHeight=0.1 TextAlign=TXTA_Center End Object Begin Object class=GeoLabel Name=TLanguageLabel IniOption="TLanguageLabel" TextFont="GeoNormalFont" WinLeft=0.3 WinTop=0.280 WinHeight=0.1 End Object Begin Object Class=GeoImageButton Name=TLanguageButtonNL WinWidth=0.075 WinHeight=0.1 WinLeft=0.5 WinTop=0.3 Graphic=Material'GeoDelft.NL' OnClick=ButtonClick End Object Begin Object Class=GeoImageButton Name=TLanguageButtonEN WinWidth=0.075 WinHeight=0.1 WinLeft=0.59 WinTop=0.3 Graphic=Material'GeoDelft.EN' OnClick=ButtonClick End Object Begin Object class=GeoLabel Name=TResolutionLabel IniOption="TResolutionLabel" TextFont="GeoNormalFont" WinLeft=0.3 WinTop=0.39 WinHeight=0.1 End Object Begin Object class=GeoComboBox Name=TVideoResolution WinLeft=0.5 WinTop=0.42 INIOption="@INTERNAL" INIDefault="640x480" OnChange=InternalOnChange End Object Begin Object class=GeoLabel Name=TFullScreenLabel INIOption="TFullScreenLabel" TextFont="GeoNormalFont" WinLeft=0.3 WinTop=0.45 WinHeight=0.1 End Object Begin Object class=GeoButton Name=TApplyButton IniOption="TApplyButton" WinWidth=0.13 WinHeight=0.04 WinLeft=0.55 WinTop=0.48 OnClick=ButtonClick End Object Begin Object class=GeoCheckBox Name=TVideoFullScreen WinLeft=0.5 WinTop=0.48 INIOption="@INTERNAL" INIDefault="True" OnChange=InternalOnChange End Object Begin Object class=GeoLabel Name=TDetailLabel IniOption="TDetailLabel" TextFont="GeoNormalFont" WinLeft=0.3 WinTop=0.51 WinHeight=0.1 End Object Begin Object class=GeoComboBox Name=TDetailSettings WinLeft=0.5 WinTop=0.54 INIOption="@INTERNAL" INIDefault="640x480" OnChange=InternalOnChange End Object Begin Object class=GeoLabel Name=TMouseSensitivityLabel IniOption="TMouseSensitivityLabel" WinLeft=0.3 WinTop=0.63 WinHeight=0.1 TextFont="GeoNormalFont" End Object Begin Object class=GeoSlider Name=TInputMouseSensitivity WinLeft=0.488 WinTop=0.66 OnDeActivate=OnDeActivateSlider OnChange=InternalOnChange MinValue=1.0 MaxValue=6.0 End Object Begin Object Class=GeoButton Name=TBackButton OnClick=ButtonClick INIOption="TBackButton" WinWidth=0.12 WinLeft=0.44 WinTop=0.78 End Object DialogBackground=TDialogBackground TitleLabel=TTitleLabel LanguageLabel = TLanguageLabel LanguageButtonNL = TLanguageButtonNL LanguageButtonEN = TLanguageButtonEN ResolutionLabel=TResolutionLabel ResolutionCombo=TVideoResolution FullScreenLabel=TFullScreenLabel FullScreenCheck=TVideoFullScreen DetailLabel=TDetailLabel DetailCombo=TDetailSettings ApplyButton=TApplyButton MouseSensitivityLabel=TMouseSensitivityLabel MouseSensitivitySlider=TInputMouseSensitivity BackButton=TBackButton Background=Texture'GeoDelft.BackGround0' WinWidth=1.0 WinHeight=1.0 WinTop=0.0 WinLeft=0.0 OnClose=InternalOnClose OnKeyEvent=MyKeyEvent bAllowedAsLast=true bDisconnectOnOpen=false DisplayModes(0)=(Width=1024,Height=768) DisplayModes(1)=(Width=1152,Height=864) DisplayModes(2)=(Width=1280,Height=800) DisplayModes(3)=(Width=1280,Height=960) DisplayModes(4)=(Width=1280,Height=1024) DisplayModes(5)=(Width=1600,Height=1200) DisplayModes(6)=(Width=1680,Height=1050) DisplayModes(7)=(Width=1920,Height=1200) }