1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Merge pull request #370 from vcmi/issue/2780

Issue/2780
This commit is contained in:
ArseniyShestakov 2017-09-05 01:21:58 +03:00 committed by GitHub
commit ca066841f1
3 changed files with 92 additions and 7 deletions

View File

@ -291,8 +291,8 @@ std::array<SDL_Color, 8> CCreatureAnimation::genSpecialPalette()
ret[0] = genShadow(0);
ret[1] = genShadow(64);
ret[2] = genShadow(128);
ret[3] = genShadow(128);
ret[2] = genShadow(128);//unused
ret[3] = genShadow(128);//unused
ret[4] = genShadow(128);
ret[5] = genBorderColor(getBorderStrength(elapsedTime), border);
ret[6] = addColors(genShadow(128), genBorderColor(getBorderStrength(elapsedTime), border));
@ -412,7 +412,7 @@ inline void CCreatureAnimation::putPixelAt(SDL_Surface * dest, int X, int Y, siz
template<int bpp>
inline void CCreatureAnimation::putPixel(ui8 * dest, const SDL_Color & color, size_t index, const std::array<SDL_Color, 8> & special) const
{
if (index < 8)
if((index <= 1) || (index >=4 && index < 8))
{
const SDL_Color & pal = special[index];
ColorPutter<bpp, 0>::PutColor(dest, pal.r, pal.g, pal.b, pal.a);

View File

@ -247,16 +247,50 @@ public:
}
};
enum class DefType : uint32_t
{
SPELL = 0x40,
UNUSED_1 = 0x41,
CREATURE = 0x42,
MAP = 0x43,
MAP_HERO = 0x44,
TERRAIN = 0x45,
CURSOR = 0x46,
INTERFACE = 0x47,
UNUSED_2 = 0x48,
BATTLE_HERO = 0x49
};
static CFileCache animationCache;
/*************************************************************************
* DefFile, class used for def loading *
*************************************************************************/
bool operator== (const SDL_Color & lhs, const SDL_Color & rhs)
{
return (lhs.a == rhs.a) && (lhs.b == rhs.b) &&(lhs.g == rhs.g) &&(lhs.r == rhs.r);
}
CDefFile::CDefFile(std::string Name):
data(nullptr),
palette(nullptr)
{
#if 0
static SDL_Color H3_ORIG_PALETTE[8] =
{
{ 0, 255, 255, SDL_ALPHA_OPAQUE},
{255, 150, 255, SDL_ALPHA_OPAQUE},
{255, 100, 255, SDL_ALPHA_OPAQUE},
{255, 50, 255, SDL_ALPHA_OPAQUE},
{255, 0, 255, SDL_ALPHA_OPAQUE},
{255, 255, 0, SDL_ALPHA_OPAQUE},
{180, 0, 255, SDL_ALPHA_OPAQUE},
{ 0, 255, 0, SDL_ALPHA_OPAQUE}
};
#endif // 0
//First 8 colors in def palette used for transparency
static SDL_Color H3Palette[8] =
{
@ -289,10 +323,56 @@ CDefFile::CDefFile(std::string Name):
palette[i].b = data[it++];
palette[i].a = SDL_ALPHA_OPAQUE;
}
if (type == 71 || type == 64)//Buttons/buildings don't have shadows\semi-transparency
memset(palette.get(), 0, sizeof(SDL_Color)*2);
else
memcpy(palette.get(), H3Palette, sizeof(SDL_Color)*8);//initialize shadow\selection colors
switch(static_cast<DefType>(type))
{
case DefType::SPELL:
palette[0] = H3Palette[0];
break;
case DefType::CREATURE:
palette[0] = H3Palette[0];
palette[1] = H3Palette[1];
palette[4] = H3Palette[4];
palette[5] = H3Palette[5];
palette[6] = H3Palette[6];
palette[7] = H3Palette[7];
break;
case DefType::MAP:
palette[0] = H3Palette[0];
palette[1] = H3Palette[1];
palette[4] = H3Palette[4];
//5 = owner flag, handled separately
break;
case DefType::MAP_HERO:
palette[0] = H3Palette[0];
palette[1] = H3Palette[1];
palette[4] = H3Palette[4];
//5 = owner flag, handled separately
break;
case DefType::TERRAIN:
palette[0] = H3Palette[0];
palette[1] = H3Palette[1];
palette[2] = H3Palette[2];
palette[3] = H3Palette[3];
palette[4] = H3Palette[4];
break;
case DefType::CURSOR:
palette[0] = H3Palette[0];
break;
case DefType::INTERFACE:
palette[0] = H3Palette[0];
palette[1] = H3Palette[1];
palette[4] = H3Palette[4];
break;
case DefType::BATTLE_HERO:
//TODO:
logAnim->error("Unimplemented def type %d in %s", type, Name);
break;
default:
logAnim->error("Unknown def type %d in %s", type, Name);
break;
}
for (ui32 i=0; i<totalBlocks; i++)
{
@ -1388,6 +1468,9 @@ CAnimation::CAnimation(std::string Name, bool Compressed):
CDefFile * file = getFile();
init(file);
delete file;
if(source.empty())
logAnim->error("Animation %s failed to load", Name);
}
CAnimation::CAnimation():

View File

@ -101,6 +101,8 @@ void ObjectTemplate::afterLoadFixup()
usedTiles[0][0] = VISITABLE;
visitDir = 0xFF;
}
boost::algorithm::replace_all(animationFile, "\\", "/");
boost::algorithm::replace_all(editorAnimationFile, "\\", "/");
}
void ObjectTemplate::readTxt(CLegacyConfigParser & parser)