mirror of
https://github.com/electronicarts/CNC_TS_and_RA2_Mission_Editor.git
synced 2025-10-16 01:03:37 -04:00
split out palette management, preparing for custom palette support .
This commit is contained in:
parent
fb64321a28
commit
981059c2b4
6 changed files with 645 additions and 655 deletions
89
MissionEditor/Palettes.h
Normal file
89
MissionEditor/Palettes.h
Normal file
|
@ -0,0 +1,89 @@
|
|||
#pragma once
|
||||
|
||||
#include <afxcview.h>
|
||||
#include <map>
|
||||
#include "MissionEditorPackLib.h"
|
||||
|
||||
struct BGRStruct
|
||||
{
|
||||
unsigned char B, G, R, Zero;
|
||||
bool operator< (const BGRStruct& rhs) const { return *(int*)this < *(int*)&rhs; }
|
||||
bool operator==(const BGRStruct& rhs) const { return *(int*)this == *(int*)&rhs; }
|
||||
};
|
||||
|
||||
struct ColorStruct
|
||||
{
|
||||
unsigned char red, green, blue;
|
||||
};
|
||||
|
||||
class BytePalette
|
||||
{
|
||||
public:
|
||||
ColorStruct Data[256];
|
||||
|
||||
ColorStruct& operator[](int index) { return Data[index]; }
|
||||
};
|
||||
|
||||
class Palette
|
||||
{
|
||||
public:
|
||||
Palette(const BytePalette& bytes);
|
||||
Palette(HTSPALETTE raw);
|
||||
|
||||
BGRStruct& operator[](int index) { return Data[index]; }
|
||||
ColorStruct GetByteColor(int index) {
|
||||
ColorStruct ret;
|
||||
BGRStruct& tmp = Data[index];
|
||||
ret.red = tmp.R;
|
||||
ret.green = tmp.G;
|
||||
ret.blue = tmp.B;
|
||||
return ret;
|
||||
}
|
||||
private:
|
||||
BGRStruct Data[256];
|
||||
};
|
||||
|
||||
class Palettes
|
||||
{
|
||||
public:
|
||||
Palettes(CLoading& loading) :
|
||||
loading(loading)
|
||||
{}
|
||||
|
||||
void Init();
|
||||
|
||||
HTSPALETTE GetIsoPalette(char theat);
|
||||
HTSPALETTE GetUnitPalette(char theat);
|
||||
void FetchPalettes();
|
||||
void CreateConvTable(RGBTRIPLE* pal, int* iPal);
|
||||
|
||||
Palette* LoadPalette(const CString& palName);
|
||||
void Clear();
|
||||
|
||||
HTSPALETTE m_hPalIsoTemp;
|
||||
HTSPALETTE m_hPalIsoSnow;
|
||||
HTSPALETTE m_hPalIsoUrb;
|
||||
|
||||
HTSPALETTE m_hPalUnitTemp;
|
||||
HTSPALETTE m_hPalUnitSnow;
|
||||
HTSPALETTE m_hPalUnitUrb;
|
||||
HTSPALETTE m_hPalTemp;
|
||||
HTSPALETTE m_hPalSnow;
|
||||
HTSPALETTE m_hPalUrb;
|
||||
HTSPALETTE m_hPalLib;
|
||||
// YR pals:
|
||||
HTSPALETTE m_hPalLun;
|
||||
HTSPALETTE m_hPalDes;
|
||||
HTSPALETTE m_hPalUbn;
|
||||
HTSPALETTE m_hPalIsoLun;
|
||||
HTSPALETTE m_hPalIsoDes;
|
||||
HTSPALETTE m_hPalIsoUbn;
|
||||
HTSPALETTE m_hPalUnitLun;
|
||||
HTSPALETTE m_hPalUnitDes;
|
||||
HTSPALETTE m_hPalUnitUbn;
|
||||
|
||||
private:
|
||||
CLoading& loading;
|
||||
std::map<CString, Palette*> LoadedPalettes;
|
||||
std::map<Palette*, std::map<BGRStruct, Palette>> RemappedPalettes;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue