diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncMenuLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncMenuLogic.cs index 64d2152b7c..4abf3ca97e 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncMenuLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncMenuLogic.cs @@ -82,6 +82,15 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic }); }; + settingsMenu.Get("CREDITS_BUTTON").OnClick = () => + { + Menu = MenuType.None; + Ui.OpenWindow("CREDITS_PANEL", new WidgetArgs() + { + { "onExit", () => Menu = MenuType.Settings }, + }); + }; + settingsMenu.Get("SETTINGS_BUTTON").OnClick = () => { Menu = MenuType.None; diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index c78ce1584d..67f14a46b7 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -452,6 +452,7 @@ + @@ -501,4 +502,4 @@ cd "$(SolutionDir)thirdparty/" copy "FuzzyLogicLibrary.dll" "$(SolutionDir)" cd "$(SolutionDir)" - \ No newline at end of file + diff --git a/OpenRA.Mods.RA/Widgets/Logic/CreditsLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/CreditsLogic.cs new file mode 100644 index 0000000000..a87cbeb8da --- /dev/null +++ b/OpenRA.Mods.RA/Widgets/Logic/CreditsLogic.cs @@ -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("BACK_BUTTON").OnClick = () => + { + Ui.CloseWindow(); + onExit(); + }; + + var scrollPanel = panel.Get("CREDITS_DISPLAY"); + var template = scrollPanel.Get("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); + } + } + } +} diff --git a/OpenRA.Mods.RA/Widgets/Logic/MainMenuButtonsLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/MainMenuButtonsLogic.cs index 2ad69c8871..4edf081189 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/MainMenuButtonsLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/MainMenuButtonsLogic.cs @@ -62,6 +62,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic }); }; + widget.Get("MAINMENU_BUTTON_CREDITS").OnClick = () => + { + Menu = MenuType.None; + Ui.OpenWindow("CREDITS_PANEL", new WidgetArgs() + { + { "onExit", () => Menu = MenuType.Main }, + }); + }; + widget.Get("MAINMENU_BUTTON_REPLAY_VIEWER").OnClick = () => { Menu = MenuType.None; diff --git a/mods/cnc/chrome/credits.yaml b/mods/cnc/chrome/credits.yaml new file mode 100644 index 0000000000..349496c0ae --- /dev/null +++ b/mods/cnc/chrome/credits.yaml @@ -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 diff --git a/mods/cnc/chrome/mainmenu.yaml b/mods/cnc/chrome/mainmenu.yaml index 34f863f13b..2e38979737 100644 --- a/mods/cnc/chrome/mainmenu.yaml +++ b/mods/cnc/chrome/mainmenu.yaml @@ -157,6 +157,12 @@ Container@MENU_BACKGROUND: Width:140 Height:35 Text:Settings + Button@CREDITS_BUTTON: + X:450 + Y:0 + Width:140 + Height:35 + Text:Credits Button@BACK_BUTTON: Key:escape X:600 diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml index a306881e58..4a96823ff4 100644 --- a/mods/cnc/mod.yaml +++ b/mods/cnc/mod.yaml @@ -77,6 +77,7 @@ ChromeLayout: mods/cnc/chrome/music.yaml mods/cnc/chrome/modchooser.yaml mods/cnc/chrome/settings.yaml + mods/cnc/chrome/credits.yaml mods/cnc/chrome/cheats.yaml mods/cnc/chrome/dialogs.yaml mods/cnc/chrome/objectives.yaml diff --git a/mods/d2k/chrome/mainmenu.yaml b/mods/d2k/chrome/mainmenu.yaml index c9092ef014..aecf6dac50 100644 --- a/mods/d2k/chrome/mainmenu.yaml +++ b/mods/d2k/chrome/mainmenu.yaml @@ -2,7 +2,7 @@ Background@MAINMENU: X:(WINDOW_RIGHT - WIDTH)/2 Y:(WINDOW_BOTTOM - HEIGHT)/2 Width:250 - Height:460 + Height:500 Visible:true Logic:MainMenuButtonsLogic Children: @@ -63,16 +63,23 @@ Background@MAINMENU: Height:25 Text:Replay Viewer Font:Bold - Button@MAINMENU_BUTTON_ASSET_BROWSER: + Button@MAINMENU_BUTTON_CREDITS: X:45 Y:350 Width:160 Height:25 + Text:Credits + Font:Bold + Button@MAINMENU_BUTTON_ASSET_BROWSER: + X:45 + Y:390 + Width:160 + Height:25 Text:Asset Browser Font:Bold Button@MAINMENU_BUTTON_QUIT: X:45 - Y:390 + Y:430 Width:160 Height:25 Text:Quit diff --git a/mods/d2k/mod.yaml b/mods/d2k/mod.yaml index 4c78d4effc..b3a9f65c94 100644 --- a/mods/d2k/mod.yaml +++ b/mods/d2k/mod.yaml @@ -56,6 +56,7 @@ ChromeLayout: mods/ra/chrome/ingame-observerstats.yaml mods/d2k/chrome/mainmenu.yaml mods/ra/chrome/settings.yaml + mods/ra/chrome/credits.yaml mods/d2k/chrome/lobby.yaml mods/d2k/chrome/color-picker.yaml mods/ra/chrome/map-chooser.yaml diff --git a/mods/ra/chrome/credits.yaml b/mods/ra/chrome/credits.yaml new file mode 100644 index 0000000000..1d61851732 --- /dev/null +++ b/mods/ra/chrome/credits.yaml @@ -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 + diff --git a/mods/ra/chrome/mainmenu.yaml b/mods/ra/chrome/mainmenu.yaml index caac30da30..993445a453 100644 --- a/mods/ra/chrome/mainmenu.yaml +++ b/mods/ra/chrome/mainmenu.yaml @@ -23,7 +23,7 @@ Container@MAINMENU: X:(WINDOW_RIGHT - WIDTH)/8 Y:(WINDOW_BOTTOM - HEIGHT)/2 Width:250 - Height:555 + Height:605 Logic:MainMenuButtonsLogic Children: Label@MAINMENU_LABEL_TITLE: @@ -83,16 +83,23 @@ Container@MAINMENU: Height:35 Text:Replay Viewer Font:Bold - Button@MAINMENU_BUTTON_ASSET_BROWSER: + Button@MAINMENU_BUTTON_CREDITS: X:45 Y:430 Width:160 Height:35 + Text:Credits + Font:Bold + Button@MAINMENU_BUTTON_ASSET_BROWSER: + X:45 + Y:480 + Width:160 + Height:35 Text:Asset Browser Font:Bold Button@MAINMENU_BUTTON_QUIT: X:45 - Y:480 + Y:530 Width:160 Height:35 Text:Quit diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml index bc44858485..f70736a854 100644 --- a/mods/ra/mod.yaml +++ b/mods/ra/mod.yaml @@ -68,6 +68,7 @@ ChromeLayout: mods/ra/chrome/ingame-observerstats.yaml mods/ra/chrome/mainmenu.yaml mods/ra/chrome/settings.yaml + mods/ra/chrome/credits.yaml mods/ra/chrome/lobby.yaml mods/ra/chrome/color-picker.yaml mods/ra/chrome/map-chooser.yaml