1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-21 12:06:49 +02:00

Fixed recoloring filler background to correct player color after game reload;

This commit is contained in:
Fay 2015-01-29 20:34:53 +01:00
parent 794c03792a
commit df419e23c0
3 changed files with 23 additions and 11 deletions

View File

@ -1235,6 +1235,11 @@ CAdvMapPanel::CAdvMapPanel(SDL_Surface * bg, Point position)
recActions = 255; recActions = 255;
pos.x += position.x; pos.x += position.x;
pos.y += position.y; pos.y += position.y;
if (bg)
{
pos.w = bg->w;
pos.h = bg->h;
}
} }
CAdvMapPanel::~CAdvMapPanel() CAdvMapPanel::~CAdvMapPanel()
@ -1274,11 +1279,11 @@ void CAdvMapPanel::addChildToPanel(CIntObject * obj, ui8 actions /* = 0 */)
CAdvMapWorldViewPanel::CAdvMapWorldViewPanel(SDL_Surface * bg, Point position, int spaceBottom, const PlayerColor &color) 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: " tmpBackgroundFiller = CMessage::drawDialogBox(pos.w, fillerHeight, color);
<< background->w << "x" << (spaceBottom - pos.y - background->h);
tmpBackgroundFiller = CMessage::drawDialogBox(background->w, spaceBottom - pos.y - background->h, color);
} }
else else
tmpBackgroundFiller = nullptr; tmpBackgroundFiller = nullptr;
@ -1287,10 +1292,10 @@ CAdvMapWorldViewPanel::CAdvMapWorldViewPanel(SDL_Surface * bg, Point position, i
CAdvMapWorldViewPanel::~CAdvMapWorldViewPanel() CAdvMapWorldViewPanel::~CAdvMapWorldViewPanel()
{ {
if (tmpBackgroundFiller) 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) for (auto &pic : currentIcons)
{ {
@ -1306,6 +1311,13 @@ void CAdvMapWorldViewPanel::recolorIcons(const CDefHandler *def, int indexOffset
currentIcons.push_back(pic); currentIcons.push_back(pic);
addChildToPanel(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) 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) if (tmpBackgroundFiller)
{ {
blitAt(tmpBackgroundFiller, pos.x, pos.y + background->h, to); blitAt(tmpBackgroundFiller, pos.x, pos.y + pos.h, to);
} }
CAdvMapPanel::showAll(to); CAdvMapPanel::showAll(to);

View File

@ -320,7 +320,6 @@ class CAdvMapPanel : public CIntObject
{ {
/// ptrs to child-buttons that can be recolored with setPlayerColor() /// ptrs to child-buttons that can be recolored with setPlayerColor()
std::vector<CButton *> buttons; std::vector<CButton *> buttons;
protected:
/// the surface passed to this obj will be freed in dtor /// the surface passed to this obj will be freed in dtor
SDL_Surface * background; SDL_Surface * background;
public: public:
@ -344,13 +343,14 @@ class CAdvMapWorldViewPanel : public CAdvMapPanel
std::vector<CPicture *> currentIcons; 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) /// 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; SDL_Surface * tmpBackgroundFiller;
int fillerHeight;
public: public:
CAdvMapWorldViewPanel(SDL_Surface * bg, Point position, int spaceBottom, const PlayerColor &color); CAdvMapWorldViewPanel(SDL_Surface * bg, Point position, int spaceBottom, const PlayerColor &color);
virtual ~CAdvMapWorldViewPanel(); virtual ~CAdvMapWorldViewPanel();
void addChildIcon(std::pair<int, Point> data, const CDefHandler *def, int indexOffset); 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 /// 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); void showAll(SDL_Surface * to);
}; };

View File

@ -1281,7 +1281,7 @@ void CAdvMapInt::setPlayer(PlayerColor Player)
panelMain->setPlayerColor(player); panelMain->setPlayerColor(player);
panelWorldView->setPlayerColor(player); panelWorldView->setPlayerColor(player);
panelWorldView->recolorIcons(worldViewIconsDef, player.getNum() * 19); panelWorldView->recolorIcons(player, worldViewIconsDef, player.getNum() * 19);
graphics->blueToPlayersAdv(resdatabar.bg,player); graphics->blueToPlayersAdv(resdatabar.bg,player);
//heroList.updateHList(); //heroList.updateHList();