Lobby player listing working with widgets
This commit is contained in:
@@ -110,9 +110,7 @@ namespace OpenRA
|
||||
Chrome.rootWidget.CloseWindow();
|
||||
});
|
||||
|
||||
var mapBackground = new Rectangle(r.Right - 284, r.Top + 26, 264, 264);
|
||||
var mapContainer = new Rectangle(r.Right - 280, r.Top + 30, 256, 256);
|
||||
var mapRect = currentMap.PreviewBounds(new Rectangle(mapContainer.X,mapContainer.Y,mapContainer.Width,mapContainer.Height));
|
||||
|
||||
var y = r.Top + 50;
|
||||
|
||||
@@ -171,61 +169,6 @@ namespace OpenRA
|
||||
var w = 800;
|
||||
var h = 600;
|
||||
var r = new Rectangle( (Game.viewport.Width - w) / 2, (Game.viewport.Height - h) / 2, w, h );
|
||||
var f = renderer.BoldFont;
|
||||
|
||||
rgbaRenderer.Flush();
|
||||
|
||||
var y = r.Top + 80;
|
||||
foreach (var client in Game.LobbyInfo.Clients)
|
||||
{
|
||||
var isLocalPlayer = client.Index == Game.orderManager.Connection.LocalClientId;
|
||||
var paletteRect = new Rectangle(r.Left + 130, y - 2, 65, 22);
|
||||
/*
|
||||
if (isLocalPlayer)
|
||||
{
|
||||
// todo: name editing
|
||||
var nameRect = new Rectangle(r.Left + 30, y - 2, 95, 22);
|
||||
DrawDialogBackground(nameRect, "dialog3");
|
||||
|
||||
DrawDialogBackground(paletteRect, "dialog3");
|
||||
AddButton(paletteRect, CyclePalette);
|
||||
|
||||
var factionRect = new Rectangle(r.Left + 210, y - 2, 90, 22);
|
||||
DrawDialogBackground(factionRect, "dialog3");
|
||||
AddButton(factionRect, CycleRace);
|
||||
|
||||
var spawnPointRect = new Rectangle(r.Left + 305, y - 2, 70, 22);
|
||||
DrawDialogBackground(spawnPointRect, "dialog3");
|
||||
AddButton(spawnPointRect, CycleSpawnPoint);
|
||||
|
||||
var teamRect = new Rectangle(r.Left + 385, y - 2, 70, 22);
|
||||
DrawDialogBackground(teamRect, "dialog3");
|
||||
AddButton(teamRect, CycleTeam);
|
||||
|
||||
var readyRect = new Rectangle(r.Left + 465, y - 2, 50, 22);
|
||||
DrawDialogBackground(readyRect, "dialog3");
|
||||
AddButton(readyRect, CycleReady);
|
||||
}
|
||||
*/
|
||||
shpRenderer.Flush();
|
||||
/*
|
||||
f = renderer.RegularFont;
|
||||
f.DrawText(client.Name, new int2(r.Left + 40, y), Color.White);
|
||||
lineRenderer.FillRect(RectangleF.FromLTRB(paletteRect.Left + Game.viewport.Location.X + 5,
|
||||
paletteRect.Top + Game.viewport.Location.Y + 5,
|
||||
paletteRect.Right + Game.viewport.Location.X - 5,
|
||||
paletteRect.Bottom+Game.viewport.Location.Y - 5),
|
||||
Player.PlayerColors(Game.world)[client.PaletteIndex % Player.PlayerColors(Game.world).Count()].c);
|
||||
lineRenderer.Flush();
|
||||
f.DrawText(client.Country, new int2(r.Left + 220, y), Color.White);
|
||||
f.DrawText((client.SpawnPoint == 0) ? "-" : client.SpawnPoint.ToString(), new int2(r.Left + 315 + 20, y), Color.White);
|
||||
f.DrawText((client.Team == 0)? "-" : client.Team.ToString(), new int2(r.Left + 395 + 20, y), Color.White);
|
||||
f.DrawText(client.State.ToString(), new int2(r.Left + 475, y), Color.White);
|
||||
y += 30;
|
||||
*/
|
||||
rgbaRenderer.Flush();
|
||||
|
||||
}
|
||||
|
||||
var typingBox = new Rectangle(r.Left + 20, r.Bottom - 47, r.Width - 40, 27);
|
||||
var chatBox = new Rectangle(r.Left + 20, r.Bottom - 269, r.Width - 40, 220);
|
||||
@@ -234,11 +177,6 @@ namespace OpenRA
|
||||
DrawDialogBackground(chatBox, "dialog3");
|
||||
|
||||
DrawChat(typingBox, chatBox);
|
||||
|
||||
// block clicks `through` the dialog
|
||||
AddButton(r, _ => { });
|
||||
|
||||
|
||||
}
|
||||
|
||||
void AddButton(RectangleF r, Action<bool> b) { buttons.Add(Pair.New(r, b)); }
|
||||
|
||||
@@ -36,13 +36,13 @@ namespace OpenRA.Widgets
|
||||
GetText = () => { return Text; };
|
||||
}
|
||||
|
||||
public ButtonWidget(ButtonWidget widget)
|
||||
public ButtonWidget(Widget widget)
|
||||
:base(widget)
|
||||
{
|
||||
Text = widget.Text;
|
||||
Depressed = widget.Depressed;
|
||||
VisualHeight = widget.VisualHeight;
|
||||
GetText = widget.GetText;
|
||||
Text = (widget as ButtonWidget).Text;
|
||||
Depressed = (widget as ButtonWidget).Depressed;
|
||||
VisualHeight = (widget as ButtonWidget).VisualHeight;
|
||||
GetText = (widget as ButtonWidget).GetText;
|
||||
}
|
||||
|
||||
public override bool HandleInput(MouseInput mi)
|
||||
|
||||
@@ -9,15 +9,15 @@ namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
public class LobbyDelegate : IWidgetDelegate
|
||||
{
|
||||
Widget PlayerTemplate;
|
||||
Widget Players;
|
||||
Widget Players, LocalPlayerTemplate, RemotePlayerTemplate;
|
||||
|
||||
public LobbyDelegate ()
|
||||
{
|
||||
var r = Chrome.rootWidget;
|
||||
var lobby = r.GetWidget("SERVER_LOBBY");
|
||||
Players = Chrome.rootWidget.GetWidget("SERVER_LOBBY").GetWidget("PLAYERS");
|
||||
PlayerTemplate = Players.GetWidget("TEMPLATE");
|
||||
LocalPlayerTemplate = Players.GetWidget("TEMPLATE_LOCAL");
|
||||
RemotePlayerTemplate = Players.GetWidget("TEMPLATE_REMOTE");
|
||||
|
||||
|
||||
var mapButton = lobby.GetWidget("CHANGEMAP_BUTTON");
|
||||
@@ -26,11 +26,9 @@ namespace OpenRA.Widgets.Delegates
|
||||
return true;
|
||||
};
|
||||
|
||||
mapButton.IsVisible = () => {return (mapButton.Visible && Game.IsHost);};
|
||||
mapButton.IsVisible = () => mapButton.Visible && Game.IsHost;
|
||||
|
||||
Game.LobbyInfoChanged += () => UpdatePlayerList();
|
||||
|
||||
UpdatePlayerList();
|
||||
Game.LobbyInfoChanged += UpdatePlayerList;
|
||||
}
|
||||
|
||||
void UpdatePlayerList()
|
||||
@@ -41,37 +39,53 @@ namespace OpenRA.Widgets.Delegates
|
||||
foreach(var client in Game.LobbyInfo.Clients)
|
||||
{
|
||||
var c = client;
|
||||
|
||||
Log.Write("Client {0}",c.Name);
|
||||
var template = PlayerTemplate.Clone();
|
||||
var pos = template.DrawPosition();
|
||||
var template = (client.Index == Game.LocalClient.Index)? LocalPlayerTemplate.Clone() : RemotePlayerTemplate.Clone();
|
||||
|
||||
template.Id = "PLAYER_{0}".F(c.Index);
|
||||
template.Parent = Players;
|
||||
template.GetWidget<LabelWidget>("NAME").GetText = () => c.Name;
|
||||
|
||||
template.GetWidget<ButtonWidget>("NAME").GetText = () => c.Name;
|
||||
|
||||
if(client.Index == Game.LocalClient.Index)
|
||||
{
|
||||
//TODO: Real Color Button
|
||||
var color = template.GetWidget<ButtonWidget>("COLOR");
|
||||
color.OnMouseUp = mi => CyclePalette(mi);
|
||||
color.OnMouseUp = CyclePalette;
|
||||
color.GetText = () => c.PaletteIndex.ToString();
|
||||
|
||||
var faction = template.GetWidget<ButtonWidget>("FACTION");
|
||||
faction.OnMouseUp = mi => CycleRace(mi);
|
||||
faction.OnMouseUp = CycleRace;
|
||||
faction.GetText = () => c.Country;
|
||||
|
||||
var spawn = template.GetWidget<ButtonWidget>("SPAWN");
|
||||
spawn.OnMouseUp = mi => CycleSpawnPoint(mi);
|
||||
spawn.GetText = () => { return (c.SpawnPoint == 0) ? "-" : c.SpawnPoint.ToString(); };
|
||||
spawn.OnMouseUp = CycleSpawnPoint;
|
||||
spawn.GetText = () => (c.SpawnPoint == 0) ? "-" : c.SpawnPoint.ToString();
|
||||
|
||||
var team = template.GetWidget<ButtonWidget>("TEAM");
|
||||
team.OnMouseUp = mi => CycleTeam(mi);
|
||||
team.GetText = () => { return (c.Team == 0) ? "-" : c.Team.ToString(); };
|
||||
team.OnMouseUp = CycleTeam;
|
||||
team.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString();
|
||||
|
||||
//It fails here
|
||||
var status = template.GetWidget<CheckboxWidget>("STATUS");
|
||||
status.Checked = () => { return (c.State == Session.ClientState.Ready) ? true : false; };
|
||||
status.OnMouseDown = mi => CycleReady(mi);
|
||||
status.Checked = () => c.State == Session.ClientState.Ready;
|
||||
status.OnMouseDown = CycleReady;
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: Real Color Label
|
||||
var color = template.GetWidget<LabelWidget>("COLOR");
|
||||
color.GetText = () => c.PaletteIndex.ToString();
|
||||
|
||||
var faction = template.GetWidget<LabelWidget>("FACTION");
|
||||
faction.GetText = () => c.Country;
|
||||
|
||||
var spawn = template.GetWidget<LabelWidget>("SPAWN");
|
||||
spawn.GetText = () => (c.SpawnPoint == 0) ? "-" : c.SpawnPoint.ToString();
|
||||
|
||||
var team = template.GetWidget<LabelWidget>("TEAM");
|
||||
team.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString();
|
||||
|
||||
var status = template.GetWidget<CheckboxWidget>("STATUS");
|
||||
status.Checked = () => c.State == Session.ClientState.Ready;
|
||||
}
|
||||
|
||||
template.Bounds = new Rectangle(0, offset, template.Bounds.Width, template.Bounds.Height);
|
||||
template.IsVisible = () => true;
|
||||
|
||||
@@ -36,6 +36,15 @@ namespace OpenRA.Widgets
|
||||
GetText = () => { return Text; };
|
||||
}
|
||||
|
||||
public LabelWidget(Widget other)
|
||||
: base(other)
|
||||
{
|
||||
Text = (other as LabelWidget).Text;
|
||||
Align = (other as LabelWidget).Align;
|
||||
Bold = (other as LabelWidget).Bold;
|
||||
GetText = (other as LabelWidget).GetText;
|
||||
}
|
||||
|
||||
public override void Draw(World world)
|
||||
{
|
||||
if (!IsVisible())
|
||||
@@ -56,5 +65,10 @@ namespace OpenRA.Widgets
|
||||
font.DrawText(text, position, Color.White);
|
||||
base.Draw(world);
|
||||
}
|
||||
|
||||
public override Widget Clone()
|
||||
{
|
||||
return new LabelWidget(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -262,6 +262,7 @@ Container:
|
||||
Text:Abort
|
||||
Background@SERVER_LOBBY:
|
||||
Id:SERVER_LOBBY
|
||||
Delegate:LobbyDelegate
|
||||
X:(WINDOW_RIGHT - WIDTH)/2
|
||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||
Width:800
|
||||
@@ -287,6 +288,165 @@ Container:
|
||||
Y:4
|
||||
Width:244
|
||||
Height:244
|
||||
Container@PLAYERS
|
||||
Id:PLAYERS
|
||||
X:30
|
||||
Y:75
|
||||
Width:500
|
||||
Height:200
|
||||
Children:
|
||||
Container@TEMPLATE_LOCAL
|
||||
Id:TEMPLATE_LOCAL
|
||||
X:0
|
||||
Y:0
|
||||
Width:500
|
||||
Height:30
|
||||
Visible:false
|
||||
Children:
|
||||
Label@NAME:
|
||||
Id:NAME
|
||||
Text:Name
|
||||
Width:95
|
||||
Height:25
|
||||
X:0
|
||||
Y:0
|
||||
Button@COLOR:
|
||||
Id:COLOR
|
||||
Text:Color
|
||||
Width:65
|
||||
Height:25
|
||||
X:100
|
||||
Y:0
|
||||
Button@FACTION:
|
||||
Id:FACTION
|
||||
Text:Faction
|
||||
Width:90
|
||||
Height:25
|
||||
X:180
|
||||
Y:0
|
||||
Button@SPAWN:
|
||||
Id:SPAWN
|
||||
Text:Spawn
|
||||
Width:70
|
||||
Height:25
|
||||
X:275
|
||||
Y:0
|
||||
Button@TEAM:
|
||||
Id:TEAM
|
||||
Text:Team
|
||||
Width:70
|
||||
Height:25
|
||||
X:355
|
||||
Y:0
|
||||
Checkbox@STATUS:
|
||||
Id:STATUS
|
||||
X:455
|
||||
Y:0
|
||||
Width:20
|
||||
Height:20
|
||||
Container@TEMPLATE_REMOTE
|
||||
Id:TEMPLATE_REMOTE
|
||||
X:0
|
||||
Y:0
|
||||
Width:500
|
||||
Height:30
|
||||
Visible:false
|
||||
Children:
|
||||
Label@NAME:
|
||||
Id:NAME
|
||||
Text:Name
|
||||
Width:95
|
||||
Height:25
|
||||
X:0
|
||||
Y:0
|
||||
Label@COLOR:
|
||||
Id:COLOR
|
||||
Text:Color
|
||||
Width:65
|
||||
Height:25
|
||||
X:100
|
||||
Y:0
|
||||
Align:Center
|
||||
Label@FACTION:
|
||||
Id:FACTION
|
||||
Text:Faction
|
||||
Width:90
|
||||
Height:25
|
||||
X:180
|
||||
Y:0
|
||||
Align:Center
|
||||
Label@SPAWN:
|
||||
Id:SPAWN
|
||||
Text:Spawn
|
||||
Width:70
|
||||
Height:25
|
||||
X:275
|
||||
Y:0
|
||||
Align:Center
|
||||
Label@TEAM:
|
||||
Id:TEAM
|
||||
Text:Team
|
||||
Width:70
|
||||
Height:25
|
||||
X:355
|
||||
Y:0
|
||||
Align:Center
|
||||
Checkbox@STATUS:
|
||||
Id:STATUS
|
||||
X:455
|
||||
Y:0
|
||||
Width:20
|
||||
Height:20
|
||||
Button@CHANGEMAP_BUTTON:
|
||||
Id:CHANGEMAP_BUTTON
|
||||
Visible:true
|
||||
X:PARENT_RIGHT-140
|
||||
Y:300
|
||||
Width:120
|
||||
Height:25
|
||||
Text:Change Map
|
||||
Label@LABEL_LOBBY_NAME:
|
||||
Id:LABEL_LOBBY_NAME
|
||||
X:40
|
||||
Y:50
|
||||
Width:250
|
||||
Height:25
|
||||
Text:Name
|
||||
Label@LABEL_LOBBY_COLOR:
|
||||
Id:LABEL_LOBBY_COLOR
|
||||
X:140
|
||||
Y:50
|
||||
Width:250
|
||||
Height:25
|
||||
Text:Color
|
||||
Label@LABEL_LOBBY_FACTION
|
||||
Id:LABEL_LOBBY_FACTION
|
||||
X:220
|
||||
Y:50
|
||||
Width:250
|
||||
Height:25
|
||||
Text:Faction
|
||||
Label@LABEL_LOBBY_SPAWN
|
||||
Id:LABEL_LOBBY_SPAWN
|
||||
X:315
|
||||
Y:50
|
||||
Width:250
|
||||
Height:25
|
||||
Text:Spawn
|
||||
Label@LABEL_LOBBY_TEAM
|
||||
Id:LABEL_LOBBY_TEAM
|
||||
X:395
|
||||
Y:50
|
||||
Width:250
|
||||
Height:25
|
||||
Text:Team
|
||||
Label@LABEL_LOBBY_STATUS
|
||||
Id:LABEL_LOBBY_STATUS
|
||||
X:475
|
||||
Y:50
|
||||
Width:250
|
||||
Height:25
|
||||
Text:Status
|
||||
Background@MAP_CHOOSER:
|
||||
Id:MAP_CHOOSER
|
||||
X:(WINDOW_RIGHT - WIDTH)/2
|
||||
@@ -463,3 +623,6 @@ Container:
|
||||
Width:25
|
||||
Height:25
|
||||
Text:[]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -292,18 +292,18 @@ Container:
|
||||
Id:PLAYERS
|
||||
X:30
|
||||
Y:75
|
||||
Width:455
|
||||
Width:500
|
||||
Height:200
|
||||
Children:
|
||||
Container@TEMPLATE
|
||||
Id:TEMPLATE
|
||||
Container@TEMPLATE_LOCAL
|
||||
Id:TEMPLATE_LOCAL
|
||||
X:0
|
||||
Y:0
|
||||
Width:455
|
||||
Width:500
|
||||
Height:30
|
||||
Visible:false
|
||||
Children:
|
||||
Button@NAME:
|
||||
Label@NAME:
|
||||
Id:NAME
|
||||
Text:Name
|
||||
Width:95
|
||||
@@ -340,11 +340,63 @@ Container:
|
||||
Y:0
|
||||
Checkbox@STATUS:
|
||||
Id:STATUS
|
||||
X:430
|
||||
X:455
|
||||
Y:0
|
||||
Width:300
|
||||
Width:20
|
||||
Height:20
|
||||
Container@TEMPLATE_REMOTE
|
||||
Id:TEMPLATE_REMOTE
|
||||
X:0
|
||||
Y:0
|
||||
Width:500
|
||||
Height:30
|
||||
Visible:false
|
||||
Children:
|
||||
Label@NAME:
|
||||
Id:NAME
|
||||
Text:Name
|
||||
Width:95
|
||||
Height:25
|
||||
X:0
|
||||
Y:0
|
||||
Label@COLOR:
|
||||
Id:COLOR
|
||||
Text:Color
|
||||
Width:65
|
||||
Height:25
|
||||
X:100
|
||||
Y:0
|
||||
Align:Center
|
||||
Label@FACTION:
|
||||
Id:FACTION
|
||||
Text:Faction
|
||||
Width:90
|
||||
Height:25
|
||||
X:180
|
||||
Y:0
|
||||
Align:Center
|
||||
Label@SPAWN:
|
||||
Id:SPAWN
|
||||
Text:Spawn
|
||||
Width:70
|
||||
Height:25
|
||||
X:275
|
||||
Y:0
|
||||
Align:Center
|
||||
Label@TEAM:
|
||||
Id:TEAM
|
||||
Text:Team
|
||||
Width:70
|
||||
Height:25
|
||||
X:355
|
||||
Y:0
|
||||
Align:Center
|
||||
Checkbox@STATUS:
|
||||
Id:STATUS
|
||||
X:455
|
||||
Y:0
|
||||
Width:20
|
||||
Height:20
|
||||
Text:Show Spatial Index Debug
|
||||
Button@CHANGEMAP_BUTTON:
|
||||
Id:CHANGEMAP_BUTTON
|
||||
Visible:true
|
||||
|
||||
Reference in New Issue
Block a user