Direct Connect panel

This commit is contained in:
Paul Chote
2011-05-07 23:54:12 +12:00
parent dded6040d6
commit 57530c819b
6 changed files with 359 additions and 358 deletions

View File

@@ -57,6 +57,16 @@ namespace OpenRA.Mods.Cnc.Widgets
});
};
multiplayerMenu.GetWidget<CncMenuButtonWidget>("DIRECTCONNECT_BUTTON").OnClick = () =>
{
Menu = MenuType.None;
Widget.OpenWindow("DIRECTCONNECT_PANEL", new Dictionary<string, object>()
{
{ "onExit", new Action(() => { Menu = MenuType.Multiplayer; Widget.CloseWindow(); }) },
{ "openLobby", new Action(OpenLobbyPanel) }
});
};
// Settings menu
var settingsMenu = widget.GetWidget("SETTINGS_MENU");
settingsMenu.IsVisible = () => Menu == MenuType.Settings;
@@ -64,6 +74,30 @@ namespace OpenRA.Mods.Cnc.Widgets
settingsMenu.GetWidget<CncMenuButtonWidget>("BACK_BUTTON").OnClick = () => Menu = MenuType.Main;
}
void OpenLobbyPanel()
{
// Starting a game: remove all shellmap ui
Action onStart = () =>
{
Widget.CloseWindow();
Widget.RootWidget.RemoveChild(Widget.RootWidget.GetWidget("MENU_BACKGROUND"));
};
// Quit the lobby: disconnect and restore menu
Action onLobbyClose = () =>
{
Game.DisconnectOnly();
Menu = MenuType.Main;
Widget.CloseWindow();
};
Menu = MenuType.None;
Game.OpenWindow("SERVER_LOBBY", new Dictionary<string, object>()
{
{ "onExit", onLobbyClose },
{ "onStart", onStart }
});
}
void StartSkirmishGame()
{
@@ -76,27 +110,7 @@ namespace OpenRA.Mods.Cnc.Widgets
settings.Server.ExternalPort = 1234;
Game.CreateAndJoinServer(settings, map);
Menu = MenuType.None;
Game.OpenWindow("SERVER_LOBBY", new Dictionary<string, object>()
{
// Returning to main menu
{"onExit", new Action(() =>
{
Game.DisconnectOnly();
Menu = MenuType.Main;
Widget.CloseWindow();
})
},
// Starting a game: remove all shellmap ui
{"onStart", new Action(() =>
{
Widget.CloseWindow();
Widget.RootWidget.RemoveChild(Widget.RootWidget.GetWidget("MENU_BACKGROUND"));
})
}
});
OpenLobbyPanel();
}
}
}

View File

@@ -51,7 +51,8 @@ namespace OpenRA.Mods.Cnc.Widgets
}
[ObjectCreator.UseCtor]
public CncServerBrowserLogic( [ObjectCreator.Param] Widget widget, [ObjectCreator.Param] Action onExit )
public CncServerBrowserLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] Action onExit)
{
var panel = widget.GetWidget("SERVERBROWSER_PANEL");
var sl = panel.GetWidget<ScrollPanelWidget>("SERVER_LIST");
@@ -188,4 +189,36 @@ namespace OpenRA.Mods.Cnc.Widgets
browserLogic.RefreshServerList(games);
}
}
public class CncDirectConnectLogic : IWidgetDelegate
{
[ObjectCreator.UseCtor]
public CncDirectConnectLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] Action onExit,
[ObjectCreator.Param] Action openLobby)
{
var panel = widget.GetWidget("DIRECTCONNECT_PANEL");
var ip = panel.GetWidget<TextFieldWidget>("IP");
var port = panel.GetWidget<TextFieldWidget>("PORT");
var last = Game.Settings.Player.LastServer.Split(':').ToArray();
ip.Text = last.Length > 1 ? last[0] : "localhost";
port.Text = last.Length > 2 ? last[1] : "1234";
panel.GetWidget<CncMenuButtonWidget>("JOIN_BUTTON").OnClick = () =>
{
int p;
if (!int.TryParse(port.Text, out p))
p = 1234;
Game.Settings.Player.LastServer = "{0}:{1}".F(ip.Text, p);
Game.Settings.Save();
Game.JoinServer(ip.Text,p);
openLobby();
};
panel.GetWidget<CncMenuButtonWidget>("BACK_BUTTON").OnClick = onExit;
}
}
}

View File

@@ -1,122 +1,60 @@
Background@DIRECTCONNECT_BG:
Id:DIRECTCONNECT_BG
Delegate:DirectConnectDelegate
Container@DIRECTCONNECT_PANEL:
Id:DIRECTCONNECT_PANEL
Delegate:CncDirectConnectLogic
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:400
Height:155
Y:(WINDOW_BOTTOM - 90)/2
Width:370
Height:125
Children:
Label@DIRECTCONNECT_LABEL_TITLE:
Id:DIRECTCONNECT_LABEL_TITLE
X:0
Y:20
Width:400
Height:25
Text:Direct Connect
Label@TITLE:
Width:PARENT_RIGHT
Y:0-25
Font:BigBold
Contrast:true
Align:Center
Bold:True
Label@ADDRESS_LABEL:
Id:ADDRESS_LABEL
X:50
Y:59
Width:95
Height:25
Align:Right
Text:Server Address:
TextField@SERVER_ADDRESS:
Id:SERVER_ADDRESS
X:150
Y:60
Width:200
MaxLength:50
Height:25
Button@JOIN_BUTTON:
Text:Connect to Server
Background@bg:
Width:370
Height:90
Background:panel-black
Children:
Label@ADDRESS_LABEL:
X:50
Y:14
Width:95
Height:25
Align:Right
Text:Address:
TextField@SERVER_ADDRESS:
Id:IP
X:150
Y:15
Width:200
Height:25
Label@ADDRESS_LABEL:
X:50
Y:49
Width:95
Height:25
Align:Right
Text:Port:
TextField@PORT:
Id:PORT
X:150
Y:50
Width:200
Height:25
CncMenuButton@JOIN_BUTTON:
Id:JOIN_BUTTON
X:130
Y:PARENT_BOTTOM - 45
Width:120
Height:25
X:0
Y:89
Width:140
Height:35
Text:Join
Bold:True
Button@CANCEL_BUTTON:
Id:CANCEL_BUTTON
X:260
Y:PARENT_BOTTOM - 45
Width:120
Height:25
Text:Cancel
Bold:True
Background@CONNECTION_FAILED_BG:
Id:CONNECTION_FAILED_BG
Delegate:ConnectionFailedDelegate
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:450
Height:150
Children:
Label@CONNECTION_FAILED_TITLE:
Id:CONNECTION_FAILED_TITLE
X:0
Y:20
Width:450
Height:25
Text:Connection Failed
Align:Center
Bold:True
Label@CONNECTION_FAILED_DESC:
Id:CONNECTION_FAILED_DESC
X:0
Y:60
Width:PARENT_RIGHT
Height:25
Text:Could not connect to AAA.BBB.CCC.DDD:EEEE
Align:Center
Button@CONNECTION_BUTTON_RETRY:
Id:CONNECTION_BUTTON_RETRY
X:PARENT_RIGHT - 360
Y:PARENT_BOTTOM - 45
Width:160
Height:25
Text:Retry
Bold:True
Button@CONNECTION_BUTTON_CANCEL:
Id:CONNECTION_BUTTON_CANCEL
X:PARENT_RIGHT - 180
Y:PARENT_BOTTOM - 45
Width:160
Height:25
Text:Cancel
Bold:True
Background@CONNECTING_BG:
Id:CONNECTING_BG
Delegate:ConnectionDialogsDelegate
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:450
Height:150
Children:
Label@CONNECTING_TITLE:
Id:CONNECTING_TITLE
X:0
Y:20
Width:450
Height:25
Text:Connecting
Align:Center
Bold:True
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
Button@CONNECTION_BUTTON_ABORT:
Id:CONNECTION_BUTTON_ABORT
X:PARENT_RIGHT - 180
Y:PARENT_BOTTOM - 45
Width:160
Height:25
Text:Abort
Bold:True
CncMenuButton@BACK_BUTTON:
Id:BACK_BUTTON
X:230
Y:89
Width:140
Height:35
Text:Back

View File

@@ -1,7 +1,5 @@
Container@MENU_BACKGROUND:
Id:MENU_BACKGROUND
X:0
Y:0
Width:WINDOW_RIGHT
Height:WINDOW_BOTTOM
Delegate:CncMenuLogic
@@ -14,8 +12,6 @@ Container@MENU_BACKGROUND:
ImageCollection:shellmap
ImageName:reticle
Background@BORDER:
X:0
Y:0
Width:WINDOW_RIGHT
Height:WINDOW_BOTTOM
Background:shellmapborder
@@ -157,218 +153,3 @@ Container@MENU_BACKGROUND:
Width:140
Height:35
Text:Back
Background@QUICKMODSWITCHER:
Id:QUICKMODSWITCHER
Background: dialog4
X:(WINDOW_RIGHT - PARENT_LEFT - WIDTH - 10)
Y:10 - PARENT_TOP
Width:205
Visible:false
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:
Id:PERF_BG
Background:dialog4
Delegate:PerfDebugDelegate
X:10
Y:WINDOW_BOTTOM - 250
Width: 210
Height: 250
Children:
PerfGraph@GRAPH:
Id:GRAPH
X:5
Y:5
Width:200
Height:200
Label@TEXT:
Id:TEXT
Bold: false
X:20
Y:205
Width:170
Height:40
Background@MUSIC_MENU:
Id:MUSIC_MENU
Delegate:MusicPlayerDelegate
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width: 450
Height: 250
Children:
Label@SETTINGS_LABEL_TITLE:
Id:SETTINGS_LABEL_TITLE
X:0
Y:20
Width:450
Height:25
Text:Music
Align:Center
Font:Bold
Button@BUTTON_INSTALL:
Id:BUTTON_INSTALL
X:20
Y:PARENT_BOTTOM - 45
Width:160
Height:25
Text:Install Music
Font:Bold
Button@BUTTON_CLOSE:
Id:BUTTON_CLOSE
X:PARENT_RIGHT - 180
Y:PARENT_BOTTOM - 45
Width:160
Height:25
Text:Close
Font:Bold
Container@BUTTONS:
X:PARENT_RIGHT - 150
Y:50
Children:
Button@BUTTON_PLAY:
Id:BUTTON_PLAY
X:35
Y:0
Width:25
Height:25
Children:
Image@IMAGE_PLAY:
Id:IMAGE_PLAY
X:0
Y:0
Width:25
Height:25
ImageCollection:music
ImageName:play
Button@BUTTON_PAUSE:
Id:BUTTON_PAUSE
Visible:false
X:35
Y:0
Width:25
Height:25
Children:
Image@IMAGE_PAUSE:
Id:IMAGE_PAUSE
X:0
Y:0
Width:25
Height:25
ImageCollection:music
ImageName:pause
Button@BUTTON_STOP:
Id:BUTTON_STOP
X:70
Y:0
Width:25
Height:25
Children:
Image@IMAGE_STOP:
Id:IMAGE_STOP
X:0
Y:0
Width:25
Height:25
ImageCollection:music
ImageName:stop
Button@BUTTON_NEXT:
Id:BUTTON_NEXT
X:105
Y:0
Width:25
Height:25
Children:
Image@IMAGE_NEXT:
Id:IMAGE_NEXT
X:0
Y:0
Width:25
Height:25
ImageCollection:music
ImageName:next
Button@BUTTON_PREV:
Id:BUTTON_PREV
X:0
Y:0
Width:25
Height:25
Children:
Image@IMAGE_PREV:
Id:IMAGE_PREV
X:0
Y:0
Width:25
Height:25
ImageCollection:music
ImageName:prev
Label@TIME:
Id:TIME
X:PARENT_RIGHT - 150
Y:75
Width:140
Height:25
Align: Center
ScrollPanel@MUSIC_LIST:
Id:MUSIC_LIST
X:10
Y:50
Width:280
Height:140
Children:
Label@MUSIC_TEMPLATE:
Id:MUSIC_TEMPLATE
Width:PARENT_RIGHT-28
Height:25
X:2
Y:0
Visible:false
Children:
Label@TITLE:
Id:TITLE
X:5
Width:PARENT_RIGHT - 10
Height:PARENT_BOTTOM
Align: Left
Label@LENGTH:
Id:LENGTH
X:5
Width:PARENT_RIGHT - 10
Height:PARENT_BOTTOM
Align: Right
Checkbox@SHUFFLE:
Id:SHUFFLE
X:PARENT_RIGHT - 150
Y:110
Width:100
Height:20
Text:Shuffle
Checkbox@REPEAT:
Id:REPEAT
X:PARENT_RIGHT - 150
Y:140
Width:100
Height:20
Text:Loop

View File

@@ -0,0 +1,74 @@
Background@CONNECTION_FAILED_BG:
Id:CONNECTION_FAILED_BG
Delegate:ConnectionFailedDelegate
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:450
Height:150
Children:
Label@CONNECTION_FAILED_TITLE:
Id:CONNECTION_FAILED_TITLE
X:0
Y:20
Width:450
Height:25
Text:Connection Failed
Align:Center
Bold:True
Label@CONNECTION_FAILED_DESC:
Id:CONNECTION_FAILED_DESC
X:0
Y:60
Width:PARENT_RIGHT
Height:25
Text:Could not connect to AAA.BBB.CCC.DDD:EEEE
Align:Center
Button@CONNECTION_BUTTON_RETRY:
Id:CONNECTION_BUTTON_RETRY
X:PARENT_RIGHT - 360
Y:PARENT_BOTTOM - 45
Width:160
Height:25
Text:Retry
Bold:True
Button@CONNECTION_BUTTON_CANCEL:
Id:CONNECTION_BUTTON_CANCEL
X:PARENT_RIGHT - 180
Y:PARENT_BOTTOM - 45
Width:160
Height:25
Text:Cancel
Bold:True
Background@CONNECTING_BG:
Id:CONNECTING_BG
Delegate:ConnectionDialogsDelegate
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:450
Height:150
Children:
Label@CONNECTING_TITLE:
Id:CONNECTING_TITLE
X:0
Y:20
Width:450
Height:25
Text:Connecting
Align:Center
Bold:True
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
Button@CONNECTION_BUTTON_ABORT:
Id:CONNECTION_BUTTON_ABORT
X:PARENT_RIGHT - 180
Y:PARENT_BOTTOM - 45
Width:160
Height:25
Text:Abort
Bold:True

View File

@@ -0,0 +1,161 @@
Background@MUSIC_MENU:
Id:MUSIC_MENU
Delegate:MusicPlayerDelegate
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width: 450
Height: 250
Children:
Label@SETTINGS_LABEL_TITLE:
Id:SETTINGS_LABEL_TITLE
X:0
Y:20
Width:450
Height:25
Text:Music
Align:Center
Font:Bold
Button@BUTTON_INSTALL:
Id:BUTTON_INSTALL
X:20
Y:PARENT_BOTTOM - 45
Width:160
Height:25
Text:Install Music
Font:Bold
Button@BUTTON_CLOSE:
Id:BUTTON_CLOSE
X:PARENT_RIGHT - 180
Y:PARENT_BOTTOM - 45
Width:160
Height:25
Text:Close
Font:Bold
Container@BUTTONS:
X:PARENT_RIGHT - 150
Y:50
Children:
Button@BUTTON_PLAY:
Id:BUTTON_PLAY
X:35
Y:0
Width:25
Height:25
Children:
Image@IMAGE_PLAY:
Id:IMAGE_PLAY
X:0
Y:0
Width:25
Height:25
ImageCollection:music
ImageName:play
Button@BUTTON_PAUSE:
Id:BUTTON_PAUSE
Visible:false
X:35
Y:0
Width:25
Height:25
Children:
Image@IMAGE_PAUSE:
Id:IMAGE_PAUSE
X:0
Y:0
Width:25
Height:25
ImageCollection:music
ImageName:pause
Button@BUTTON_STOP:
Id:BUTTON_STOP
X:70
Y:0
Width:25
Height:25
Children:
Image@IMAGE_STOP:
Id:IMAGE_STOP
X:0
Y:0
Width:25
Height:25
ImageCollection:music
ImageName:stop
Button@BUTTON_NEXT:
Id:BUTTON_NEXT
X:105
Y:0
Width:25
Height:25
Children:
Image@IMAGE_NEXT:
Id:IMAGE_NEXT
X:0
Y:0
Width:25
Height:25
ImageCollection:music
ImageName:next
Button@BUTTON_PREV:
Id:BUTTON_PREV
X:0
Y:0
Width:25
Height:25
Children:
Image@IMAGE_PREV:
Id:IMAGE_PREV
X:0
Y:0
Width:25
Height:25
ImageCollection:music
ImageName:prev
Label@TIME:
Id:TIME
X:PARENT_RIGHT - 150
Y:75
Width:140
Height:25
Align: Center
ScrollPanel@MUSIC_LIST:
Id:MUSIC_LIST
X:10
Y:50
Width:280
Height:140
Children:
Label@MUSIC_TEMPLATE:
Id:MUSIC_TEMPLATE
Width:PARENT_RIGHT-28
Height:25
X:2
Y:0
Visible:false
Children:
Label@TITLE:
Id:TITLE
X:5
Width:PARENT_RIGHT - 10
Height:PARENT_BOTTOM
Align: Left
Label@LENGTH:
Id:LENGTH
X:5
Width:PARENT_RIGHT - 10
Height:PARENT_BOTTOM
Align: Right
Checkbox@SHUFFLE:
Id:SHUFFLE
X:PARENT_RIGHT - 150
Y:110
Width:100
Height:20
Text:Shuffle
Checkbox@REPEAT:
Id:REPEAT
X:PARENT_RIGHT - 150
Y:140
Width:100
Height:20
Text:Loop