Load the main menu without loading mixes or creating a shellmap world. A giant hack.
This commit is contained in:
@@ -20,9 +20,9 @@ namespace OpenRA
|
|||||||
sequence = CursorProvider.GetCursorSequence(cursor);
|
sequence = CursorProvider.GetCursorSequence(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(WorldRenderer wr, int frame, float2 pos)
|
public void Draw(int frame, float2 pos)
|
||||||
{
|
{
|
||||||
sequence.GetSprite(frame).DrawAt(wr, pos - sequence.Hotspot, sequence.Palette);
|
sequence.GetSprite(frame).DrawAt(pos - sequence.Hotspot, Game.modData.Palette.GetPaletteIndex(sequence.Palette));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
|
|
||||||
Tick( orderManager );
|
Tick( orderManager );
|
||||||
if( orderManager.world != worldRenderer.world )
|
if( worldRenderer != null && orderManager.world != worldRenderer.world )
|
||||||
Tick( worldRenderer.world.orderManager );
|
Tick( worldRenderer.world.orderManager );
|
||||||
|
|
||||||
using (new PerfSample("render"))
|
using (new PerfSample("render"))
|
||||||
@@ -244,13 +244,16 @@ namespace OpenRA
|
|||||||
Console.WriteLine("Loading mods: {0}",string.Join(",",mods));
|
Console.WriteLine("Loading mods: {0}",string.Join(",",mods));
|
||||||
|
|
||||||
modData = new ModData( mods );
|
modData = new ModData( mods );
|
||||||
|
modData.Sucks();
|
||||||
|
|
||||||
Sound.Initialize();
|
Sound.Initialize();
|
||||||
PerfHistory.items["render"].hasNormalTick = false;
|
PerfHistory.items["render"].hasNormalTick = false;
|
||||||
PerfHistory.items["batches"].hasNormalTick = false;
|
PerfHistory.items["batches"].hasNormalTick = false;
|
||||||
|
|
||||||
JoinLocal();
|
JoinLocal();
|
||||||
|
viewport = new Viewport(new int2(Renderer.Resolution), Rectangle.Empty, Renderer);
|
||||||
|
|
||||||
StartGame(ChooseShellmap());
|
//StartGame(ChooseShellmap());
|
||||||
|
|
||||||
// TODO: unhardcode this
|
// 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" );
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Graphics
|
namespace OpenRA.Graphics
|
||||||
{
|
{
|
||||||
class HardwarePalette
|
public class HardwarePalette
|
||||||
{
|
{
|
||||||
public const int MaxPalettes = 64;
|
public const int MaxPalettes = 64;
|
||||||
int allocated = 0;
|
int allocated = 0;
|
||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Graphics
|
|||||||
Dictionary<string, Palette> palettes;
|
Dictionary<string, Palette> palettes;
|
||||||
Dictionary<string, int> indices;
|
Dictionary<string, int> indices;
|
||||||
|
|
||||||
public HardwarePalette(Map map)
|
public HardwarePalette()
|
||||||
{
|
{
|
||||||
palettes = new Dictionary<string, Palette>();
|
palettes = new Dictionary<string, Palette>();
|
||||||
indices = new Dictionary<string, int>();
|
indices = new Dictionary<string, int>();
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
public class SpriteLoader
|
public class SpriteLoader
|
||||||
{
|
{
|
||||||
public SpriteLoader( TileSet tileset, SheetBuilder sheetBuilder )
|
public SpriteLoader( string[] exts, SheetBuilder sheetBuilder )
|
||||||
{
|
{
|
||||||
exts = tileset.Extensions;
|
SheetBuilder = sheetBuilder;
|
||||||
SheetBuilder = sheetBuilder;
|
this.exts = exts;
|
||||||
sprites = new Cache<string, Sprite[]>( LoadSprites );
|
sprites = new Cache<string, Sprite[]>( LoadSprites );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,11 +84,12 @@ namespace OpenRA.Graphics
|
|||||||
public void DrawRegions( WorldRenderer wr, IInputHandler inputHandler )
|
public void DrawRegions( WorldRenderer wr, IInputHandler inputHandler )
|
||||||
{
|
{
|
||||||
renderer.BeginFrame(scrollPosition);
|
renderer.BeginFrame(scrollPosition);
|
||||||
|
if (wr != null)
|
||||||
|
wr.Draw();
|
||||||
|
|
||||||
wr.Draw();
|
|
||||||
Widget.DoDraw();
|
Widget.DoDraw();
|
||||||
var cursorName = Widget.RootWidget.GetCursorOuter(Viewport.LastMousePos) ?? "default";
|
var cursorName = Widget.RootWidget.GetCursorOuter(Viewport.LastMousePos) ?? "default";
|
||||||
new Cursor(cursorName).Draw(wr, (int)cursorFrame, Viewport.LastMousePos + Location);
|
new Cursor(cursorName).Draw((int)cursorFrame, Viewport.LastMousePos + Location);
|
||||||
|
|
||||||
renderer.EndFrame( inputHandler );
|
renderer.EndFrame( inputHandler );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace OpenRA.Graphics
|
|||||||
terrainRenderer = new TerrainRenderer(world, this);
|
terrainRenderer = new TerrainRenderer(world, this);
|
||||||
shroudRenderer = new ShroudRenderer(world);
|
shroudRenderer = new ShroudRenderer(world);
|
||||||
uiOverlay = new UiOverlay();
|
uiOverlay = new UiOverlay();
|
||||||
palette = new HardwarePalette(world.Map);
|
this.palette = Game.modData.Palette;
|
||||||
|
|
||||||
foreach( var pal in world.traitDict.ActorsWithTraitMultiple<IPalette>( world ) )
|
foreach( var pal in world.traitDict.ActorsWithTraitMultiple<IPalette>( world ) )
|
||||||
pal.Trait.InitPalette( this );
|
pal.Trait.InitPalette( this );
|
||||||
|
|||||||
@@ -1,121 +1,133 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
* 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
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
* see LICENSE.
|
* see LICENSE.
|
||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
|
|
||||||
namespace OpenRA
|
namespace OpenRA
|
||||||
{
|
{
|
||||||
public class ModData
|
public class ModData
|
||||||
{
|
{
|
||||||
public readonly Manifest Manifest;
|
public readonly Manifest Manifest;
|
||||||
public readonly ObjectCreator ObjectCreator;
|
public readonly ObjectCreator ObjectCreator;
|
||||||
public readonly Dictionary<string, MapStub> AvailableMaps;
|
public readonly Dictionary<string, MapStub> AvailableMaps;
|
||||||
public readonly WidgetLoader WidgetLoader;
|
public readonly WidgetLoader WidgetLoader;
|
||||||
public ILoadScreen LoadScreen = null;
|
public ILoadScreen LoadScreen = null;
|
||||||
public SheetBuilder SheetBuilder;
|
public SheetBuilder SheetBuilder;
|
||||||
public CursorSheetBuilder CursorSheetBuilder;
|
public CursorSheetBuilder CursorSheetBuilder;
|
||||||
public SpriteLoader SpriteLoader;
|
public SpriteLoader SpriteLoader;
|
||||||
|
public readonly HardwarePalette Palette;
|
||||||
public ModData( params string[] mods )
|
|
||||||
{
|
public ModData( params string[] mods )
|
||||||
Manifest = new Manifest( mods );
|
{
|
||||||
ObjectCreator = new ObjectCreator( Manifest );
|
Manifest = new Manifest( mods );
|
||||||
LoadScreen = ObjectCreator.CreateObject<ILoadScreen>(Manifest.LoadScreen);
|
ObjectCreator = new ObjectCreator( Manifest );
|
||||||
LoadScreen.Init();
|
LoadScreen = ObjectCreator.CreateObject<ILoadScreen>(Manifest.LoadScreen);
|
||||||
LoadScreen.Display();
|
LoadScreen.Init();
|
||||||
|
LoadScreen.Display();
|
||||||
// all this manipulation of static crap here is nasty and breaks
|
|
||||||
// horribly when you use ModData in unexpected ways.
|
AvailableMaps = FindMaps( Manifest.Mods );
|
||||||
|
WidgetLoader = new WidgetLoader( this );
|
||||||
FileSystem.LoadFromManifest( Manifest );
|
Palette = new HardwarePalette();
|
||||||
ChromeProvider.Initialize( Manifest.Chrome );
|
}
|
||||||
SheetBuilder = new SheetBuilder( TextureChannel.Red );
|
|
||||||
CursorSheetBuilder = new CursorSheetBuilder( this );
|
public void Sucks()
|
||||||
AvailableMaps = FindMaps( mods );
|
{
|
||||||
WidgetLoader = new WidgetLoader( this );
|
// all this manipulation of static crap here is nasty and breaks
|
||||||
}
|
// horribly when you use ModData in unexpected ways.
|
||||||
|
|
||||||
public static IEnumerable<string> FindMapsIn(string dir)
|
FileSystem.UnmountAll();
|
||||||
{
|
foreach (var dir in Manifest.Folders) FileSystem.Mount(dir);
|
||||||
string[] NoMaps = { };
|
//foreach (var pkg in Manifest.Packages) FileSystem.Mount(pkg);
|
||||||
|
|
||||||
if (!Directory.Exists(dir))
|
Palette.AddPalette("cursor", new Palette( FileSystem.Open( "cursor.pal" ), false ));
|
||||||
return NoMaps;
|
ChromeProvider.Initialize( Manifest.Chrome );
|
||||||
|
SheetBuilder = new SheetBuilder( TextureChannel.Red );
|
||||||
// todo: look for compressed maps too.
|
CursorSheetBuilder = new CursorSheetBuilder( this );
|
||||||
return Directory.GetDirectories(dir)
|
|
||||||
.Concat(Directory.GetFiles(dir, "*.zip"))
|
SpriteLoader = new SpriteLoader(new[]{".shp"}, SheetBuilder);
|
||||||
.Concat(Directory.GetFiles(dir, "*.oramap"));
|
CursorProvider.Initialize(Manifest.Cursors);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<string, MapStub> FindMaps(string[] mods)
|
public static IEnumerable<string> FindMapsIn(string dir)
|
||||||
{
|
{
|
||||||
var paths = mods.SelectMany(p => FindMapsIn("mods{0}{1}{0}maps{0}".F(Path.DirectorySeparatorChar, p)))
|
string[] NoMaps = { };
|
||||||
.Concat(mods.SelectMany(p => FindMapsIn("{1}maps{0}{2}{0}".F(Path.DirectorySeparatorChar, Game.SupportDir, p))));
|
|
||||||
|
if (!Directory.Exists(dir))
|
||||||
Dictionary<string, MapStub> ret = new Dictionary<string, MapStub>();
|
return NoMaps;
|
||||||
foreach (var path in paths)
|
|
||||||
{
|
return Directory.GetDirectories(dir)
|
||||||
var map = new MapStub(path);
|
.Concat(Directory.GetFiles(dir, "*.zip"))
|
||||||
if (ret.ContainsKey(map.Uid))
|
.Concat(Directory.GetFiles(dir, "*.oramap"));
|
||||||
System.Console.WriteLine("Ignoring duplicate map: {0}", path);
|
}
|
||||||
else
|
|
||||||
ret.Add(map.Uid, map);
|
Dictionary<string, MapStub> FindMaps(string[] mods)
|
||||||
}
|
{
|
||||||
return ret;
|
var paths = mods.SelectMany(p => FindMapsIn("mods{0}{1}{0}maps{0}".F(Path.DirectorySeparatorChar, p)))
|
||||||
}
|
.Concat(mods.SelectMany(p => FindMapsIn("{1}maps{0}{2}{0}".F(Path.DirectorySeparatorChar, Game.SupportDir, p))));
|
||||||
|
|
||||||
string cachedTileset = null;
|
Dictionary<string, MapStub> ret = new Dictionary<string, MapStub>();
|
||||||
|
foreach (var path in paths)
|
||||||
|
{
|
||||||
|
var map = new MapStub(path);
|
||||||
|
if (ret.ContainsKey(map.Uid))
|
||||||
|
System.Console.WriteLine("Ignoring duplicate map: {0}", path);
|
||||||
|
else
|
||||||
|
ret.Add(map.Uid, map);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
string cachedTileset = null;
|
||||||
bool previousMapHadSequences = true;
|
bool previousMapHadSequences = true;
|
||||||
IFolder previousMapMount = null;
|
IFolder previousMapMount = null;
|
||||||
|
|
||||||
public Map PrepareMap(string uid)
|
public Map PrepareMap(string uid)
|
||||||
{
|
{
|
||||||
LoadScreen.Display();
|
LoadScreen.Display();
|
||||||
|
|
||||||
if (!AvailableMaps.ContainsKey(uid))
|
if (!AvailableMaps.ContainsKey(uid))
|
||||||
throw new InvalidDataException("Invalid map uid: {0}".F(uid));
|
throw new InvalidDataException("Invalid map uid: {0}".F(uid));
|
||||||
|
|
||||||
var map = new Map(AvailableMaps[uid].Path);
|
var map = new Map(AvailableMaps[uid].Path);
|
||||||
|
|
||||||
// unload the previous map mount if we have one
|
// unload the previous map mount if we have one
|
||||||
if (previousMapMount != null) FileSystem.Unmount(previousMapMount);
|
if (previousMapMount != null) FileSystem.Unmount(previousMapMount);
|
||||||
|
|
||||||
// Adds the map its container to the FileSystem
|
// Adds the map its container to the FileSystem
|
||||||
// allowing the map to use custom assets
|
// allowing the map to use custom assets
|
||||||
// Container should have the lowest priority of all (ie int max)
|
// Container should have the lowest priority of all (ie int max)
|
||||||
// Store a reference so we can unload it next time
|
// Store a reference so we can unload it next time
|
||||||
previousMapMount = FileSystem.OpenPackage(map.Path, int.MaxValue);
|
previousMapMount = FileSystem.OpenPackage(map.Path, int.MaxValue);
|
||||||
FileSystem.Mount(previousMapMount);
|
FileSystem.Mount(previousMapMount);
|
||||||
Rules.LoadRules(Manifest, map);
|
Rules.LoadRules(Manifest, map);
|
||||||
|
|
||||||
if (map.Tileset != cachedTileset
|
if (map.Tileset != cachedTileset
|
||||||
|| previousMapHadSequences || map.Sequences.Count > 0)
|
|| previousMapHadSequences || map.Sequences.Count > 0)
|
||||||
{
|
{
|
||||||
SheetBuilder = new SheetBuilder( TextureChannel.Red );
|
SheetBuilder = new SheetBuilder( TextureChannel.Red );
|
||||||
SpriteLoader = new SpriteLoader(Rules.TileSets[map.Tileset], SheetBuilder);
|
SpriteLoader = new SpriteLoader( Rules.TileSets[map.Tileset].Extensions, SheetBuilder );
|
||||||
CursorSheetBuilder = new CursorSheetBuilder( this );
|
CursorSheetBuilder = new CursorSheetBuilder( this );
|
||||||
CursorProvider.Initialize(Manifest.Cursors);
|
CursorProvider.Initialize(Manifest.Cursors);
|
||||||
SequenceProvider.Initialize(Manifest.Sequences, map.Sequences);
|
SequenceProvider.Initialize(Manifest.Sequences, map.Sequences);
|
||||||
cachedTileset = map.Tileset;
|
cachedTileset = map.Tileset;
|
||||||
}
|
}
|
||||||
|
|
||||||
previousMapHadSequences = map.Sequences.Count > 0;
|
previousMapHadSequences = map.Sequences.Count > 0;
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ILoadScreen { void Display(); void Init(); }
|
public interface ILoadScreen { void Display(); void Init(); }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user