Add a Credits menu. Fixes #2864.

This commit is contained in:
Paul Chote
2013-06-17 01:57:07 +12:00
parent 66383a57d1
commit a0e224ec71
12 changed files with 164 additions and 7 deletions

View File

@@ -82,6 +82,15 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
}); });
}; };
settingsMenu.Get<ButtonWidget>("CREDITS_BUTTON").OnClick = () =>
{
Menu = MenuType.None;
Ui.OpenWindow("CREDITS_PANEL", new WidgetArgs()
{
{ "onExit", () => Menu = MenuType.Settings },
});
};
settingsMenu.Get<ButtonWidget>("SETTINGS_BUTTON").OnClick = () => settingsMenu.Get<ButtonWidget>("SETTINGS_BUTTON").OnClick = () =>
{ {
Menu = MenuType.None; Menu = MenuType.None;

View File

@@ -452,6 +452,7 @@
<Compile Include="Render\WithVoxelBody.cs" /> <Compile Include="Render\WithVoxelBody.cs" />
<Compile Include="Render\WithVoxelBarrel.cs" /> <Compile Include="Render\WithVoxelBarrel.cs" />
<Compile Include="Render\WithVoxelWalkerBody.cs" /> <Compile Include="Render\WithVoxelWalkerBody.cs" />
<Compile Include="Widgets\Logic\CreditsLogic.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj"> <ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
@@ -501,4 +502,4 @@ cd "$(SolutionDir)thirdparty/"
copy "FuzzyLogicLibrary.dll" "$(SolutionDir)" copy "FuzzyLogicLibrary.dll" "$(SolutionDir)"
cd "$(SolutionDir)"</PostBuildEvent> cd "$(SolutionDir)"</PostBuildEvent>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@@ -0,0 +1,46 @@
#region Copyright & License Information
/*
* Copyright 2007-2013 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.FileFormats;
using OpenRA.Widgets;
namespace OpenRA.Mods.RA.Widgets.Logic
{
public class CreditsLogic
{
[ObjectCreator.UseCtor]
public CreditsLogic(Widget widget, Action onExit)
{
var panel = widget.Get("CREDITS_PANEL");
panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = () =>
{
Ui.CloseWindow();
onExit();
};
var scrollPanel = panel.Get<ScrollPanelWidget>("CREDITS_DISPLAY");
var template = scrollPanel.Get<LabelWidget>("CREDITS_TEMPLATE");
scrollPanel.RemoveChildren();
var lines = FileSystem.Open("AUTHORS").ReadAllLines();
foreach (var l in lines)
{
// Improve the formatting
var line = l.Replace("\t", " ").Replace("*", "\u2022");
var label = template.Clone() as LabelWidget;
label.GetText = () => line;
scrollPanel.AddChild(label);
}
}
}
}

View File

@@ -62,6 +62,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic
}); });
}; };
widget.Get<ButtonWidget>("MAINMENU_BUTTON_CREDITS").OnClick = () =>
{
Menu = MenuType.None;
Ui.OpenWindow("CREDITS_PANEL", new WidgetArgs()
{
{ "onExit", () => Menu = MenuType.Main },
});
};
widget.Get<ButtonWidget>("MAINMENU_BUTTON_REPLAY_VIEWER").OnClick = () => widget.Get<ButtonWidget>("MAINMENU_BUTTON_REPLAY_VIEWER").OnClick = () =>
{ {
Menu = MenuType.None; Menu = MenuType.None;

View File

@@ -0,0 +1,36 @@
Container@CREDITS_PANEL:
Logic:CreditsLogic
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - 400)/2
Width:400
Height:435
Children:
Label@CREDITS_TITLE:
Width:PARENT_RIGHT
Y:0-25
Font:BigBold
Contrast:true
Align:Center
Text:Credits
Background@bg:
Width:PARENT_RIGHT
Height:400
Background:panel-black
Children:
ScrollPanel@CREDITS_DISPLAY:
X:15
Y:15
Width:PARENT_RIGHT - 30
Height:PARENT_BOTTOM - 30
Children:
Label@CREDITS_TEMPLATE:
X:8
Height:16
VAlign:Top
Button@BACK_BUTTON:
X:PARENT_RIGHT-140
Y:400
Width:140
Height:35
Text:Back
Key:escape

View File

@@ -157,6 +157,12 @@ Container@MENU_BACKGROUND:
Width:140 Width:140
Height:35 Height:35
Text:Settings Text:Settings
Button@CREDITS_BUTTON:
X:450
Y:0
Width:140
Height:35
Text:Credits
Button@BACK_BUTTON: Button@BACK_BUTTON:
Key:escape Key:escape
X:600 X:600

View File

@@ -77,6 +77,7 @@ ChromeLayout:
mods/cnc/chrome/music.yaml mods/cnc/chrome/music.yaml
mods/cnc/chrome/modchooser.yaml mods/cnc/chrome/modchooser.yaml
mods/cnc/chrome/settings.yaml mods/cnc/chrome/settings.yaml
mods/cnc/chrome/credits.yaml
mods/cnc/chrome/cheats.yaml mods/cnc/chrome/cheats.yaml
mods/cnc/chrome/dialogs.yaml mods/cnc/chrome/dialogs.yaml
mods/cnc/chrome/objectives.yaml mods/cnc/chrome/objectives.yaml

View File

@@ -2,7 +2,7 @@ Background@MAINMENU:
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:460 Height:500
Visible:true Visible:true
Logic:MainMenuButtonsLogic Logic:MainMenuButtonsLogic
Children: Children:
@@ -63,16 +63,23 @@ Background@MAINMENU:
Height:25 Height:25
Text:Replay Viewer Text:Replay Viewer
Font:Bold Font:Bold
Button@MAINMENU_BUTTON_ASSET_BROWSER: Button@MAINMENU_BUTTON_CREDITS:
X:45 X:45
Y:350 Y:350
Width:160 Width:160
Height:25 Height:25
Text:Credits
Font:Bold
Button@MAINMENU_BUTTON_ASSET_BROWSER:
X:45
Y:390
Width:160
Height:25
Text:Asset Browser Text:Asset Browser
Font:Bold Font:Bold
Button@MAINMENU_BUTTON_QUIT: Button@MAINMENU_BUTTON_QUIT:
X:45 X:45
Y:390 Y:430
Width:160 Width:160
Height:25 Height:25
Text:Quit Text:Quit

View File

@@ -56,6 +56,7 @@ ChromeLayout:
mods/ra/chrome/ingame-observerstats.yaml mods/ra/chrome/ingame-observerstats.yaml
mods/d2k/chrome/mainmenu.yaml mods/d2k/chrome/mainmenu.yaml
mods/ra/chrome/settings.yaml mods/ra/chrome/settings.yaml
mods/ra/chrome/credits.yaml
mods/d2k/chrome/lobby.yaml mods/d2k/chrome/lobby.yaml
mods/d2k/chrome/color-picker.yaml mods/d2k/chrome/color-picker.yaml
mods/ra/chrome/map-chooser.yaml mods/ra/chrome/map-chooser.yaml

View File

@@ -0,0 +1,33 @@
Background@CREDITS_PANEL:
Logic:CreditsLogic
X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - 400)/2
Width:400
Height:450
Children:
Label@CREDITS_TITLE:
Width:PARENT_RIGHT
Y:20
Height:25
Font:Bold
Align:Center
Text:Credits
ScrollPanel@CREDITS_DISPLAY:
X:15
Y:50
Width:PARENT_RIGHT - 30
Height:345
Children:
Label@CREDITS_TEMPLATE:
X:8
Height:16
VAlign:Top
Button@BACK_BUTTON:
X:PARENT_RIGHT - 180
Y:PARENT_BOTTOM - 45
Width:160
Height:25
Text:Close
Font:Bold
Key:escape

View File

@@ -23,7 +23,7 @@ Container@MAINMENU:
X:(WINDOW_RIGHT - WIDTH)/8 X:(WINDOW_RIGHT - WIDTH)/8
Y:(WINDOW_BOTTOM - HEIGHT)/2 Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:250 Width:250
Height:555 Height:605
Logic:MainMenuButtonsLogic Logic:MainMenuButtonsLogic
Children: Children:
Label@MAINMENU_LABEL_TITLE: Label@MAINMENU_LABEL_TITLE:
@@ -83,16 +83,23 @@ Container@MAINMENU:
Height:35 Height:35
Text:Replay Viewer Text:Replay Viewer
Font:Bold Font:Bold
Button@MAINMENU_BUTTON_ASSET_BROWSER: Button@MAINMENU_BUTTON_CREDITS:
X:45 X:45
Y:430 Y:430
Width:160 Width:160
Height:35 Height:35
Text:Credits
Font:Bold
Button@MAINMENU_BUTTON_ASSET_BROWSER:
X:45
Y:480
Width:160
Height:35
Text:Asset Browser Text:Asset Browser
Font:Bold Font:Bold
Button@MAINMENU_BUTTON_QUIT: Button@MAINMENU_BUTTON_QUIT:
X:45 X:45
Y:480 Y:530
Width:160 Width:160
Height:35 Height:35
Text:Quit Text:Quit

View File

@@ -68,6 +68,7 @@ ChromeLayout:
mods/ra/chrome/ingame-observerstats.yaml mods/ra/chrome/ingame-observerstats.yaml
mods/ra/chrome/mainmenu.yaml mods/ra/chrome/mainmenu.yaml
mods/ra/chrome/settings.yaml mods/ra/chrome/settings.yaml
mods/ra/chrome/credits.yaml
mods/ra/chrome/lobby.yaml mods/ra/chrome/lobby.yaml
mods/ra/chrome/color-picker.yaml mods/ra/chrome/color-picker.yaml
mods/ra/chrome/map-chooser.yaml mods/ra/chrome/map-chooser.yaml