@@ -344,9 +344,10 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
if (orderManager.world != null)
|
if (orderManager.world != null)
|
||||||
orderManager.world.traitDict.PrintReport();
|
orderManager.world.traitDict.PrintReport();
|
||||||
|
|
||||||
|
orderManager.Dispose();
|
||||||
CloseServer();
|
CloseServer();
|
||||||
JoinLocal();
|
JoinLocal();
|
||||||
orderManager.Dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CloseServer()
|
public static void CloseServer()
|
||||||
|
|||||||
@@ -202,7 +202,10 @@ namespace OpenRA.Network
|
|||||||
if (socket != null)
|
if (socket != null)
|
||||||
socket.Client.Close();
|
socket.Client.Close();
|
||||||
using( new PerfSample( "Thread.Join" ))
|
using( new PerfSample( "Thread.Join" ))
|
||||||
t.Join();
|
{
|
||||||
|
if (!t.Join(1000))
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~NetworkConnection() { Dispose(); }
|
~NetworkConnection() { Dispose(); }
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ namespace OpenRA.Network
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
writer.Close();
|
writer.Close();
|
||||||
|
inner.Dispose();
|
||||||
disposed = true;
|
disposed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
|
||||||
using OpenRA.Graphics;
|
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
@@ -75,20 +75,14 @@
|
|||||||
<Compile Include="Widgets\LogicTickerWidget.cs" />
|
<Compile Include="Widgets\LogicTickerWidget.cs" />
|
||||||
<Compile Include="Widgets\Logic\ButtonTooltipLogic.cs" />
|
<Compile Include="Widgets\Logic\ButtonTooltipLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\CncCheatsLogic.cs" />
|
<Compile Include="Widgets\Logic\CncCheatsLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\CncConnectionLogic.cs" />
|
|
||||||
<Compile Include="Widgets\Logic\CncConquestObjectivesLogic.cs" />
|
<Compile Include="Widgets\Logic\CncConquestObjectivesLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\CncIngameChromeLogic.cs" />
|
<Compile Include="Widgets\Logic\CncIngameChromeLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\CncIngameMenuLogic.cs" />
|
<Compile Include="Widgets\Logic\CncIngameMenuLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\CncInstallFromCDLogic.cs" />
|
<Compile Include="Widgets\Logic\CncInstallFromCDLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\CncInstallLogic.cs" />
|
<Compile Include="Widgets\Logic\CncInstallLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\CncLobbyLogic.cs" />
|
|
||||||
<Compile Include="Widgets\Logic\CncMenuLogic.cs" />
|
<Compile Include="Widgets\Logic\CncMenuLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\CncModBrowserLogic.cs" />
|
|
||||||
<Compile Include="Widgets\Logic\CncMusicPlayerLogic.cs" />
|
<Compile Include="Widgets\Logic\CncMusicPlayerLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\CncPerfDebugLogic.cs" />
|
<Compile Include="Widgets\Logic\CncPerfDebugLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\CncReplayBrowserLogic.cs" />
|
|
||||||
<Compile Include="Widgets\Logic\CncServerBrowserLogic.cs" />
|
|
||||||
<Compile Include="Widgets\Logic\CncServerCreationLogic.cs" />
|
|
||||||
<Compile Include="Widgets\Logic\CncSettingsLogic.cs" />
|
<Compile Include="Widgets\Logic\CncSettingsLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\ProductionTooltipLogic.cs" />
|
<Compile Include="Widgets\Logic\ProductionTooltipLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\SimpleTooltipLogic.cs" />
|
<Compile Include="Widgets\Logic\SimpleTooltipLogic.cs" />
|
||||||
@@ -103,7 +97,6 @@
|
|||||||
<Compile Include="Widgets\TooltipContainerWidget.cs" />
|
<Compile Include="Widgets\TooltipContainerWidget.cs" />
|
||||||
<Compile Include="WithFire.cs" />
|
<Compile Include="WithFire.cs" />
|
||||||
<Compile Include="WithRoof.cs" />
|
<Compile Include="WithRoof.cs" />
|
||||||
<Compile Include="Widgets\Logic\CncDirectConnectLogic.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||||
|
|||||||
@@ -1,20 +1,10 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
*
|
* available to you under the terms of the GNU General Public License
|
||||||
* OpenRA is free software: you can redistribute it and/or modify
|
* as published by the Free Software Foundation. For more information,
|
||||||
* it under the terms of the GNU General Public License as published by
|
* see COPYING.
|
||||||
* 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
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
|
||||||
* available to you under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation. For more information,
|
|
||||||
* see COPYING.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using OpenRA.Widgets;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|
||||||
{
|
|
||||||
public class CncDirectConnectLogic
|
|
||||||
{
|
|
||||||
[ObjectCreator.UseCtor]
|
|
||||||
public CncDirectConnectLogic(Widget widget, Action onExit, Action openLobby)
|
|
||||||
{
|
|
||||||
var panel = widget.GetWidget("DIRECTCONNECT_PANEL");
|
|
||||||
var ipField = panel.GetWidget<TextFieldWidget>("IP");
|
|
||||||
var portField = panel.GetWidget<TextFieldWidget>("PORT");
|
|
||||||
|
|
||||||
var last = Game.Settings.Player.LastServer.Split(':');
|
|
||||||
ipField.Text = last.Length > 1 ? last[0] : "localhost";
|
|
||||||
portField.Text = last.Length > 2 ? last[1] : "1234";
|
|
||||||
|
|
||||||
panel.GetWidget<ButtonWidget>("JOIN_BUTTON").OnClick = () =>
|
|
||||||
{
|
|
||||||
var port = Exts.WithDefault(1234, () => int.Parse(portField.Text));
|
|
||||||
|
|
||||||
Game.Settings.Player.LastServer = "{0}:{1}".F(ipField.Text, port);
|
|
||||||
Game.Settings.Save();
|
|
||||||
|
|
||||||
Widget.CloseWindow();
|
|
||||||
CncConnectionLogic.Connect(ipField.Text, port, openLobby, onExit);
|
|
||||||
};
|
|
||||||
|
|
||||||
panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -102,7 +102,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
retryButton.IsDisabled = () => false;
|
retryButton.IsDisabled = () => false;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
var t = new Thread( _ =>
|
new Thread( _ =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -122,8 +122,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
{
|
{
|
||||||
onError("Installation failed");
|
onError("Installation failed");
|
||||||
}
|
}
|
||||||
}) { IsBackground = true };
|
}) { IsBackground = true }.Start();
|
||||||
t.Start();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,446 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
|
||||||
* available to you under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation. For more information,
|
|
||||||
* see COPYING.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using OpenRA.Mods.RA;
|
|
||||||
using OpenRA.Mods.RA.Widgets.Logic;
|
|
||||||
using OpenRA.Network;
|
|
||||||
using OpenRA.Traits;
|
|
||||||
using OpenRA.Widgets;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|
||||||
{
|
|
||||||
public class CncLobbyLogic
|
|
||||||
{
|
|
||||||
Widget EditablePlayerTemplate, NonEditablePlayerTemplate, EmptySlotTemplate,
|
|
||||||
EditableSpectatorTemplate, NonEditableSpectatorTemplate, NewSpectatorTemplate;
|
|
||||||
ScrollPanelWidget chatPanel;
|
|
||||||
Widget chatTemplate;
|
|
||||||
|
|
||||||
ScrollPanelWidget Players;
|
|
||||||
Dictionary<string, string> CountryNames;
|
|
||||||
string MapUid;
|
|
||||||
Map Map;
|
|
||||||
|
|
||||||
ColorPickerPaletteModifier PlayerPalettePreview;
|
|
||||||
|
|
||||||
readonly Action OnGameStart;
|
|
||||||
readonly Action onExit;
|
|
||||||
readonly OrderManager orderManager;
|
|
||||||
|
|
||||||
// Listen for connection failures
|
|
||||||
void ConnectionStateChanged(OrderManager om)
|
|
||||||
{
|
|
||||||
if (om.Connection.ConnectionState == ConnectionState.NotConnected)
|
|
||||||
{
|
|
||||||
// Show connection failed dialog
|
|
||||||
CloseWindow();
|
|
||||||
|
|
||||||
Action onConnect = () =>
|
|
||||||
{
|
|
||||||
Game.OpenWindow("SERVER_LOBBY", new WidgetArgs()
|
|
||||||
{
|
|
||||||
{ "onExit", onExit },
|
|
||||||
{ "onStart", OnGameStart },
|
|
||||||
{ "addBots", false }
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
Action onRetry = () =>
|
|
||||||
{
|
|
||||||
CloseWindow();
|
|
||||||
CncConnectionLogic.Connect(om.Host, om.Port, onConnect, onExit);
|
|
||||||
};
|
|
||||||
|
|
||||||
Widget.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs()
|
|
||||||
{
|
|
||||||
{ "onAbort", onExit },
|
|
||||||
{ "onRetry", onRetry },
|
|
||||||
{ "host", om.Host },
|
|
||||||
{ "port", om.Port }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CloseWindow()
|
|
||||||
{
|
|
||||||
Game.LobbyInfoChanged -= UpdateCurrentMap;
|
|
||||||
Game.LobbyInfoChanged -= UpdatePlayerList;
|
|
||||||
Game.BeforeGameStart -= OnGameStart;
|
|
||||||
Game.AddChatLine -= AddChatLine;
|
|
||||||
Game.ConnectionStateChanged -= ConnectionStateChanged;
|
|
||||||
|
|
||||||
Widget.CloseWindow();
|
|
||||||
}
|
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
|
||||||
internal CncLobbyLogic(Widget widget, World world, OrderManager orderManager,
|
|
||||||
Action onExit, Action onStart, bool addBots)
|
|
||||||
{
|
|
||||||
var lobby = widget;
|
|
||||||
this.orderManager = orderManager;
|
|
||||||
this.OnGameStart = () => { CloseWindow(); onStart(); };
|
|
||||||
this.onExit = onExit;
|
|
||||||
|
|
||||||
Game.LobbyInfoChanged += UpdateCurrentMap;
|
|
||||||
Game.LobbyInfoChanged += UpdatePlayerList;
|
|
||||||
Game.BeforeGameStart += OnGameStart;
|
|
||||||
Game.AddChatLine += AddChatLine;
|
|
||||||
Game.ConnectionStateChanged += ConnectionStateChanged;
|
|
||||||
|
|
||||||
UpdateCurrentMap();
|
|
||||||
PlayerPalettePreview = world.WorldActor.Trait<ColorPickerPaletteModifier>();
|
|
||||||
PlayerPalettePreview.Ramp = Game.Settings.Player.ColorRamp;
|
|
||||||
Players = lobby.GetWidget<ScrollPanelWidget>("PLAYERS");
|
|
||||||
EditablePlayerTemplate = Players.GetWidget("TEMPLATE_EDITABLE_PLAYER");
|
|
||||||
NonEditablePlayerTemplate = Players.GetWidget("TEMPLATE_NONEDITABLE_PLAYER");
|
|
||||||
EmptySlotTemplate = Players.GetWidget("TEMPLATE_EMPTY");
|
|
||||||
EditableSpectatorTemplate = Players.GetWidget("TEMPLATE_EDITABLE_SPECTATOR");
|
|
||||||
NonEditableSpectatorTemplate = Players.GetWidget("TEMPLATE_NONEDITABLE_SPECTATOR");
|
|
||||||
NewSpectatorTemplate = Players.GetWidget("TEMPLATE_NEW_SPECTATOR");
|
|
||||||
|
|
||||||
var mapPreview = lobby.GetWidget<MapPreviewWidget>("MAP_PREVIEW");
|
|
||||||
mapPreview.IsVisible = () => Map != null;
|
|
||||||
mapPreview.Map = () => Map;
|
|
||||||
mapPreview.OnMouseDown = mi => LobbyUtils.SelectSpawnPoint( orderManager, mapPreview, Map, mi );
|
|
||||||
|
|
||||||
var mapTitle = lobby.GetWidget<LabelWidget>("MAP_TITLE");
|
|
||||||
mapTitle.IsVisible = () => Map != null;
|
|
||||||
mapTitle.GetText = () => Map.Title;
|
|
||||||
|
|
||||||
mapPreview.SpawnColors = () => LobbyUtils.GetSpawnColors( orderManager, Map );
|
|
||||||
|
|
||||||
CountryNames = Rules.Info["world"].Traits.WithInterface<CountryInfo>()
|
|
||||||
.Where(c => c.Selectable)
|
|
||||||
.ToDictionary(a => a.Race, a => a.Name);
|
|
||||||
CountryNames.Add("random", "Any");
|
|
||||||
|
|
||||||
var mapButton = lobby.GetWidget<ButtonWidget>("CHANGEMAP_BUTTON");
|
|
||||||
mapButton.OnClick = () =>
|
|
||||||
{
|
|
||||||
var onSelect = new Action<Map>(m =>
|
|
||||||
{
|
|
||||||
orderManager.IssueOrder(Order.Command("map " + m.Uid));
|
|
||||||
Game.Settings.Server.Map = m.Uid;
|
|
||||||
Game.Settings.Save();
|
|
||||||
});
|
|
||||||
|
|
||||||
Widget.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs()
|
|
||||||
{
|
|
||||||
{ "initialMap", Map.Uid },
|
|
||||||
{ "onExit", () => {} },
|
|
||||||
{ "onSelect", onSelect }
|
|
||||||
});
|
|
||||||
};
|
|
||||||
mapButton.IsVisible = () => mapButton.Visible && Game.IsHost;
|
|
||||||
|
|
||||||
var disconnectButton = lobby.GetWidget<ButtonWidget>("DISCONNECT_BUTTON");
|
|
||||||
disconnectButton.OnClick = () => { CloseWindow(); onExit(); };
|
|
||||||
|
|
||||||
var gameStarting = false;
|
|
||||||
|
|
||||||
var allowCheats = lobby.GetWidget<CheckboxWidget>("ALLOWCHEATS_CHECKBOX");
|
|
||||||
allowCheats.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllowCheats;
|
|
||||||
allowCheats.IsDisabled = () => !Game.IsHost || gameStarting || orderManager.LocalClient == null
|
|
||||||
|| orderManager.LocalClient.IsReady;
|
|
||||||
allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command(
|
|
||||||
"allowcheats {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowCheats)));
|
|
||||||
|
|
||||||
var startGameButton = lobby.GetWidget<ButtonWidget>("START_GAME_BUTTON");
|
|
||||||
startGameButton.IsVisible = () => Game.IsHost;
|
|
||||||
startGameButton.IsDisabled = () => gameStarting;
|
|
||||||
startGameButton.OnClick = () =>
|
|
||||||
{
|
|
||||||
gameStarting = true;
|
|
||||||
orderManager.IssueOrder(Order.Command("startgame"));
|
|
||||||
};
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
orderManager.IssueOrder(Order.Chat(teamChat, chatTextField.Text));
|
|
||||||
chatTextField.Text = "";
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
chatTextField.OnTabKey = () =>
|
|
||||||
{
|
|
||||||
teamChat ^= true;
|
|
||||||
chatLabel.Text = (teamChat) ? "Team:" : "Chat:";
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
chatPanel = lobby.GetWidget<ScrollPanelWidget>("CHAT_DISPLAY");
|
|
||||||
chatTemplate = chatPanel.GetWidget("CHAT_TEMPLATE");
|
|
||||||
chatPanel.RemoveChildren();
|
|
||||||
|
|
||||||
var musicButton = lobby.GetWidget<ButtonWidget>("MUSIC_BUTTON");
|
|
||||||
if (musicButton != null)
|
|
||||||
musicButton.OnClick = () => Widget.OpenWindow("MUSIC_PANEL", new WidgetArgs
|
|
||||||
{ { "onExit", () => {} } });
|
|
||||||
|
|
||||||
// Add a bot on the first lobbyinfo update
|
|
||||||
if (addBots)
|
|
||||||
Game.LobbyInfoChanged += WidgetUtils.Once(() =>
|
|
||||||
{
|
|
||||||
var slot = orderManager.LobbyInfo.FirstEmptySlot();
|
|
||||||
var bot = Rules.Info["player"].Traits.WithInterface<IBotInfo>().Select(t => t.Name).FirstOrDefault();
|
|
||||||
if (slot != null && bot != null)
|
|
||||||
orderManager.IssueOrder(Order.Command("slot_bot {0} {1}".F(slot, bot)));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddChatLine(Color c, string from, string text)
|
|
||||||
{
|
|
||||||
var template = chatTemplate.Clone();
|
|
||||||
var nameLabel = template.GetWidget<LabelWidget>("NAME");
|
|
||||||
var timeLabel = template.GetWidget<LabelWidget>("TIME");
|
|
||||||
var textLabel = template.GetWidget<LabelWidget>("TEXT");
|
|
||||||
|
|
||||||
var name = from + ":";
|
|
||||||
var font = Game.Renderer.Fonts[nameLabel.Font];
|
|
||||||
var nameSize = font.Measure(from);
|
|
||||||
|
|
||||||
var time = DateTime.Now;
|
|
||||||
timeLabel.GetText = () => "{0:D2}:{1:D2}".F(time.Hour, time.Minute);
|
|
||||||
|
|
||||||
nameLabel.GetColor = () => c;
|
|
||||||
nameLabel.GetText = () => name;
|
|
||||||
nameLabel.Bounds.Width = nameSize.X;
|
|
||||||
textLabel.Bounds.X += nameSize.X;
|
|
||||||
textLabel.Bounds.Width -= nameSize.X;
|
|
||||||
|
|
||||||
// Hack around our hacky wordwrap behavior: need to resize the widget to fit the text
|
|
||||||
text = WidgetUtils.WrapText(text, textLabel.Bounds.Width, font);
|
|
||||||
textLabel.GetText = () => text;
|
|
||||||
var dh = font.Measure(text).Y - textLabel.Bounds.Height;
|
|
||||||
if (dh > 0)
|
|
||||||
{
|
|
||||||
textLabel.Bounds.Height += dh;
|
|
||||||
template.Bounds.Height += dh;
|
|
||||||
}
|
|
||||||
|
|
||||||
chatPanel.AddChild(template);
|
|
||||||
chatPanel.ScrollToBottom();
|
|
||||||
Sound.Play("scold1.aud");
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateCurrentMap()
|
|
||||||
{
|
|
||||||
if (MapUid == orderManager.LobbyInfo.GlobalSettings.Map) return;
|
|
||||||
MapUid = orderManager.LobbyInfo.GlobalSettings.Map;
|
|
||||||
Map = new Map(Game.modData.AvailableMaps[MapUid].Path);
|
|
||||||
|
|
||||||
var title = Widget.RootWidget.GetWidget<LabelWidget>("TITLE");
|
|
||||||
title.Text = orderManager.LobbyInfo.GlobalSettings.ServerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
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.RemoveChildren();
|
|
||||||
|
|
||||||
foreach (var kv in orderManager.LobbyInfo.Slots)
|
|
||||||
{
|
|
||||||
var key = kv.Key;
|
|
||||||
var slot = kv.Value;
|
|
||||||
var client = orderManager.LobbyInfo.ClientInSlot(key);
|
|
||||||
Widget template;
|
|
||||||
|
|
||||||
// Empty slot
|
|
||||||
if (client == null)
|
|
||||||
{
|
|
||||||
template = EmptySlotTemplate.Clone();
|
|
||||||
Func<string> getText = () => slot.Closed ? "Closed" : "Open";
|
|
||||||
var ready = orderManager.LocalClient.IsReady;
|
|
||||||
|
|
||||||
if (Game.IsHost)
|
|
||||||
{
|
|
||||||
var name = template.GetWidget<DropDownButtonWidget>("NAME_HOST");
|
|
||||||
name.IsVisible = () => true;
|
|
||||||
name.IsDisabled = () => ready;
|
|
||||||
name.GetText = getText;
|
|
||||||
name.OnMouseDown = _ => LobbyUtils.ShowSlotDropDown(name, slot, client, orderManager);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var name = template.GetWidget<LabelWidget>("NAME");
|
|
||||||
name.IsVisible = () => true;
|
|
||||||
name.GetText = getText;
|
|
||||||
}
|
|
||||||
|
|
||||||
var join = template.GetWidget<ButtonWidget>("JOIN");
|
|
||||||
join.IsVisible = () => !slot.Closed;
|
|
||||||
join.IsDisabled = () => ready;
|
|
||||||
join.OnClick = () => orderManager.IssueOrder(Order.Command("slot " + key));
|
|
||||||
}
|
|
||||||
// Editable player in slot
|
|
||||||
else if ((client.Index == orderManager.LocalClient.Index) ||
|
|
||||||
(client.Bot != null && Game.IsHost))
|
|
||||||
{
|
|
||||||
template = EditablePlayerTemplate.Clone();
|
|
||||||
var botReady = client.Bot != null && Game.IsHost && orderManager.LocalClient.IsReady;
|
|
||||||
var ready = botReady || client.IsReady;
|
|
||||||
|
|
||||||
if (client.Bot != null)
|
|
||||||
{
|
|
||||||
var name = template.GetWidget<DropDownButtonWidget>("BOT_DROPDOWN");
|
|
||||||
name.IsVisible = () => true;
|
|
||||||
name.IsDisabled = () => ready;
|
|
||||||
name.GetText = () => client.Name;
|
|
||||||
name.OnMouseDown = _ => LobbyUtils.ShowSlotDropDown(name, slot, client, orderManager);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var name = template.GetWidget<TextFieldWidget>("NAME");
|
|
||||||
name.IsVisible = () => true;
|
|
||||||
name.IsDisabled = () => ready;
|
|
||||||
LobbyUtils.SetupNameWidget(orderManager, client, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
var color = template.GetWidget<DropDownButtonWidget>("COLOR");
|
|
||||||
color.IsDisabled = () => slot.LockColor || ready;
|
|
||||||
color.OnMouseDown = _ => LobbyUtils.ShowColorDropDown(color, client, orderManager, PlayerPalettePreview);
|
|
||||||
|
|
||||||
var colorBlock = color.GetWidget<ColorBlockWidget>("COLORBLOCK");
|
|
||||||
colorBlock.GetColor = () => client.ColorRamp.GetColor(0);
|
|
||||||
|
|
||||||
var faction = template.GetWidget<DropDownButtonWidget>("FACTION");
|
|
||||||
faction.IsDisabled = () => slot.LockRace || ready;
|
|
||||||
faction.OnMouseDown = _ => LobbyUtils.ShowRaceDropDown(faction, client, orderManager, CountryNames);
|
|
||||||
|
|
||||||
var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME");
|
|
||||||
factionname.GetText = () => CountryNames[client.Country];
|
|
||||||
var factionflag = faction.GetWidget<ImageWidget>("FACTIONFLAG");
|
|
||||||
factionflag.GetImageName = () => client.Country;
|
|
||||||
factionflag.GetImageCollection = () => "flags";
|
|
||||||
|
|
||||||
var team = template.GetWidget<DropDownButtonWidget>("TEAM");
|
|
||||||
team.IsDisabled = () => slot.LockTeam || ready;
|
|
||||||
team.OnMouseDown = _ => LobbyUtils.ShowTeamDropDown(team, client, orderManager, Map);
|
|
||||||
team.GetText = () => (client.Team == 0) ? "-" : client.Team.ToString();
|
|
||||||
|
|
||||||
if (client.Bot == null)
|
|
||||||
{
|
|
||||||
// local player
|
|
||||||
var status = template.GetWidget<CheckboxWidget>("STATUS_CHECKBOX");
|
|
||||||
status.IsChecked = () => ready;
|
|
||||||
status.IsVisible = () => true;
|
|
||||||
status.OnClick += CycleReady;
|
|
||||||
}
|
|
||||||
else // Bot
|
|
||||||
template.GetWidget<ImageWidget>("STATUS_IMAGE").IsVisible = () => true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // Non-editable player in slot
|
|
||||||
template = NonEditablePlayerTemplate.Clone();
|
|
||||||
template.GetWidget<LabelWidget>("NAME").GetText = () => client.Name;
|
|
||||||
var color = template.GetWidget<ColorBlockWidget>("COLOR");
|
|
||||||
color.GetColor = () => client.ColorRamp.GetColor(0);
|
|
||||||
|
|
||||||
var faction = template.GetWidget<LabelWidget>("FACTION");
|
|
||||||
var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME");
|
|
||||||
factionname.GetText = () => CountryNames[client.Country];
|
|
||||||
var factionflag = faction.GetWidget<ImageWidget>("FACTIONFLAG");
|
|
||||||
factionflag.GetImageName = () => client.Country;
|
|
||||||
factionflag.GetImageCollection = () => "flags";
|
|
||||||
|
|
||||||
var team = template.GetWidget<LabelWidget>("TEAM");
|
|
||||||
team.GetText = () => (client.Team == 0) ? "-" : client.Team.ToString();
|
|
||||||
|
|
||||||
template.GetWidget<ImageWidget>("STATUS_IMAGE").IsVisible = () =>
|
|
||||||
client.Bot != null || client.IsReady;
|
|
||||||
|
|
||||||
var kickButton = template.GetWidget<ButtonWidget>("KICK");
|
|
||||||
kickButton.IsVisible = () => Game.IsHost && client.Index != orderManager.LocalClient.Index;
|
|
||||||
kickButton.IsDisabled = () => orderManager.LocalClient.IsReady;
|
|
||||||
kickButton.OnClick = () => orderManager.IssueOrder(Order.Command("kick " + client.Index));
|
|
||||||
}
|
|
||||||
|
|
||||||
template.IsVisible = () => true;
|
|
||||||
Players.AddChild(template);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add spectators
|
|
||||||
foreach (var client in orderManager.LobbyInfo.Clients.Where(client => client.Slot == null))
|
|
||||||
{
|
|
||||||
Widget template;
|
|
||||||
var c = client;
|
|
||||||
var ready = c.IsReady;
|
|
||||||
|
|
||||||
// Editable spectator
|
|
||||||
if (c.Index == orderManager.LocalClient.Index)
|
|
||||||
{
|
|
||||||
template = EditableSpectatorTemplate.Clone();
|
|
||||||
var name = template.GetWidget<TextFieldWidget>("NAME");
|
|
||||||
name.IsDisabled = () => ready;
|
|
||||||
LobbyUtils.SetupNameWidget(orderManager, c, name);
|
|
||||||
|
|
||||||
var color = template.GetWidget<DropDownButtonWidget>("COLOR");
|
|
||||||
color.IsDisabled = () => ready;
|
|
||||||
color.OnMouseDown = _ => LobbyUtils.ShowColorDropDown(color, c, orderManager, PlayerPalettePreview);
|
|
||||||
|
|
||||||
var colorBlock = color.GetWidget<ColorBlockWidget>("COLORBLOCK");
|
|
||||||
colorBlock.GetColor = () => c.ColorRamp.GetColor(0);
|
|
||||||
|
|
||||||
var status = template.GetWidget<CheckboxWidget>("STATUS_CHECKBOX");
|
|
||||||
status.IsChecked = () => ready;
|
|
||||||
status.OnClick += CycleReady;
|
|
||||||
}
|
|
||||||
// Non-editable spectator
|
|
||||||
else
|
|
||||||
{
|
|
||||||
template = NonEditableSpectatorTemplate.Clone();
|
|
||||||
template.GetWidget<LabelWidget>("NAME").GetText = () => c.Name;
|
|
||||||
var color = template.GetWidget<ColorBlockWidget>("COLOR");
|
|
||||||
color.GetColor = () => c.ColorRamp.GetColor(0);
|
|
||||||
|
|
||||||
template.GetWidget<ImageWidget>("STATUS_IMAGE").IsVisible = () => c.Bot != null || c.IsReady;
|
|
||||||
|
|
||||||
var kickButton = template.GetWidget<ButtonWidget>("KICK");
|
|
||||||
kickButton.IsVisible = () => Game.IsHost && c.Index != orderManager.LocalClient.Index;
|
|
||||||
kickButton.IsDisabled = () => orderManager.LocalClient.IsReady;
|
|
||||||
kickButton.OnClick = () => orderManager.IssueOrder(Order.Command("kick " + c.Index));
|
|
||||||
}
|
|
||||||
|
|
||||||
template.IsVisible = () => true;
|
|
||||||
Players.AddChild(template);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Spectate button
|
|
||||||
if (orderManager.LocalClient.Slot != null)
|
|
||||||
{
|
|
||||||
var spec = NewSpectatorTemplate.Clone();
|
|
||||||
var btn = spec.GetWidget<ButtonWidget>("SPECTATE");
|
|
||||||
btn.OnClick = () => orderManager.IssueOrder(Order.Command("spectate"));
|
|
||||||
btn.IsDisabled = () => orderManager.LocalClient.IsReady;
|
|
||||||
spec.IsVisible = () => true;
|
|
||||||
Players.AddChild(spec);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SpawnPointAvailable(int index) { return (index == 0) || orderManager.LobbyInfo.Clients.All(c => c.SpawnPoint != index); }
|
|
||||||
|
|
||||||
void CycleReady()
|
|
||||||
{
|
|
||||||
orderManager.IssueOrder(Order.Command("ready"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using OpenRA.Mods.RA.Widgets.Logic;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||||
@@ -54,35 +55,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
multiplayerMenu.IsVisible = () => Menu == MenuType.Multiplayer;
|
multiplayerMenu.IsVisible = () => Menu == MenuType.Multiplayer;
|
||||||
|
|
||||||
multiplayerMenu.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => Menu = MenuType.Main;
|
multiplayerMenu.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => Menu = MenuType.Main;
|
||||||
multiplayerMenu.GetWidget<ButtonWidget>("JOIN_BUTTON").OnClick = () =>
|
multiplayerMenu.GetWidget<ButtonWidget>("JOIN_BUTTON").OnClick = () => OpenGamePanel("SERVERBROWSER_PANEL");
|
||||||
{
|
multiplayerMenu.GetWidget<ButtonWidget>("CREATE_BUTTON").OnClick = () => OpenGamePanel("CREATESERVER_PANEL");
|
||||||
Menu = MenuType.None;
|
multiplayerMenu.GetWidget<ButtonWidget>("DIRECTCONNECT_BUTTON").OnClick = () => OpenGamePanel("DIRECTCONNECT_PANEL");
|
||||||
Widget.OpenWindow("SERVERBROWSER_PANEL", new WidgetArgs()
|
|
||||||
{
|
|
||||||
{ "onExit", () => Menu = MenuType.Multiplayer },
|
|
||||||
{ "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer, false) }
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
multiplayerMenu.GetWidget<ButtonWidget>("CREATE_BUTTON").OnClick = () =>
|
|
||||||
{
|
|
||||||
Menu = MenuType.None;
|
|
||||||
Widget.OpenWindow("CREATESERVER_PANEL", new WidgetArgs()
|
|
||||||
{
|
|
||||||
{ "onExit", () => Menu = MenuType.Multiplayer },
|
|
||||||
{ "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer, false) }
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
multiplayerMenu.GetWidget<ButtonWidget>("DIRECTCONNECT_BUTTON").OnClick = () =>
|
|
||||||
{
|
|
||||||
Menu = MenuType.None;
|
|
||||||
Widget.OpenWindow("DIRECTCONNECT_PANEL", new WidgetArgs()
|
|
||||||
{
|
|
||||||
{ "onExit", () => Menu = MenuType.Multiplayer },
|
|
||||||
{ "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer, false) }
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Settings menu
|
// Settings menu
|
||||||
var settingsMenu = widget.GetWidget("SETTINGS_MENU");
|
var settingsMenu = widget.GetWidget("SETTINGS_MENU");
|
||||||
@@ -122,6 +97,16 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
rootMenu.GetWidget<ImageWidget>("RECBLOCK").IsVisible = () => world.FrameNumber / 25 % 2 == 0;
|
rootMenu.GetWidget<ImageWidget>("RECBLOCK").IsVisible = () => world.FrameNumber / 25 % 2 == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenGamePanel(string id)
|
||||||
|
{
|
||||||
|
Menu = MenuType.None;
|
||||||
|
Widget.OpenWindow(id, new WidgetArgs()
|
||||||
|
{
|
||||||
|
{ "onExit", () => Menu = MenuType.Multiplayer },
|
||||||
|
{ "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer, false) }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void RemoveShellmapUI()
|
void RemoveShellmapUI()
|
||||||
{
|
{
|
||||||
rootMenu.Parent.RemoveChild(rootMenu);
|
rootMenu.Parent.RemoveChild(rootMenu);
|
||||||
@@ -142,7 +127,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
{
|
{
|
||||||
var map = WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map);
|
var map = WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map);
|
||||||
|
|
||||||
CncConnectionLogic.Connect(IPAddress.Loopback.ToString(),
|
ConnectionLogic.Connect(IPAddress.Loopback.ToString(),
|
||||||
Game.CreateLocalServer(map),
|
Game.CreateLocalServer(map),
|
||||||
() => OpenLobbyPanel(MenuType.Main, true),
|
() => OpenLobbyPanel(MenuType.Main, true),
|
||||||
() => { Game.CloseServer(); Menu = MenuType.Main; });
|
() => { Game.CloseServer(); Menu = MenuType.Main; });
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
@@ -129,7 +128,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Play()
|
void Play()
|
||||||
{
|
{
|
||||||
if (currentSong == null)
|
if (currentSong == null)
|
||||||
|
|||||||
@@ -1,101 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
|
||||||
* available to you under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation. For more information,
|
|
||||||
* see COPYING.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using OpenRA.Network;
|
|
||||||
using OpenRA.Widgets;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|
||||||
{
|
|
||||||
public class CncReplayBrowserLogic
|
|
||||||
{
|
|
||||||
Widget panel;
|
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
|
||||||
public CncReplayBrowserLogic(Widget widget, Action onExit, Action onStart)
|
|
||||||
{
|
|
||||||
panel = widget.GetWidget("REPLAYBROWSER_PANEL");
|
|
||||||
|
|
||||||
panel.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); };
|
|
||||||
|
|
||||||
var rl = panel.GetWidget<ScrollPanelWidget>("REPLAY_LIST");
|
|
||||||
var replayDir = Path.Combine(Platform.SupportDir, "Replays");
|
|
||||||
|
|
||||||
var template = panel.GetWidget<ScrollItemWidget>("REPLAY_TEMPLATE");
|
|
||||||
|
|
||||||
rl.RemoveChildren();
|
|
||||||
if (Directory.Exists(replayDir))
|
|
||||||
{
|
|
||||||
var files = Directory.GetFiles(replayDir, "*.rep").Reverse();
|
|
||||||
foreach (var replayFile in files)
|
|
||||||
AddReplay(rl, replayFile, template);
|
|
||||||
|
|
||||||
SelectReplay(files.FirstOrDefault());
|
|
||||||
}
|
|
||||||
|
|
||||||
var watch = panel.GetWidget<ButtonWidget>("WATCH_BUTTON");
|
|
||||||
watch.IsDisabled = () => currentReplay == null || currentMap == null || currentReplay.Duration == 0;
|
|
||||||
watch.OnClick = () =>
|
|
||||||
{
|
|
||||||
if (currentReplay != null)
|
|
||||||
{
|
|
||||||
Game.JoinReplay(currentReplay.Filename);
|
|
||||||
Widget.CloseWindow();
|
|
||||||
onStart();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
panel.GetWidget("REPLAY_INFO").IsVisible = () => currentReplay != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Replay currentReplay;
|
|
||||||
Map currentMap;
|
|
||||||
|
|
||||||
void SelectReplay(string filename)
|
|
||||||
{
|
|
||||||
if (filename == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
currentReplay = new Replay(filename);
|
|
||||||
currentMap = currentReplay.Map();
|
|
||||||
|
|
||||||
panel.GetWidget<LabelWidget>("DURATION").GetText =
|
|
||||||
() => WidgetUtils.FormatTime(currentReplay.Duration * 3 /* todo: 3:1 ratio isnt always true. */);
|
|
||||||
panel.GetWidget<MapPreviewWidget>("MAP_PREVIEW").Map = () => currentMap;
|
|
||||||
panel.GetWidget<LabelWidget>("MAP_TITLE").GetText =
|
|
||||||
() => currentMap != null ? currentMap.Title : "(Unknown Map)";
|
|
||||||
|
|
||||||
var players = currentReplay.LobbyInfo.Slots
|
|
||||||
.Count(s => currentReplay.LobbyInfo.ClientInSlot(s.Key) != null);
|
|
||||||
panel.GetWidget<LabelWidget>("PLAYERS").GetText = () => players.ToString();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log.Write("debug", "Exception while parsing replay: {0}", e);
|
|
||||||
currentReplay = null;
|
|
||||||
currentMap = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddReplay(ScrollPanelWidget list, string filename, ScrollItemWidget template)
|
|
||||||
{
|
|
||||||
var item = ScrollItemWidget.Setup(template,
|
|
||||||
() => currentReplay != null && currentReplay.Filename == filename,
|
|
||||||
() => SelectReplay(filename));
|
|
||||||
var f = Path.GetFileName(filename);
|
|
||||||
item.GetWidget<LabelWidget>("TITLE").GetText = () => f;
|
|
||||||
list.AddChild(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,158 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
|
||||||
* available to you under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation. For more information,
|
|
||||||
* see COPYING.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using OpenRA.Mods.RA.Widgets.Logic;
|
|
||||||
using OpenRA.Network;
|
|
||||||
using OpenRA.Widgets;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|
||||||
{
|
|
||||||
public class CncServerBrowserLogic
|
|
||||||
{
|
|
||||||
GameServer currentServer;
|
|
||||||
ScrollItemWidget serverTemplate;
|
|
||||||
|
|
||||||
enum SearchStatus { Fetching, Failed, NoGames, Hidden }
|
|
||||||
SearchStatus searchStatus = SearchStatus.Fetching;
|
|
||||||
|
|
||||||
public string ProgressLabelText()
|
|
||||||
{
|
|
||||||
switch (searchStatus)
|
|
||||||
{
|
|
||||||
case SearchStatus.Fetching:
|
|
||||||
return "Fetching game list...";
|
|
||||||
case SearchStatus.Failed:
|
|
||||||
return "Failed to contact master server.";
|
|
||||||
case SearchStatus.NoGames:
|
|
||||||
return "No games found.";
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
|
||||||
public CncServerBrowserLogic(Widget widget, Action openLobby, Action onExit)
|
|
||||||
{
|
|
||||||
var panel = widget.GetWidget("SERVERBROWSER_PANEL");
|
|
||||||
var sl = panel.GetWidget<ScrollPanelWidget>("SERVER_LIST");
|
|
||||||
|
|
||||||
// Menu buttons
|
|
||||||
var refreshButton = panel.GetWidget<ButtonWidget>("REFRESH_BUTTON");
|
|
||||||
refreshButton.IsDisabled = () => searchStatus == SearchStatus.Fetching;
|
|
||||||
refreshButton.OnClick = () =>
|
|
||||||
{
|
|
||||||
searchStatus = SearchStatus.Fetching;
|
|
||||||
sl.RemoveChildren();
|
|
||||||
currentServer = null;
|
|
||||||
ServerList.Query(games => RefreshServerList(panel, games));
|
|
||||||
};
|
|
||||||
|
|
||||||
var join = panel.GetWidget<ButtonWidget>("JOIN_BUTTON");
|
|
||||||
join.IsDisabled = () => currentServer == null || !currentServer.CanJoin();
|
|
||||||
join.OnClick = () =>
|
|
||||||
{
|
|
||||||
if (currentServer == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var host = currentServer.Address.Split(':')[0];
|
|
||||||
var port = int.Parse(currentServer.Address.Split(':')[1]);
|
|
||||||
|
|
||||||
Widget.CloseWindow();
|
|
||||||
CncConnectionLogic.Connect(host, port, openLobby, onExit);
|
|
||||||
};
|
|
||||||
|
|
||||||
panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); };
|
|
||||||
|
|
||||||
// Server list
|
|
||||||
serverTemplate = sl.GetWidget<ScrollItemWidget>("SERVER_TEMPLATE");
|
|
||||||
|
|
||||||
// Display the progress label over the server list
|
|
||||||
// The text is only visible when the list is empty
|
|
||||||
var progressText = panel.GetWidget<LabelWidget>("PROGRESS_LABEL");
|
|
||||||
progressText.IsVisible = () => searchStatus != SearchStatus.Hidden;
|
|
||||||
progressText.GetText = ProgressLabelText;
|
|
||||||
|
|
||||||
// Map preview
|
|
||||||
var preview = panel.GetWidget<MapPreviewWidget>("MAP_PREVIEW");
|
|
||||||
preview.Map = () => CurrentMap();
|
|
||||||
preview.IsVisible = () => CurrentMap() != null;
|
|
||||||
|
|
||||||
// Server info
|
|
||||||
var infoPanel = panel.GetWidget("SERVER_INFO");
|
|
||||||
infoPanel.IsVisible = () => currentServer != null;
|
|
||||||
infoPanel.GetWidget<LabelWidget>("SERVER_IP").GetText = () => currentServer.Address;
|
|
||||||
infoPanel.GetWidget<LabelWidget>("SERVER_MODS").GetText = () => ServerBrowserLogic.GenerateModsLabel(currentServer);
|
|
||||||
infoPanel.GetWidget<LabelWidget>("MAP_TITLE").GetText = () => (CurrentMap() != null) ? CurrentMap().Title : "Unknown";
|
|
||||||
infoPanel.GetWidget<LabelWidget>("MAP_PLAYERS").GetText = () => GetPlayersLabel(currentServer);
|
|
||||||
|
|
||||||
ServerList.Query(games => RefreshServerList(panel, games));
|
|
||||||
}
|
|
||||||
|
|
||||||
string GetPlayersLabel(GameServer game)
|
|
||||||
{
|
|
||||||
if (game == null)
|
|
||||||
return "";
|
|
||||||
|
|
||||||
var map = Game.modData.FindMapByUid(game.Map);
|
|
||||||
return map == null ? "{0}".F(currentServer.Players) : "{0} / {1}".F(currentServer.Players, map.PlayerCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map CurrentMap()
|
|
||||||
{
|
|
||||||
return (currentServer == null) ? null : Game.modData.FindMapByUid(currentServer.Map);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RefreshServerList(Widget panel, IEnumerable<GameServer> games)
|
|
||||||
{
|
|
||||||
var sl = panel.GetWidget<ScrollPanelWidget>("SERVER_LIST");
|
|
||||||
|
|
||||||
sl.RemoveChildren();
|
|
||||||
currentServer = null;
|
|
||||||
|
|
||||||
if (games == null)
|
|
||||||
{
|
|
||||||
searchStatus = SearchStatus.Failed;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var gamesWaiting = games.Where(g => g.CanJoin());
|
|
||||||
|
|
||||||
if (gamesWaiting.Count() == 0)
|
|
||||||
{
|
|
||||||
searchStatus = SearchStatus.NoGames;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
searchStatus = SearchStatus.Hidden;
|
|
||||||
currentServer = gamesWaiting.FirstOrDefault();
|
|
||||||
|
|
||||||
foreach (var loop in gamesWaiting)
|
|
||||||
{
|
|
||||||
var game = loop;
|
|
||||||
|
|
||||||
var item = ScrollItemWidget.Setup(serverTemplate, () => currentServer == game, () => currentServer = game);
|
|
||||||
item.GetWidget<LabelWidget>("TITLE").GetText = () => game.Name;
|
|
||||||
// TODO: Use game.MapTitle once the server supports it
|
|
||||||
item.GetWidget<LabelWidget>("MAP").GetText = () =>
|
|
||||||
{
|
|
||||||
var map = Game.modData.FindMapByUid(game.Map);
|
|
||||||
return map == null ? "Unknown" : map.Title;
|
|
||||||
};
|
|
||||||
// TODO: Use game.MaxPlayers once the server supports it
|
|
||||||
item.GetWidget<LabelWidget>("PLAYERS").GetText = () => GetPlayersLabel(game);
|
|
||||||
item.GetWidget<LabelWidget>("IP").GetText = () => game.Address;
|
|
||||||
sl.AddChild(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
{
|
{
|
||||||
public List<ProductionTab> Tabs = new List<ProductionTab>();
|
public List<ProductionTab> Tabs = new List<ProductionTab>();
|
||||||
public string Group;
|
public string Group;
|
||||||
public int CumulativeCount;
|
public int NextQueueName = 1;
|
||||||
public bool Alert { get { return Tabs.Any(t => t.Queue.CurrentDone); } }
|
public bool Alert { get { return Tabs.Any(t => t.Queue.CurrentDone); } }
|
||||||
|
|
||||||
public void Update(IEnumerable<ProductionQueue> allQueues)
|
public void Update(IEnumerable<ProductionQueue> allQueues)
|
||||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
foreach (var queue in queues)
|
foreach (var queue in queues)
|
||||||
tabs.Add(new ProductionTab()
|
tabs.Add(new ProductionTab()
|
||||||
{
|
{
|
||||||
Name = (++CumulativeCount).ToString(),
|
Name = (NextQueueName++).ToString(),
|
||||||
Queue = queue
|
Queue = queue
|
||||||
});
|
});
|
||||||
Tabs = tabs;
|
Tabs = tabs;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using OpenRA.Effects;
|
|
||||||
using OpenRA.Mods.RA.Move;
|
using OpenRA.Mods.RA.Move;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
@@ -250,8 +250,8 @@
|
|||||||
<Compile Include="Player\ClassicProductionQueue.cs" />
|
<Compile Include="Player\ClassicProductionQueue.cs" />
|
||||||
<Compile Include="Player\PlaceBuilding.cs" />
|
<Compile Include="Player\PlaceBuilding.cs" />
|
||||||
<Compile Include="Player\ProductionQueue.cs" />
|
<Compile Include="Player\ProductionQueue.cs" />
|
||||||
<Compile Include="Player\TechTree.cs" />
|
|
||||||
<Compile Include="Player\SurrenderOnDisconnect.cs" />
|
<Compile Include="Player\SurrenderOnDisconnect.cs" />
|
||||||
|
<Compile Include="Player\TechTree.cs" />
|
||||||
<Compile Include="PrimaryBuilding.cs" />
|
<Compile Include="PrimaryBuilding.cs" />
|
||||||
<Compile Include="Production.cs" />
|
<Compile Include="Production.cs" />
|
||||||
<Compile Include="ProductionBar.cs" />
|
<Compile Include="ProductionBar.cs" />
|
||||||
@@ -332,9 +332,9 @@
|
|||||||
<Compile Include="WaterPaletteRotation.cs" />
|
<Compile Include="WaterPaletteRotation.cs" />
|
||||||
<Compile Include="Weapon.cs" />
|
<Compile Include="Weapon.cs" />
|
||||||
<Compile Include="Widgets\BuildPaletteWidget.cs" />
|
<Compile Include="Widgets\BuildPaletteWidget.cs" />
|
||||||
|
<Compile Include="Widgets\Logic\ModBrowserLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\ColorPickerLogic.cs" />
|
<Compile Include="Widgets\Logic\ColorPickerLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\ConnectionDialogsLogic.cs" />
|
<Compile Include="Widgets\Logic\ConnectionLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\CreateServerMenuLogic.cs" />
|
|
||||||
<Compile Include="Widgets\Logic\DeveloperModeLogic.cs" />
|
<Compile Include="Widgets\Logic\DeveloperModeLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\DiplomacyLogic.cs" />
|
<Compile Include="Widgets\Logic\DiplomacyLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\DirectConnectLogic.cs" />
|
<Compile Include="Widgets\Logic\DirectConnectLogic.cs" />
|
||||||
@@ -352,6 +352,7 @@
|
|||||||
<Compile Include="Widgets\Logic\RAInstallLogic.cs" />
|
<Compile Include="Widgets\Logic\RAInstallLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\ReplayBrowserLogic.cs" />
|
<Compile Include="Widgets\Logic\ReplayBrowserLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\ServerBrowserLogic.cs" />
|
<Compile Include="Widgets\Logic\ServerBrowserLogic.cs" />
|
||||||
|
<Compile Include="Widgets\Logic\ServerCreationLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\SettingsMenuLogic.cs" />
|
<Compile Include="Widgets\Logic\SettingsMenuLogic.cs" />
|
||||||
<Compile Include="Widgets\MoneyBinWidget.cs" />
|
<Compile Include="Widgets\MoneyBinWidget.cs" />
|
||||||
<Compile Include="Widgets\OrderButtonWidget.cs" />
|
<Compile Include="Widgets\OrderButtonWidget.cs" />
|
||||||
|
|||||||
@@ -70,32 +70,6 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void StartGame()
|
public void StartGame()
|
||||||
{
|
{
|
||||||
Game.ConnectionStateChanged += orderManager =>
|
|
||||||
{
|
|
||||||
Widget.CloseWindow();
|
|
||||||
switch (orderManager.Connection.ConnectionState)
|
|
||||||
{
|
|
||||||
case ConnectionState.PreConnecting:
|
|
||||||
Widget.LoadWidget("MAINMENU_BG", Widget.RootWidget, new WidgetArgs());
|
|
||||||
break;
|
|
||||||
case ConnectionState.Connecting:
|
|
||||||
Widget.OpenWindow("CONNECTING_BG",
|
|
||||||
new WidgetArgs() { { "host", orderManager.Host }, { "port", orderManager.Port } });
|
|
||||||
break;
|
|
||||||
case ConnectionState.NotConnected:
|
|
||||||
Widget.OpenWindow("CONNECTION_FAILED_BG",
|
|
||||||
new WidgetArgs() { { "orderManager", orderManager } });
|
|
||||||
break;
|
|
||||||
case ConnectionState.Connected:
|
|
||||||
var lobby = Game.OpenWindow("SERVER_LOBBY", new WidgetArgs {});
|
|
||||||
lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").ClearChat();
|
|
||||||
lobby.GetWidget("CHANGEMAP_BUTTON").Visible = true;
|
|
||||||
lobby.GetWidget("ALLOWCHEATS_CHECKBOX").Visible = true;
|
|
||||||
lobby.GetWidget("DISCONNECT_BUTTON").Visible = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TestAndContinue();
|
TestAndContinue();
|
||||||
Game.JoinExternalGame();
|
Game.JoinExternalGame();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,8 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Mods.RA.Buildings;
|
|
||||||
using OpenRA.Traits;
|
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
|
||||||
* available to you under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation. For more information,
|
|
||||||
* see COPYING.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using OpenRA.Network;
|
|
||||||
using OpenRA.Widgets;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Widgets.Logic
|
|
||||||
{
|
|
||||||
public class ConnectionDialogsLogic
|
|
||||||
{
|
|
||||||
[ObjectCreator.UseCtor]
|
|
||||||
public ConnectionDialogsLogic(Widget widget, string host, int port)
|
|
||||||
{
|
|
||||||
widget.GetWidget<ButtonWidget>("CONNECTION_BUTTON_ABORT").OnClick = () => {
|
|
||||||
widget.GetWidget("CONNECTION_BUTTON_ABORT").Parent.Visible = false;
|
|
||||||
Game.Disconnect();
|
|
||||||
Game.LoadShellMap();
|
|
||||||
Widget.CloseWindow();
|
|
||||||
Widget.OpenWindow("MAINMENU_BG");
|
|
||||||
};
|
|
||||||
|
|
||||||
widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () =>
|
|
||||||
"Connecting to {0}:{1}...".F(host, port);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ConnectionFailedLogic
|
|
||||||
{
|
|
||||||
[ObjectCreator.UseCtor]
|
|
||||||
public ConnectionFailedLogic(Widget widget, OrderManager orderManager)
|
|
||||||
{
|
|
||||||
widget.GetWidget<ButtonWidget>("CONNECTION_BUTTON_CANCEL").OnClick = () => {
|
|
||||||
widget.GetWidget("CONNECTION_BUTTON_CANCEL").Parent.Visible = false;
|
|
||||||
Game.Disconnect();
|
|
||||||
Game.LoadShellMap();
|
|
||||||
Widget.CloseWindow();
|
|
||||||
Widget.OpenWindow("MAINMENU_BG");
|
|
||||||
};
|
|
||||||
widget.GetWidget<ButtonWidget>("CONNECTION_BUTTON_RETRY").OnClick = () =>
|
|
||||||
Game.JoinServer(orderManager.Host, orderManager.Port);
|
|
||||||
|
|
||||||
widget.GetWidget<LabelWidget>("CONNECTION_FAILED_DESC").GetText = () => string.IsNullOrEmpty(orderManager.ServerError) ?
|
|
||||||
"Could not connect to {0}:{1}".F(orderManager.Host, orderManager.Port) : orderManager.ServerError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -12,9 +12,9 @@ using System;
|
|||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
namespace OpenRA.Mods.RA.Widgets.Logic
|
||||||
{
|
{
|
||||||
public class CncConnectionLogic
|
public class ConnectionLogic
|
||||||
{
|
{
|
||||||
Action onConnect, onRetry, onAbort;
|
Action onConnect, onRetry, onAbort;
|
||||||
string host;
|
string host;
|
||||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public CncConnectionLogic(Widget widget, string host, int port, Action onConnect, Action onRetry, Action onAbort)
|
public ConnectionLogic(Widget widget, string host, int port, Action onConnect, Action onRetry, Action onAbort)
|
||||||
{
|
{
|
||||||
this.host = host;
|
this.host = host;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
|
|
||||||
Game.ConnectionStateChanged += ConnectionStateChanged;
|
Game.ConnectionStateChanged += ConnectionStateChanged;
|
||||||
|
|
||||||
var panel = widget.GetWidget("CONNECTING_PANEL");
|
var panel = widget;
|
||||||
panel.GetWidget<ButtonWidget>("ABORT_BUTTON").OnClick = () => { CloseWindow(); onAbort(); };
|
panel.GetWidget<ButtonWidget>("ABORT_BUTTON").OnClick = () => { CloseWindow(); onAbort(); };
|
||||||
|
|
||||||
widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () =>
|
widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () =>
|
||||||
@@ -79,16 +79,17 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CncConnectionFailedLogic
|
public class ConnectionFailedLogic
|
||||||
{
|
{
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public CncConnectionFailedLogic(Widget widget, string host, int port, Action onRetry, Action onAbort)
|
public ConnectionFailedLogic(Widget widget, string host, int port, Action onRetry, Action onAbort)
|
||||||
{
|
{
|
||||||
var panel = widget.GetWidget("CONNECTIONFAILED_PANEL");
|
var panel = widget;
|
||||||
panel.GetWidget<ButtonWidget>("ABORT_BUTTON").OnClick = () => { Widget.CloseWindow(); onAbort(); };
|
panel.GetWidget<ButtonWidget>("ABORT_BUTTON").OnClick = () => { Widget.CloseWindow(); onAbort(); };
|
||||||
panel.GetWidget<ButtonWidget>("RETRY_BUTTON").OnClick = () => { Widget.CloseWindow(); onRetry(); };
|
panel.GetWidget<ButtonWidget>("RETRY_BUTTON").OnClick = () => { Widget.CloseWindow(); onRetry(); };
|
||||||
|
|
||||||
widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () =>
|
widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () =>
|
||||||
"Could not connect to {0}:{1}".F(host, port);
|
"Could not connect to {0}:{1}".F(host, port);
|
||||||
}
|
}
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
|
||||||
* available to you under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation. For more information,
|
|
||||||
* see COPYING.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System.Net;
|
|
||||||
using OpenRA.GameRules;
|
|
||||||
using OpenRA.Widgets;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Widgets.Logic
|
|
||||||
{
|
|
||||||
public class CreateServerMenuLogic
|
|
||||||
{
|
|
||||||
[ObjectCreator.UseCtor]
|
|
||||||
public CreateServerMenuLogic(Widget widget)
|
|
||||||
{
|
|
||||||
var settings = Game.Settings;
|
|
||||||
var cs = widget;
|
|
||||||
|
|
||||||
cs.GetWidget<ButtonWidget>("BUTTON_CANCEL").OnClick = () => Widget.CloseWindow();
|
|
||||||
cs.GetWidget<ButtonWidget>("BUTTON_START").OnClick = () =>
|
|
||||||
{
|
|
||||||
settings.Server.Name = cs.GetWidget<TextFieldWidget>("GAME_TITLE").Text;
|
|
||||||
settings.Server.ListenPort = int.Parse(cs.GetWidget<TextFieldWidget>("LISTEN_PORT").Text);
|
|
||||||
settings.Server.ExternalPort = int.Parse(cs.GetWidget<TextFieldWidget>("EXTERNAL_PORT").Text);
|
|
||||||
settings.Server.Map = WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map);
|
|
||||||
settings.Save();
|
|
||||||
|
|
||||||
// Take a copy so that subsequent settings changes don't affect the server
|
|
||||||
Game.CreateServer(new ServerSettings(Game.Settings.Server));
|
|
||||||
Game.JoinServer(IPAddress.Loopback.ToString(), settings.Server.ListenPort);
|
|
||||||
};
|
|
||||||
|
|
||||||
cs.GetWidget<TextFieldWidget>("GAME_TITLE").Text = settings.Server.Name ?? "";
|
|
||||||
cs.GetWidget<TextFieldWidget>("LISTEN_PORT").Text = settings.Server.ListenPort.ToString();
|
|
||||||
cs.GetWidget<TextFieldWidget>("EXTERNAL_PORT").Text = settings.Server.ExternalPort.ToString();
|
|
||||||
|
|
||||||
var onlineCheckbox = cs.GetWidget<CheckboxWidget>("CHECKBOX_ONLINE");
|
|
||||||
onlineCheckbox.IsChecked = () => settings.Server.AdvertiseOnline;
|
|
||||||
onlineCheckbox.OnClick = () => { settings.Server.AdvertiseOnline ^= true; settings.Save(); };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +1,10 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
*
|
* available to you under the terms of the GNU General Public License
|
||||||
* OpenRA is free software: you can redistribute it and/or modify
|
* as published by the Free Software Foundation. For more information,
|
||||||
* it under the terms of the GNU General Public License as published by
|
* see COPYING.
|
||||||
* 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
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Linq;
|
using System;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Widgets.Logic
|
namespace OpenRA.Mods.RA.Widgets.Logic
|
||||||
@@ -16,34 +16,28 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
public class DirectConnectLogic
|
public class DirectConnectLogic
|
||||||
{
|
{
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public DirectConnectLogic(Widget widget)
|
public DirectConnectLogic(Widget widget, Action onExit, Action openLobby)
|
||||||
{
|
{
|
||||||
var dc = widget.GetWidget("DIRECTCONNECT_BG");
|
var panel = widget;
|
||||||
|
var ipField = panel.GetWidget<TextFieldWidget>("IP");
|
||||||
|
var portField = panel.GetWidget<TextFieldWidget>("PORT");
|
||||||
|
|
||||||
dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text = Game.Settings.Player.LastServer;
|
var last = Game.Settings.Player.LastServer.Split(':');
|
||||||
|
ipField.Text = last.Length > 1 ? last[0] : "localhost";
|
||||||
|
portField.Text = last.Length > 2 ? last[1] : "1234";
|
||||||
|
|
||||||
dc.GetWidget<ButtonWidget>("JOIN_BUTTON").OnClick = () =>
|
panel.GetWidget<ButtonWidget>("JOIN_BUTTON").OnClick = () =>
|
||||||
{
|
{
|
||||||
var address = dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text;
|
var port = Exts.WithDefault(1234, () => int.Parse(portField.Text));
|
||||||
var addressParts = address.Split(':');
|
|
||||||
if (addressParts.Length < 1 || addressParts.Length > 2)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var port = Exts.WithDefault(1234, () => int.Parse(addressParts[1]));
|
Game.Settings.Player.LastServer = "{0}:{1}".F(ipField.Text, port);
|
||||||
|
|
||||||
Game.Settings.Player.LastServer = address;
|
|
||||||
Game.Settings.Save();
|
Game.Settings.Save();
|
||||||
|
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
Game.JoinServer(addressParts[0], port);
|
ConnectionLogic.Connect(ipField.Text, port, openLobby, onExit);
|
||||||
};
|
};
|
||||||
|
|
||||||
dc.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnClick = () =>
|
panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); };
|
||||||
{
|
|
||||||
Widget.CloseWindow();
|
|
||||||
Widget.OpenWindow("MAINMENU_BG");
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
{
|
{
|
||||||
public class LobbyLogic
|
public class LobbyLogic
|
||||||
{
|
{
|
||||||
Widget lobby, LocalPlayerTemplate, RemotePlayerTemplate, EmptySlotTemplate, EmptySlotTemplateHost,
|
Widget EditablePlayerTemplate, NonEditablePlayerTemplate, EmptySlotTemplate,
|
||||||
LocalSpectatorTemplate, RemoteSpectatorTemplate, NewSpectatorTemplate;
|
EditableSpectatorTemplate, NonEditableSpectatorTemplate, NewSpectatorTemplate;
|
||||||
|
ScrollPanelWidget chatPanel;
|
||||||
|
Widget chatTemplate;
|
||||||
|
|
||||||
ScrollPanelWidget Players;
|
ScrollPanelWidget Players;
|
||||||
Dictionary<string, string> CountryNames;
|
Dictionary<string, string> CountryNames;
|
||||||
@@ -30,39 +32,98 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
ColorPickerPaletteModifier PlayerPalettePreview;
|
ColorPickerPaletteModifier PlayerPalettePreview;
|
||||||
|
|
||||||
|
readonly Action OnGameStart;
|
||||||
|
readonly Action onExit;
|
||||||
readonly OrderManager orderManager;
|
readonly OrderManager orderManager;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
// Listen for connection failures
|
||||||
internal LobbyLogic(Widget widget, World world, OrderManager orderManager)
|
void ConnectionStateChanged(OrderManager om)
|
||||||
{
|
{
|
||||||
|
if (om.Connection.ConnectionState == ConnectionState.NotConnected)
|
||||||
|
{
|
||||||
|
// Show connection failed dialog
|
||||||
|
CloseWindow();
|
||||||
|
|
||||||
|
Action onConnect = () =>
|
||||||
|
{
|
||||||
|
Game.OpenWindow("SERVER_LOBBY", new WidgetArgs()
|
||||||
|
{
|
||||||
|
{ "onExit", onExit },
|
||||||
|
{ "onStart", OnGameStart },
|
||||||
|
{ "addBots", false }
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Action onRetry = () =>
|
||||||
|
{
|
||||||
|
CloseWindow();
|
||||||
|
ConnectionLogic.Connect(om.Host, om.Port, onConnect, onExit);
|
||||||
|
};
|
||||||
|
|
||||||
|
Widget.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs()
|
||||||
|
{
|
||||||
|
{ "onAbort", onExit },
|
||||||
|
{ "onRetry", onRetry },
|
||||||
|
{ "host", om.Host },
|
||||||
|
{ "port", om.Port }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloseWindow()
|
||||||
|
{
|
||||||
|
Game.LobbyInfoChanged -= UpdateCurrentMap;
|
||||||
|
Game.LobbyInfoChanged -= UpdatePlayerList;
|
||||||
|
Game.BeforeGameStart -= OnGameStart;
|
||||||
|
Game.AddChatLine -= AddChatLine;
|
||||||
|
Game.ConnectionStateChanged -= ConnectionStateChanged;
|
||||||
|
|
||||||
|
Widget.CloseWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
[ObjectCreator.UseCtor]
|
||||||
|
internal LobbyLogic(Widget widget, World world, OrderManager orderManager,
|
||||||
|
Action onExit, Action onStart, bool addBots)
|
||||||
|
{
|
||||||
|
var lobby = widget;
|
||||||
this.orderManager = orderManager;
|
this.orderManager = orderManager;
|
||||||
this.lobby = widget;
|
this.OnGameStart = () => { CloseWindow(); onStart(); };
|
||||||
Game.BeforeGameStart += CloseWindow;
|
this.onExit = onExit;
|
||||||
|
|
||||||
Game.LobbyInfoChanged += UpdateCurrentMap;
|
Game.LobbyInfoChanged += UpdateCurrentMap;
|
||||||
Game.LobbyInfoChanged += UpdatePlayerList;
|
Game.LobbyInfoChanged += UpdatePlayerList;
|
||||||
UpdateCurrentMap();
|
Game.BeforeGameStart += OnGameStart;
|
||||||
|
Game.AddChatLine += AddChatLine;
|
||||||
|
Game.ConnectionStateChanged += ConnectionStateChanged;
|
||||||
|
|
||||||
|
UpdateCurrentMap();
|
||||||
PlayerPalettePreview = world.WorldActor.Trait<ColorPickerPaletteModifier>();
|
PlayerPalettePreview = world.WorldActor.Trait<ColorPickerPaletteModifier>();
|
||||||
PlayerPalettePreview.Ramp = Game.Settings.Player.ColorRamp;
|
PlayerPalettePreview.Ramp = Game.Settings.Player.ColorRamp;
|
||||||
|
|
||||||
Players = lobby.GetWidget<ScrollPanelWidget>("PLAYERS");
|
Players = lobby.GetWidget<ScrollPanelWidget>("PLAYERS");
|
||||||
LocalPlayerTemplate = Players.GetWidget("TEMPLATE_LOCAL");
|
EditablePlayerTemplate = Players.GetWidget("TEMPLATE_EDITABLE_PLAYER");
|
||||||
RemotePlayerTemplate = Players.GetWidget("TEMPLATE_REMOTE");
|
NonEditablePlayerTemplate = Players.GetWidget("TEMPLATE_NONEDITABLE_PLAYER");
|
||||||
EmptySlotTemplate = Players.GetWidget("TEMPLATE_EMPTY");
|
EmptySlotTemplate = Players.GetWidget("TEMPLATE_EMPTY");
|
||||||
EmptySlotTemplateHost = Players.GetWidget("TEMPLATE_EMPTY_HOST");
|
EditableSpectatorTemplate = Players.GetWidget("TEMPLATE_EDITABLE_SPECTATOR");
|
||||||
LocalSpectatorTemplate = Players.GetWidget("TEMPLATE_LOCAL_SPECTATOR");
|
NonEditableSpectatorTemplate = Players.GetWidget("TEMPLATE_NONEDITABLE_SPECTATOR");
|
||||||
RemoteSpectatorTemplate = Players.GetWidget("TEMPLATE_REMOTE_SPECTATOR");
|
|
||||||
NewSpectatorTemplate = Players.GetWidget("TEMPLATE_NEW_SPECTATOR");
|
NewSpectatorTemplate = Players.GetWidget("TEMPLATE_NEW_SPECTATOR");
|
||||||
|
|
||||||
var mapPreview = lobby.GetWidget<MapPreviewWidget>("LOBBY_MAP_PREVIEW");
|
var mapPreview = lobby.GetWidget<MapPreviewWidget>("MAP_PREVIEW");
|
||||||
|
mapPreview.IsVisible = () => Map != null;
|
||||||
mapPreview.Map = () => Map;
|
mapPreview.Map = () => Map;
|
||||||
mapPreview.OnMouseDown = mi => LobbyUtils.SelectSpawnPoint( orderManager, mapPreview, Map, mi );
|
mapPreview.OnMouseDown = mi => LobbyUtils.SelectSpawnPoint( orderManager, mapPreview, Map, mi );
|
||||||
mapPreview.SpawnColors = () => LobbyUtils.GetSpawnColors( orderManager, Map );
|
mapPreview.SpawnColors = () => LobbyUtils.GetSpawnColors( orderManager, Map );
|
||||||
|
|
||||||
|
var mapTitle = lobby.GetWidget<LabelWidget>("MAP_TITLE");
|
||||||
|
if (mapTitle != null)
|
||||||
|
{
|
||||||
|
mapTitle.IsVisible = () => Map != null;
|
||||||
|
mapTitle.GetText = () => Map.Title;
|
||||||
|
}
|
||||||
|
|
||||||
CountryNames = Rules.Info["world"].Traits.WithInterface<CountryInfo>()
|
CountryNames = Rules.Info["world"].Traits.WithInterface<CountryInfo>()
|
||||||
.Where(c => c.Selectable)
|
.Where(c => c.Selectable)
|
||||||
.ToDictionary(a => a.Race, a => a.Name);
|
.ToDictionary(a => a.Race, a => a.Name);
|
||||||
CountryNames.Add("random", "Random");
|
CountryNames.Add("random", "Any");
|
||||||
|
|
||||||
var mapButton = lobby.GetWidget<ButtonWidget>("CHANGEMAP_BUTTON");
|
var mapButton = lobby.GetWidget<ButtonWidget>("CHANGEMAP_BUTTON");
|
||||||
mapButton.OnClick = () =>
|
mapButton.OnClick = () =>
|
||||||
@@ -74,48 +135,40 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
Game.Settings.Save();
|
Game.Settings.Save();
|
||||||
});
|
});
|
||||||
|
|
||||||
Widget.OpenWindow("MAP_CHOOSER", new WidgetArgs()
|
Widget.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs()
|
||||||
{
|
{
|
||||||
{ "initialMap", MapUid },
|
{ "initialMap", Map.Uid },
|
||||||
{ "onExit", () => {} },
|
{ "onExit", () => {} },
|
||||||
{ "onSelect", onSelect }
|
{ "onSelect", onSelect }
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
mapButton.IsVisible = () => mapButton.Visible && Game.IsHost;
|
mapButton.IsVisible = () => mapButton.Visible && Game.IsHost;
|
||||||
|
|
||||||
var disconnectButton = lobby.GetWidget<ButtonWidget>("DISCONNECT_BUTTON");
|
var disconnectButton = lobby.GetWidget<ButtonWidget>("DISCONNECT_BUTTON");
|
||||||
disconnectButton.OnClick = () =>
|
disconnectButton.OnClick = () => { CloseWindow(); onExit(); };
|
||||||
{
|
|
||||||
CloseWindow();
|
var gameStarting = false;
|
||||||
Game.Disconnect();
|
|
||||||
Game.LoadShellMap();
|
|
||||||
Widget.OpenWindow("MAINMENU_BG");
|
|
||||||
};
|
|
||||||
|
|
||||||
var allowCheats = lobby.GetWidget<CheckboxWidget>("ALLOWCHEATS_CHECKBOX");
|
var allowCheats = lobby.GetWidget<CheckboxWidget>("ALLOWCHEATS_CHECKBOX");
|
||||||
allowCheats.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllowCheats;
|
allowCheats.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllowCheats;
|
||||||
allowCheats.OnClick = () =>
|
allowCheats.IsDisabled = () => !Game.IsHost || gameStarting || orderManager.LocalClient == null
|
||||||
{
|
|| orderManager.LocalClient.IsReady;
|
||||||
if (Game.IsHost)
|
allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||||
orderManager.IssueOrder(Order.Command(
|
|
||||||
"allowcheats {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowCheats)));
|
"allowcheats {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowCheats)));
|
||||||
};
|
|
||||||
|
|
||||||
var startGameButton = lobby.GetWidget<ButtonWidget>("START_GAME_BUTTON");
|
var startGameButton = lobby.GetWidget<ButtonWidget>("START_GAME_BUTTON");
|
||||||
|
startGameButton.IsVisible = () => Game.IsHost;
|
||||||
|
startGameButton.IsDisabled = () => gameStarting;
|
||||||
startGameButton.OnClick = () =>
|
startGameButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
mapButton.Visible = false;
|
gameStarting = true;
|
||||||
disconnectButton.Visible = false;
|
|
||||||
orderManager.IssueOrder(Order.Command("startgame"));
|
orderManager.IssueOrder(Order.Command("startgame"));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Todo: Only show if the map requirements are met for player slots
|
|
||||||
startGameButton.IsVisible = () => Game.IsHost;
|
|
||||||
|
|
||||||
bool teamChat = false;
|
bool teamChat = false;
|
||||||
var chatLabel = lobby.GetWidget<LabelWidget>("LABEL_CHATTYPE");
|
var chatLabel = lobby.GetWidget<LabelWidget>("LABEL_CHATTYPE");
|
||||||
var chatTextField = lobby.GetWidget<TextFieldWidget>("CHAT_TEXTFIELD");
|
var chatTextField = lobby.GetWidget<TextFieldWidget>("CHAT_TEXTFIELD");
|
||||||
|
|
||||||
chatTextField.OnEnterKey = () =>
|
chatTextField.OnEnterKey = () =>
|
||||||
{
|
{
|
||||||
if (chatTextField.Text.Length == 0)
|
if (chatTextField.Text.Length == 0)
|
||||||
@@ -133,36 +186,69 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
Game.AddChatLine += AddChatLine;
|
chatPanel = lobby.GetWidget<ScrollPanelWidget>("CHAT_DISPLAY");
|
||||||
}
|
chatTemplate = chatPanel.GetWidget("CHAT_TEMPLATE");
|
||||||
|
chatPanel.RemoveChildren();
|
||||||
|
|
||||||
public void CloseWindow()
|
var musicButton = lobby.GetWidget<ButtonWidget>("MUSIC_BUTTON");
|
||||||
|
if (musicButton != null)
|
||||||
|
musicButton.OnClick = () => Widget.OpenWindow("MUSIC_PANEL", new WidgetArgs
|
||||||
|
{ { "onExit", () => {} } });
|
||||||
|
|
||||||
|
// Add a bot on the first lobbyinfo update
|
||||||
|
if (addBots)
|
||||||
|
Game.LobbyInfoChanged += WidgetUtils.Once(() =>
|
||||||
{
|
{
|
||||||
Game.LobbyInfoChanged -= UpdateCurrentMap;
|
var slot = orderManager.LobbyInfo.FirstEmptySlot();
|
||||||
Game.LobbyInfoChanged -= UpdatePlayerList;
|
var bot = Rules.Info["player"].Traits.WithInterface<IBotInfo>().Select(t => t.Name).FirstOrDefault();
|
||||||
Game.AddChatLine -= AddChatLine;
|
if (slot != null && bot != null)
|
||||||
Game.BeforeGameStart -= CloseWindow;
|
orderManager.IssueOrder(Order.Command("slot_bot {0} {1}".F(slot, bot)));
|
||||||
|
});
|
||||||
Widget.CloseWindow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddChatLine(Color c, string from, string text)
|
void AddChatLine(Color c, string from, string text)
|
||||||
{
|
{
|
||||||
lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").AddLine(c, from, text);
|
var template = chatTemplate.Clone();
|
||||||
|
var nameLabel = template.GetWidget<LabelWidget>("NAME");
|
||||||
|
var timeLabel = template.GetWidget<LabelWidget>("TIME");
|
||||||
|
var textLabel = template.GetWidget<LabelWidget>("TEXT");
|
||||||
|
|
||||||
|
var name = from + ":";
|
||||||
|
var font = Game.Renderer.Fonts[nameLabel.Font];
|
||||||
|
var nameSize = font.Measure(from);
|
||||||
|
|
||||||
|
var time = DateTime.Now;
|
||||||
|
timeLabel.GetText = () => "{0:D2}:{1:D2}".F(time.Hour, time.Minute);
|
||||||
|
|
||||||
|
nameLabel.GetColor = () => c;
|
||||||
|
nameLabel.GetText = () => name;
|
||||||
|
nameLabel.Bounds.Width = nameSize.X;
|
||||||
|
textLabel.Bounds.X += nameSize.X;
|
||||||
|
textLabel.Bounds.Width -= nameSize.X;
|
||||||
|
|
||||||
|
// Hack around our hacky wordwrap behavior: need to resize the widget to fit the text
|
||||||
|
text = WidgetUtils.WrapText(text, textLabel.Bounds.Width, font);
|
||||||
|
textLabel.GetText = () => text;
|
||||||
|
var dh = font.Measure(text).Y - textLabel.Bounds.Height;
|
||||||
|
if (dh > 0)
|
||||||
|
{
|
||||||
|
textLabel.Bounds.Height += dh;
|
||||||
|
template.Bounds.Height += dh;
|
||||||
|
}
|
||||||
|
|
||||||
|
chatPanel.AddChild(template);
|
||||||
|
chatPanel.ScrollToBottom();
|
||||||
|
Sound.Play("scold1.aud");
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateCurrentMap()
|
void UpdateCurrentMap()
|
||||||
{
|
{
|
||||||
var newMap = orderManager.LobbyInfo.GlobalSettings.Map;
|
if (MapUid == orderManager.LobbyInfo.GlobalSettings.Map) return;
|
||||||
if (MapUid == newMap) return;
|
MapUid = orderManager.LobbyInfo.GlobalSettings.Map;
|
||||||
|
|
||||||
MapUid = newMap;
|
|
||||||
Map = new Map(Game.modData.AvailableMaps[MapUid].Path);
|
Map = new Map(Game.modData.AvailableMaps[MapUid].Path);
|
||||||
|
|
||||||
var title = Widget.RootWidget.GetWidget<LabelWidget>("LOBBY_TITLE");
|
var title = Widget.RootWidget.GetWidget<LabelWidget>("TITLE");
|
||||||
if (title != null)
|
title.Text = orderManager.LobbyInfo.GlobalSettings.ServerName;
|
||||||
title.Text = "OpenRA Multiplayer Lobby - {0} - {1}".F(
|
|
||||||
orderManager.LobbyInfo.GlobalSettings.ServerName, Map.Title);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdatePlayerList()
|
void UpdatePlayerList()
|
||||||
@@ -173,108 +259,119 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
foreach (var kv in orderManager.LobbyInfo.Slots)
|
foreach (var kv in orderManager.LobbyInfo.Slots)
|
||||||
{
|
{
|
||||||
var s = kv.Value;
|
var key = kv.Key;
|
||||||
var c = orderManager.LobbyInfo.ClientInSlot(kv.Key);
|
var slot = kv.Value;
|
||||||
|
var client = orderManager.LobbyInfo.ClientInSlot(key);
|
||||||
Widget template;
|
Widget template;
|
||||||
|
|
||||||
if (c == null)
|
// Empty slot
|
||||||
|
if (client == null)
|
||||||
{
|
{
|
||||||
|
template = EmptySlotTemplate.Clone();
|
||||||
|
Func<string> getText = () => slot.Closed ? "Closed" : "Open";
|
||||||
|
var ready = orderManager.LocalClient.IsReady;
|
||||||
|
|
||||||
if (Game.IsHost)
|
if (Game.IsHost)
|
||||||
{
|
{
|
||||||
template = EmptySlotTemplateHost.Clone();
|
var name = template.GetWidget<DropDownButtonWidget>("NAME_HOST");
|
||||||
var name = template.GetWidget<DropDownButtonWidget>("NAME");
|
name.IsVisible = () => true;
|
||||||
name.GetText = () => s.Closed ? "Closed" : "Open";
|
name.IsDisabled = () => ready;
|
||||||
name.OnMouseDown = _ => LobbyUtils.ShowSlotDropDown(name, s, c, orderManager);
|
name.GetText = getText;
|
||||||
|
name.OnMouseDown = _ => LobbyUtils.ShowSlotDropDown(name, slot, client, orderManager);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
template = EmptySlotTemplate.Clone();
|
|
||||||
var name = template.GetWidget<LabelWidget>("NAME");
|
var name = template.GetWidget<LabelWidget>("NAME");
|
||||||
name.GetText = () => s.Closed ? "Closed" : "Open";
|
name.IsVisible = () => true;
|
||||||
|
name.GetText = getText;
|
||||||
}
|
}
|
||||||
|
|
||||||
var join = template.GetWidget<ButtonWidget>("JOIN");
|
var join = template.GetWidget<ButtonWidget>("JOIN");
|
||||||
if (join != null)
|
join.IsVisible = () => !slot.Closed;
|
||||||
{
|
join.IsDisabled = () => ready;
|
||||||
join.OnClick = () => orderManager.IssueOrder(Order.Command("slot " + s.PlayerReference));
|
join.OnClick = () => orderManager.IssueOrder(Order.Command("slot " + key));
|
||||||
join.IsVisible = () => !s.Closed && c == null && !orderManager.LocalClient.IsReady;
|
|
||||||
}
|
}
|
||||||
}
|
// Editable player in slot
|
||||||
|
else if ((client.Index == orderManager.LocalClient.Index) ||
|
||||||
else if ((c.Index == orderManager.LocalClient.Index && !c.IsReady) || (c.Bot != null && Game.IsHost))
|
(client.Bot != null && Game.IsHost))
|
||||||
{
|
{
|
||||||
template = LocalPlayerTemplate.Clone();
|
template = EditablePlayerTemplate.Clone();
|
||||||
|
var botReady = client.Bot != null && Game.IsHost && orderManager.LocalClient.IsReady;
|
||||||
|
var ready = botReady || client.IsReady;
|
||||||
|
|
||||||
var botReady = (c.Bot != null && Game.IsHost
|
if (client.Bot != null)
|
||||||
&& orderManager.LocalClient.IsReady);
|
|
||||||
var ready = botReady || c.IsReady;
|
|
||||||
|
|
||||||
if (c.Bot == null)
|
|
||||||
{
|
|
||||||
LobbyUtils.SetupNameWidget(orderManager, c, template.GetWidget<TextFieldWidget>("NAME"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
var name = template.GetWidget<DropDownButtonWidget>("BOT_DROPDOWN");
|
var name = template.GetWidget<DropDownButtonWidget>("BOT_DROPDOWN");
|
||||||
name.IsVisible = () => true;
|
name.IsVisible = () => true;
|
||||||
name.IsDisabled = () => ready;
|
name.IsDisabled = () => ready;
|
||||||
name.GetText = () => c.Name;
|
name.GetText = () => client.Name;
|
||||||
name.OnMouseDown = _ => LobbyUtils.ShowSlotDropDown(name, s, c, orderManager);
|
name.OnMouseDown = _ => LobbyUtils.ShowSlotDropDown(name, slot, client, orderManager);
|
||||||
}
|
|
||||||
|
|
||||||
var color = template.GetWidget<DropDownButtonWidget>("COLOR");
|
|
||||||
color.IsDisabled = () => s.LockColor;
|
|
||||||
color.OnMouseDown = _ => LobbyUtils.ShowColorDropDown(color, c, orderManager, PlayerPalettePreview);
|
|
||||||
|
|
||||||
var colorBlock = color.GetWidget<ColorBlockWidget>("COLORBLOCK");
|
|
||||||
colorBlock.GetColor = () => c.ColorRamp.GetColor(0);
|
|
||||||
|
|
||||||
var faction = template.GetWidget<DropDownButtonWidget>("FACTION");
|
|
||||||
faction.IsDisabled = () => s.LockRace;
|
|
||||||
faction.OnMouseDown = _ => LobbyUtils.ShowRaceDropDown(faction, c, orderManager, CountryNames);
|
|
||||||
|
|
||||||
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<DropDownButtonWidget>("TEAM");
|
|
||||||
team.IsDisabled = () => s.LockTeam;
|
|
||||||
team.OnMouseDown = _ => LobbyUtils.ShowTeamDropDown(team, c, orderManager, Map);
|
|
||||||
team.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString();
|
|
||||||
|
|
||||||
var status = template.GetWidget<CheckboxWidget>("STATUS");
|
|
||||||
status.IsChecked = () => c.IsReady;
|
|
||||||
status.OnClick = CycleReady;
|
|
||||||
status.IsVisible = () => c.Bot == null;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
template = RemotePlayerTemplate.Clone();
|
var name = template.GetWidget<TextFieldWidget>("NAME");
|
||||||
template.GetWidget<LabelWidget>("NAME").GetText = () => c.Name;
|
name.IsVisible = () => true;
|
||||||
|
name.IsDisabled = () => ready;
|
||||||
|
LobbyUtils.SetupNameWidget(orderManager, client, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
var color = template.GetWidget<DropDownButtonWidget>("COLOR");
|
||||||
|
color.IsDisabled = () => slot.LockColor || ready;
|
||||||
|
color.OnMouseDown = _ => LobbyUtils.ShowColorDropDown(color, client, orderManager, PlayerPalettePreview);
|
||||||
|
|
||||||
|
var colorBlock = color.GetWidget<ColorBlockWidget>("COLORBLOCK");
|
||||||
|
colorBlock.GetColor = () => client.ColorRamp.GetColor(0);
|
||||||
|
|
||||||
|
var faction = template.GetWidget<DropDownButtonWidget>("FACTION");
|
||||||
|
faction.IsDisabled = () => slot.LockRace || ready;
|
||||||
|
faction.OnMouseDown = _ => LobbyUtils.ShowRaceDropDown(faction, client, orderManager, CountryNames);
|
||||||
|
|
||||||
|
var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME");
|
||||||
|
factionname.GetText = () => CountryNames[client.Country];
|
||||||
|
var factionflag = faction.GetWidget<ImageWidget>("FACTIONFLAG");
|
||||||
|
factionflag.GetImageName = () => client.Country;
|
||||||
|
factionflag.GetImageCollection = () => "flags";
|
||||||
|
|
||||||
|
var team = template.GetWidget<DropDownButtonWidget>("TEAM");
|
||||||
|
team.IsDisabled = () => slot.LockTeam || ready;
|
||||||
|
team.OnMouseDown = _ => LobbyUtils.ShowTeamDropDown(team, client, orderManager, Map);
|
||||||
|
team.GetText = () => (client.Team == 0) ? "-" : client.Team.ToString();
|
||||||
|
|
||||||
|
if (client.Bot == null)
|
||||||
|
{
|
||||||
|
// local player
|
||||||
|
var status = template.GetWidget<CheckboxWidget>("STATUS_CHECKBOX");
|
||||||
|
status.IsChecked = () => ready;
|
||||||
|
status.IsVisible = () => true;
|
||||||
|
status.OnClick += CycleReady;
|
||||||
|
}
|
||||||
|
else // Bot
|
||||||
|
template.GetWidget<ImageWidget>("STATUS_IMAGE").IsVisible = () => true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Non-editable player in slot
|
||||||
|
template = NonEditablePlayerTemplate.Clone();
|
||||||
|
template.GetWidget<LabelWidget>("NAME").GetText = () => client.Name;
|
||||||
var color = template.GetWidget<ColorBlockWidget>("COLOR");
|
var color = template.GetWidget<ColorBlockWidget>("COLOR");
|
||||||
color.GetColor = () => c.ColorRamp.GetColor(0);
|
color.GetColor = () => client.ColorRamp.GetColor(0);
|
||||||
|
|
||||||
var faction = template.GetWidget<LabelWidget>("FACTION");
|
var faction = template.GetWidget<LabelWidget>("FACTION");
|
||||||
var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME");
|
var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME");
|
||||||
factionname.GetText = () => CountryNames[c.Country];
|
factionname.GetText = () => CountryNames[client.Country];
|
||||||
var factionflag = faction.GetWidget<ImageWidget>("FACTIONFLAG");
|
var factionflag = faction.GetWidget<ImageWidget>("FACTIONFLAG");
|
||||||
factionflag.GetImageName = () => c.Country;
|
factionflag.GetImageName = () => client.Country;
|
||||||
factionflag.GetImageCollection = () => "flags";
|
factionflag.GetImageCollection = () => "flags";
|
||||||
|
|
||||||
var team = template.GetWidget<LabelWidget>("TEAM");
|
var team = template.GetWidget<LabelWidget>("TEAM");
|
||||||
team.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString();
|
team.GetText = () => (client.Team == 0) ? "-" : client.Team.ToString();
|
||||||
|
|
||||||
var status = template.GetWidget<CheckboxWidget>("STATUS");
|
template.GetWidget<ImageWidget>("STATUS_IMAGE").IsVisible = () =>
|
||||||
status.IsChecked = () => c.IsReady;
|
client.Bot != null || client.IsReady;
|
||||||
if (c.Index == orderManager.LocalClient.Index)
|
|
||||||
status.OnClick = CycleReady;
|
|
||||||
status.IsVisible = () => c.Bot == null;
|
|
||||||
|
|
||||||
var kickButton = template.GetWidget<ButtonWidget>("KICK");
|
var kickButton = template.GetWidget<ButtonWidget>("KICK");
|
||||||
kickButton.IsVisible = () => Game.IsHost && c.Index != orderManager.LocalClient.Index;
|
kickButton.IsVisible = () => Game.IsHost && client.Index != orderManager.LocalClient.Index;
|
||||||
kickButton.OnClick = () => orderManager.IssueOrder(Order.Command("kick " + c.Index));
|
kickButton.IsDisabled = () => orderManager.LocalClient.IsReady;
|
||||||
|
kickButton.OnClick = () => orderManager.IssueOrder(Order.Command("kick " + client.Index));
|
||||||
}
|
}
|
||||||
|
|
||||||
template.IsVisible = () => true;
|
template.IsVisible = () => true;
|
||||||
@@ -284,39 +381,42 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
// Add spectators
|
// Add spectators
|
||||||
foreach (var client in orderManager.LobbyInfo.Clients.Where(client => client.Slot == null))
|
foreach (var client in orderManager.LobbyInfo.Clients.Where(client => client.Slot == null))
|
||||||
{
|
{
|
||||||
var c = client;
|
|
||||||
Widget template;
|
Widget template;
|
||||||
|
var c = client;
|
||||||
|
var ready = c.IsReady;
|
||||||
|
|
||||||
// Editable spectator
|
// Editable spectator
|
||||||
if (c.Index == orderManager.LocalClient.Index && !c.IsReady)
|
if (c.Index == orderManager.LocalClient.Index)
|
||||||
{
|
{
|
||||||
template = LocalSpectatorTemplate.Clone();
|
template = EditableSpectatorTemplate.Clone();
|
||||||
LobbyUtils.SetupNameWidget(orderManager, c, template.GetWidget<TextFieldWidget>("NAME"));
|
var name = template.GetWidget<TextFieldWidget>("NAME");
|
||||||
|
name.IsDisabled = () => ready;
|
||||||
|
LobbyUtils.SetupNameWidget(orderManager, c, name);
|
||||||
|
|
||||||
var color = template.GetWidget<DropDownButtonWidget>("COLOR");
|
var color = template.GetWidget<DropDownButtonWidget>("COLOR");
|
||||||
|
color.IsDisabled = () => ready;
|
||||||
color.OnMouseDown = _ => LobbyUtils.ShowColorDropDown(color, c, orderManager, PlayerPalettePreview);
|
color.OnMouseDown = _ => LobbyUtils.ShowColorDropDown(color, c, orderManager, PlayerPalettePreview);
|
||||||
|
|
||||||
var colorBlock = color.GetWidget<ColorBlockWidget>("COLORBLOCK");
|
var colorBlock = color.GetWidget<ColorBlockWidget>("COLORBLOCK");
|
||||||
colorBlock.GetColor = () => c.ColorRamp.GetColor(0);
|
colorBlock.GetColor = () => c.ColorRamp.GetColor(0);
|
||||||
|
|
||||||
var status = template.GetWidget<CheckboxWidget>("STATUS");
|
var status = template.GetWidget<CheckboxWidget>("STATUS_CHECKBOX");
|
||||||
status.IsChecked = () => c.IsReady;
|
status.IsChecked = () => ready;
|
||||||
status.OnClick += CycleReady;
|
status.OnClick += CycleReady;
|
||||||
}
|
}
|
||||||
// Non-editable spectator
|
// Non-editable spectator
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
template = RemoteSpectatorTemplate.Clone();
|
template = NonEditableSpectatorTemplate.Clone();
|
||||||
template.GetWidget<LabelWidget>("NAME").GetText = () => c.Name;
|
template.GetWidget<LabelWidget>("NAME").GetText = () => c.Name;
|
||||||
var color = template.GetWidget<ColorBlockWidget>("COLOR");
|
var color = template.GetWidget<ColorBlockWidget>("COLOR");
|
||||||
color.GetColor = () => c.ColorRamp.GetColor(0);
|
color.GetColor = () => c.ColorRamp.GetColor(0);
|
||||||
|
|
||||||
var status = template.GetWidget<CheckboxWidget>("STATUS");
|
template.GetWidget<ImageWidget>("STATUS_IMAGE").IsVisible = () => c.Bot != null || c.IsReady;
|
||||||
status.IsChecked = () => c.IsReady;
|
|
||||||
if (c.Index == orderManager.LocalClient.Index)
|
|
||||||
status.OnClick += CycleReady;
|
|
||||||
|
|
||||||
var kickButton = template.GetWidget<ButtonWidget>("KICK");
|
var kickButton = template.GetWidget<ButtonWidget>("KICK");
|
||||||
kickButton.IsVisible = () => Game.IsHost && c.Index != orderManager.LocalClient.Index;
|
kickButton.IsVisible = () => Game.IsHost && c.Index != orderManager.LocalClient.Index;
|
||||||
|
kickButton.IsDisabled = () => orderManager.LocalClient.IsReady;
|
||||||
kickButton.OnClick = () => orderManager.IssueOrder(Order.Command("kick " + c.Index));
|
kickButton.OnClick = () => orderManager.IssueOrder(Order.Command("kick " + c.Index));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,11 +425,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Spectate button
|
// Spectate button
|
||||||
if (orderManager.LocalClient.Slot != null && !orderManager.LocalClient.IsReady)
|
if (orderManager.LocalClient.Slot != null)
|
||||||
{
|
{
|
||||||
var spec = NewSpectatorTemplate.Clone();
|
var spec = NewSpectatorTemplate.Clone();
|
||||||
var btn = spec.GetWidget<ButtonWidget>("SPECTATE");
|
var btn = spec.GetWidget<ButtonWidget>("SPECTATE");
|
||||||
btn.OnClick = () => orderManager.IssueOrder(Order.Command("spectate"));
|
btn.OnClick = () => orderManager.IssueOrder(Order.Command("spectate"));
|
||||||
|
btn.IsDisabled = () => orderManager.LocalClient.IsReady;
|
||||||
spec.IsVisible = () => true;
|
spec.IsVisible = () => true;
|
||||||
Players.AddChild(spec);
|
Players.AddChild(spec);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,58 +8,62 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using OpenRA.FileFormats;
|
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Widgets.Logic
|
namespace OpenRA.Mods.RA.Widgets.Logic
|
||||||
{
|
{
|
||||||
public class MainMenuButtonsLogic
|
public class MainMenuButtonsLogic
|
||||||
{
|
{
|
||||||
|
Widget rootMenu;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public MainMenuButtonsLogic(Widget widget)
|
public MainMenuButtonsLogic(Widget widget)
|
||||||
{
|
{
|
||||||
|
rootMenu = widget;
|
||||||
|
|
||||||
Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Widget.RootWidget, "PERF_BG" );
|
Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Widget.RootWidget, "PERF_BG" );
|
||||||
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_JOIN").OnClick = () => Widget.OpenWindow("JOINSERVER_BG");
|
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_JOIN").OnClick = () => OpenGamePanel("JOINSERVER_BG");
|
||||||
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_CREATE").OnClick = () => Widget.OpenWindow("CREATESERVER_BG");
|
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_CREATE").OnClick = () => OpenGamePanel("CREATESERVER_BG");
|
||||||
|
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_DIRECTCONNECT").OnClick = () => OpenGamePanel("DIRECTCONNECT_BG");
|
||||||
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_SETTINGS").OnClick = () => Widget.OpenWindow("SETTINGS_MENU");
|
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_SETTINGS").OnClick = () => Widget.OpenWindow("SETTINGS_MENU");
|
||||||
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_MUSIC").OnClick = () => Widget.OpenWindow("MUSIC_MENU");
|
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_MUSIC").OnClick = () => Widget.OpenWindow("MUSIC_MENU");
|
||||||
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_REPLAY_VIEWER").OnClick = () => Widget.OpenWindow("REPLAYBROWSER_BG");
|
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_MODS").OnClick = () =>
|
||||||
|
Widget.OpenWindow("MODS_PANEL", new WidgetArgs()
|
||||||
|
{
|
||||||
|
{ "onExit", () => {} },
|
||||||
|
{ "onSwitch", RemoveShellmapUI }
|
||||||
|
});
|
||||||
|
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_REPLAY_VIEWER").OnClick = () =>
|
||||||
|
Widget.OpenWindow("REPLAYBROWSER_BG", new WidgetArgs()
|
||||||
|
{
|
||||||
|
{ "onExit", () => {} },
|
||||||
|
{ "onStart", RemoveShellmapUI }
|
||||||
|
});
|
||||||
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_QUIT").OnClick = () => Game.Exit();
|
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_QUIT").OnClick = () => Game.Exit();
|
||||||
|
|
||||||
DisplayModSelector();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DisplayModSelector()
|
void RemoveShellmapUI()
|
||||||
{
|
{
|
||||||
var selector = Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Widget.RootWidget, "QUICKMODSWITCHER" );
|
rootMenu.Parent.RemoveChild(rootMenu);
|
||||||
var switcher = selector.GetWidget<DropDownButtonWidget>("SWITCHER");
|
|
||||||
switcher.OnMouseDown = _ => ShowModsDropDown(switcher);
|
|
||||||
switcher.GetText = WidgetUtils.ActiveModTitle;
|
|
||||||
selector.GetWidget<LabelWidget>("VERSION").GetText = WidgetUtils.ActiveModVersion;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadMod(string mod)
|
void OpenGamePanel(string id)
|
||||||
{
|
{
|
||||||
var mods = Mod.AllMods[mod].WithPrerequisites();
|
Widget.OpenWindow(id, new WidgetArgs()
|
||||||
|
{
|
||||||
if (Game.CurrentMods.Keys.SymmetricDifference(mods).Any())
|
{ "onExit", () => {} },
|
||||||
Game.RunAfterTick(() => Game.InitializeWithMods(mods));
|
{ "openLobby", () => OpenLobbyPanel() }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShowModsDropDown(DropDownButtonWidget dropdown)
|
void OpenLobbyPanel()
|
||||||
{
|
{
|
||||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (m, itemTemplate) =>
|
Game.OpenWindow("SERVER_LOBBY", new WidgetArgs()
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
{ "onExit", () => { Game.Disconnect(); } },
|
||||||
() => m == Game.CurrentMods.Keys.First(),
|
{ "onStart", RemoveShellmapUI },
|
||||||
() => LoadMod(m));
|
{ "addBots", false }
|
||||||
item.GetWidget<LabelWidget>("LABEL").GetText = () => Mod.AllMods[m].Title;
|
});
|
||||||
return item;
|
|
||||||
};
|
|
||||||
|
|
||||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 150, Mod.AllMods.Keys, setupItem);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,16 +13,16 @@ using System.Linq;
|
|||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
namespace OpenRA.Mods.RA.Widgets.Logic
|
||||||
{
|
{
|
||||||
public class CncModBrowserLogic
|
public class ModBrowserLogic
|
||||||
{
|
{
|
||||||
Mod currentMod;
|
Mod currentMod;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public CncModBrowserLogic(Widget widget, Action onSwitch, Action onExit)
|
public ModBrowserLogic(Widget widget, Action onSwitch, Action onExit)
|
||||||
{
|
{
|
||||||
var panel = widget.GetWidget("MODS_PANEL");
|
var panel = widget;
|
||||||
var modList = panel.GetWidget<ScrollPanelWidget>("MOD_LIST");
|
var modList = panel.GetWidget<ScrollPanelWidget>("MOD_LIST");
|
||||||
var loadButton = panel.GetWidget<ButtonWidget>("LOAD_BUTTON");
|
var loadButton = panel.GetWidget<ButtonWidget>("LOAD_BUTTON");
|
||||||
loadButton.OnClick = () => LoadMod(currentMod.Id, onSwitch);
|
loadButton.OnClick = () => LoadMod(currentMod.Id, onSwitch);
|
||||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
{
|
{
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
onSwitch();
|
onSwitch();
|
||||||
Game.InitializeWithMods(mods.ToArray());
|
Game.InitializeWithMods(mods);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,8 +33,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
Widget.OpenWindow("INSTALL_FROMCD_PANEL", args);
|
Widget.OpenWindow("INSTALL_FROMCD_PANEL", args);
|
||||||
|
|
||||||
panel.GetWidget<ButtonWidget>("QUIT_BUTTON").OnClick = Game.Exit;
|
panel.GetWidget<ButtonWidget>("QUIT_BUTTON").OnClick = Game.Exit;
|
||||||
|
|
||||||
MainMenuButtonsLogic.DisplayModSelector();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,70 +18,80 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
{
|
{
|
||||||
public class ReplayBrowserLogic
|
public class ReplayBrowserLogic
|
||||||
{
|
{
|
||||||
Widget widget;
|
Widget panel;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public ReplayBrowserLogic(Widget widget)
|
public ReplayBrowserLogic(Widget widget, Action onExit, Action onStart)
|
||||||
{
|
{
|
||||||
this.widget = widget;
|
panel = widget;
|
||||||
|
|
||||||
widget.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnClick = () => Widget.CloseWindow();
|
panel.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); };
|
||||||
|
|
||||||
/* find some replays? */
|
var rl = panel.GetWidget<ScrollPanelWidget>("REPLAY_LIST");
|
||||||
var rl = widget.GetWidget<ScrollPanelWidget>("REPLAY_LIST");
|
|
||||||
var replayDir = Path.Combine(Platform.SupportDir, "Replays");
|
var replayDir = Path.Combine(Platform.SupportDir, "Replays");
|
||||||
|
|
||||||
var template = widget.GetWidget<ScrollItemWidget>("REPLAY_TEMPLATE");
|
var template = panel.GetWidget<ScrollItemWidget>("REPLAY_TEMPLATE");
|
||||||
SelectReplay(null);
|
|
||||||
|
|
||||||
rl.RemoveChildren();
|
rl.RemoveChildren();
|
||||||
if (Directory.Exists(replayDir))
|
if (Directory.Exists(replayDir))
|
||||||
foreach (var replayFile in Directory.GetFiles(replayDir, "*.rep").Reverse())
|
{
|
||||||
|
var files = Directory.GetFiles(replayDir, "*.rep").Reverse();
|
||||||
|
foreach (var replayFile in files)
|
||||||
AddReplay(rl, replayFile, template);
|
AddReplay(rl, replayFile, template);
|
||||||
|
|
||||||
widget.GetWidget<ButtonWidget>("WATCH_BUTTON").OnClick = () =>
|
SelectReplay(files.FirstOrDefault());
|
||||||
|
}
|
||||||
|
|
||||||
|
var watch = panel.GetWidget<ButtonWidget>("WATCH_BUTTON");
|
||||||
|
watch.IsDisabled = () => currentReplay == null || currentMap == null || currentReplay.Duration == 0;
|
||||||
|
watch.OnClick = () =>
|
||||||
{
|
{
|
||||||
if (currentReplay != null)
|
if (currentReplay != null)
|
||||||
{
|
{
|
||||||
|
Game.JoinReplay(currentReplay.Filename);
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
Game.JoinReplay(currentReplay);
|
onStart();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
widget.GetWidget("REPLAY_INFO").IsVisible = () => currentReplay != null;
|
panel.GetWidget("REPLAY_INFO").IsVisible = () => currentReplay != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
string currentReplay;
|
Replay currentReplay;
|
||||||
|
Map currentMap;
|
||||||
|
|
||||||
void SelectReplay(string filename)
|
void SelectReplay(string filename)
|
||||||
{
|
{
|
||||||
currentReplay = filename;
|
if (filename == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (currentReplay != null)
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var summary = new Replay(currentReplay);
|
currentReplay = new Replay(filename);
|
||||||
var mapStub = summary.Map();
|
currentMap = currentReplay.Map();
|
||||||
|
|
||||||
widget.GetWidget<LabelWidget>("DURATION").GetText =
|
panel.GetWidget<LabelWidget>("DURATION").GetText =
|
||||||
() => WidgetUtils.FormatTime(summary.Duration * 3 /* todo: 3:1 ratio isnt always true. */);
|
() => WidgetUtils.FormatTime(currentReplay.Duration * 3 /* todo: 3:1 ratio isnt always true. */);
|
||||||
widget.GetWidget<MapPreviewWidget>("MAP_PREVIEW").Map = () => mapStub;
|
panel.GetWidget<MapPreviewWidget>("MAP_PREVIEW").Map = () => currentMap;
|
||||||
widget.GetWidget<LabelWidget>("MAP_TITLE").GetText =
|
panel.GetWidget<LabelWidget>("MAP_TITLE").GetText =
|
||||||
() => mapStub != null ? mapStub.Title : "(Unknown Map)";
|
() => currentMap != null ? currentMap.Title : "(Unknown Map)";
|
||||||
|
|
||||||
|
var players = currentReplay.LobbyInfo.Slots
|
||||||
|
.Count(s => currentReplay.LobbyInfo.ClientInSlot(s.Key) != null);
|
||||||
|
panel.GetWidget<LabelWidget>("PLAYERS").GetText = () => players.ToString();
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.Write("debug", "Exception while parsing replay: {0}", e);
|
Log.Write("debug", "Exception while parsing replay: {0}", e);
|
||||||
currentReplay = null;
|
currentReplay = null;
|
||||||
}
|
currentMap = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddReplay(ScrollPanelWidget list, string filename, ScrollItemWidget template)
|
void AddReplay(ScrollPanelWidget list, string filename, ScrollItemWidget template)
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(template,
|
var item = ScrollItemWidget.Setup(template,
|
||||||
() => currentReplay == filename,
|
() => currentReplay != null && currentReplay.Filename == filename,
|
||||||
() => SelectReplay(filename));
|
() => SelectReplay(filename));
|
||||||
var f = Path.GetFileName(filename);
|
var f = Path.GetFileName(filename);
|
||||||
item.GetWidget<LabelWidget>("TITLE").GetText = () => f;
|
item.GetWidget<LabelWidget>("TITLE").GetText = () => f;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
@@ -18,65 +19,88 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
{
|
{
|
||||||
public class ServerBrowserLogic
|
public class ServerBrowserLogic
|
||||||
{
|
{
|
||||||
GameServer currentServer = null;
|
GameServer currentServer;
|
||||||
ScrollItemWidget ServerTemplate;
|
ScrollItemWidget serverTemplate;
|
||||||
|
|
||||||
|
enum SearchStatus { Fetching, Failed, NoGames, Hidden }
|
||||||
|
SearchStatus searchStatus = SearchStatus.Fetching;
|
||||||
|
|
||||||
|
public string ProgressLabelText()
|
||||||
|
{
|
||||||
|
switch (searchStatus)
|
||||||
|
{
|
||||||
|
case SearchStatus.Fetching: return "Fetching game list...";
|
||||||
|
case SearchStatus.Failed: return "Failed to contact master server.";
|
||||||
|
case SearchStatus.NoGames: return "No games found.";
|
||||||
|
default: return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public ServerBrowserLogic(Widget widget)
|
public ServerBrowserLogic(Widget widget, Action openLobby, Action onExit)
|
||||||
{
|
{
|
||||||
var bg = widget.GetWidget("JOINSERVER_BG");
|
var panel = widget;
|
||||||
|
var sl = panel.GetWidget<ScrollPanelWidget>("SERVER_LIST");
|
||||||
|
|
||||||
bg.GetWidget("JOINSERVER_PROGRESS_TITLE").Visible = true;
|
// Menu buttons
|
||||||
bg.GetWidget<LabelWidget>("JOINSERVER_PROGRESS_TITLE").Text = "Fetching game list...";
|
var refreshButton = panel.GetWidget<ButtonWidget>("REFRESH_BUTTON");
|
||||||
|
refreshButton.IsDisabled = () => searchStatus == SearchStatus.Fetching;
|
||||||
ServerList.Query(RefreshServerList);
|
refreshButton.OnClick = () =>
|
||||||
|
|
||||||
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 = () => GenerateModsLabel(currentServer);
|
|
||||||
bg.GetWidget<LabelWidget>("MAP_TITLE").GetText = () => (CurrentMap() != null) ? CurrentMap().Title : "Unknown";
|
|
||||||
bg.GetWidget<LabelWidget>("MAP_PLAYERS").GetText = () =>
|
|
||||||
{
|
{
|
||||||
if (currentServer == null)
|
searchStatus = SearchStatus.Fetching;
|
||||||
return "";
|
|
||||||
string ret = currentServer.Players.ToString();
|
|
||||||
if (CurrentMap() != null)
|
|
||||||
ret += "/" + CurrentMap().PlayerCount.ToString();
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
var sl = bg.GetWidget<ScrollPanelWidget>("SERVER_LIST");
|
|
||||||
ServerTemplate = sl.GetWidget<ScrollItemWidget>("SERVER_TEMPLATE");
|
|
||||||
|
|
||||||
bg.GetWidget<ButtonWidget>("REFRESH_BUTTON").OnClick = () =>
|
|
||||||
{
|
|
||||||
bg.GetWidget("JOINSERVER_PROGRESS_TITLE").Visible = true;
|
|
||||||
bg.GetWidget<LabelWidget>("JOINSERVER_PROGRESS_TITLE").Text = "Fetching game list...";
|
|
||||||
sl.RemoveChildren();
|
sl.RemoveChildren();
|
||||||
currentServer = null;
|
currentServer = null;
|
||||||
|
ServerList.Query(games => RefreshServerList(panel, games));
|
||||||
ServerList.Query(RefreshServerList);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bg.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnClick = () => Widget.CloseWindow();
|
var join = panel.GetWidget<ButtonWidget>("JOIN_BUTTON");
|
||||||
bg.GetWidget<ButtonWidget>("DIRECTCONNECT_BUTTON").OnClick = () =>
|
join.IsDisabled = () => currentServer == null || !currentServer.CanJoin();
|
||||||
{
|
join.OnClick = () =>
|
||||||
Widget.CloseWindow();
|
|
||||||
Widget.OpenWindow("DIRECTCONNECT_BG");
|
|
||||||
};
|
|
||||||
|
|
||||||
bg.GetWidget<ButtonWidget>("JOIN_BUTTON").OnClick = () =>
|
|
||||||
{
|
{
|
||||||
if (currentServer == null)
|
if (currentServer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
var host = currentServer.Address.Split(':')[0];
|
||||||
|
var port = int.Parse(currentServer.Address.Split(':')[1]);
|
||||||
|
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
Game.JoinServer(currentServer.Address.Split(':')[0], int.Parse(currentServer.Address.Split(':')[1]));
|
ConnectionLogic.Connect(host, port, openLobby, onExit);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); };
|
||||||
|
|
||||||
|
// Server list
|
||||||
|
serverTemplate = sl.GetWidget<ScrollItemWidget>("SERVER_TEMPLATE");
|
||||||
|
|
||||||
|
// Display the progress label over the server list
|
||||||
|
// The text is only visible when the list is empty
|
||||||
|
var progressText = panel.GetWidget<LabelWidget>("PROGRESS_LABEL");
|
||||||
|
progressText.IsVisible = () => searchStatus != SearchStatus.Hidden;
|
||||||
|
progressText.GetText = ProgressLabelText;
|
||||||
|
|
||||||
|
// Map preview
|
||||||
|
var preview = panel.GetWidget<MapPreviewWidget>("MAP_PREVIEW");
|
||||||
|
preview.Map = () => CurrentMap();
|
||||||
|
preview.IsVisible = () => CurrentMap() != null;
|
||||||
|
|
||||||
|
// Server info
|
||||||
|
var infoPanel = panel.GetWidget("SERVER_INFO");
|
||||||
|
infoPanel.IsVisible = () => currentServer != null;
|
||||||
|
infoPanel.GetWidget<LabelWidget>("SERVER_IP").GetText = () => currentServer.Address;
|
||||||
|
infoPanel.GetWidget<LabelWidget>("SERVER_MODS").GetText = () => ServerBrowserLogic.GenerateModsLabel(currentServer);
|
||||||
|
infoPanel.GetWidget<LabelWidget>("MAP_TITLE").GetText = () => (CurrentMap() != null) ? CurrentMap().Title : "Unknown";
|
||||||
|
infoPanel.GetWidget<LabelWidget>("MAP_PLAYERS").GetText = () => GetPlayersLabel(currentServer);
|
||||||
|
|
||||||
|
ServerList.Query(games => RefreshServerList(panel, games));
|
||||||
|
}
|
||||||
|
|
||||||
|
string GetPlayersLabel(GameServer game)
|
||||||
|
{
|
||||||
|
if (game == null)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
var map = Game.modData.FindMapByUid(game.Map);
|
||||||
|
return map == null ? "{0}".F(currentServer.Players) : "{0} / {1}".F(currentServer.Players, map.PlayerCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map CurrentMap()
|
Map CurrentMap()
|
||||||
@@ -97,23 +121,16 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
return s.UsefulMods.Select(m => GenerateModLabel(m)).JoinWith("\n");
|
return s.UsefulMods.Select(m => GenerateModLabel(m)).JoinWith("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefreshServerList(IEnumerable<GameServer> games)
|
public void RefreshServerList(Widget panel, IEnumerable<GameServer> games)
|
||||||
{
|
{
|
||||||
var r = Widget.RootWidget;
|
var sl = panel.GetWidget<ScrollPanelWidget>("SERVER_LIST");
|
||||||
var bg = r.GetWidget("JOINSERVER_BG");
|
|
||||||
|
|
||||||
if (bg == null) // We got a MasterServer reply AFTER the browser is gone, just return to prevent crash - Gecko
|
|
||||||
return;
|
|
||||||
|
|
||||||
var sl = bg.GetWidget<ScrollPanelWidget>("SERVER_LIST");
|
|
||||||
|
|
||||||
sl.RemoveChildren();
|
sl.RemoveChildren();
|
||||||
currentServer = null;
|
currentServer = null;
|
||||||
|
|
||||||
if (games == null)
|
if (games == null)
|
||||||
{
|
{
|
||||||
r.GetWidget("JOINSERVER_PROGRESS_TITLE").Visible = true;
|
searchStatus = SearchStatus.Failed;
|
||||||
r.GetWidget<LabelWidget>("JOINSERVER_PROGRESS_TITLE").Text = "Failed to contact master server.";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,22 +138,28 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
if (gamesWaiting.Count() == 0)
|
if (gamesWaiting.Count() == 0)
|
||||||
{
|
{
|
||||||
r.GetWidget("JOINSERVER_PROGRESS_TITLE").Visible = true;
|
searchStatus = SearchStatus.NoGames;
|
||||||
r.GetWidget<LabelWidget>("JOINSERVER_PROGRESS_TITLE").Text = "No games found.";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
r.GetWidget("JOINSERVER_PROGRESS_TITLE").Visible = false;
|
searchStatus = SearchStatus.Hidden;
|
||||||
|
|
||||||
currentServer = gamesWaiting.FirstOrDefault();
|
currentServer = gamesWaiting.FirstOrDefault();
|
||||||
|
|
||||||
foreach (var loop in gamesWaiting)
|
foreach (var loop in gamesWaiting)
|
||||||
{
|
{
|
||||||
var game = loop;
|
var game = loop;
|
||||||
var item = ScrollItemWidget.Setup(ServerTemplate,
|
|
||||||
() => currentServer == game,
|
var item = ScrollItemWidget.Setup(serverTemplate, () => currentServer == game, () => currentServer = game);
|
||||||
() => currentServer = game);
|
item.GetWidget<LabelWidget>("TITLE").GetText = () => game.Name;
|
||||||
item.GetWidget<LabelWidget>("TITLE").GetText = () => "{0} ({1})".F(game.Name, game.Address);
|
// TODO: Use game.MapTitle once the server supports it
|
||||||
|
item.GetWidget<LabelWidget>("MAP").GetText = () =>
|
||||||
|
{
|
||||||
|
var map = Game.modData.FindMapByUid(game.Map);
|
||||||
|
return map == null ? "Unknown" : map.Title;
|
||||||
|
};
|
||||||
|
// TODO: Use game.MaxPlayers once the server supports it
|
||||||
|
item.GetWidget<LabelWidget>("PLAYERS").GetText = () => GetPlayersLabel(game);
|
||||||
|
item.GetWidget<LabelWidget>("IP").GetText = () => game.Address;
|
||||||
sl.AddChild(item);
|
sl.AddChild(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ using System.Net;
|
|||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
namespace OpenRA.Mods.RA.Widgets.Logic
|
||||||
{
|
{
|
||||||
public class CncServerCreationLogic
|
public class ServerCreationLogic
|
||||||
{
|
{
|
||||||
Widget panel;
|
Widget panel;
|
||||||
Action onCreate;
|
Action onCreate;
|
||||||
@@ -24,9 +24,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
bool advertiseOnline;
|
bool advertiseOnline;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public CncServerCreationLogic(Widget widget, Action onExit, Action openLobby)
|
public ServerCreationLogic(Widget widget, Action onExit, Action openLobby)
|
||||||
{
|
{
|
||||||
panel = widget.GetWidget("CREATESERVER_PANEL");
|
panel = widget;
|
||||||
onCreate = openLobby;
|
onCreate = openLobby;
|
||||||
this.onExit = onExit;
|
this.onExit = onExit;
|
||||||
|
|
||||||
@@ -34,6 +34,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); };
|
panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); };
|
||||||
panel.GetWidget<ButtonWidget>("CREATE_BUTTON").OnClick = CreateAndJoin;
|
panel.GetWidget<ButtonWidget>("CREATE_BUTTON").OnClick = CreateAndJoin;
|
||||||
|
|
||||||
|
map = Game.modData.AvailableMaps[ WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map) ];
|
||||||
|
|
||||||
|
var mapButton = panel.GetWidget<ButtonWidget>("MAP_BUTTON");
|
||||||
|
if (mapButton != null)
|
||||||
|
{
|
||||||
panel.GetWidget<ButtonWidget>("MAP_BUTTON").OnClick = () =>
|
panel.GetWidget<ButtonWidget>("MAP_BUTTON").OnClick = () =>
|
||||||
{
|
{
|
||||||
Widget.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs()
|
Widget.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs()
|
||||||
@@ -44,10 +49,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
map = Game.modData.AvailableMaps[ WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map) ];
|
|
||||||
|
|
||||||
panel.GetWidget<MapPreviewWidget>("MAP_PREVIEW").Map = () => map;
|
panel.GetWidget<MapPreviewWidget>("MAP_PREVIEW").Map = () => map;
|
||||||
panel.GetWidget<LabelWidget>("MAP_NAME").GetText = () => map.Title;
|
panel.GetWidget<LabelWidget>("MAP_NAME").GetText = () => map.Title;
|
||||||
|
}
|
||||||
|
|
||||||
panel.GetWidget<TextFieldWidget>("SERVER_NAME").Text = settings.Server.Name ?? "";
|
panel.GetWidget<TextFieldWidget>("SERVER_NAME").Text = settings.Server.Name ?? "";
|
||||||
panel.GetWidget<TextFieldWidget>("LISTEN_PORT").Text = settings.Server.ListenPort.ToString();
|
panel.GetWidget<TextFieldWidget>("LISTEN_PORT").Text = settings.Server.ListenPort.ToString();
|
||||||
@@ -60,10 +64,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
var advertiseCheckbox = panel.GetWidget<CheckboxWidget>("ADVERTISE_CHECKBOX");
|
var advertiseCheckbox = panel.GetWidget<CheckboxWidget>("ADVERTISE_CHECKBOX");
|
||||||
advertiseCheckbox.IsChecked = () => advertiseOnline;
|
advertiseCheckbox.IsChecked = () => advertiseOnline;
|
||||||
advertiseCheckbox.OnClick = () => advertiseOnline ^= true;
|
advertiseCheckbox.OnClick = () => advertiseOnline ^= true;
|
||||||
|
|
||||||
// Disable these until we have some logic behind them
|
|
||||||
panel.GetWidget<TextFieldWidget>("SERVER_DESC").IsDisabled = () => true;
|
|
||||||
panel.GetWidget<TextFieldWidget>("SERVER_PASSWORD").IsDisabled = () => true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateAndJoin()
|
void CreateAndJoin()
|
||||||
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
// Create and join the server
|
// Create and join the server
|
||||||
Game.CreateServer(settings);
|
Game.CreateServer(settings);
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
CncConnectionLogic.Connect(IPAddress.Loopback.ToString(), Game.Settings.Server.ListenPort, onCreate, onExit);
|
ConnectionLogic.Connect(IPAddress.Loopback.ToString(), Game.Settings.Server.ListenPort, onCreate, onExit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
Container@CONNECTING_PANEL:
|
Container@CONNECTING_PANEL:
|
||||||
Id:CONNECTING_PANEL
|
Id:CONNECTING_PANEL
|
||||||
Logic:CncConnectionLogic
|
Logic:ConnectionLogic
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
Y:(WINDOW_BOTTOM - 90)/2
|
Y:(WINDOW_BOTTOM - 90)/2
|
||||||
Width:370
|
Width:370
|
||||||
@@ -37,7 +37,7 @@ Container@CONNECTING_PANEL:
|
|||||||
|
|
||||||
Container@CONNECTIONFAILED_PANEL:
|
Container@CONNECTIONFAILED_PANEL:
|
||||||
Id:CONNECTIONFAILED_PANEL
|
Id:CONNECTIONFAILED_PANEL
|
||||||
Logic:CncConnectionFailedLogic
|
Logic:ConnectionFailedLogic
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
Y:(WINDOW_BOTTOM - 90)/2
|
Y:(WINDOW_BOTTOM - 90)/2
|
||||||
Width:370
|
Width:370
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
# TODO: Hook up the description field
|
|
||||||
# TODO: Hook up the password field
|
|
||||||
# TODO: Have the advertise checkbox en/disable the external port textfield
|
|
||||||
Container@CREATESERVER_PANEL:
|
Container@CREATESERVER_PANEL:
|
||||||
Id:CREATESERVER_PANEL
|
Id:CREATESERVER_PANEL
|
||||||
Logic:CncServerCreationLogic
|
Logic:ServerCreationLogic
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
Y:(WINDOW_BOTTOM - 260)/2
|
Y:(WINDOW_BOTTOM - 260)/2
|
||||||
Width:604
|
Width:604
|
||||||
@@ -57,34 +54,6 @@ Container@CREATESERVER_PANEL:
|
|||||||
MaxLength:50
|
MaxLength:50
|
||||||
Height:25
|
Height:25
|
||||||
Text:My OpenRA Server
|
Text:My OpenRA Server
|
||||||
Label@SERVER_DESC_LABEL:
|
|
||||||
X:15
|
|
||||||
Y:49
|
|
||||||
Width:90
|
|
||||||
Height:25
|
|
||||||
Align:Right
|
|
||||||
Text:Description:
|
|
||||||
TextField@SERVER_DESC:
|
|
||||||
Id:SERVER_DESC
|
|
||||||
X:110
|
|
||||||
Y:50
|
|
||||||
Width:275
|
|
||||||
MaxLength:50
|
|
||||||
Height:25
|
|
||||||
Label@SERVER_PASSWORD_LABEL:
|
|
||||||
X:15
|
|
||||||
Y:84
|
|
||||||
Width:90
|
|
||||||
Height:25
|
|
||||||
Align:Right
|
|
||||||
Text:Password:
|
|
||||||
TextField@SERVER_PASSWORD:
|
|
||||||
Id:SERVER_PASSWORD
|
|
||||||
X:110
|
|
||||||
Y:85
|
|
||||||
Width:275
|
|
||||||
MaxLength:50
|
|
||||||
Height:25
|
|
||||||
Label@LISTEN_PORT_LABEL:
|
Label@LISTEN_PORT_LABEL:
|
||||||
X:15
|
X:15
|
||||||
Y:119
|
Y:119
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Container@DIRECTCONNECT_PANEL:
|
Container@DIRECTCONNECT_PANEL:
|
||||||
Id:DIRECTCONNECT_PANEL
|
Id:DIRECTCONNECT_PANEL
|
||||||
Logic:CncDirectConnectLogic
|
Logic:DirectConnectLogic
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
Y:(WINDOW_BOTTOM - 90)/2
|
Y:(WINDOW_BOTTOM - 90)/2
|
||||||
Width:370
|
Width:370
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Container@SERVER_LOBBY:
|
Container@SERVER_LOBBY:
|
||||||
Id:SERVER_LOBBY
|
Id:SERVER_LOBBY
|
||||||
Logic:CncLobbyLogic
|
Logic:LobbyLogic
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
Y:(WINDOW_BOTTOM - 500)/2
|
Y:(WINDOW_BOTTOM - 500)/2
|
||||||
Width:740
|
Width:740
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Container@MODS_PANEL:
|
Container@MODS_PANEL:
|
||||||
Id:MODS_PANEL
|
Id:MODS_PANEL
|
||||||
Logic:CncModBrowserLogic
|
Logic:ModBrowserLogic
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
Y:(WINDOW_BOTTOM - 500)/2
|
Y:(WINDOW_BOTTOM - 500)/2
|
||||||
Width:740
|
Width:740
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Container@REPLAYBROWSER_PANEL:
|
Container@REPLAYBROWSER_PANEL:
|
||||||
Id:REPLAYBROWSER_PANEL
|
Id:REPLAYBROWSER_PANEL
|
||||||
Logic:CncReplayBrowserLogic
|
Logic:ReplayBrowserLogic
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
Y:(WINDOW_BOTTOM - 300)/2
|
Y:(WINDOW_BOTTOM - 300)/2
|
||||||
Width:520
|
Width:520
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Container@SERVERBROWSER_PANEL:
|
Container@SERVERBROWSER_PANEL:
|
||||||
Id:SERVERBROWSER_PANEL
|
Id:SERVERBROWSER_PANEL
|
||||||
Logic:CncServerBrowserLogic
|
Logic:ServerBrowserLogic
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
Y:(WINDOW_BOTTOM - 500)/2
|
Y:(WINDOW_BOTTOM - 500)/2
|
||||||
Width:740
|
Width:740
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Background@CREATESERVER_BG:
|
Background@CREATESERVER_BG:
|
||||||
Id:CREATESERVER_BG
|
Id:CREATESERVER_BG
|
||||||
Logic:CreateServerMenuLogic
|
Logic:ServerCreationLogic
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||||
Width:400
|
Width:400
|
||||||
@@ -15,16 +15,16 @@ Background@CREATESERVER_BG:
|
|||||||
Text:Create Server
|
Text:Create Server
|
||||||
Align:Center
|
Align:Center
|
||||||
Font:Bold
|
Font:Bold
|
||||||
Label@GAME_TITLE_LABEL:
|
Label@SERVER_NAME_LABEL:
|
||||||
Id:GAME_TITLE_LABEL
|
Id:SERVER_NAME_LABEL
|
||||||
X:50
|
X:50
|
||||||
Y:59
|
Y:59
|
||||||
Width:95
|
Width:95
|
||||||
Height:25
|
Height:25
|
||||||
Align: Right
|
Align: Right
|
||||||
Text:Game Title:
|
Text:Game Title:
|
||||||
TextField@GAME_TITLE:
|
TextField@SERVER_NAME:
|
||||||
Id:GAME_TITLE
|
Id:SERVER_NAME
|
||||||
X:150
|
X:150
|
||||||
Y:60
|
Y:60
|
||||||
Width:210
|
Width:210
|
||||||
@@ -62,15 +62,15 @@ Background@CREATESERVER_BG:
|
|||||||
Width:50
|
Width:50
|
||||||
MaxLength:5
|
MaxLength:5
|
||||||
Height:25
|
Height:25
|
||||||
Checkbox@CHECKBOX_ONLINE:
|
Checkbox@ADVERTISE_CHECKBOX:
|
||||||
Id:CHECKBOX_ONLINE
|
Id:ADVERTISE_CHECKBOX
|
||||||
X:165
|
X:165
|
||||||
Y:130
|
Y:130
|
||||||
Width:300
|
Width:300
|
||||||
Height:20
|
Height:20
|
||||||
Text:Advertise game Online
|
Text:Advertise game Online
|
||||||
Button@BUTTON_START:
|
Button@CREATE_BUTTON:
|
||||||
Id:BUTTON_START
|
Id:CREATE_BUTTON
|
||||||
X:130
|
X:130
|
||||||
Y:PARENT_BOTTOM - 45
|
Y:PARENT_BOTTOM - 45
|
||||||
Width:120
|
Width:120
|
||||||
@@ -78,8 +78,8 @@ Background@CREATESERVER_BG:
|
|||||||
Text:Create
|
Text:Create
|
||||||
Font:Bold
|
Font:Bold
|
||||||
Key:return
|
Key:return
|
||||||
Button@BUTTON_CANCEL:
|
Button@BACK_BUTTON:
|
||||||
Id:BUTTON_CANCEL
|
Id:BACK_BUTTON
|
||||||
X:260
|
X:260
|
||||||
Y:PARENT_BOTTOM - 45
|
Y:PARENT_BOTTOM - 45
|
||||||
Width:120
|
Width:120
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ Background@SERVER_LOBBY:
|
|||||||
Width:800
|
Width:800
|
||||||
Height:600
|
Height:600
|
||||||
Children:
|
Children:
|
||||||
Label@LOBBY_TITLE:
|
Label@TITLE:
|
||||||
Id:LOBBY_TITLE
|
Id:TITLE
|
||||||
X:0
|
X:0
|
||||||
Y:17
|
Y:17
|
||||||
Align:Center
|
Align:Center
|
||||||
@@ -22,8 +22,8 @@ Background@SERVER_LOBBY:
|
|||||||
Height:252
|
Height:252
|
||||||
Background:dialog3
|
Background:dialog3
|
||||||
Children:
|
Children:
|
||||||
MapPreview@LOBBY_MAP_PREVIEW:
|
MapPreview@MAP_PREVIEW:
|
||||||
Id:LOBBY_MAP_PREVIEW
|
Id:MAP_PREVIEW
|
||||||
X:4
|
X:4
|
||||||
Y:4
|
Y:4
|
||||||
Width:244
|
Width:244
|
||||||
@@ -36,8 +36,8 @@ Background@SERVER_LOBBY:
|
|||||||
Width:504
|
Width:504
|
||||||
Height:235
|
Height:235
|
||||||
Children:
|
Children:
|
||||||
Container@TEMPLATE_LOCAL:
|
Container@TEMPLATE_EDITABLE_PLAYER:
|
||||||
Id:TEMPLATE_LOCAL
|
Id:TEMPLATE_EDITABLE_PLAYER
|
||||||
X:5
|
X:5
|
||||||
Y:0
|
Y:0
|
||||||
Width:475
|
Width:475
|
||||||
@@ -99,14 +99,25 @@ Background@SERVER_LOBBY:
|
|||||||
Height:25
|
Height:25
|
||||||
X:390
|
X:390
|
||||||
Y:0
|
Y:0
|
||||||
Checkbox@STATUS:
|
Checkbox@STATUS_CHECKBOX:
|
||||||
Id:STATUS
|
Id:STATUS_CHECKBOX
|
||||||
X:448
|
X:448
|
||||||
Y:2
|
Y:2
|
||||||
Width:20
|
Width:20
|
||||||
Height:20
|
Height:20
|
||||||
Container@TEMPLATE_REMOTE:
|
Visible:false
|
||||||
Id:TEMPLATE_REMOTE
|
Image@STATUS_IMAGE:
|
||||||
|
Id:STATUS_IMAGE
|
||||||
|
Visible:false
|
||||||
|
X:450
|
||||||
|
Y:4
|
||||||
|
Width:20
|
||||||
|
Height:20
|
||||||
|
ImageCollection:checkbox-bits
|
||||||
|
ImageName:checked
|
||||||
|
Visible:false
|
||||||
|
Container@TEMPLATE_NONEDITABLE_PLAYER:
|
||||||
|
Id:TEMPLATE_NONEDITABLE_PLAYER
|
||||||
X:5
|
X:5
|
||||||
Y:0
|
Y:0
|
||||||
Width:475
|
Width:475
|
||||||
@@ -162,12 +173,16 @@ Background@SERVER_LOBBY:
|
|||||||
Align:Center
|
Align:Center
|
||||||
X:390
|
X:390
|
||||||
Y:0
|
Y:0
|
||||||
Checkbox@STATUS:
|
Image@STATUS_IMAGE:
|
||||||
Id:STATUS
|
Id:STATUS_IMAGE
|
||||||
X:448
|
Visible:false
|
||||||
Y:2
|
X:450
|
||||||
|
Y:4
|
||||||
Width:20
|
Width:20
|
||||||
Height:20
|
Height:20
|
||||||
|
ImageCollection:checkbox-bits
|
||||||
|
ImageName:checked
|
||||||
|
|
||||||
Container@TEMPLATE_EMPTY:
|
Container@TEMPLATE_EMPTY:
|
||||||
Id:TEMPLATE_EMPTY
|
Id:TEMPLATE_EMPTY
|
||||||
X:5
|
X:5
|
||||||
@@ -183,28 +198,14 @@ Background@SERVER_LOBBY:
|
|||||||
Height:25
|
Height:25
|
||||||
X:5
|
X:5
|
||||||
Y:0-1
|
Y:0-1
|
||||||
Button@JOIN:
|
DropDownButton@NAME_HOST:
|
||||||
Id:JOIN
|
Id:NAME_HOST
|
||||||
Text:Play in this slot
|
|
||||||
Width:278
|
|
||||||
Height:25
|
|
||||||
X:160
|
|
||||||
Y:0
|
|
||||||
Container@TEMPLATE_EMPTY_HOST:
|
|
||||||
Id:TEMPLATE_EMPTY_HOST
|
|
||||||
X:5
|
|
||||||
Y:0
|
|
||||||
Width:400
|
|
||||||
Height:25
|
|
||||||
Visible:false
|
|
||||||
Children:
|
|
||||||
DropDownButton@NAME:
|
|
||||||
Id:NAME
|
|
||||||
Text:Name
|
Text:Name
|
||||||
Width:150
|
Width:150
|
||||||
Height:25
|
Height:25
|
||||||
X:0
|
X:0
|
||||||
Y:0
|
Y:0
|
||||||
|
Visible:false
|
||||||
Button@JOIN:
|
Button@JOIN:
|
||||||
Id:JOIN
|
Id:JOIN
|
||||||
Text:Play in this slot
|
Text:Play in this slot
|
||||||
@@ -212,8 +213,8 @@ Background@SERVER_LOBBY:
|
|||||||
Height:25
|
Height:25
|
||||||
X:160
|
X:160
|
||||||
Y:0
|
Y:0
|
||||||
Container@TEMPLATE_LOCAL_SPECTATOR:
|
Container@TEMPLATE_EDITABLE_SPECTATOR:
|
||||||
Id:TEMPLATE_LOCAL_SPECTATOR
|
Id:TEMPLATE_EDITABLE_SPECTATOR
|
||||||
X:5
|
X:5
|
||||||
Y:0
|
Y:0
|
||||||
Width:475
|
Width:475
|
||||||
@@ -247,14 +248,24 @@ Background@SERVER_LOBBY:
|
|||||||
Y:0
|
Y:0
|
||||||
Align:Center
|
Align:Center
|
||||||
Font:Bold
|
Font:Bold
|
||||||
Checkbox@STATUS:
|
Checkbox@STATUS_CHECKBOX:
|
||||||
Id:STATUS
|
Id:STATUS_CHECKBOX
|
||||||
X:448
|
X:448
|
||||||
Y:2
|
Y:2
|
||||||
Width:20
|
Width:20
|
||||||
Height:20
|
Height:20
|
||||||
Container@TEMPLATE_REMOTE_SPECTATOR:
|
Image@STATUS_IMAGE:
|
||||||
Id:TEMPLATE_REMOTE_SPECTATOR
|
Id:STATUS_IMAGE
|
||||||
|
Visible:false
|
||||||
|
X:450
|
||||||
|
Y:4
|
||||||
|
Width:20
|
||||||
|
Height:20
|
||||||
|
ImageCollection:checkbox-bits
|
||||||
|
ImageName:checked
|
||||||
|
|
||||||
|
Container@TEMPLATE_NONEDITABLE_SPECTATOR:
|
||||||
|
Id:TEMPLATE_NONEDITABLE_SPECTATOR
|
||||||
X:5
|
X:5
|
||||||
Y:0
|
Y:0
|
||||||
Width:475
|
Width:475
|
||||||
@@ -290,12 +301,15 @@ Background@SERVER_LOBBY:
|
|||||||
Y:0
|
Y:0
|
||||||
Align:Center
|
Align:Center
|
||||||
Font:Bold
|
Font:Bold
|
||||||
Checkbox@STATUS:
|
Image@STATUS_IMAGE:
|
||||||
Id:STATUS
|
Id:STATUS_IMAGE
|
||||||
X:448
|
Visible:false
|
||||||
Y:2
|
X:450
|
||||||
|
Y:4
|
||||||
Width:20
|
Width:20
|
||||||
Height:20
|
Height:20
|
||||||
|
ImageCollection:checkbox-bits
|
||||||
|
ImageName:checked
|
||||||
Container@TEMPLATE_NEW_SPECTATOR:
|
Container@TEMPLATE_NEW_SPECTATOR:
|
||||||
Id:TEMPLATE_NEW_SPECTATOR
|
Id:TEMPLATE_NEW_SPECTATOR
|
||||||
X:5
|
X:5
|
||||||
@@ -369,13 +383,40 @@ Background@SERVER_LOBBY:
|
|||||||
Height:25
|
Height:25
|
||||||
Text:Change Map
|
Text:Change Map
|
||||||
Font:Bold
|
Font:Bold
|
||||||
ChatDisplay@CHAT_DISPLAY:
|
ScrollPanel@CHAT_DISPLAY:
|
||||||
Id:CHAT_DISPLAY
|
Id:CHAT_DISPLAY
|
||||||
X:20
|
X:20
|
||||||
Notification: rabeep1.aud
|
|
||||||
Height:230
|
|
||||||
Y:PARENT_BOTTOM - 289
|
Y:PARENT_BOTTOM - 289
|
||||||
Width:PARENT_RIGHT - 200
|
Width:PARENT_RIGHT - 200
|
||||||
|
Height:230
|
||||||
|
ItemSpacing:1
|
||||||
|
Children:
|
||||||
|
Container@CHAT_TEMPLATE:
|
||||||
|
Id:CHAT_TEMPLATE
|
||||||
|
Width:PARENT_RIGHT-27
|
||||||
|
Height:16
|
||||||
|
X:2
|
||||||
|
Y:0
|
||||||
|
Children:
|
||||||
|
Label@TIME:
|
||||||
|
Id:TIME
|
||||||
|
X:3
|
||||||
|
Width:50
|
||||||
|
Height:15
|
||||||
|
VAlign:Top
|
||||||
|
Label@NAME:
|
||||||
|
Id:NAME
|
||||||
|
X:45
|
||||||
|
Width:50
|
||||||
|
Height:15
|
||||||
|
VAlign:Top
|
||||||
|
Label@TEXT:
|
||||||
|
Id:TEXT
|
||||||
|
X:55
|
||||||
|
Width:PARENT_RIGHT - 60
|
||||||
|
Height:15
|
||||||
|
WordWrap:true
|
||||||
|
VAlign:Top
|
||||||
Label@LABEL_CHATTYPE:
|
Label@LABEL_CHATTYPE:
|
||||||
Id:LABEL_CHATTYPE
|
Id:LABEL_CHATTYPE
|
||||||
Width:65
|
Width:65
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ Background@MAINMENU_BG:
|
|||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||||
Width:250
|
Width:250
|
||||||
Height:330
|
Height:420
|
||||||
Visible:true
|
Visible:true
|
||||||
Logic:MainMenuButtonsLogic
|
Logic:MainMenuButtonsLogic
|
||||||
Children:
|
Children:
|
||||||
@@ -32,18 +32,34 @@ Background@MAINMENU_BG:
|
|||||||
Height:25
|
Height:25
|
||||||
Text:Create Game
|
Text:Create Game
|
||||||
Font:Bold
|
Font:Bold
|
||||||
Button@MAINMENU_BUTTON_SETTINGS:
|
Button@MAINMENU_BUTTON_DIRECTCONNECT:
|
||||||
Id:MAINMENU_BUTTON_SETTINGS
|
Id:MAINMENU_BUTTON_DIRECTCONNECT
|
||||||
X:45
|
X:45
|
||||||
Y:150
|
Y:150
|
||||||
Width:160
|
Width:160
|
||||||
Height:25
|
Height:25
|
||||||
|
Text:Direct Connect
|
||||||
|
Font:Bold
|
||||||
|
Button@MAINMENU_BUTTON_SETTINGS:
|
||||||
|
Id:MAINMENU_BUTTON_SETTINGS
|
||||||
|
X:45
|
||||||
|
Y:190
|
||||||
|
Width:160
|
||||||
|
Height:25
|
||||||
Text:Settings
|
Text:Settings
|
||||||
Font:Bold
|
Font:Bold
|
||||||
|
Button@MAINMENU_BUTTON_MODS:
|
||||||
|
Id:MAINMENU_BUTTON_MODS
|
||||||
|
X:45
|
||||||
|
Y:230
|
||||||
|
Width:160
|
||||||
|
Height:25
|
||||||
|
Text:Mods
|
||||||
|
Font:Bold
|
||||||
Button@MAINMENU_BUTTON_MUSIC:
|
Button@MAINMENU_BUTTON_MUSIC:
|
||||||
Id:MAINMENU_BUTTON_MUSIC
|
Id:MAINMENU_BUTTON_MUSIC
|
||||||
X:45
|
X:45
|
||||||
Y:190
|
Y:270
|
||||||
Width:160
|
Width:160
|
||||||
Height:25
|
Height:25
|
||||||
Text:Music
|
Text:Music
|
||||||
@@ -51,7 +67,7 @@ Background@MAINMENU_BG:
|
|||||||
Button@MAINMENU_BUTTON_REPLAY_VIEWER:
|
Button@MAINMENU_BUTTON_REPLAY_VIEWER:
|
||||||
Id:MAINMENU_BUTTON_REPLAY_VIEWER
|
Id:MAINMENU_BUTTON_REPLAY_VIEWER
|
||||||
X:45
|
X:45
|
||||||
Y:230
|
Y:310
|
||||||
Width:160
|
Width:160
|
||||||
Height:25
|
Height:25
|
||||||
Text:Replay Viewer
|
Text:Replay Viewer
|
||||||
@@ -59,42 +75,11 @@ Background@MAINMENU_BG:
|
|||||||
Button@MAINMENU_BUTTON_QUIT:
|
Button@MAINMENU_BUTTON_QUIT:
|
||||||
Id:MAINMENU_BUTTON_QUIT
|
Id:MAINMENU_BUTTON_QUIT
|
||||||
X:45
|
X:45
|
||||||
Y:270
|
Y:350
|
||||||
Width:160
|
Width:160
|
||||||
Height:25
|
Height:25
|
||||||
Text:Quit
|
Text:Quit
|
||||||
Font:Bold
|
Font:Bold
|
||||||
Background@QUICKMODSWITCHER:
|
|
||||||
Id:QUICKMODSWITCHER
|
|
||||||
Background: dialog4
|
|
||||||
X:(WINDOW_RIGHT - PARENT_LEFT - WIDTH - 10)
|
|
||||||
Y:10 - PARENT_TOP
|
|
||||||
Width:205
|
|
||||||
Height:65
|
|
||||||
Children:
|
|
||||||
Label@TITLE:
|
|
||||||
X:8
|
|
||||||
Y:3
|
|
||||||
Width:PARENT_RIGHT
|
|
||||||
Height:25
|
|
||||||
Text:Mod:
|
|
||||||
Align:Left
|
|
||||||
Font:Bold
|
|
||||||
DropDownButton@SWITCHER:
|
|
||||||
Id:SWITCHER
|
|
||||||
Text:Team
|
|
||||||
Width:150
|
|
||||||
Height:25
|
|
||||||
X:50
|
|
||||||
Y:5
|
|
||||||
Label@VERSION:
|
|
||||||
Id:VERSION
|
|
||||||
X:50
|
|
||||||
Y:30
|
|
||||||
Width:150
|
|
||||||
Height:25
|
|
||||||
Align:Center
|
|
||||||
Font:Bold
|
|
||||||
Background@PERF_BG:
|
Background@PERF_BG:
|
||||||
ClickThrough:true
|
ClickThrough:true
|
||||||
Id:PERF_BG
|
Id:PERF_BG
|
||||||
|
|||||||
92
mods/ra/chrome/modchooser.yaml
Normal file
92
mods/ra/chrome/modchooser.yaml
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
Background@MODS_PANEL:
|
||||||
|
Logic:ModBrowserLogic
|
||||||
|
Id:MODS_PANEL
|
||||||
|
Width:740
|
||||||
|
Height:500
|
||||||
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
|
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||||
|
Children:
|
||||||
|
Label@TITLE:
|
||||||
|
Text:Select Mod
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Y:20
|
||||||
|
Font:Bold
|
||||||
|
Align:Center
|
||||||
|
ScrollPanel@MOD_LIST:
|
||||||
|
Id:MOD_LIST
|
||||||
|
X:15
|
||||||
|
Y:70
|
||||||
|
Width:710
|
||||||
|
Height:PARENT_BOTTOM - 125
|
||||||
|
Children:
|
||||||
|
ScrollItem@MOD_TEMPLATE:
|
||||||
|
Id:MOD_TEMPLATE
|
||||||
|
Width:PARENT_RIGHT-27
|
||||||
|
Height:25
|
||||||
|
X:2
|
||||||
|
Y:0
|
||||||
|
Visible:false
|
||||||
|
Children:
|
||||||
|
Label@TITLE:
|
||||||
|
X:10
|
||||||
|
Id:TITLE
|
||||||
|
Width:200
|
||||||
|
Height:25
|
||||||
|
Label@AUTHOR:
|
||||||
|
Id:AUTHOR
|
||||||
|
X:PARENT_RIGHT-300
|
||||||
|
Align:Center
|
||||||
|
Width:50
|
||||||
|
Height:25
|
||||||
|
Label@VERSION:
|
||||||
|
Id:VERSION
|
||||||
|
Width:140
|
||||||
|
X:PARENT_RIGHT-150
|
||||||
|
Align:Center
|
||||||
|
Height:25
|
||||||
|
Container@MOD_LABELS:
|
||||||
|
Width:710-25
|
||||||
|
Height:25
|
||||||
|
X:15
|
||||||
|
Y:45
|
||||||
|
Children:
|
||||||
|
Label@TITLE:
|
||||||
|
Width:125
|
||||||
|
Height:25
|
||||||
|
X:0
|
||||||
|
Y:0
|
||||||
|
Text:Title
|
||||||
|
Align:Center
|
||||||
|
Font:Bold
|
||||||
|
Label@AUTHOR:
|
||||||
|
X:PARENT_RIGHT-300
|
||||||
|
Align:Center
|
||||||
|
Width:50
|
||||||
|
Height:25
|
||||||
|
Text:Author
|
||||||
|
Font:Bold
|
||||||
|
Label@VERSION:
|
||||||
|
Width:140
|
||||||
|
X:PARENT_RIGHT-150
|
||||||
|
Align:Center
|
||||||
|
Height:25
|
||||||
|
Text:Version
|
||||||
|
Font:Bold
|
||||||
|
Button@BACK_BUTTON:
|
||||||
|
Id:BACK_BUTTON
|
||||||
|
Key:escape
|
||||||
|
X:PARENT_RIGHT-180
|
||||||
|
Y:PARENT_BOTTOM-45
|
||||||
|
Width:160
|
||||||
|
Height:25
|
||||||
|
Font:Bold
|
||||||
|
Text:Cancel
|
||||||
|
Button@LOAD_BUTTON:
|
||||||
|
Id:LOAD_BUTTON
|
||||||
|
Key:return
|
||||||
|
X:PARENT_RIGHT-360
|
||||||
|
Y:PARENT_BOTTOM-45
|
||||||
|
Width:160
|
||||||
|
Height:25
|
||||||
|
Font:Bold
|
||||||
|
Text:Load Mod
|
||||||
@@ -81,6 +81,22 @@ Background@REPLAYBROWSER_BG:
|
|||||||
Align:Left
|
Align:Left
|
||||||
Width:70
|
Width:70
|
||||||
Height:20
|
Height:20
|
||||||
|
Label@PLAYERS_LABEL:
|
||||||
|
Id:PLAYERS_LABEL
|
||||||
|
X:PARENT_RIGHT - 200 - WIDTH
|
||||||
|
Y:290
|
||||||
|
Align:Right
|
||||||
|
Width:70
|
||||||
|
Height:20
|
||||||
|
Text:Players:
|
||||||
|
Font:Bold
|
||||||
|
Label@PLAYERS:
|
||||||
|
Id:PLAYERS
|
||||||
|
X:PARENT_RIGHT - 195
|
||||||
|
Y:290
|
||||||
|
Align:Left
|
||||||
|
Width:70
|
||||||
|
Height:20
|
||||||
Button@WATCH_BUTTON:
|
Button@WATCH_BUTTON:
|
||||||
Id:WATCH_BUTTON
|
Id:WATCH_BUTTON
|
||||||
X:PARENT_RIGHT - 140 - 130
|
X:PARENT_RIGHT - 140 - 130
|
||||||
|
|||||||
@@ -34,8 +34,19 @@ Background@JOINSERVER_BG:
|
|||||||
Id:TITLE
|
Id:TITLE
|
||||||
Width:200
|
Width:200
|
||||||
Height:25
|
Height:25
|
||||||
Label@JOINSERVER_PROGRESS_TITLE:
|
Label@MAP:
|
||||||
Id:JOINSERVER_PROGRESS_TITLE
|
Id:MAP
|
||||||
|
X:210
|
||||||
|
Width:100
|
||||||
|
Height:25
|
||||||
|
Label@PLAYERS:
|
||||||
|
Id:PLAYERS
|
||||||
|
Visible:False
|
||||||
|
Label@IP:
|
||||||
|
Id:IP
|
||||||
|
Visible:False
|
||||||
|
Label@PROGRESS_LABEL:
|
||||||
|
Id:PROGRESS_LABEL
|
||||||
X:150
|
X:150
|
||||||
Y:PARENT_BOTTOM / 2 - HEIGHT
|
Y:PARENT_BOTTOM / 2 - HEIGHT
|
||||||
Width:150
|
Width:150
|
||||||
@@ -121,17 +132,9 @@ Background@JOINSERVER_BG:
|
|||||||
VAlign:Top
|
VAlign:Top
|
||||||
Width:70
|
Width:70
|
||||||
Height:20
|
Height:20
|
||||||
Button@DIRECTCONNECT_BUTTON:
|
|
||||||
Id:DIRECTCONNECT_BUTTON
|
|
||||||
X:20
|
|
||||||
Y:PARENT_BOTTOM - 45
|
|
||||||
Width:120
|
|
||||||
Height:25
|
|
||||||
Text:Direct Connect
|
|
||||||
Font:Bold
|
|
||||||
Button@REFRESH_BUTTON:
|
Button@REFRESH_BUTTON:
|
||||||
Id:REFRESH_BUTTON
|
Id:REFRESH_BUTTON
|
||||||
X:160
|
X:20
|
||||||
Y:PARENT_BOTTOM - 45
|
Y:PARENT_BOTTOM - 45
|
||||||
Width:120
|
Width:120
|
||||||
Height:25
|
Height:25
|
||||||
@@ -146,8 +149,8 @@ Background@JOINSERVER_BG:
|
|||||||
Text:Join
|
Text:Join
|
||||||
Font:Bold
|
Font:Bold
|
||||||
Key:return
|
Key:return
|
||||||
Button@CANCEL_BUTTON:
|
Button@BACK_BUTTON:
|
||||||
Id:CANCEL_BUTTON
|
Id:BACK_BUTTON
|
||||||
X:PARENT_RIGHT - 140
|
X:PARENT_RIGHT - 140
|
||||||
Y:PARENT_BOTTOM - 45
|
Y:PARENT_BOTTOM - 45
|
||||||
Width:120
|
Width:120
|
||||||
@@ -180,13 +183,20 @@ Background@DIRECTCONNECT_BG:
|
|||||||
Height:25
|
Height:25
|
||||||
Align:Right
|
Align:Right
|
||||||
Text:Server Address:
|
Text:Server Address:
|
||||||
TextField@SERVER_ADDRESS:
|
TextField@IP:
|
||||||
Id:SERVER_ADDRESS
|
Id:IP
|
||||||
X:150
|
X:150
|
||||||
Y:60
|
Y:60
|
||||||
Width:200
|
Width:160
|
||||||
MaxLength:50
|
MaxLength:50
|
||||||
Height:25
|
Height:25
|
||||||
|
TextField@PORT:
|
||||||
|
Id:PORT
|
||||||
|
X:315
|
||||||
|
Y:60
|
||||||
|
Width:55
|
||||||
|
MaxLength:5
|
||||||
|
Height:25
|
||||||
Button@JOIN_BUTTON:
|
Button@JOIN_BUTTON:
|
||||||
Id:JOIN_BUTTON
|
Id:JOIN_BUTTON
|
||||||
X:130
|
X:130
|
||||||
@@ -196,8 +206,8 @@ Background@DIRECTCONNECT_BG:
|
|||||||
Text:Join
|
Text:Join
|
||||||
Font:Bold
|
Font:Bold
|
||||||
Key:return
|
Key:return
|
||||||
Button@CANCEL_BUTTON:
|
Button@BACK_BUTTON:
|
||||||
Id:CANCEL_BUTTON
|
Id:BACK_BUTTON
|
||||||
X:260
|
X:260
|
||||||
Y:PARENT_BOTTOM - 45
|
Y:PARENT_BOTTOM - 45
|
||||||
Width:120
|
Width:120
|
||||||
@@ -205,8 +215,8 @@ Background@DIRECTCONNECT_BG:
|
|||||||
Text:Cancel
|
Text:Cancel
|
||||||
Font:Bold
|
Font:Bold
|
||||||
Key:escape
|
Key:escape
|
||||||
Background@CONNECTION_FAILED_BG:
|
Background@CONNECTIONFAILED_PANEL:
|
||||||
Id:CONNECTION_FAILED_BG
|
Id:CONNECTIONFAILED_PANEL
|
||||||
Logic:ConnectionFailedLogic
|
Logic:ConnectionFailedLogic
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||||
@@ -222,16 +232,16 @@ Background@CONNECTION_FAILED_BG:
|
|||||||
Text:Connection Failed
|
Text:Connection Failed
|
||||||
Align:Center
|
Align:Center
|
||||||
Font:Bold
|
Font:Bold
|
||||||
Label@CONNECTION_FAILED_DESC:
|
Label@CONNECTING_DESC:
|
||||||
Id:CONNECTION_FAILED_DESC
|
Id:CONNECTING_DESC
|
||||||
X:0
|
X:0
|
||||||
Y:60
|
Y:60
|
||||||
Width:PARENT_RIGHT
|
Width:PARENT_RIGHT
|
||||||
Height:25
|
Height:25
|
||||||
Text:Could not connect to AAA.BBB.CCC.DDD:EEEE
|
Text:Could not connect to AAA.BBB.CCC.DDD:EEEE
|
||||||
Align:Center
|
Align:Center
|
||||||
Button@CONNECTION_BUTTON_RETRY:
|
Button@RETRY_BUTTON:
|
||||||
Id:CONNECTION_BUTTON_RETRY
|
Id:RETRY_BUTTON
|
||||||
X:PARENT_RIGHT - 360
|
X:PARENT_RIGHT - 360
|
||||||
Y:PARENT_BOTTOM - 45
|
Y:PARENT_BOTTOM - 45
|
||||||
Width:160
|
Width:160
|
||||||
@@ -239,8 +249,8 @@ Background@CONNECTION_FAILED_BG:
|
|||||||
Text:Retry
|
Text:Retry
|
||||||
Font:Bold
|
Font:Bold
|
||||||
Key:return
|
Key:return
|
||||||
Button@CONNECTION_BUTTON_CANCEL:
|
Button@ABORT_BUTTON:
|
||||||
Id:CONNECTION_BUTTON_CANCEL
|
Id:ABORT_BUTTON
|
||||||
X:PARENT_RIGHT - 180
|
X:PARENT_RIGHT - 180
|
||||||
Y:PARENT_BOTTOM - 45
|
Y:PARENT_BOTTOM - 45
|
||||||
Width:160
|
Width:160
|
||||||
@@ -248,9 +258,9 @@ Background@CONNECTION_FAILED_BG:
|
|||||||
Text:Cancel
|
Text:Cancel
|
||||||
Font:Bold
|
Font:Bold
|
||||||
Key:escape
|
Key:escape
|
||||||
Background@CONNECTING_BG:
|
Background@CONNECTING_PANEL:
|
||||||
Id:CONNECTING_BG
|
Id:CONNECTING_PANEL
|
||||||
Logic:ConnectionDialogsLogic
|
Logic:ConnectionLogic
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||||
Width:450
|
Width:450
|
||||||
@@ -273,8 +283,8 @@ Background@CONNECTING_BG:
|
|||||||
Height:25
|
Height:25
|
||||||
Text:Connecting to AAA.BBB.CCC.DDD:EEEE...
|
Text:Connecting to AAA.BBB.CCC.DDD:EEEE...
|
||||||
Align:Center
|
Align:Center
|
||||||
Button@CONNECTION_BUTTON_ABORT:
|
Button@ABORT_BUTTON:
|
||||||
Id:CONNECTION_BUTTON_ABORT
|
Id:ABORT_BUTTON
|
||||||
X:PARENT_RIGHT - 180
|
X:PARENT_RIGHT - 180
|
||||||
Y:PARENT_BOTTOM - 45
|
Y:PARENT_BOTTOM - 45
|
||||||
Width:160
|
Width:160
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ ChromeLayout:
|
|||||||
mods/ra/chrome/serverbrowser.yaml
|
mods/ra/chrome/serverbrowser.yaml
|
||||||
mods/ra/chrome/replaybrowser.yaml
|
mods/ra/chrome/replaybrowser.yaml
|
||||||
mods/ra/chrome/dropdowns.yaml
|
mods/ra/chrome/dropdowns.yaml
|
||||||
|
mods/ra/chrome/modchooser.yaml
|
||||||
Weapons:
|
Weapons:
|
||||||
mods/ra/weapons.yaml
|
mods/ra/weapons.yaml
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user