Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
100 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#region Copyright & License Information | ||
/* | ||
* Copyright 2007-2018 The OpenRA Developers (see AUTHORS) | ||
* 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 | ||
* as published by the Free Software Foundation, either version 3 of | ||
* the License, or (at your option) any later version. For more | ||
* information, see COPYING. | ||
*/ | ||
#endregion | ||
|
||
using System.Collections.Generic; | ||
using OpenRA.Graphics; | ||
using OpenRA.Mods.Common.Traits; | ||
using OpenRA.Traits; | ||
|
||
namespace OpenRA.Mods.D2k.Traits | ||
{ | ||
class D2kFogPaletteInfo : ITraitInfo | ||
{ | ||
[FieldLoader.Require, PaletteDefinition] | ||
[Desc("Internal palette name")] | ||
public readonly string Name = null; | ||
|
||
[FieldLoader.Require, PaletteReference] | ||
[Desc("The name of the shroud palette to base off.")] | ||
public readonly string BasePalette = null; | ||
|
||
[Desc("Allow palette modifiers to change the palette.")] | ||
public readonly bool AllowModifiers = true; | ||
|
||
public object Create(ActorInitializer init) { return new D2kFogPalette(this); } | ||
} | ||
|
||
class D2kFogPalette : ILoadsPalettes, IProvidesAssetBrowserPalettes | ||
{ | ||
readonly D2kFogPaletteInfo info; | ||
public D2kFogPalette(D2kFogPaletteInfo info) { this.info = info; } | ||
|
||
public void LoadPalettes(WorldRenderer wr) | ||
{ | ||
var basePalette = wr.Palette(info.BasePalette).Palette; | ||
|
||
// Bit twiddling is equivalent to unpacking RGB channels, dividing them by 2, subtracting from 255, then repacking | ||
var fog = new uint[Palette.Size]; | ||
for (var i = 0; i < Palette.Size; i++) | ||
fog[i] = ~((basePalette[i] >> 1) & 0x007F7F7F); | ||
|
||
wr.AddPalette(info.Name, new ImmutablePalette(fog), info.AllowModifiers); | ||
} | ||
|
||
public IEnumerable<string> PaletteNames { get { yield return info.Name; } } | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters