From cfbdebc3717c9a53608368c4be226ee5e27d3456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 19 Oct 2014 14:18:47 +0200 Subject: [PATCH 1/2] fix inconsistent naming --- mods/cnc/chrome/settings.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/cnc/chrome/settings.yaml b/mods/cnc/chrome/settings.yaml index 821dcab639..f3f5b7ef23 100644 --- a/mods/cnc/chrome/settings.yaml +++ b/mods/cnc/chrome/settings.yaml @@ -47,7 +47,7 @@ Container@SETTINGS_PANEL: Y: 20 Width: PARENT_RIGHT Font: Bold - Text: Graphics + Text: Display Align: Center Label@MODE_LABEL: X: 120 From 1bed876540605099517ca07b08ad8537c5d77ce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 5 Oct 2014 18:54:41 +0200 Subject: [PATCH 2/2] bring back the player name and color to the settings menu closes #6380 --- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 1 + .../Widgets/Logic/AssetBrowserLogic.cs | 23 +----------------- .../Widgets/Logic/ColorPickerLogic.cs | 21 ++++++++++++++++ .../Widgets/Logic/SettingsLogic.cs | 24 +++++++++++++++++-- OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 1 - mods/cnc/chrome/settings.yaml | 23 ++++++++++++++++++ mods/ra/chrome/settings.yaml | 23 ++++++++++++++++++ 7 files changed, 91 insertions(+), 25 deletions(-) rename {OpenRA.Mods.RA => OpenRA.Mods.Common}/Widgets/Logic/SettingsLogic.cs (95%) diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 78042a2544..e30a9daa32 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -121,6 +121,7 @@ + diff --git a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs index 32e6bef8e2..544a55990a 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs @@ -103,7 +103,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (colorDropdown != null) { colorDropdown.IsDisabled = () => currentPalette != colorPreview.PaletteName; - colorDropdown.OnMouseDown = _ => ShowColorDropDown(colorDropdown, colorPreview, world); + colorDropdown.OnMouseDown = _ => ColorPickerLogic.ShowColorDropDown(colorDropdown, colorPreview, world); panel.Get("COLORBLOCK").GetColor = () => Game.Settings.Player.Color.RGB; } @@ -376,26 +376,5 @@ namespace OpenRA.Mods.Common.Widgets.Logic dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 280, palettes, setupItem); return true; } - - static void ShowColorDropDown(DropDownButtonWidget color, ColorPreviewManagerWidget preview, World world) - { - Action onExit = () => - { - Game.Settings.Player.Color = preview.Color; - Game.Settings.Save(); - }; - - color.RemovePanel(); - - Action onChange = c => preview.Color = c; - - var colorChooser = Game.LoadWidget(world, "COLOR_CHOOSER", null, new WidgetArgs() - { - { "onChange", onChange }, - { "initialColor", Game.Settings.Player.Color } - }); - - color.AttachPanel(colorChooser, onExit); - } } } diff --git a/OpenRA.Mods.Common/Widgets/Logic/ColorPickerLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ColorPickerLogic.cs index a2d42e72b6..304fa02780 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ColorPickerLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ColorPickerLogic.cs @@ -52,6 +52,27 @@ namespace OpenRA.Mods.Common.Widgets.Logic hueSlider.Value = initialColor.H / 255f; onChange(mixer.Color); } + + public static void ShowColorDropDown(DropDownButtonWidget color, ColorPreviewManagerWidget preview, World world) + { + Action onExit = () => + { + Game.Settings.Player.Color = preview.Color; + Game.Settings.Save(); + }; + + color.RemovePanel(); + + Action onChange = c => preview.Color = c; + + var colorChooser = Game.LoadWidget(world, "COLOR_CHOOSER", null, new WidgetArgs() + { + { "onChange", onChange }, + { "initialColor", Game.Settings.Player.Color } + }); + + color.AttachPanel(colorChooser, onExit); + } } } diff --git a/OpenRA.Mods.RA/Widgets/Logic/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs similarity index 95% rename from OpenRA.Mods.RA/Widgets/Logic/SettingsLogic.cs rename to OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs index 53c4154ed1..2e4b5787b9 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs @@ -13,10 +13,9 @@ using System; using System.Collections.Generic; using System.Linq; using OpenRA.Graphics; -using OpenRA.Mods.Common.Widgets; using OpenRA.Widgets; -namespace OpenRA.Mods.RA.Widgets.Logic +namespace OpenRA.Mods.Common.Widgets.Logic { public class SettingsLogic { @@ -196,6 +195,21 @@ namespace OpenRA.Mods.RA.Widgets.Logic frameLimitTextfield.OnEnterKey = () => { frameLimitTextfield.YieldKeyboardFocus(); return true; }; frameLimitTextfield.IsDisabled = () => !ds.CapFramerate; + // Player profile + var ps = Game.Settings.Player; + + var nameTextfield = panel.Get("PLAYERNAME"); + nameTextfield.Text = ps.Name; + nameTextfield.OnEnterKey = () => { nameTextfield.YieldKeyboardFocus(); return true; }; + nameTextfield.OnLoseFocus = () => { ps.Name = nameTextfield.Text; }; + + var colorPreview = panel.Get("COLOR_MANAGER"); + colorPreview.Color = ps.Color; + + var colorDropdown = panel.Get("PLAYERCOLOR"); + colorDropdown.OnMouseDown = _ => ColorPickerLogic.ShowColorDropDown(colorDropdown, colorPreview, worldRenderer.world); + colorDropdown.Get("COLORBLOCK").GetColor = () => ps.Color.RGB; + return () => { int x, y; @@ -203,6 +217,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic Exts.TryParseIntegerInvariant(windowHeight.Text, out y); ds.WindowedSize = new int2(x, y); frameLimitTextfield.YieldKeyboardFocus(); + nameTextfield.YieldKeyboardFocus(); }; } @@ -210,8 +225,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic { var ds = Game.Settings.Graphics; var gs = Game.Settings.Game; + var ps = Game.Settings.Player; var dds = new GraphicSettings(); var dgs = new GameSettings(); + var dps = new PlayerSettings(); return () => { gs.ShowShellmap = dgs.ShowShellmap; @@ -225,6 +242,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic ds.PixelDouble = dds.PixelDouble; ds.CursorDouble = dds.CursorDouble; worldRenderer.Viewport.Zoom = ds.PixelDouble ? 2 : 1; + + ps.Color = dps.Color; + ps.Name = dps.Name; }; } diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 17e184362b..f0d5fed984 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -420,7 +420,6 @@ - diff --git a/mods/cnc/chrome/settings.yaml b/mods/cnc/chrome/settings.yaml index f3f5b7ef23..0037165b9a 100644 --- a/mods/cnc/chrome/settings.yaml +++ b/mods/cnc/chrome/settings.yaml @@ -152,6 +152,29 @@ Container@SETTINGS_PANEL: Height: 20 Font: Regular Text: Show Shellmap + Label@PLAYER: + Text: Player: + X: 15 + Y: 215 + TextField@PLAYERNAME: + Text: Name + X: 65 + Y: 205 + Width: 145 + Height: 25 + MaxLength: 16 + ColorPreviewManager@COLOR_MANAGER: + DropDownButton@PLAYERCOLOR: + X: 215 + Y: 205 + Width: 70 + Height: 25 + Children: + ColorBlock@COLORBLOCK: + X: 5 + Y: 6 + Width: PARENT_RIGHT-35 + Height: PARENT_BOTTOM-12 Checkbox@ALWAYS_SHOW_STATUS_BARS_CHECKBOX: X: 310 Y: 205 diff --git a/mods/ra/chrome/settings.yaml b/mods/ra/chrome/settings.yaml index 850c6aa776..98cf67f928 100644 --- a/mods/ra/chrome/settings.yaml +++ b/mods/ra/chrome/settings.yaml @@ -165,6 +165,29 @@ Background@SETTINGS_PANEL: Height: 20 Font: Regular Text: Show Shellmap + Label@PLAYER: + Text: Player: + X: 15 + Y: 215 + TextField@PLAYERNAME: + Text: Name + X: 65 + Y: 205 + Width: 145 + Height: 25 + MaxLength: 16 + ColorPreviewManager@COLOR_MANAGER: + DropDownButton@PLAYERCOLOR: + X: 215 + Y: 205 + Width: 70 + Height: 25 + Children: + ColorBlock@COLORBLOCK: + X: 5 + Y: 6 + Width: PARENT_RIGHT-35 + Height: PARENT_BOTTOM-12 Checkbox@ALWAYS_SHOW_STATUS_BARS_CHECKBOX: X: 310 Y: 205