Basic ingame menu reimplemented.

This commit is contained in:
Paul Chote
2011-05-08 18:27:20 +12:00
parent 5e32cd38eb
commit 8957caeaca
8 changed files with 190 additions and 384 deletions

View File

@@ -334,9 +334,9 @@ namespace OpenRA.Widgets
return window;
}
public static Widget LoadWidget(string id)
public static Widget LoadWidget(string id, Dictionary<string, object> args)
{
return Game.modData.WidgetLoader.LoadWidget(new Dictionary<string, object>(), rootWidget, id);
return Game.modData.WidgetLoader.LoadWidget(args, rootWidget, id);
}
public static void DoTick()

View File

@@ -58,9 +58,9 @@ namespace OpenRA.Mods.Cnc
() => Scripting.Media.PlayFMVFullscreen(w, "consyard.vqa", () =>
{
Sound.StopMusic();
Game.Disconnect();
Widget.CloseWindow();
Widget.LoadWidget("MENU_BACKGROUND");
//Game.Disconnect();
//Widget.CloseWindow();
//Widget.LoadWidget("MENU_BACKGROUND");
})));
}
@@ -76,9 +76,9 @@ namespace OpenRA.Mods.Cnc
() => Scripting.Media.PlayFMVFullscreen(w, "gameover.vqa", () =>
{
Sound.StopMusic();
Game.Disconnect();
Widget.CloseWindow();
Widget.LoadWidget("MENU_BACKGROUND");
//Game.Disconnect();
//Widget.CloseWindow();
//Widget.LoadWidget("MENU_BACKGROUND");
})));
}

View File

@@ -78,6 +78,7 @@
<Compile Include="Widgets\CncServerCreationLogic.cs" />
<Compile Include="Widgets\CncMapChooserLogic.cs" />
<Compile Include="Widgets\CncConnectionLogic.cs" />
<Compile Include="Widgets\CncIngameChromeLogic.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -0,0 +1,106 @@
#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.Traits;
using OpenRA.Widgets;
using System.Drawing;
using System.Collections.Generic;
using System;
namespace OpenRA.Mods.Cnc.Widgets
{
public class CncIngameChromeLogic : IWidgetDelegate
{
static bool staticSetup;
Widget ingameRoot;
public static CncIngameChromeLogic GetHandler()
{
var panel = Widget.RootWidget.GetWidget("INGAME_ROOT");
if (panel == null)
return null;
return panel.DelegateObject as CncIngameChromeLogic;
}
static void AddChatLineStub(Color c, string from, string text)
{
var handler = GetHandler();
if (handler == null)
return;
handler.AddChatLine(c, from, text);
}
void AddChatLine(Color c, string from, string text)
{
ingameRoot.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").AddLine(c, from, text);
}
[ObjectCreator.UseCtor]
public CncIngameChromeLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] World world )
{
ingameRoot = widget.GetWidget("INGAME_ROOT");
if (!staticSetup)
{
staticSetup = true;
Game.AddChatLine += AddChatLineStub;
}
ingameRoot.GetWidget<CncMenuButtonWidget>("OPTIONS_BUTTON").OnClick = () =>
{
ingameRoot.IsVisible = () => false;
var onExit = new Action(() => {ingameRoot.IsVisible = () => true;});
Widget.LoadWidget("INGAME_MENU", new Dictionary<string, object>() {{ "world", world }, { "onExit", onExit }});
};
var postgameBG = ingameRoot.GetWidget("POSTGAME_BG");
postgameBG.IsVisible = () =>
{
return world.LocalPlayer != null && world.LocalPlayer.WinState != WinState.Undefined;
};
postgameBG.GetWidget<LabelWidget>("TEXT").GetText = () =>
{
var state = world.LocalPlayer.WinState;
return (state == WinState.Undefined)? "" :
((state == WinState.Lost)? "YOU ARE DEFEATED" : "YOU ARE VICTORIOUS");
};
}
}
public class CncIngameMenuLogic : IWidgetDelegate
{
[ObjectCreator.UseCtor]
public CncIngameMenuLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] World world,
[ObjectCreator.Param] Action onExit)
{
var menu = widget.GetWidget("INGAME_MENU");
menu.GetWidget<CncMenuButtonWidget>("QUIT_BUTTON").OnClick = () =>
{
Game.DisconnectOnly();
// This is stupid. It should be handled by the shellmap
Game.LoadShellMap();
Widget.RootWidget.RemoveChildren();
Widget.LoadWidget("MENU_BACKGROUND", new Dictionary<string, object>());
};
menu.GetWidget<CncMenuButtonWidget>("RESUME_BUTTON").OnClick = () =>
{
Widget.RootWidget.RemoveChild(menu);
onExit();
};
}
}
}

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
switch (orderManager.Connection.ConnectionState)
{
case ConnectionState.PreConnecting:
Widget.LoadWidget("MAINMENU_BG");
Widget.LoadWidget("MAINMENU_BG", new Dictionary<string, object>());
break;
case ConnectionState.Connecting:
Widget.OpenWindow("CONNECTING_BG",
@@ -73,7 +73,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
Game.LoadShellMap();
Widget.RootWidget.RemoveChildren();
if (Info.InstallMode == "cnc")
Widget.LoadWidget("MENU_BACKGROUND");
Widget.LoadWidget("MENU_BACKGROUND", new Dictionary<string, object>());
else
Widget.OpenWindow("MAINMENU_BG");
}

View File

@@ -1,21 +1,15 @@
Container@INGAME_ROOT:
Id:INGAME_ROOT
Delegate:IngameChromeDelegate
Delegate:CncIngameChromeLogic
Children:
WorldInteractionController:
Id:INTERACTION_CONTROLLER
X:0
Y:0
Width:WINDOW_RIGHT
Height:WINDOW_BOTTOM
ViewportScrollController:
X:0
Y:0
Width:WINDOW_RIGHT
Height:WINDOW_BOTTOM
WorldCommand:
X:0
Y:0
Width:WINDOW_RIGHT
Height:WINDOW_BOTTOM
Timer@GAME_TIMER:
@@ -45,7 +39,6 @@ Container@INGAME_ROOT:
Bold:True
SpecialPowerBin@INGAME_POWERS_BIN:
Id:INGAME_POWERS_BIN
X:0
Y:25
BuildPalette@INGAME_BUILD_PALETTE:
Id:INGAME_BUILD_PALETTE
@@ -56,26 +49,26 @@ Container@INGAME_ROOT:
TabClick: button.aud
BuildPaletteOpen: appear1.aud
BuildPaletteClose: appear1.aud
Button@INGAME_OPTIONS_BUTTON:
Id:INGAME_OPTIONS_BUTTON
X:0
Y:0
Width:160
Height:25
CncMenuButton@OPTIONS_BUTTON:
Id:OPTIONS_BUTTON
X:5
Y:5
Width:140
Height:35
Text:Options
Bold:True
Button@INGAME_DIPLOMACY_BUTTON:
Id:INGAME_DIPLOMACY_BUTTON
X:162
Y:0
Width:160
Height:25
CncMenuButton@DIPLOMACY_BUTTON:
Id:DIPLOMACY_BUTTON
X:150
Y:5
Width:140
Height:35
Text:Diplomacy
Bold:True
Button@INGAME_DEVELOPERMODE_BUTTON:
Id:INGAME_DEVELOPERMODE_BUTTON
X:324
Y:0
CncMenuButton@DEVELOPERMODE_BUTTON:
Id:DEVELOPERMODE_BUTTON
X:295
Y:5
Width:160
Height:25
Text:Developer Mode
@@ -115,89 +108,6 @@ Container@INGAME_ROOT:
Description:Repair
LongDesc:Repair damaged buildings
WorldTooltip:
Background@INGAME_OPTIONS_BG:
Id:INGAME_OPTIONS_BG
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:300
Height:320
Visible:false
Children:
Label@LABEL_TITLE:
Id:LABEL_TITLE
X:(PARENT_RIGHT - WIDTH)/2
Y:20
Width:250
Height:25
Text:Options
Align:Center
Bold:True
Button@RESUME:
Id:RESUME
X:(PARENT_RIGHT - WIDTH)/2
Y:60
Width:160
Height:25
Text:Resume
Bold:True
Button@SETTINGS:
Id:SETTINGS
X:(PARENT_RIGHT - WIDTH)/2
Y:100
Width:160
Height:25
Text:Settings
Bold:True
Button@MUSIC:
Id:MUSIC
X:(PARENT_RIGHT - WIDTH)/2
Y:140
Width:160
Height:25
Text:Music
Bold:True
Button@SURRENDER:
Id:SURRENDER
X:(PARENT_RIGHT - WIDTH)/2
Y:180
Width:160
Height:25
Text:Surrender
Bold:True
Button@DISCONNECT:
Id:DISCONNECT
X:(PARENT_RIGHT - WIDTH)/2
Y:220
Width:160
Height:25
Text:Disconnect
Bold:True
Button@QUIT:
Id:QUIT
X:(PARENT_RIGHT - WIDTH)/2
Y:260
Width:160
Height:25
Text:Quit
Bold:True
Background@DIPLOMACY_BG:
Id:DIPLOMACY_BG
Delegate:DiplomacyDelegate
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:450
Height:400
Visible:false
Children:
Label@LABEL_TITLE:
Id:LABEL_TITLE
X:(PARENT_RIGHT - WIDTH)/2
Y:20
Width:250
Height:25
Text:Diplomacy
Align:Center
Bold:True
ChatDisplay@CHAT_DISPLAY:
Id:CHAT_DISPLAY
X:250
@@ -214,269 +124,3 @@ Container@INGAME_ROOT:
Width: 760
Height: 30
UseContrast: yes
Background@DEVELOPERMODE_BG:
Id:DEVELOPERMODE_BG
Delegate:DeveloperModeDelegate
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:350
Height:370
Visible:false
Children:
Label@LABEL_TITLE:
Id:LABEL_TITLE
X:(PARENT_RIGHT - WIDTH)/2
Y:20
Width:250
Height:25
Text:Developer Mode
Align:Center
Checkbox@CHECKBOX_SHROUD
Id:CHECKBOX_SHROUD
X:30
Y:50
Height:20
Width:PARENT_RIGHT - 30
Text:Disable Shroud
Button@GIVE_EXPLORATION
Id:GIVE_EXPLORATION
X:30
Y:80
Width:200
Height:20
Text: Give Exploration
Checkbox@CHECKBOX_PATHDEBUG:
Id:CHECKBOX_PATHDEBUG
X:30
Y:110
Width:PARENT_RIGHT - 30
Height:20
Text:Show Unit Paths
Button@GIVE_CASH
Id:GIVE_CASH
X:30
Y:140
Width:200
Height:20
Text: Give Cash
Checkbox@INSTANT_BUILD
Id:INSTANT_BUILD
X:30
Y:170
Width:PARENT_RIGHT - 30
Height:20
Text:Instant Build Speed
Checkbox@INSTANT_CHARGE
Id:INSTANT_CHARGE
X:30
Y:200
Width:PARENT_RIGHT - 30
Height:20
Text:Instant Charge Time (Special Powers)
Checkbox@ENABLE_TECH
Id:ENABLE_TECH
X:30
Y:230
Width:PARENT_RIGHT - 30
Height:20
Text:Build Everything
Checkbox@UNLIMITED_POWER
Id:UNLIMITED_POWER
X:30
Y:260
Width:PARENT_RIGHT - 30
Height:20
Text:Unlimited Power
Checkbox@BUILD_ANYWHERE
Id:BUILD_ANYWHERE
X:30
Y:290
Width:PARENT_RIGHT - 30
Height:20
Text:Build Anywhere
Background@PERF_BG:
ClickThrough:true
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
Container@OBSERVER_ROOT:
Id:OBSERVER_ROOT
Visible:true
Delegate:IngameObserverChromeDelegate
Children:
WorldInteractionController:
X:0
Y:0
Width:WINDOW_RIGHT
Height:WINDOW_BOTTOM
ViewportScrollController:
X:0
Y:0
Width:WINDOW_RIGHT
Height:WINDOW_BOTTOM
Timer@GAME_TIMER:
Id:GAME_TIMER
X: WINDOW_RIGHT/2
Y: 10
Background@POSTGAME_BG:
Id:POSTGAME_BG
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:400
Height:100
Background:dialog4
Visible:false
Children:
Label@TEXT:
Id:TEXT
X:(PARENT_RIGHT - WIDTH)/2
Y:(PARENT_BOTTOM - HEIGHT)/2
Width:200
Height:40
Align:Center
Bold:True
SpecialPowerBin@INGAME_POWERS_BIN:
Id:INGAME_POWERS_BIN
X:0
Y:25
Button@INGAME_OPTIONS_BUTTON:
Id:INGAME_OPTIONS_BUTTON
X:0
Y:0
Width:160
Height:25
Text:Options
Bold:True
WorldTooltip:
Background@INGAME_OPTIONS_BG:
Id:INGAME_OPTIONS_BG
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:300
Height:320
Visible:false
Children:
Label@LABEL_TITLE:
Id:LABEL_TITLE
X:(PARENT_RIGHT - WIDTH)/2
Y:20
Width:250
Height:25
Text:Options
Align:Center
Bold:True
Button@RESUME:
Id:RESUME
X:(PARENT_RIGHT - WIDTH)/2
Y:60
Width:160
Height:25
Text:Resume
Bold:True
Button@SETTINGS:
Id:SETTINGS
X:(PARENT_RIGHT - WIDTH)/2
Y:100
Width:160
Height:25
Text:Settings
Bold:True
Button@MUSIC:
Id:MUSIC
X:(PARENT_RIGHT - WIDTH)/2
Y:140
Width:160
Height:25
Text:Music
Bold:True
Button@SURRENDER:
Id:SURRENDER
X:(PARENT_RIGHT - WIDTH)/2
Y:180
Width:160
Height:25
Text:Surrender
Bold:True
Button@DISCONNECT:
Id:DISCONNECT
X:(PARENT_RIGHT - WIDTH)/2
Y:220
Width:160
Height:25
Text:Disconnect
Bold:True
Button@QUIT:
Id:QUIT
X:(PARENT_RIGHT - WIDTH)/2
Y:260
Width:160
Height:25
Text:Quit
Bold:True
ChatDisplay@CHAT_DISPLAY:
Id:CHAT_DISPLAY
X:250
Y:WINDOW_BOTTOM - HEIGHT - 30
Width: 760
Height: 200
DrawBackground: False
RemoveTime:250
ChatEntry@CHAT_ENTRY:
Id:CHAT_ENTRY
X:250
Y:WINDOW_BOTTOM - HEIGHT
Width: 760
Height: 30
Background@PERF_BG:
ClickThrough:true
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@FMVPLAYER:
Id:FMVPLAYER
Width:WINDOW_RIGHT
Height:WINDOW_BOTTOM
Background:dialog4
Children:
VqaPlayer:
Id:PLAYER
X:0
Y:0
Width:WINDOW_RIGHT
Height:WINDOW_BOTTOM

View File

@@ -0,0 +1,54 @@
Container@INGAME_MENU:
Id:INGAME_MENU
Width:WINDOW_RIGHT
Height:WINDOW_BOTTOM
Delegate:CncIngameMenuLogic
Children:
Image@RETICLE:
X:(WINDOW_RIGHT-WIDTH)/2
Y:(WINDOW_BOTTOM-HEIGHT)/2
Width:512
Height:512
ImageCollection:shellmap
ImageName:reticle
ScanLine:
Width:WINDOW_RIGHT
Height:WINDOW_BOTTOM
Background@BORDER:
Width:WINDOW_RIGHT
Height:WINDOW_BOTTOM
Background:shellmapborder
Container@MENUS:
X:(WINDOW_RIGHT-WIDTH)/2
Y:WINDOW_BOTTOM-33-HEIGHT-10
Width:740
Height:35
Children:
CncMenuButton@QUIT_BUTTON:
Id:QUIT_BUTTON
X:0
Y:0
Width:140
Height:35
Text:Exit Game
CncMenuButton@SURRENDER_BUTTON:
Id:SURRENDER_BUTTON
X:150
Y:0
Width:140
Height:35
Text:Surrender
CncMenuButton@SETTINGS_BUTTON:
Id:SETTINGS_BUTTON
X:450
Y:0
Width:140
Height:35
Text:Settings
CncMenuButton@RESUME_BUTTON:
Id:RESUME_BUTTON
X:600
Y:0
Width:140
Height:35
Text:Resume

View File

@@ -69,6 +69,7 @@ ChromeLayout:
mods/cnc/chrome/mapchooser.yaml
mods/cnc/chrome/replaybrowser.yaml
mods/cnc/chrome/ingame.yaml
mods/cnc/chrome/ingamemenu.yaml
Weapons:
mods/cnc/weapons.yaml