untangling WorldRenderer from World

This commit is contained in:
Bob
2010-10-12 01:11:56 +13:00
parent 1c1483377c
commit 597dba8584
17 changed files with 162 additions and 124 deletions

View File

@@ -11,21 +11,21 @@
using System.Collections.Generic;
using OpenRA.FileFormats;
using OpenRA.Traits;
using OpenRA.Widgets.Delegates;
using OpenRA.Widgets.Delegates;
using OpenRA.Graphics;
namespace OpenRA.Mods.RA
{
class ColorPickerPaletteModifierInfo : TraitInfo<ColorPickerPaletteModifier> {}
class ColorPickerPaletteModifier : IPaletteModifier, IWorldLoaded
class ColorPickerPaletteModifier : IPalette, IPaletteModifier
{
PaletteFormat format;
public void WorldLoaded(World w)
{
// Copy the base palette for the colorpicker
var info = Rules.Info["world"].Traits.Get<PlayerColorPaletteInfo>();
public void InitPalette( WorldRenderer wr )
{
var info = Rules.Info["player"].Traits.Get<PlayerColorPaletteInfo>();
format = info.PaletteFormat;
w.WorldRenderer.AddPalette("colorpicker", w.WorldRenderer.GetPalette(info.BasePalette));
wr.AddPalette("colorpicker", wr.GetPalette(info.BasePalette));
}
public void AdjustPalette(Dictionary<string, Palette> palettes)
@@ -33,6 +33,6 @@ namespace OpenRA.Mods.RA
palettes["colorpicker"] = new Palette(palettes["colorpicker"],
new PlayerColorRemap(LobbyDelegate.CurrentColorPreview1,
LobbyDelegate.CurrentColorPreview2, format));
}
}
}
}