Convert remaining buttons and checkboxes to cnc variants
This commit is contained in:
@@ -464,9 +464,9 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
team.OnMouseDown = _ => ShowTeamDropDown(team);
|
team.OnMouseDown = _ => ShowTeamDropDown(team);
|
||||||
team.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString();
|
team.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString();
|
||||||
|
|
||||||
var status = template.GetWidget<CheckboxWidget>("STATUS");
|
var status = template.GetWidget<CncCheckboxWidget>("STATUS");
|
||||||
status.IsChecked = () => c.State == Session.ClientState.Ready;
|
status.IsChecked = () => c.State == Session.ClientState.Ready;
|
||||||
status.OnChange += CycleReady;
|
status.OnClick += CycleReady;
|
||||||
|
|
||||||
var spectator = template.GetWidget<LabelWidget>("SPECTATOR");
|
var spectator = template.GetWidget<LabelWidget>("SPECTATOR");
|
||||||
|
|
||||||
@@ -496,10 +496,10 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
var team = template.GetWidget<LabelWidget>("TEAM");
|
var team = template.GetWidget<LabelWidget>("TEAM");
|
||||||
team.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString();
|
team.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString();
|
||||||
|
|
||||||
var status = template.GetWidget<CheckboxWidget>("STATUS");
|
var status = template.GetWidget<CncCheckboxWidget>("STATUS");
|
||||||
status.IsChecked = () => c.State == Session.ClientState.Ready;
|
status.IsChecked = () => c.State == Session.ClientState.Ready;
|
||||||
if (c.Index == orderManager.LocalClient.Index)
|
if (c.Index == orderManager.LocalClient.Index)
|
||||||
status.OnChange += CycleReady;
|
status.OnClick += CycleReady;
|
||||||
|
|
||||||
var spectator = template.GetWidget<LabelWidget>("SPECTATOR");
|
var spectator = template.GetWidget<LabelWidget>("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); }
|
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"));
|
orderManager.IssueOrder(Order.Command("ready"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
{
|
{
|
||||||
public Func<bool> IsDisabled = () => false;
|
public Func<bool> IsDisabled = () => false;
|
||||||
public Action OnClick = () => {};
|
public Action OnClick = () => {};
|
||||||
|
public Renderer.FontType Font = Renderer.FontType.Bold;
|
||||||
|
|
||||||
public CncMenuButtonWidget()
|
public CncMenuButtonWidget()
|
||||||
: base()
|
: base()
|
||||||
@@ -26,29 +27,32 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
OnMouseUp = mi => { if (!IsDisabled()) OnClick(); return true; };
|
OnMouseUp = mi => { if (!IsDisabled()) OnClick(); return true; };
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CncMenuButtonWidget(CncMenuButtonWidget widget)
|
protected CncMenuButtonWidget(CncMenuButtonWidget other)
|
||||||
: base(widget)
|
: base(other)
|
||||||
{
|
{
|
||||||
OnMouseUp = mi => { if (!IsDisabled()) OnClick(); return true; };
|
OnMouseUp = mi => { if (!IsDisabled()) OnClick(); return true; };
|
||||||
|
Font = other.Font;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int2 ChildOrigin { get { return RenderOrigin; } }
|
public override int2 ChildOrigin { get { return RenderOrigin; } }
|
||||||
public override void DrawInner()
|
public override void DrawInner()
|
||||||
{
|
{
|
||||||
var font = Game.Renderer.BoldFont;
|
var rb = RenderBounds;
|
||||||
|
var font = Game.Renderer.Fonts[Font];
|
||||||
var state = IsDisabled() ? "button-disabled" :
|
var state = IsDisabled() ? "button-disabled" :
|
||||||
Depressed ? "button-pressed" :
|
Depressed ? "button-pressed" :
|
||||||
RenderBounds.Contains(Viewport.LastMousePos) ? "button-hover" :
|
rb.Contains(Viewport.LastMousePos) ? "button-hover" :
|
||||||
"button";
|
"button";
|
||||||
|
|
||||||
WidgetUtils.DrawPanel(state, RenderBounds);
|
WidgetUtils.DrawPanel(state, rb);
|
||||||
var text = GetText();
|
var text = GetText();
|
||||||
|
|
||||||
font.DrawText(text,
|
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,
|
- new int2(font.Measure(text).X / 2,
|
||||||
font.Measure(text).Y / 2), IsDisabled() ? Color.Gray : Color.White);
|
font.Measure(text).Y / 2), IsDisabled() ? Color.Gray : Color.White);
|
||||||
}
|
}
|
||||||
|
public override Widget Clone() { return new CncMenuButtonWidget(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CncCheckboxWidget : CncMenuButtonWidget
|
public class CncCheckboxWidget : CncMenuButtonWidget
|
||||||
@@ -81,6 +85,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
ChromeProvider.GetImage("checkbox", "checked"),
|
ChromeProvider.GetImage("checkbox", "checked"),
|
||||||
new float2(rect.Left + 2, rect.Top + 2));
|
new float2(rect.Left + 2, rect.Top + 2));
|
||||||
}
|
}
|
||||||
|
public override Widget Clone() { return new CncCheckboxWidget(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CncScrollPanelWidget : ScrollPanelWidget
|
public class CncScrollPanelWidget : ScrollPanelWidget
|
||||||
@@ -148,6 +153,8 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
{
|
{
|
||||||
ListOffset = Math.Min(0,Bounds.Height - ContentHeight);
|
ListOffset = Math.Min(0,Bounds.Height - ContentHeight);
|
||||||
}
|
}
|
||||||
|
public override Widget Clone() { return new CncScrollPanelWidget(this); }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ Container@SERVER_LOBBY:
|
|||||||
Height:25
|
Height:25
|
||||||
X:390
|
X:390
|
||||||
Y:0
|
Y:0
|
||||||
Checkbox@STATUS:
|
CncCheckbox@STATUS:
|
||||||
Id:STATUS
|
Id:STATUS
|
||||||
X:448
|
X:448
|
||||||
Y:2
|
Y:2
|
||||||
@@ -139,7 +139,7 @@ Container@SERVER_LOBBY:
|
|||||||
Height:25
|
Height:25
|
||||||
X:5
|
X:5
|
||||||
Y:0-1
|
Y:0-1
|
||||||
Button@KICK:
|
CncMenuButton@KICK:
|
||||||
Id:KICK
|
Id:KICK
|
||||||
Text:X
|
Text:X
|
||||||
Width:25
|
Width:25
|
||||||
@@ -181,7 +181,7 @@ Container@SERVER_LOBBY:
|
|||||||
Align:Center
|
Align:Center
|
||||||
X:390
|
X:390
|
||||||
Y:0
|
Y:0
|
||||||
Checkbox@STATUS:
|
CncCheckbox@STATUS:
|
||||||
Id:STATUS
|
Id:STATUS
|
||||||
X:448
|
X:448
|
||||||
Y:2
|
Y:2
|
||||||
@@ -211,9 +211,10 @@ Container@SERVER_LOBBY:
|
|||||||
Height:25
|
Height:25
|
||||||
X:5
|
X:5
|
||||||
Y:0-1
|
Y:0-1
|
||||||
Button@JOIN:
|
CncMenuButton@JOIN:
|
||||||
Id:JOIN
|
Id:JOIN
|
||||||
Text:Play in this slot
|
Text:Play in this slot
|
||||||
|
Font:Regular
|
||||||
Width:278
|
Width:278
|
||||||
Height:25
|
Height:25
|
||||||
X:160
|
X:160
|
||||||
@@ -242,9 +243,10 @@ Container@SERVER_LOBBY:
|
|||||||
Height:25
|
Height:25
|
||||||
X:0
|
X:0
|
||||||
Y:0
|
Y:0
|
||||||
Button@JOIN:
|
CncMenuButton@JOIN:
|
||||||
Id:JOIN
|
Id:JOIN
|
||||||
Text:Play in this slot
|
Text:Play in this slot
|
||||||
|
Font:Regular
|
||||||
Width:278
|
Width:278
|
||||||
Height:25
|
Height:25
|
||||||
X:160
|
X:160
|
||||||
|
|||||||
Reference in New Issue
Block a user