Load the main menu without loading mixes or creating a shellmap world. A giant hack.

This commit is contained in:
Paul Chote
2011-01-19 22:25:04 +13:00
parent 8d2a78abc6
commit 6776d6f906
7 changed files with 148 additions and 132 deletions

View File

@@ -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));
} }
} }
} }

View File

@@ -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" );

View File

@@ -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>();

View File

@@ -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 );
} }

View File

@@ -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 );
} }

View File

@@ -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 );

View File

@@ -1,4 +1,4 @@
#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
@@ -26,6 +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 ModData( params string[] mods ) public ModData( params string[] mods )
{ {
@@ -35,15 +36,27 @@ namespace OpenRA
LoadScreen.Init(); LoadScreen.Init();
LoadScreen.Display(); LoadScreen.Display();
AvailableMaps = FindMaps( Manifest.Mods );
WidgetLoader = new WidgetLoader( this );
Palette = new HardwarePalette();
}
public void Sucks()
{
// all this manipulation of static crap here is nasty and breaks // all this manipulation of static crap here is nasty and breaks
// horribly when you use ModData in unexpected ways. // horribly when you use ModData in unexpected ways.
FileSystem.LoadFromManifest( Manifest ); 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 ); ChromeProvider.Initialize( Manifest.Chrome );
SheetBuilder = new SheetBuilder( TextureChannel.Red ); SheetBuilder = new SheetBuilder( TextureChannel.Red );
CursorSheetBuilder = new CursorSheetBuilder( this ); CursorSheetBuilder = new CursorSheetBuilder( this );
AvailableMaps = FindMaps( mods );
WidgetLoader = new WidgetLoader( this ); SpriteLoader = new SpriteLoader(new[]{".shp"}, SheetBuilder);
CursorProvider.Initialize(Manifest.Cursors);
} }
public static IEnumerable<string> FindMapsIn(string dir) public static IEnumerable<string> FindMapsIn(string dir)
@@ -53,7 +66,6 @@ namespace OpenRA
if (!Directory.Exists(dir)) if (!Directory.Exists(dir))
return NoMaps; return NoMaps;
// todo: look for compressed maps too.
return Directory.GetDirectories(dir) return Directory.GetDirectories(dir)
.Concat(Directory.GetFiles(dir, "*.zip")) .Concat(Directory.GetFiles(dir, "*.zip"))
.Concat(Directory.GetFiles(dir, "*.oramap")); .Concat(Directory.GetFiles(dir, "*.oramap"));
@@ -104,7 +116,7 @@ namespace OpenRA
|| 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);