Replace fullscreen checkbox and misleading width/height fields in RA settings menu with a mode/resolution selector like C&C. Fixes bugs #118, #791.
This commit is contained in:
@@ -58,7 +58,6 @@ namespace OpenRA.GameRules
|
|||||||
public WindowMode Mode = WindowMode.PseudoFullscreen;
|
public WindowMode Mode = WindowMode.PseudoFullscreen;
|
||||||
public int2 FullscreenSize = new int2(0,0);
|
public int2 FullscreenSize = new int2(0,0);
|
||||||
public int2 WindowedSize = new int2(1024, 768);
|
public int2 WindowedSize = new int2(1024, 768);
|
||||||
public readonly int2 MinResolution = new int2(800, 600);
|
|
||||||
|
|
||||||
public int BatchSize = 8192;
|
public int BatchSize = 8192;
|
||||||
public int NumTempBuffers = 8;
|
public int NumTempBuffers = 8;
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.FileFormats.Graphics;
|
using OpenRA.FileFormats.Graphics;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
@@ -76,45 +78,19 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
// Display
|
// Display
|
||||||
var display = bg.GetWidget("DISPLAY_PANE");
|
var display = bg.GetWidget("DISPLAY_PANE");
|
||||||
var gs = Game.Settings.Graphics;
|
var gs = Game.Settings.Graphics;
|
||||||
|
|
||||||
|
var windowModeDropdown = display.GetWidget<DropDownButtonWidget>("MODE_DROPDOWN");
|
||||||
|
windowModeDropdown.OnMouseDown = _ => ShowWindowModeDropdown(windowModeDropdown, gs);
|
||||||
|
windowModeDropdown.GetText = () => gs.Mode == WindowMode.Windowed ?
|
||||||
|
"Windowed" : gs.Mode == WindowMode.Fullscreen ? "Fullscreen" : "Pseudo-Fullscreen";
|
||||||
|
|
||||||
var fullscreen = display.GetWidget<CheckboxWidget>("FULLSCREEN_CHECKBOX");
|
display.GetWidget("WINDOW_RESOLUTION").IsVisible = () => gs.Mode == WindowMode.Windowed;
|
||||||
fullscreen.IsChecked = () => gs.Mode != WindowMode.Windowed;
|
var windowWidth = display.GetWidget<TextFieldWidget>("WINDOW_WIDTH");
|
||||||
fullscreen.OnClick = () => gs.Mode = (gs.Mode == WindowMode.Windowed) ? WindowMode.PseudoFullscreen : WindowMode.Windowed;
|
windowWidth.Text = gs.WindowedSize.X.ToString();
|
||||||
|
|
||||||
var width = display.GetWidget<TextFieldWidget>("SCREEN_WIDTH");
|
|
||||||
gs.WindowedSize.X = Math.Max(gs.WindowedSize.X, gs.MinResolution.X);
|
|
||||||
width.Text = gs.WindowedSize.X.ToString();
|
|
||||||
width.OnLoseFocus = () =>
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
var w = int.Parse(width.Text);
|
|
||||||
if (w > gs.MinResolution.X)
|
|
||||||
gs.WindowedSize = new int2(w, gs.WindowedSize.Y);
|
|
||||||
}
|
|
||||||
catch (FormatException) {
|
|
||||||
width.Text = gs.WindowedSize.X.ToString();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
width.OnEnterKey = () => { width.LoseFocus(); return true; };
|
|
||||||
|
|
||||||
var height = display.GetWidget<TextFieldWidget>("SCREEN_HEIGHT");
|
|
||||||
gs.WindowedSize.Y = Math.Max(gs.WindowedSize.Y, gs.MinResolution.Y);
|
|
||||||
height.Text = gs.WindowedSize.Y.ToString();
|
|
||||||
height.OnLoseFocus = () =>
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
var h = int.Parse(height.Text);
|
|
||||||
if (h > gs.MinResolution.Y)
|
|
||||||
gs.WindowedSize = new int2(gs.WindowedSize.X, h);
|
|
||||||
else
|
|
||||||
height.Text = gs.WindowedSize.Y.ToString();
|
|
||||||
}
|
|
||||||
catch (FormatException) {
|
|
||||||
height.Text = gs.WindowedSize.Y.ToString();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
height.OnEnterKey = () => { height.LoseFocus(); return true; };
|
|
||||||
|
|
||||||
|
var windowHeight = display.GetWidget<TextFieldWidget>("WINDOW_HEIGHT");
|
||||||
|
windowHeight.Text = gs.WindowedSize.Y.ToString();
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
var debug = bg.GetWidget("DEBUG_PANE");
|
var debug = bg.GetWidget("DEBUG_PANE");
|
||||||
|
|
||||||
@@ -128,7 +104,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
checkunsyncedCheckbox.IsChecked = () => Game.Settings.Debug.SanityCheckUnsyncedCode;
|
checkunsyncedCheckbox.IsChecked = () => Game.Settings.Debug.SanityCheckUnsyncedCode;
|
||||||
checkunsyncedCheckbox.OnClick = () => Game.Settings.Debug.SanityCheckUnsyncedCode ^= true;
|
checkunsyncedCheckbox.OnClick = () => Game.Settings.Debug.SanityCheckUnsyncedCode ^= true;
|
||||||
|
|
||||||
bg.GetWidget<ButtonWidget>("BUTTON_CLOSE").OnClick = () => {
|
bg.GetWidget<ButtonWidget>("BUTTON_CLOSE").OnClick = () =>
|
||||||
|
{
|
||||||
|
int x = gs.WindowedSize.X, y = gs.WindowedSize.Y;
|
||||||
|
int.TryParse(windowWidth.Text, out x);
|
||||||
|
int.TryParse(windowHeight.Text, out y);
|
||||||
|
gs.WindowedSize = new int2(x,y);
|
||||||
Game.Settings.Save();
|
Game.Settings.Save();
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
};
|
};
|
||||||
@@ -144,5 +125,27 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
bg.GetWidget(open).Visible = true;
|
bg.GetWidget(open).Visible = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ShowWindowModeDropdown(DropDownButtonWidget dropdown, GraphicSettings s)
|
||||||
|
{
|
||||||
|
var options = new Dictionary<string, WindowMode>()
|
||||||
|
{
|
||||||
|
{ "Pseudo-Fullscreen", WindowMode.PseudoFullscreen },
|
||||||
|
{ "Fullscreen", WindowMode.Fullscreen },
|
||||||
|
{ "Windowed", WindowMode.Windowed },
|
||||||
|
};
|
||||||
|
|
||||||
|
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
||||||
|
{
|
||||||
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
|
() => s.Mode == options[o],
|
||||||
|
() => s.Mode = options[o]);
|
||||||
|
item.GetWidget<LabelWidget>("LABEL").GetText = () => o;
|
||||||
|
return item;
|
||||||
|
};
|
||||||
|
|
||||||
|
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys.ToList(), setupItem);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,44 +159,59 @@ Background@SETTINGS_MENU:
|
|||||||
Height:PARENT_BOTTOM - 100
|
Height:PARENT_BOTTOM - 100
|
||||||
Visible: false
|
Visible: false
|
||||||
Children:
|
Children:
|
||||||
Checkbox@FULLSCREEN_CHECKBOX:
|
Label@MODE_LABEL:
|
||||||
Id:FULLSCREEN_CHECKBOX
|
|
||||||
X:0
|
X:0
|
||||||
Y:0
|
Y:0
|
||||||
Width:300
|
Width:45
|
||||||
Height:20
|
|
||||||
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
|
Height:25
|
||||||
X:130
|
Text:Mode:
|
||||||
Y:40
|
DropDownButton@MODE_DROPDOWN:
|
||||||
MaxLength:5
|
Id:MODE_DROPDOWN
|
||||||
Label@X:
|
X:50
|
||||||
Id:X
|
Y:1
|
||||||
Text:x
|
Width:170
|
||||||
X:185
|
|
||||||
Y:50
|
|
||||||
TextField@SCREEN_HEIGHT:
|
|
||||||
Id:SCREEN_HEIGHT
|
|
||||||
Text:Height
|
|
||||||
Width:50
|
|
||||||
Height:25
|
Height:25
|
||||||
X:195
|
Font:Regular
|
||||||
Y:40
|
Text:Windowed
|
||||||
MaxLength:5
|
Container@WINDOWRES:
|
||||||
Label@RESTART:
|
Id:WINDOW_RESOLUTION
|
||||||
Id:RESTART
|
X:220
|
||||||
Text: Restart Game To Apply Changes
|
Y:0
|
||||||
X:0
|
Children:
|
||||||
Y:PARENT_BOTTOM - 30
|
Label@At:
|
||||||
|
Text:@
|
||||||
|
Font:Bold
|
||||||
|
Y:0-1
|
||||||
|
Height:25
|
||||||
|
Width:25
|
||||||
|
Align:Center
|
||||||
|
TextField@SCREEN_WIDTH:
|
||||||
|
Id:WINDOW_WIDTH
|
||||||
|
X:25
|
||||||
|
Width:45
|
||||||
|
Height:25
|
||||||
|
MaxLength:5
|
||||||
|
Label@X:
|
||||||
|
Text:x
|
||||||
|
Font:Bold
|
||||||
|
X:70
|
||||||
|
Y:0-1
|
||||||
|
Height:25
|
||||||
|
Width:15
|
||||||
|
Align:Center
|
||||||
|
TextField@SCREEN_HEIGHT:
|
||||||
|
Id:WINDOW_HEIGHT
|
||||||
|
X:85
|
||||||
|
Width:45
|
||||||
|
Height:25
|
||||||
|
MaxLength:5
|
||||||
|
Label@VIDEO_DESC:
|
||||||
|
Y:25
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Height:25
|
||||||
|
Font:Tiny
|
||||||
|
Align:Center
|
||||||
|
Text:Video changes will be applied after the game is restarted
|
||||||
Container@DEBUG_PANE:
|
Container@DEBUG_PANE:
|
||||||
Id:DEBUG_PANE
|
Id:DEBUG_PANE
|
||||||
X:37
|
X:37
|
||||||
|
|||||||
Reference in New Issue
Block a user