diff --git a/Intersect.Client/Interface/Game/EscapeMenu.cs b/Intersect.Client/Interface/Game/EscapeMenu.cs
index 346fd3ad2a..6213dfcc5b 100644
--- a/Intersect.Client/Interface/Game/EscapeMenu.cs
+++ b/Intersect.Client/Interface/Game/EscapeMenu.cs
@@ -25,9 +25,9 @@ public class EscapeMenu : ImagePanel
private readonly Button mLogout;
- private readonly Button mOptions;
+ private readonly Button mSettings;
- private readonly OptionsWindow mOptionsWindow;
+ private readonly SettingsWindow mSettingsWindow;
private readonly Label mTitle;
@@ -45,14 +45,14 @@ public EscapeMenu(Canvas gameCanvas) : base(gameCanvas, "EscapeMenu")
Text = Strings.EscapeMenu.Title,
};
- mOptionsWindow = new OptionsWindow(gameCanvas, null, null);
+ mSettingsWindow = new SettingsWindow(gameCanvas, null);
- mOptions = new Button(mContainer, "OptionsButton")
+ mSettings = new Button(mContainer, "SettingsButton")
{
- Text = Strings.EscapeMenu.Options
+ Text = Strings.EscapeMenu.Settings
};
- mOptions.Clicked += Options_Clicked;
+ mSettings.Clicked += Settings_Clicked;
mGoToCharacterSelect = new Button(mContainer, "CharacterSelectButton")
{
@@ -119,22 +119,22 @@ public void Update()
mGoToCharacterSelect.IsDisabled = Globals.Me?.CombatTimer > Timing.Global.Milliseconds;
}
- private void Options_Clicked(Base sender, ClickedEventArgs arguments)
+ private void Settings_Clicked(Base sender, ClickedEventArgs arguments)
{
- mOptionsWindow.Show();
+ mSettingsWindow.Show();
Interface.GameUi?.EscapeMenu?.Hide();
}
public void OpenSettings()
{
- mOptionsWindow.Show();
+ mSettingsWindow.Show();
Interface.GameUi?.EscapeMenu?.Hide();
}
///
public override void ToggleHidden()
{
- if (mOptionsWindow.IsVisible())
+ if (mSettingsWindow.IsVisible())
{
return;
}
diff --git a/Intersect.Client/Interface/Menu/MainMenu.cs b/Intersect.Client/Interface/Menu/MainMenu.cs
index 4eb75bda9f..c957315262 100644
--- a/Intersect.Client/Interface/Menu/MainMenu.cs
+++ b/Intersect.Client/Interface/Menu/MainMenu.cs
@@ -2,7 +2,6 @@
using Intersect.Client.Core;
using Intersect.Client.Framework.File_Management;
-using Intersect.Client.Framework.Graphics;
using Intersect.Client.Framework.Gwen;
using Intersect.Client.Framework.Gwen.Control;
using Intersect.Client.Framework.Gwen.Control.EventArguments;
@@ -45,9 +44,9 @@ public class MainMenu : MutableInterface
private readonly ImagePanel mMenuWindow;
- private readonly Button mOptionsButton;
+ private readonly Button mSettingsButton;
- private readonly OptionsWindow mOptionsWindow;
+ private readonly SettingsWindow mSettingsWindow;
private readonly Button mRegisterButton;
@@ -93,41 +92,41 @@ public MainMenu(Canvas menuCanvas) : base(menuCanvas)
//Menu Header
mMenuHeader = new Label(mMenuWindow, "Title");
- mMenuHeader.SetText(Strings.MainMenu.title);
+ mMenuHeader.SetText(Strings.MainMenu.Title);
//Login Button
mLoginButton = new Button(mMenuWindow, "LoginButton");
- mLoginButton.SetText(Strings.MainMenu.login);
+ mLoginButton.SetText(Strings.MainMenu.Login);
mLoginButton.Clicked += LoginButton_Clicked;
//Register Button
mRegisterButton = new Button(mMenuWindow, "RegisterButton");
- mRegisterButton.SetText(Strings.MainMenu.register);
+ mRegisterButton.SetText(Strings.MainMenu.Register);
mRegisterButton.Clicked += RegisterButton_Clicked;
//Credits Button
mCreditsButton = new Button(mMenuWindow, "CreditsButton");
- mCreditsButton.SetText(Strings.MainMenu.credits);
+ mCreditsButton.SetText(Strings.MainMenu.Credits);
mCreditsButton.Clicked += CreditsButton_Clicked;
//Exit Button
mExitButton = new Button(mMenuWindow, "ExitButton");
- mExitButton.SetText(Strings.MainMenu.exit);
+ mExitButton.SetText(Strings.MainMenu.Exit);
mExitButton.Clicked += ExitButton_Clicked;
- //Options Button
- mOptionsButton = new Button(mMenuWindow, "OptionsButton");
- mOptionsButton.Clicked += OptionsButton_Clicked;
- mOptionsButton.SetText(Strings.MainMenu.options);
- if (!string.IsNullOrEmpty(Strings.MainMenu.optionstooltip))
+ //Settings Button
+ mSettingsButton = new Button(mMenuWindow, "SettingsButton");
+ mSettingsButton.Clicked += SettingsButton_Clicked;
+ mSettingsButton.SetText(Strings.MainMenu.Settings);
+ if (!string.IsNullOrEmpty(Strings.MainMenu.SettingsTooltip))
{
- mOptionsButton.SetToolTipText(Strings.MainMenu.optionstooltip);
+ mSettingsButton.SetToolTipText(Strings.MainMenu.SettingsTooltip);
}
mMenuWindow.LoadJsonUi(GameContentManager.UI.Menu, Graphics.Renderer.GetResolutionString());
- //Options Controls
- mOptionsWindow = new OptionsWindow(menuCanvas, this, mMenuWindow);
+ //Settings Controls
+ mSettingsWindow = new SettingsWindow(menuCanvas, this);
//Login Controls
mLoginWindow = new LoginWindow(menuCanvas, this, mMenuWindow);
@@ -192,14 +191,14 @@ public void Update()
mSelectCharacterWindow.Update();
}
- mOptionsWindow.Update();
+ mSettingsWindow.Update();
}
public void Reset()
{
mLoginWindow.Hide();
mRegisterWindow.Hide();
- mOptionsWindow.Hide();
+ mSettingsWindow.Hide();
mCreditsWindow.Hide();
mForgotPasswordWindow.Hide();
mResetPasswordWindow.Hide();
@@ -214,19 +213,19 @@ public void Reset()
}
mMenuWindow.Show();
- mOptionsButton.Show();
+ mSettingsButton.Show();
}
public void Show()
{
mMenuWindow.IsHidden = false;
- mOptionsButton.IsHidden = false;
+ mSettingsButton.IsHidden = false;
}
public void Hide()
{
mMenuWindow.IsHidden = true;
- mOptionsButton.IsHidden = true;
+ mSettingsButton.IsHidden = true;
}
public void NotifyOpenCharacterSelection(List characters)
@@ -262,7 +261,7 @@ public void CreateCharacterSelection()
Hide();
mLoginWindow.Hide();
mRegisterWindow.Hide();
- mOptionsWindow.Hide();
+ mSettingsWindow.Hide();
mCreateCharacterWindow.Hide();
mSelectCharacterWindow.Show();
mShouldOpenCharacterSelection = false;
@@ -278,7 +277,7 @@ public void CreateCharacterCreation()
Hide();
mLoginWindow.Hide();
mRegisterWindow.Hide();
- mOptionsWindow.Hide();
+ mSettingsWindow.Hide();
mSelectCharacterWindow.Hide();
mCreateCharacterWindow.Show();
mCreateCharacterWindow.Init();
@@ -305,10 +304,10 @@ void CreditsButton_Clicked(Base sender, ClickedEventArgs arguments)
mCreditsWindow.Show();
}
- void OptionsButton_Clicked(Base sender, ClickedEventArgs arguments)
+ void SettingsButton_Clicked(Base sender, ClickedEventArgs arguments)
{
Hide();
- mOptionsWindow.Show();
+ mSettingsWindow.Show();
}
void ExitButton_Clicked(Base sender, ClickedEventArgs arguments)
diff --git a/Intersect.Client/Interface/Shared/OptionsWindow.cs b/Intersect.Client/Interface/Shared/OptionsWindow.cs
deleted file mode 100644
index dc7294e20c..0000000000
--- a/Intersect.Client/Interface/Shared/OptionsWindow.cs
+++ /dev/null
@@ -1,593 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-using Intersect.Client.Core;
-using Intersect.Client.Core.Controls;
-using Intersect.Client.Framework.File_Management;
-using Intersect.Client.Framework.GenericClasses;
-using Intersect.Client.Framework.Graphics;
-using Intersect.Client.Framework.Gwen;
-using Intersect.Client.Framework.Gwen.Control;
-using Intersect.Client.Framework.Gwen.Control.EventArguments;
-using Intersect.Client.General;
-using Intersect.Client.Interface.Menu;
-using Intersect.Client.Localization;
-using Intersect.Utilities;
-
-namespace Intersect.Client.Interface.Shared
-{
-
- public class OptionsWindow
- {
-
- private Button mApplyBtn;
-
- private Button mApplyKeybindingsButton;
-
- private LabeledCheckBox mAutocloseWindowsCheckbox;
-
- private Button mBackBtn;
-
- private Button mCancelKeybindingsButton;
-
- private ScrollControl mControlsContainer;
-
- //Keybindings
- private Button mEditKeybindingsBtn;
-
- private Button mEdittingButton;
-
- private Control mEdittingControl;
-
- private Controls mEdittingControls;
-
- private int mEdittingKey = -1;
-
- private ImagePanel mFpsBackground;
-
- private Label mFpsLabel;
-
- private ComboBox mFpsList;
-
- private LabeledCheckBox mFullscreen;
-
- //Parent Windows
- private bool mGameWindow = false;
-
- private Dictionary mKeyButtons = new Dictionary();
-
- private long mListeningTimer;
-
- private MainMenu mMainMenu;
-
- private Label mMusicLabel;
-
- private HorizontalSlider mMusicSlider;
-
- //Panels
- private ScrollControl mOptionsContainer;
-
- //Window
- private Label mOptionsHeader;
-
- //Controls
- private ImagePanel mOptionsPanel;
-
- private int mPreviousMusicVolume;
-
- private int mPreviousSoundVolume;
-
- private ImagePanel mResolutionBackground;
-
- private Label mResolutionLabel;
-
- private ComboBox mResolutionList;
-
- private Button mRestoreKeybindingsButton;
-
- private Label mSoundLabel;
-
- private HorizontalSlider mSoundSlider;
-
- private MenuItem mCustomResolutionMenuItem;
-
- //Init
- public OptionsWindow(Canvas parent, MainMenu mainMenu, ImagePanel parentPanel)
- {
- //Assign References
- mMainMenu = mainMenu;
-
- //Main Menu Window
- mOptionsPanel = new ImagePanel(parent, "OptionsWindow") {IsHidden = true};
- Interface.InputBlockingElements.Add(mOptionsPanel);
-
- //Menu Header
- mOptionsHeader = new Label(mOptionsPanel, "OptionsHeader");
- mOptionsHeader.SetText(Strings.Options.title);
-
- //Options Get Stored in the Options Scroll Control
- mOptionsContainer = new ScrollControl(mOptionsPanel, "OptionsContainer");
- mOptionsContainer.EnableScroll(false, false);
- mOptionsContainer.Show();
-
- //Resolution Background
- mResolutionBackground = new ImagePanel(mOptionsContainer, "ResolutionPanel");
-
- //Options - Resolution Label
- mResolutionLabel = new Label(mResolutionBackground, "ResolutionLabel");
- mResolutionLabel.SetText(Strings.Options.resolution);
-
- mResolutionList = new ComboBox(mResolutionBackground, "ResolutionCombobox");
- var myModes = Graphics.Renderer.GetValidVideoModes();
- myModes?.ForEach(
- t =>
- {
- var item = mResolutionList.AddItem(t);
- item.Alignment = Pos.Left;
- }
- );
-
- //FPS Background
- mFpsBackground = new ImagePanel(mOptionsContainer, "FPSPanel");
-
- //Options - FPS Label
- mFpsLabel = new Label(mFpsBackground, "FPSLabel");
- mFpsLabel.SetText(Strings.Options.targetfps);
-
- //Options - FPS List
- mFpsList = new ComboBox(mFpsBackground, "FPSCombobox");
- mFpsList.AddItem(Strings.Options.vsync);
- mFpsList.AddItem(Strings.Options.fps30);
- mFpsList.AddItem(Strings.Options.fps60);
- mFpsList.AddItem(Strings.Options.fps90);
- mFpsList.AddItem(Strings.Options.fps120);
- mFpsList.AddItem(Strings.Options.unlimitedfps);
-
- //Options - Fullscreen Checkbox
- mFullscreen = new LabeledCheckBox(mOptionsContainer, "FullscreenCheckbox")
- {
- Text = Strings.Options.fullscreen
- };
-
- mAutocloseWindowsCheckbox = new LabeledCheckBox(mOptionsContainer, "AutocloseWindowsCheckbox")
- {
- Text = Strings.Options.AutocloseWindows
- };
-
- mEditKeybindingsBtn = new Button(mOptionsContainer, "KeybindingsButton") {Text = Strings.Controls.edit};
- mEditKeybindingsBtn.Clicked += EditKeybindingsButton_Clicked;
-
- //Options - Sound Label
- mSoundLabel = new Label(mOptionsContainer, "SoundLabel");
- mSoundLabel.SetText(Strings.Options.soundvolume.ToString(100));
-
- //Options - Sound Slider
- mSoundSlider = new HorizontalSlider(mOptionsContainer, "SoundSlider");
- mSoundSlider.Min = 0;
- mSoundSlider.Max = 100;
- mSoundSlider.ValueChanged += _soundSlider_ValueChanged;
-
- //Options - Music Label
- mMusicLabel = new Label(mOptionsContainer, "MusicLabel");
- mMusicLabel.SetText(Strings.Options.musicvolume.ToString(100));
-
- //Options - Music Slider
- mMusicSlider = new HorizontalSlider(mOptionsContainer, "MusicSlider");
- mMusicSlider.Min = 0;
- mMusicSlider.Max = 100;
- mMusicSlider.ValueChanged += _musicSlider_ValueChanged;
-
- //Controls Get Stored in the Controls Scroll Control
- mControlsContainer = new ScrollControl(mOptionsPanel, "ControlsContainer");
- mControlsContainer.EnableScroll(false, true);
- mControlsContainer.Hide();
-
- mApplyKeybindingsButton = new Button(mOptionsPanel, "ExitControlsButton");
- mApplyKeybindingsButton.Text = Strings.Options.apply;
- mApplyKeybindingsButton.Hide();
- mApplyKeybindingsButton.Clicked += ApplyKeybindingsButton_Clicked;
-
- mCancelKeybindingsButton = new Button(mOptionsPanel, "CancelControlsButton");
- mCancelKeybindingsButton.Text = Strings.Options.back;
- mCancelKeybindingsButton.Hide();
- mCancelKeybindingsButton.Clicked += CancelKeybindingsButton_Clicked;
-
- mRestoreKeybindingsButton = new Button(mOptionsPanel, "RestoreControlsButton");
- mRestoreKeybindingsButton.Text = Strings.Options.restore;
- mRestoreKeybindingsButton.Hide();
- mRestoreKeybindingsButton.Clicked += RestoreKeybindingsButton_Clicked;
-
- var row = 0;
- var defaultFont = GameContentManager.Current?.GetFont("sourcesansproblack", 16);
- foreach (Control control in Enum.GetValues(typeof(Control)))
- {
- var offset = row * 32;
- var name = Enum.GetName(typeof(Control), control)?.ToLower();
-
- var label = new Label(mControlsContainer, $"Control{Enum.GetName(typeof(Control), control)}Label")
- {
- Text = Strings.Controls.controldict[name],
- AutoSizeToContents = true,
- Font = defaultFont
- };
-
- label.SetBounds(8, 8 + offset, 0, 24);
- label.SetTextColor(new Color(255, 255, 255, 255), Label.ControlState.Normal);
-
- var key1 = new Button(mControlsContainer, $"Control{Enum.GetName(typeof(Control), control)}Button1")
- {
- Text = "",
- AutoSizeToContents = false,
- UserData = new KeyValuePair(control, 1),
- Font = defaultFont
- };
-
- key1.Clicked += Key_Clicked;
-
- var key2 = new Button(mControlsContainer, $"Control{Enum.GetName(typeof(Control), control)}Button2")
- {
- Text = "",
- AutoSizeToContents = false,
- UserData = new KeyValuePair(control, 2),
- Font = defaultFont
- };
-
- key2.Clicked += Key_Clicked;
-
- mKeyButtons.Add(control, new[] {key1, key2});
-
- row++;
- }
-
- //Options - Apply Button
- mApplyBtn = new Button(mOptionsContainer, "ApplyButton");
- mApplyBtn.SetText(Strings.Options.apply);
- mApplyBtn.Clicked += ApplyBtn_Clicked;
-
- //Options - Back Button
- mBackBtn = new Button(mOptionsContainer, "CancelButton");
- mBackBtn.SetText(Strings.Options.cancel);
- mBackBtn.Clicked += BackBtn_Clicked;
-
- Input.KeyDown += OnKeyDown;
- Input.MouseDown += OnKeyDown;
-
- mOptionsPanel.LoadJsonUi(
- mainMenu == null ? GameContentManager.UI.InGame : GameContentManager.UI.Menu,
- Graphics.Renderer.GetResolutionString()
- );
-
- CloseKeybindings();
- }
-
- private void Key_Clicked(Base sender, ClickedEventArgs arguments)
- {
- EditKeyPressed((Button) sender);
- }
-
- private void EditKeyPressed(Button sender)
- {
- if (mEdittingButton == null)
- {
- sender.Text = Strings.Controls.listening;
- mEdittingKey = ((KeyValuePair)sender.UserData).Value;
- mEdittingControl = ((KeyValuePair) sender.UserData).Key;
- mEdittingButton = sender;
- Interface.GwenInput.HandleInput = false;
- mListeningTimer = Timing.Global.Milliseconds + 3000;
- }
- }
-
- private void EditKeybindingsButton_Clicked(Base sender, ClickedEventArgs arguments)
- {
- //Determine if controls are currently being shown or not
- if (!mControlsContainer.IsVisible)
- {
- mControlsContainer.Show();
- mOptionsContainer.Hide();
- mOptionsHeader.SetText(Strings.Controls.title);
- mApplyKeybindingsButton.Show();
- mCancelKeybindingsButton.Show();
- mRestoreKeybindingsButton.Show();
- foreach (Control control in Enum.GetValues(typeof(Control)))
- {
- mKeyButtons[control][0].Text =
- Strings.Keys.keydict[
- Enum.GetName(typeof(Keys), mEdittingControls.ControlMapping[control].Key1).ToLower()];
-
- mKeyButtons[control][1].Text =
- Strings.Keys.keydict[
- Enum.GetName(typeof(Keys), mEdittingControls.ControlMapping[control].Key2).ToLower()];
- }
- }
- }
-
- private void ApplyKeybindingsButton_Clicked(Base sender, ClickedEventArgs arguments)
- {
- Controls.ActiveControls = mEdittingControls;
- Controls.ActiveControls.Save();
- CloseKeybindings();
- }
-
- private void CancelKeybindingsButton_Clicked(Base sender, ClickedEventArgs arguments)
- {
- mEdittingControls = new Controls(Controls.ActiveControls);
- CloseKeybindings();
- }
-
- private void RestoreKeybindingsButton_Clicked(Base sender, ClickedEventArgs arguments)
- {
- mEdittingControls.ResetDefaults();
- foreach (Control control in Enum.GetValues(typeof(Control)))
- {
- mKeyButtons[control][0].Text =
- Strings.Keys.keydict[
- Enum.GetName(typeof(Keys), mEdittingControls.ControlMapping[control].Key1).ToLower()];
-
- mKeyButtons[control][1].Text =
- Strings.Keys.keydict[
- Enum.GetName(typeof(Keys), mEdittingControls.ControlMapping[control].Key2).ToLower()];
- }
- }
-
- private void CloseKeybindings()
- {
- mControlsContainer.Hide();
- mOptionsContainer.Show();
- mOptionsHeader.SetText(Strings.Options.title);
- mApplyKeybindingsButton.Hide();
- mCancelKeybindingsButton.Hide();
- mRestoreKeybindingsButton.Hide();
- }
-
- private void OnKeyDown(Keys key)
- {
- if (mEdittingButton != null)
- {
- mEdittingControls.UpdateControl(mEdittingControl, mEdittingKey, key);
- if (mEdittingKey == 1)
- {
- mEdittingButton.Text =
- Strings.Keys.keydict[
- Enum.GetName(typeof(Keys), mEdittingControls.ControlMapping[mEdittingControl].Key1)
- .ToLower()];
- }
- else
- {
- mEdittingButton.Text =
- Strings.Keys.keydict[
- Enum.GetName(typeof(Keys), mEdittingControls.ControlMapping[mEdittingControl].Key2)
- .ToLower()];
- }
-
- if (key != Keys.None) {
- foreach (var control in mEdittingControls.ControlMapping)
- {
- if (control.Key != mEdittingControl)
- {
- if (control.Value.Key1 == key)
- {
- //Remove this mapping
- mEdittingControls.UpdateControl(control.Key, 1, Keys.None);
-
- //Update UI
- mKeyButtons[control.Key][0].Text = Strings.Keys.keydict[Enum.GetName(typeof(Keys), Keys.None).ToLower()];
- }
- if (control.Value.Key2 == key)
- {
- //Remove this mapping
- mEdittingControls.UpdateControl(control.Key, 2, Keys.None);
-
- //Update UI
- mKeyButtons[control.Key][1].Text = Strings.Keys.keydict[Enum.GetName(typeof(Keys), Keys.None).ToLower()];
- }
- }
- }
- }
-
- mEdittingButton.PlayHoverSound();
- mEdittingButton = null;
- Interface.GwenInput.HandleInput = true;
- }
- }
-
- //Methods
- public void Update()
- {
- if (mOptionsPanel.IsVisible && mEdittingButton != null && mListeningTimer < Timing.Global.Milliseconds)
- {
- OnKeyDown(Keys.None);
- }
- }
-
- public void Show()
- {
- if (mMainMenu == null)
- {
- mOptionsPanel.MakeModal(true);
- }
-
- mPreviousMusicVolume = Globals.Database.MusicVolume;
- mPreviousSoundVolume = Globals.Database.SoundVolume;
- mEdittingControls = new Controls(Controls.ActiveControls);
- if (Graphics.Renderer.GetValidVideoModes().Count > 0)
- {
- string resolutionLabel;
- if (Graphics.Renderer.HasOverrideResolution)
- {
- resolutionLabel = Strings.Options.ResolutionCustom;
-
- if (mCustomResolutionMenuItem == null)
- {
- mCustomResolutionMenuItem = mResolutionList.AddItem(Strings.Options.ResolutionCustom);
- }
-
- mCustomResolutionMenuItem.Show();
- }
- else
- {
- resolutionLabel = Graphics.Renderer.GetValidVideoModes()[Globals.Database.TargetResolution];
- }
-
- mResolutionList.SelectByText(resolutionLabel);
- }
-
- switch (Globals.Database.TargetFps)
- {
- case -1: //Unlimited
- mFpsList.SelectByText(Strings.Options.unlimitedfps);
-
- break;
- case 0: //VSYNC
- mFpsList.SelectByText(Strings.Options.vsync);
-
- break;
- case 1:
- mFpsList.SelectByText(Strings.Options.fps30);
-
- break;
- case 2:
- mFpsList.SelectByText(Strings.Options.fps60);
-
- break;
- case 3:
- mFpsList.SelectByText(Strings.Options.fps90);
-
- break;
- case 4:
- mFpsList.SelectByText(Strings.Options.fps120);
-
- break;
- default:
- mFpsList.SelectByText(Strings.Options.vsync);
-
- break;
- }
-
- mAutocloseWindowsCheckbox.IsChecked = Globals.Database.HideOthersOnWindowOpen;
- mFullscreen.IsChecked = Globals.Database.FullScreen;
- mMusicSlider.Value = Globals.Database.MusicVolume;
- mSoundSlider.Value = Globals.Database.SoundVolume;
- mMusicLabel.Text = Strings.Options.musicvolume.ToString((int) mMusicSlider.Value);
- mSoundLabel.Text = Strings.Options.soundvolume.ToString((int) mSoundSlider.Value);
- mOptionsPanel.IsHidden = false;
- }
-
- public bool IsVisible()
- {
- return !mOptionsPanel.IsHidden;
- }
-
- public void Hide()
- {
- if (mMainMenu == null)
- {
- mOptionsPanel.RemoveModal();
- }
-
- mOptionsPanel.IsHidden = true;
- }
-
- //Input Handlers
- void BackBtn_Clicked(Base sender, ClickedEventArgs arguments)
- {
- Globals.Database.MusicVolume = mPreviousMusicVolume;
- Globals.Database.SoundVolume = mPreviousSoundVolume;
- Audio.UpdateGlobalVolume();
- if (Globals.GameState == GameStates.Menu)
- {
- Hide();
- mMainMenu.Show();
- }
- else
- {
- Hide();
- }
- }
-
- void _musicSlider_ValueChanged(Base sender, EventArgs arguments)
- {
- mMusicLabel.Text = Strings.Options.musicvolume.ToString((int) mMusicSlider.Value);
- Globals.Database.MusicVolume = (int) mMusicSlider.Value;
- Audio.UpdateGlobalVolume();
- }
-
- void _soundSlider_ValueChanged(Base sender, EventArgs arguments)
- {
- mSoundLabel.Text = Strings.Options.soundvolume.ToString((int) mSoundSlider.Value);
- Globals.Database.SoundVolume = (int) mSoundSlider.Value;
- Audio.UpdateGlobalVolume();
- }
-
- void ApplyBtn_Clicked(Base sender, ClickedEventArgs arguments)
- {
- var shouldReset = false;
- var resolution = mResolutionList.SelectedItem;
- var validVideoModes = Graphics.Renderer.GetValidVideoModes();
- var targetResolution = validVideoModes?.FindIndex(videoMode => string.Equals(videoMode, resolution.Text)) ?? -1;
- if (targetResolution > -1)
- {
- shouldReset = Globals.Database.TargetResolution != targetResolution || Graphics.Renderer.HasOverrideResolution;
- Globals.Database.TargetResolution = targetResolution;
- }
-
- Globals.Database.HideOthersOnWindowOpen = mAutocloseWindowsCheckbox.IsChecked;
- if (Globals.Database.FullScreen != mFullscreen.IsChecked)
- {
- Globals.Database.FullScreen = mFullscreen.IsChecked;
- shouldReset = true;
- }
-
- var newFps = 0;
- if (mFpsList.SelectedItem.Text == Strings.Options.unlimitedfps)
- {
- newFps = -1;
- }
- else if (mFpsList.SelectedItem.Text == Strings.Options.fps30)
- {
- newFps = 1;
- }
- else if (mFpsList.SelectedItem.Text == Strings.Options.fps60)
- {
- newFps = 2;
- }
- else if (mFpsList.SelectedItem.Text == Strings.Options.fps90)
- {
- newFps = 3;
- }
- else if (mFpsList.SelectedItem.Text == Strings.Options.fps120)
- {
- newFps = 4;
- }
-
- if (newFps != Globals.Database.TargetFps)
- {
- shouldReset = true;
- Globals.Database.TargetFps = newFps;
- }
-
- Globals.Database.MusicVolume = (int) mMusicSlider.Value;
- Globals.Database.SoundVolume = (int) mSoundSlider.Value;
- Audio.UpdateGlobalVolume();
- Globals.Database.SavePreferences();
- if (shouldReset)
- {
- mCustomResolutionMenuItem?.Hide();
- Graphics.Renderer.OverrideResolution = Resolution.Empty;
- Graphics.Renderer.Init();
- }
-
- if (Globals.GameState == GameStates.InGame)
- {
- Hide();
- }
- else
- {
- Hide();
- mMainMenu.Show();
- }
- }
-
- }
-
-}
diff --git a/Intersect.Client/Interface/Shared/SettingsWindow.cs b/Intersect.Client/Interface/Shared/SettingsWindow.cs
new file mode 100644
index 0000000000..c053656bc9
--- /dev/null
+++ b/Intersect.Client/Interface/Shared/SettingsWindow.cs
@@ -0,0 +1,726 @@
+using System;
+using System.Collections.Generic;
+
+using Intersect.Client.Core;
+using Intersect.Client.Core.Controls;
+using Intersect.Client.Framework.File_Management;
+using Intersect.Client.Framework.GenericClasses;
+using Intersect.Client.Framework.Graphics;
+using Intersect.Client.Framework.Gwen;
+using Intersect.Client.Framework.Gwen.Control;
+using Intersect.Client.Framework.Gwen.Control.EventArguments;
+using Intersect.Client.General;
+using Intersect.Client.Interface.Menu;
+using Intersect.Client.Localization;
+using Intersect.Utilities;
+
+namespace Intersect.Client.Interface.Shared
+{
+ public class SettingsWindow
+ {
+ // Parent Window.
+ private readonly MainMenu mMainMenu;
+
+ // Settings Window.
+ private readonly Label mSettingsHeader;
+
+ private readonly ImagePanel mSettingsPanel;
+
+ private readonly Button mSettingsApplyBtn;
+
+ private readonly Button mSettingsCancelBtn;
+
+ // Option Containers.
+ private readonly ScrollControl mGameSettingsContainer;
+
+ private readonly ScrollControl mVideoSettingsContainer;
+
+ private readonly ScrollControl mAudioSettingsContainer;
+
+ private readonly ScrollControl mKeybindingSettingsContainer;
+
+ // Tabs.
+ private readonly Button mGameSettingsTab;
+
+ private readonly Button mVideoSettingsTab;
+
+ private readonly Button mAudioSettingsTab;
+
+ private readonly Button mKeybindingSettingsTab;
+
+ // Game Settings.
+ // TODO: Place our configurable gameplay related variables here!
+
+ // Video Settings.
+ private readonly ImagePanel mResolutionBackground;
+
+ private readonly Label mResolutionLabel;
+
+ private readonly ComboBox mResolutionList;
+
+ private MenuItem mCustomResolutionMenuItem;
+
+ private readonly ImagePanel mFpsBackground;
+
+ private readonly Label mFpsLabel;
+
+ private readonly ComboBox mFpsList;
+
+ private readonly LabeledCheckBox mAutocloseWindowsCheckbox;
+
+ private readonly LabeledCheckBox mFullscreenCheckbox;
+
+ // Audio Settings.
+ private readonly HorizontalSlider mMusicSlider;
+
+ private int mPreviousMusicVolume;
+
+ private readonly Label mMusicLabel;
+
+ private readonly HorizontalSlider mSoundSlider;
+
+ private int mPreviousSoundVolume;
+
+ private readonly Label mSoundLabel;
+
+ // Keybinding Settings.
+ private Control mKeybindingEditControl;
+
+ private Controls mKeybindingEditControls;
+
+ private Button mKeybindingEditBtn;
+
+ private readonly Button mKeybindingRestoreBtn;
+
+ private long mKeybindingListeningTimer;
+
+ private int mKeyEdit = -1;
+
+ private readonly Dictionary mKeybindingBtns = new Dictionary();
+
+ // Initialize.
+ public SettingsWindow(Canvas parent, MainMenu mainMenu)
+ {
+ // Assign References.
+ mMainMenu = mainMenu;
+
+ // Main Menu Window.
+ mSettingsPanel = new ImagePanel(parent, "SettingsWindow") {IsHidden = true};
+ Interface.InputBlockingElements.Add(mSettingsPanel);
+
+ // Menu Header.
+ mSettingsHeader = new Label(mSettingsPanel, "SettingsHeader");
+ mSettingsHeader.SetText(Strings.Settings.Title);
+
+ // Apply Button.
+ mSettingsApplyBtn = new Button(mSettingsPanel, "SettingsApplyBtn");
+ mSettingsApplyBtn.SetText(Strings.Settings.Apply);
+ mSettingsApplyBtn.Clicked += SettingsApplyBtn_Clicked;
+
+ // Cancel Button.
+ mSettingsCancelBtn = new Button(mSettingsPanel, "SettingsCancelBtn");
+ mSettingsCancelBtn.SetText(Strings.Settings.Cancel);
+ mSettingsCancelBtn.Clicked += SettingsCancelBtn_Clicked;
+
+ #region InitGameSettings
+
+ // Init GameSettings Tab.
+ mGameSettingsTab = new Button(mSettingsPanel, "GameSettingsTab");
+ mGameSettingsTab.Text = Strings.Settings.GameSettingsTab;
+ mGameSettingsTab.Clicked += GameSettingsTab_Clicked;
+
+ // Game Settings Get Stored in the GameSettings Scroll Control.
+ mGameSettingsContainer = new ScrollControl(mSettingsPanel, "GameSettingsContainer");
+ mGameSettingsContainer.EnableScroll(false, true);
+
+ // TODO: Place our configurable gameplay related settings into their respective container for initialization here!
+
+ #endregion
+
+ #region InitVideoSettings
+
+ // Init VideoSettings Tab.
+ mVideoSettingsTab = new Button(mSettingsPanel, "VideoSettingsTab");
+ mVideoSettingsTab.Text = Strings.Settings.VideoSettingsTab;
+ mVideoSettingsTab.Clicked += VideoSettingsTab_Clicked;
+
+ // Video Settings Get Stored in the VideoSettings Scroll Control.
+ mVideoSettingsContainer = new ScrollControl(mSettingsPanel, "VideoSettingsContainer");
+ mVideoSettingsContainer.EnableScroll(false, false);
+
+ // Video Settings - Resolution Background.
+ mResolutionBackground = new ImagePanel(mVideoSettingsContainer, "ResolutionPanel");
+
+ // Video Settings - Resolution Label.
+ mResolutionLabel = new Label(mResolutionBackground, "ResolutionLabel");
+ mResolutionLabel.SetText(Strings.Settings.Resolution);
+
+ // Video Settings - Resolution List.
+ mResolutionList = new ComboBox(mResolutionBackground, "ResolutionCombobox");
+ var myModes = Graphics.Renderer.GetValidVideoModes();
+ myModes?.ForEach(
+ t =>
+ {
+ var item = mResolutionList.AddItem(t);
+ item.Alignment = Pos.Left;
+ }
+ );
+
+ // Video Settings - FPS Background.
+ mFpsBackground = new ImagePanel(mVideoSettingsContainer, "FPSPanel");
+
+ // Video Settings - FPS Label.
+ mFpsLabel = new Label(mFpsBackground, "FPSLabel");
+ mFpsLabel.SetText(Strings.Settings.TargetFps);
+
+ // Video Settings - FPS List.
+ mFpsList = new ComboBox(mFpsBackground, "FPSCombobox");
+ mFpsList.AddItem(Strings.Settings.Vsync);
+ mFpsList.AddItem(Strings.Settings.Fps30);
+ mFpsList.AddItem(Strings.Settings.Fps60);
+ mFpsList.AddItem(Strings.Settings.Fps90);
+ mFpsList.AddItem(Strings.Settings.Fps120);
+ mFpsList.AddItem(Strings.Settings.UnlimitedFps);
+
+ // Video Settings - Fullscreen Checkbox.
+ mFullscreenCheckbox = new LabeledCheckBox(mVideoSettingsContainer, "FullscreenCheckbox")
+ {
+ Text = Strings.Settings.Fullscreen
+ };
+
+ // Video Settings - AutoCloseWindows Checkbox.
+ mAutocloseWindowsCheckbox = new LabeledCheckBox(mVideoSettingsContainer, "AutocloseWindowsCheckbox")
+ {
+ Text = Strings.Settings.AutoCloseWindows
+ };
+
+ #endregion
+
+ #region InitAudioSettings
+
+ // Init AudioSettingsTab.
+ mAudioSettingsTab = new Button(mSettingsPanel, "AudioSettingsTab");
+ mAudioSettingsTab.Text = Strings.Settings.AudioSettingsTab;
+ mAudioSettingsTab.Clicked += AudioSettingsTab_Clicked;
+
+ // Audio Settings Get Stored in the AudioSettings Scroll Control.
+ mAudioSettingsContainer = new ScrollControl(mSettingsPanel, "AudioSettingsContainer");
+ mAudioSettingsContainer.EnableScroll(false, false);
+
+ // Audio Settings - Sound Label
+ mSoundLabel = new Label(mAudioSettingsContainer, "SoundLabel");
+ mSoundLabel.SetText(Strings.Settings.SoundVolume.ToString(100));
+
+ // Audio Settings - Sound Slider
+ mSoundSlider = new HorizontalSlider(mAudioSettingsContainer, "SoundSlider");
+ mSoundSlider.Min = 0;
+ mSoundSlider.Max = 100;
+ mSoundSlider.ValueChanged += SoundSlider_ValueChanged;
+
+ // Audio Settings - Music Label
+ mMusicLabel = new Label(mAudioSettingsContainer, "MusicLabel");
+ mMusicLabel.SetText(Strings.Settings.MusicVolume.ToString(100));
+
+ // Audio Settings - Music Slider
+ mMusicSlider = new HorizontalSlider(mAudioSettingsContainer, "MusicSlider");
+ mMusicSlider.Min = 0;
+ mMusicSlider.Max = 100;
+ mMusicSlider.ValueChanged += MusicSlider_ValueChanged;
+
+ #endregion
+
+ #region InitKeybindingSettings
+
+ // Init KeybindingsSettings Tab.
+ mKeybindingSettingsTab = new Button(mSettingsPanel, "KeybindingSettingsTab");
+ mKeybindingSettingsTab.Text = Strings.Settings.KeyBindingSettingsTab;
+ mKeybindingSettingsTab.Clicked += KeybindingSettingsTab_Clicked;
+
+ // KeybindingSettings Get Stored in the KeybindingSettings Scroll Control
+ mKeybindingSettingsContainer = new ScrollControl(mSettingsPanel, "KeybindingSettingsContainer");
+ mKeybindingSettingsContainer.EnableScroll(false, true);
+
+ // Keybinding Settings - Restore Default Keys Button.
+ mKeybindingRestoreBtn = new Button(mSettingsPanel, "KeybindingsRestoreBtn");
+ mKeybindingRestoreBtn.Text = Strings.Settings.Restore;
+ mKeybindingRestoreBtn.Clicked += KeybindingsRestoreBtn_Clicked;
+
+ // Keybinding Settings - Controls
+ var row = 0;
+ var defaultFont = GameContentManager.Current?.GetFont("sourcesansproblack", 16);
+ foreach (Control control in Enum.GetValues(typeof(Control)))
+ {
+ var offset = row * 32;
+ var name = Enum.GetName(typeof(Control), control)?.ToLower();
+
+ var label = new Label(mKeybindingSettingsContainer, $"Control{Enum.GetName(typeof(Control), control)}Label");
+ label.Text = Strings.Controls.controldict[name];
+ label.AutoSizeToContents = true;
+ label.Font = defaultFont;
+ label.SetBounds(8, 8 + offset, 0, 24);
+ label.SetTextColor(new Color(255, 255, 255, 255), Label.ControlState.Normal);
+
+ var key1 = new Button(mKeybindingSettingsContainer, $"Control{Enum.GetName(typeof(Control), control)}Button1");
+ key1.Text = "";
+ key1.AutoSizeToContents = false;
+ key1.UserData = new KeyValuePair(control, 1);
+ key1.Font = defaultFont;
+
+ key1.Clicked += Key_Clicked;
+
+ var key2 = new Button(mKeybindingSettingsContainer, $"Control{Enum.GetName(typeof(Control), control)}Button2")
+ {
+ Text = "",
+ AutoSizeToContents = false,
+ UserData = new KeyValuePair(control, 2),
+ Font = defaultFont
+ };
+
+ key2.Clicked += Key_Clicked;
+
+ mKeybindingBtns.Add(control, new[] {key1, key2});
+
+ row++;
+ }
+
+ #endregion
+
+ Input.KeyDown += OnKeyDown;
+ Input.MouseDown += OnKeyDown;
+
+ mSettingsPanel.LoadJsonUi(
+ mainMenu == null ? GameContentManager.UI.InGame : GameContentManager.UI.Menu,
+ Graphics.Renderer.GetResolutionString()
+ );
+ }
+
+ private void GameSettingsTab_Clicked(Base sender, ClickedEventArgs arguments)
+ {
+ // Determine if GameSettingsContainer is currently being shown or not.
+ if (!mGameSettingsContainer.IsVisible)
+ {
+ // Disable the GameSettingsTab to fake it being selected visually.
+ mGameSettingsTab.Disable();
+ mVideoSettingsTab.Enable();
+ mAudioSettingsTab.Enable();
+ mKeybindingSettingsTab.Enable();
+
+ // Containers.
+ mGameSettingsContainer.Show();
+ mVideoSettingsContainer.Hide();
+ mAudioSettingsContainer.Hide();
+ mKeybindingSettingsContainer.Hide();
+
+ // Restore Default KeybindingSettings Button.
+ mKeybindingRestoreBtn.Hide();
+ }
+ }
+
+ private void VideoSettingsTab_Clicked(Base sender, ClickedEventArgs arguments)
+ {
+ // Determine if VideoSettingsContainer is currently being shown or not.
+ if (!mVideoSettingsContainer.IsVisible)
+ {
+ // Disable the VideoSettingsTab to fake it being selected visually.
+ mGameSettingsTab.Enable();
+ mVideoSettingsTab.Disable();
+ mAudioSettingsTab.Enable();
+ mKeybindingSettingsTab.Enable();
+
+ // Containers.
+ mGameSettingsContainer.Hide();
+ mVideoSettingsContainer.Show();
+ mAudioSettingsContainer.Hide();
+ mKeybindingSettingsContainer.Hide();
+
+ // Restore Default KeybindingSettings Button.
+ mKeybindingRestoreBtn.Hide();
+ }
+ }
+
+ private void AudioSettingsTab_Clicked(Base sender, ClickedEventArgs arguments)
+ {
+ // Determine if AudioSettingsContainer is currently being shown or not.
+ if (!mAudioSettingsContainer.IsVisible)
+ {
+ // Disable the AudioSettingsTab to fake it being selected visually.
+ mGameSettingsTab.Enable();
+ mVideoSettingsTab.Enable();
+ mAudioSettingsTab.Disable();
+ mKeybindingSettingsTab.Enable();
+
+ // Containers.
+ mGameSettingsContainer.Hide();
+ mVideoSettingsContainer.Hide();
+ mAudioSettingsContainer.Show();
+ mKeybindingSettingsContainer.Hide();
+
+ // Restore Default KeybindingSettings Button.
+ mKeybindingRestoreBtn.Hide();
+ }
+ }
+
+ private void KeybindingSettingsTab_Clicked(Base sender, ClickedEventArgs arguments)
+ {
+ // Determine if controls are currently being shown or not.
+ if (!mKeybindingSettingsContainer.IsVisible)
+ {
+ // Disable the KeybindingSettingsTab to fake it being selected visually.
+ mGameSettingsTab.Enable();
+ mVideoSettingsTab.Enable();
+ mAudioSettingsTab.Enable();
+ mKeybindingSettingsTab.Disable();
+
+ // Containers.
+ mGameSettingsContainer.Hide();
+ mVideoSettingsContainer.Hide();
+ mAudioSettingsContainer.Hide();
+ mKeybindingSettingsContainer.Show();
+
+ // Restore Default KeybindingSettings Button.
+ mKeybindingRestoreBtn.Show();
+
+ // KeybindingBtns.
+ foreach (Control control in Enum.GetValues(typeof(Control)))
+ {
+ mKeybindingBtns[control][0].Text =
+ Strings.Keys.keydict[
+ Enum.GetName(typeof(Keys), mKeybindingEditControls.ControlMapping[control].Key1).ToLower()];
+
+ mKeybindingBtns[control][1].Text =
+ Strings.Keys.keydict[
+ Enum.GetName(typeof(Keys), mKeybindingEditControls.ControlMapping[control].Key2).ToLower()];
+ }
+ }
+ }
+
+ private void LoadSettingsWindow()
+ {
+ // SettingsWindow Title.
+ mSettingsHeader.SetText(Strings.Settings.Title);
+
+ // Containers.
+ mGameSettingsContainer.Show();
+ mVideoSettingsContainer.Hide();
+ mAudioSettingsContainer.Hide();
+ mKeybindingSettingsContainer.Hide();
+
+ // Tabs.
+ mGameSettingsTab.Show();
+ mVideoSettingsTab.Show();
+ mAudioSettingsTab.Show();
+ mKeybindingSettingsTab.Show();
+
+ // Disable the GameSettingsTab to fake it being selected visually by default.
+ mGameSettingsTab.Disable();
+ mVideoSettingsTab.Enable();
+ mAudioSettingsTab.Enable();
+ mKeybindingSettingsTab.Enable();
+
+ // Buttons.
+ mSettingsApplyBtn.Show();
+ mSettingsCancelBtn.Show();
+ mKeybindingRestoreBtn.Hide();
+ }
+
+ private void OnKeyDown(Keys key)
+ {
+ if (mKeybindingEditBtn != null)
+ {
+ mKeybindingEditControls.UpdateControl(mKeybindingEditControl, mKeyEdit, key);
+ if (mKeyEdit == 1)
+ {
+ mKeybindingEditBtn.Text =
+ Strings.Keys.keydict[Enum.GetName(typeof(Keys), mKeybindingEditControls.ControlMapping[mKeybindingEditControl].Key1).ToLower()];
+ }
+ else
+ {
+ mKeybindingEditBtn.Text =
+ Strings.Keys.keydict[Enum.GetName(typeof(Keys), mKeybindingEditControls.ControlMapping[mKeybindingEditControl].Key2).ToLower()];
+ }
+
+ if (key != Keys.None)
+ {
+ foreach (var control in mKeybindingEditControls.ControlMapping)
+ {
+ if (control.Key != mKeybindingEditControl)
+ {
+ if (control.Value.Key1 == key)
+ {
+ // Remove this mapping.
+ mKeybindingEditControls.UpdateControl(control.Key, 1, Keys.None);
+
+ // Update UI.
+ mKeybindingBtns[control.Key][0].Text = Strings.Keys.keydict[Enum.GetName(typeof(Keys), Keys.None).ToLower()];
+ }
+
+ if (control.Value.Key2 == key)
+ {
+ // Remove this mapping.
+ mKeybindingEditControls.UpdateControl(control.Key, 2, Keys.None);
+
+ // Update UI.
+ mKeybindingBtns[control.Key][1].Text = Strings.Keys.keydict[Enum.GetName(typeof(Keys), Keys.None).ToLower()];
+ }
+ }
+ }
+ }
+
+ mKeybindingEditBtn.PlayHoverSound();
+ mKeybindingEditBtn = null;
+ Interface.GwenInput.HandleInput = true;
+ }
+ }
+
+ // Methods.
+ public void Update()
+ {
+ if (mSettingsPanel.IsVisible &&
+ mKeybindingEditBtn != null &&
+ mKeybindingListeningTimer < Timing.Global.Milliseconds)
+ {
+ OnKeyDown(Keys.None);
+ }
+ }
+
+ public void Show()
+ {
+ if (mMainMenu == null)
+ {
+ mSettingsPanel.MakeModal(true);
+ }
+
+ mKeybindingEditControls = new Controls(Controls.ActiveControls);
+ if (Graphics.Renderer.GetValidVideoModes().Count > 0)
+ {
+ string resolutionLabel;
+ if (Graphics.Renderer.HasOverrideResolution)
+ {
+ resolutionLabel = Strings.Settings.ResolutionCustom;
+
+ if (mCustomResolutionMenuItem == null)
+ {
+ mCustomResolutionMenuItem = mResolutionList.AddItem(Strings.Settings.ResolutionCustom);
+ }
+
+ mCustomResolutionMenuItem.Show();
+ }
+ else
+ {
+ resolutionLabel = Graphics.Renderer.GetValidVideoModes()[Globals.Database.TargetResolution];
+ }
+
+ mResolutionList.SelectByText(resolutionLabel);
+ }
+
+ switch (Globals.Database.TargetFps)
+ {
+ case -1: // Unlimited.
+ mFpsList.SelectByText(Strings.Settings.UnlimitedFps);
+
+ break;
+ case 0: // Vertical Sync.
+ mFpsList.SelectByText(Strings.Settings.Vsync);
+
+ break;
+ case 1: // 30 Frames per second.
+ mFpsList.SelectByText(Strings.Settings.Fps30);
+
+ break;
+ case 2: // 60 Frames per second.
+ mFpsList.SelectByText(Strings.Settings.Fps60);
+
+ break;
+ case 3: // 90 Frames per second.
+ mFpsList.SelectByText(Strings.Settings.Fps90);
+
+ break;
+ case 4: // 120 Frames per second.
+ mFpsList.SelectByText(Strings.Settings.Fps120);
+
+ break;
+ default:
+ mFpsList.SelectByText(Strings.Settings.Vsync);
+
+ break;
+ }
+
+ // Game Settings.
+ //
+
+ // Video Settings.
+ mAutocloseWindowsCheckbox.IsChecked = Globals.Database.HideOthersOnWindowOpen;
+ mFullscreenCheckbox.IsChecked = Globals.Database.FullScreen;
+
+ // Audio Settings.
+ mPreviousMusicVolume = Globals.Database.MusicVolume;
+ mPreviousSoundVolume = Globals.Database.SoundVolume;
+ mMusicSlider.Value = Globals.Database.MusicVolume;
+ mSoundSlider.Value = Globals.Database.SoundVolume;
+ mMusicLabel.Text = Strings.Settings.MusicVolume.ToString((int) mMusicSlider.Value);
+ mSoundLabel.Text = Strings.Settings.SoundVolume.ToString((int) mSoundSlider.Value);
+
+ // SettingsWindow is not hidden anymore.
+ mSettingsPanel.IsHidden = false;
+
+ // Load every GUI element to their default state when showing up the settings window (pressed tabs, containers, etc.)
+ LoadSettingsWindow();
+ }
+
+ public bool IsVisible()
+ {
+ return !mSettingsPanel.IsHidden;
+ }
+
+ public void Hide()
+ {
+ if (mMainMenu == null)
+ {
+ mSettingsPanel.RemoveModal();
+ }
+
+ mSettingsPanel.IsHidden = true;
+ }
+
+ // Input Handlers
+ private void MusicSlider_ValueChanged(Base sender, EventArgs arguments)
+ {
+ mMusicLabel.Text = Strings.Settings.MusicVolume.ToString((int) mMusicSlider.Value);
+ Globals.Database.MusicVolume = (int) mMusicSlider.Value;
+ Audio.UpdateGlobalVolume();
+ }
+
+ private void SoundSlider_ValueChanged(Base sender, EventArgs arguments)
+ {
+ mSoundLabel.Text = Strings.Settings.SoundVolume.ToString((int) mSoundSlider.Value);
+ Globals.Database.SoundVolume = (int) mSoundSlider.Value;
+ Audio.UpdateGlobalVolume();
+ }
+
+ private void Key_Clicked(Base sender, ClickedEventArgs arguments)
+ {
+ EditKeyPressed((Button) sender);
+ }
+
+ private void EditKeyPressed(Button sender)
+ {
+ if (mKeybindingEditBtn == null)
+ {
+ sender.Text = Strings.Controls.listening;
+ mKeyEdit = ((KeyValuePair) sender.UserData).Value;
+ mKeybindingEditControl = ((KeyValuePair) sender.UserData).Key;
+ mKeybindingEditBtn = sender;
+ Interface.GwenInput.HandleInput = false;
+ mKeybindingListeningTimer = Timing.Global.Milliseconds + 3000;
+ }
+ }
+
+ private void KeybindingsRestoreBtn_Clicked(Base sender, ClickedEventArgs arguments)
+ {
+ mKeybindingEditControls.ResetDefaults();
+ foreach (Control control in Enum.GetValues(typeof(Control)))
+ {
+ mKeybindingBtns[control][0].Text =
+ Strings.Keys.keydict[
+ Enum.GetName(typeof(Keys), mKeybindingEditControls.ControlMapping[control].Key1).ToLower()];
+
+ mKeybindingBtns[control][1].Text =
+ Strings.Keys.keydict[
+ Enum.GetName(typeof(Keys), mKeybindingEditControls.ControlMapping[control].Key2).ToLower()];
+ }
+ }
+
+ private void SettingsApplyBtn_Clicked(Base sender, ClickedEventArgs arguments)
+ {
+ var shouldReset = false;
+ var resolution = mResolutionList.SelectedItem;
+ var validVideoModes = Graphics.Renderer.GetValidVideoModes();
+ var targetResolution = validVideoModes?.FindIndex(videoMode => string.Equals(videoMode, resolution.Text)) ?? -1;
+
+ if (targetResolution > -1)
+ {
+ shouldReset = Globals.Database.TargetResolution != targetResolution || Graphics.Renderer.HasOverrideResolution;
+ Globals.Database.TargetResolution = targetResolution;
+ }
+
+ Globals.Database.HideOthersOnWindowOpen = mAutocloseWindowsCheckbox.IsChecked;
+ if (Globals.Database.FullScreen != mFullscreenCheckbox.IsChecked)
+ {
+ Globals.Database.FullScreen = mFullscreenCheckbox.IsChecked;
+ shouldReset = true;
+ }
+
+ var newFps = 0;
+ if (mFpsList.SelectedItem.Text == Strings.Settings.UnlimitedFps)
+ {
+ newFps = -1;
+ }
+ else if (mFpsList.SelectedItem.Text == Strings.Settings.Fps30)
+ {
+ newFps = 1;
+ }
+ else if (mFpsList.SelectedItem.Text == Strings.Settings.Fps60)
+ {
+ newFps = 2;
+ }
+ else if (mFpsList.SelectedItem.Text == Strings.Settings.Fps90)
+ {
+ newFps = 3;
+ }
+ else if (mFpsList.SelectedItem.Text == Strings.Settings.Fps120)
+ {
+ newFps = 4;
+ }
+
+ if (newFps != Globals.Database.TargetFps)
+ {
+ shouldReset = true;
+ Globals.Database.TargetFps = newFps;
+ }
+
+ // Save Settings.
+ Globals.Database.MusicVolume = (int) mMusicSlider.Value;
+ Globals.Database.SoundVolume = (int) mSoundSlider.Value;
+ Audio.UpdateGlobalVolume();
+ Controls.ActiveControls = mKeybindingEditControls;
+ Controls.ActiveControls.Save();
+ Globals.Database.SavePreferences();
+
+ if (shouldReset)
+ {
+ mCustomResolutionMenuItem?.Hide();
+ Graphics.Renderer.OverrideResolution = Resolution.Empty;
+ Graphics.Renderer.Init();
+ }
+
+ if (Globals.GameState == GameStates.Menu)
+ {
+ Hide();
+ mMainMenu.Show();
+ }
+ else if (Globals.GameState == GameStates.InGame)
+ {
+ Hide();
+ }
+ }
+
+ private void SettingsCancelBtn_Clicked(Base sender, ClickedEventArgs arguments)
+ {
+ // Update previously saved values in order to discard changes.
+ Globals.Database.MusicVolume = mPreviousMusicVolume;
+ Globals.Database.SoundVolume = mPreviousSoundVolume;
+ Audio.UpdateGlobalVolume();
+ mKeybindingEditControls = new Controls(Controls.ActiveControls);
+
+ if (Globals.GameState == GameStates.Menu)
+ {
+ Hide();
+ mMainMenu.Show();
+ }
+ else if (Globals.GameState == GameStates.InGame)
+ {
+ Hide();
+ }
+ }
+ }
+}
diff --git a/Intersect.Client/Intersect.Client.csproj b/Intersect.Client/Intersect.Client.csproj
index 88fff79586..08b71c2b06 100644
--- a/Intersect.Client/Intersect.Client.csproj
+++ b/Intersect.Client/Intersect.Client.csproj
@@ -116,6 +116,7 @@
+
@@ -201,7 +202,6 @@
-
diff --git a/Intersect.Client/Localization/Strings.cs b/Intersect.Client/Localization/Strings.cs
index db79fcc5b2..0e899dc825 100644
--- a/Intersect.Client/Localization/Strings.cs
+++ b/Intersect.Client/Localization/Strings.cs
@@ -567,12 +567,8 @@ public struct Controls
{"togglegui", @"Toggle Interface:"}
};
- public static LocalizedString edit = @"Edit Controls";
-
public static LocalizedString listening = @"Listening";
- public static LocalizedString title = @"Controls";
-
}
public struct Crafting
@@ -1214,62 +1210,92 @@ public struct Main
public struct MainMenu
{
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Credits = @"Credits";
- public static LocalizedString credits = @"Credits";
-
- public static LocalizedString exit = @"Exit";
-
- public static LocalizedString login = @"Login";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Exit = @"Exit";
- public static LocalizedString options = @"Settings";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Login = @"Login";
- public static LocalizedString optionstooltip = @"";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Register = @"Register";
- public static LocalizedString register = @"Register";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Settings = @"Settings";
- public static LocalizedString title = @"Main Menu";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString SettingsTooltip = @"";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Title = @"Main Menu";
}
- public struct Options
+ public struct Settings
{
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Apply = @"Apply";
- public static LocalizedString fps30 = @"30";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString AudioSettingsTab = @"Audio";
- public static LocalizedString fps60 = @"60";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString AutoCloseWindows = @"Auto-close Windows";
- public static LocalizedString fps90 = @"90";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Cancel = @"Cancel";
- public static LocalizedString fps120 = @"120";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Fps120 = @"120";
- public static LocalizedString apply = @"Apply";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Fps30 = @"30";
- public static LocalizedString back = @"Back";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Fps60 = @"60";
- public static LocalizedString cancel = @"Cancel";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Fps90 = @"90";
- public static LocalizedString fullscreen = @"Fullscreen";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Fullscreen = @"Fullscreen";
- public static LocalizedString AutocloseWindows = @"Auto-close Windows";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString GameSettingsTab = @"Game";
- public static LocalizedString musicvolume = @"Music Volume: {00}%";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString KeyBindingSettingsTab = @"Controls";
- public static LocalizedString resolution = @"Resolution:";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString MusicVolume = @"Music Volume: {00}%";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Resolution = @"Resolution:";
+
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public static LocalizedString ResolutionCustom = @"Custom Resolution";
- public static LocalizedString restore = @"Restore Defaults";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Restore = @"Restore Defaults";
- public static LocalizedString soundvolume = @"Sound Volume: {00}%";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString SoundVolume = @"Sound Volume: {00}%";
- public static LocalizedString targetfps = @"Target FPS:";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString TargetFps = @"Target FPS:";
- public static LocalizedString title = @"Options";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Title = @"Settings";
- public static LocalizedString unlimitedfps = @"No Limit";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString UnlimitedFps = @"No Limit";
- public static LocalizedString vsync = @"V-Sync";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString VideoSettingsTab = @"Video";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Vsync = @"V-Sync";
}
public struct Parties
@@ -1597,19 +1623,23 @@ public struct Trading
public struct EscapeMenu
{
-
- public static LocalizedString Title = @"Menu";
-
- public static LocalizedString Options = @"Options";
-
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public static LocalizedString CharacterSelect = @"Characters";
- public static LocalizedString Logout = @"Logout";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Close = @"Close";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public static LocalizedString ExitToDesktop = @"Desktop";
- public static LocalizedString Close = @"Close";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Logout = @"Logout";
+
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Settings = @"Settings";
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public static LocalizedString Title = @"Menu";
}
public struct Numbers