diff --git a/OpenRA.FileFormats/Session.cs b/OpenRA.FileFormats/Session.cs index 89a896baca..e1eeccf68d 100644 --- a/OpenRA.FileFormats/Session.cs +++ b/OpenRA.FileFormats/Session.cs @@ -63,6 +63,7 @@ namespace OpenRA.FileFormats public readonly string[] Sequences = { }; public readonly string[] Chrome = { }; public readonly string[] Assemblies = { }; + public readonly string[] ChromeLayout = { }; public Manifest(string[] mods) { @@ -77,6 +78,7 @@ namespace OpenRA.FileFormats Sequences = YamlList(yaml, "Sequences"); Chrome = YamlList(yaml, "Chrome"); Assemblies = YamlList(yaml, "Assemblies"); + ChromeLayout = YamlList(yaml, "ChromeLayout"); } static string[] YamlList(Dictionary ys, string key) { return ys[key].Nodes.Keys.ToArray(); } diff --git a/OpenRA.Game/Chrome.cs b/OpenRA.Game/Chrome.cs index b9679ddf86..9900c2e83f 100644 --- a/OpenRA.Game/Chrome.cs +++ b/OpenRA.Game/Chrome.cs @@ -93,7 +93,7 @@ namespace OpenRA Sprite mapChooserSprite; int mapOffset = 0; - public Chrome(Renderer r) + public Chrome(Renderer r, Manifest m) { this.renderer = r; rgbaRenderer = new SpriteRenderer(renderer, true, renderer.RgbaSpriteShader); @@ -129,8 +129,8 @@ namespace OpenRA ready.PlayRepeating("ready"); clock = new Animation("clock"); - // TODO: make this generic - var widgetYaml = MiniYaml.FromFile("mods/cnc/menus.yaml"); + var widgetYaml = m.ChromeLayout.Select(a => MiniYaml.FromFile(a)).Aggregate(MiniYaml.Merge); + // Hack around a bug in MiniYaml widgetYaml.Values.FirstOrDefault().Value = widgetYaml.Keys.FirstOrDefault(); WidgetLoader.rootWidget = WidgetLoader.LoadWidget(widgetYaml.Values.FirstOrDefault()); diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 238a318e19..d20b323782 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -128,7 +128,7 @@ namespace OpenRA skipMakeAnims = false; Timer.Time( "map actors: {0}" ); - chrome = new Chrome(renderer); + chrome = new Chrome(renderer, manifest); Timer.Time( "chrome: {0}" ); Timer.Time( "----end ChangeMap" ); diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml index bdd9716123..2d4e254f8f 100644 --- a/mods/cnc/mod.yaml +++ b/mods/cnc/mod.yaml @@ -43,3 +43,6 @@ Chrome: Assemblies: mods/cnc/OpenRA.Mods.Cnc.dll: Cnc mod traits mods/ra/OpenRA.Mods.RA.dll: Red alert mod traits + +ChromeLayout: + mods/cnc/menus.yaml: \ No newline at end of file diff --git a/mods/ra/menus.yaml b/mods/ra/menus.yaml new file mode 100644 index 0000000000..e93e36231a --- /dev/null +++ b/mods/ra/menus.yaml @@ -0,0 +1,118 @@ +Container: + Children: + Background@MAINMENU_BG: + Id:MAINMENU_BG + X:WINDOW_RIGHT/2 - 125 + Y:WINDOW_BOTTOM/2 - 100 + Width:250 + Height:200 + Children: + Label@MAINMENU_LABEL_TITLE: + Id:MAINMENU_LABEL_TITLE + X:0 + Y:20 + Width:250 + Height:25 + Text:OpenRA Main Menu + Align:Center + Button@MAINMENU_BUTTON_JOIN: + Id:MAINMENU_BUTTON_JOIN + X:45 + Y:70 + Width:160 + Height:25 + Text:Join Game + Delegate:ServerBrowserDelegate + Button@MAINMENU_BUTTON_CREATE: + Id:MAINMENU_BUTTON_CREATE + X:45 + Y:110 + Width:160 + Height:25 + Text:Create Game + Delegate:MainMenuButtonsDelegate + Button@MAINMENU_BUTTON_QUIT: + Id:MAINMENU_BUTTON_QUIT + X:45 + Y:150 + Width:160 + Height:25 + Text:Quit + Delegate:MainMenuButtonsDelegate + Background@CREATESERVER_BG: + Id:CREATESERVER_BG + X:WINDOW_RIGHT/2 - 225 + Y:WINDOW_BOTTOM/2 - 72 + Width:450 + Height:145 + Visible:false + Children: + Label@CREATESERVER_LABEL_TITLE: + Id:CREATESERVER_LABEL_TITLE + X:0 + Y:20 + Width:250 + Height:25 + Text:Create Server + Align:Center + Button@CREATESERVER_CHECKBOX_HIDDEN: + Id:CREATESERVER_CHECKBOX_HIDDEN + X:100 + Y:60 + Width:20 + Height:20 + Label@CREATESERVER_LABEL_HIDDENGAME: + Id:CREATESERVER_LABEL_HIDDENGAME + X:135 + Y:60 + Width:300 + Height:25 + Text:Hide from Server Browser + Button@CREATESERVER_BUTTON_CANCEL: + Id:CREATESERVER_BUTTON_CANCEL + X:100 + Y:100 + Width:160 + Height:25 + Text:Cancel + Delegate:MainMenuButtonsDelegate + Button@CREATESERVER_BUTTON_START: + Id:CREATESERVER_BUTTON_START + X:270 + Y:100 + Width:160 + Height:25 + Text:Create + Delegate:MainMenuButtonsDelegate + Background@JOINSERVER_BG: + Id:JOINSERVER_BG + X:WINDOW_RIGHT/2 - 225 + Y:WINDOW_BOTTOM/2 - 200 + Width:450 + Height:400 + Visible:false + Children: + Label@JOINSERVER_LABEL_TITLE: + Id:JOINSERVER_LABEL_TITLE + X:0 + Y:20 + Width:450 + Height:25 + Text:Quick'n'dirty Server Browser + Align:Center + Button@JOINSERVER_BUTTON_DIRECTCONNECT: + Id:JOINSERVER_BUTTON_DIRECTCONNECT + X:PARENT_RIGHT - 360 + Y:PARENT_BOTTOM - 45 + Width:160 + Height:25 + Text:Direct Connect + Delegate:ServerBrowserDelegate + Button@JOINSERVER_BUTTON_CANCEL: + Id:JOINSERVER_BUTTON_CANCEL + X:PARENT_RIGHT - 180 + Y:PARENT_BOTTOM - 45 + Width:160 + Height:25 + Text:Cancel + Delegate:ServerBrowserDelegate \ No newline at end of file diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml index b95a3c7375..c225e66e7f 100644 --- a/mods/ra/mod.yaml +++ b/mods/ra/mod.yaml @@ -35,3 +35,6 @@ Chrome: Assemblies: mods/ra/OpenRA.Mods.RA.dll: Traits used + +ChromeLayout: + mods/ra/menus.yaml: \ No newline at end of file