Fix graphics mode dropdown
This commit is contained in:
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
// Video
|
// Video
|
||||||
windowMode = Game.Settings.Graphics.Mode;
|
windowMode = Game.Settings.Graphics.Mode;
|
||||||
var windowModeDropdown = generalPane.GetWidget<CncDropDownButtonWidget>("MODE_DROPDOWN");
|
var windowModeDropdown = generalPane.GetWidget<CncDropDownButtonWidget>("MODE_DROPDOWN");
|
||||||
windowModeDropdown.OnMouseUp = _ => ShowWindowModeDropdown(windowModeDropdown);
|
windowModeDropdown.OnClick = () => ShowWindowModeDropdown(windowModeDropdown);
|
||||||
windowModeDropdown.GetText = () => windowMode == WindowMode.Windowed ? "Windowed" : windowMode == WindowMode.Fullscreen ? "Fullscreen" : "Pseudo-Fullscreen";
|
windowModeDropdown.GetText = () => windowMode == WindowMode.Windowed ? "Windowed" : windowMode == WindowMode.Fullscreen ? "Fullscreen" : "Pseudo-Fullscreen";
|
||||||
|
|
||||||
generalPane.GetWidget("WINDOW_RESOLUTION").IsVisible = () => windowMode == WindowMode.Windowed;
|
generalPane.GetWidget("WINDOW_RESOLUTION").IsVisible = () => windowMode == WindowMode.Windowed;
|
||||||
@@ -220,7 +220,6 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
void ShowGroupModifierDropdown(CncDropDownButtonWidget dropdown)
|
void ShowGroupModifierDropdown(CncDropDownButtonWidget dropdown)
|
||||||
{
|
{
|
||||||
var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", dropdown.Bounds.Width }};
|
var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", dropdown.Bounds.Width }};
|
||||||
|
|
||||||
var panel = (ScrollPanelWidget)Game.LoadWidget(world, "LABEL_DROPDOWN_TEMPLATE", null, new WidgetArgs()
|
var panel = (ScrollPanelWidget)Game.LoadWidget(world, "LABEL_DROPDOWN_TEMPLATE", null, new WidgetArgs()
|
||||||
{
|
{
|
||||||
{ "substitutions", substitutions }
|
{ "substitutions", substitutions }
|
||||||
@@ -247,25 +246,32 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
dropdown.AttachPanel(panel);
|
dropdown.AttachPanel(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShowWindowModeDropdown(Widget dropdown)
|
void ShowWindowModeDropdown(CncDropDownButtonWidget dropdown)
|
||||||
{
|
{
|
||||||
var dropDownOptions = new List<Pair<string, Action>>()
|
var substitutions = new Dictionary<string,int>() {{ "DROPDOWN_WIDTH", dropdown.Bounds.Width }};
|
||||||
|
var panel = (ScrollPanelWidget)Game.LoadWidget(world, "LABEL_DROPDOWN_TEMPLATE", null, new WidgetArgs()
|
||||||
{
|
{
|
||||||
Pair.New("Pseudo-Fullscreen", new Action(() => windowMode = WindowMode.PseudoFullscreen)),
|
{ "substitutions", substitutions }
|
||||||
Pair.New("Fullscreen", new Action(() => windowMode = WindowMode.Fullscreen)),
|
});
|
||||||
Pair.New("Windowed", new Action(() => windowMode = WindowMode.Windowed)),
|
|
||||||
|
var itemTemplate = panel.GetWidget<ScrollItemWidget>("TEMPLATE");
|
||||||
|
var options = new List<Pair<string, WindowMode>>()
|
||||||
|
{
|
||||||
|
Pair.New("Pseudo-Fullscreen", WindowMode.PseudoFullscreen),
|
||||||
|
Pair.New("Fullscreen",WindowMode.Fullscreen),
|
||||||
|
Pair.New("Windowed", WindowMode.Windowed),
|
||||||
};
|
};
|
||||||
|
|
||||||
CncDropDownButtonWidget.ShowDropDown(dropdown,
|
foreach (var o in options)
|
||||||
dropDownOptions,
|
|
||||||
(ac, w) => new LabelWidget
|
|
||||||
{
|
{
|
||||||
Bounds = new Rectangle(0, 0, w, 24),
|
var key = o;
|
||||||
Text = ac.First,
|
var item = ScrollItemWidget.Setup(itemTemplate, () => windowMode == key.Second, () => { windowMode = key.Second; dropdown.RemovePanel(); });
|
||||||
Align = LabelWidget.TextAlign.Center,
|
item.GetWidget<LabelWidget>("LABEL").GetText = () => key.First;
|
||||||
OnMouseUp = mi => { ac.Second(); return true; },
|
panel.AddChild(item);
|
||||||
});
|
}
|
||||||
return true;
|
|
||||||
|
panel.Bounds.Height = panel.ContentHeight;
|
||||||
|
dropdown.AttachPanel(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -110,40 +110,39 @@ Container@SETTINGS_PANEL:
|
|||||||
Id:MODE_DROPDOWN
|
Id:MODE_DROPDOWN
|
||||||
X:425
|
X:425
|
||||||
Y:40
|
Y:40
|
||||||
Width:150
|
Width:170
|
||||||
Height:25
|
Height:25
|
||||||
Font:Regular
|
Font:Regular
|
||||||
Text:Windowed
|
Text:Windowed
|
||||||
Container@WINDOWRES:
|
Container@WINDOWRES:
|
||||||
Id:WINDOW_RESOLUTION
|
Id:WINDOW_RESOLUTION
|
||||||
|
X:595
|
||||||
|
Y:40
|
||||||
Children:
|
Children:
|
||||||
Label@At:
|
Label@At:
|
||||||
Text:@
|
Text:@
|
||||||
Font:Bold
|
Font:Bold
|
||||||
X:575
|
Y:0-1
|
||||||
Y:39
|
|
||||||
Height:25
|
Height:25
|
||||||
Width:25
|
Width:25
|
||||||
Align:Center
|
Align:Center
|
||||||
TextField@SCREEN_WIDTH:
|
TextField@SCREEN_WIDTH:
|
||||||
Id:WINDOW_WIDTH
|
Id:WINDOW_WIDTH
|
||||||
X:600
|
X:25
|
||||||
Y:40
|
|
||||||
Width:45
|
Width:45
|
||||||
Height:25
|
Height:25
|
||||||
MaxLength:5
|
MaxLength:5
|
||||||
Label@X:
|
Label@X:
|
||||||
Text:x
|
Text:x
|
||||||
Font:Bold
|
Font:Bold
|
||||||
X:645
|
X:70
|
||||||
Y:39
|
Y:0-1
|
||||||
Height:25
|
Height:25
|
||||||
Width:25
|
Width:15
|
||||||
Align:Center
|
Align:Center
|
||||||
TextField@SCREEN_HEIGHT:
|
TextField@SCREEN_HEIGHT:
|
||||||
Id:WINDOW_HEIGHT
|
Id:WINDOW_HEIGHT
|
||||||
X:670
|
X:85
|
||||||
Y:40
|
|
||||||
Width:45
|
Width:45
|
||||||
Height:25
|
Height:25
|
||||||
MaxLength:5
|
MaxLength:5
|
||||||
|
|||||||
Reference in New Issue
Block a user