This commit is contained in:
Paul Chote
2011-05-08 18:45:52 +12:00
parent 8957caeaca
commit 33b35f768e
4 changed files with 23 additions and 29 deletions

View File

@@ -30,17 +30,17 @@ namespace OpenRA.Mods.Cnc.Widgets
Dictionary<string, string> CountryNames;
string MapUid;
Map Map;
public static ColorRamp CurrentColorPreview;
// Must be set only once on game start
// TODO: This is stupid
readonly Action OnGameStart;
readonly Action onExit;
readonly OrderManager orderManager;
readonly WorldRenderer worldRenderer;
public static ColorRamp CurrentColorPreview;
static bool staticSetup;
public static CncLobbyLogic GetHandler()
{
var panel = Widget.RootWidget.GetWidget("SERVER_LOBBY");
// The panel may not be open anymore
if (panel == null)
return null;
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Cnc.Widgets
if (handler == null)
return;
handler.onGameStart();
handler.OnGameStart();
}
static void AddChatLineStub(Color c, string from, string text)
@@ -84,7 +84,6 @@ namespace OpenRA.Mods.Cnc.Widgets
handler.ConnectionStateChanged(om);
}
// Listen for connection failures
void ConnectionStateChanged(OrderManager om)
{
@@ -98,7 +97,7 @@ namespace OpenRA.Mods.Cnc.Widgets
Game.OpenWindow("SERVER_LOBBY", new Dictionary<string, object>()
{
{ "onExit", onExit },
{ "onStart", onGameStart }
{ "onStart", OnGameStart }
});
});
@@ -118,11 +117,6 @@ namespace OpenRA.Mods.Cnc.Widgets
}
}
readonly Action onGameStart;
readonly Action onExit;
readonly OrderManager orderManager;
readonly WorldRenderer worldRenderer;
[ObjectCreator.UseCtor]
internal CncLobbyLogic([ObjectCreator.Param( "widget" )] Widget lobby,
[ObjectCreator.Param] OrderManager orderManager,
@@ -132,7 +126,7 @@ namespace OpenRA.Mods.Cnc.Widgets
{
this.orderManager = orderManager;
this.worldRenderer = worldRenderer;
this.onGameStart = onStart;
this.OnGameStart = onStart;
this.onExit = onExit;
if (!staticSetup)

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Cnc.Widgets
{
public class CncMapChooserLogic : IWidgetDelegate
{
Map map = null;
Map map;
Widget scrollpanel;
Widget itemTemplate;

View File

@@ -22,21 +22,21 @@ namespace OpenRA.Mods.Cnc.Widgets
{
public class CncReplayBrowserLogic : IWidgetDelegate
{
Widget widget;
Widget panel;
[ObjectCreator.UseCtor]
public CncReplayBrowserLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] Action onExit,
[ObjectCreator.Param] Action onStart)
{
this.widget = widget;
panel = widget.GetWidget("REPLAYBROWSER_PANEL");
widget.GetWidget<CncMenuButtonWidget>("CANCEL_BUTTON").OnClick = onExit;
panel.GetWidget<CncMenuButtonWidget>("CANCEL_BUTTON").OnClick = onExit;
var rl = widget.GetWidget<ScrollPanelWidget>("REPLAY_LIST");
var rl = panel.GetWidget<ScrollPanelWidget>("REPLAY_LIST");
var replayDir = Path.Combine(Platform.SupportDir, "Replays");
var template = widget.GetWidget("REPLAY_TEMPLATE");
var template = panel.GetWidget("REPLAY_TEMPLATE");
CurrentReplay = null;
rl.RemoveChildren();
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Cnc.Widgets
CurrentReplay = files.FirstOrDefault();
}
var watch = widget.GetWidget<CncMenuButtonWidget>("WATCH_BUTTON");
var watch = panel.GetWidget<CncMenuButtonWidget>("WATCH_BUTTON");
watch.IsDisabled = () => currentReplay == null || currentMap == null;
watch.OnClick = () =>
{
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Cnc.Widgets
}
};
widget.GetWidget("REPLAY_INFO").IsVisible = () => currentReplay != null;
panel.GetWidget("REPLAY_INFO").IsVisible = () => currentReplay != null;
}
string currentReplay = null;
@@ -78,14 +78,14 @@ namespace OpenRA.Mods.Cnc.Widgets
var summary = new ReplaySummary(currentReplay);
currentMap = summary.Map();
widget.GetWidget<LabelWidget>("DURATION").GetText =
panel.GetWidget<LabelWidget>("DURATION").GetText =
() => WidgetUtils.FormatTime(summary.Duration * 3 /* todo: 3:1 ratio isnt always true. */);
widget.GetWidget<MapPreviewWidget>("MAP_PREVIEW").Map = () => currentMap;
widget.GetWidget<LabelWidget>("MAP_TITLE").GetText =
panel.GetWidget<MapPreviewWidget>("MAP_PREVIEW").Map = () => currentMap;
panel.GetWidget<LabelWidget>("MAP_TITLE").GetText =
() => currentMap != null ? currentMap.Title : "(Unknown Map)";
var players = summary.LobbyInfo.Slots.Count(s => summary.LobbyInfo.ClientInSlot(s) != null || s.Bot != null);
widget.GetWidget<LabelWidget>("PLAYERS").GetText = () => players.ToString();
panel.GetWidget<LabelWidget>("PLAYERS").GetText = () => players.ToString();
}
catch(Exception e)
{

View File

@@ -23,8 +23,8 @@ namespace OpenRA.Mods.Cnc.Widgets
{
// Prevent repeated additions of RefreshServerList to the master server
static bool masterServerSetup;
GameServer currentServer = null;
GameServer currentServer;
Widget serverTemplate;
enum SearchStatus