added Renderer Dropdown in RA Settings

This commit is contained in:
Matthias Mailänder
2012-06-17 21:57:54 +03:00
committed by Chris Forbes
parent d64ecac74e
commit c9edf7d0dc
2 changed files with 47 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2012 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
@@ -91,6 +91,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var display = bg.Get("DISPLAY_PANE"); var display = bg.Get("DISPLAY_PANE");
var gs = Game.Settings.Graphics; var gs = Game.Settings.Graphics;
var GraphicsRendererDropdown = display.Get<DropDownButtonWidget>("GRAPHICS_RENDERER");
GraphicsRendererDropdown.OnMouseDown = _ => ShowRendererDropdown(GraphicsRendererDropdown, gs);
GraphicsRendererDropdown.GetText = () => gs.Renderer == "Gl" ?
"OpenGL" : gs.Renderer == "Cg" ? "Cg Toolkit" : "OpenGL";
var windowModeDropdown = display.Get<DropDownButtonWidget>("MODE_DROPDOWN"); var windowModeDropdown = display.Get<DropDownButtonWidget>("MODE_DROPDOWN");
windowModeDropdown.OnMouseDown = _ => ShowWindowModeDropdown(windowModeDropdown, gs); windowModeDropdown.OnMouseDown = _ => ShowWindowModeDropdown(windowModeDropdown, gs);
windowModeDropdown.GetText = () => gs.Mode == WindowMode.Windowed ? windowModeDropdown.GetText = () => gs.Mode == WindowMode.Windowed ?
@@ -189,5 +194,26 @@ namespace OpenRA.Mods.RA.Widgets.Logic
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem); dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
return true; return true;
} }
public static bool ShowRendererDropdown(DropDownButtonWidget dropdown, GraphicSettings s)
{
var options = new Dictionary<string, string>()
{
{ "OpenGL", "Gl" },
{ "Cg Toolkit", "Cg" },
};
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
{
var item = ScrollItemWidget.Setup(itemTemplate,
() => s.Renderer == options[o],
() => s.Renderer = options[o]);
item.Get<LabelWidget>("LABEL").GetText = () => o;
return item;
};
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
return true;
}
} }
} }

View File

@@ -154,22 +154,35 @@ Background@SETTINGS_MENU:
Height:PARENT_BOTTOM - 100 Height:PARENT_BOTTOM - 100
Visible: false Visible: false
Children: Children:
Label@MODE_LABEL: Label@RENDERER_LABEL:
X:0 X:0
Y:0 Y:0
Width:75
Height:25
Text:Renderer:
DropDownButton@GRAPHICS_RENDERER:
X:80
Y:1
Width:120
Height:25
Font:Regular
Text:OpenGL
Label@MODE_LABEL:
X:0
Y:30
Width:45 Width:45
Height:25 Height:25
Text:Mode: Text:Mode:
DropDownButton@MODE_DROPDOWN: DropDownButton@MODE_DROPDOWN:
X:50 X:50
Y:1 Y:30
Width:170 Width:170
Height:25 Height:25
Font:Regular Font:Regular
Text:Windowed Text:Windowed
Container@WINDOW_RESOLUTION: Container@WINDOW_RESOLUTION:
X:220 X:225
Y:0 Y:30
Children: Children:
Label@At: Label@At:
Text:@ Text:@
@@ -197,14 +210,14 @@ Background@SETTINGS_MENU:
Height:25 Height:25
MaxLength:5 MaxLength:5
Label@VIDEO_DESC: Label@VIDEO_DESC:
Y:25 Y:60
Width:PARENT_RIGHT Width:PARENT_RIGHT
Height:25 Height:25
Font:Tiny Font:Tiny
Align:Center Align:Center
Text:Mode/Resolution changes will be applied after the game is restarted Text:Renderer/Mode/Resolution changes will be applied after the game is restarted.
Checkbox@PIXELDOUBLE_CHECKBOX: Checkbox@PIXELDOUBLE_CHECKBOX:
Y:50 Y:90
Width:200 Width:200
Height:20 Height:20
Font:Regular Font:Regular