1 #include "Font.h"
2 #include "HImage.h"
3 #include "LoadSaveData.h"
4 #include "Types.h"
5 #include "Utilities.h"
6 #include "VObject.h"
7 #include "FileMan.h"
8 #include "Font_Control.h"
9 #include "Overhead.h"
10 #include "Overhead_Types.h"
11 #include "Debug.h"
12 #include "VSurface.h"
13 
14 #include "ContentManager.h"
15 #include "GameInstance.h"
16 
17 #include <string_theory/format>
18 #include <string_theory/string>
19 
20 
CreateSGPPaletteFromCOLFile(SGPPaletteEntry * const pal,const char * const col_file)21 BOOLEAN CreateSGPPaletteFromCOLFile(SGPPaletteEntry* const pal, const char* const col_file)
22 try
23 {
24 	AutoSGPFile f(GCM->openGameResForReading(col_file));
25 
26 	BYTE data[776];
27 	FileRead(f, data, sizeof(data));
28 
29 	DataReader d{data};
30 	EXTR_SKIP(d, 8); // skip header
31 	for (UINT i = 0; i != 256; ++i)
32 	{
33 		EXTR_U8(d, pal[i].r)
34 		EXTR_U8(d, pal[i].g)
35 		EXTR_U8(d, pal[i].b)
36 	}
37 	Assert(d.getConsumed() == lengthof(data));
38 
39 	return TRUE;
40 }
41 catch (...) { return FALSE; }
42 
43 
DisplayPaletteRep(const ST::string & aPalRep,UINT8 ubXPos,UINT8 ubYPos,SGPVSurface * dst)44 void DisplayPaletteRep(const ST::string& aPalRep, UINT8 ubXPos, UINT8 ubYPos, SGPVSurface* dst)
45 {
46 	UINT16 us16BPPColor;
47 	UINT32 cnt1;
48 	UINT8  ubSize;
49 	INT16  sTLX, sTLY, sBRX, sBRY;
50 
51 	// Create 16BPP Palette
52 	const UINT8 ubPaletteRep = GetPaletteRepIndexFromID(aPalRep);
53 
54 	SetFont( LARGEFONT1 );
55 
56 	ubSize = gpPalRep[ ubPaletteRep ].ubPaletteSize;
57 
58 	for ( cnt1 = 0; cnt1 < ubSize; cnt1++ )
59 	{
60 		sTLX = ubXPos + (UINT16)( ( cnt1 % 16 ) * 20 );
61 		sTLY = ubYPos + (UINT16)( ( cnt1 / 16 ) * 20 );
62 		sBRX = sTLX + 20;
63 		sBRY = sTLY + 20;
64 
65 		const SGPPaletteEntry* Clr = &gpPalRep[ubPaletteRep].rgb[cnt1];
66 		us16BPPColor = Get16BPPColor(FROMRGB(Clr->r, Clr->g, Clr->b));
67 
68 		ColorFillVideoSurfaceArea(dst, sTLX, sTLY, sBRX, sBRY, us16BPPColor);
69 	}
70 
71 	GPrint(ubXPos + 16 * 20, ubYPos, ST::format("{}", gpPalRep[ubPaletteRep].ID));
72 }
73