it fails
This commit is contained in:
@@ -238,7 +238,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
var isLocalPlayer = client.Index == Game.orderManager.Connection.LocalClientId;
|
var isLocalPlayer = client.Index == Game.orderManager.Connection.LocalClientId;
|
||||||
var paletteRect = new Rectangle(r.Left + 130, y - 2, 65, 22);
|
var paletteRect = new Rectangle(r.Left + 130, y - 2, 65, 22);
|
||||||
|
/*
|
||||||
if (isLocalPlayer)
|
if (isLocalPlayer)
|
||||||
{
|
{
|
||||||
// todo: name editing
|
// todo: name editing
|
||||||
@@ -264,9 +264,9 @@ namespace OpenRA
|
|||||||
DrawDialogBackground(readyRect, "dialog3");
|
DrawDialogBackground(readyRect, "dialog3");
|
||||||
AddButton(readyRect, CycleReady);
|
AddButton(readyRect, CycleReady);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
shpRenderer.Flush();
|
shpRenderer.Flush();
|
||||||
|
/*
|
||||||
f = renderer.RegularFont;
|
f = renderer.RegularFont;
|
||||||
f.DrawText(client.Name, new int2(r.Left + 40, y), Color.White);
|
f.DrawText(client.Name, new int2(r.Left + 40, y), Color.White);
|
||||||
lineRenderer.FillRect(RectangleF.FromLTRB(paletteRect.Left + Game.viewport.Location.X + 5,
|
lineRenderer.FillRect(RectangleF.FromLTRB(paletteRect.Left + Game.viewport.Location.X + 5,
|
||||||
@@ -280,7 +280,7 @@ namespace OpenRA
|
|||||||
f.DrawText((client.Team == 0)? "-" : client.Team.ToString(), new int2(r.Left + 395 + 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);
|
f.DrawText(client.State.ToString(), new int2(r.Left + 475, y), Color.White);
|
||||||
y += 30;
|
y += 30;
|
||||||
|
*/
|
||||||
rgbaRenderer.Flush();
|
rgbaRenderer.Flush();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
{
|
{
|
||||||
@@ -27,6 +28,14 @@ namespace OpenRA.Widgets
|
|||||||
public string Text = "";
|
public string Text = "";
|
||||||
public bool Depressed = false;
|
public bool Depressed = false;
|
||||||
public int VisualHeight = 1;
|
public int VisualHeight = 1;
|
||||||
|
public Func<string> GetText;
|
||||||
|
|
||||||
|
public ButtonWidget()
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
GetText = () => { return Text; };
|
||||||
|
}
|
||||||
|
|
||||||
public override bool HandleInput(MouseInput mi)
|
public override bool HandleInput(MouseInput mi)
|
||||||
{
|
{
|
||||||
if (Chrome.selectedWidget == this)
|
if (Chrome.selectedWidget == this)
|
||||||
@@ -79,5 +88,20 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
base.Draw(world);
|
base.Draw(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Widget Clone()
|
||||||
|
{
|
||||||
|
Log.Write("Foo");
|
||||||
|
var widget = (base.Clone() as ButtonWidget);
|
||||||
|
Log.Write(widget.Id);
|
||||||
|
|
||||||
|
widget.Text = Text;
|
||||||
|
widget.Depressed = Depressed;
|
||||||
|
widget.VisualHeight = VisualHeight;
|
||||||
|
widget.GetText = GetText;
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,20 +1,55 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace OpenRA.Widgets.Delegates
|
namespace OpenRA.Widgets.Delegates
|
||||||
{
|
{
|
||||||
public class LobbyDelegate : IWidgetDelegate
|
public class LobbyDelegate : IWidgetDelegate
|
||||||
{
|
{
|
||||||
|
Widget PlayerTemplate;
|
||||||
|
Widget Players;
|
||||||
|
|
||||||
public LobbyDelegate ()
|
public LobbyDelegate ()
|
||||||
{
|
{
|
||||||
var r = Chrome.rootWidget;
|
var r = Chrome.rootWidget;
|
||||||
var lobby = r.GetWidget("SERVER_LOBBY");
|
var lobby = r.GetWidget("SERVER_LOBBY");
|
||||||
|
Players = Chrome.rootWidget.GetWidget("SERVER_LOBBY").GetWidget("PLAYERS");
|
||||||
|
PlayerTemplate = Players.GetWidget("TEMPLATE");
|
||||||
|
|
||||||
|
|
||||||
var mapButton = lobby.GetWidget("CHANGEMAP_BUTTON");
|
var mapButton = lobby.GetWidget("CHANGEMAP_BUTTON");
|
||||||
mapButton.OnMouseUp = mi => {
|
mapButton.OnMouseUp = mi => {
|
||||||
r.OpenWindow("MAP_CHOOSER");
|
r.OpenWindow("MAP_CHOOSER");
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
mapButton.IsVisible = () => {return (mapButton.Visible && Game.IsHost);};
|
mapButton.IsVisible = () => {return (mapButton.Visible && Game.IsHost);};
|
||||||
|
|
||||||
|
Game.LobbyInfoChanged += () => { UpdatePlayerList(); };
|
||||||
|
|
||||||
|
UpdatePlayerList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdatePlayerList()
|
||||||
|
{
|
||||||
|
Log.Write("UpdatePlayerList");
|
||||||
|
|
||||||
|
Players.Children.Clear();
|
||||||
|
int i = 0;
|
||||||
|
foreach(var client in Game.LobbyInfo.Clients)
|
||||||
|
{
|
||||||
|
Log.Write("Client {0}",client.Name);
|
||||||
|
var template = PlayerTemplate.Clone();
|
||||||
|
template.Id = "PLAYER_{0}".F(client.Name);
|
||||||
|
template.GetWidget<ButtonWidget>("NAME").GetText = () => client.Name;
|
||||||
|
template.Bounds = new Rectangle(template.Bounds.X, template.Bounds.Y + i, template.Bounds.Width, template.Bounds.Height);
|
||||||
|
template.Visible = true;
|
||||||
|
Players.AddChild(template);
|
||||||
|
i += 30;
|
||||||
|
}
|
||||||
|
Log.Write("Players has {0} children",Players.Children.Count);
|
||||||
|
foreach (var foo in Players.Children)
|
||||||
|
Log.Write("{0} {1} {2}",foo.Id, foo.GetWidget<ButtonWidget>("NAME").GetText(), foo.Bounds.Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,11 +35,6 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
GetText = () => { return Text; };
|
GetText = () => { return Text; };
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
base.Initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Draw(World world)
|
public override void Draw(World world)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -54,7 +54,34 @@ namespace OpenRA.Widgets
|
|||||||
public Func<bool> IsVisible;
|
public Func<bool> IsVisible;
|
||||||
|
|
||||||
public Widget() { IsVisible = () => Visible; }
|
public Widget() { IsVisible = () => Visible; }
|
||||||
|
|
||||||
|
public virtual Widget Clone()
|
||||||
|
{
|
||||||
|
Widget widget = new Widget();
|
||||||
|
|
||||||
|
widget.Id = Id;
|
||||||
|
widget.X = X;
|
||||||
|
widget.Y = Y;
|
||||||
|
widget.Width = Width;
|
||||||
|
widget.Height = Height;
|
||||||
|
widget.Delegate = Delegate;
|
||||||
|
widget.ClickThrough = ClickThrough;
|
||||||
|
widget.Visible = Visible;
|
||||||
|
|
||||||
|
widget.Bounds = Bounds;
|
||||||
|
widget.Parent = Parent;
|
||||||
|
|
||||||
|
widget.OnMouseDown = OnMouseDown;
|
||||||
|
widget.OnMouseUp = OnMouseUp;
|
||||||
|
widget.OnMouseMove = OnMouseMove;
|
||||||
|
widget.IsVisible = IsVisible;
|
||||||
|
|
||||||
|
foreach(var child in Children)
|
||||||
|
widget.AddChild(child.Clone());
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void Initialize()
|
public virtual void Initialize()
|
||||||
{
|
{
|
||||||
// Parse the YAML equations to find the widget bounds
|
// Parse the YAML equations to find the widget bounds
|
||||||
|
|||||||
@@ -288,6 +288,55 @@ Container:
|
|||||||
Y:4
|
Y:4
|
||||||
Width:244
|
Width:244
|
||||||
Height:244
|
Height:244
|
||||||
|
Container@PLAYERS
|
||||||
|
Id:PLAYERS
|
||||||
|
X:30
|
||||||
|
Y:75
|
||||||
|
Children:
|
||||||
|
Container@TEMPLATE
|
||||||
|
Id:TEMPLATE
|
||||||
|
Visible:false
|
||||||
|
Children:
|
||||||
|
Button@NAME
|
||||||
|
Id:NAME
|
||||||
|
Text:Name
|
||||||
|
Width:95
|
||||||
|
Height:25
|
||||||
|
X:0
|
||||||
|
Y:0
|
||||||
|
Button@COLOR
|
||||||
|
Id:NAME
|
||||||
|
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
|
||||||
|
Button@STATUS
|
||||||
|
Id:STATUS
|
||||||
|
Text:Foo
|
||||||
|
X:430
|
||||||
|
Y:0
|
||||||
Button@CHANGEMAP_BUTTON:
|
Button@CHANGEMAP_BUTTON:
|
||||||
Id:CHANGEMAP_BUTTON
|
Id:CHANGEMAP_BUTTON
|
||||||
Visible:true
|
Visible:true
|
||||||
|
|||||||
Reference in New Issue
Block a user