diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 9ef4ea6c8a..e675ed267d 100755 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -253,15 +253,17 @@ namespace OpenRA JoinLocal(); viewport = new Viewport(new int2(Renderer.Resolution), Rectangle.Empty, Renderer); - //StartGame(ChooseShellmap()); - - // TODO: unhardcode this modData.WidgetLoader.LoadWidget( new Dictionary(), Widget.RootWidget, "PERF_BG" ); - Widget.OpenWindow("MAINMENU_BG"); + Widget.OpenWindow("MAINMENU_INIT"); Game.orderManager.LastTickTime = Environment.TickCount; } - + + public static void LoadShellMap() + { + StartGame(ChooseShellmap()); + } + static string ChooseShellmap() { var shellmaps = modData.AvailableMaps diff --git a/OpenRA.Game/Graphics/HardwarePalette.cs b/OpenRA.Game/Graphics/HardwarePalette.cs index 17f9368ed5..16322ef51b 100644 --- a/OpenRA.Game/Graphics/HardwarePalette.cs +++ b/OpenRA.Game/Graphics/HardwarePalette.cs @@ -51,6 +51,9 @@ namespace OpenRA.Graphics public void AddPalette(string name, Palette p) { + if (palettes.ContainsKey(name)) + throw new InvalidOperationException("Palette {0} has already been defined".F(name)); + palettes.Add(name, p); indices.Add(name, allocated++); } diff --git a/OpenRA.Game/ModData.cs b/OpenRA.Game/ModData.cs index 6bacc85464..a8404d4570 100755 --- a/OpenRA.Game/ModData.cs +++ b/OpenRA.Game/ModData.cs @@ -26,7 +26,7 @@ namespace OpenRA public SheetBuilder SheetBuilder; public CursorSheetBuilder CursorSheetBuilder; public SpriteLoader SpriteLoader; - public readonly HardwarePalette Palette; + public HardwarePalette Palette { get; private set; } public ModData( params string[] mods ) { @@ -38,7 +38,12 @@ namespace OpenRA AvailableMaps = FindMaps( Manifest.Mods ); WidgetLoader = new WidgetLoader( this ); + } + + void LoadHackyPalettes() + { Palette = new HardwarePalette(); + Palette.AddPalette("cursor", new Palette( FileSystem.Open( "cursor.pal" ), false )); } public void Sucks() @@ -48,15 +53,19 @@ namespace OpenRA FileSystem.UnmountAll(); foreach (var dir in Manifest.Folders) FileSystem.Mount(dir); - //foreach (var pkg in Manifest.Packages) FileSystem.Mount(pkg); - - Palette.AddPalette("cursor", new Palette( FileSystem.Open( "cursor.pal" ), false )); + ChromeProvider.Initialize( Manifest.Chrome ); SheetBuilder = new SheetBuilder( TextureChannel.Red ); CursorSheetBuilder = new CursorSheetBuilder( this ); SpriteLoader = new SpriteLoader(new[]{".shp"}, SheetBuilder); CursorProvider.Initialize(Manifest.Cursors); + LoadHackyPalettes(); + } + + public void LoadPackages() + { + foreach (var pkg in Manifest.Packages) FileSystem.Mount(pkg); } public static IEnumerable FindMapsIn(string dir) @@ -124,6 +133,7 @@ namespace OpenRA } previousMapHadSequences = map.Sequences.Count > 0; + LoadHackyPalettes(); return map; } diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 8cc58517d2..cab84f9bc1 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -328,6 +328,7 @@ + diff --git a/OpenRA.Mods.RA/Widgets/Delegates/MainMenuButtonsDelegate.cs b/OpenRA.Mods.RA/Widgets/Delegates/MainMenuButtonsDelegate.cs index 360e1237d9..469c37b9cb 100755 --- a/OpenRA.Mods.RA/Widgets/Delegates/MainMenuButtonsDelegate.cs +++ b/OpenRA.Mods.RA/Widgets/Delegates/MainMenuButtonsDelegate.cs @@ -18,8 +18,6 @@ namespace OpenRA.Mods.RA.Widgets.Delegates { public class MainMenuButtonsDelegate : IWidgetDelegate { - static bool FirstInit = true; - [ObjectCreator.UseCtor] public MainMenuButtonsDelegate([ObjectCreator.Param] Widget widget) { @@ -30,37 +28,6 @@ namespace OpenRA.Mods.RA.Widgets.Delegates widget.GetWidget("MAINMENU_BUTTON_MUSIC").OnMouseUp = mi => { Widget.OpenWindow("MUSIC_MENU"); return true; }; widget.GetWidget("MAINMENU_BUTTON_REPLAY_VIEWER").OnMouseUp = mi => { Widget.OpenWindow("REPLAYBROWSER_BG"); return true; }; widget.GetWidget("MAINMENU_BUTTON_QUIT").OnMouseUp = mi => { Game.Exit(); return true; }; - - if (FirstInit) - { - FirstInit = false; - Game.ConnectionStateChanged += orderManager => - { - Widget.CloseWindow(); - switch( orderManager.Connection.ConnectionState ) - { - case ConnectionState.PreConnecting: - Widget.OpenWindow("MAINMENU_BG"); - break; - case ConnectionState.Connecting: - Widget.OpenWindow( "CONNECTING_BG", - new Dictionary { { "host", orderManager.Host }, { "port", orderManager.Port } } ); - break; - case ConnectionState.NotConnected: - Widget.OpenWindow( "CONNECTION_FAILED_BG", - new Dictionary { { "orderManager", orderManager } } ); - break; - case ConnectionState.Connected: - var lobby = Game.OpenWindow(orderManager.world, "SERVER_LOBBY"); - lobby.GetWidget("CHAT_DISPLAY").ClearChat(); - lobby.GetWidget("CHANGEMAP_BUTTON").Visible = true; - lobby.GetWidget("LOCKTEAMS_CHECKBOX").Visible = true; - lobby.GetWidget("DISCONNECT_BUTTON").Visible = true; - //r.GetWidget("INGAME_ROOT").GetWidget("CHAT_DISPLAY").ClearChat(); - break; - } - }; - } } } } diff --git a/mods/ra/chrome/mainmenu.yaml b/mods/ra/chrome/mainmenu.yaml index b009b53c45..dce60ada04 100644 --- a/mods/ra/chrome/mainmenu.yaml +++ b/mods/ra/chrome/mainmenu.yaml @@ -1,9 +1,28 @@ +Background@MAINMENU_INIT: + Id:MAINMENU_INIT + X:(WINDOW_RIGHT - WIDTH)/2 + Y:(WINDOW_BOTTOM - HEIGHT)/2 + Width:250 + Height:330 + Visible:true + Delegate:RAInitDelegate + Children: + Button@FINISH_INIT: + Id:FINISH_INIT + X:45 + Y:70 + Width:160 + Height:25 + Text:START + Bold:True + Background@MAINMENU_BG: Id:MAINMENU_BG X:(WINDOW_RIGHT - WIDTH)/2 Y:(WINDOW_BOTTOM - HEIGHT)/2 Width:250 Height:330 + Visible:true Delegate:MainMenuButtonsDelegate Children: Label@MAINMENU_LABEL_TITLE: diff --git a/mods/ra/rules/system.yaml b/mods/ra/rules/system.yaml index a2ce9f1c9e..012105bcc0 100644 --- a/mods/ra/rules/system.yaml +++ b/mods/ra/rules/system.yaml @@ -116,9 +116,6 @@ World: PaletteFromFile@effect: Name: effect Filename: temperat.pal - PaletteFromFile@cursor: - Name: cursor - Filename: temperat.pal PaletteFromRGBA@shadow: Name: shadow R: 0