Start tidying things up
This commit is contained in:
@@ -244,7 +244,7 @@ namespace OpenRA
|
||||
Console.WriteLine("Loading mods: {0}",string.Join(",",mods));
|
||||
|
||||
modData = new ModData( mods );
|
||||
modData.Sucks();
|
||||
modData.LoadInitialAssets();
|
||||
|
||||
Sound.Initialize();
|
||||
PerfHistory.items["render"].hasNormalTick = false;
|
||||
@@ -252,10 +252,7 @@ namespace OpenRA
|
||||
|
||||
JoinLocal();
|
||||
viewport = new Viewport(new int2(Renderer.Resolution), Rectangle.Empty, Renderer);
|
||||
|
||||
modData.WidgetLoader.LoadWidget( new Dictionary<string,object>(), Widget.RootWidget, "PERF_BG" );
|
||||
modData.WidgetLoader.LoadWidget( new Dictionary<string,object>(), Widget.RootWidget, "MAINMENU_INIT" );
|
||||
|
||||
Game.orderManager.LastTickTime = Environment.TickCount;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,14 @@ namespace OpenRA.Graphics
|
||||
|
||||
public static void Initialize(string[] sequenceFiles)
|
||||
{
|
||||
// TODO: Convert cursor definitions to yaml and parse cursor palette info
|
||||
Game.modData.Palette.AddPalette("cursor", new Palette( FileSystem.Open( "cursor.pal" ), false ));
|
||||
|
||||
cursors = new Dictionary<string, CursorSequence>();
|
||||
|
||||
foreach (var f in sequenceFiles)
|
||||
LoadSequenceSource(f);
|
||||
|
||||
}
|
||||
|
||||
static void LoadSequenceSource(string filename)
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace OpenRA
|
||||
public CursorSheetBuilder CursorSheetBuilder;
|
||||
public SpriteLoader SpriteLoader;
|
||||
public HardwarePalette Palette { get; private set; }
|
||||
IFolder previousMapMount = null;
|
||||
|
||||
public ModData( params string[] mods )
|
||||
{
|
||||
@@ -40,32 +41,44 @@ namespace OpenRA
|
||||
WidgetLoader = new WidgetLoader( this );
|
||||
}
|
||||
|
||||
void LoadHackyPalettes()
|
||||
{
|
||||
Palette = new HardwarePalette();
|
||||
Palette.AddPalette("cursor", new Palette( FileSystem.Open( "cursor.pal" ), false ));
|
||||
}
|
||||
|
||||
public void Sucks()
|
||||
public void LoadInitialAssets()
|
||||
{
|
||||
// all this manipulation of static crap here is nasty and breaks
|
||||
// horribly when you use ModData in unexpected ways.
|
||||
|
||||
FileSystem.UnmountAll();
|
||||
foreach (var dir in Manifest.Folders) FileSystem.Mount(dir);
|
||||
foreach (var dir in Manifest.Folders)
|
||||
FileSystem.Mount(dir);
|
||||
|
||||
Palette = new HardwarePalette();
|
||||
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()
|
||||
public Map PrepareMap(string uid)
|
||||
{
|
||||
foreach (var pkg in Manifest.Packages) FileSystem.Mount(pkg);
|
||||
LoadScreen.Display();
|
||||
if (!AvailableMaps.ContainsKey(uid))
|
||||
throw new InvalidDataException("Invalid map uid: {0}".F(uid));
|
||||
var map = new Map(AvailableMaps[uid].Path);
|
||||
|
||||
// Maps may contain custom assets
|
||||
// TODO: why are they lowest priority? they should be highest.
|
||||
if (previousMapMount != null) FileSystem.Unmount(previousMapMount);
|
||||
previousMapMount = FileSystem.OpenPackage(map.Path, int.MaxValue);
|
||||
FileSystem.Mount(previousMapMount);
|
||||
|
||||
// Reinit all our assets
|
||||
LoadInitialAssets();
|
||||
foreach (var pkg in Manifest.Packages)
|
||||
FileSystem.Mount(pkg);
|
||||
|
||||
Rules.LoadRules(Manifest, map);
|
||||
SpriteLoader = new SpriteLoader( Rules.TileSets[map.Tileset].Extensions, SheetBuilder );
|
||||
SequenceProvider.Initialize(Manifest.Sequences, map.Sequences);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
public static IEnumerable<string> FindMapsIn(string dir)
|
||||
@@ -97,46 +110,6 @@ namespace OpenRA
|
||||
return ret;
|
||||
}
|
||||
|
||||
string cachedTileset = null;
|
||||
bool previousMapHadSequences = true;
|
||||
IFolder previousMapMount = null;
|
||||
|
||||
public Map PrepareMap(string uid)
|
||||
{
|
||||
LoadScreen.Display();
|
||||
|
||||
if (!AvailableMaps.ContainsKey(uid))
|
||||
throw new InvalidDataException("Invalid map uid: {0}".F(uid));
|
||||
|
||||
var map = new Map(AvailableMaps[uid].Path);
|
||||
|
||||
// unload the previous map mount if we have one
|
||||
if (previousMapMount != null) FileSystem.Unmount(previousMapMount);
|
||||
|
||||
// Adds the map its container to the FileSystem
|
||||
// allowing the map to use custom assets
|
||||
// Container should have the lowest priority of all (ie int max)
|
||||
// Store a reference so we can unload it next time
|
||||
previousMapMount = FileSystem.OpenPackage(map.Path, int.MaxValue);
|
||||
FileSystem.Mount(previousMapMount);
|
||||
Rules.LoadRules(Manifest, map);
|
||||
|
||||
if (map.Tileset != cachedTileset
|
||||
|| previousMapHadSequences || map.Sequences.Count > 0)
|
||||
{
|
||||
SheetBuilder = new SheetBuilder( TextureChannel.Red );
|
||||
SpriteLoader = new SpriteLoader( Rules.TileSets[map.Tileset].Extensions, SheetBuilder );
|
||||
CursorSheetBuilder = new CursorSheetBuilder( this );
|
||||
CursorProvider.Initialize(Manifest.Cursors);
|
||||
SequenceProvider.Initialize(Manifest.Sequences, map.Sequences);
|
||||
cachedTileset = map.Tileset;
|
||||
}
|
||||
|
||||
previousMapHadSequences = map.Sequences.Count > 0;
|
||||
LoadHackyPalettes();
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
public interface ILoadScreen { void Display(); void Init(); }
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
[ObjectCreator.UseCtor]
|
||||
public MainMenuButtonsDelegate([ObjectCreator.Param] Widget widget)
|
||||
{
|
||||
// Main menu is the default window
|
||||
Game.modData.WidgetLoader.LoadWidget( new Dictionary<string,object>(), Widget.RootWidget, "PERF_BG" );
|
||||
widget.GetWidget("MAINMENU_BUTTON_JOIN").OnMouseUp = mi => { Widget.OpenWindow("JOINSERVER_BG"); return true; };
|
||||
widget.GetWidget("MAINMENU_BUTTON_CREATE").OnMouseUp = mi => { Widget.OpenWindow("CREATESERVER_BG"); return true; };
|
||||
widget.GetWidget("MAINMENU_BUTTON_SETTINGS").OnMouseUp = mi => { Widget.OpenWindow("SETTINGS_MENU"); return true; };
|
||||
|
||||
@@ -45,18 +45,17 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
if (FileSystem.Exists("fake.mix"))
|
||||
ContinueLoading();
|
||||
ContinueLoading(widget);
|
||||
else
|
||||
{
|
||||
widget.GetWidget("INIT_DOWNLOAD").OnMouseUp = mi =>
|
||||
{
|
||||
ContinueLoading();
|
||||
ContinueLoading(widget);
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -86,10 +85,10 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
p.Start();
|
||||
}
|
||||
|
||||
void ContinueLoading()
|
||||
void ContinueLoading(Widget widget)
|
||||
{
|
||||
Game.modData.LoadPackages();
|
||||
Game.LoadShellMap();
|
||||
Widget.RootWidget.Children.Remove(widget);
|
||||
Widget.OpenWindow("MAINMENU_BG");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user