Include all the relevant palettes in the asset browser.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.FileSystem;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
@@ -26,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public object Create(ActorInitializer init) { return new PaletteFromCurrentTileset(init.World, this); }
|
||||
}
|
||||
|
||||
class PaletteFromCurrentTileset : ILoadsPalettes
|
||||
class PaletteFromCurrentTileset : ILoadsPalettes, IProvidesAssetBrowserPalettes
|
||||
{
|
||||
readonly World world;
|
||||
readonly PaletteFromCurrentTilesetInfo info;
|
||||
@@ -41,5 +42,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
wr.AddPalette(info.Name, new ImmutablePalette(GlobalFileSystem.Open(world.TileSet.Palette), info.ShadowIndex), info.AllowModifiers);
|
||||
}
|
||||
|
||||
public IEnumerable<string> PaletteNames { get { yield return info.Name; } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.FileSystem;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
@@ -29,7 +30,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public object Create(ActorInitializer init) { return new PaletteFromFile(init.World, this); }
|
||||
}
|
||||
|
||||
class PaletteFromFile : ILoadsPalettes
|
||||
class PaletteFromFile : ILoadsPalettes, IProvidesAssetBrowserPalettes
|
||||
{
|
||||
readonly World world;
|
||||
readonly PaletteFromFileInfo info;
|
||||
@@ -45,14 +46,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
wr.AddPalette(info.Name, new ImmutablePalette(GlobalFileSystem.Open(info.Filename), info.ShadowIndex), info.AllowModifiers);
|
||||
}
|
||||
|
||||
public string Filename
|
||||
public IEnumerable<string> PaletteNames
|
||||
{
|
||||
get { return info.Filename; }
|
||||
get
|
||||
{
|
||||
// Only expose the palette if it is available for the shellmap's tileset (which is a requirement for its use).
|
||||
if (info.Tileset == null || info.Tileset == world.TileSet.Id)
|
||||
yield return info.Name;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return info.Name; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
@@ -27,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public object Create(ActorInitializer init) { return new ShroudPalette(this); }
|
||||
}
|
||||
|
||||
class ShroudPalette : ILoadsPalettes
|
||||
class ShroudPalette : ILoadsPalettes, IProvidesAssetBrowserPalettes
|
||||
{
|
||||
readonly ShroudPaletteInfo info;
|
||||
|
||||
@@ -58,5 +59,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Color.FromArgb(128, 0, 0, 0),
|
||||
Color.FromArgb(64, 0, 0, 0)
|
||||
};
|
||||
|
||||
public IEnumerable<string> PaletteNames { get { yield return info.Name; } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,4 +71,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
CVec DeliveryOffset { get; }
|
||||
bool AllowDocking { get; }
|
||||
}
|
||||
|
||||
public interface IProvidesAssetBrowserPalettes
|
||||
{
|
||||
IEnumerable<string> PaletteNames { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,9 +369,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
bool ShowPaletteDropdown(DropDownButtonWidget dropdown, World world)
|
||||
{
|
||||
Func<PaletteFromFile, ScrollItemWidget, ScrollItemWidget> setupItem = (palette, itemTemplate) =>
|
||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (name, itemTemplate) =>
|
||||
{
|
||||
var name = palette.Name;
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => currentPalette == name,
|
||||
() => currentPalette = name);
|
||||
@@ -380,7 +379,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
return item;
|
||||
};
|
||||
|
||||
var palettes = world.WorldActor.TraitsImplementing<PaletteFromFile>();
|
||||
var palettes = world.WorldActor.TraitsImplementing<IProvidesAssetBrowserPalettes>()
|
||||
.SelectMany(p => p.PaletteNames);
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 280, palettes, setupItem);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,11 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using OpenRA.FileSystem;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.D2k.Traits
|
||||
@@ -29,7 +31,7 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
public object Create(ActorInitializer init) { return new FogPaletteFromR8(this); }
|
||||
}
|
||||
|
||||
class FogPaletteFromR8 : ILoadsPalettes
|
||||
class FogPaletteFromR8 : ILoadsPalettes, IProvidesAssetBrowserPalettes
|
||||
{
|
||||
readonly FogPaletteFromR8Info info;
|
||||
public FogPaletteFromR8(FogPaletteFromR8Info info) { this.info = info; }
|
||||
@@ -55,5 +57,7 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
|
||||
wr.AddPalette(info.Name, new ImmutablePalette(colors), info.AllowModifiers);
|
||||
}
|
||||
|
||||
public IEnumerable<string> PaletteNames { get { yield return info.Name; } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,11 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using OpenRA.FileSystem;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.D2k.Traits
|
||||
@@ -29,7 +31,7 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
public object Create(ActorInitializer init) { return new PaletteFromR8(this); }
|
||||
}
|
||||
|
||||
class PaletteFromR8 : ILoadsPalettes
|
||||
class PaletteFromR8 : ILoadsPalettes, IProvidesAssetBrowserPalettes
|
||||
{
|
||||
readonly PaletteFromR8Info info;
|
||||
public PaletteFromR8(PaletteFromR8Info info) { this.info = info; }
|
||||
@@ -53,5 +55,7 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
|
||||
wr.AddPalette(info.Name, new ImmutablePalette(colors), info.AllowModifiers);
|
||||
}
|
||||
|
||||
public IEnumerable<string> PaletteNames { get { yield return info.Name; } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.D2k.Traits
|
||||
@@ -35,7 +37,7 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
public object Create(ActorInitializer init) { return new PaletteFromScaledPalette(this); }
|
||||
}
|
||||
|
||||
class PaletteFromScaledPalette : ILoadsPalettes
|
||||
class PaletteFromScaledPalette : ILoadsPalettes, IProvidesAssetBrowserPalettes
|
||||
{
|
||||
readonly PaletteFromScaledPaletteInfo info;
|
||||
public PaletteFromScaledPalette(PaletteFromScaledPaletteInfo info) { this.info = info; }
|
||||
@@ -45,6 +47,8 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
var remap = new ScaledPaletteRemap(info.Scale, info.Offset);
|
||||
wr.AddPalette(info.Name, new ImmutablePalette(wr.Palette(info.BasePalette).Palette, remap), info.AllowModifiers);
|
||||
}
|
||||
|
||||
public IEnumerable<string> PaletteNames { get { yield return info.Name; } }
|
||||
}
|
||||
|
||||
class ScaledPaletteRemap : IPaletteRemap
|
||||
|
||||
@@ -65,8 +65,8 @@
|
||||
<Compile Include="Traits\Render\WithVoxelWalkerBody.cs" />
|
||||
<Compile Include="Traits\Render\WithVoxelUnloadBody.cs" />
|
||||
<Compile Include="Traits\World\VoxelNormalsPalette.cs" />
|
||||
<Compile Include="Traits\World\ShroudPalette.cs" />
|
||||
<Compile Include="UtilityCommands\LegacyTilesetImporter.cs" />
|
||||
<Compile Include="Traits\World\TSShroudPalette.cs" />
|
||||
</ItemGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.TS.Traits
|
||||
@@ -24,7 +26,7 @@ namespace OpenRA.Mods.TS.Traits
|
||||
public object Create(ActorInitializer init) { return new TSShroudPalette(this); }
|
||||
}
|
||||
|
||||
class TSShroudPalette : ILoadsPalettes
|
||||
class TSShroudPalette : ILoadsPalettes, IProvidesAssetBrowserPalettes
|
||||
{
|
||||
readonly TSShroudPaletteInfo info;
|
||||
|
||||
@@ -41,5 +43,7 @@ namespace OpenRA.Mods.TS.Traits
|
||||
|
||||
wr.AddPalette(info.Name, new ImmutablePalette(Enumerable.Range(0, Palette.Size).Select(i => makeColor(i))));
|
||||
}
|
||||
|
||||
public IEnumerable<string> PaletteNames { get { yield return info.Name; } }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user