diff --git a/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs b/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs index 63a806cfc7..42f06cbde1 100755 --- a/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs @@ -464,9 +464,9 @@ namespace OpenRA.Mods.Cnc.Widgets team.OnMouseDown = _ => ShowTeamDropDown(team); team.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString(); - var status = template.GetWidget("STATUS"); + var status = template.GetWidget("STATUS"); status.IsChecked = () => c.State == Session.ClientState.Ready; - status.OnChange += CycleReady; + status.OnClick += CycleReady; var spectator = template.GetWidget("SPECTATOR"); @@ -496,10 +496,10 @@ namespace OpenRA.Mods.Cnc.Widgets var team = template.GetWidget("TEAM"); team.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString(); - var status = template.GetWidget("STATUS"); + var status = template.GetWidget("STATUS"); status.IsChecked = () => c.State == Session.ClientState.Ready; if (c.Index == orderManager.LocalClient.Index) - status.OnChange += CycleReady; + status.OnClick += CycleReady; var spectator = template.GetWidget("SPECTATOR"); @@ -528,7 +528,7 @@ namespace OpenRA.Mods.Cnc.Widgets bool SpawnPointAvailable(int index) { return (index == 0) || orderManager.LobbyInfo.Clients.All(c => c.SpawnPoint != index); } - void CycleReady(bool ready) + void CycleReady() { orderManager.IssueOrder(Order.Command("ready")); } diff --git a/OpenRA.Mods.Cnc/Widgets/CncMenuButton.cs b/OpenRA.Mods.Cnc/Widgets/CncMenuButton.cs index 93e3df3dcb..f656c08cf1 100644 --- a/OpenRA.Mods.Cnc/Widgets/CncMenuButton.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncMenuButton.cs @@ -19,6 +19,7 @@ namespace OpenRA.Mods.Cnc.Widgets { public Func IsDisabled = () => false; public Action OnClick = () => {}; + public Renderer.FontType Font = Renderer.FontType.Bold; public CncMenuButtonWidget() : base() @@ -26,29 +27,32 @@ namespace OpenRA.Mods.Cnc.Widgets OnMouseUp = mi => { if (!IsDisabled()) OnClick(); return true; }; } - protected CncMenuButtonWidget(CncMenuButtonWidget widget) - : base(widget) + protected CncMenuButtonWidget(CncMenuButtonWidget other) + : base(other) { OnMouseUp = mi => { if (!IsDisabled()) OnClick(); return true; }; + Font = other.Font; } public override int2 ChildOrigin { get { return RenderOrigin; } } public override void DrawInner() { - var font = Game.Renderer.BoldFont; + var rb = RenderBounds; + var font = Game.Renderer.Fonts[Font]; var state = IsDisabled() ? "button-disabled" : Depressed ? "button-pressed" : - RenderBounds.Contains(Viewport.LastMousePos) ? "button-hover" : + rb.Contains(Viewport.LastMousePos) ? "button-hover" : "button"; - WidgetUtils.DrawPanel(state, RenderBounds); + WidgetUtils.DrawPanel(state, rb); var text = GetText(); font.DrawText(text, - new int2(RenderOrigin.X + UsableWidth / 2, RenderOrigin.Y + Bounds.Height / 2) + new int2(rb.X + UsableWidth / 2, rb.Y + Bounds.Height / 2) - new int2(font.Measure(text).X / 2, font.Measure(text).Y / 2), IsDisabled() ? Color.Gray : Color.White); } + public override Widget Clone() { return new CncMenuButtonWidget(this); } } public class CncCheckboxWidget : CncMenuButtonWidget @@ -81,6 +85,7 @@ namespace OpenRA.Mods.Cnc.Widgets ChromeProvider.GetImage("checkbox", "checked"), new float2(rect.Left + 2, rect.Top + 2)); } + public override Widget Clone() { return new CncCheckboxWidget(this); } } public class CncScrollPanelWidget : ScrollPanelWidget @@ -148,6 +153,8 @@ namespace OpenRA.Mods.Cnc.Widgets { ListOffset = Math.Min(0,Bounds.Height - ContentHeight); } + public override Widget Clone() { return new CncScrollPanelWidget(this); } + } } diff --git a/mods/cnc/chrome/lobby.yaml b/mods/cnc/chrome/lobby.yaml index c696a33263..83e6b0797f 100644 --- a/mods/cnc/chrome/lobby.yaml +++ b/mods/cnc/chrome/lobby.yaml @@ -109,7 +109,7 @@ Container@SERVER_LOBBY: Height:25 X:390 Y:0 - Checkbox@STATUS: + CncCheckbox@STATUS: Id:STATUS X:448 Y:2 @@ -139,7 +139,7 @@ Container@SERVER_LOBBY: Height:25 X:5 Y:0-1 - Button@KICK: + CncMenuButton@KICK: Id:KICK Text:X Width:25 @@ -181,7 +181,7 @@ Container@SERVER_LOBBY: Align:Center X:390 Y:0 - Checkbox@STATUS: + CncCheckbox@STATUS: Id:STATUS X:448 Y:2 @@ -211,9 +211,10 @@ Container@SERVER_LOBBY: Height:25 X:5 Y:0-1 - Button@JOIN: + CncMenuButton@JOIN: Id:JOIN Text:Play in this slot + Font:Regular Width:278 Height:25 X:160 @@ -242,9 +243,10 @@ Container@SERVER_LOBBY: Height:25 X:0 Y:0 - Button@JOIN: + CncMenuButton@JOIN: Id:JOIN Text:Play in this slot + Font:Regular Width:278 Height:25 X:160