mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
use CAnimImage for world view legend
This commit is contained in:
parent
36ac9ac86c
commit
365c64a345
@ -17,6 +17,8 @@
|
||||
#include "../gui/CGuiHandler.h"
|
||||
#include "../gui/SDL_Pixels.h"
|
||||
|
||||
#include "../widgets/Images.h"
|
||||
|
||||
#include "../windows/InfoWindows.h"
|
||||
#include "../windows/CAdvmapInterface.h"
|
||||
#include "../windows/GUIClasses.h"
|
||||
@ -1256,11 +1258,11 @@ void CAdvMapPanel::addChildToPanel(CIntObject * obj, ui8 actions /* = 0 */)
|
||||
addChild(obj, false);
|
||||
}
|
||||
|
||||
CAdvMapWorldViewPanel::CAdvMapWorldViewPanel(SDL_Surface * bg, Point position, int spaceBottom, const PlayerColor &color)
|
||||
: CAdvMapPanel(bg, position)
|
||||
CAdvMapWorldViewPanel::CAdvMapWorldViewPanel(std::shared_ptr<CAnimation> _icons, SDL_Surface * bg, Point position, int spaceBottom, const PlayerColor &color)
|
||||
: CAdvMapPanel(bg, position), icons(_icons)
|
||||
{
|
||||
fillerHeight = bg ? spaceBottom - pos.y - pos.h : 0;
|
||||
|
||||
|
||||
if (fillerHeight > 0)
|
||||
{
|
||||
tmpBackgroundFiller = CMessage::drawDialogBox(pos.w, fillerHeight, color);
|
||||
@ -1275,23 +1277,16 @@ CAdvMapWorldViewPanel::~CAdvMapWorldViewPanel()
|
||||
SDL_FreeSurface(tmpBackgroundFiller);
|
||||
}
|
||||
|
||||
void CAdvMapWorldViewPanel::recolorIcons(const PlayerColor &color, const CDefHandler *def, int indexOffset)
|
||||
void CAdvMapWorldViewPanel::recolorIcons(const PlayerColor &color, int indexOffset)
|
||||
{
|
||||
for (auto &pic : currentIcons)
|
||||
{
|
||||
removeChild(pic);
|
||||
delete pic;
|
||||
}
|
||||
currentIcons.clear();
|
||||
assert(iconsData.size() == currentIcons.size());
|
||||
|
||||
for (auto &data : iconsData)
|
||||
for(size_t idx = 0; idx < iconsData.size(); idx++)
|
||||
{
|
||||
auto pic = new CPicture(def->ourImages[data.first + indexOffset].bitmap, data.second.x, data.second.y, false);
|
||||
pic->recActions |= SHOWALL;
|
||||
currentIcons.push_back(pic);
|
||||
addChildToPanel(pic);
|
||||
const auto & data = iconsData.at(idx);
|
||||
currentIcons[idx]->setFrame(data.first + indexOffset);
|
||||
}
|
||||
|
||||
|
||||
if (fillerHeight > 0)
|
||||
{
|
||||
if (tmpBackgroundFiller)
|
||||
@ -1300,18 +1295,17 @@ void CAdvMapWorldViewPanel::recolorIcons(const PlayerColor &color, const CDefHan
|
||||
}
|
||||
}
|
||||
|
||||
void CAdvMapWorldViewPanel::addChildIcon(std::pair<int, Point> data, const CDefHandler *def, int indexOffset)
|
||||
void CAdvMapWorldViewPanel::addChildIcon(std::pair<int, Point> data, int indexOffset)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
iconsData.push_back(data);
|
||||
auto pic = new CPicture(def->ourImages[data.first + indexOffset].bitmap, data.second.x, data.second.y, false);
|
||||
currentIcons.push_back(pic);
|
||||
addChildToPanel(pic);
|
||||
currentIcons.push_back(new CAnimImage(icons, data.first + indexOffset, 0, data.second.x, data.second.y));
|
||||
}
|
||||
|
||||
void CAdvMapWorldViewPanel::showAll(SDL_Surface * to)
|
||||
{
|
||||
if (tmpBackgroundFiller)
|
||||
{
|
||||
{
|
||||
blitAt(tmpBackgroundFiller, pos.x, pos.y + pos.h, to);
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include "../../lib/FunctionList.h"
|
||||
|
||||
class CArmedInstance;
|
||||
class CAnimation;
|
||||
class CAnimImage;
|
||||
class CShowableAnim;
|
||||
class CGGarrison;
|
||||
class CGObjectInstance;
|
||||
@ -340,17 +342,18 @@ class CAdvMapWorldViewPanel : public CAdvMapPanel
|
||||
/// data that allows reconstruction of panel info icons
|
||||
std::vector<std::pair<int, Point>> iconsData;
|
||||
/// ptrs to child-pictures constructed from iconsData
|
||||
std::vector<CPicture *> currentIcons;
|
||||
std::vector<CAnimImage *> 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;
|
||||
std::shared_ptr<CAnimation> icons;
|
||||
public:
|
||||
CAdvMapWorldViewPanel(SDL_Surface * bg, Point position, int spaceBottom, const PlayerColor &color);
|
||||
CAdvMapWorldViewPanel(std::shared_ptr<CAnimation> _icons, SDL_Surface * bg, Point position, int spaceBottom, const PlayerColor &color);
|
||||
virtual ~CAdvMapWorldViewPanel();
|
||||
|
||||
void addChildIcon(std::pair<int, Point> data, const CDefHandler *def, int indexOffset);
|
||||
void addChildIcon(std::pair<int, Point> data, int indexOffset);
|
||||
/// recreates all pictures from given def to recolor them according to current player color
|
||||
void recolorIcons(const PlayerColor &color, const CDefHandler *def, int indexOffset);
|
||||
void recolorIcons(const PlayerColor &color, int indexOffset);
|
||||
void showAll(SDL_Surface * to) override;
|
||||
};
|
||||
|
||||
|
@ -321,9 +321,6 @@ void CTerrainRect::show(SDL_Surface * to)
|
||||
showPath(&pos, to);
|
||||
}
|
||||
}
|
||||
//SDL_BlitSurface(teren,&genRect(pos.h,pos.w,0,0),screen,&genRect(547,594,7,6));
|
||||
//SDL_FreeSurface(teren);
|
||||
|
||||
}
|
||||
|
||||
void CTerrainRect::showAll(SDL_Surface * to)
|
||||
@ -503,6 +500,8 @@ CAdvMapInt::CAdvMapInt():
|
||||
}
|
||||
worldViewIconsDef = CDefHandler::giveDef("VwSymbol.def");
|
||||
|
||||
worldViewIcons = std::make_shared<CAnimation>("VwSymbol");//todo: customize with ADVOPT
|
||||
|
||||
for (int g=0; g<ADVOPT.gemG.size(); ++g)
|
||||
{
|
||||
gems.push_back(new CAnimImage(ADVOPT.gemG[g], 0, 0, ADVOPT.gemX[g], ADVOPT.gemY[g]));
|
||||
@ -531,7 +530,7 @@ CAdvMapInt::CAdvMapInt():
|
||||
|
||||
panelMain = new CAdvMapPanel(nullptr, Point(0, 0));
|
||||
// TODO correct drawing position
|
||||
panelWorldView = new CAdvMapWorldViewPanel(bgWorldView, Point(heroList.pos.x - 2, 195), panelSpaceBottom, LOCPLINT->playerID);
|
||||
panelWorldView = new CAdvMapWorldViewPanel(worldViewIcons, bgWorldView, Point(heroList.pos.x - 2, 195), panelSpaceBottom, LOCPLINT->playerID);
|
||||
|
||||
panelMain->addChildColorableButton(kingOverview);
|
||||
panelMain->addChildColorableButton(underground);
|
||||
@ -600,16 +599,17 @@ CAdvMapInt::CAdvMapInt():
|
||||
|
||||
int iconColorMultiplier = player.getNum() * 19;
|
||||
int wvLeft = heroList.pos.x - 2; // TODO correct drawing position
|
||||
//int wvTop = 195;
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
panelWorldView->addChildIcon(std::pair<int, Point>(i, Point(wvLeft + 5, 253 + i * 20)), worldViewIconsDef, iconColorMultiplier);
|
||||
panelWorldView->addChildIcon(std::pair<int, Point>(i, Point(5, 58 + i * 20)), iconColorMultiplier);
|
||||
panelWorldView->addChildToPanel(new CLabel(wvLeft + 45, 263 + i * 20, EFonts::FONT_SMALL, EAlignment::TOPLEFT,
|
||||
Colors::WHITE, CGI->generaltexth->allTexts[612 + i]));
|
||||
}
|
||||
for (int i = 0; i < 7; ++i)
|
||||
{
|
||||
panelWorldView->addChildIcon(std::pair<int, Point>(i + 5, Point(wvLeft + 5, 377 + i * 20)), worldViewIconsDef, iconColorMultiplier);
|
||||
panelWorldView->addChildIcon(std::pair<int, Point>(i + 12, Point(wvLeft + 160, 377 + i * 20)), worldViewIconsDef, iconColorMultiplier);
|
||||
panelWorldView->addChildIcon(std::pair<int, Point>(i + 5, Point(5, 182 + i * 20)), iconColorMultiplier);
|
||||
panelWorldView->addChildIcon(std::pair<int, Point>(i + 12, Point(160, 182 + i * 20)), iconColorMultiplier);
|
||||
panelWorldView->addChildToPanel(new CLabel(wvLeft + 45, 387 + i * 20, EFonts::FONT_SMALL, EAlignment::TOPLEFT,
|
||||
Colors::WHITE, CGI->generaltexth->allTexts[619 + i]));
|
||||
}
|
||||
@ -1377,11 +1377,8 @@ void CAdvMapInt::setPlayer(PlayerColor Player)
|
||||
|
||||
panelMain->setPlayerColor(player);
|
||||
panelWorldView->setPlayerColor(player);
|
||||
panelWorldView->recolorIcons(player, worldViewIconsDef, player.getNum() * 19);
|
||||
panelWorldView->recolorIcons(player, player.getNum() * 19);
|
||||
graphics->blueToPlayersAdv(resdatabar.bg,player);
|
||||
|
||||
//heroList.updateHList();
|
||||
//townList.genList();
|
||||
}
|
||||
|
||||
void CAdvMapInt::startTurn()
|
||||
|
@ -176,7 +176,9 @@ public:
|
||||
CAdvMapWorldViewPanel *panelWorldView; // panel that holds all buttons and other ui in world view
|
||||
CAdvMapPanel *activeMapPanel; // currently active panel (either main or world view, depending on current mode)
|
||||
|
||||
CDefHandler * worldViewIconsDef; // images for world view overlay
|
||||
CDefHandler * worldViewIconsDef; // images for world view overlay(DEPRECATED)
|
||||
|
||||
std::shared_ptr<CAnimation> worldViewIcons;// images for world view overlay
|
||||
|
||||
const CSpell *spellBeingCasted; //nullptr if none
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user