1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Reduce direct access to CAnimation, removed various caching schemes

This commit is contained in:
Ivan Savenko 2024-06-02 15:43:56 +00:00
parent 56f1725234
commit a1fb3b8b01
28 changed files with 59 additions and 138 deletions

View File

@ -31,7 +31,6 @@ class CAnimImage;
class CGStatusBar;
class AdventureMapWidget;
class AdventureMapShortcuts;
class CAnimation;
class MapView;
class CResDataBar;
class CHeroList;

View File

@ -20,7 +20,6 @@
#include "../gui/CGuiHandler.h"
#include "../gui/Shortcut.h"
#include "../mapView/MapView.h"
#include "../render/CAnimation.h"
#include "../render/IImage.h"
#include "../render/IRenderHandler.h"
#include "../widgets/Buttons.h"
@ -125,26 +124,6 @@ Rect AdventureMapWidget::readArea(const JsonNode & source, const Rect & bounding
return Rect(topLeft + boundingBox.topLeft(), dimensions);
}
std::shared_ptr<IImage> AdventureMapWidget::loadImage(const JsonNode & name)
{
ImagePath resource = ImagePath::fromJson(name);
if(images.count(resource) == 0)
images[resource] = GH.renderHandler().loadImage(resource);
return images[resource];
}
std::shared_ptr<CAnimation> AdventureMapWidget::loadAnimation(const JsonNode & name)
{
AnimationPath resource = AnimationPath::fromJson(name);
if(animations.count(resource) == 0)
animations[resource] = GH.renderHandler().loadAnimation(resource);
return animations[resource];
}
std::shared_ptr<CIntObject> AdventureMapWidget::buildInfobox(const JsonNode & input)
{
Rect area = readTargetArea(input["area"]);
@ -157,7 +136,7 @@ std::shared_ptr<CIntObject> AdventureMapWidget::buildMapImage(const JsonNode & i
Rect targetArea = readTargetArea(input["area"]);
Rect sourceArea = readSourceArea(input["sourceArea"], input["area"]);
return std::make_shared<CFilledTexture>(loadImage(input["image"]), targetArea, sourceArea);
return std::make_shared<CFilledTexture>(ImagePath::fromJson(input["image"]), targetArea, sourceArea);
}
std::shared_ptr<CIntObject> AdventureMapWidget::buildMapButton(const JsonNode & input)
@ -257,7 +236,7 @@ std::shared_ptr<CIntObject> AdventureMapWidget::buildMapIcon(const JsonNode & in
size_t index = input["index"].Integer();
size_t perPlayer = input["perPlayer"].Integer();
return std::make_shared<CAdventureMapIcon>(area.topLeft(), loadAnimation(input["image"]), index, perPlayer);
return std::make_shared<CAdventureMapIcon>(area.topLeft(), AnimationPath::fromJson(input["image"]), index, perPlayer);
}
std::shared_ptr<CIntObject> AdventureMapWidget::buildMapTownList(const JsonNode & input)
@ -387,16 +366,10 @@ void AdventureMapWidget::setPlayerChildren(CIntObject * widget, const PlayerColo
texture->playerColored(player);
}
for(const auto & entry : playerColorerImages)
{
if(images.count(entry))
images[entry]->playerColored(player);
}
redraw();
}
CAdventureMapIcon::CAdventureMapIcon(const Point & position, std::shared_ptr<CAnimation> animation, size_t index, size_t iconsPerPlayer)
CAdventureMapIcon::CAdventureMapIcon(const Point & position, const AnimationPath & animation, size_t index, size_t iconsPerPlayer)
: index(index)
, iconsPerPlayer(iconsPerPlayer)
{

View File

@ -11,7 +11,6 @@
#include "../gui/InterfaceObjectConfigurable.h"
class CAnimation;
class CHeroList;
class CTownList;
class CMinimap;
@ -31,10 +30,6 @@ class AdventureMapWidget : public InterfaceObjectConfigurable
/// list of images on which player-colored palette will be applied
std::vector<ImagePath> playerColorerImages;
/// list of named images shared between widgets
std::map<ImagePath, std::shared_ptr<IImage>> images;
std::map<AnimationPath, std::shared_ptr<CAnimation>> animations;
/// Widgets that require access from adventure map
std::shared_ptr<CHeroList> heroList;
std::shared_ptr<CTownList> townList;
@ -48,9 +43,6 @@ class AdventureMapWidget : public InterfaceObjectConfigurable
Rect readSourceArea(const JsonNode & source, const JsonNode & sourceCommon);
Rect readArea(const JsonNode & source, const Rect & boundingBox);
std::shared_ptr<IImage> loadImage(const JsonNode & name);
std::shared_ptr<CAnimation> loadAnimation(const JsonNode & name);
std::shared_ptr<CIntObject> buildInfobox(const JsonNode & input);
std::shared_ptr<CIntObject> buildMapImage(const JsonNode & input);
std::shared_ptr<CIntObject> buildMapButton(const JsonNode & input);
@ -104,7 +96,7 @@ class CAdventureMapIcon : public CIntObject
size_t index;
size_t iconsPerPlayer;
public:
CAdventureMapIcon(const Point & position, std::shared_ptr<CAnimation> image, size_t index, size_t iconsPerPlayer);
CAdventureMapIcon(const Point & position, const AnimationPath & image, size_t index, size_t iconsPerPlayer);
void setPlayer(const PlayerColor & player);
};

View File

@ -24,6 +24,7 @@
#include "../gui/CursorHandler.h"
#include "../gui/CGuiHandler.h"
#include "../media/ISoundPlayer.h"
#include "../render/CAnimation.h"
#include "../render/IRenderHandler.h"
#include "../../CCallback.h"

View File

@ -39,7 +39,6 @@ class Canvas;
class BattleResultWindow;
class StackQueue;
class CPlayerInterface;
class CAnimation;
struct BattleEffect;
class IImage;
class StackQueue;

View File

@ -21,6 +21,7 @@
#include "../CPlayerInterface.h"
#include "../gui/CGuiHandler.h"
#include "../media/ISoundPlayer.h"
#include "../render/CAnimation.h"
#include "../render/Canvas.h"
#include "../render/IRenderHandler.h"

View File

@ -15,6 +15,7 @@
#include "BattleStacksController.h"
#include "CreatureAnimation.h"
#include "../render/CAnimation.h"
#include "../render/Canvas.h"
#include "../render/IRenderHandler.h"
#include "../gui/CGuiHandler.h"

View File

@ -14,6 +14,7 @@
#include "../../lib/CCreatureHandler.h"
#include "../gui/CGuiHandler.h"
#include "../render/CAnimation.h"
#include "../render/Canvas.h"
#include "../render/ColorFilter.h"
#include "../render/IRenderHandler.h"

View File

@ -12,7 +12,6 @@
#include "../../lib/FunctionList.h"
#include "../../lib/Color.h"
#include "../widgets/Images.h"
#include "../render/CAnimation.h"
#include "../render/IImage.h"
class CIntObject;

View File

@ -515,9 +515,6 @@ CFlagBox::CFlagBox(const Rect & rect)
labelAllies = std::make_shared<CLabel>(0, 0, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[390] + ":");
labelEnemies = std::make_shared<CLabel>(133, 0, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[391] + ":");
iconsTeamFlags = GH.renderHandler().loadAnimation(AnimationPath::builtin("ITGFLAGS.DEF"));
iconsTeamFlags->preload();
}
void CFlagBox::recreate()
@ -529,7 +526,7 @@ void CFlagBox::recreate()
const int enemiesX = 5 + 133 + (int)labelEnemies->getWidth();
for(auto i = CSH->si->playerInfos.cbegin(); i != CSH->si->playerInfos.cend(); i++)
{
auto flag = std::make_shared<CAnimImage>(iconsTeamFlags, i->first.getNum(), 0);
auto flag = std::make_shared<CAnimImage>(AnimationPath::builtin("ITGFLAGS.DEF"), i->first.getNum(), 0);
if(i->first == CSH->myFirstColor() || CSH->getPlayerTeamId(i->first) == CSH->getPlayerTeamId(CSH->myFirstColor()))
{
flag->moveTo(Point(pos.x + alliesX + (int)flagsAllies.size()*flag->pos.w, pos.y));
@ -546,10 +543,10 @@ void CFlagBox::recreate()
void CFlagBox::showPopupWindow(const Point & cursorPosition)
{
if(SEL->getMapInfo())
GH.windows().createAndPushWindow<CFlagBoxTooltipBox>(iconsTeamFlags);
GH.windows().createAndPushWindow<CFlagBoxTooltipBox>();
}
CFlagBox::CFlagBoxTooltipBox::CFlagBoxTooltipBox(std::shared_ptr<CAnimation> icons)
CFlagBox::CFlagBoxTooltipBox::CFlagBoxTooltipBox()
: CWindowObject(BORDERED | RCLICK_POPUP | SHADOW_DISABLED, ImagePath::builtin("DIBOXBCK"))
{
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
@ -577,7 +574,7 @@ CFlagBox::CFlagBoxTooltipBox::CFlagBoxTooltipBox(std::shared_ptr<CAnimation> ico
int curx = 128 - 9 * team.size();
for(const auto & player : team)
{
iconsFlags.push_back(std::make_shared<CAnimImage>(icons, player, 0, curx, 75 + 50 * curIdx));
iconsFlags.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("ITGFLAGS.DEF"), player, 0, curx, 75 + 50 * curIdx));
curx += 18;
}
++curIdx;

View File

@ -174,7 +174,6 @@ public:
class CFlagBox : public CIntObject
{
std::shared_ptr<CAnimation> iconsTeamFlags;
std::shared_ptr<CLabel> labelAllies;
std::shared_ptr<CLabel> labelEnemies;
std::vector<std::shared_ptr<CAnimImage>> flagsAllies;
@ -192,7 +191,7 @@ public:
std::shared_ptr<CLabelGroup> labelGroupTeams;
std::vector<std::shared_ptr<CAnimImage>> iconsFlags;
public:
CFlagBoxTooltipBox(std::shared_ptr<CAnimation> icons);
CFlagBoxTooltipBox();
};
};

View File

@ -20,6 +20,7 @@ class CSlider;
class CLabel;
class CPicture;
class IImage;
class CAnimation;
enum ESortBy
{

View File

@ -24,7 +24,6 @@ class CGStatusBar;
class CTextBox;
class CTabbedInt;
class CAnimImage;
class CAnimation;
class CButton;
class CFilledTexture;
class CLabel;

View File

@ -28,7 +28,6 @@ class JsonNode;
VCMI_LIB_NAMESPACE_END
struct SDL_Surface;
class CAnimation;
class IFont;
/// Handles fonts, hero images, town images, various graphics

View File

@ -9,7 +9,6 @@
*/
#pragma once
class CAnimation;
class IImage;
struct SDL_Surface;
struct SDL_Texture;

View File

@ -9,7 +9,6 @@
*/
#pragma once
class CAnimation;
class IImage;
struct SDL_Surface;
struct SDL_Texture;

View File

@ -24,7 +24,6 @@
#include "../gui/InterfaceObjectConfigurable.h"
#include "../media/ISoundPlayer.h"
#include "../windows/InfoWindows.h"
#include "../render/CAnimation.h"
#include "../render/Canvas.h"
#include "../render/IRenderHandler.h"

View File

@ -111,18 +111,18 @@ void CPicture::colorize(PlayerColor player)
bg->playerColored(player);
}
CFilledTexture::CFilledTexture(const ImagePath & imageName, Rect position):
CIntObject(0, position.topLeft()),
texture(GH.renderHandler().loadImage(imageName))
CFilledTexture::CFilledTexture(const ImagePath & imageName, Rect position)
: CIntObject(0, position.topLeft())
, texture(GH.renderHandler().loadImage(imageName))
{
pos.w = position.w;
pos.h = position.h;
imageArea = Rect(Point(), texture->dimensions());
}
CFilledTexture::CFilledTexture(std::shared_ptr<IImage> image, Rect position, Rect imageArea)
CFilledTexture::CFilledTexture(const ImagePath & imageName, Rect position, Rect imageArea)
: CIntObject(0, position.topLeft())
, texture(image)
, texture(GH.renderHandler().loadImage(imageName))
, imageArea(imageArea)
{
pos.w = position.w;
@ -191,8 +191,8 @@ CAnimImage::CAnimImage(std::shared_ptr<CAnimation> Anim, size_t Frame, size_t Gr
init();
}
CAnimImage::CAnimImage(std::shared_ptr<CAnimation> Anim, size_t Frame, Rect targetPos, size_t Group, ui8 Flags):
anim(Anim),
CAnimImage::CAnimImage(const AnimationPath & name, size_t Frame, Rect targetPos, size_t Group, ui8 Flags):
anim(GH.renderHandler().loadAnimation(name)),
frame(Frame),
group(Group),
flags(Flags),

View File

@ -68,8 +68,8 @@ protected:
Rect imageArea;
public:
CFilledTexture(const ImagePath & imageName, Rect position, Rect imageArea);
CFilledTexture(const ImagePath & imageName, Rect position);
CFilledTexture(std::shared_ptr<IImage> image, Rect position, Rect imageArea);
void showAll(Canvas & to) override;
};
@ -104,7 +104,7 @@ public:
CAnimImage(const AnimationPath & name, size_t Frame, size_t Group=0, int x=0, int y=0, ui8 Flags=0);
CAnimImage(std::shared_ptr<CAnimation> Anim, size_t Frame, size_t Group=0, int x=0, int y=0, ui8 Flags=0);
CAnimImage(std::shared_ptr<CAnimation> Anim, size_t Frame, Rect targetPos, size_t Group=0, ui8 Flags=0);
CAnimImage(const AnimationPath & name, size_t Frame, Rect targetPos, size_t Group=0, ui8 Flags=0);
~CAnimImage();
/// size of animation

View File

@ -18,7 +18,6 @@ VCMI_LIB_NAMESPACE_END
class CAnimImage;
class CSlider;
class CLabel;
class CAnimation;
/// Used as base for Tabs and List classes
class CObjectList : public CIntObject

View File

@ -26,7 +26,6 @@
#include "../widgets/TextControls.h"
#include "../render/IRenderHandler.h"
#include "../render/CAnimation.h"
#include "../../CCallback.h"
@ -66,17 +65,12 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
titles[0] = std::make_shared<CLabel>(147, 25, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, genTitle(heroInst[0]));
titles[1] = std::make_shared<CLabel>(653, 25, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, genTitle(heroInst[1]));
auto PSKIL32 = GH.renderHandler().loadAnimation(AnimationPath::builtin("PSKIL32"));
PSKIL32->preload();
auto SECSK32 = GH.renderHandler().loadAnimation(AnimationPath::builtin("SECSK32"));
for(int g = 0; g < 4; ++g)
{
if (qeLayout)
primSkillImages.push_back(std::make_shared<CAnimImage>(PSKIL32, g, Rect(389, 12 + 26 * g, 22, 22)));
primSkillImages.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("PSKIL32"), g, Rect(389, 12 + 26 * g, 22, 22)));
else
primSkillImages.push_back(std::make_shared<CAnimImage>(PSKIL32, g, 0, 385, 19 + 36 * g));
primSkillImages.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("PSKIL32"), g, 0, 385, 19 + 36 * g));
}
for(int leftRight : {0, 1})
@ -88,14 +82,14 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
for(int m=0; m < hero->secSkills.size(); ++m)
secSkillIcons[leftRight].push_back(std::make_shared<CAnimImage>(SECSK32, 0, 0, 32 + 36 * m + 454 * leftRight, qeLayout ? 83 : 88));
secSkillIcons[leftRight].push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("SECSK32"), 0, 0, 32 + 36 * m + 454 * leftRight, qeLayout ? 83 : 88));
specImages[leftRight] = std::make_shared<CAnimImage>(AnimationPath::builtin("UN32"), hero->type->imageIndex, 0, 67 + 490 * leftRight, qeLayout ? 41 : 45);
expImages[leftRight] = std::make_shared<CAnimImage>(PSKIL32, 4, 0, 103 + 490 * leftRight, qeLayout ? 41 : 45);
expImages[leftRight] = std::make_shared<CAnimImage>(AnimationPath::builtin("PSKIL32"), 4, 0, 103 + 490 * leftRight, qeLayout ? 41 : 45);
expValues[leftRight] = std::make_shared<CLabel>(119 + 490 * leftRight, qeLayout ? 66 : 71, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
manaImages[leftRight] = std::make_shared<CAnimImage>(PSKIL32, 5, 0, 139 + 490 * leftRight, qeLayout ? 41 : 45);
manaImages[leftRight] = std::make_shared<CAnimImage>(AnimationPath::builtin("PSKIL32"), 5, 0, 139 + 490 * leftRight, qeLayout ? 41 : 45);
manaValues[leftRight] = std::make_shared<CLabel>(155 + 490 * leftRight, qeLayout ? 66 : 71, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
}

View File

@ -224,12 +224,12 @@ void CHeroOverview::genControls()
{
if((*CGI->heroh)[heroIdx]->haveSpellBook)
{
imageSpells.push_back(std::make_shared<CAnimImage>(GH.renderHandler().loadAnimation(AnimationPath::builtin("ARTIFACT")), 0, Rect(302 + (292 / 2) + 2 * borderOffset, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset), 32, 32), 0));
imageSpells.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("ARTIFACT"), 0, Rect(302 + (292 / 2) + 2 * borderOffset, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset), 32, 32), 0));
}
i++;
}
imageSpells.push_back(std::make_shared<CAnimImage>(GH.renderHandler().loadAnimation(AnimationPath::builtin("SPELLBON")), (*CGI->spellh)[spell]->getIconIndex(), Rect(302 + (292 / 2) + 2 * borderOffset, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset), 32, 32), 0));
imageSpells.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("SPELLBON"), (*CGI->spellh)[spell]->getIconIndex(), Rect(302 + (292 / 2) + 2 * borderOffset, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset), 32, 32), 0));
labelSpellsNames.push_back(std::make_shared<CLabel>(302 + (292 / 2) + 3 * borderOffset + 32 + borderOffset, 8 * borderOffset + yOffset + 186 + i * (32 + borderOffset) + 3, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, (*CGI->spellh)[spell]->getNameTranslated()));
i++;
}

View File

@ -28,7 +28,6 @@
#include "../widgets/CGarrisonInt.h"
#include "../widgets/TextControls.h"
#include "../widgets/Buttons.h"
#include "../render/CAnimation.h"
#include "../render/IRenderHandler.h"
#include "../../CCallback.h"
@ -131,14 +130,12 @@ CHeroWindow::CHeroWindow(const CGHeroInstance * hero)
primSkillValues.push_back(value);
}
auto primSkills = GH.renderHandler().loadAnimation(AnimationPath::builtin("PSKIL42"));
primSkills->preload();
primSkillImages.push_back(std::make_shared<CAnimImage>(primSkills, 0, 0, 32, 111));
primSkillImages.push_back(std::make_shared<CAnimImage>(primSkills, 1, 0, 102, 111));
primSkillImages.push_back(std::make_shared<CAnimImage>(primSkills, 2, 0, 172, 111));
primSkillImages.push_back(std::make_shared<CAnimImage>(primSkills, 3, 0, 162, 230));
primSkillImages.push_back(std::make_shared<CAnimImage>(primSkills, 4, 0, 20, 230));
primSkillImages.push_back(std::make_shared<CAnimImage>(primSkills, 5, 0, 242, 111));
primSkillImages.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("PSKIL42"), 0, 0, 32, 111));
primSkillImages.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("PSKIL42"), 1, 0, 102, 111));
primSkillImages.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("PSKIL42"), 2, 0, 172, 111));
primSkillImages.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("PSKIL42"), 3, 0, 162, 230));
primSkillImages.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("PSKIL42"), 4, 0, 20, 230));
primSkillImages.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("PSKIL42"), 5, 0, 242, 111));
specImage = std::make_shared<CAnimImage>(AnimationPath::builtin("UN44"), 0, 0, 18, 180);
specArea = std::make_shared<LRClickableAreaWText>(Rect(18, 180, 136, 42), CGI->generaltexth->heroscrn[27]);

View File

@ -20,7 +20,6 @@
#include "../widgets/TextControls.h"
#include "../windows/GUIClasses.h"
#include "../windows/InfoWindows.h"
#include "../render/CAnimation.h"
#include "../render/Canvas.h"
#include "../render/IImage.h"
#include "../render/IRenderHandler.h"

View File

@ -30,7 +30,6 @@
#include "../widgets/CTextInput.h"
#include "../widgets/TextControls.h"
#include "../adventureMap/AdventureMapInterface.h"
#include "../render/CAnimation.h"
#include "../render/IRenderHandler.h"
#include "../render/IImage.h"
#include "../render/IImageLoader.h"
@ -151,18 +150,9 @@ CSpellWindow::CSpellWindow(const CGHeroInstance * _myHero, CPlayerInterface * _m
leftCorner = std::make_shared<CPicture>(ImagePath::builtin("SpelTrnL.bmp"), 97 + offL, 77 + offT);
rightCorner = std::make_shared<CPicture>(ImagePath::builtin("SpelTrnR.bmp"), 487 + offR, 72 + offT);
spellIcons = GH.renderHandler().loadAnimation(AnimationPath::builtin("Spells"));
schoolTab = std::make_shared<CAnimImage>(AnimationPath::builtin("SpelTab"), selectedTab, 0, 524 + offR, 88);
schoolPicture = std::make_shared<CAnimImage>(AnimationPath::builtin("Schools"), 0, 0, 117 + offL, 74 + offT);
schoolBorders[0] = GH.renderHandler().loadAnimation(AnimationPath::builtin("SplevA.def"));
schoolBorders[1] = GH.renderHandler().loadAnimation(AnimationPath::builtin("SplevF.def"));
schoolBorders[2] = GH.renderHandler().loadAnimation(AnimationPath::builtin("SplevW.def"));
schoolBorders[3] = GH.renderHandler().loadAnimation(AnimationPath::builtin("SplevE.def"));
for(auto item : schoolBorders)
item->preload();
mana = std::make_shared<CLabel>(435 + (isBigSpellbook ? 159 : 0), 426 + offB, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, std::to_string(myHero->mana));
if(isBigSpellbook)
@ -595,7 +585,7 @@ CSpellWindow::SpellArea::SpellArea(Rect pos, CSpellWindow * owner)
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
image = std::make_shared<CAnimImage>(owner->spellIcons, 0, 0);
image = std::make_shared<CAnimImage>(AnimationPath::builtin("Spells"), 0, 0);
image->visible = false;
name = std::make_shared<CLabel>(39, 70, FONT_TINY, ETextAlignment::CENTER);
@ -744,14 +734,22 @@ void CSpellWindow::SpellArea::setSpell(const CSpell * spell)
{
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
static const std::array schoolBorders = {
AnimationPath::builtin("SplevA.def"),
AnimationPath::builtin("SplevF.def"),
AnimationPath::builtin("SplevW.def"),
AnimationPath::builtin("SplevE.def")
};
schoolBorder.reset();
if (owner->selectedTab >= 4)
{
if (whichSchool.getNum() != SpellSchool())
schoolBorder = std::make_shared<CAnimImage>(owner->schoolBorders.at(whichSchool.getNum()), schoolLevel);
schoolBorder = std::make_shared<CAnimImage>(schoolBorders.at(whichSchool.getNum()), schoolLevel);
}
else
schoolBorder = std::make_shared<CAnimImage>(owner->schoolBorders.at(owner->selectedTab), schoolLevel);
schoolBorder = std::make_shared<CAnimImage>(schoolBorders.at(owner->selectedTab), schoolLevel);
}
ColorRGBA firstLineColor, secondLineColor;

View File

@ -19,7 +19,6 @@ class CSpell;
VCMI_LIB_NAMESPACE_END
class IImage;
class CAnimation;
class CAnimImage;
class CPicture;
class CLabel;
@ -67,9 +66,6 @@ class CSpellWindow : public CWindowObject
InteractiveArea(const Rect &myRect, std::function<void()> funcL, int helpTextId, CSpellWindow * _owner);
};
std::shared_ptr<CAnimation> spellIcons;
std::array<std::shared_ptr<CAnimation>, 4> schoolBorders; //[0]: air, [1]: fire, [2]: water, [3]: earth
std::shared_ptr<CPicture> leftCorner;
std::shared_ptr<CPicture> rightCorner;

View File

@ -36,7 +36,6 @@
#include "../widgets/VideoWidget.h"
#include "../render/Canvas.h"
#include "../render/CAnimation.h"
#include "../render/IRenderHandler.h"
#include "../render/IImage.h"
@ -892,8 +891,13 @@ CUniversityWindow::CItem::CItem(CUniversityWindow * _parent, int _ID, int X, int
pos.x += X;
pos.y += Y;
topBar = std::make_shared<CAnimImage>(parent->bars, 0, 0, -28, -22);
bottomBar = std::make_shared<CAnimImage>(parent->bars, 0, 0, -28, 48);
// TODO: restore
//bars->setCustom("UNIVRED", 0, 0);
//bars->setCustom("UNIVGOLD", 1, 0);
//bars->setCustom("UNIVGREN", 2, 0);
topBar = std::make_shared<CPicture>(ImagePath::builtin("UNIVRED"), Point(-28, -22));
bottomBar = std::make_shared<CPicture>(ImagePath::builtin("UNIVRED"), Point(-28, 48));
icon = std::make_shared<CAnimImage>(AnimationPath::builtin("SECSKILL"), _ID * 3 + 3, 0);
@ -932,16 +936,6 @@ int CUniversityWindow::CItem::state()
return 2;
}
void CUniversityWindow::CItem::showAll(Canvas & to)
{
//TODO: update when state actually changes
auto stateIndex = state();
topBar->setFrame(stateIndex);
bottomBar->setFrame(stateIndex);
CIntObject::showAll(to);
}
CUniversityWindow::CUniversityWindow(const CGHeroInstance * _hero, const IMarket * _market, const std::function<void()> & onWindowClosed)
: CWindowObject(PLAYER_COLORED, ImagePath::builtin("UNIVERS1")),
hero(_hero),
@ -950,12 +944,7 @@ CUniversityWindow::CUniversityWindow(const CGHeroInstance * _hero, const IMarket
{
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
bars = GH.renderHandler().createAnimation();
bars->setCustom("UNIVRED", 0, 0);
bars->setCustom("UNIVGOLD", 1, 0);
bars->setCustom("UNIVGREN", 2, 0);
bars->preload();
std::string titleStr = CGI->generaltexth->allTexts[602];
std::string speechStr = CGI->generaltexth->allTexts[603];
@ -1331,18 +1320,12 @@ CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
rowHeaders.push_back(std::make_shared<CLabel>(135, y, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, text));
}
auto PRSTRIPS = GH.renderHandler().loadAnimation(AnimationPath::builtin("PRSTRIPS"));
PRSTRIPS->preload();
for(int g=1; g<tgi.playerColors.size(); ++g)
columnBackgrounds.push_back(std::make_shared<CAnimImage>(PRSTRIPS, g-1, 0, 250 + 66*g, 7));
columnBackgrounds.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("PRSTRIPS"), g-1, 0, 250 + 66*g, 7));
for(int g=0; g<tgi.playerColors.size(); ++g)
columnHeaders.push_back(std::make_shared<CLabel>(283 + 66*g, 24, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[16+g]));
auto itgflags = GH.renderHandler().loadAnimation(AnimationPath::builtin("itgflags"));
itgflags->preload();
//printing flags
for(int g = 0; g < std::size(fields); ++g) //by lines
{
@ -1366,7 +1349,7 @@ CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
int rowStartY = ypos + (j ? 4 : 0);
for(size_t i=0; i < rowLength[j]; i++)
cells.push_back(std::make_shared<CAnimImage>(itgflags, players[i + j*4].getNum(), 0, rowStartX + (int)i*12, rowStartY));
cells.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("itgflags"), players[i + j*4].getNum(), 0, rowStartX + (int)i*12, rowStartY));
}
}
}

View File

@ -363,15 +363,14 @@ class CUniversityWindow : public CStatusbarWindow
class CItem : public CIntObject
{
std::shared_ptr<CAnimImage> icon;
std::shared_ptr<CAnimImage> topBar;
std::shared_ptr<CAnimImage> bottomBar;
std::shared_ptr<CPicture> topBar;
std::shared_ptr<CPicture> bottomBar;
std::shared_ptr<CLabel> name;
std::shared_ptr<CLabel> level;
public:
SecondarySkill ID;//id of selected skill
CUniversityWindow * parent;
void showAll(Canvas & to) override;
void clickPressed(const Point & cursorPosition) override;
void showPopupWindow(const Point & cursorPosition) override;
void hover(bool on) override;
@ -382,8 +381,6 @@ class CUniversityWindow : public CStatusbarWindow
const CGHeroInstance * hero;
const IMarket * market;
std::shared_ptr<CAnimation> bars;
std::vector<std::shared_ptr<CItem>> items;
std::shared_ptr<CButton> cancel;