Remove Password and Endpoint from OrderManager
This commit is contained in:
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
Action onConnect, onAbort;
|
||||
Action<string> onRetry;
|
||||
|
||||
void ConnectionStateChanged(OrderManager om)
|
||||
void ConnectionStateChanged(OrderManager om, string password, NetworkConnection connection)
|
||||
{
|
||||
if (om.Connection.ConnectionState == ConnectionState.Connected)
|
||||
{
|
||||
@@ -35,6 +35,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
Ui.OpenWindow(switchPanel, new WidgetArgs()
|
||||
{
|
||||
{ "orderManager", om },
|
||||
{ "connection", connection },
|
||||
{ "password", password },
|
||||
{ "onAbort", onAbort },
|
||||
{ "onRetry", onRetry }
|
||||
});
|
||||
@@ -83,7 +85,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
bool passwordOffsetAdjusted;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ConnectionFailedLogic(Widget widget, OrderManager orderManager, Action onAbort, Action<string> onRetry)
|
||||
public ConnectionFailedLogic(Widget widget, OrderManager orderManager, NetworkConnection connection, string password, Action onAbort, Action<string> onRetry)
|
||||
{
|
||||
var panel = widget;
|
||||
var abortButton = panel.Get<ButtonWidget>("ABORT_BUTTON");
|
||||
@@ -95,13 +97,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
retryButton.Visible = onRetry != null;
|
||||
retryButton.OnClick = () =>
|
||||
{
|
||||
var password = passwordField != null && passwordField.IsVisible() ? passwordField.Text : orderManager.Password;
|
||||
var pass = passwordField != null && passwordField.IsVisible() ? passwordField.Text : password;
|
||||
|
||||
Ui.CloseWindow();
|
||||
onRetry(password);
|
||||
onRetry(pass);
|
||||
};
|
||||
|
||||
widget.Get<LabelWidget>("CONNECTING_DESC").GetText = () => $"Could not connect to {orderManager.Endpoint}";
|
||||
widget.Get<LabelWidget>("CONNECTING_DESC").GetText = () => $"Could not connect to {connection.Target}";
|
||||
|
||||
var connectionError = widget.Get<LabelWidget>("CONNECTION_ERROR");
|
||||
connectionError.GetText = () => orderManager.ServerError ?? orderManager.Connection.ErrorMessage ?? "Unknown error";
|
||||
@@ -149,7 +151,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
public class ConnectionSwitchModLogic : ChromeLogic
|
||||
{
|
||||
[ObjectCreator.UseCtor]
|
||||
public ConnectionSwitchModLogic(Widget widget, OrderManager orderManager, Action onAbort, Action<string> onRetry)
|
||||
public ConnectionSwitchModLogic(Widget widget, OrderManager orderManager, string password, NetworkConnection connection, Action onAbort, Action<string> onRetry)
|
||||
{
|
||||
var panel = widget;
|
||||
var abortButton = panel.Get<ButtonWidget>("ABORT_BUTTON");
|
||||
@@ -161,7 +163,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
switchButton.OnClick = () =>
|
||||
{
|
||||
var launchCommand = $"Launch.URI={new UriBuilder("tcp", orderManager.Connection.EndPoint.Address.ToString(), orderManager.Connection.EndPoint.Port)}";
|
||||
var launchCommand = $"Launch.URI={new UriBuilder("tcp", connection.EndPoint.Address.ToString(), connection.EndPoint.Port)}";
|
||||
Game.SwitchToExternalMod(orderManager.ServerExternalMod, new[] { launchCommand }, () =>
|
||||
{
|
||||
orderManager.ServerError = "Failed to switch mod.";
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
Game.RunAfterTick(() => Ui.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs
|
||||
{
|
||||
{ "orderManager", orderManager },
|
||||
{ "password", CurrentServerSettings.Password },
|
||||
{ "connection", orderManager.Connection as NetworkConnection },
|
||||
{ "onAbort", null },
|
||||
{ "onRetry", null }
|
||||
}));
|
||||
|
||||
@@ -72,9 +72,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
bool MapIsPlayable => (mapStatus & Session.MapStatus.Playable) == Session.MapStatus.Playable;
|
||||
|
||||
// Listen for connection failures
|
||||
void ConnectionStateChanged(OrderManager om)
|
||||
void ConnectionStateChanged(OrderManager om, string password, NetworkConnection connection)
|
||||
{
|
||||
if (om.Connection.ConnectionState == ConnectionState.NotConnected)
|
||||
if (connection.ConnectionState == ConnectionState.NotConnected)
|
||||
{
|
||||
// Show connection failed dialog
|
||||
Ui.CloseWindow();
|
||||
@@ -89,12 +89,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
});
|
||||
};
|
||||
|
||||
Action<string> onRetry = password => ConnectionLogic.Connect(om.Endpoint, password, onConnect, onExit);
|
||||
Action<string> onRetry = pass => ConnectionLogic.Connect(connection.Target, pass, onConnect, onExit);
|
||||
|
||||
var switchPanel = om.ServerExternalMod != null ? "CONNECTION_SWITCHMOD_PANEL" : "CONNECTIONFAILED_PANEL";
|
||||
Ui.OpenWindow(switchPanel, new WidgetArgs()
|
||||
{
|
||||
{ "orderManager", om },
|
||||
{ "connection", connection },
|
||||
{ "password", password },
|
||||
{ "onAbort", onExit },
|
||||
{ "onRetry", onRetry }
|
||||
});
|
||||
@@ -762,7 +764,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
string secret = null;
|
||||
if (orderManager.LobbyInfo.GlobalSettings.Dedicated)
|
||||
{
|
||||
var endpoint = orderManager.Endpoint.GetConnectEndPoints().First();
|
||||
var endpoint = CurrentServerSettings.Target.GetConnectEndPoints().First();
|
||||
secret = string.Concat(endpoint.Address, "|", endpoint.Port);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user