mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
- Move color sets into the PlayerPawn metadata.
SVN r2270 (scripting)
This commit is contained in:
parent
42ac75e894
commit
900324c205
8 changed files with 53 additions and 101 deletions
|
@ -195,7 +195,7 @@ void D_GetPlayerColor (int player, float *h, float *s, float *v, FPlayerColorSet
|
|||
|
||||
if (players[player].mo != NULL)
|
||||
{
|
||||
colorset = P_GetPlayerColorSet(players[player].mo->GetClass()->TypeName, info->colorset);
|
||||
colorset = players[player].mo->GetClass()->GetColorSet(info->colorset);
|
||||
}
|
||||
if (colorset != NULL)
|
||||
{
|
||||
|
|
|
@ -46,6 +46,20 @@
|
|||
|
||||
class player_t;
|
||||
|
||||
// Standard pre-defined skin colors
|
||||
struct FPlayerColorSet
|
||||
{
|
||||
FName Name; // Name of this color
|
||||
|
||||
int Lump; // Lump to read the translation from, otherwise use next 2 fields
|
||||
BYTE FirstColor, LastColor; // Describes the range of colors to use for the translation
|
||||
|
||||
BYTE RepresentativeColor; // A palette entry representative of this translation,
|
||||
// for map arrows and status bar backgrounds and such
|
||||
};
|
||||
typedef TMap<int, FPlayerColorSet> FPlayerColorSetMap;
|
||||
|
||||
|
||||
class PClassPlayerPawn : public PClassActor
|
||||
{
|
||||
DECLARE_CLASS(PClassPlayerPawn, PClassActor);
|
||||
|
@ -53,6 +67,8 @@ protected:
|
|||
virtual void Derive(PClass *newclass);
|
||||
public:
|
||||
PClassPlayerPawn();
|
||||
void EnumColorSets(TArray<int> *out);
|
||||
FPlayerColorSet *GetColorSet(int setnum) { return ColorSets.CheckKey(setnum); }
|
||||
|
||||
FString DisplayName; // Display name (used in menus, etc.)
|
||||
FString SoundClass; // Sound class
|
||||
|
@ -63,11 +79,9 @@ public:
|
|||
fixed_t HexenArmor[5];
|
||||
BYTE ColorRangeStart; // Skin color range
|
||||
BYTE ColorRangeEnd;
|
||||
FPlayerColorSetMap ColorSets;
|
||||
};
|
||||
|
||||
FPlayerColorSet *P_GetPlayerColorSet(FName classname, int setnum);
|
||||
void P_EnumPlayerColorSets(FName classname, TArray<int> *out);
|
||||
|
||||
class player_t;
|
||||
|
||||
class APlayerPawn : public AActor
|
||||
|
|
19
src/info.cpp
19
src/info.cpp
|
@ -494,25 +494,6 @@ void PClassActor::SetPainChance(FName type, int chance)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void PClassActor::SetColorSet(int index, const FPlayerColorSet *set)
|
||||
{
|
||||
if (set != NULL)
|
||||
{
|
||||
if (ColorSets == NULL) ColorSets = new FPlayerColorSetMap;
|
||||
ColorSets->Insert(index, *set);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ColorSets != NULL)
|
||||
ColorSets->Remove(index);
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FDoomEdMap DoomEdMap;
|
||||
|
||||
FDoomEdMap::FDoomEdEntry *FDoomEdMap::DoomEdHash[DOOMED_HASHSIZE];
|
||||
|
|
15
src/info.h
15
src/info.h
|
@ -123,21 +123,8 @@ FArchive &operator<< (FArchive &arc, FState *&state);
|
|||
|
||||
#include "gametype.h"
|
||||
|
||||
// Standard pre-defined skin colors
|
||||
struct FPlayerColorSet
|
||||
{
|
||||
FName Name; // Name of this color
|
||||
|
||||
int Lump; // Lump to read the translation from, otherwise use next 2 fields
|
||||
BYTE FirstColor, LastColor; // Describes the range of colors to use for the translation
|
||||
|
||||
BYTE RepresentativeColor; // A palette entry representative of this translation,
|
||||
// for map arrows and status bar backgrounds and such
|
||||
};
|
||||
|
||||
typedef TMap<FName, fixed_t> DmgFactors;
|
||||
typedef TMap<FName, int> PainChanceList;
|
||||
typedef TMap<int, FPlayerColorSet> FPlayerColorSetMap;
|
||||
class DDropItem;
|
||||
|
||||
class PClassActor : public PClass
|
||||
|
@ -158,7 +145,6 @@ public:
|
|||
void RegisterIDs();
|
||||
void SetDamageFactor(FName type, fixed_t factor);
|
||||
void SetPainChance(FName type, int chance);
|
||||
void SetColorSet(int index, const FPlayerColorSet *set);
|
||||
size_t PropagateMark();
|
||||
void InitializeNativeDefaults();
|
||||
|
||||
|
@ -182,7 +168,6 @@ public:
|
|||
FStateLabels *StateList;
|
||||
DmgFactors *DamageFactors;
|
||||
PainChanceList *PainChances;
|
||||
FPlayerColorSetMap *ColorSets;
|
||||
FString Obituary; // Player was killed by this actor
|
||||
FString HitObituary; // Player was killed by this actor in melee
|
||||
fixed_t DeathHeight; // Height on normal death
|
||||
|
|
|
@ -2093,7 +2093,7 @@ void M_PlayerSetup (void)
|
|||
}
|
||||
PlayerSkin = players[consoleplayer].userinfo.skin;
|
||||
R_GetPlayerTranslation (players[consoleplayer].userinfo.color,
|
||||
P_GetPlayerColorSet(PlayerClass->Type->TypeName, players[consoleplayer].userinfo.colorset),
|
||||
PlayerClass->Type->GetColorSet(players[consoleplayer].userinfo.colorset),
|
||||
&skins[PlayerSkin], translationtables[TRANSLATION_Players][MAXPLAYERS]);
|
||||
PlayerState = GetDefaultByType (PlayerClass->Type)->SeeState;
|
||||
PlayerTics = PlayerState->GetTics();
|
||||
|
@ -2101,7 +2101,7 @@ void M_PlayerSetup (void)
|
|||
{
|
||||
FireTexture = new FBackdropTexture;
|
||||
}
|
||||
P_EnumPlayerColorSets(PlayerClass->Type->TypeName, &PlayerColorSets);
|
||||
PlayerClass->Type->EnumColorSets(&PlayerColorSets);
|
||||
}
|
||||
|
||||
static void M_PlayerSetupTicker (void)
|
||||
|
@ -2119,7 +2119,7 @@ static void M_PlayerSetupTicker (void)
|
|||
item = (MenuTime>>2) % (ClassMenuDef.numitems-1);
|
||||
|
||||
PlayerClass = &PlayerClasses[D_PlayerClassToInt (ClassMenuItems[item].name)];
|
||||
P_EnumPlayerColorSets(PlayerClass->Type->TypeName, &PlayerColorSets);
|
||||
PlayerClass->Type->EnumColorSets(&PlayerColorSets);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2133,7 +2133,7 @@ static void M_PlayerSetupTicker (void)
|
|||
|
||||
PlayerSkin = R_FindSkin (skins[PlayerSkin].name, int(PlayerClass - &PlayerClasses[0]));
|
||||
R_GetPlayerTranslation (players[consoleplayer].userinfo.color,
|
||||
P_GetPlayerColorSet(PlayerClass->Type->TypeName, players[consoleplayer].userinfo.colorset),
|
||||
PlayerClass->Type->GetColorSet(players[consoleplayer].userinfo.colorset),
|
||||
&skins[PlayerSkin], translationtables[TRANSLATION_Players][MAXPLAYERS]);
|
||||
}
|
||||
|
||||
|
@ -2290,7 +2290,7 @@ static void M_PlayerSetupDrawer ()
|
|||
}
|
||||
|
||||
// Draw player color selection and sliders
|
||||
FPlayerColorSet *colorset = P_GetPlayerColorSet(PlayerClass->Type->TypeName, players[consoleplayer].userinfo.colorset);
|
||||
FPlayerColorSet *colorset = PlayerClass->Type->GetColorSet(players[consoleplayer].userinfo.colorset);
|
||||
x = SmallFont->StringWidth("Color") + 8 + PSetupDef.x;
|
||||
screen->DrawText(SmallFont, label, PSetupDef.x, PSetupDef.y + LINEHEIGHT*2+yo, "Color", DTA_Clean, true, TAG_DONE);
|
||||
screen->DrawText(SmallFont, value, x, PSetupDef.y + LINEHEIGHT*2+yo,
|
||||
|
@ -2604,7 +2604,7 @@ static void M_ChangeSkin (int choice)
|
|||
} while (!PlayerClass->CheckSkin (PlayerSkin));
|
||||
|
||||
R_GetPlayerTranslation (players[consoleplayer].userinfo.color,
|
||||
P_GetPlayerColorSet(PlayerClass->Type->TypeName, players[consoleplayer].userinfo.colorset),
|
||||
PlayerClass->Type->GetColorSet(players[consoleplayer].userinfo.colorset),
|
||||
&skins[PlayerSkin], translationtables[TRANSLATION_Players][MAXPLAYERS]);
|
||||
|
||||
cvar_set ("skin", skins[PlayerSkin].name);
|
||||
|
@ -2762,7 +2762,7 @@ static void M_ChangeColorSet (int choice)
|
|||
mysnprintf(command, countof(command), "colorset %d", mycolorset);
|
||||
C_DoCommand(command);
|
||||
R_GetPlayerTranslation(players[consoleplayer].userinfo.color,
|
||||
P_GetPlayerColorSet(PlayerClass->Type->TypeName, mycolorset),
|
||||
PlayerClass->Type->GetColorSet(mycolorset),
|
||||
&skins[PlayerSkin], translationtables[TRANSLATION_Players][MAXPLAYERS]);
|
||||
}
|
||||
|
||||
|
@ -2773,7 +2773,7 @@ static void SendNewColor (int red, int green, int blue)
|
|||
mysnprintf (command, countof(command), "color \"%02x %02x %02x\"", red, green, blue);
|
||||
C_DoCommand (command);
|
||||
R_GetPlayerTranslation(MAKERGB (red, green, blue),
|
||||
P_GetPlayerColorSet(PlayerClass->Type->TypeName, players[consoleplayer].userinfo.colorset),
|
||||
PlayerClass->Type->GetColorSet(players[consoleplayer].userinfo.colorset),
|
||||
&skins[PlayerSkin], translationtables[TRANSLATION_Players][MAXPLAYERS]);
|
||||
}
|
||||
|
||||
|
@ -4116,5 +4116,5 @@ static void PickPlayerClass ()
|
|||
}
|
||||
|
||||
PlayerClass = &PlayerClasses[pclass];
|
||||
P_EnumPlayerColorSets(PlayerClass->Type->TypeName, &PlayerColorSets);
|
||||
PlayerClass->Type->EnumColorSets(&PlayerColorSets);
|
||||
}
|
||||
|
|
|
@ -421,6 +421,7 @@ void PClassPlayerPawn::Derive(PClass *newclass)
|
|||
newp->HealingRadiusType = HealingRadiusType;
|
||||
newp->ColorRangeStart = ColorRangeStart;
|
||||
newp->ColorRangeEnd = ColorRangeEnd;
|
||||
newp->ColorSets = ColorSets;
|
||||
for (i = 0; i < countof(HexenArmor); ++i)
|
||||
{
|
||||
newp->HexenArmor[i] = HexenArmor[i];
|
||||
|
@ -431,6 +432,25 @@ void PClassPlayerPawn::Derive(PClass *newclass)
|
|||
}
|
||||
}
|
||||
|
||||
static int STACK_ARGS intcmp(const void *a, const void *b)
|
||||
{
|
||||
return *(const int *)a - *(const int *)b;
|
||||
}
|
||||
|
||||
void PClassPlayerPawn::EnumColorSets(TArray<int> *out)
|
||||
{
|
||||
out->Clear();
|
||||
FPlayerColorSetMap::Iterator it(ColorSets);
|
||||
FPlayerColorSetMap::Pair *pair;
|
||||
|
||||
while (it.NextPair(pair))
|
||||
{
|
||||
out->Push(pair->Key);
|
||||
}
|
||||
qsort(&(*out)[0], out->Size(), sizeof(int), intcmp);
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APlayerPawn
|
||||
|
@ -2669,48 +2689,3 @@ void player_t::Serialize (FArchive &arc)
|
|||
original_oldbuttons = ~0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static FPlayerColorSetMap *GetPlayerColors(FName classname)
|
||||
{
|
||||
PClassPlayerPawn *cls = dyn_cast<PClassPlayerPawn>(PClass::FindClass(classname));
|
||||
|
||||
if (cls != NULL)
|
||||
{
|
||||
return cls->ColorSets;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FPlayerColorSet *P_GetPlayerColorSet(FName classname, int setnum)
|
||||
{
|
||||
FPlayerColorSetMap *map = GetPlayerColors(classname);
|
||||
if (map == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return map->CheckKey(setnum);
|
||||
}
|
||||
|
||||
static int STACK_ARGS intcmp(const void *a, const void *b)
|
||||
{
|
||||
return *(const int *)a - *(const int *)b;
|
||||
}
|
||||
|
||||
void P_EnumPlayerColorSets(FName classname, TArray<int> *out)
|
||||
{
|
||||
out->Clear();
|
||||
FPlayerColorSetMap *map = GetPlayerColors(classname);
|
||||
if (map != NULL)
|
||||
{
|
||||
FPlayerColorSetMap::Iterator it(*map);
|
||||
FPlayerColorSetMap::Pair *pair;
|
||||
|
||||
while (it.NextPair(pair))
|
||||
{
|
||||
out->Push(pair->Key);
|
||||
}
|
||||
qsort(&(*out)[0], out->Size(), sizeof(int), intcmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -153,12 +153,6 @@ PClassActor *CreateNewActor(const FScriptPosition &sc, FName typeName, FName par
|
|||
ti->PainChances = new PainChanceList;
|
||||
*ti->PainChances = *parent->PainChances;
|
||||
}
|
||||
if (parent->ColorSets != NULL)
|
||||
{
|
||||
// copy color sets from parent
|
||||
ti->ColorSets = new FPlayerColorSetMap;
|
||||
*ti->ColorSets = *parent->ColorSets;
|
||||
}
|
||||
ti->Replacee = ti->Replacement = NULL;
|
||||
ti->DoomEdNum = -1;
|
||||
return ti;
|
||||
|
|
|
@ -1931,7 +1931,8 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, colorset, ISIII, PlayerPawn)
|
|||
}
|
||||
else
|
||||
{
|
||||
info->SetColorSet(setnum, &color);
|
||||
assert(info->IsKindOf(RUNTIME_CLASS(PClassPlayerPawn)));
|
||||
static_cast<PClassPlayerPawn *>(info)->ColorSets.Insert(setnum, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1955,7 +1956,8 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, colorsetfile, ISSI, PlayerPawn)
|
|||
}
|
||||
else if (color.Lump >= 0)
|
||||
{
|
||||
info->SetColorSet(setnum, &color);
|
||||
assert(info->IsKindOf(RUNTIME_CLASS(PClassPlayerPawn)));
|
||||
static_cast<PClassPlayerPawn *>(info)->ColorSets.Insert(setnum, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1972,7 +1974,8 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, clearcolorset, I, PlayerPawn)
|
|||
}
|
||||
else
|
||||
{
|
||||
info->SetColorSet(setnum, NULL);
|
||||
assert(info->IsKindOf(RUNTIME_CLASS(PClassPlayerPawn)));
|
||||
static_cast<PClassPlayerPawn *>(info)->ColorSets.Remove(setnum);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue