remove plenty of redundant junk
This commit is contained in:
@@ -1,8 +1,27 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Widgets.Delegates
|
||||
|
||||
@@ -16,11 +16,8 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
using System;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Support;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
public class IngameChromeDelegate : IWidgetDelegate
|
||||
|
||||
@@ -18,76 +18,77 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
public class LobbyDelegate : IWidgetDelegate
|
||||
{
|
||||
Widget Players, LocalPlayerTemplate, RemotePlayerTemplate;
|
||||
|
||||
Dictionary<string,string> CountryNames;
|
||||
|
||||
string MapUid;
|
||||
MapStub Map;
|
||||
public LobbyDelegate()
|
||||
{
|
||||
Game.LobbyInfoChanged += UpdateCurrentMap;
|
||||
UpdateCurrentMap();
|
||||
|
||||
var r = Chrome.rootWidget;
|
||||
var lobby = r.GetWidget("SERVER_LOBBY");
|
||||
Players = Chrome.rootWidget.GetWidget("SERVER_LOBBY").GetWidget("PLAYERS");
|
||||
LocalPlayerTemplate = Players.GetWidget("TEMPLATE_LOCAL");
|
||||
RemotePlayerTemplate = Players.GetWidget("TEMPLATE_REMOTE");
|
||||
|
||||
|
||||
var map = lobby.GetWidget<MapPreviewWidget>("LOBBY_MAP_PREVIEW");
|
||||
map.Map = () => {return Map;};
|
||||
map.OnSpawnClick = sp =>
|
||||
{
|
||||
if (Game.LocalClient.State == Session.ClientState.Ready) return;
|
||||
var owned = Game.LobbyInfo.Clients.Any(c => c.SpawnPoint == sp);
|
||||
if (sp == 0 || !owned)
|
||||
Game.IssueOrder(Order.Command("spawn {0}".F(sp)));
|
||||
};
|
||||
|
||||
map.SpawnColors = () =>
|
||||
{
|
||||
var spawns = Map.SpawnPoints;
|
||||
var playerColors = Game.world.PlayerColors();
|
||||
var sc = new Dictionary<int2,Color>();
|
||||
|
||||
for (int i = 1; i <= spawns.Count(); i++)
|
||||
{
|
||||
var client = Game.LobbyInfo.Clients.FirstOrDefault(c => c.SpawnPoint == i);
|
||||
if (client == null)
|
||||
continue;
|
||||
sc.Add(spawns.ElementAt(i-1),playerColors[client.PaletteIndex % playerColors.Count()].Color);
|
||||
}
|
||||
return sc;
|
||||
};
|
||||
|
||||
CountryNames = Rules.Info["world"].Traits.WithInterface<OpenRA.Traits.CountryInfo>().ToDictionary(a => a.Race, a => a.Name);
|
||||
CountryNames.Add("random", "Random");
|
||||
|
||||
var mapButton = lobby.GetWidget("CHANGEMAP_BUTTON");
|
||||
mapButton.OnMouseUp = mi => {
|
||||
r.GetWidget("MAP_CHOOSER").SpecialOneArg(MapUid);
|
||||
r.OpenWindow("MAP_CHOOSER");
|
||||
return true;
|
||||
};
|
||||
|
||||
mapButton.IsVisible = () => mapButton.Visible && Game.IsHost;
|
||||
|
||||
var disconnectButton = lobby.GetWidget("DISCONNECT_BUTTON");
|
||||
disconnectButton.OnMouseUp = mi => {
|
||||
Game.Disconnect();
|
||||
return true;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
public class LobbyDelegate : IWidgetDelegate
|
||||
{
|
||||
Widget Players, LocalPlayerTemplate, RemotePlayerTemplate;
|
||||
|
||||
Dictionary<string, string> CountryNames;
|
||||
|
||||
string MapUid;
|
||||
MapStub Map;
|
||||
public LobbyDelegate()
|
||||
{
|
||||
Game.LobbyInfoChanged += UpdateCurrentMap;
|
||||
UpdateCurrentMap();
|
||||
|
||||
var r = Chrome.rootWidget;
|
||||
var lobby = r.GetWidget("SERVER_LOBBY");
|
||||
Players = Chrome.rootWidget.GetWidget("SERVER_LOBBY").GetWidget("PLAYERS");
|
||||
LocalPlayerTemplate = Players.GetWidget("TEMPLATE_LOCAL");
|
||||
RemotePlayerTemplate = Players.GetWidget("TEMPLATE_REMOTE");
|
||||
|
||||
|
||||
var mapPreview = lobby.GetWidget<MapPreviewWidget>("LOBBY_MAP_PREVIEW");
|
||||
mapPreview.Map = () => Map;
|
||||
mapPreview.OnSpawnClick = sp =>
|
||||
{
|
||||
if (Game.LocalClient.State == Session.ClientState.Ready) return;
|
||||
var owned = Game.LobbyInfo.Clients.Any(c => c.SpawnPoint == sp);
|
||||
if (sp == 0 || !owned)
|
||||
Game.IssueOrder(Order.Command("spawn {0}".F(sp)));
|
||||
};
|
||||
|
||||
mapPreview.SpawnColors = () =>
|
||||
{
|
||||
var spawns = Map.SpawnPoints;
|
||||
var playerColors = Game.world.PlayerColors();
|
||||
var sc = new Dictionary<int2, Color>();
|
||||
|
||||
for (int i = 1; i <= spawns.Count(); i++)
|
||||
{
|
||||
var client = Game.LobbyInfo.Clients.FirstOrDefault(c => c.SpawnPoint == i);
|
||||
if (client == null)
|
||||
continue;
|
||||
sc.Add(spawns.ElementAt(i - 1), playerColors[client.PaletteIndex % playerColors.Count()].Color);
|
||||
}
|
||||
return sc;
|
||||
};
|
||||
|
||||
CountryNames = Rules.Info["world"].Traits.WithInterface<OpenRA.Traits.CountryInfo>().ToDictionary(a => a.Race, a => a.Name);
|
||||
CountryNames.Add("random", "Random");
|
||||
|
||||
var mapButton = lobby.GetWidget("CHANGEMAP_BUTTON");
|
||||
mapButton.OnMouseUp = mi =>
|
||||
{
|
||||
r.GetWidget("MAP_CHOOSER").SpecialOneArg(MapUid);
|
||||
r.OpenWindow("MAP_CHOOSER");
|
||||
return true;
|
||||
};
|
||||
|
||||
mapButton.IsVisible = () => mapButton.Visible && Game.IsHost;
|
||||
|
||||
var disconnectButton = lobby.GetWidget("DISCONNECT_BUTTON");
|
||||
disconnectButton.OnMouseUp = mi =>
|
||||
{
|
||||
Game.Disconnect();
|
||||
return true;
|
||||
};
|
||||
|
||||
var lockTeamsCheckbox = lobby.GetWidget<CheckboxWidget>("LOCKTEAMS_CHECKBOX");
|
||||
@@ -99,186 +100,186 @@ namespace OpenRA.Widgets.Delegates
|
||||
Game.IssueOrder(Order.Command(
|
||||
"lockteams {0}".F(!Game.LobbyInfo.GlobalSettings.LockTeams)));
|
||||
return true;
|
||||
};
|
||||
|
||||
Game.LobbyInfoChanged += UpdatePlayerList;
|
||||
Game.AddChatLine += (c,n,s) => lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").AddLine(c,n,s);
|
||||
|
||||
bool teamChat = false;
|
||||
var chatLabel = lobby.GetWidget<LabelWidget>("LABEL_CHATTYPE");
|
||||
var chatTextField = lobby.GetWidget<TextFieldWidget>("CHAT_TEXTFIELD");
|
||||
chatTextField.OnEnterKey = () =>
|
||||
{
|
||||
if (chatTextField.Text.Length == 0)
|
||||
return true;
|
||||
|
||||
var order = (teamChat) ? Order.TeamChat( chatTextField.Text ) : Order.Chat( chatTextField.Text );
|
||||
Game.IssueOrder( order );
|
||||
chatTextField.Text = "";
|
||||
return true;
|
||||
};
|
||||
|
||||
chatTextField.OnTabKey = () =>
|
||||
{
|
||||
teamChat ^= true;
|
||||
chatLabel.Text = (teamChat) ? "Team:" : "Chat:";
|
||||
return true;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
void UpdateCurrentMap()
|
||||
{
|
||||
if (MapUid == Game.LobbyInfo.GlobalSettings.Map) return;
|
||||
MapUid = Game.LobbyInfo.GlobalSettings.Map;
|
||||
Map = Game.AvailableMaps[ MapUid ];
|
||||
}
|
||||
|
||||
void UpdatePlayerList()
|
||||
{
|
||||
// This causes problems for people who are in the process of editing their names (the widgets vanish from beneath them)
|
||||
// Todo: handle this nicer
|
||||
Players.Children.Clear();
|
||||
|
||||
int offset = 0;
|
||||
foreach(var client in Game.LobbyInfo.Clients)
|
||||
{
|
||||
var c = client;
|
||||
Widget template;
|
||||
|
||||
if(client.Index == Game.LocalClient.Index && c.State != Session.ClientState.Ready)
|
||||
{
|
||||
template = LocalPlayerTemplate.Clone();
|
||||
var name = template.GetWidget<TextFieldWidget>("NAME");
|
||||
name.Text = c.Name;
|
||||
name.OnEnterKey = () =>
|
||||
{
|
||||
name.Text = name.Text.Trim();
|
||||
if (name.Text.Length == 0)
|
||||
name.Text = c.Name;
|
||||
|
||||
name.LoseFocus();
|
||||
if (name.Text == c.Name)
|
||||
return true;
|
||||
|
||||
Game.IssueOrder(Order.Command( "name "+name.Text ));
|
||||
Game.Settings.PlayerName = name.Text;
|
||||
Game.Settings.Save();
|
||||
return true;
|
||||
};
|
||||
name.OnLoseFocus = () => name.OnEnterKey();
|
||||
|
||||
var color = template.GetWidget<ButtonWidget>("COLOR");
|
||||
color.OnMouseUp = CyclePalette;
|
||||
|
||||
};
|
||||
|
||||
Game.LobbyInfoChanged += UpdatePlayerList;
|
||||
Game.AddChatLine += (c, n, s) => lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").AddLine(c, n, s);
|
||||
|
||||
bool teamChat = false;
|
||||
var chatLabel = lobby.GetWidget<LabelWidget>("LABEL_CHATTYPE");
|
||||
var chatTextField = lobby.GetWidget<TextFieldWidget>("CHAT_TEXTFIELD");
|
||||
chatTextField.OnEnterKey = () =>
|
||||
{
|
||||
if (chatTextField.Text.Length == 0)
|
||||
return true;
|
||||
|
||||
var order = (teamChat) ? Order.TeamChat(chatTextField.Text) : Order.Chat(chatTextField.Text);
|
||||
Game.IssueOrder(order);
|
||||
chatTextField.Text = "";
|
||||
return true;
|
||||
};
|
||||
|
||||
chatTextField.OnTabKey = () =>
|
||||
{
|
||||
teamChat ^= true;
|
||||
chatLabel.Text = (teamChat) ? "Team:" : "Chat:";
|
||||
return true;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
void UpdateCurrentMap()
|
||||
{
|
||||
if (MapUid == Game.LobbyInfo.GlobalSettings.Map) return;
|
||||
MapUid = Game.LobbyInfo.GlobalSettings.Map;
|
||||
Map = Game.AvailableMaps[MapUid];
|
||||
}
|
||||
|
||||
void UpdatePlayerList()
|
||||
{
|
||||
// This causes problems for people who are in the process of editing their names (the widgets vanish from beneath them)
|
||||
// Todo: handle this nicer
|
||||
Players.Children.Clear();
|
||||
|
||||
int offset = 0;
|
||||
foreach (var client in Game.LobbyInfo.Clients)
|
||||
{
|
||||
var c = client;
|
||||
Widget template;
|
||||
|
||||
if (client.Index == Game.LocalClient.Index && c.State != Session.ClientState.Ready)
|
||||
{
|
||||
template = LocalPlayerTemplate.Clone();
|
||||
var name = template.GetWidget<TextFieldWidget>("NAME");
|
||||
name.Text = c.Name;
|
||||
name.OnEnterKey = () =>
|
||||
{
|
||||
name.Text = name.Text.Trim();
|
||||
if (name.Text.Length == 0)
|
||||
name.Text = c.Name;
|
||||
|
||||
name.LoseFocus();
|
||||
if (name.Text == c.Name)
|
||||
return true;
|
||||
|
||||
Game.IssueOrder(Order.Command("name " + name.Text));
|
||||
Game.Settings.PlayerName = name.Text;
|
||||
Game.Settings.Save();
|
||||
return true;
|
||||
};
|
||||
name.OnLoseFocus = () => name.OnEnterKey();
|
||||
|
||||
var color = template.GetWidget<ButtonWidget>("COLOR");
|
||||
color.OnMouseUp = CyclePalette;
|
||||
|
||||
var colorBlock = color.GetWidget<ColorBlockWidget>("COLORBLOCK");
|
||||
colorBlock.GetColor = () => Game.world.PlayerColors()[c.PaletteIndex % Game.world.PlayerColors().Count].Color;
|
||||
|
||||
var faction = template.GetWidget<ButtonWidget>("FACTION");
|
||||
faction.OnMouseUp = CycleRace;
|
||||
var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME");
|
||||
factionname.GetText = () => CountryNames[c.Country];
|
||||
var factionflag = faction.GetWidget<ImageWidget>("FACTIONFLAG");
|
||||
factionflag.GetImageName = () => c.Country;
|
||||
factionflag.GetImageCollection = () => "flags";
|
||||
|
||||
var team = template.GetWidget<ButtonWidget>("TEAM");
|
||||
team.OnMouseUp = CycleTeam;
|
||||
team.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString();
|
||||
|
||||
var status = template.GetWidget<CheckboxWidget>("STATUS");
|
||||
status.Checked = () => c.State == Session.ClientState.Ready;
|
||||
status.OnMouseDown = CycleReady;
|
||||
}
|
||||
else
|
||||
{
|
||||
template = RemotePlayerTemplate.Clone();
|
||||
template.GetWidget<LabelWidget>("NAME").GetText = () => c.Name;
|
||||
colorBlock.GetColor = () => Game.world.PlayerColors()[c.PaletteIndex % Game.world.PlayerColors().Count].Color;
|
||||
|
||||
var faction = template.GetWidget<ButtonWidget>("FACTION");
|
||||
faction.OnMouseUp = CycleRace;
|
||||
var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME");
|
||||
factionname.GetText = () => CountryNames[c.Country];
|
||||
var factionflag = faction.GetWidget<ImageWidget>("FACTIONFLAG");
|
||||
factionflag.GetImageName = () => c.Country;
|
||||
factionflag.GetImageCollection = () => "flags";
|
||||
|
||||
var team = template.GetWidget<ButtonWidget>("TEAM");
|
||||
team.OnMouseUp = CycleTeam;
|
||||
team.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString();
|
||||
|
||||
var status = template.GetWidget<CheckboxWidget>("STATUS");
|
||||
status.Checked = () => c.State == Session.ClientState.Ready;
|
||||
status.OnMouseDown = CycleReady;
|
||||
}
|
||||
else
|
||||
{
|
||||
template = RemotePlayerTemplate.Clone();
|
||||
template.GetWidget<LabelWidget>("NAME").GetText = () => c.Name;
|
||||
var color = template.GetWidget<ColorBlockWidget>("COLOR");
|
||||
color.GetColor = () => Game.world.PlayerColors()[c.PaletteIndex % Game.world.PlayerColors().Count].Color;
|
||||
|
||||
var faction = template.GetWidget<LabelWidget>("FACTION");
|
||||
var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME");
|
||||
factionname.GetText = () => CountryNames[c.Country];
|
||||
var factionflag = faction.GetWidget<ImageWidget>("FACTIONFLAG");
|
||||
factionflag.GetImageName = () => c.Country;
|
||||
factionflag.GetImageCollection = () => "flags";
|
||||
|
||||
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;
|
||||
if (client.Index == Game.LocalClient.Index) status.OnMouseDown = CycleReady;
|
||||
}
|
||||
|
||||
template.Id = "PLAYER_{0}".F(c.Index);
|
||||
template.Parent = Players;
|
||||
|
||||
template.Bounds = new Rectangle(0, offset, template.Bounds.Width, template.Bounds.Height);
|
||||
template.IsVisible = () => true;
|
||||
Players.AddChild(template);
|
||||
|
||||
offset += template.Bounds.Height;
|
||||
}
|
||||
}
|
||||
|
||||
bool PaletteAvailable(int index) { return Game.LobbyInfo.Clients.All(c => c.PaletteIndex != index) && Game.world.PlayerColors()[index % Game.world.PlayerColors().Count].Playable; }
|
||||
bool SpawnPointAvailable(int index) { return (index == 0) || Game.LobbyInfo.Clients.All(c => c.SpawnPoint != index); }
|
||||
|
||||
bool CyclePalette(MouseInput mi)
|
||||
color.GetColor = () => Game.world.PlayerColors()[c.PaletteIndex % Game.world.PlayerColors().Count].Color;
|
||||
|
||||
var faction = template.GetWidget<LabelWidget>("FACTION");
|
||||
var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME");
|
||||
factionname.GetText = () => CountryNames[c.Country];
|
||||
var factionflag = faction.GetWidget<ImageWidget>("FACTIONFLAG");
|
||||
factionflag.GetImageName = () => c.Country;
|
||||
factionflag.GetImageCollection = () => "flags";
|
||||
|
||||
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;
|
||||
if (client.Index == Game.LocalClient.Index) status.OnMouseDown = CycleReady;
|
||||
}
|
||||
|
||||
template.Id = "PLAYER_{0}".F(c.Index);
|
||||
template.Parent = Players;
|
||||
|
||||
template.Bounds = new Rectangle(0, offset, template.Bounds.Width, template.Bounds.Height);
|
||||
template.IsVisible = () => true;
|
||||
Players.AddChild(template);
|
||||
|
||||
offset += template.Bounds.Height;
|
||||
}
|
||||
}
|
||||
|
||||
bool PaletteAvailable(int index) { return Game.LobbyInfo.Clients.All(c => c.PaletteIndex != index) && Game.world.PlayerColors()[index % Game.world.PlayerColors().Count].Playable; }
|
||||
bool SpawnPointAvailable(int index) { return (index == 0) || Game.LobbyInfo.Clients.All(c => c.SpawnPoint != index); }
|
||||
|
||||
bool CyclePalette(MouseInput mi)
|
||||
{
|
||||
var d = (mi.Button == MouseButton.Left) ? +1 : Game.world.PlayerColors().Count() - 1;
|
||||
|
||||
var newIndex = ((int)Game.LocalClient.PaletteIndex + d) % Game.world.PlayerColors().Count();
|
||||
|
||||
var newIndex = ((int)Game.LocalClient.PaletteIndex + d) % Game.world.PlayerColors().Count();
|
||||
|
||||
while (!PaletteAvailable(newIndex) && newIndex != (int)Game.LocalClient.PaletteIndex)
|
||||
newIndex = (newIndex + d) % Game.world.PlayerColors().Count();
|
||||
|
||||
Game.IssueOrder(
|
||||
Order.Command("pal " + newIndex));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CycleRace(MouseInput mi)
|
||||
{
|
||||
var countries = CountryNames.Select(a => a.Key);
|
||||
|
||||
if (mi.Button == MouseButton.Right)
|
||||
countries = countries.Reverse();
|
||||
|
||||
var nextCountry = countries
|
||||
.SkipWhile(c => c != Game.LocalClient.Country)
|
||||
.Skip(1)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (nextCountry == null)
|
||||
nextCountry = countries.First();
|
||||
|
||||
Game.IssueOrder(Order.Command("race " + nextCountry));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CycleReady(MouseInput mi)
|
||||
{
|
||||
//HACK: Can't set this as part of the fuction as LocalClient/State not initalised yet
|
||||
Chrome.rootWidget.GetWidget("SERVER_LOBBY").GetWidget<ButtonWidget>("CHANGEMAP_BUTTON").Visible
|
||||
= (Game.IsHost && Game.LocalClient.State == Session.ClientState.Ready);
|
||||
Game.IssueOrder(Order.Command("ready"));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CycleTeam(MouseInput mi)
|
||||
{
|
||||
var d = (mi.Button == MouseButton.Left) ? +1 : Game.world.Map.PlayerCount;
|
||||
|
||||
var newIndex = (Game.LocalClient.Team + d) % (Game.world.Map.PlayerCount+1);
|
||||
|
||||
Game.IssueOrder(
|
||||
Order.Command("team " + newIndex));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
newIndex = (newIndex + d) % Game.world.PlayerColors().Count();
|
||||
|
||||
Game.IssueOrder(
|
||||
Order.Command("pal " + newIndex));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CycleRace(MouseInput mi)
|
||||
{
|
||||
var countries = CountryNames.Select(a => a.Key);
|
||||
|
||||
if (mi.Button == MouseButton.Right)
|
||||
countries = countries.Reverse();
|
||||
|
||||
var nextCountry = countries
|
||||
.SkipWhile(c => c != Game.LocalClient.Country)
|
||||
.Skip(1)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (nextCountry == null)
|
||||
nextCountry = countries.First();
|
||||
|
||||
Game.IssueOrder(Order.Command("race " + nextCountry));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CycleReady(MouseInput mi)
|
||||
{
|
||||
//HACK: Can't set this as part of the fuction as LocalClient/State not initalised yet
|
||||
Chrome.rootWidget.GetWidget("SERVER_LOBBY").GetWidget<ButtonWidget>("CHANGEMAP_BUTTON").Visible
|
||||
= (Game.IsHost && Game.LocalClient.State == Session.ClientState.Ready);
|
||||
Game.IssueOrder(Order.Command("ready"));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CycleTeam(MouseInput mi)
|
||||
{
|
||||
var d = (mi.Button == MouseButton.Left) ? +1 : Game.world.Map.PlayerCount;
|
||||
|
||||
var newIndex = (Game.LocalClient.Team + d) % (Game.world.Map.PlayerCount + 1);
|
||||
|
||||
Game.IssueOrder(
|
||||
Order.Command("team " + newIndex));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
using System;
|
||||
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
public class MainMenuButtonsDelegate : IWidgetDelegate
|
||||
@@ -27,10 +28,10 @@ namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
// Main menu is the default window
|
||||
Widget.WindowList.Push("MAINMENU_BG");
|
||||
Chrome.rootWidget.GetWidget("MAINMENU_BUTTON_QUIT").OnMouseUp = mi => {Game.Exit(); return true;};
|
||||
|
||||
Chrome.rootWidget.GetWidget("MAINMENU_BUTTON_QUIT").OnMouseUp = mi => { Game.Exit(); return true; };
|
||||
|
||||
var version = Chrome.rootWidget.GetWidget("MAINMENU_BG").GetWidget<LabelWidget>("VERSION_STRING");
|
||||
|
||||
|
||||
if (FileSystem.Exists("VERSION"))
|
||||
{
|
||||
var s = FileSystem.Open("VERSION");
|
||||
|
||||
@@ -16,75 +16,75 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
public class MapChooserDelegate : IWidgetDelegate
|
||||
{
|
||||
MapStub Map = null;
|
||||
public MapChooserDelegate()
|
||||
{
|
||||
var r = Chrome.rootWidget;
|
||||
var bg = r.GetWidget("MAP_CHOOSER");
|
||||
bg.SpecialOneArg = (map) => RefreshMapList(map);
|
||||
var ml = bg.GetWidget<ListBoxWidget>("MAP_LIST");
|
||||
|
||||
bg.GetWidget<MapPreviewWidget>("MAPCHOOSER_MAP_PREVIEW").Map = () => {return Map;};
|
||||
bg.GetWidget<LabelWidget>("CURMAP_TITLE").GetText = () => {return Map.Title;};
|
||||
bg.GetWidget<LabelWidget>("CURMAP_SIZE").GetText = () => {return "{0}x{1}".F(Map.Width, Map.Height);};
|
||||
bg.GetWidget<LabelWidget>("CURMAP_THEATER").GetText = () => {return Rules.TileSets[Map.Tileset].Name;};
|
||||
bg.GetWidget<LabelWidget>("CURMAP_PLAYERS").GetText = () => {return Map.PlayerCount.ToString();};
|
||||
|
||||
bg.GetWidget("BUTTON_OK").OnMouseUp = mi => {
|
||||
Game.IssueOrder(Order.Command("map " + Map.Uid));
|
||||
r.CloseWindow();
|
||||
return true;
|
||||
};
|
||||
|
||||
bg.GetWidget("BUTTON_CANCEL").OnMouseUp = mi => {
|
||||
r.CloseWindow();
|
||||
return true;
|
||||
};
|
||||
|
||||
var itemTemplate = ml.GetWidget<LabelWidget>("MAP_TEMPLATE");
|
||||
int offset = itemTemplate.Bounds.Y;
|
||||
foreach (var kv in Game.AvailableMaps)
|
||||
{
|
||||
var map = kv.Value;
|
||||
if (!map.Selectable)
|
||||
continue;
|
||||
|
||||
var template = itemTemplate.Clone() as LabelWidget;
|
||||
template.Id = "MAP_{0}".F(map.Uid);
|
||||
template.GetText = () => " "+map.Title;
|
||||
template.GetBackground = () => ((Map == map) ? "dialog2" : null);
|
||||
template.OnMouseDown = mi => {Map = map; return true;};
|
||||
template.Parent = ml;
|
||||
|
||||
template.Bounds = new Rectangle(template.Bounds.X, offset, template.Bounds.Width, template.Bounds.Height);
|
||||
template.IsVisible = () => true;
|
||||
ml.AddChild(template);
|
||||
|
||||
offset += template.Bounds.Height;
|
||||
ml.ContentHeight += template.Bounds.Height;
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshMapList(object uidobj)
|
||||
{
|
||||
// Set the default selected map
|
||||
var uid = uidobj as string;
|
||||
if (uid != null)
|
||||
Map = Game.AvailableMaps[ uid ];
|
||||
else
|
||||
Map = Game.AvailableMaps.FirstOrDefault().Value;
|
||||
}
|
||||
}
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
public class MapChooserDelegate : IWidgetDelegate
|
||||
{
|
||||
MapStub Map = null;
|
||||
public MapChooserDelegate()
|
||||
{
|
||||
var r = Chrome.rootWidget;
|
||||
var bg = r.GetWidget("MAP_CHOOSER");
|
||||
bg.SpecialOneArg = (map) => RefreshMapList(map);
|
||||
var ml = bg.GetWidget<ListBoxWidget>("MAP_LIST");
|
||||
|
||||
bg.GetWidget<MapPreviewWidget>("MAPCHOOSER_MAP_PREVIEW").Map = () => Map;
|
||||
bg.GetWidget<LabelWidget>("CURMAP_TITLE").GetText = () => Map.Title;
|
||||
bg.GetWidget<LabelWidget>("CURMAP_SIZE").GetText = () => "{0}x{1}".F(Map.Width, Map.Height);
|
||||
bg.GetWidget<LabelWidget>("CURMAP_THEATER").GetText = () => Rules.TileSets[Map.Tileset].Name;
|
||||
bg.GetWidget<LabelWidget>("CURMAP_PLAYERS").GetText = () => Map.PlayerCount.ToString();
|
||||
|
||||
bg.GetWidget("BUTTON_OK").OnMouseUp = mi =>
|
||||
{
|
||||
Game.IssueOrder(Order.Command("map " + Map.Uid));
|
||||
r.CloseWindow();
|
||||
return true;
|
||||
};
|
||||
|
||||
bg.GetWidget("BUTTON_CANCEL").OnMouseUp = mi =>
|
||||
{
|
||||
r.CloseWindow();
|
||||
return true;
|
||||
};
|
||||
|
||||
var itemTemplate = ml.GetWidget<LabelWidget>("MAP_TEMPLATE");
|
||||
int offset = itemTemplate.Bounds.Y;
|
||||
foreach (var kv in Game.AvailableMaps)
|
||||
{
|
||||
var map = kv.Value;
|
||||
if (!map.Selectable)
|
||||
continue;
|
||||
|
||||
var template = itemTemplate.Clone() as LabelWidget;
|
||||
template.Id = "MAP_{0}".F(map.Uid);
|
||||
template.GetText = () => " " + map.Title;
|
||||
template.GetBackground = () => ((Map == map) ? "dialog2" : null);
|
||||
template.OnMouseDown = mi => { Map = map; return true; };
|
||||
template.Parent = ml;
|
||||
|
||||
template.Bounds = new Rectangle(template.Bounds.X, offset, template.Bounds.Width, template.Bounds.Height);
|
||||
template.IsVisible = () => true;
|
||||
ml.AddChild(template);
|
||||
|
||||
offset += template.Bounds.Height;
|
||||
ml.ContentHeight += template.Bounds.Height;
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshMapList(object uidobj)
|
||||
{
|
||||
// Set the default selected map
|
||||
var uid = uidobj as string;
|
||||
if (uid != null)
|
||||
Map = Game.AvailableMaps[uid];
|
||||
else
|
||||
Map = Game.AvailableMaps.FirstOrDefault().Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,69 +17,80 @@
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
using System;
|
||||
|
||||
namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
public class MusicPlayerDelegate : IWidgetDelegate
|
||||
{
|
||||
public MusicPlayerDelegate()
|
||||
{
|
||||
var bg = Chrome.rootWidget.GetWidget("MUSIC_BG");
|
||||
bg.Visible = Game.Settings.MusicPlayer;
|
||||
|
||||
bg.GetWidget("BUTTON_PLAY").OnMouseUp = mi => {
|
||||
if (Sound.MusicStopped)
|
||||
Sound.PlayMusic(GetSong());
|
||||
Sound.MusicStopped = false;
|
||||
Sound.MusicPaused = false;
|
||||
bg.GetWidget("BUTTON_PLAY").Visible = false;
|
||||
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
||||
return true;
|
||||
};
|
||||
bg.GetWidget("BUTTON_PAUSE").OnMouseUp = mi => {
|
||||
Sound.MusicPaused = true;
|
||||
bg.GetWidget("BUTTON_PAUSE").Visible = false;
|
||||
bg.GetWidget("BUTTON_PLAY").Visible = true;
|
||||
return true;
|
||||
};
|
||||
bg.GetWidget("BUTTON_STOP").OnMouseUp = mi => {
|
||||
Sound.MusicStopped = true;
|
||||
bg.GetWidget("BUTTON_PAUSE").Visible = false;
|
||||
bg.GetWidget("BUTTON_PLAY").Visible = true;
|
||||
return true;
|
||||
};
|
||||
bg.GetWidget("BUTTON_NEXT").OnMouseUp = mi => {
|
||||
Sound.PlayMusic(GetNextSong());
|
||||
Sound.MusicStopped = false;
|
||||
Sound.MusicPaused = false;
|
||||
bg.GetWidget("BUTTON_PLAY").Visible = false;
|
||||
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
||||
return true;
|
||||
};
|
||||
bg.GetWidget("BUTTON_PREV").OnMouseUp = mi => {
|
||||
Sound.PlayMusic(GetPrevSong());
|
||||
Sound.MusicStopped = false;
|
||||
Sound.MusicPaused = false;
|
||||
bg.GetWidget("BUTTON_PLAY").Visible = false;
|
||||
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
string GetNextSong()
|
||||
{
|
||||
if (!Rules.Music.ContainsKey("allmusic")) return null;
|
||||
return Rules.Music["allmusic"].Pool.GetNext();
|
||||
}
|
||||
string GetPrevSong()
|
||||
{
|
||||
if (!Rules.Music.ContainsKey("allmusic")) return null;
|
||||
return Rules.Music["allmusic"].Pool.GetPrev();
|
||||
}
|
||||
string GetSong()
|
||||
{
|
||||
if (!Rules.Music.ContainsKey("allmusic")) return null;
|
||||
return Rules.Music["allmusic"].Pool.GetCurrent();
|
||||
}
|
||||
{
|
||||
public class MusicPlayerDelegate : IWidgetDelegate
|
||||
{
|
||||
public MusicPlayerDelegate()
|
||||
{
|
||||
var bg = Chrome.rootWidget.GetWidget("MUSIC_BG");
|
||||
bg.Visible = Game.Settings.MusicPlayer;
|
||||
|
||||
bg.GetWidget("BUTTON_PLAY").OnMouseUp = mi =>
|
||||
{
|
||||
if (Sound.MusicStopped)
|
||||
Sound.PlayMusic(GetSong());
|
||||
Sound.MusicStopped = false;
|
||||
Sound.MusicPaused = false;
|
||||
bg.GetWidget("BUTTON_PLAY").Visible = false;
|
||||
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
||||
return true;
|
||||
};
|
||||
|
||||
bg.GetWidget("BUTTON_PAUSE").OnMouseUp = mi =>
|
||||
{
|
||||
Sound.MusicPaused = true;
|
||||
bg.GetWidget("BUTTON_PAUSE").Visible = false;
|
||||
bg.GetWidget("BUTTON_PLAY").Visible = true;
|
||||
return true;
|
||||
};
|
||||
|
||||
bg.GetWidget("BUTTON_STOP").OnMouseUp = mi =>
|
||||
{
|
||||
Sound.MusicStopped = true;
|
||||
bg.GetWidget("BUTTON_PAUSE").Visible = false;
|
||||
bg.GetWidget("BUTTON_PLAY").Visible = true;
|
||||
return true;
|
||||
};
|
||||
|
||||
bg.GetWidget("BUTTON_NEXT").OnMouseUp = mi =>
|
||||
{
|
||||
Sound.PlayMusic(GetNextSong());
|
||||
Sound.MusicStopped = false;
|
||||
Sound.MusicPaused = false;
|
||||
bg.GetWidget("BUTTON_PLAY").Visible = false;
|
||||
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
||||
return true;
|
||||
};
|
||||
|
||||
bg.GetWidget("BUTTON_PREV").OnMouseUp = mi =>
|
||||
{
|
||||
Sound.PlayMusic(GetPrevSong());
|
||||
Sound.MusicStopped = false;
|
||||
Sound.MusicPaused = false;
|
||||
bg.GetWidget("BUTTON_PLAY").Visible = false;
|
||||
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
string GetNextSong()
|
||||
{
|
||||
if (!Rules.Music.ContainsKey("allmusic")) return null;
|
||||
return Rules.Music["allmusic"].Pool.GetNext();
|
||||
}
|
||||
|
||||
string GetPrevSong()
|
||||
{
|
||||
if (!Rules.Music.ContainsKey("allmusic")) return null;
|
||||
return Rules.Music["allmusic"].Pool.GetPrev();
|
||||
}
|
||||
|
||||
string GetSong()
|
||||
{
|
||||
if (!Rules.Music.ContainsKey("allmusic")) return null;
|
||||
return Rules.Music["allmusic"].Pool.GetCurrent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,31 +17,28 @@
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
using System;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Support;
|
||||
|
||||
namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
public class PerfDebugDelegate : IWidgetDelegate
|
||||
{
|
||||
public PerfDebugDelegate()
|
||||
{
|
||||
var r = Chrome.rootWidget;
|
||||
var perfRoot = r.GetWidget("PERF_BG");
|
||||
perfRoot.IsVisible = () => {return (perfRoot.Visible && Game.Settings.PerfDebug);};
|
||||
|
||||
// Perf text
|
||||
var perfText = perfRoot.GetWidget<LabelWidget>("TEXT");
|
||||
perfText.GetText = () => {
|
||||
return "Render {0} ({5}={2:F1} ms)\nTick {4} ({3:F1} ms)".F(
|
||||
Game.RenderFrame,
|
||||
Game.orderManager.FrameNumber,
|
||||
PerfHistory.items["render"].LastValue,
|
||||
PerfHistory.items["tick_time"].LastValue,
|
||||
Game.LocalTick,
|
||||
PerfHistory.items["batches"].LastValue);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
using OpenRA.Support;
|
||||
|
||||
namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
public class PerfDebugDelegate : IWidgetDelegate
|
||||
{
|
||||
public PerfDebugDelegate()
|
||||
{
|
||||
var r = Chrome.rootWidget;
|
||||
var perfRoot = r.GetWidget("PERF_BG");
|
||||
perfRoot.IsVisible = () => perfRoot.Visible && Game.Settings.PerfDebug;
|
||||
|
||||
// Perf text
|
||||
var perfText = perfRoot.GetWidget<LabelWidget>("TEXT");
|
||||
perfText.GetText = () => "Render {0} ({5}={2:F1} ms)\nTick {4} ({3:F1} ms)".F(
|
||||
Game.RenderFrame,
|
||||
Game.orderManager.FrameNumber,
|
||||
PerfHistory.items["render"].LastValue,
|
||||
PerfHistory.items["tick_time"].LastValue,
|
||||
Game.LocalTick,
|
||||
PerfHistory.items["batches"].LastValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Server;
|
||||
using OpenRA.FileFormats;
|
||||
using System;
|
||||
using OpenRA.Server;
|
||||
|
||||
namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
@@ -36,10 +35,10 @@ namespace OpenRA.Widgets.Delegates
|
||||
|
||||
public ServerBrowserDelegate()
|
||||
{
|
||||
var r = Chrome.rootWidget;
|
||||
var r = Chrome.rootWidget;
|
||||
var bg = r.GetWidget("JOINSERVER_BG");
|
||||
var dc = r.GetWidget("DIRECTCONNECT_BG");
|
||||
|
||||
|
||||
MasterServerQuery.OnComplete += games => RefreshServerList(games);
|
||||
|
||||
r.GetWidget("MAINMENU_BUTTON_JOIN").OnMouseUp = mi =>
|
||||
@@ -56,14 +55,14 @@ namespace OpenRA.Widgets.Delegates
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
bg.GetWidget("SERVER_INFO").IsVisible = () => currentServer != null;
|
||||
var preview = bg.GetWidget<MapPreviewWidget>("MAP_PREVIEW");
|
||||
preview.Map = () => CurrentMap();
|
||||
preview.IsVisible = () => CurrentMap() != null;
|
||||
|
||||
|
||||
bg.GetWidget<LabelWidget>("SERVER_IP").GetText = () => currentServer.Address;
|
||||
bg.GetWidget<LabelWidget>("SERVER_MODS").GetText = () => string.Join( ",", currentServer.Mods );
|
||||
bg.GetWidget<LabelWidget>("SERVER_MODS").GetText = () => string.Join(",", currentServer.Mods);
|
||||
bg.GetWidget<LabelWidget>("MAP_TITLE").GetText = () => (CurrentMap() != null) ? CurrentMap().Title : "Unknown";
|
||||
bg.GetWidget<LabelWidget>("MAP_PLAYERS").GetText = () =>
|
||||
{
|
||||
@@ -71,11 +70,11 @@ namespace OpenRA.Widgets.Delegates
|
||||
return "";
|
||||
string ret = currentServer.Players.ToString();
|
||||
if (CurrentMap() != null)
|
||||
ret += "/"+CurrentMap().PlayerCount.ToString();
|
||||
ret += "/" + CurrentMap().PlayerCount.ToString();
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
var sl = bg.GetWidget<ListBoxWidget>("SERVER_LIST");
|
||||
ServerTemplate = sl.GetWidget<LabelWidget>("SERVER_TEMPLATE");
|
||||
|
||||
@@ -101,20 +100,20 @@ namespace OpenRA.Widgets.Delegates
|
||||
bg.GetWidget("DIRECTCONNECT_BUTTON").OnMouseUp = mi =>
|
||||
{
|
||||
r.CloseWindow();
|
||||
|
||||
|
||||
dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text = Game.Settings.LastServer;
|
||||
r.OpenWindow("DIRECTCONNECT_BG");
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
bg.GetWidget("JOIN_BUTTON").OnMouseUp = mi =>
|
||||
{
|
||||
if (currentServer == null)
|
||||
return false;
|
||||
|
||||
|
||||
// Todo: Add an error dialog explaining why we aren't letting them join
|
||||
// Or even better, reject them server side and display the error in the connection failed dialog.
|
||||
|
||||
|
||||
// Don't bother joining a server with different mods... its only going to crash
|
||||
if (currentServer.Mods.SymmetricDifference(Game.LobbyInfo.GlobalSettings.Mods).Any())
|
||||
{
|
||||
@@ -122,56 +121,59 @@ namespace OpenRA.Widgets.Delegates
|
||||
System.Console.WriteLine("FIX THIS BUG YOU NOOB!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Prevent user joining a full server
|
||||
if (CurrentMap() != null && currentServer.Players >= CurrentMap().PlayerCount)
|
||||
{
|
||||
System.Console.WriteLine("Server is full; not connecting");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
r.CloseWindow();
|
||||
Game.JoinServer(currentServer.Address.Split(':')[0], int.Parse(currentServer.Address.Split(':')[1]));
|
||||
Game.SetGameId(currentServer.Id);
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
// Direct Connect
|
||||
dc.GetWidget("JOIN_BUTTON").OnMouseUp = mi => {
|
||||
|
||||
dc.GetWidget("JOIN_BUTTON").OnMouseUp = mi =>
|
||||
{
|
||||
|
||||
var address = dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text;
|
||||
var cpts = address.Split(':').ToArray();
|
||||
if (cpts.Length != 2)
|
||||
return true;
|
||||
|
||||
|
||||
Game.Settings.LastServer = address;
|
||||
Game.Settings.Save();
|
||||
|
||||
|
||||
r.CloseWindow();
|
||||
Game.JoinServer(cpts[0], int.Parse(cpts[1]));
|
||||
return true;
|
||||
};
|
||||
|
||||
dc.GetWidget("CANCEL_BUTTON").OnMouseUp = mi => {
|
||||
|
||||
dc.GetWidget("CANCEL_BUTTON").OnMouseUp = mi =>
|
||||
{
|
||||
r.CloseWindow();
|
||||
return r.GetWidget("MAINMENU_BUTTON_JOIN").OnMouseUp(mi);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
MapStub CurrentMap()
|
||||
{
|
||||
return (currentServer == null || !Game.AvailableMaps.ContainsKey(currentServer.Map)) ? null : Game.AvailableMaps[currentServer.Map];
|
||||
return (currentServer == null || !Game.AvailableMaps.ContainsKey(currentServer.Map))
|
||||
? null : Game.AvailableMaps[currentServer.Map];
|
||||
}
|
||||
|
||||
|
||||
void RefreshServerList(IEnumerable<GameServer> games)
|
||||
{
|
||||
var r = Chrome.rootWidget;
|
||||
var r = Chrome.rootWidget;
|
||||
var bg = r.GetWidget("JOINSERVER_BG");
|
||||
var sl = bg.GetWidget<ListBoxWidget>("SERVER_LIST");
|
||||
|
||||
sl.Children.Clear();
|
||||
currentServer = null;
|
||||
|
||||
|
||||
if (games == null)
|
||||
{
|
||||
r.GetWidget("JOINSERVER_PROGRESS_TITLE").Visible = true;
|
||||
@@ -187,26 +189,26 @@ namespace OpenRA.Widgets.Delegates
|
||||
}
|
||||
|
||||
r.GetWidget("JOINSERVER_PROGRESS_TITLE").Visible = false;
|
||||
|
||||
|
||||
int offset = ServerTemplate.Bounds.Y;
|
||||
int i = 0;
|
||||
foreach (var game in games.Where( g => g.State == 1 )) /* only "waiting for players" */
|
||||
{
|
||||
foreach (var game in games.Where(g => g.State == 1)) /* only "waiting for players" */
|
||||
{
|
||||
var template = ServerTemplate.Clone() as LabelWidget;
|
||||
template.Id = "JOIN_GAME_{0}".F(i);
|
||||
template.GetText = () => " {0} ({1})".F( /* /8 = hack */
|
||||
game.Name,
|
||||
game.Name,
|
||||
game.Address);
|
||||
template.GetBackground = () => ((currentServer == game) ? "dialog2" : null);
|
||||
template.OnMouseDown = mi => {currentServer = game; return true;};
|
||||
template.Parent = sl;
|
||||
|
||||
template.GetBackground = () => (currentServer == game) ? "dialog2" : null;
|
||||
template.OnMouseDown = mi => { currentServer = game; return true; };
|
||||
template.Parent = sl;
|
||||
|
||||
template.Bounds = new Rectangle(template.Bounds.X, offset, template.Bounds.Width, template.Bounds.Height);
|
||||
template.IsVisible = () => true;
|
||||
sl.AddChild(template);
|
||||
|
||||
|
||||
if (i == 0) currentServer = game;
|
||||
|
||||
|
||||
offset += template.Bounds.Height;
|
||||
sl.ContentHeight += template.Bounds.Height;
|
||||
i++;
|
||||
|
||||
Reference in New Issue
Block a user