2007-01-15 12:09:25 -08:00
|
|
|
/*
|
|
|
|
This file is part of Warzone 2100.
|
|
|
|
Copyright (C) 1999-2004 Eidos Interactive
|
2010-07-26 16:36:29 -07:00
|
|
|
Copyright (C) 2005-2010 Warzone 2100 Project
|
2007-01-15 12:09:25 -08:00
|
|
|
|
|
|
|
Warzone 2100 is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Warzone 2100 is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Warzone 2100; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2009-11-21 02:18:30 -08:00
|
|
|
#include "lib/framework/frame.h"
|
|
|
|
#include "lib/framework/file.h"
|
2010-12-31 13:37:14 -08:00
|
|
|
#include "lib/ivis_opengl/piestate.h"
|
|
|
|
#include "lib/ivis_opengl/piepalette.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "screen.h"
|
|
|
|
|
2007-11-26 13:48:36 -08:00
|
|
|
PIELIGHT psPalette[WZCOL_MAX];
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2008-01-21 09:06:31 -08:00
|
|
|
void pal_Init(void)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2009-11-21 02:18:30 -08:00
|
|
|
char *pFileData, *ptr;
|
|
|
|
UDWORD fileSize;
|
|
|
|
int i, lenLeft;
|
|
|
|
|
|
|
|
// Read these from file so that mod-makers can change them
|
|
|
|
loadFile("palette.txt", &pFileData, &fileSize);
|
|
|
|
|
|
|
|
ptr = pFileData;
|
|
|
|
lenLeft = fileSize;
|
|
|
|
for (i = 0; i < WZCOL_MAX; i++)
|
|
|
|
{
|
|
|
|
unsigned int r, g, b, a;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
sscanf(ptr, "%x, %x, %x, %x %*[^\n]\n%n", &r, &g, &b, &a, &len);
|
|
|
|
psPalette[i].byte.r = r;
|
|
|
|
psPalette[i].byte.g = g;
|
|
|
|
psPalette[i].byte.b = b;
|
|
|
|
psPalette[i].byte.a = a;
|
|
|
|
ptr += len;
|
|
|
|
lenLeft -= len;
|
|
|
|
ASSERT(lenLeft >= 0, "Buffer overrun reading palette data");
|
|
|
|
}
|
|
|
|
free(pFileData);
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void pal_ShutDown(void)
|
|
|
|
{
|
2008-01-21 09:06:31 -08:00
|
|
|
// placeholder
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
2010-03-06 15:03:29 -08:00
|
|
|
|
|
|
|
PIELIGHT pal_GetTeamColour(int team)
|
|
|
|
{
|
|
|
|
PIELIGHT tcolour;
|
|
|
|
|
|
|
|
// set correct team colour based on team
|
|
|
|
switch (team)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
tcolour = WZCOL_TEAM1; //green
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
tcolour = WZCOL_TEAM2; //orange
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
tcolour = WZCOL_TEAM3; //gray
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
tcolour = WZCOL_TEAM4; //black
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
tcolour = WZCOL_TEAM5; //red
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
tcolour = WZCOL_TEAM6; //blue
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
tcolour = WZCOL_TEAM7; //purple
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
tcolour = WZCOL_TEAM8; //teal
|
|
|
|
break;
|
2011-01-03 05:48:41 -08:00
|
|
|
case 8: return WZCOL_TEAM9;
|
|
|
|
case 9: return WZCOL_TEAM10;
|
|
|
|
case 10: return WZCOL_TEAM11;
|
|
|
|
case 11: return WZCOL_TEAM12;
|
|
|
|
case 12: return WZCOL_TEAM13;
|
|
|
|
case 13: return WZCOL_TEAM14;
|
|
|
|
case 14: return WZCOL_TEAM15;
|
|
|
|
case 15: return WZCOL_TEAM16;
|
2010-03-06 15:03:29 -08:00
|
|
|
default:
|
2011-01-03 05:48:41 -08:00
|
|
|
STATIC_ASSERT(MAX_PLAYERS <= 16);
|
2010-03-06 15:03:29 -08:00
|
|
|
ASSERT(false, "Attempting to get colour for non-existing team %u", (unsigned int)team);
|
|
|
|
tcolour = WZCOL_WHITE; //default is white
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return tcolour;
|
2010-10-13 11:25:57 -07:00
|
|
|
}
|