#include "StdAfx.h" #include "CResFile.h" #include "GlobalFunc.h" #include "T2DLL.h" #include "T2PaletteAnimeDef.h" T2PaletteAnimeDef::T2PaletteAnimeDef(HINSTANCE instance, CResFile* resFile) { int i, j; Init(); *resFile >> mNumOfTowerColor; *resFile >> mNumOfAnimColor; *resFile >> mAnimStartIndex; *resFile >> mNumOfRefrectColor; *resFile >> mNumOfSkyColor; *resFile >> mNumOfSEKind; *resFile >> mNumOfSEColor; *resFile >> mSEInterval; LOGPALETTE *basePal = LoadACTPaletteEntries(instance, 100); #line 22 _ASSERT(basePal); for (i = mAnimStartIndex; i < (mAnimStartIndex + mNumOfAnimColor); i++) basePal->palPalEntry[i].peFlags = PC_RESERVED; basePal->palPalEntry[253].peFlags = PC_RESERVED; basePal->palPalEntry[254].peFlags = PC_RESERVED; mTowerPalette = new CPalette; mTowerPalette->CreatePalette(basePal); mSEPalette = LoadACTPaletteEntries(instance, 102); #line 31 _ASSERT(mSEPalette); for (i = 0; i < (mNumOfSEKind * mNumOfSEColor); i++) mSEPalette->palPalEntry[i].peFlags = PC_RESERVED; mDayLightPalette = LoadACTPaletteEntries(instance, 101); #line 36 _ASSERT(mDayLightPalette); for (i = 0; i < (mNumOfRefrectColor + mNumOfSkyColor); i++) mDayLightPalette->palPalEntry[i].peFlags = PC_RESERVED; mUnknownPalette = LoadACTPaletteEntries(instance, 103); #line 41 _ASSERT(mUnknownPalette); gCommonColor[0] = 0; gCommonColor[1] = 255; for (i = 2; i <= 19; i++) { if ( mUnknownPalette->palPalEntry[i].peRed == 0 && mUnknownPalette->palPalEntry[i].peGreen == 0 && mUnknownPalette->palPalEntry[i].peBlue == 0 ) { gCommonColor[i] = 255; } else { for (j = 0; j < mNumOfTowerColor; j++) { if ( basePal->palPalEntry[j].peRed == mUnknownPalette->palPalEntry[i].peRed && basePal->palPalEntry[j].peGreen == mUnknownPalette->palPalEntry[i].peGreen && basePal->palPalEntry[j].peBlue == mUnknownPalette->palPalEntry[i].peBlue ) { break; } } #line 53 _ASSERT(j < mNumOfTowerColor); gCommonColor[i] = j; } } free(basePal); } T2PaletteAnimeDef::~T2PaletteAnimeDef() { delete mTowerPalette; free(mSEPalette); free(mDayLightPalette); free(mUnknownPalette); } void T2PaletteAnimeDef::Init() { mUnknownPalette = NULL; mSEPalette = NULL; mDayLightPalette = NULL; } void T2PaletteAnimeDef::ReplaceDayLightPalette(HINSTANCE instance, int id) { LOGPALETTE *pal = LoadACTPaletteEntries(instance, id); #line 80 _ASSERT(pal); for (int i = 0; i < (mNumOfRefrectColor + mNumOfSkyColor); i++) { pal->palPalEntry[i].peFlags = PC_RESERVED; mDayLightPalette->palPalEntry[i] = pal->palPalEntry[i]; } } /*static*/ int T2PaletteAnimeDef::GetCommonColor(int i) { return gCommonColor[i]; }