mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-24 03:47:18 +02:00
Fixed recoloring filler background to correct player color after game reload;
This commit is contained in:
parent
794c03792a
commit
df419e23c0
@ -1235,6 +1235,11 @@ CAdvMapPanel::CAdvMapPanel(SDL_Surface * bg, Point position)
|
||||
recActions = 255;
|
||||
pos.x += position.x;
|
||||
pos.y += position.y;
|
||||
if (bg)
|
||||
{
|
||||
pos.w = bg->w;
|
||||
pos.h = bg->h;
|
||||
}
|
||||
}
|
||||
|
||||
CAdvMapPanel::~CAdvMapPanel()
|
||||
@ -1272,13 +1277,13 @@ void CAdvMapPanel::addChildToPanel(CIntObject * obj, ui8 actions /* = 0 */)
|
||||
}
|
||||
|
||||
CAdvMapWorldViewPanel::CAdvMapWorldViewPanel(SDL_Surface * bg, Point position, int spaceBottom, const PlayerColor &color)
|
||||
: CAdvMapPanel(bg, position)
|
||||
: CAdvMapPanel(bg, position)
|
||||
{
|
||||
if (background && spaceBottom - pos.y > background->h)
|
||||
fillerHeight = bg ? spaceBottom - pos.y - pos.h : 0;
|
||||
|
||||
if (fillerHeight > 0)
|
||||
{
|
||||
logGlobal->debugStream() << "Creating filler bitmap for world view panel: "
|
||||
<< background->w << "x" << (spaceBottom - pos.y - background->h);
|
||||
tmpBackgroundFiller = CMessage::drawDialogBox(background->w, spaceBottom - pos.y - background->h, color);
|
||||
tmpBackgroundFiller = CMessage::drawDialogBox(pos.w, fillerHeight, color);
|
||||
}
|
||||
else
|
||||
tmpBackgroundFiller = nullptr;
|
||||
@ -1287,10 +1292,10 @@ CAdvMapWorldViewPanel::CAdvMapWorldViewPanel(SDL_Surface * bg, Point position, i
|
||||
CAdvMapWorldViewPanel::~CAdvMapWorldViewPanel()
|
||||
{
|
||||
if (tmpBackgroundFiller)
|
||||
delete tmpBackgroundFiller;
|
||||
SDL_FreeSurface(tmpBackgroundFiller);
|
||||
}
|
||||
|
||||
void CAdvMapWorldViewPanel::recolorIcons(const CDefHandler *def, int indexOffset)
|
||||
void CAdvMapWorldViewPanel::recolorIcons(const PlayerColor &color, const CDefHandler *def, int indexOffset)
|
||||
{
|
||||
for (auto &pic : currentIcons)
|
||||
{
|
||||
@ -1306,6 +1311,13 @@ void CAdvMapWorldViewPanel::recolorIcons(const CDefHandler *def, int indexOffset
|
||||
currentIcons.push_back(pic);
|
||||
addChildToPanel(pic);
|
||||
}
|
||||
|
||||
if (fillerHeight > 0)
|
||||
{
|
||||
if (tmpBackgroundFiller)
|
||||
SDL_FreeSurface(tmpBackgroundFiller);
|
||||
tmpBackgroundFiller = CMessage::drawDialogBox(pos.w, fillerHeight, color);
|
||||
}
|
||||
}
|
||||
|
||||
void CAdvMapWorldViewPanel::addChildIcon(std::pair<int, Point> data, const CDefHandler *def, int indexOffset)
|
||||
@ -1320,7 +1332,7 @@ void CAdvMapWorldViewPanel::showAll(SDL_Surface * to)
|
||||
{
|
||||
if (tmpBackgroundFiller)
|
||||
{
|
||||
blitAt(tmpBackgroundFiller, pos.x, pos.y + background->h, to);
|
||||
blitAt(tmpBackgroundFiller, pos.x, pos.y + pos.h, to);
|
||||
}
|
||||
|
||||
CAdvMapPanel::showAll(to);
|
||||
|
@ -320,7 +320,6 @@ class CAdvMapPanel : public CIntObject
|
||||
{
|
||||
/// ptrs to child-buttons that can be recolored with setPlayerColor()
|
||||
std::vector<CButton *> buttons;
|
||||
protected:
|
||||
/// the surface passed to this obj will be freed in dtor
|
||||
SDL_Surface * background;
|
||||
public:
|
||||
@ -344,13 +343,14 @@ class CAdvMapWorldViewPanel : public CAdvMapPanel
|
||||
std::vector<CPicture *> currentIcons;
|
||||
/// temporary surface drawn below world view panel on higher resolutions (won't be needed when world view panel is configured for extraResolutions mod)
|
||||
SDL_Surface * tmpBackgroundFiller;
|
||||
int fillerHeight;
|
||||
public:
|
||||
CAdvMapWorldViewPanel(SDL_Surface * bg, Point position, int spaceBottom, const PlayerColor &color);
|
||||
virtual ~CAdvMapWorldViewPanel();
|
||||
|
||||
void addChildIcon(std::pair<int, Point> data, const CDefHandler *def, int indexOffset);
|
||||
/// recreates all pictures from given def to recolor them according to current player color
|
||||
void recolorIcons(const CDefHandler *def, int indexOffset);
|
||||
void recolorIcons(const PlayerColor &color, const CDefHandler *def, int indexOffset);
|
||||
void showAll(SDL_Surface * to);
|
||||
};
|
||||
|
||||
|
@ -1281,7 +1281,7 @@ void CAdvMapInt::setPlayer(PlayerColor Player)
|
||||
|
||||
panelMain->setPlayerColor(player);
|
||||
panelWorldView->setPlayerColor(player);
|
||||
panelWorldView->recolorIcons(worldViewIconsDef, player.getNum() * 19);
|
||||
panelWorldView->recolorIcons(player, worldViewIconsDef, player.getNum() * 19);
|
||||
graphics->blueToPlayersAdv(resdatabar.bg,player);
|
||||
|
||||
//heroList.updateHList();
|
||||
|
Loading…
x
Reference in New Issue
Block a user