untangling WorldRenderer from World
This commit is contained in:
@@ -6,19 +6,19 @@
|
|||||||
* 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;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
using OpenRA.Server;
|
using OpenRA.Server;
|
||||||
using OpenRA.Support;
|
using OpenRA.Support;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
@@ -32,6 +32,8 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static ModData modData;
|
public static ModData modData;
|
||||||
public static World world;
|
public static World world;
|
||||||
|
public static WorldRenderer worldRenderer;
|
||||||
|
|
||||||
public static Viewport viewport;
|
public static Viewport viewport;
|
||||||
public static Settings Settings;
|
public static Settings Settings;
|
||||||
|
|
||||||
@@ -48,6 +50,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
viewport = new Viewport(new float2(Renderer.Resolution), map.TopLeft, map.BottomRight, Renderer);
|
viewport = new Viewport(new float2(Renderer.Resolution), map.TopLeft, map.BottomRight, Renderer);
|
||||||
world = new World(modData.Manifest, map, orderManager);
|
world = new World(modData.Manifest, map, orderManager);
|
||||||
|
worldRenderer = new WorldRenderer(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void MoveViewport(int2 loc)
|
public static void MoveViewport(int2 loc)
|
||||||
@@ -92,18 +95,18 @@ namespace OpenRA
|
|||||||
internal static int RenderFrame = 0;
|
internal static int RenderFrame = 0;
|
||||||
internal static int LocalTick = 0;
|
internal static int LocalTick = 0;
|
||||||
const int NetTickScale = 3; // 120ms net tick for 40ms local tick
|
const int NetTickScale = 3; // 120ms net tick for 40ms local tick
|
||||||
|
|
||||||
internal static event Action<OrderManager> ConnectionStateChanged = _ => { };
|
internal static event Action<OrderManager> ConnectionStateChanged = _ => { };
|
||||||
static ConnectionState lastConnectionState = ConnectionState.PreConnecting;
|
static ConnectionState lastConnectionState = ConnectionState.PreConnecting;
|
||||||
public static int LocalClientId { get { return orderManager.Connection.LocalClientId; } }
|
public static int LocalClientId { get { return orderManager.Connection.LocalClientId; } }
|
||||||
|
|
||||||
static void Tick( World world, OrderManager orderManager, Viewport viewPort )
|
static void Tick( World world, OrderManager orderManager, Viewport viewPort )
|
||||||
{
|
{
|
||||||
if (orderManager.Connection.ConnectionState != lastConnectionState)
|
if (orderManager.Connection.ConnectionState != lastConnectionState)
|
||||||
{
|
{
|
||||||
lastConnectionState = orderManager.Connection.ConnectionState;
|
lastConnectionState = orderManager.Connection.ConnectionState;
|
||||||
ConnectionStateChanged( orderManager );
|
ConnectionStateChanged( orderManager );
|
||||||
}
|
}
|
||||||
|
|
||||||
int t = Environment.TickCount;
|
int t = Environment.TickCount;
|
||||||
int dt = t - lastTime;
|
int dt = t - lastTime;
|
||||||
@@ -131,6 +134,7 @@ namespace OpenRA
|
|||||||
world.OrderGenerator.Tick(world);
|
world.OrderGenerator.Tick(world);
|
||||||
world.Selection.Tick(world);
|
world.Selection.Tick(world);
|
||||||
world.Tick();
|
world.Tick();
|
||||||
|
worldRenderer.Tick();
|
||||||
|
|
||||||
PerfHistory.Tick();
|
PerfHistory.Tick();
|
||||||
}
|
}
|
||||||
@@ -143,7 +147,7 @@ namespace OpenRA
|
|||||||
using (new PerfSample("render"))
|
using (new PerfSample("render"))
|
||||||
{
|
{
|
||||||
++RenderFrame;
|
++RenderFrame;
|
||||||
viewport.DrawRegions(world.WorldRenderer, world);
|
viewport.DrawRegions(worldRenderer, world);
|
||||||
Sound.SetListenerPosition(viewport.Location + .5f * new float2(viewport.Width, viewport.Height));
|
Sound.SetListenerPosition(viewport.Location + .5f * new float2(viewport.Width, viewport.Height));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,9 +178,9 @@ namespace OpenRA
|
|||||||
if (orderManager.GameStarted) return;
|
if (orderManager.GameStarted) return;
|
||||||
Widget.SelectedWidget = null;
|
Widget.SelectedWidget = null;
|
||||||
|
|
||||||
LocalTick = 0;
|
LocalTick = 0;
|
||||||
|
|
||||||
orderManager.StartGame();
|
orderManager.StartGame();
|
||||||
viewport.RefreshPalette();
|
viewport.RefreshPalette();
|
||||||
AfterGameStart( world );
|
AfterGameStart( world );
|
||||||
}
|
}
|
||||||
@@ -221,24 +225,24 @@ namespace OpenRA
|
|||||||
|
|
||||||
internal static void Initialize(Arguments args)
|
internal static void Initialize(Arguments args)
|
||||||
{
|
{
|
||||||
AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly;
|
AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly;
|
||||||
|
|
||||||
var defaultSupport = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
|
var defaultSupport = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
|
||||||
+ Path.DirectorySeparatorChar + "OpenRA";
|
+ Path.DirectorySeparatorChar + "OpenRA";
|
||||||
|
|
||||||
SupportDir = args.GetValue("SupportDir", defaultSupport);
|
SupportDir = args.GetValue("SupportDir", defaultSupport);
|
||||||
Settings = new Settings(SupportDir + "settings.yaml", args);
|
Settings = new Settings(SupportDir + "settings.yaml", args);
|
||||||
|
|
||||||
// force master server upgrade -- remove once everyone is switched over.
|
// force master server upgrade -- remove once everyone is switched over.
|
||||||
if (Settings.Server.MasterServer == "http://open-ra.org/master/")
|
if (Settings.Server.MasterServer == "http://open-ra.org/master/")
|
||||||
Settings.Server.MasterServer = "http://master.open-ra.org/";
|
Settings.Server.MasterServer = "http://master.open-ra.org/";
|
||||||
|
|
||||||
Settings.Save();
|
Settings.Save();
|
||||||
|
|
||||||
Log.LogPath = SupportDir + "Logs" + Path.DirectorySeparatorChar;
|
Log.LogPath = SupportDir + "Logs" + Path.DirectorySeparatorChar;
|
||||||
Log.AddChannel("perf", "perf.log");
|
Log.AddChannel("perf", "perf.log");
|
||||||
Log.AddChannel("debug", "debug.log");
|
Log.AddChannel("debug", "debug.log");
|
||||||
Log.AddChannel("sync", "syncreport.log");
|
Log.AddChannel("sync", "syncreport.log");
|
||||||
|
|
||||||
FileSystem.Mount("."); // Needed to access shaders
|
FileSystem.Mount("."); // Needed to access shaders
|
||||||
Renderer.Initialize( Game.Settings.Graphics.Mode );
|
Renderer.Initialize( Game.Settings.Graphics.Mode );
|
||||||
@@ -259,13 +263,14 @@ namespace OpenRA
|
|||||||
PerfHistory.items["render"].hasNormalTick = false;
|
PerfHistory.items["render"].hasNormalTick = false;
|
||||||
PerfHistory.items["batches"].hasNormalTick = false;
|
PerfHistory.items["batches"].hasNormalTick = false;
|
||||||
PerfHistory.items["text"].hasNormalTick = false;
|
PerfHistory.items["text"].hasNormalTick = false;
|
||||||
PerfHistory.items["cursor"].hasNormalTick = false;
|
PerfHistory.items["cursor"].hasNormalTick = false;
|
||||||
|
|
||||||
|
|
||||||
JoinLocal();
|
JoinLocal();
|
||||||
StartGame(modData.Manifest.ShellmapUid);
|
StartGame(modData.Manifest.ShellmapUid);
|
||||||
|
|
||||||
Game.AfterGameStart += world => Widget.OpenWindow("INGAME_ROOT", new Dictionary<string,object>{{"world", world}});
|
Game.AfterGameStart += world => Widget.OpenWindow("INGAME_ROOT", new Dictionary<string,object>{{"world", world}});
|
||||||
Game.AfterGameStart += world => Widget.OpenWindow("INGAME_ROOT", new Dictionary<string,object>{{"world", world}});
|
|
||||||
Game.ConnectionStateChanged += orderManager =>
|
Game.ConnectionStateChanged += orderManager =>
|
||||||
{
|
{
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
@@ -309,13 +314,13 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Exit() { quit = true; }
|
||||||
public static void Exit() { quit = true; }
|
|
||||||
public static Action<Color,string,string> AddChatLine = (c,n,s) => {};
|
public static Action<Color,string,string> AddChatLine = (c,n,s) => {};
|
||||||
|
|
||||||
|
public static void Debug(string s, params object[] args)
|
||||||
public static void Debug(string s, params object[] args)
|
{
|
||||||
{
|
AddChatLine(Color.White, "Debug", String.Format(s,args));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Disconnect()
|
public static void Disconnect()
|
||||||
@@ -327,25 +332,25 @@ namespace OpenRA
|
|||||||
|
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
Widget.OpenWindow("MAINMENU_BG");
|
Widget.OpenWindow("MAINMENU_BG");
|
||||||
Widget.OpenWindow("MAINMENU_BG");
|
}
|
||||||
}
|
|
||||||
|
static string baseSupportDir = null;
|
||||||
static string baseSupportDir = null;
|
public static string SupportDir
|
||||||
public static string SupportDir
|
{
|
||||||
{
|
set
|
||||||
set
|
{
|
||||||
{
|
var dir = value;
|
||||||
var dir = value;
|
|
||||||
|
// Expand paths relative to the personal directory
|
||||||
// Expand paths relative to the personal directory
|
if (dir.ElementAt(0) == '~')
|
||||||
if (dir.ElementAt(0) == '~')
|
dir = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + dir.Substring(1);
|
||||||
dir = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + dir.Substring(1);
|
|
||||||
|
if (!Directory.Exists(dir))
|
||||||
if (!Directory.Exists(dir))
|
Directory.CreateDirectory(dir);
|
||||||
Directory.CreateDirectory(dir);
|
|
||||||
|
baseSupportDir = dir + Path.DirectorySeparatorChar;
|
||||||
}
|
}
|
||||||
}
|
get { return baseSupportDir; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T CreateObject<T>( string name )
|
public static T CreateObject<T>( string name )
|
||||||
@@ -353,4 +358,4 @@ namespace OpenRA
|
|||||||
return modData.ObjectCreator.CreateObject<T>( name );
|
return modData.ObjectCreator.CreateObject<T>( name );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public void RefreshPalette()
|
public void RefreshPalette()
|
||||||
{
|
{
|
||||||
Game.world.WorldRenderer.palette.Update(
|
Game.worldRenderer.palette.Update(
|
||||||
Game.world.WorldActor.TraitsImplementing<IPaletteModifier>());
|
Game.world.WorldActor.TraitsImplementing<IPaletteModifier>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ namespace OpenRA.Graphics
|
|||||||
terrainRenderer = new TerrainRenderer(world, this);
|
terrainRenderer = new TerrainRenderer(world, this);
|
||||||
uiOverlay = new UiOverlay();
|
uiOverlay = new UiOverlay();
|
||||||
palette = new HardwarePalette(world.Map);
|
palette = new HardwarePalette(world.Map);
|
||||||
|
|
||||||
|
foreach( var pal in world.traitDict.ActorsWithTraitMultiple<IPalette>( world ) )
|
||||||
|
pal.Trait.InitPalette( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetPaletteIndex(string name) { return palette.GetPaletteIndex(name); }
|
public int GetPaletteIndex(string name) { return palette.GetPaletteIndex(name); }
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ namespace OpenRA
|
|||||||
|
|
||||||
PlayerRef = pr;
|
PlayerRef = pr;
|
||||||
|
|
||||||
RegisterPlayerColor(world, Palette);
|
|
||||||
PlayerActor = world.CreateActor("Player", new TypeDictionary{ new OwnerInit( this ) });
|
PlayerActor = world.CreateActor("Player", new TypeDictionary{ new OwnerInit( this ) });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,18 +84,9 @@ namespace OpenRA
|
|||||||
ClientIndex = client.Index;
|
ClientIndex = client.Index;
|
||||||
PlayerRef = pr;
|
PlayerRef = pr;
|
||||||
|
|
||||||
RegisterPlayerColor(world, Palette);
|
|
||||||
PlayerActor = world.CreateActor("Player", new TypeDictionary{ new OwnerInit( this ) });
|
PlayerActor = world.CreateActor("Player", new TypeDictionary{ new OwnerInit( this ) });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterPlayerColor(World world, string palette)
|
|
||||||
{
|
|
||||||
var info = Rules.Info["world"].Traits.Get<PlayerColorPaletteInfo>();
|
|
||||||
var newpal = new Palette(world.WorldRenderer.GetPalette(info.BasePalette),
|
|
||||||
new PlayerColorRemap(Color, Color2, info.PaletteFormat));
|
|
||||||
world.WorldRenderer.AddPalette(palette, newpal);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void GiveAdvice(string advice)
|
public void GiveAdvice(string advice)
|
||||||
{
|
{
|
||||||
Sound.PlayToPlayer(this, advice);
|
Sound.PlayToPlayer(this, advice);
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ namespace OpenRA.Traits
|
|||||||
public interface IDamageModifier { float GetDamageModifier( WarheadInfo warhead ); }
|
public interface IDamageModifier { float GetDamageModifier( WarheadInfo warhead ); }
|
||||||
public interface ISpeedModifier { float GetSpeedModifier(); }
|
public interface ISpeedModifier { float GetSpeedModifier(); }
|
||||||
public interface IFirepowerModifier { float GetFirepowerModifier(); }
|
public interface IFirepowerModifier { float GetFirepowerModifier(); }
|
||||||
|
public interface IPalette { void InitPalette( WorldRenderer wr ); }
|
||||||
public interface IPaletteModifier { void AdjustPalette(Dictionary<string,Palette> b); }
|
public interface IPaletteModifier { void AdjustPalette(Dictionary<string,Palette> b); }
|
||||||
public interface IPips { IEnumerable<PipType> GetPips(Actor self); }
|
public interface IPips { IEnumerable<PipType> GetPips(Actor self); }
|
||||||
public interface ITags { IEnumerable<TagType> GetTags(); }
|
public interface ITags { IEnumerable<TagType> GetTags(); }
|
||||||
|
|||||||
@@ -9,13 +9,34 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
|
using OpenRA.Graphics;
|
||||||
namespace OpenRA.Traits
|
namespace OpenRA.Traits
|
||||||
{
|
{
|
||||||
public class PlayerColorPaletteInfo : TraitInfo<PlayerColorPalette>
|
public class PlayerColorPaletteInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
public readonly string BasePalette = null;
|
public readonly string BasePalette = null;
|
||||||
|
public readonly string BaseName = "player";
|
||||||
public readonly PaletteFormat PaletteFormat = PaletteFormat.ra;
|
public readonly PaletteFormat PaletteFormat = PaletteFormat.ra;
|
||||||
|
|
||||||
|
public object Create( ActorInitializer init ) { return new PlayerColorPalette( init.self.Owner, this ); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PlayerColorPalette {}
|
public class PlayerColorPalette : IPalette
|
||||||
|
{
|
||||||
|
readonly Player owner;
|
||||||
|
readonly PlayerColorPaletteInfo info;
|
||||||
|
public PlayerColorPalette( Player owner, PlayerColorPaletteInfo info )
|
||||||
|
{
|
||||||
|
this.owner = owner;
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InitPalette( WorldRenderer wr )
|
||||||
|
{
|
||||||
|
var paletteName = "{0}{1}".F( info.BaseName, owner.Index );
|
||||||
|
var newpal = new Palette(wr.GetPalette(info.BasePalette),
|
||||||
|
new PlayerColorRemap(owner.Color, owner.Color2, info.PaletteFormat));
|
||||||
|
wr.AddPalette(paletteName, newpal);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace OpenRA.Widgets
|
|||||||
cachedFrame = frame;
|
cachedFrame = frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
Game.Renderer.WorldSpriteRenderer.DrawSprite(sprite,RenderOrigin, Game.world.WorldRenderer, palette);
|
Game.Renderer.WorldSpriteRenderer.DrawSprite(sprite,RenderOrigin, Game.worldRenderer, palette);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public static void DrawSHP(Sprite s, float2 pos)
|
public static void DrawSHP(Sprite s, float2 pos)
|
||||||
{
|
{
|
||||||
Game.Renderer.WorldSpriteRenderer.DrawSprite(s,pos, Game.world.WorldRenderer, "chrome");
|
Game.Renderer.WorldSpriteRenderer.DrawSprite(s,pos, Game.worldRenderer, "chrome");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DrawPanel(string collection, Rectangle Bounds)
|
public static void DrawPanel(string collection, Rectangle Bounds)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Widgets
|
|||||||
Game.Renderer.LineRenderer.DrawLine(a, a + c, Color.White, Color.White);
|
Game.Renderer.LineRenderer.DrawLine(a, a + c, Color.White, Color.White);
|
||||||
|
|
||||||
foreach (var u in SelectActorsInBox(world, selbox.Value.First, selbox.Value.Second))
|
foreach (var u in SelectActorsInBox(world, selbox.Value.First, selbox.Value.Second))
|
||||||
world.WorldRenderer.DrawSelectionBox(u, Color.Yellow);
|
Game.worldRenderer.DrawSelectionBox(u, Color.Yellow);
|
||||||
}
|
}
|
||||||
|
|
||||||
float2 dragStart, dragEnd;
|
float2 dragStart, dragEnd;
|
||||||
|
|||||||
@@ -57,8 +57,6 @@ namespace OpenRA
|
|||||||
public readonly Map Map;
|
public readonly Map Map;
|
||||||
public readonly TileSet TileSet;
|
public readonly TileSet TileSet;
|
||||||
|
|
||||||
public readonly WorldRenderer WorldRenderer;
|
|
||||||
|
|
||||||
IOrderGenerator orderGenerator_;
|
IOrderGenerator orderGenerator_;
|
||||||
public IOrderGenerator OrderGenerator
|
public IOrderGenerator OrderGenerator
|
||||||
{
|
{
|
||||||
@@ -97,8 +95,6 @@ namespace OpenRA
|
|||||||
TileSet = Rules.TileSets[Map.Tileset];
|
TileSet = Rules.TileSets[Map.Tileset];
|
||||||
TileSet.LoadTiles();
|
TileSet.LoadTiles();
|
||||||
|
|
||||||
WorldRenderer = new WorldRenderer(this);
|
|
||||||
|
|
||||||
WorldActor = CreateActor( "World", new TypeDictionary() );
|
WorldActor = CreateActor( "World", new TypeDictionary() );
|
||||||
Queries = new AllQueries(this);
|
Queries = new AllQueries(this);
|
||||||
|
|
||||||
@@ -170,8 +166,6 @@ namespace OpenRA
|
|||||||
Game.viewport.Tick();
|
Game.viewport.Tick();
|
||||||
while (frameEndActions.Count != 0)
|
while (frameEndActions.Count != 0)
|
||||||
frameEndActions.Dequeue()(this);
|
frameEndActions.Dequeue()(this);
|
||||||
|
|
||||||
WorldRenderer.Tick();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Actor> Actors { get { return actors; } }
|
public IEnumerable<Actor> Actors { get { return actors; } }
|
||||||
|
|||||||
@@ -11,21 +11,21 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Widgets.Delegates;
|
using OpenRA.Widgets.Delegates;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
class ColorPickerPaletteModifierInfo : TraitInfo<ColorPickerPaletteModifier> {}
|
class ColorPickerPaletteModifierInfo : TraitInfo<ColorPickerPaletteModifier> {}
|
||||||
|
|
||||||
class ColorPickerPaletteModifier : IPaletteModifier, IWorldLoaded
|
class ColorPickerPaletteModifier : IPalette, IPaletteModifier
|
||||||
{
|
{
|
||||||
PaletteFormat format;
|
PaletteFormat format;
|
||||||
public void WorldLoaded(World w)
|
public void InitPalette( WorldRenderer wr )
|
||||||
{
|
{
|
||||||
// Copy the base palette for the colorpicker
|
var info = Rules.Info["player"].Traits.Get<PlayerColorPaletteInfo>();
|
||||||
var info = Rules.Info["world"].Traits.Get<PlayerColorPaletteInfo>();
|
|
||||||
format = info.PaletteFormat;
|
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)
|
public void AdjustPalette(Dictionary<string, Palette> palettes)
|
||||||
@@ -33,6 +33,6 @@ namespace OpenRA.Mods.RA
|
|||||||
palettes["colorpicker"] = new Palette(palettes["colorpicker"],
|
palettes["colorpicker"] = new Palette(palettes["colorpicker"],
|
||||||
new PlayerColorRemap(LobbyDelegate.CurrentColorPreview1,
|
new PlayerColorRemap(LobbyDelegate.CurrentColorPreview1,
|
||||||
LobbyDelegate.CurrentColorPreview2, format));
|
LobbyDelegate.CurrentColorPreview2, format));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,12 +21,20 @@ namespace OpenRA.Mods.RA
|
|||||||
public object Create(ActorInitializer init) { return new PaletteFromCurrentTheatre(init.world, this); }
|
public object Create(ActorInitializer init) { return new PaletteFromCurrentTheatre(init.world, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class PaletteFromCurrentTheatre
|
class PaletteFromCurrentTheatre : IPalette
|
||||||
{
|
{
|
||||||
|
readonly World world;
|
||||||
|
readonly PaletteFromCurrentTheatreInfo info;
|
||||||
|
|
||||||
public PaletteFromCurrentTheatre(World world, PaletteFromCurrentTheatreInfo info)
|
public PaletteFromCurrentTheatre(World world, PaletteFromCurrentTheatreInfo info)
|
||||||
{
|
{
|
||||||
world.WorldRenderer.AddPalette(info.Name,
|
this.world = world;
|
||||||
new Palette(FileSystem.Open(world.TileSet.Palette), info.Transparent));
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void InitPalette( OpenRA.Graphics.WorldRenderer wr )
|
||||||
|
{
|
||||||
|
wr.AddPalette( info.Name, new Palette( FileSystem.Open( world.TileSet.Palette ), info.Transparent ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
@@ -23,16 +24,20 @@ namespace OpenRA.Mods.RA
|
|||||||
public object Create(ActorInitializer init) { return new PaletteFromFile(init.world, this); }
|
public object Create(ActorInitializer init) { return new PaletteFromFile(init.world, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class PaletteFromFile
|
class PaletteFromFile : IPalette
|
||||||
{
|
{
|
||||||
|
readonly World world;
|
||||||
|
readonly PaletteFromFileInfo info;
|
||||||
public PaletteFromFile(World world, PaletteFromFileInfo info)
|
public PaletteFromFile(World world, PaletteFromFileInfo info)
|
||||||
{
|
{
|
||||||
if (info.Theater == null ||
|
this.world = world;
|
||||||
info.Theater.ToLowerInvariant() == world.Map.Theater.ToLowerInvariant())
|
this.info = info;
|
||||||
{
|
}
|
||||||
world.WorldRenderer.AddPalette(info.Name,
|
|
||||||
new Palette(FileSystem.Open(info.Filename), info.Transparent));
|
public void InitPalette( WorldRenderer wr )
|
||||||
}
|
{
|
||||||
|
if( info.Theater == null || info.Theater.ToLowerInvariant() == world.Map.Theater.ToLowerInvariant() )
|
||||||
|
wr.AddPalette( info.Name, new Palette( FileSystem.Open( info.Filename ), info.Transparent ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
@@ -26,15 +27,21 @@ namespace OpenRA.Mods.RA
|
|||||||
public object Create(ActorInitializer init) { return new PaletteFromRGBA(init.world, this); }
|
public object Create(ActorInitializer init) { return new PaletteFromRGBA(init.world, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class PaletteFromRGBA
|
class PaletteFromRGBA : IPalette
|
||||||
{
|
{
|
||||||
|
readonly World world;
|
||||||
|
readonly PaletteFromRGBAInfo info;
|
||||||
public PaletteFromRGBA(World world, PaletteFromRGBAInfo info)
|
public PaletteFromRGBA(World world, PaletteFromRGBAInfo info)
|
||||||
{
|
{
|
||||||
if (info.Theatre == null ||
|
this.world = world;
|
||||||
info.Theatre.ToLowerInvariant() == world.Map.Theater.ToLowerInvariant())
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InitPalette( WorldRenderer wr )
|
||||||
|
{
|
||||||
|
if (info.Theatre == null || info.Theatre.ToLowerInvariant() == world.Map.Theater.ToLowerInvariant())
|
||||||
{
|
{
|
||||||
// TODO: This shouldn't rely on a base palette
|
// TODO: This shouldn't rely on a base palette
|
||||||
var wr = world.WorldRenderer;
|
|
||||||
var pal = wr.GetPalette("terrain");
|
var pal = wr.GetPalette("terrain");
|
||||||
wr.AddPalette(info.Name, new Palette(pal, new SingleColorRemap(Color.FromArgb(info.A, info.R, info.G, info.B))));
|
wr.AddPalette(info.Name, new Palette(pal, new SingleColorRemap(Color.FromArgb(info.A, info.R, info.G, info.B))));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
@@ -18,17 +19,21 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
public readonly string Name = "shroud";
|
public readonly string Name = "shroud";
|
||||||
public readonly bool IsFog = false;
|
public readonly bool IsFog = false;
|
||||||
public object Create(ActorInitializer init) { return new ShroudPalette(init.world, this); }
|
public object Create(ActorInitializer init) { return new ShroudPalette(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class ShroudPalette
|
class ShroudPalette : IPalette
|
||||||
{
|
{
|
||||||
public ShroudPalette(World world, ShroudPaletteInfo info)
|
readonly ShroudPaletteInfo info;
|
||||||
|
public ShroudPalette( ShroudPaletteInfo info )
|
||||||
{
|
{
|
||||||
// TODO: This shouldn't rely on a base palette
|
this.info = info;
|
||||||
var wr = world.WorldRenderer;
|
}
|
||||||
var pal = wr.GetPalette("terrain");
|
|
||||||
wr.AddPalette(info.Name, new Palette(pal, new ShroudPaletteRemap(info.IsFog)));
|
public void InitPalette( WorldRenderer wr )
|
||||||
|
{
|
||||||
|
var pal = wr.GetPalette( "terrain" );
|
||||||
|
wr.AddPalette( info.Name, new Palette( pal, new ShroudPaletteRemap( info.IsFog ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,10 +37,12 @@ Player:
|
|||||||
ActorGroupProxy:
|
ActorGroupProxy:
|
||||||
DeveloperMode:
|
DeveloperMode:
|
||||||
HackyAI:
|
HackyAI:
|
||||||
|
PlayerColorPalette:
|
||||||
|
BasePalette: terrain
|
||||||
|
PaletteFormat: cnc
|
||||||
|
|
||||||
World:
|
World:
|
||||||
ScreenShaker:
|
ScreenShaker:
|
||||||
ColorPickerPaletteModifier:
|
|
||||||
NukePaletteEffect:
|
NukePaletteEffect:
|
||||||
WaterPaletteRotation:
|
WaterPaletteRotation:
|
||||||
CncMode: true
|
CncMode: true
|
||||||
@@ -50,9 +52,6 @@ World:
|
|||||||
Bridges: bridge1, bridge2, bridge3, bridge4
|
Bridges: bridge1, bridge2, bridge3, bridge4
|
||||||
PaletteFromCurrentTheatre:
|
PaletteFromCurrentTheatre:
|
||||||
Name: terrain
|
Name: terrain
|
||||||
PlayerColorPalette:
|
|
||||||
BasePalette: terrain
|
|
||||||
PaletteFormat: cnc
|
|
||||||
PaletteFromFile@chrome:
|
PaletteFromFile@chrome:
|
||||||
Name: chrome
|
Name: chrome
|
||||||
Filename: temperat.pal
|
Filename: temperat.pal
|
||||||
@@ -85,6 +84,7 @@ World:
|
|||||||
G: 0
|
G: 0
|
||||||
B: 0
|
B: 0
|
||||||
A: 180
|
A: 180
|
||||||
|
ColorPickerPaletteModifier:
|
||||||
ShroudPalette@shroud:
|
ShroudPalette@shroud:
|
||||||
ShroudPalette@fog:
|
ShroudPalette@fog:
|
||||||
IsFog: yes
|
IsFog: yes
|
||||||
|
|||||||
@@ -98,11 +98,11 @@ Player:
|
|||||||
ActorGroupProxy:
|
ActorGroupProxy:
|
||||||
DeveloperMode:
|
DeveloperMode:
|
||||||
HackyAI:
|
HackyAI:
|
||||||
|
PlayerColorPalette:
|
||||||
|
BasePalette: terrain
|
||||||
|
|
||||||
World:
|
World:
|
||||||
ScreenShaker:
|
ScreenShaker:
|
||||||
ColorPickerPaletteModifier:
|
|
||||||
WaterPaletteRotation:
|
WaterPaletteRotation:
|
||||||
ChronoshiftPaletteEffect:
|
ChronoshiftPaletteEffect:
|
||||||
NukePaletteEffect:
|
NukePaletteEffect:
|
||||||
@@ -119,8 +119,6 @@ World:
|
|||||||
WaterChance: .2
|
WaterChance: .2
|
||||||
PaletteFromCurrentTheatre:
|
PaletteFromCurrentTheatre:
|
||||||
Name: terrain
|
Name: terrain
|
||||||
PlayerColorPalette:
|
|
||||||
BasePalette: terrain
|
|
||||||
PaletteFromFile@chrome:
|
PaletteFromFile@chrome:
|
||||||
Name: chrome
|
Name: chrome
|
||||||
Filename: temperat.pal
|
Filename: temperat.pal
|
||||||
@@ -154,6 +152,7 @@ World:
|
|||||||
G: 0
|
G: 0
|
||||||
B: 0
|
B: 0
|
||||||
A: 180
|
A: 180
|
||||||
|
ColorPickerPaletteModifier:
|
||||||
ShroudPalette@shroud:
|
ShroudPalette@shroud:
|
||||||
ShroudPalette@fog:
|
ShroudPalette@fog:
|
||||||
IsFog: yes
|
IsFog: yes
|
||||||
|
|||||||
Reference in New Issue
Block a user