Settings menu (pchote: fix alzeihs broken world)
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRA.FileFormats.Graphics;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
@@ -21,11 +22,37 @@ namespace OpenRA.Widgets.Delegates
|
||||
tabs.GetWidget<ButtonWidget>("DEBUG").OnMouseUp = mi => FlipToTab("DEBUG_PANE");
|
||||
FlipToTab("GENERAL_PANE");
|
||||
|
||||
//General
|
||||
var general = bg.GetWidget("GENERAL_PANE");
|
||||
|
||||
var name = general.GetWidget<TextFieldWidget>("NAME");
|
||||
name.Text = Game.Settings.PlayerName;
|
||||
name.OnLoseFocus = () =>
|
||||
{
|
||||
name.Text = name.Text.Trim();
|
||||
|
||||
if (name.Text.Length == 0)
|
||||
name.Text = Game.Settings.PlayerName;
|
||||
else
|
||||
{
|
||||
Game.Settings.PlayerName = name.Text;
|
||||
Game.Settings.Save();
|
||||
}
|
||||
};
|
||||
name.OnEnterKey = () => { name.LoseFocus(); return true; };
|
||||
|
||||
// Audio
|
||||
var audio = bg.GetWidget("AUDIO_PANE");
|
||||
var music = audio.GetWidget<CheckboxWidget>("MUSICPLAYER_CHECKBOX");
|
||||
|
||||
var soundslider = audio.GetWidget<SliderWidget>("SOUND_VOLUME");
|
||||
soundslider.OnChange += x => { Sound.Volume = x; };
|
||||
soundslider.GetOffset = () => { return Sound.Volume; };
|
||||
|
||||
var musicslider = audio.GetWidget<SliderWidget>("MUSIC_VOLUME");
|
||||
musicslider.OnChange += x => { Sound.MusicVolume = x; };
|
||||
musicslider.GetOffset = () => { return Sound.MusicVolume; };
|
||||
|
||||
var music = audio.GetWidget<CheckboxWidget>("MUSICPLAYER_CHECKBOX");
|
||||
music.Checked = () => { return Game.Settings.MusicPlayer; };
|
||||
music.OnMouseDown = mi =>
|
||||
{
|
||||
@@ -46,6 +73,44 @@ namespace OpenRA.Widgets.Delegates
|
||||
return true;
|
||||
};
|
||||
|
||||
var width = display.GetWidget<TextFieldWidget>("SCREEN_WIDTH");
|
||||
width.Text = Game.Settings.WindowedSize.X.ToString();
|
||||
width.OnLoseFocus = () =>
|
||||
{
|
||||
try {
|
||||
var w = int.Parse(width.Text);
|
||||
if (w > 800 && w <= Screen.PrimaryScreen.Bounds.Size.Width){
|
||||
Game.Settings.WindowedSize = new int2(w, Game.Settings.WindowedSize.Y);
|
||||
Game.Settings.Save();
|
||||
}
|
||||
else
|
||||
width.Text = Game.Settings.WindowedSize.X.ToString();
|
||||
}
|
||||
catch (FormatException e) {
|
||||
width.Text = Game.Settings.WindowedSize.X.ToString();
|
||||
}
|
||||
};
|
||||
width.OnEnterKey = () => { width.LoseFocus(); return true; };
|
||||
|
||||
var height = display.GetWidget<TextFieldWidget>("SCREEN_HEIGHT");
|
||||
height.Text = Game.Settings.WindowedSize.Y.ToString();
|
||||
height.OnLoseFocus = () =>
|
||||
{
|
||||
try {
|
||||
var h = int.Parse(height.Text);
|
||||
if (h > 600 && h <= Screen.PrimaryScreen.Bounds.Size.Height){
|
||||
Game.Settings.WindowedSize = new int2(Game.Settings.WindowedSize.X, h);
|
||||
Game.Settings.Save();
|
||||
}
|
||||
else
|
||||
height.Text = Game.Settings.WindowedSize.Y.ToString();
|
||||
}
|
||||
catch (System.FormatException) {
|
||||
height.Text = Game.Settings.WindowedSize.Y.ToString();
|
||||
}
|
||||
};
|
||||
height.OnEnterKey = () => { height.LoseFocus(); return true; };
|
||||
|
||||
// Debug
|
||||
var debug = bg.GetWidget("DEBUG_PANE");
|
||||
var perfdebug = debug.GetWidget<CheckboxWidget>("PERFDEBUG_CHECKBOX");
|
||||
|
||||
@@ -222,13 +222,16 @@ Container:
|
||||
Label@SETTINGS_PLAYER_NAME:
|
||||
Id:SETTINGS_PLAYER_NAME
|
||||
X:0
|
||||
Y:10
|
||||
Text: Player Name:
|
||||
TextField@NAME:
|
||||
Id:NAME
|
||||
Text:Name
|
||||
Width:139
|
||||
Height:25
|
||||
X:90
|
||||
Y:0
|
||||
Text: Player Name
|
||||
Label@SETTINGS_DOWNLOAD_MAPS:
|
||||
Id:SETTINGS_DOWNLOAD_MAPS
|
||||
X:0
|
||||
Y:30
|
||||
Text: Download Maps
|
||||
MaxLength:16
|
||||
Container@AUDIO_PANE:
|
||||
Id:AUDIO_PANE
|
||||
X:37
|
||||
@@ -240,17 +243,31 @@ Container:
|
||||
Label@SOUND_VOLUME_LABEL:
|
||||
Id:SOUND_VOLUME_LABEL
|
||||
X:0
|
||||
Y:0
|
||||
Y:10
|
||||
Text: Sound Volume
|
||||
Slider@SOUND_VOLUME:
|
||||
Id:SOUND_VOLUME
|
||||
X:100
|
||||
Y:0
|
||||
Width:250
|
||||
Height:20
|
||||
Ticks:5
|
||||
Label@MUSIC_VOLUME_LABEL:
|
||||
Id:MUSIC_VOLUME_LABEL
|
||||
X:0
|
||||
Y:30
|
||||
Y:40
|
||||
Text: Music Volume
|
||||
Slider@MUSIC_VOLUME:
|
||||
Id:MUSIC_VOLUME
|
||||
X:100
|
||||
Y:30
|
||||
Width:250
|
||||
Height:20
|
||||
Ticks:5
|
||||
Checkbox@MUSICPLAYER_CHECKBOX:
|
||||
Id:MUSICPLAYER_CHECKBOX
|
||||
X:0
|
||||
Y:60
|
||||
Y:70
|
||||
Width:300
|
||||
Height:20
|
||||
Text:Show Music Player
|
||||
@@ -268,12 +285,38 @@ Container:
|
||||
Y:0
|
||||
Width:300
|
||||
Height:20
|
||||
Text:Fullscreen (Requires restart)
|
||||
Text:Fullscreen
|
||||
Label@RESOLUTION_LABEL:
|
||||
Id:RESOLUTION_LABEL
|
||||
X:0
|
||||
Y:50
|
||||
Text: Window Resolution:
|
||||
TextField@SCREEN_WIDTH:
|
||||
Id:SCREEN_WIDTH
|
||||
Text:Width
|
||||
Width:50
|
||||
Height:25
|
||||
X:130
|
||||
Y:40
|
||||
Text: Screen Resolution:
|
||||
MaxLength:5
|
||||
Label@X:
|
||||
Id:X
|
||||
Text:x
|
||||
X:185
|
||||
Y:50
|
||||
TextField@SCREEN_HEIGHT:
|
||||
Id:SCREEN_HEIGHT
|
||||
Text:Height
|
||||
Width:50
|
||||
Height:25
|
||||
X:195
|
||||
Y:40
|
||||
MaxLength:5
|
||||
Label@RESTART:
|
||||
Id:RESTART
|
||||
Text: Restart Game To Apply Changes
|
||||
X:0
|
||||
Y:PARENT_BOTTOM - 30
|
||||
Container@DEBUG_PANE:
|
||||
Id:DEBUG_PANE
|
||||
X:37
|
||||
|
||||
@@ -222,13 +222,16 @@ Container:
|
||||
Label@SETTINGS_PLAYER_NAME:
|
||||
Id:SETTINGS_PLAYER_NAME
|
||||
X:0
|
||||
Y:10
|
||||
Text: Player Name:
|
||||
TextField@NAME:
|
||||
Id:NAME
|
||||
Text:Name
|
||||
Width:139
|
||||
Height:25
|
||||
X:90
|
||||
Y:0
|
||||
Text: Player Name
|
||||
Label@SETTINGS_DOWNLOAD_MAPS:
|
||||
Id:SETTINGS_DOWNLOAD_MAPS
|
||||
X:0
|
||||
Y:30
|
||||
Text: Download Maps
|
||||
MaxLength:16
|
||||
Container@AUDIO_PANE:
|
||||
Id:AUDIO_PANE
|
||||
X:37
|
||||
@@ -240,17 +243,31 @@ Container:
|
||||
Label@SOUND_VOLUME_LABEL:
|
||||
Id:SOUND_VOLUME_LABEL
|
||||
X:0
|
||||
Y:0
|
||||
Y:10
|
||||
Text: Sound Volume
|
||||
Slider@SOUND_VOLUME:
|
||||
Id:SOUND_VOLUME
|
||||
X:100
|
||||
Y:0
|
||||
Width:250
|
||||
Height:20
|
||||
Ticks:5
|
||||
Label@MUSIC_VOLUME_LABEL:
|
||||
Id:MUSIC_VOLUME_LABEL
|
||||
X:0
|
||||
Y:30
|
||||
Y:40
|
||||
Text: Music Volume
|
||||
Slider@MUSIC_VOLUME:
|
||||
Id:MUSIC_VOLUME
|
||||
X:100
|
||||
Y:30
|
||||
Width:250
|
||||
Height:20
|
||||
Ticks:5
|
||||
Checkbox@MUSICPLAYER_CHECKBOX:
|
||||
Id:MUSICPLAYER_CHECKBOX
|
||||
X:0
|
||||
Y:60
|
||||
Y:70
|
||||
Width:300
|
||||
Height:20
|
||||
Text:Show Music Player
|
||||
@@ -268,12 +285,38 @@ Container:
|
||||
Y:0
|
||||
Width:300
|
||||
Height:20
|
||||
Text:Fullscreen (Requires restart)
|
||||
Text:Fullscreen
|
||||
Label@RESOLUTION_LABEL:
|
||||
Id:RESOLUTION_LABEL
|
||||
X:0
|
||||
Y:50
|
||||
Text: Window Resolution:
|
||||
TextField@SCREEN_WIDTH:
|
||||
Id:SCREEN_WIDTH
|
||||
Text:Width
|
||||
Width:50
|
||||
Height:25
|
||||
X:130
|
||||
Y:40
|
||||
Text: Screen Resolution:
|
||||
MaxLength:5
|
||||
Label@X:
|
||||
Id:X
|
||||
Text:x
|
||||
X:185
|
||||
Y:50
|
||||
TextField@SCREEN_HEIGHT:
|
||||
Id:SCREEN_HEIGHT
|
||||
Text:Height
|
||||
Width:50
|
||||
Height:25
|
||||
X:195
|
||||
Y:40
|
||||
MaxLength:5
|
||||
Label@RESTART:
|
||||
Id:RESTART
|
||||
Text: Restart Game To Apply Changes
|
||||
X:0
|
||||
Y:PARENT_BOTTOM - 30
|
||||
Container@DEBUG_PANE:
|
||||
Id:DEBUG_PANE
|
||||
X:37
|
||||
|
||||
Reference in New Issue
Block a user