Replace one pile of hacks with another
This commit is contained in:
@@ -6,7 +6,7 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
class ButtonWidget : Widget
|
class ButtonWidget : Widget
|
||||||
{
|
{
|
||||||
public readonly string Text = "";
|
public string Text = "";
|
||||||
public bool Depressed = false;
|
public bool Depressed = false;
|
||||||
public int VisualHeight = 1;
|
public int VisualHeight = 1;
|
||||||
public override bool HandleInput(MouseInput mi)
|
public override bool HandleInput(MouseInput mi)
|
||||||
|
|||||||
@@ -155,4 +155,33 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ConnectionDialogsDelegate : WidgetDelegate
|
||||||
|
{
|
||||||
|
public override bool OnMouseUp(Widget w, MouseInput mi)
|
||||||
|
{
|
||||||
|
// Main Menu root
|
||||||
|
if (w.Id == "CONNECTION_BUTTON_ABORT")
|
||||||
|
{
|
||||||
|
Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = true;
|
||||||
|
Game.chrome.rootWidget.GetWidget("CONNECTING_BG").Visible = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (w.Id == "CONNECTION_BUTTON_CANCEL")
|
||||||
|
{
|
||||||
|
Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = true;
|
||||||
|
Game.chrome.rootWidget.GetWidget("CONNECTION_FAILED_BG").Visible = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (w.Id == "CONNECTION_BUTTON_RETRY")
|
||||||
|
{
|
||||||
|
Game.JoinServer(Game.CurrentHost,Game.CurrentPort);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,8 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
class LabelWidget : Widget
|
class LabelWidget : Widget
|
||||||
{
|
{
|
||||||
public readonly string Text = null;
|
public string Text = "";
|
||||||
public readonly string Align = "Left";
|
public string Align = "Left";
|
||||||
|
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -146,9 +146,13 @@ namespace OpenRA
|
|||||||
JoinLocal();
|
JoinLocal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string CurrentHost = "";
|
||||||
|
public static int CurrentPort = 0;
|
||||||
internal static void JoinServer(string host, int port)
|
internal static void JoinServer(string host, int port)
|
||||||
{
|
{
|
||||||
orderManager = new OrderManager(new NetworkConnection( host, port ), "replay.rep");
|
CurrentHost = host;
|
||||||
|
CurrentPort = port;
|
||||||
|
orderManager = new OrderManager(new NetworkConnection( host, port )); // TODO: supplying a replay file prevents osx from joining a game
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void JoinLocal()
|
internal static void JoinLocal()
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Graphics
|
namespace OpenRA.Graphics
|
||||||
{
|
{
|
||||||
@@ -61,6 +62,7 @@ namespace OpenRA.Graphics
|
|||||||
this.scrollPosition = Game.CellSize* mapStart;
|
this.scrollPosition = Game.CellSize* mapStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConnectionState lastConnectionState = ConnectionState.PreConnecting;
|
||||||
public void DrawRegions( World world )
|
public void DrawRegions( World world )
|
||||||
{
|
{
|
||||||
world.WorldRenderer.palette.Update(world.Queries.WithTraitMultiple<IPaletteModifier>().Select(t=>t.Trait));
|
world.WorldRenderer.palette.Update(world.Queries.WithTraitMultiple<IPaletteModifier>().Select(t=>t.Trait));
|
||||||
@@ -81,24 +83,54 @@ namespace OpenRA.Graphics
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// what a hack. as soon as we have some real chrome stuff...
|
// Still hacky, but at least it uses widgets
|
||||||
|
// TODO: Clean up the logic of this beast
|
||||||
Game.chrome.DrawWidgets(world);
|
// TODO: Have a proper "In main menu" state
|
||||||
|
ConnectionState state = Game.orderManager.Connection.ConnectionState;
|
||||||
|
if (state != lastConnectionState)
|
||||||
|
{
|
||||||
switch( Game.orderManager.Connection.ConnectionState )
|
switch( Game.orderManager.Connection.ConnectionState )
|
||||||
{
|
{
|
||||||
|
case ConnectionState.PreConnecting:
|
||||||
|
Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = true;
|
||||||
|
Game.chrome.rootWidget.GetWidget("CONNECTING_BG").Visible = false;
|
||||||
|
Game.chrome.rootWidget.GetWidget("CONNECTION_FAILED_BG").Visible = false;
|
||||||
|
break;
|
||||||
case ConnectionState.Connecting:
|
case ConnectionState.Connecting:
|
||||||
Game.chrome.DrawDialog("Connecting to {0}:{1}...".F( Game.Settings.NetworkHost, Game.Settings.NetworkPort ));
|
Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = false;
|
||||||
|
Game.chrome.rootWidget.GetWidget("CONNECTING_BG").Visible = true;
|
||||||
|
Game.chrome.rootWidget.GetWidget("CONNECTION_FAILED_BG").Visible = false;
|
||||||
|
|
||||||
|
//(Game.chrome.rootWidget.GetWidget("CONNECTION_GROUP_FAILED") as LabelWidget).Text = "Connecting abort";
|
||||||
|
|
||||||
|
//Game.chrome.DrawDialog("Connecting to {0}:{1}...".F( Game.Settings.NetworkHost, Game.Settings.NetworkPort ));
|
||||||
break;
|
break;
|
||||||
case ConnectionState.NotConnected:
|
case ConnectionState.NotConnected:
|
||||||
// Todo: Hook these up
|
Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = false;
|
||||||
Game.chrome.DrawDialog("Connection failed.", "Retry", _ => {}, "Cancel",_ => {});
|
Game.chrome.rootWidget.GetWidget("CONNECTING_BG").Visible = false;
|
||||||
|
Game.chrome.rootWidget.GetWidget("CONNECTION_FAILED_BG").Visible = true;
|
||||||
|
|
||||||
|
//(Game.chrome.rootWidget.GetWidget("CONNECTION_GROUP_FAILED") as LabelWidget).Text = "Not Connected Retry/fail";
|
||||||
|
//Game.chrome.DrawDialog("Connection failed.", "Retry", _ => {}, "Cancel",_ => {});
|
||||||
break;
|
break;
|
||||||
case ConnectionState.Connected:
|
case ConnectionState.Connected:
|
||||||
Game.chrome.DrawLobby( world );
|
Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = false;
|
||||||
|
Game.chrome.rootWidget.GetWidget("CONNECTING_BG").Visible = false;
|
||||||
|
Game.chrome.rootWidget.GetWidget("CONNECTION_FAILED_BG").Visible = false;
|
||||||
|
//Game.chrome.DrawLobby( world );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Kill this (hopefully!) soon
|
||||||
|
if (state == ConnectionState.Connected)
|
||||||
|
Game.chrome.DrawLobby( world );
|
||||||
|
|
||||||
|
lastConnectionState = state;
|
||||||
|
Game.chrome.DrawWidgets(world);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
var cursorName = Game.chrome.HitTest(mousePos) ? "default" : Game.controller.ChooseCursor( world );
|
var cursorName = Game.chrome.HitTest(mousePos) ? "default" : Game.controller.ChooseCursor( world );
|
||||||
var c = new Cursor(cursorName);
|
var c = new Cursor(cursorName);
|
||||||
cursorRenderer.DrawSprite(c.GetSprite((int)cursorFrame), mousePos + Location - c.GetHotspot(), "cursor");
|
cursorRenderer.DrawSprite(c.GetSprite((int)cursorFrame), mousePos + Location - c.GetHotspot(), "cursor");
|
||||||
|
|||||||
@@ -117,38 +117,31 @@ Container:
|
|||||||
Height:25
|
Height:25
|
||||||
Text:Cancel
|
Text:Cancel
|
||||||
Delegate:ServerBrowserDelegate
|
Delegate:ServerBrowserDelegate
|
||||||
Background@CONNECTION_BG:
|
Background@CONNECTION_FAILED_BG:
|
||||||
Id:CONNECTION_BG
|
Id:CONNECTION_FAILED_BG
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||||
Width:450
|
Width:450
|
||||||
Height:400
|
Height:150
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
Label@CONNECTION_LABEL_TITLE:
|
Label@CONNECTION_FAILED_TITLE:
|
||||||
Id:CONNECTION_LABEL_TITLE
|
Id:CONNECTION_FAILED_TITLE
|
||||||
X:0
|
X:0
|
||||||
Y:20
|
Y:20
|
||||||
Width:450
|
Width:450
|
||||||
Height:25
|
Height:25
|
||||||
Text:Connecting
|
Text:Connection Failed
|
||||||
Align:Center
|
Align:Center
|
||||||
Container@CONNECTION_GROUP_CONNECTING:
|
Label@CONNECTION_FAILED_DESC:
|
||||||
Id:CONNECTION_GROUP_CONNECTING
|
Id:CONNECTION_FAILED_DESC
|
||||||
Visible:false
|
X:0
|
||||||
Children:
|
Y:60
|
||||||
Button@CONNECTION_BUTTON_ABORT:
|
Width:PARENT_RIGHT
|
||||||
Id:CONNECTION_BUTTON_ABORT
|
|
||||||
X:PARENT_RIGHT - 180
|
|
||||||
Y:PARENT_BOTTOM - 45
|
|
||||||
Width:160
|
|
||||||
Height:25
|
Height:25
|
||||||
Text:Abort
|
Text:Could not connect to AAA.BBB.CCC.DDD:EEEE
|
||||||
Delegate:ServerBrowserDelegate
|
Align:Center
|
||||||
Container@CONNECTION_GROUP_FAILED:
|
Delegate:ConnectionDialogsDelegate
|
||||||
Id:CONNECTION_GROUP_FAILED
|
|
||||||
Visible:false
|
|
||||||
Children:
|
|
||||||
Button@CONNECTION_BUTTON_RETRY:
|
Button@CONNECTION_BUTTON_RETRY:
|
||||||
Id:CONNECTION_BUTTON_RETRY
|
Id:CONNECTION_BUTTON_RETRY
|
||||||
X:PARENT_RIGHT - 360
|
X:PARENT_RIGHT - 360
|
||||||
@@ -156,7 +149,7 @@ Container:
|
|||||||
Width:160
|
Width:160
|
||||||
Height:25
|
Height:25
|
||||||
Text:Retry
|
Text:Retry
|
||||||
Delegate:ServerBrowserDelegate
|
Delegate:ConnectionDialogsDelegate
|
||||||
Button@CONNECTION_BUTTON_CANCEL:
|
Button@CONNECTION_BUTTON_CANCEL:
|
||||||
Id:CONNECTION_BUTTON_CANCEL
|
Id:CONNECTION_BUTTON_CANCEL
|
||||||
X:PARENT_RIGHT - 180
|
X:PARENT_RIGHT - 180
|
||||||
@@ -164,4 +157,37 @@ Container:
|
|||||||
Width:160
|
Width:160
|
||||||
Height:25
|
Height:25
|
||||||
Text:Cancel
|
Text:Cancel
|
||||||
Delegate:ServerBrowserDelegate
|
Delegate:ConnectionDialogsDelegate
|
||||||
|
Background@CONNECTING_BG:
|
||||||
|
Id:CONNECTING_BG
|
||||||
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
|
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||||
|
Width:450
|
||||||
|
Height:150
|
||||||
|
Visible:false
|
||||||
|
Children:
|
||||||
|
Label@CONNECTING_TITLE:
|
||||||
|
Id:CONNECTING_TITLE
|
||||||
|
X:0
|
||||||
|
Y:20
|
||||||
|
Width:450
|
||||||
|
Height:25
|
||||||
|
Text:Connecting
|
||||||
|
Align:Center
|
||||||
|
Label@CONNECTING_DESC:
|
||||||
|
Id:CONNECTING_DESC
|
||||||
|
X:0
|
||||||
|
Y:60
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Height:25
|
||||||
|
Text:Connecting to AAA.BBB.CCC.DDD:EEEE...
|
||||||
|
Align:Center
|
||||||
|
Delegate:ConnectionDialogsDelegate
|
||||||
|
Button@CONNECTION_BUTTON_ABORT:
|
||||||
|
Id:CONNECTION_BUTTON_ABORT
|
||||||
|
X:PARENT_RIGHT - 180
|
||||||
|
Y:PARENT_BOTTOM - 45
|
||||||
|
Width:160
|
||||||
|
Height:25
|
||||||
|
Text:Abort
|
||||||
|
Delegate:ConnectionDialogsDelegate
|
||||||
@@ -117,38 +117,31 @@ Container:
|
|||||||
Height:25
|
Height:25
|
||||||
Text:Cancel
|
Text:Cancel
|
||||||
Delegate:ServerBrowserDelegate
|
Delegate:ServerBrowserDelegate
|
||||||
Background@CONNECTION_BG:
|
Background@CONNECTION_FAILED_BG:
|
||||||
Id:CONNECTION_BG
|
Id:CONNECTION_FAILED_BG
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||||
Width:450
|
Width:450
|
||||||
Height:400
|
Height:150
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
Label@CONNECTION_LABEL_TITLE:
|
Label@CONNECTION_FAILED_TITLE:
|
||||||
Id:CONNECTION_LABEL_TITLE
|
Id:CONNECTION_FAILED_TITLE
|
||||||
X:0
|
X:0
|
||||||
Y:20
|
Y:20
|
||||||
Width:450
|
Width:450
|
||||||
Height:25
|
Height:25
|
||||||
Text:Connecting
|
Text:Connection Failed
|
||||||
Align:Center
|
Align:Center
|
||||||
Container:
|
Label@CONNECTION_FAILED_DESC:
|
||||||
Id:CONNECTION_GROUP_CONNECTING
|
Id:CONNECTION_FAILED_DESC
|
||||||
Visible:false
|
X:0
|
||||||
Children:
|
Y:60
|
||||||
Button@CONNECTION_BUTTON_ABORT:
|
Width:PARENT_RIGHT
|
||||||
Id:CONNECTION_BUTTON_ABORT
|
|
||||||
X:PARENT_RIGHT - 180
|
|
||||||
Y:PARENT_BOTTOM - 45
|
|
||||||
Width:160
|
|
||||||
Height:25
|
Height:25
|
||||||
Text:Abort
|
Text:Could not connect to AAA.BBB.CCC.DDD:EEEE
|
||||||
Delegate:ServerBrowserDelegate
|
Align:Center
|
||||||
Container:
|
Delegate:ConnectionDialogsDelegate
|
||||||
Id:CONNECTION_GROUP_FAILED
|
|
||||||
Visible:false
|
|
||||||
Children:
|
|
||||||
Button@CONNECTION_BUTTON_RETRY:
|
Button@CONNECTION_BUTTON_RETRY:
|
||||||
Id:CONNECTION_BUTTON_RETRY
|
Id:CONNECTION_BUTTON_RETRY
|
||||||
X:PARENT_RIGHT - 360
|
X:PARENT_RIGHT - 360
|
||||||
@@ -156,7 +149,7 @@ Container:
|
|||||||
Width:160
|
Width:160
|
||||||
Height:25
|
Height:25
|
||||||
Text:Retry
|
Text:Retry
|
||||||
Delegate:ServerBrowserDelegate
|
Delegate:ConnectionDialogsDelegate
|
||||||
Button@CONNECTION_BUTTON_CANCEL:
|
Button@CONNECTION_BUTTON_CANCEL:
|
||||||
Id:CONNECTION_BUTTON_CANCEL
|
Id:CONNECTION_BUTTON_CANCEL
|
||||||
X:PARENT_RIGHT - 180
|
X:PARENT_RIGHT - 180
|
||||||
@@ -164,4 +157,37 @@ Container:
|
|||||||
Width:160
|
Width:160
|
||||||
Height:25
|
Height:25
|
||||||
Text:Cancel
|
Text:Cancel
|
||||||
Delegate:ServerBrowserDelegate
|
Delegate:ConnectionDialogsDelegate
|
||||||
|
Background@CONNECTING_BG:
|
||||||
|
Id:CONNECTING_BG
|
||||||
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
|
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||||
|
Width:450
|
||||||
|
Height:150
|
||||||
|
Visible:false
|
||||||
|
Children:
|
||||||
|
Label@CONNECTING_TITLE:
|
||||||
|
Id:CONNECTING_TITLE
|
||||||
|
X:0
|
||||||
|
Y:20
|
||||||
|
Width:450
|
||||||
|
Height:25
|
||||||
|
Text:Connecting
|
||||||
|
Align:Center
|
||||||
|
Label@CONNECTING_DESC:
|
||||||
|
Id:CONNECTING_DESC
|
||||||
|
X:0
|
||||||
|
Y:60
|
||||||
|
Width:PARENT_RIGHT
|
||||||
|
Height:25
|
||||||
|
Text:Connecting to AAA.BBB.CCC.DDD:EEEE...
|
||||||
|
Align:Center
|
||||||
|
Delegate:ConnectionDialogsDelegate
|
||||||
|
Button@CONNECTION_BUTTON_ABORT:
|
||||||
|
Id:CONNECTION_BUTTON_ABORT
|
||||||
|
X:PARENT_RIGHT - 180
|
||||||
|
Y:PARENT_BOTTOM - 45
|
||||||
|
Width:160
|
||||||
|
Height:25
|
||||||
|
Text:Abort
|
||||||
|
Delegate:ConnectionDialogsDelegate
|
||||||
Reference in New Issue
Block a user