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

Added empty background below world view panel for better compat with higher resolutions;

This commit is contained in:
Fay 2015-01-29 18:39:46 +01:00
parent 77908dcf76
commit 794c03792a
3 changed files with 35 additions and 4 deletions

View File

@ -12,6 +12,7 @@
#include "../CPlayerInterface.h"
#include "../CPreGame.h"
#include "../Graphics.h"
#include "../CMessage.h"
#include "../gui/CGuiHandler.h"
#include "../gui/SDL_Pixels.h"
@ -1270,10 +1271,23 @@ void CAdvMapPanel::addChildToPanel(CIntObject * obj, ui8 actions /* = 0 */)
addChild(obj, false);
}
CAdvMapWorldViewPanel::CAdvMapWorldViewPanel(SDL_Surface * bg, Point position)
CAdvMapWorldViewPanel::CAdvMapWorldViewPanel(SDL_Surface * bg, Point position, int spaceBottom, const PlayerColor &color)
: CAdvMapPanel(bg, position)
{
if (background && spaceBottom - pos.y > background->h)
{
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);
}
else
tmpBackgroundFiller = nullptr;
}
CAdvMapWorldViewPanel::~CAdvMapWorldViewPanel()
{
if (tmpBackgroundFiller)
delete tmpBackgroundFiller;
}
void CAdvMapWorldViewPanel::recolorIcons(const CDefHandler *def, int indexOffset)
@ -1301,3 +1315,13 @@ void CAdvMapWorldViewPanel::addChildIcon(std::pair<int, Point> data, const CDefH
currentIcons.push_back(pic);
addChildToPanel(pic);
}
void CAdvMapWorldViewPanel::showAll(SDL_Surface * to)
{
if (tmpBackgroundFiller)
{
blitAt(tmpBackgroundFiller, pos.x, pos.y + background->h, to);
}
CAdvMapPanel::showAll(to);
}

View File

@ -320,6 +320,7 @@ 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:
@ -341,13 +342,16 @@ class CAdvMapWorldViewPanel : public CAdvMapPanel
std::vector<std::pair<int, Point>> iconsData;
/// ptrs to child-pictures constructed from iconsData
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;
public:
CAdvMapWorldViewPanel(SDL_Surface * bg, Point position);
virtual ~CAdvMapWorldViewPanel(){}
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 showAll(SDL_Surface * to);
};
class CInGameConsole : public CIntObject

View File

@ -458,8 +458,11 @@ CAdvMapInt::CAdvMapInt():
nextHero = makeButton(301, std::bind(&CAdvMapInt::fnextHero,this), ADVOPT.nextHero, SDLK_h);
endTurn = makeButton(302, std::bind(&CAdvMapInt::fendTurn,this), ADVOPT.endTurn, SDLK_e);
int panelSpaceBottom = screen->h - resdatabar.pos.h - 4;
panelMain = new CAdvMapPanel(nullptr, Point(0, 0));
panelWorldView = new CAdvMapWorldViewPanel(bgWorldView, Point(heroList.pos.x - 2, 195)); // TODO correct drawing position
// TODO correct drawing position
panelWorldView = new CAdvMapWorldViewPanel(bgWorldView, Point(heroList.pos.x - 2, 195), panelSpaceBottom, LOCPLINT->playerID);
panelMain->addChildColorableButton(kingOverview);
panelMain->addChildColorableButton(underground);