Initial lobby rework progress

This commit is contained in:
Paul Chote
2010-11-28 11:25:42 +13:00
parent 7884cb310b
commit 4c517c0e59
2 changed files with 45 additions and 43 deletions

View File

@@ -244,6 +244,29 @@ namespace OpenRA.Widgets.Delegates
});
}
void ShowRaceDropDown(Session.Slot s, ButtonWidget race)
{
if (Map.Players[s.MapPlayer].LockRace)
return;
var dropDownOptions = new List<Pair<string, Action>>();
foreach (var c in CountryNames)
{
var cc = c;
dropDownOptions.Add(new Pair<string, Action>( cc.Value,
() => orderManager.IssueOrder( Order.Command("race "+cc.Key) )) );
};
DropDownButtonWidget.ShowDropDown( race,
dropDownOptions,
(ac, w) => new LabelWidget
{
Bounds = new Rectangle(0, 0, w, 24),
Text = " {0}".F(ac.First),
OnMouseUp = mi => { ac.Second(); return true; },
});
}
void UpdatePlayerList()
{
// This causes problems for people who are in the process of editing their names (the widgets vanish from beneath them)
@@ -349,7 +372,8 @@ namespace OpenRA.Widgets.Delegates
colorBlock.GetColor = () => c.Color1;
var faction = template.GetWidget<ButtonWidget>("FACTION");
faction.OnMouseUp = mi => CycleRace(mi, s);
faction.OnMouseDown = _ => {ShowRaceDropDown(s, faction); return true;};
var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME");
factionname.GetText = () => CountryNames[c.Country];
var factionflag = faction.GetWidget<ImageWidget>("FACTIONFLAG");
@@ -415,28 +439,6 @@ namespace OpenRA.Widgets.Delegates
}
bool SpawnPointAvailable(int index) { return (index == 0) || orderManager.LobbyInfo.Clients.All(c => c.SpawnPoint != index); }
bool CycleRace(MouseInput mi, Session.Slot s)
{
if (Map.Players[s.MapPlayer].LockColor)
return false;
var countries = CountryNames.Select(a => a.Key);
if (mi.Button == MouseButton.Right)
countries = countries.Reverse();
var nextCountry = countries
.SkipWhile(c => c != orderManager.LocalClient.Country)
.Skip(1)
.FirstOrDefault();
if (nextCountry == null)
nextCountry = countries.First();
orderManager.IssueOrder(Order.Command("race " + nextCountry));
return true;
}
bool CycleReady(MouseInput mi)
{

View File

@@ -47,36 +47,36 @@ Background@SERVER_LOBBY:
Id:TEMPLATE_LOCAL
X:0
Y:0
Width:400
Width:475
Height:30
Visible:false
Children:
TextField@NAME:
Id:NAME
Text:Name
Width:139
Width:150
Height:25
X:0
Y:0
MaxLength:16
Button@COLOR:
DropDownButton@COLOR:
Id:COLOR
Width:65
Width:80
Height:25
X:159
X:160
Y:0
Children:
ColorBlock@COLORBLOCK:
Id:COLORBLOCK
X:5
Y:7
Width:PARENT_RIGHT-10
Y:6
Width:PARENT_RIGHT-35
Height:PARENT_BOTTOM-12
Button@FACTION:
DropDownButton@FACTION:
Id:FACTION
Width:110
Width:130
Height:25
X:244
X:250
Y:0
Children:
Image@FACTIONFLAG:
@@ -92,16 +92,16 @@ Background@SERVER_LOBBY:
Height:25
X:40
Y:0
Button@TEAM:
DropDownButton@TEAM:
Id:TEAM
Text:Team
Width:25
Width:48
Height:25
X:374
X:390
Y:0
Checkbox@STATUS:
Id:STATUS
X:450
X:448
Y:2
Width:20
Height:20
@@ -116,7 +116,7 @@ Background@SERVER_LOBBY:
Label@NAME:
Id:NAME
Text:Name
Width:139
Width:150
Height:25
X:0
Y:0
@@ -172,7 +172,7 @@ Background@SERVER_LOBBY:
Button@NAME:
Id:NAME
Text:Name
Width:139
Width:150
Height:25
X:0
Y:0
@@ -194,7 +194,7 @@ Background@SERVER_LOBBY:
Label@NAME:
Id:NAME
Text:Name
Width:139
Width:150
Height:25
X:0
Y:0
@@ -213,10 +213,10 @@ Background@SERVER_LOBBY:
Height:30
Visible:false
Children:
DropDownButton@NAME: -- TODO: replace with dropdown
DropDownButton@NAME:
Id:NAME
Text:Name
Width:155
Width:150
Height:25
X:0
Y:0
@@ -228,7 +228,7 @@ Background@SERVER_LOBBY:
X:160
Y:0
Container@LABEL_CONTAINER:
X:30
X:25
Y:45
Children:
Label@LABEL_LOBBY_NAME: