2020-10-09 07:07:05 +00:00
|
|
|
#ifndef GAME_CLIENT_SKIN_H
|
|
|
|
#define GAME_CLIENT_SKIN_H
|
|
|
|
#include <base/color.h>
|
2022-10-12 17:25:59 +00:00
|
|
|
#include <base/system.h>
|
2020-10-09 07:07:05 +00:00
|
|
|
#include <base/vmath.h>
|
|
|
|
#include <engine/graphics.h>
|
2020-11-12 07:35:07 +00:00
|
|
|
#include <limits>
|
2020-10-09 07:07:05 +00:00
|
|
|
|
|
|
|
// do this better and nicer
|
|
|
|
struct CSkin
|
|
|
|
{
|
2022-10-12 17:25:59 +00:00
|
|
|
private:
|
|
|
|
char m_aName[24];
|
|
|
|
|
|
|
|
public:
|
2020-10-09 07:07:05 +00:00
|
|
|
struct SSkinTextures
|
|
|
|
{
|
|
|
|
IGraphics::CTextureHandle m_Body;
|
|
|
|
IGraphics::CTextureHandle m_BodyOutline;
|
|
|
|
|
|
|
|
IGraphics::CTextureHandle m_Feet;
|
|
|
|
IGraphics::CTextureHandle m_FeetOutline;
|
|
|
|
|
|
|
|
IGraphics::CTextureHandle m_Hands;
|
|
|
|
IGraphics::CTextureHandle m_HandsOutline;
|
|
|
|
|
2022-06-30 22:36:32 +00:00
|
|
|
IGraphics::CTextureHandle m_aEyes[6];
|
2020-10-09 07:07:05 +00:00
|
|
|
|
|
|
|
void Reset()
|
|
|
|
{
|
|
|
|
m_Body = IGraphics::CTextureHandle();
|
|
|
|
m_BodyOutline = IGraphics::CTextureHandle();
|
|
|
|
m_Feet = IGraphics::CTextureHandle();
|
|
|
|
m_FeetOutline = IGraphics::CTextureHandle();
|
|
|
|
m_Hands = IGraphics::CTextureHandle();
|
|
|
|
m_HandsOutline = IGraphics::CTextureHandle();
|
2022-06-30 22:36:32 +00:00
|
|
|
for(auto &Eye : m_aEyes)
|
2020-10-26 14:14:07 +00:00
|
|
|
Eye = IGraphics::CTextureHandle();
|
2020-10-09 07:07:05 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
SSkinTextures m_OriginalSkin;
|
|
|
|
SSkinTextures m_ColorableSkin;
|
|
|
|
ColorRGBA m_BloodColor;
|
|
|
|
|
2020-11-12 07:35:07 +00:00
|
|
|
template<bool IsSizeType>
|
|
|
|
struct SSkinMetricVariableInt
|
2020-11-08 05:39:16 +00:00
|
|
|
{
|
2020-11-12 07:35:07 +00:00
|
|
|
int m_Value;
|
2023-05-30 22:08:01 +00:00
|
|
|
operator int() const { return m_Value; }
|
2020-11-12 07:35:07 +00:00
|
|
|
SSkinMetricVariableInt &operator=(int NewVal)
|
|
|
|
{
|
|
|
|
if(IsSizeType)
|
|
|
|
m_Value = maximum(m_Value, NewVal);
|
|
|
|
else
|
|
|
|
m_Value = minimum(m_Value, NewVal);
|
|
|
|
return *this;
|
|
|
|
}
|
2020-11-08 05:39:16 +00:00
|
|
|
|
2020-11-12 07:35:07 +00:00
|
|
|
SSkinMetricVariableInt()
|
2020-11-08 05:39:16 +00:00
|
|
|
{
|
2020-11-12 07:35:07 +00:00
|
|
|
Reset();
|
2020-11-08 05:39:16 +00:00
|
|
|
}
|
|
|
|
|
2020-11-12 07:35:07 +00:00
|
|
|
void Reset()
|
2020-11-08 05:39:16 +00:00
|
|
|
{
|
2020-11-12 07:35:07 +00:00
|
|
|
if(IsSizeType)
|
|
|
|
m_Value = std::numeric_limits<int>::lowest();
|
|
|
|
else
|
|
|
|
m_Value = std::numeric_limits<int>::max();
|
2020-11-08 05:39:16 +00:00
|
|
|
}
|
2020-11-12 07:35:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SSkinMetricVariable
|
|
|
|
{
|
|
|
|
SSkinMetricVariableInt<true> m_Width;
|
|
|
|
SSkinMetricVariableInt<true> m_Height;
|
|
|
|
SSkinMetricVariableInt<false> m_OffsetX;
|
|
|
|
SSkinMetricVariableInt<false> m_OffsetY;
|
|
|
|
|
|
|
|
// these can be used to normalize the metrics
|
|
|
|
SSkinMetricVariableInt<true> m_MaxWidth;
|
|
|
|
SSkinMetricVariableInt<true> m_MaxHeight;
|
2020-11-08 05:39:16 +00:00
|
|
|
|
2023-05-30 22:08:01 +00:00
|
|
|
float WidthNormalized() const
|
2020-11-08 05:39:16 +00:00
|
|
|
{
|
2020-11-12 07:35:07 +00:00
|
|
|
return (float)m_Width / (float)m_MaxWidth;
|
2020-11-08 05:39:16 +00:00
|
|
|
}
|
|
|
|
|
2023-05-30 22:08:01 +00:00
|
|
|
float HeightNormalized() const
|
2020-11-08 05:39:16 +00:00
|
|
|
{
|
2020-11-12 07:35:07 +00:00
|
|
|
return (float)m_Height / (float)m_MaxHeight;
|
2020-11-08 05:39:16 +00:00
|
|
|
}
|
|
|
|
|
2023-05-30 22:08:01 +00:00
|
|
|
float OffsetXNormalized() const
|
2020-11-08 05:39:16 +00:00
|
|
|
{
|
2020-11-12 07:35:07 +00:00
|
|
|
return (float)m_OffsetX / (float)m_MaxWidth;
|
2020-11-08 05:39:16 +00:00
|
|
|
}
|
|
|
|
|
2023-05-30 22:08:01 +00:00
|
|
|
float OffsetYNormalized() const
|
2020-11-08 05:39:16 +00:00
|
|
|
{
|
2020-11-12 07:35:07 +00:00
|
|
|
return (float)m_OffsetY / (float)m_MaxHeight;
|
2020-11-08 05:39:16 +00:00
|
|
|
}
|
|
|
|
|
2020-11-12 07:35:07 +00:00
|
|
|
void Reset()
|
2020-11-08 05:39:16 +00:00
|
|
|
{
|
2020-11-12 07:35:07 +00:00
|
|
|
m_Width.Reset();
|
|
|
|
m_Height.Reset();
|
|
|
|
m_OffsetX.Reset();
|
|
|
|
m_OffsetY.Reset();
|
|
|
|
m_MaxWidth.Reset();
|
|
|
|
m_MaxHeight.Reset();
|
2020-11-08 05:39:16 +00:00
|
|
|
}
|
2020-11-12 07:35:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SSkinMetrics
|
|
|
|
{
|
|
|
|
SSkinMetricVariable m_Body;
|
|
|
|
SSkinMetricVariable m_Feet;
|
|
|
|
|
|
|
|
void Reset()
|
2020-11-08 05:39:16 +00:00
|
|
|
{
|
2020-11-12 07:35:07 +00:00
|
|
|
m_Body.Reset();
|
|
|
|
m_Feet.Reset();
|
2020-11-08 05:39:16 +00:00
|
|
|
}
|
|
|
|
|
2020-11-12 07:35:07 +00:00
|
|
|
SSkinMetrics()
|
2020-11-08 05:39:16 +00:00
|
|
|
{
|
2020-11-12 07:35:07 +00:00
|
|
|
Reset();
|
2020-11-08 05:39:16 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
SSkinMetrics m_Metrics;
|
|
|
|
|
2021-03-23 12:20:35 +00:00
|
|
|
bool operator<(const CSkin &Other) const { return str_comp(m_aName, Other.m_aName) < 0; }
|
2022-05-23 20:20:10 +00:00
|
|
|
bool operator==(const CSkin &Other) const { return !str_comp(m_aName, Other.m_aName); }
|
2022-10-12 17:25:59 +00:00
|
|
|
|
|
|
|
CSkin(const char *pName)
|
|
|
|
{
|
|
|
|
str_copy(m_aName, pName);
|
|
|
|
}
|
|
|
|
CSkin(CSkin &&) = default;
|
|
|
|
CSkin &operator=(CSkin &&) = default;
|
|
|
|
|
|
|
|
const char *GetName() const { return m_aName; }
|
2020-10-09 07:07:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|