Load the game into an intermediate state where RAInitDelegate can install packages, etc (an even bigger hack).
This commit is contained in:
@@ -253,15 +253,17 @@ namespace OpenRA
|
|||||||
JoinLocal();
|
JoinLocal();
|
||||||
viewport = new Viewport(new int2(Renderer.Resolution), Rectangle.Empty, Renderer);
|
viewport = new Viewport(new int2(Renderer.Resolution), Rectangle.Empty, Renderer);
|
||||||
|
|
||||||
//StartGame(ChooseShellmap());
|
|
||||||
|
|
||||||
// TODO: unhardcode this
|
|
||||||
modData.WidgetLoader.LoadWidget( new Dictionary<string,object>(), Widget.RootWidget, "PERF_BG" );
|
modData.WidgetLoader.LoadWidget( new Dictionary<string,object>(), Widget.RootWidget, "PERF_BG" );
|
||||||
Widget.OpenWindow("MAINMENU_BG");
|
Widget.OpenWindow("MAINMENU_INIT");
|
||||||
|
|
||||||
Game.orderManager.LastTickTime = Environment.TickCount;
|
Game.orderManager.LastTickTime = Environment.TickCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void LoadShellMap()
|
||||||
|
{
|
||||||
|
StartGame(ChooseShellmap());
|
||||||
|
}
|
||||||
|
|
||||||
static string ChooseShellmap()
|
static string ChooseShellmap()
|
||||||
{
|
{
|
||||||
var shellmaps = modData.AvailableMaps
|
var shellmaps = modData.AvailableMaps
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public void AddPalette(string name, Palette p)
|
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);
|
palettes.Add(name, p);
|
||||||
indices.Add(name, allocated++);
|
indices.Add(name, allocated++);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA
|
|||||||
public SheetBuilder SheetBuilder;
|
public SheetBuilder SheetBuilder;
|
||||||
public CursorSheetBuilder CursorSheetBuilder;
|
public CursorSheetBuilder CursorSheetBuilder;
|
||||||
public SpriteLoader SpriteLoader;
|
public SpriteLoader SpriteLoader;
|
||||||
public readonly HardwarePalette Palette;
|
public HardwarePalette Palette { get; private set; }
|
||||||
|
|
||||||
public ModData( params string[] mods )
|
public ModData( params string[] mods )
|
||||||
{
|
{
|
||||||
@@ -38,7 +38,12 @@ namespace OpenRA
|
|||||||
|
|
||||||
AvailableMaps = FindMaps( Manifest.Mods );
|
AvailableMaps = FindMaps( Manifest.Mods );
|
||||||
WidgetLoader = new WidgetLoader( this );
|
WidgetLoader = new WidgetLoader( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadHackyPalettes()
|
||||||
|
{
|
||||||
Palette = new HardwarePalette();
|
Palette = new HardwarePalette();
|
||||||
|
Palette.AddPalette("cursor", new Palette( FileSystem.Open( "cursor.pal" ), false ));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Sucks()
|
public void Sucks()
|
||||||
@@ -48,15 +53,19 @@ namespace OpenRA
|
|||||||
|
|
||||||
FileSystem.UnmountAll();
|
FileSystem.UnmountAll();
|
||||||
foreach (var dir in Manifest.Folders) FileSystem.Mount(dir);
|
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 );
|
ChromeProvider.Initialize( Manifest.Chrome );
|
||||||
SheetBuilder = new SheetBuilder( TextureChannel.Red );
|
SheetBuilder = new SheetBuilder( TextureChannel.Red );
|
||||||
CursorSheetBuilder = new CursorSheetBuilder( this );
|
CursorSheetBuilder = new CursorSheetBuilder( this );
|
||||||
|
|
||||||
SpriteLoader = new SpriteLoader(new[]{".shp"}, SheetBuilder);
|
SpriteLoader = new SpriteLoader(new[]{".shp"}, SheetBuilder);
|
||||||
CursorProvider.Initialize(Manifest.Cursors);
|
CursorProvider.Initialize(Manifest.Cursors);
|
||||||
|
LoadHackyPalettes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadPackages()
|
||||||
|
{
|
||||||
|
foreach (var pkg in Manifest.Packages) FileSystem.Mount(pkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<string> FindMapsIn(string dir)
|
public static IEnumerable<string> FindMapsIn(string dir)
|
||||||
@@ -124,6 +133,7 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
|
|
||||||
previousMapHadSequences = map.Sequences.Count > 0;
|
previousMapHadSequences = map.Sequences.Count > 0;
|
||||||
|
LoadHackyPalettes();
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -328,6 +328,7 @@
|
|||||||
<Compile Include="Buildings\ShakeOnDeath.cs" />
|
<Compile Include="Buildings\ShakeOnDeath.cs" />
|
||||||
<Compile Include="Buildings\SoundOnDamageTransition.cs" />
|
<Compile Include="Buildings\SoundOnDamageTransition.cs" />
|
||||||
<Compile Include="Activities\RAHarvesterDockSequence.cs" />
|
<Compile Include="Activities\RAHarvesterDockSequence.cs" />
|
||||||
|
<Compile Include="Widgets\Delegates\RAInitDelegate.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
|||||||
{
|
{
|
||||||
public class MainMenuButtonsDelegate : IWidgetDelegate
|
public class MainMenuButtonsDelegate : IWidgetDelegate
|
||||||
{
|
{
|
||||||
static bool FirstInit = true;
|
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public MainMenuButtonsDelegate([ObjectCreator.Param] Widget widget)
|
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_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_REPLAY_VIEWER").OnMouseUp = mi => { Widget.OpenWindow("REPLAYBROWSER_BG"); return true; };
|
||||||
widget.GetWidget("MAINMENU_BUTTON_QUIT").OnMouseUp = mi => { Game.Exit(); 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<string, object> { { "host", orderManager.Host }, { "port", orderManager.Port } } );
|
|
||||||
break;
|
|
||||||
case ConnectionState.NotConnected:
|
|
||||||
Widget.OpenWindow( "CONNECTION_FAILED_BG",
|
|
||||||
new Dictionary<string, object> { { "orderManager", orderManager } } );
|
|
||||||
break;
|
|
||||||
case ConnectionState.Connected:
|
|
||||||
var lobby = Game.OpenWindow(orderManager.world, "SERVER_LOBBY");
|
|
||||||
lobby.GetWidget<ChatDisplayWidget>("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<ChatDisplayWidget>("CHAT_DISPLAY").ClearChat();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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:
|
Background@MAINMENU_BG:
|
||||||
Id:MAINMENU_BG
|
Id:MAINMENU_BG
|
||||||
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:330
|
Height:330
|
||||||
|
Visible:true
|
||||||
Delegate:MainMenuButtonsDelegate
|
Delegate:MainMenuButtonsDelegate
|
||||||
Children:
|
Children:
|
||||||
Label@MAINMENU_LABEL_TITLE:
|
Label@MAINMENU_LABEL_TITLE:
|
||||||
|
|||||||
@@ -116,9 +116,6 @@ World:
|
|||||||
PaletteFromFile@effect:
|
PaletteFromFile@effect:
|
||||||
Name: effect
|
Name: effect
|
||||||
Filename: temperat.pal
|
Filename: temperat.pal
|
||||||
PaletteFromFile@cursor:
|
|
||||||
Name: cursor
|
|
||||||
Filename: temperat.pal
|
|
||||||
PaletteFromRGBA@shadow:
|
PaletteFromRGBA@shadow:
|
||||||
Name: shadow
|
Name: shadow
|
||||||
R: 0
|
R: 0
|
||||||
|
|||||||
Reference in New Issue
Block a user