1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-10-31 00:07:39 +02:00

Most of rendering in BattleInt is done via canvas

- refactoring of CBattleStacksController.cpp
- moved EAlignment enum to Geometries.h from CIntObject
- renamed EAlignment to ETextAlignment, to avoid conflict with good/evil
alignemt
- ETextAlignment is now enum class
This commit is contained in:
Ivan Savenko
2022-11-26 23:12:20 +02:00
parent 4f91b062db
commit 0cae259f53
51 changed files with 450 additions and 447 deletions

View File

@@ -20,7 +20,7 @@ CreatureCostBox::CreatureCostBox(Rect position, std::string titleText)
type |= REDRAW_PARENT; type |= REDRAW_PARENT;
pos = position + pos; pos = position + pos;
title = std::make_shared<CLabel>(pos.w/2, 10, FONT_SMALL, CENTER, Colors::WHITE, titleText); title = std::make_shared<CLabel>(pos.w/2, 10, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, titleText);
} }
void CreatureCostBox::set(TResources res) void CreatureCostBox::set(TResources res)
@@ -39,7 +39,7 @@ void CreatureCostBox::createItems(TResources res)
while(iter.valid()) while(iter.valid())
{ {
ImagePtr image = std::make_shared<CAnimImage>("RESOURCE", iter->resType); ImagePtr image = std::make_shared<CAnimImage>("RESOURCE", iter->resType);
LabelPtr text = std::make_shared<CLabel>(15, 43, FONT_SMALL, CENTER, Colors::WHITE, "0"); LabelPtr text = std::make_shared<CLabel>(15, 43, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, "0");
resources.insert(std::make_pair(iter->resType, std::make_pair(text, image))); resources.insert(std::make_pair(iter->resType, std::make_pair(text, image)));
iter++; iter++;

View File

@@ -30,7 +30,7 @@ struct SDL_Surface;
struct SDL_Color; struct SDL_Color;
class CAnimation; class CAnimation;
enum EFonts enum EFonts : int
{ {
FONT_BIG, FONT_CALLI, FONT_CREDITS, FONT_HIGH_SCORE, FONT_MEDIUM, FONT_SMALL, FONT_TIMES, FONT_TINY, FONT_VERD FONT_BIG, FONT_CALLI, FONT_CREDITS, FONT_HIGH_SCORE, FONT_MEDIUM, FONT_SMALL, FONT_TIMES, FONT_TINY, FONT_VERD
}; };

View File

@@ -16,6 +16,7 @@
#include "CBattleInterfaceClasses.h" #include "CBattleInterfaceClasses.h"
#include "CBattleStacksController.h" #include "CBattleStacksController.h"
#include "../gui/CAnimation.h" #include "../gui/CAnimation.h"
#include "../gui/CCanvas.h"
#include "../CMusicHandler.h" #include "../CMusicHandler.h"
#include "../CGameInfo.h" #include "../CGameInfo.h"
#include "../CPlayerInterface.h" #include "../CPlayerInterface.h"
@@ -34,7 +35,7 @@ void CBattleEffectsController::displayEffect(EBattleEffect::EBattleEffect effect
{ {
std::string customAnim = graphics->battleACToDef[effect][0]; std::string customAnim = graphics->battleACToDef[effect][0];
owner->stacksController->addNewAnim(new CEffectAnimation(owner, customAnim, destTile)); owner->stacksController->addNewAnim(new CEffectAnimation(owner, customAnim, destTile));//FIXME: check positioning for double-hex creatures
} }
void CBattleEffectsController::displayEffect(EBattleEffect::EBattleEffect effect, uint32_t soundID, const BattleHex & destTile) void CBattleEffectsController::displayEffect(EBattleEffect::EBattleEffect effect, uint32_t soundID, const BattleHex & destTile)
@@ -98,21 +99,17 @@ void CBattleEffectsController::startAction(const BattleAction* action)
{ {
const CStack *stack = owner->curInt->cb->battleGetStackByID(action->stackNumber); const CStack *stack = owner->curInt->cb->battleGetStackByID(action->stackNumber);
int txtid = 0;
switch(action->actionType) switch(action->actionType)
{ {
case EActionType::WAIT: case EActionType::WAIT:
txtid = 136; owner->controlPanel->console->addText(stack->formatGeneralMessage(136));
break; break;
case EActionType::BAD_MORALE: case EActionType::BAD_MORALE:
txtid = -34; //negative -> no separate singular/plural form owner->controlPanel->console->addText(stack->formatGeneralMessage(-34));
displayEffect(EBattleEffect::BAD_MORALE, soundBase::BADMRLE, stack->getPosition()); displayEffect(EBattleEffect::BAD_MORALE, soundBase::BADMRLE, stack->getPosition());
break; break;
} }
if(txtid != 0)
owner->controlPanel->console->addText(stack->formatGeneralMessage(txtid));
//displaying special abilities //displaying special abilities
auto actionTarget = action->getTarget(owner->curInt->cb.get()); auto actionTarget = action->getTarget(owner->curInt->cb.get());
switch(action->actionType) switch(action->actionType)
@@ -123,7 +120,7 @@ void CBattleEffectsController::startAction(const BattleAction* action)
} }
} }
void CBattleEffectsController::showBattlefieldObjects(SDL_Surface *to, const BattleHex & destTile) void CBattleEffectsController::showBattlefieldObjects(std::shared_ptr<CCanvas> canvas, const BattleHex & destTile)
{ {
for (auto & elem : battleEffects) for (auto & elem : battleEffects)
{ {
@@ -138,8 +135,6 @@ void CBattleEffectsController::showBattlefieldObjects(SDL_Surface *to, const Bat
auto img = elem.animation->getImage(currentFrame); auto img = elem.animation->getImage(currentFrame);
SDL_Rect temp_rect = genRect(img->height(), img->width(), elem.x, elem.y); canvas->draw(img, Point(elem.x, elem.y));
img->draw(to, &temp_rect, nullptr);
} }
} }

View File

@@ -14,6 +14,7 @@
struct SDL_Surface; struct SDL_Surface;
class BattleAction; class BattleAction;
class CAnimation; class CAnimation;
class CCanvas;
class CBattleInterface; class CBattleInterface;
struct BattleObjectsByHex; struct BattleObjectsByHex;
struct CustomEffectInfo; struct CustomEffectInfo;
@@ -68,7 +69,7 @@ public:
void displayEffect(EBattleEffect::EBattleEffect effect, uint32_t soundID, const BattleHex & destTile); //displays custom effect on the battlefield void displayEffect(EBattleEffect::EBattleEffect effect, uint32_t soundID, const BattleHex & destTile); //displays custom effect on the battlefield
void battleTriggerEffect(const BattleTriggerEffect & bte); void battleTriggerEffect(const BattleTriggerEffect & bte);
void showBattlefieldObjects(SDL_Surface *to, const BattleHex & destTile); void showBattlefieldObjects(std::shared_ptr<CCanvas> canvas, const BattleHex & destTile);
friend class CEffectAnimation; // currently, battleEffects is largely managed by CEffectAnimation, TODO: move this logic into CBattleEffectsController friend class CEffectAnimation; // currently, battleEffects is largely managed by CEffectAnimation, TODO: move this logic into CBattleEffectsController

View File

@@ -72,17 +72,17 @@ CBattleFieldController::CBattleFieldController(CBattleInterface * owner):
} }
} }
void CBattleFieldController::showBackgroundImage(SDL_Surface *to) void CBattleFieldController::showBackgroundImage(std::shared_ptr<CCanvas> canvas)
{ {
background->draw(to, owner->pos.x, owner->pos.y); canvas->draw(background, owner->pos.topLeft());
if (settings["battle"]["cellBorders"].Bool()) if (settings["battle"]["cellBorders"].Bool())
cellBorders->copyTo(to, owner->pos.topLeft()); canvas->draw(cellBorders, owner->pos.topLeft());
} }
void CBattleFieldController::showBackgroundImageWithHexes(SDL_Surface *to) void CBattleFieldController::showBackgroundImageWithHexes(std::shared_ptr<CCanvas> canvas)
{ {
backgroundWithHexes->copyTo(to, owner->pos.topLeft()); canvas->draw(backgroundWithHexes, owner->pos.topLeft());
} }
void CBattleFieldController::redrawBackgroundWithHexes() void CBattleFieldController::redrawBackgroundWithHexes()
@@ -197,10 +197,8 @@ std::set<BattleHex> CBattleFieldController::getHighlightedHexesSpellRange()
return result; return result;
} }
void CBattleFieldController::showHighlightedHexes(SDL_Surface *to) void CBattleFieldController::showHighlightedHexes(std::shared_ptr<CCanvas> canvas)
{ {
auto canvas = std::make_shared<CCanvas>(to);
std::set<BattleHex> hoveredStack = getHighlightedHexesStackRange(); std::set<BattleHex> hoveredStack = getHighlightedHexesStackRange();
std::set<BattleHex> hoveredMouse = getHighlightedHexesSpellRange(); std::set<BattleHex> hoveredMouse = getHighlightedHexesSpellRange();

View File

@@ -51,12 +51,12 @@ class CBattleFieldController : public CIntObject
public: public:
CBattleFieldController(CBattleInterface * owner); CBattleFieldController(CBattleInterface * owner);
void showBackgroundImage(SDL_Surface *to); void showBackgroundImage(std::shared_ptr<CCanvas> canvas);
void showBackgroundImageWithHexes(SDL_Surface *to); void showBackgroundImageWithHexes(std::shared_ptr<CCanvas> canvas);
void redrawBackgroundWithHexes(); void redrawBackgroundWithHexes();
void showHighlightedHexes(SDL_Surface *to); void showHighlightedHexes(std::shared_ptr<CCanvas> canvas);
Rect hexPositionLocal(BattleHex hex) const; Rect hexPositionLocal(BattleHex hex) const;
Rect hexPosition(BattleHex hex) const; Rect hexPosition(BattleHex hex) const;

View File

@@ -933,16 +933,16 @@ void CBattleInterface::show(SDL_Surface *to)
if (stacksController->getActiveStack() != nullptr /*&& creAnims[stacksController->getActiveStack()->ID]->isIdle()*/) //show everything with range if (stacksController->getActiveStack() != nullptr /*&& creAnims[stacksController->getActiveStack()->ID]->isIdle()*/) //show everything with range
{ {
// FIXME: any *real* reason to keep this separate? Speed difference can't be that big // TODO: move to showAll? // FIXME: any *real* reason to keep this separate? Speed difference can't be that big // TODO: move to showAll?
fieldController->showBackgroundImageWithHexes(to); fieldController->showBackgroundImageWithHexes(canvas);
} }
else else
{ {
fieldController->showBackgroundImage(to); fieldController->showBackgroundImage(canvas);
obstacleController->showAbsoluteObstacles(to); obstacleController->showAbsoluteObstacles(canvas);
if ( siegeController ) if ( siegeController )
siegeController->showAbsoluteObstacles(to); siegeController->showAbsoluteObstacles(canvas);
} }
fieldController->showHighlightedHexes(to); fieldController->showHighlightedHexes(canvas);
showBattlefieldObjects(to); showBattlefieldObjects(to);
projectilesController->showProjectiles(canvas); projectilesController->showProjectiles(canvas);
@@ -959,36 +959,20 @@ void CBattleInterface::show(SDL_Surface *to)
activateStack(); activateStack();
} }
void CBattleInterface::showBattlefieldObjects(SDL_Surface *to, const BattleHex & location ) void CBattleInterface::showBattlefieldObjects(std::shared_ptr<CCanvas> canvas, const BattleHex & location )
{ {
if (siegeController) if (siegeController)
siegeController->showBattlefieldObjects(to, location); siegeController->showBattlefieldObjects(canvas, location);
obstacleController->showBattlefieldObjects(to, location); obstacleController->showBattlefieldObjects(canvas, location);
stacksController->showBattlefieldObjects(to, location); stacksController->showBattlefieldObjects(canvas, location);
effectsController->showBattlefieldObjects(to, location); effectsController->showBattlefieldObjects(canvas, location);
} }
void CBattleInterface::showBattlefieldObjects(SDL_Surface *to) void CBattleInterface::showBattlefieldObjects(SDL_Surface *to)
{ {
//auto showHexEntry = [&](BattleObjectsByHex::HexData & hex) auto canvas = std::make_shared<CCanvas>(to);
//{
// if (siegeController)
// siegeController->showPiecesOfWall(to, hex.walls);
// obstacleController->showObstacles(to, hex.obstacles);
// stacksController->showAliveStacks(to, hex.alive);
// effectsController->showBattleEffects(to, hex.effects);
//};
//BattleObjectsByHex objects = sortObjectsByHex(); showBattlefieldObjects(canvas, BattleHex::HEX_BEFORE_ALL);
// dead stacks should be blit first
//stacksController->showStacks(to, objects.beforeAll.dead);
//for (auto & data : objects.hex)
// stacksController->showStacks(to, data.dead);
//stacksController->showStacks(to, objects.afterAll.dead);
// display objects that must be blit before anything else (e.g. topmost walls)
//showHexEntry(objects.beforeAll);
// show heroes after "beforeAll" - e.g. topmost wall in siege // show heroes after "beforeAll" - e.g. topmost wall in siege
if (attackingHero) if (attackingHero)
@@ -996,13 +980,10 @@ void CBattleInterface::showBattlefieldObjects(SDL_Surface *to)
if (defendingHero) if (defendingHero)
defendingHero->show(to); defendingHero->show(to);
// actual blit of most of objects, hex by hex for (int i = 0; i < GameConstants::BFIELD_SIZE; ++i)
// NOTE: row-by-row blitting may be a better approach showBattlefieldObjects(canvas, BattleHex(i));
//for (auto &data : objects.hex)
// showHexEntry(data);
// objects that must be blit *after* everything else - e.g. bottom tower or some spell effects showBattlefieldObjects(canvas, BattleHex::HEX_AFTER_ALL);
//showHexEntry(objects.afterAll);
} }
void CBattleInterface::showInterface(SDL_Surface *to) void CBattleInterface::showInterface(SDL_Surface *to)

View File

@@ -34,18 +34,13 @@ struct CustomEffectInfo;
VCMI_LIB_NAMESPACE_END VCMI_LIB_NAMESPACE_END
//class CLabel;
//class CCallback;
//class CBattleAnimation;
class CBattleHero; class CBattleHero;
//class CBattleConsole; class CCanvas;
class CBattleResultWindow; class CBattleResultWindow;
class CStackQueue; class CStackQueue;
class CPlayerInterface; class CPlayerInterface;
//class CCreatureAnimation;
class CClickableHex; class CClickableHex;
class CAnimation; class CAnimation;
//class IImage;
struct BattleEffect; struct BattleEffect;
class CBattleProjectileController; class CBattleProjectileController;
@@ -106,7 +101,7 @@ private:
void showInterface(SDL_Surface *to); void showInterface(SDL_Surface *to);
void showBattlefieldObjects(SDL_Surface *to); void showBattlefieldObjects(SDL_Surface *to);
void showBattlefieldObjects(SDL_Surface *to, const BattleHex & location ); void showBattlefieldObjects(std::shared_ptr<CCanvas> canvas, const BattleHex & location );
void setHeroAnimation(ui8 side, int phase); void setHeroAnimation(ui8 side, int phase);
public: public:

View File

@@ -295,26 +295,26 @@ CHeroInfoWindow::CHeroInfoWindow(const InfoAboutHero & hero, Point * position)
icons.push_back(std::make_shared<CAnimImage>("PortraitsLarge", hero.portrait, 0, 10, 6)); icons.push_back(std::make_shared<CAnimImage>("PortraitsLarge", hero.portrait, 0, 10, 6));
//primary stats //primary stats
labels.push_back(std::make_shared<CLabel>(9, 75, EFonts::FONT_TINY, EAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[380] + ":")); labels.push_back(std::make_shared<CLabel>(9, 75, EFonts::FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[380] + ":"));
labels.push_back(std::make_shared<CLabel>(9, 87, EFonts::FONT_TINY, EAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[381] + ":")); labels.push_back(std::make_shared<CLabel>(9, 87, EFonts::FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[381] + ":"));
labels.push_back(std::make_shared<CLabel>(9, 99, EFonts::FONT_TINY, EAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[382] + ":")); labels.push_back(std::make_shared<CLabel>(9, 99, EFonts::FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[382] + ":"));
labels.push_back(std::make_shared<CLabel>(9, 111, EFonts::FONT_TINY, EAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[383] + ":")); labels.push_back(std::make_shared<CLabel>(9, 111, EFonts::FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[383] + ":"));
labels.push_back(std::make_shared<CLabel>(69, 87, EFonts::FONT_TINY, EAlignment::BOTTOMRIGHT, Colors::WHITE, std::to_string(attack))); labels.push_back(std::make_shared<CLabel>(69, 87, EFonts::FONT_TINY, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, std::to_string(attack)));
labels.push_back(std::make_shared<CLabel>(69, 99, EFonts::FONT_TINY, EAlignment::BOTTOMRIGHT, Colors::WHITE, std::to_string(defense))); labels.push_back(std::make_shared<CLabel>(69, 99, EFonts::FONT_TINY, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, std::to_string(defense)));
labels.push_back(std::make_shared<CLabel>(69, 111, EFonts::FONT_TINY, EAlignment::BOTTOMRIGHT, Colors::WHITE, std::to_string(power))); labels.push_back(std::make_shared<CLabel>(69, 111, EFonts::FONT_TINY, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, std::to_string(power)));
labels.push_back(std::make_shared<CLabel>(69, 123, EFonts::FONT_TINY, EAlignment::BOTTOMRIGHT, Colors::WHITE, std::to_string(knowledge))); labels.push_back(std::make_shared<CLabel>(69, 123, EFonts::FONT_TINY, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, std::to_string(knowledge)));
//morale+luck //morale+luck
labels.push_back(std::make_shared<CLabel>(9, 131, EFonts::FONT_TINY, EAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[384] + ":")); labels.push_back(std::make_shared<CLabel>(9, 131, EFonts::FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[384] + ":"));
labels.push_back(std::make_shared<CLabel>(9, 143, EFonts::FONT_TINY, EAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[385] + ":")); labels.push_back(std::make_shared<CLabel>(9, 143, EFonts::FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[385] + ":"));
icons.push_back(std::make_shared<CAnimImage>("IMRL22", morale + 3, 0, 47, 131)); icons.push_back(std::make_shared<CAnimImage>("IMRL22", morale + 3, 0, 47, 131));
icons.push_back(std::make_shared<CAnimImage>("ILCK22", luck + 3, 0, 47, 143)); icons.push_back(std::make_shared<CAnimImage>("ILCK22", luck + 3, 0, 47, 143));
//spell points //spell points
labels.push_back(std::make_shared<CLabel>(39, 174, EFonts::FONT_TINY, EAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[387])); labels.push_back(std::make_shared<CLabel>(39, 174, EFonts::FONT_TINY, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[387]));
labels.push_back(std::make_shared<CLabel>(39, 186, EFonts::FONT_TINY, EAlignment::CENTER, Colors::WHITE, std::to_string(currentSpellPoints) + "/" + std::to_string(maxSpellPoints))); labels.push_back(std::make_shared<CLabel>(39, 186, EFonts::FONT_TINY, ETextAlignment::CENTER, Colors::WHITE, std::to_string(currentSpellPoints) + "/" + std::to_string(maxSpellPoints)));
} }
CBattleOptionsWindow::CBattleOptionsWindow(const SDL_Rect & position, CBattleInterface *owner) CBattleOptionsWindow::CBattleOptionsWindow(const SDL_Rect & position, CBattleInterface *owner)
@@ -357,29 +357,29 @@ CBattleOptionsWindow::CBattleOptionsWindow(const SDL_Rect & position, CBattleInt
exit->setImageOrder(1, 0, 2, 3); exit->setImageOrder(1, 0, 2, 3);
//creating labels //creating labels
labels.push_back(std::make_shared<CLabel>(242, 32, FONT_BIG, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[392]));//window title labels.push_back(std::make_shared<CLabel>(242, 32, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[392]));//window title
labels.push_back(std::make_shared<CLabel>(122, 214, FONT_MEDIUM, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[393]));//animation speed labels.push_back(std::make_shared<CLabel>(122, 214, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[393]));//animation speed
labels.push_back(std::make_shared<CLabel>(122, 293, FONT_MEDIUM, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[394]));//music volume labels.push_back(std::make_shared<CLabel>(122, 293, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[394]));//music volume
labels.push_back(std::make_shared<CLabel>(122, 359, FONT_MEDIUM, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[395]));//effects' volume labels.push_back(std::make_shared<CLabel>(122, 359, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[395]));//effects' volume
labels.push_back(std::make_shared<CLabel>(353, 66, FONT_MEDIUM, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[396]));//auto - combat options labels.push_back(std::make_shared<CLabel>(353, 66, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[396]));//auto - combat options
labels.push_back(std::make_shared<CLabel>(353, 265, FONT_MEDIUM, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[397]));//creature info labels.push_back(std::make_shared<CLabel>(353, 265, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[397]));//creature info
//auto - combat options //auto - combat options
labels.push_back(std::make_shared<CLabel>(283, 86, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[398]));//creatures labels.push_back(std::make_shared<CLabel>(283, 86, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[398]));//creatures
labels.push_back(std::make_shared<CLabel>(283, 116, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[399]));//spells labels.push_back(std::make_shared<CLabel>(283, 116, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[399]));//spells
labels.push_back(std::make_shared<CLabel>(283, 146, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[400]));//catapult labels.push_back(std::make_shared<CLabel>(283, 146, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[400]));//catapult
labels.push_back(std::make_shared<CLabel>(283, 176, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[151]));//ballista labels.push_back(std::make_shared<CLabel>(283, 176, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[151]));//ballista
labels.push_back(std::make_shared<CLabel>(283, 206, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[401]));//first aid tent labels.push_back(std::make_shared<CLabel>(283, 206, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[401]));//first aid tent
//creature info //creature info
labels.push_back(std::make_shared<CLabel>(283, 285, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[402]));//all stats labels.push_back(std::make_shared<CLabel>(283, 285, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[402]));//all stats
labels.push_back(std::make_shared<CLabel>(283, 315, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[403]));//spells only labels.push_back(std::make_shared<CLabel>(283, 315, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[403]));//spells only
//general options //general options
labels.push_back(std::make_shared<CLabel>(61, 57, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[404])); labels.push_back(std::make_shared<CLabel>(61, 57, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[404]));
labels.push_back(std::make_shared<CLabel>(61, 90, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[405])); labels.push_back(std::make_shared<CLabel>(61, 90, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[405]));
labels.push_back(std::make_shared<CLabel>(61, 123, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[406])); labels.push_back(std::make_shared<CLabel>(61, 123, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[406]));
labels.push_back(std::make_shared<CLabel>(61, 156, FONT_MEDIUM, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[407])); labels.push_back(std::make_shared<CLabel>(61, 156, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[407]));
} }
void CBattleOptionsWindow::bDefaultf() void CBattleOptionsWindow::bDefaultf()
@@ -406,25 +406,25 @@ CBattleResultWindow::CBattleResultWindow(const BattleResult & br, CPlayerInterfa
if(br.winner == 0) //attacker won if(br.winner == 0) //attacker won
{ {
labels.push_back(std::make_shared<CLabel>(59, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[410])); labels.push_back(std::make_shared<CLabel>(59, 124, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[410]));
} }
else else
{ {
labels.push_back(std::make_shared<CLabel>(59, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[411])); labels.push_back(std::make_shared<CLabel>(59, 124, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[411]));
} }
if(br.winner == 1) if(br.winner == 1)
{ {
labels.push_back(std::make_shared<CLabel>(412, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[410])); labels.push_back(std::make_shared<CLabel>(412, 124, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[410]));
} }
else else
{ {
labels.push_back(std::make_shared<CLabel>(408, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[411])); labels.push_back(std::make_shared<CLabel>(408, 124, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[411]));
} }
labels.push_back(std::make_shared<CLabel>(232, 302, FONT_BIG, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[407])); labels.push_back(std::make_shared<CLabel>(232, 302, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[407]));
labels.push_back(std::make_shared<CLabel>(232, 332, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[408])); labels.push_back(std::make_shared<CLabel>(232, 332, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[408]));
labels.push_back(std::make_shared<CLabel>(232, 428, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[409])); labels.push_back(std::make_shared<CLabel>(232, 428, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[409]));
std::string sideNames[2] = {"N/A", "N/A"}; std::string sideNames[2] = {"N/A", "N/A"};
@@ -460,15 +460,15 @@ CBattleResultWindow::CBattleResultWindow(const BattleResult & br, CPlayerInterfa
} }
//printing attacker and defender's names //printing attacker and defender's names
labels.push_back(std::make_shared<CLabel>(89, 37, FONT_SMALL, TOPLEFT, Colors::WHITE, sideNames[0])); labels.push_back(std::make_shared<CLabel>(89, 37, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, sideNames[0]));
labels.push_back(std::make_shared<CLabel>(381, 53, FONT_SMALL, BOTTOMRIGHT, Colors::WHITE, sideNames[1])); labels.push_back(std::make_shared<CLabel>(381, 53, FONT_SMALL, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, sideNames[1]));
//printing casualties //printing casualties
for(int step = 0; step < 2; ++step) for(int step = 0; step < 2; ++step)
{ {
if(br.casualties[step].size()==0) if(br.casualties[step].size()==0)
{ {
labels.push_back(std::make_shared<CLabel>(235, 360 + 97 * step, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[523])); labels.push_back(std::make_shared<CLabel>(235, 360 + 97 * step, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[523]));
} }
else else
{ {
@@ -479,7 +479,7 @@ CBattleResultWindow::CBattleResultWindow(const BattleResult & br, CPlayerInterfa
icons.push_back(std::make_shared<CAnimImage>("CPRSMALL", CGI->creatures()->getByIndex(elem.first)->getIconIndex(), 0, xPos, yPos)); icons.push_back(std::make_shared<CAnimImage>("CPRSMALL", CGI->creatures()->getByIndex(elem.first)->getIconIndex(), 0, xPos, yPos));
std::ostringstream amount; std::ostringstream amount;
amount<<elem.second; amount<<elem.second;
labels.push_back(std::make_shared<CLabel>(xPos + 16, yPos + 42, FONT_SMALL, CENTER, Colors::WHITE, amount.str())); labels.push_back(std::make_shared<CLabel>(xPos + 16, yPos + 42, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, amount.str()));
xPos += 42; xPos += 42;
} }
} }
@@ -516,7 +516,7 @@ CBattleResultWindow::CBattleResultWindow(const BattleResult & br, CPlayerInterfa
boost::algorithm::replace_first(str, "%d", boost::lexical_cast<std::string>(br.exp[weAreAttacker ? 0 : 1])); boost::algorithm::replace_first(str, "%d", boost::lexical_cast<std::string>(br.exp[weAreAttacker ? 0 : 1]));
} }
description = std::make_shared<CTextBox>(str, Rect(69, 203, 330, 68), 0, FONT_SMALL, CENTER, Colors::WHITE); description = std::make_shared<CTextBox>(str, Rect(69, 203, 330, 68), 0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
} }
else // we lose else // we lose
{ {
@@ -544,7 +544,7 @@ CBattleResultWindow::CBattleResultWindow(const BattleResult & br, CPlayerInterfa
CCS->musich->playMusic(musicName, false, true); CCS->musich->playMusic(musicName, false, true);
CCS->videoh->open(videoName); CCS->videoh->open(videoName);
labels.push_back(std::make_shared<CLabel>(235, 235, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[text])); labels.push_back(std::make_shared<CLabel>(235, 235, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[text]));
} }
} }
@@ -747,12 +747,12 @@ CStackQueue::StackBox::StackBox(CStackQueue * owner)
if(owner->embedded) if(owner->embedded)
{ {
icon = std::make_shared<CAnimImage>(owner->icons, 0, 0, 5, 2); icon = std::make_shared<CAnimImage>(owner->icons, 0, 0, 5, 2);
amount = std::make_shared<CLabel>(pos.w/2, pos.h - 7, FONT_SMALL, CENTER, Colors::WHITE); amount = std::make_shared<CLabel>(pos.w/2, pos.h - 7, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
} }
else else
{ {
icon = std::make_shared<CAnimImage>(owner->icons, 0, 0, 9, 1); icon = std::make_shared<CAnimImage>(owner->icons, 0, 0, 9, 1);
amount = std::make_shared<CLabel>(pos.w/2, pos.h - 8, FONT_MEDIUM, CENTER, Colors::WHITE); amount = std::make_shared<CLabel>(pos.w/2, pos.h - 8, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE);
int icon_x = pos.w - 17; int icon_x = pos.w - 17;
int icon_y = pos.h - 18; int icon_y = pos.h - 18;

View File

@@ -109,7 +109,7 @@ void CBattleObstacleController::obstaclePlaced(const CObstacleInstance & oi)
//CCS->soundh->playSound(sound); //CCS->soundh->playSound(sound);
} }
void CBattleObstacleController::showAbsoluteObstacles(SDL_Surface * to) void CBattleObstacleController::showAbsoluteObstacles(std::shared_ptr<CCanvas> canvas)
{ {
//Blit absolute obstacles //Blit absolute obstacles
for(auto & oi : owner->curInt->cb->battleGetAllObstacles()) for(auto & oi : owner->curInt->cb->battleGetAllObstacles())
@@ -118,12 +118,12 @@ void CBattleObstacleController::showAbsoluteObstacles(SDL_Surface * to)
{ {
auto img = getObstacleImage(*oi); auto img = getObstacleImage(*oi);
if(img) if(img)
img->draw(to, owner->pos.x + oi->getInfo().width, owner->pos.y + oi->getInfo().height); canvas->draw(img, Point(owner->pos.x + oi->getInfo().width, owner->pos.y + oi->getInfo().height));
} }
} }
} }
void CBattleObstacleController::showBattlefieldObjects(SDL_Surface *to, const BattleHex & location ) void CBattleObstacleController::showBattlefieldObjects(std::shared_ptr<CCanvas> canvas, const BattleHex & location )
{ {
for (auto &obstacle : owner->curInt->cb->battleGetAllObstacles()) for (auto &obstacle : owner->curInt->cb->battleGetAllObstacles())
{ {
@@ -140,7 +140,7 @@ void CBattleObstacleController::showBattlefieldObjects(SDL_Surface *to, const Ba
if(img) if(img)
{ {
Point p = getObstaclePosition(img, *obstacle); Point p = getObstaclePosition(img, *obstacle);
img->draw(to, p.x, p.y); canvas->draw(img, p);
} }
} }
} }

View File

@@ -35,9 +35,9 @@ public:
void obstaclePlaced(const CObstacleInstance & oi); void obstaclePlaced(const CObstacleInstance & oi);
void showObstacles(SDL_Surface *to, std::vector<std::shared_ptr<const CObstacleInstance>> &obstacles); void showObstacles(SDL_Surface *to, std::vector<std::shared_ptr<const CObstacleInstance>> &obstacles);
void showAbsoluteObstacles(SDL_Surface *to); void showAbsoluteObstacles(std::shared_ptr<CCanvas> canvas);
void showBattlefieldObjects(SDL_Surface *to, const BattleHex & location ); void showBattlefieldObjects(std::shared_ptr<CCanvas> canvas, const BattleHex & location );
void redrawBackgroundWithHexes(std::shared_ptr<CCanvas> to); void redrawBackgroundWithHexes(std::shared_ptr<CCanvas> to);
}; };

View File

@@ -19,6 +19,7 @@
#include "../CGameInfo.h" #include "../CGameInfo.h"
#include "../CPlayerInterface.h" #include "../CPlayerInterface.h"
#include "../gui/CAnimation.h" #include "../gui/CAnimation.h"
#include "../gui/CCanvas.h"
#include "../../CCallback.h" #include "../../CCallback.h"
#include "../../lib/NetPacks.h" #include "../../lib/NetPacks.h"
@@ -103,12 +104,12 @@ std::string CBattleSiegeController::getWallPieceImageName(EWallVisual::EWallVisu
} }
} }
void CBattleSiegeController::showWallPiece(SDL_Surface *to, EWallVisual::EWallVisual what) void CBattleSiegeController::showWallPiece(std::shared_ptr<CCanvas> canvas, EWallVisual::EWallVisual what)
{ {
auto & ci = town->town->clientInfo; auto & ci = town->town->clientInfo;
auto const & pos = ci.siegePositions[what]; auto const & pos = ci.siegePositions[what];
wallPieceImages[what]->draw(to, pos.x + owner->pos.x, pos.y + owner->pos.y); canvas->draw(wallPieceImages[what], owner->pos.topLeft() + Point(pos.x, pos.y));
} }
std::string CBattleSiegeController::getBattleBackgroundName() const std::string CBattleSiegeController::getBattleBackgroundName() const
@@ -249,24 +250,16 @@ void CBattleSiegeController::gateStateChanged(const EGateState state)
CCS->soundh->playSound(soundBase::DRAWBRG); CCS->soundh->playSound(soundBase::DRAWBRG);
} }
void CBattleSiegeController::showAbsoluteObstacles(SDL_Surface * to) void CBattleSiegeController::showAbsoluteObstacles(std::shared_ptr<CCanvas> canvas)
{ {
auto & info = town->town->clientInfo;
if (getWallPieceExistance(EWallVisual::MOAT)) if (getWallPieceExistance(EWallVisual::MOAT))
{ showWallPiece(canvas, EWallVisual::MOAT);
auto const & pos = info.siegePositions[EWallVisual::MOAT];
wallPieceImages[EWallVisual::MOAT]->draw(to, pos.x + owner->pos.x, pos.y + owner->pos.y);
}
if (getWallPieceExistance(EWallVisual::BACKGROUND_MOAT)) if (getWallPieceExistance(EWallVisual::BACKGROUND_MOAT))
{ showWallPiece(canvas, EWallVisual::BACKGROUND_MOAT);
auto const & pos = info.siegePositions[EWallVisual::BACKGROUND_MOAT];
wallPieceImages[EWallVisual::BACKGROUND_MOAT]->draw(to, pos.x + owner->pos.x, pos.y + owner->pos.y);
}
} }
void CBattleSiegeController::showBattlefieldObjects(SDL_Surface *to, const BattleHex & location ) void CBattleSiegeController::showBattlefieldObjects(std::shared_ptr<CCanvas> canvas, const BattleHex & location )
{ {
for (int i = EWallVisual::WALL_FIRST; i <= EWallVisual::WALL_LAST; ++i) for (int i = EWallVisual::WALL_FIRST; i <= EWallVisual::WALL_LAST; ++i)
{ {
@@ -282,7 +275,7 @@ void CBattleSiegeController::showBattlefieldObjects(SDL_Surface *to, const Battl
wallPiece != EWallVisual::BOTTOM_BATTLEMENT && wallPiece != EWallVisual::BOTTOM_BATTLEMENT &&
wallPiece != EWallVisual::UPPER_BATTLEMENT) wallPiece != EWallVisual::UPPER_BATTLEMENT)
{ {
showWallPiece(to, wallPiece); showWallPiece(canvas, wallPiece);
continue; continue;
} }
@@ -314,8 +307,8 @@ void CBattleSiegeController::showBattlefieldObjects(SDL_Surface *to, const Battl
if (turret) if (turret)
{ {
owner->stacksController->showStack(to, turret); owner->stacksController->showStack(canvas, turret);
showWallPiece(to, wallPiece); showWallPiece(canvas, wallPiece);
} }
} }
} }

View File

@@ -15,6 +15,7 @@
struct CatapultAttack; struct CatapultAttack;
struct Point; struct Point;
struct SDL_Surface; struct SDL_Surface;
class CCanvas;
class CGTownInstance; class CGTownInstance;
class CBattleInterface; class CBattleInterface;
class CCreature; class CCreature;
@@ -77,7 +78,7 @@ class CBattleSiegeController
/// returns true if chosen wall piece should be present in current battle /// returns true if chosen wall piece should be present in current battle
bool getWallPieceExistance(EWallVisual::EWallVisual what) const; bool getWallPieceExistance(EWallVisual::EWallVisual what) const;
void showWallPiece(SDL_Surface *to, EWallVisual::EWallVisual what); void showWallPiece(std::shared_ptr<CCanvas> canvas, EWallVisual::EWallVisual what);
public: public:
CBattleSiegeController(CBattleInterface * owner, const CGTownInstance *siegeTown); CBattleSiegeController(CBattleInterface * owner, const CGTownInstance *siegeTown);
@@ -87,8 +88,8 @@ public:
void stackIsCatapulting(const CatapultAttack & ca); void stackIsCatapulting(const CatapultAttack & ca);
/// call-ins from other battle controllers /// call-ins from other battle controllers
void showAbsoluteObstacles(SDL_Surface * to); void showAbsoluteObstacles(std::shared_ptr<CCanvas> canvas);
void showBattlefieldObjects(SDL_Surface *to, const BattleHex & location ); void showBattlefieldObjects(std::shared_ptr<CCanvas> canvas, const BattleHex & location );
/// queries from other battle controllers /// queries from other battle controllers
bool isAttackableByCatapult(BattleHex hex) const; bool isAttackableByCatapult(BattleHex hex) const;

View File

@@ -20,6 +20,7 @@
#include "../gui/CAnimation.h" #include "../gui/CAnimation.h"
#include "../gui/SDL_Extensions.h" #include "../gui/SDL_Extensions.h"
#include "../gui/CGuiHandler.h" #include "../gui/CGuiHandler.h"
#include "../gui/CCanvas.h"
#include "../../lib/battle/BattleHex.h" #include "../../lib/battle/BattleHex.h"
#include "../CPlayerInterface.h" #include "../CPlayerInterface.h"
#include "CCreatureAnimation.h" #include "CCreatureAnimation.h"
@@ -82,7 +83,7 @@ CBattleStacksController::CBattleStacksController(CBattleInterface * owner):
} }
} }
void CBattleStacksController::showBattlefieldObjects(SDL_Surface *to, const BattleHex & location ) void CBattleStacksController::showBattlefieldObjects(std::shared_ptr<CCanvas> canvas, const BattleHex & location )
{ {
auto getCurrentPosition = [&](const CStack *stack) -> BattleHex auto getCurrentPosition = [&](const CStack *stack) -> BattleHex
{ {
@@ -260,7 +261,7 @@ bool CBattleStacksController::stackNeedsAmountBox(const CStack * stack)
for(auto anim : pendingAnims) //no matter what other conditions below are, hide box when creature is playing hit animation for(auto anim : pendingAnims) //no matter what other conditions below are, hide box when creature is playing hit animation
{ {
auto hitAnimation = dynamic_cast<CDefenceAnimation*>(anim.first); auto hitAnimation = dynamic_cast<CDefenceAnimation*>(anim.first);
if(hitAnimation && (hitAnimation->stack->ID == stack->ID)) //we process only "current creature" as other creatures will be processed reliably on their own iteration if(hitAnimation && (hitAnimation->stack->ID == stack->ID))
return false; return false;
} }
@@ -281,57 +282,58 @@ bool CBattleStacksController::stackNeedsAmountBox(const CStack * stack)
return true; return true;
} }
void CBattleStacksController::showStackAmountBox(SDL_Surface *to, const CStack * stack) std::shared_ptr<IImage> CBattleStacksController::getStackAmountBox(const CStack * stack)
{ {
auto getEffectsPositivness = [&](const std::vector<si32> & activeSpells) -> int std::vector<si32> activeSpells = stack->activeSpells();
{
int pos = 0;
for (const auto & spellId : activeSpells)
{
pos += CGI->spellh->objects.at(spellId)->positiveness;
}
return pos;
};
auto getAmountBoxBackground = [&](int positivness) -> auto if ( activeSpells.empty())
{ return amountNormal;
if (positivness > 0)
return amountPositive; int effectsPositivness = 0;
if (positivness < 0)
return amountNegative; for ( auto const & spellID : activeSpells)
return amountEffNeutral; effectsPositivness += CGI->spellh->objects.at(spellID)->positiveness;
};
if (effectsPositivness > 0)
return amountPositive;
if (effectsPositivness < 0)
return amountNegative;
return amountEffNeutral;
}
void CBattleStacksController::showStackAmountBox(std::shared_ptr<CCanvas> canvas, const CStack * stack)
{
//blitting amount background box
auto amountBG = getStackAmountBox(stack);
const int sideShift = stack->side == BattleSide::ATTACKER ? 1 : -1; const int sideShift = stack->side == BattleSide::ATTACKER ? 1 : -1;
const int reverseSideShift = stack->side == BattleSide::ATTACKER ? -1 : 1; const int reverseSideShift = stack->side == BattleSide::ATTACKER ? -1 : 1;
const BattleHex nextPos = stack->getPosition() + sideShift; const BattleHex nextPos = stack->getPosition() + sideShift;
const bool edge = stack->getPosition() % GameConstants::BFIELD_WIDTH == (stack->side == BattleSide::ATTACKER ? GameConstants::BFIELD_WIDTH - 2 : 1); const bool edge = stack->getPosition() % GameConstants::BFIELD_WIDTH == (stack->side == BattleSide::ATTACKER ? GameConstants::BFIELD_WIDTH - 2 : 1);
const bool moveInside = !edge && !owner->fieldController->stackCountOutsideHex(nextPos); const bool moveInside = !edge && !owner->fieldController->stackCountOutsideHex(nextPos);
int xAdd = (stack->side == BattleSide::ATTACKER ? 220 : 202) + int xAdd = (stack->side == BattleSide::ATTACKER ? 220 : 202) +
(stack->doubleWide() ? 44 : 0) * sideShift + (stack->doubleWide() ? 44 : 0) * sideShift +
(moveInside ? amountNormal->width() + 10 : 0) * reverseSideShift; (moveInside ? amountBG->width() + 10 : 0) * reverseSideShift;
int yAdd = 260 + ((stack->side == BattleSide::ATTACKER || moveInside) ? 0 : -15); int yAdd = 260 + ((stack->side == BattleSide::ATTACKER || moveInside) ? 0 : -15);
//blitting amount background box canvas->draw(amountBG, creAnims[stack->ID]->pos.topLeft() + Point(xAdd, yAdd));
std::vector<si32> activeSpells = stack->activeSpells();
auto amountBG = activeSpells.empty() ? amountNormal : getAmountBoxBackground(getEffectsPositivness(activeSpells));
amountBG->draw(to, creAnims[stack->ID]->pos.x + xAdd, creAnims[stack->ID]->pos.y + yAdd);
//blitting amount //blitting amount
Point textPos(creAnims[stack->ID]->pos.x + xAdd + amountNormal->width()/2, Point textPos = creAnims[stack->ID]->pos.topLeft() + amountBG->dimensions()/2 + Point(xAdd, yAdd);
creAnims[stack->ID]->pos.y + yAdd + amountNormal->height()/2);
graphics->fonts[FONT_TINY]->renderTextCenter(to, makeNumberShort(stack->getCount()), Colors::WHITE, textPos);
canvas->drawText(textPos, EFonts::FONT_TINY, Colors::WHITE, ETextAlignment::CENTER, makeNumberShort(stack->getCount()));
} }
void CBattleStacksController::showStack(SDL_Surface *to, const CStack * stack) void CBattleStacksController::showStack(std::shared_ptr<CCanvas> canvas, const CStack * stack)
{ {
creAnims[stack->ID]->nextFrame(to, facingRight(stack)); // do actual blit creAnims[stack->ID]->nextFrame(canvas, facingRight(stack)); // do actual blit
creAnims[stack->ID]->incrementFrame(float(GH.mainFPSmng->getElapsedMilliseconds()) / 1000); creAnims[stack->ID]->incrementFrame(float(GH.mainFPSmng->getElapsedMilliseconds()) / 1000);
if (stackNeedsAmountBox(stack)) if (stackNeedsAmountBox(stack))
showStackAmountBox(to, stack); showStackAmountBox(canvas, stack);
} }
void CBattleStacksController::updateBattleAnimations() void CBattleStacksController::updateBattleAnimations()
@@ -488,12 +490,10 @@ void CBattleStacksController::startAction(const BattleAction* action)
assert(stack); assert(stack);
owner->moveStarted = true; owner->moveStarted = true;
if (creAnims[action->stackNumber]->framesInGroup(CCreatureAnim::MOVE_START)) if (creAnims[action->stackNumber]->framesInGroup(CCreatureAnim::MOVE_START))
{ addNewAnim(new CMovementStartAnimation(owner, stack));
pendingAnims.push_back(std::make_pair(new CMovementStartAnimation(owner, stack), false));
}
if(shouldRotate(stack, stack->getPosition(), actionTarget.at(0).hexValue)) if(shouldRotate(stack, stack->getPosition(), actionTarget.at(0).hexValue))
pendingAnims.push_back(std::make_pair(new CReverseAnimation(owner, stack, stack->getPosition(), true), false)); addNewAnim(new CReverseAnimation(owner, stack, stack->getPosition(), true));
} }
} }

View File

@@ -15,6 +15,7 @@ struct BattleHex;
struct StackAttackedInfo; struct StackAttackedInfo;
struct BattleAction; struct BattleAction;
class CCanvas;
class SpellID; class SpellID;
class CBattleInterface; class CBattleInterface;
class CBattleAnimation; class CBattleAnimation;
@@ -47,7 +48,9 @@ class CBattleStacksController
ui32 animIDhelper; //for giving IDs for animations ui32 animIDhelper; //for giving IDs for animations
bool stackNeedsAmountBox(const CStack * stack); bool stackNeedsAmountBox(const CStack * stack);
void showStackAmountBox(SDL_Surface *to, const CStack * stack); void showStackAmountBox(std::shared_ptr<CCanvas> canvas, const CStack * stack);
std::shared_ptr<IImage> getStackAmountBox(const CStack * stack);
public: public:
CBattleStacksController(CBattleInterface * owner); CBattleStacksController(CBattleInterface * owner);
@@ -75,10 +78,10 @@ public:
void setHoveredStack(const CStack *stack); void setHoveredStack(const CStack *stack);
void setSelectedStack(const CStack *stack); void setSelectedStack(const CStack *stack);
void showAliveStack(SDL_Surface *to, const CStack * stack); void showAliveStack(std::shared_ptr<CCanvas> canvas, const CStack * stack);
void showStack(SDL_Surface *to, const CStack * stack); void showStack(std::shared_ptr<CCanvas> canvas, const CStack * stack);
void showBattlefieldObjects(SDL_Surface *to, const BattleHex & location ); void showBattlefieldObjects(std::shared_ptr<CCanvas> canvas, const BattleHex & location );
void addNewAnim(CBattleAnimation *anim); //adds new anim to pendingAnims void addNewAnim(CBattleAnimation *anim); //adds new anim to pendingAnims
void updateBattleAnimations(); void updateBattleAnimations();

View File

@@ -14,6 +14,7 @@
#include "../../lib/CCreatureHandler.h" #include "../../lib/CCreatureHandler.h"
#include "../gui/SDL_Extensions.h" #include "../gui/SDL_Extensions.h"
#include "../gui/CCanvas.h"
static const SDL_Color creatureBlueBorder = { 0, 255, 255, 255 }; static const SDL_Color creatureBlueBorder = { 0, 255, 255, 255 };
static const SDL_Color creatureGoldBorder = { 255, 255, 0, 255 }; static const SDL_Color creatureGoldBorder = { 255, 255, 0, 255 };
@@ -296,7 +297,7 @@ void CCreatureAnimation::genBorderPalette(IImage::BorderPallete & target)
target[2] = addColors(genShadow(64), genBorderColor(getBorderStrength(elapsedTime), border)); target[2] = addColors(genShadow(64), genBorderColor(getBorderStrength(elapsedTime), border));
} }
void CCreatureAnimation::nextFrame(SDL_Surface * dest, bool attacker) void CCreatureAnimation::nextFrame(std::shared_ptr<CCanvas> canvas, bool attacker)
{ {
size_t frame = static_cast<size_t>(floor(currentFrame)); size_t frame = static_cast<size_t>(floor(currentFrame));
@@ -314,7 +315,7 @@ void CCreatureAnimation::nextFrame(SDL_Surface * dest, bool attacker)
image->setBorderPallete(borderPallete); image->setBorderPallete(borderPallete);
image->draw(dest, pos.x, pos.y); canvas->draw(image, pos.topLeft());
} }
} }

View File

@@ -15,6 +15,7 @@
class CIntObject; class CIntObject;
class CCreatureAnimation; class CCreatureAnimation;
class CCanvas;
/// Namespace for some common controls of animations /// Namespace for some common controls of animations
namespace AnimationControls namespace AnimationControls
@@ -98,7 +99,7 @@ public:
void setType(CCreatureAnim::EAnimType type); //sets type of animation and cleares framecount void setType(CCreatureAnim::EAnimType type); //sets type of animation and cleares framecount
CCreatureAnim::EAnimType getType() const; //returns type of animation CCreatureAnim::EAnimType getType() const; //returns type of animation
void nextFrame(SDL_Surface * dest, bool attacker); void nextFrame(std::shared_ptr<CCanvas> canvas, bool attacker);
// should be called every frame, return true when animation was reset to beginning // should be called every frame, return true when animation was reset to beginning
bool incrementFrame(float timePassed); bool incrementFrame(float timePassed);

View File

@@ -14,6 +14,8 @@
#include "Geometries.h" #include "Geometries.h"
#include "CAnimation.h" #include "CAnimation.h"
#include "../Graphics.h"
CCanvas::CCanvas(SDL_Surface * surface): CCanvas::CCanvas(SDL_Surface * surface):
surface(surface) surface(surface)
{ {
@@ -37,7 +39,7 @@ void CCanvas::draw(std::shared_ptr<IImage> image, const Point & pos)
void CCanvas::draw(std::shared_ptr<CCanvas> image, const Point & pos) void CCanvas::draw(std::shared_ptr<CCanvas> image, const Point & pos)
{ {
image->copyTo(surface, pos); blitAt(image->surface, pos.x, pos.y, surface);
} }
void CCanvas::drawLine(const Point & from, const Point & dest, const SDL_Color & colorFrom, const SDL_Color & colorDest) void CCanvas::drawLine(const Point & from, const Point & dest, const SDL_Color & colorFrom, const SDL_Color & colorDest)
@@ -45,7 +47,28 @@ void CCanvas::drawLine(const Point & from, const Point & dest, const SDL_Color &
CSDL_Ext::drawLine(surface, from.x, from.y, dest.x, dest.y, colorFrom, colorDest); CSDL_Ext::drawLine(surface, from.x, from.y, dest.x, dest.y, colorFrom, colorDest);
} }
void CCanvas::copyTo(SDL_Surface * to, const Point & pos) void CCanvas::drawText(const Point & position, const EFonts & font, const SDL_Color & colorDest, ETextAlignment alignment, const std::string & text )
{ {
blitAt(to, pos.x, pos.y, surface); switch (alignment)
{
case ETextAlignment::TOPLEFT: return graphics->fonts[font]->renderTextLeft (surface, text, colorDest, position);
case ETextAlignment::CENTER: return graphics->fonts[font]->renderTextCenter(surface, text, colorDest, position);
case ETextAlignment::BOTTOMRIGHT: return graphics->fonts[font]->renderTextRight (surface, text, colorDest, position);
}
}
void CCanvas::drawText(const Point & position, const EFonts & font, const SDL_Color & colorDest, ETextAlignment alignment, const std::vector<std::string> & text )
{
switch (alignment)
{
case ETextAlignment::TOPLEFT: return graphics->fonts[font]->renderTextLinesLeft (surface, text, colorDest, position);
case ETextAlignment::CENTER: return graphics->fonts[font]->renderTextLinesCenter(surface, text, colorDest, position);
case ETextAlignment::BOTTOMRIGHT: return graphics->fonts[font]->renderTextLinesRight (surface, text, colorDest, position);
}
}
SDL_Surface * CCanvas::getSurface()
{
return surface;
} }

View File

@@ -9,31 +9,42 @@
*/ */
#pragma once #pragma once
#include "Geometries.h"
struct SDL_Color; struct SDL_Color;
struct SDL_Surface; struct SDL_Surface;
struct Point;
class IImage; class IImage;
enum EFonts : int;
/// Class that represents surface for drawing on /// Class that represents surface for drawing on
class CCanvas class CCanvas
{ {
SDL_Surface * surface; SDL_Surface * surface;
public: public:
// constructs canvas using existing surface. Caller maintains ownership on the surface
/// constructs canvas using existing surface. Caller maintains ownership on the surface
CCanvas(SDL_Surface * surface); CCanvas(SDL_Surface * surface);
/// constructs canvas of specified size
CCanvas(const Point & size); CCanvas(const Point & size);
~CCanvas(); ~CCanvas();
// renders image onto this canvas /// renders image onto this canvas
void draw(std::shared_ptr<IImage> image, const Point & pos); void draw(std::shared_ptr<IImage> image, const Point & pos);
// renders another canvas onto this canvas /// renders another canvas onto this canvas
void draw(std::shared_ptr<CCanvas> image, const Point & pos); void draw(std::shared_ptr<CCanvas> image, const Point & pos);
// renders continuous, 1-pixel wide line with color gradient /// renders continuous, 1-pixel wide line with color gradient
void drawLine(const Point & from, const Point & dest, const SDL_Color & colorFrom, const SDL_Color & colorDest); void drawLine(const Point & from, const Point & dest, const SDL_Color & colorFrom, const SDL_Color & colorDest);
// for compatibility, copies content of this canvas onto SDL_Surface /// renders single line of text with specified parameters
void copyTo(SDL_Surface * to, const Point & pos); void drawText(const Point & position, const EFonts & font, const SDL_Color & colorDest, ETextAlignment alignment, const std::string & text );
/// renders multiple lines of text with specified parameters
void drawText(const Point & position, const EFonts & font, const SDL_Color & colorDest, ETextAlignment alignment, const std::vector<std::string> & text );
/// for compatibility, returns pointer to internal SDL surface
SDL_Surface * getSurface();
}; };

View File

@@ -165,8 +165,6 @@ public:
//request complete redraw of this object //request complete redraw of this object
void redraw() override; void redraw() override;
enum EAlignment {TOPLEFT, CENTER, BOTTOMRIGHT};
bool isItInLoc(const SDL_Rect &rect, int x, int y); bool isItInLoc(const SDL_Rect &rect, int x, int y);
bool isItInLoc(const SDL_Rect &rect, const Point &p); bool isItInLoc(const SDL_Rect &rect, const Point &p);
const Rect & center(const Rect &r, bool propagate = true); //sets pos so that r will be in the center of screen, assigns sizes of r to pos, returns new position const Rect & center(const Rect &r, bool propagate = true); //sets pos so that r will be in the center of screen, assigns sizes of r to pos, returns new position

View File

@@ -12,6 +12,8 @@
#include <SDL_video.h> #include <SDL_video.h>
#include "../../lib/int3.h" #include "../../lib/int3.h"
enum class ETextAlignment {TOPLEFT, CENTER, BOTTOMRIGHT};
struct SDL_MouseMotionEvent; struct SDL_MouseMotionEvent;
// A point with x/y coordinate, used mostly for graphic rendering // A point with x/y coordinate, used mostly for graphic rendering

View File

@@ -75,25 +75,25 @@ CBonusSelection::CBonusSelection()
buttonRestart = std::make_shared<CButton>(Point(475, 536), "CBRESTB.DEF", CButton::tooltip(), std::bind(&CBonusSelection::restartMap, this), SDLK_RETURN); buttonRestart = std::make_shared<CButton>(Point(475, 536), "CBRESTB.DEF", CButton::tooltip(), std::bind(&CBonusSelection::restartMap, this), SDLK_RETURN);
buttonBack = std::make_shared<CButton>(Point(624, 536), "CBCANCB.DEF", CButton::tooltip(), std::bind(&CBonusSelection::goBack, this), SDLK_ESCAPE); buttonBack = std::make_shared<CButton>(Point(624, 536), "CBCANCB.DEF", CButton::tooltip(), std::bind(&CBonusSelection::goBack, this), SDLK_ESCAPE);
campaignName = std::make_shared<CLabel>(481, 28, FONT_BIG, EAlignment::TOPLEFT, Colors::YELLOW, CSH->si->getCampaignName()); campaignName = std::make_shared<CLabel>(481, 28, FONT_BIG, ETextAlignment::TOPLEFT, Colors::YELLOW, CSH->si->getCampaignName());
iconsMapSizes = std::make_shared<CAnimImage>("SCNRMPSZ", 4, 0, 735, 26); iconsMapSizes = std::make_shared<CAnimImage>("SCNRMPSZ", 4, 0, 735, 26);
labelCampaignDescription = std::make_shared<CLabel>(481, 63, FONT_SMALL, EAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[38]); labelCampaignDescription = std::make_shared<CLabel>(481, 63, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[38]);
campaignDescription = std::make_shared<CTextBox>(getCampaign()->camp->header.description, Rect(480, 86, 286, 117), 1); campaignDescription = std::make_shared<CTextBox>(getCampaign()->camp->header.description, Rect(480, 86, 286, 117), 1);
mapName = std::make_shared<CLabel>(481, 219, FONT_BIG, EAlignment::TOPLEFT, Colors::YELLOW, CSH->mi->getName()); mapName = std::make_shared<CLabel>(481, 219, FONT_BIG, ETextAlignment::TOPLEFT, Colors::YELLOW, CSH->mi->getName());
labelMapDescription = std::make_shared<CLabel>(481, 253, FONT_SMALL, EAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[496]); labelMapDescription = std::make_shared<CLabel>(481, 253, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[496]);
mapDescription = std::make_shared<CTextBox>("", Rect(480, 280, 286, 117), 1); mapDescription = std::make_shared<CTextBox>("", Rect(480, 280, 286, 117), 1);
labelChooseBonus = std::make_shared<CLabel>(511, 432, FONT_SMALL, EAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[71]); labelChooseBonus = std::make_shared<CLabel>(511, 432, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[71]);
groupBonuses = std::make_shared<CToggleGroup>(std::bind(&IServerAPI::setCampaignBonus, CSH, _1)); groupBonuses = std::make_shared<CToggleGroup>(std::bind(&IServerAPI::setCampaignBonus, CSH, _1));
flagbox = std::make_shared<CFlagBox>(Rect(486, 407, 335, 23)); flagbox = std::make_shared<CFlagBox>(Rect(486, 407, 335, 23));
std::vector<std::string> difficulty; std::vector<std::string> difficulty;
boost::split(difficulty, CGI->generaltexth->allTexts[492], boost::is_any_of(" ")); boost::split(difficulty, CGI->generaltexth->allTexts[492], boost::is_any_of(" "));
labelDifficulty = std::make_shared<CLabel>(689, 432, FONT_MEDIUM, EAlignment::TOPLEFT, Colors::WHITE, difficulty.back()); labelDifficulty = std::make_shared<CLabel>(689, 432, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, difficulty.back());
for(size_t b = 0; b < difficultyIcons.size(); ++b) for(size_t b = 0; b < difficultyIcons.size(); ++b)
{ {

View File

@@ -117,8 +117,8 @@ InfoCard::InfoCard()
pos.x += 393; pos.x += 393;
pos.y += 6; pos.y += 6;
labelSaveDate = std::make_shared<CLabel>(158, 19, FONT_SMALL, TOPLEFT, Colors::WHITE); labelSaveDate = std::make_shared<CLabel>(158, 19, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
mapName = std::make_shared<CLabel>(26, 39, FONT_BIG, TOPLEFT, Colors::YELLOW); mapName = std::make_shared<CLabel>(26, 39, FONT_BIG, ETextAlignment::TOPLEFT, Colors::YELLOW);
Rect descriptionRect(26, 149, 320, 115); Rect descriptionRect(26, 149, 320, 115);
mapDescription = std::make_shared<CTextBox>("", descriptionRect, 1); mapDescription = std::make_shared<CTextBox>("", descriptionRect, 1);
playerListBg = std::make_shared<CPicture>("CHATPLUG.bmp", 16, 276); playerListBg = std::make_shared<CPicture>("CHATPLUG.bmp", 16, 276);
@@ -126,7 +126,7 @@ InfoCard::InfoCard()
if(SEL->screenType == ESelectionScreen::campaignList) if(SEL->screenType == ESelectionScreen::campaignList)
{ {
labelCampaignDescription = std::make_shared<CLabel>(26, 132, FONT_SMALL, TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[38]); labelCampaignDescription = std::make_shared<CLabel>(26, 132, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[38]);
} }
else else
{ {
@@ -154,24 +154,24 @@ InfoCard::InfoCard()
} }
flagbox = std::make_shared<CFlagBox>(Rect(24, 400, 335, 23)); flagbox = std::make_shared<CFlagBox>(Rect(24, 400, 335, 23));
labelMapDiff = std::make_shared<CLabel>(33, 430, FONT_SMALL, TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[494]); labelMapDiff = std::make_shared<CLabel>(33, 430, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[494]);
labelPlayerDifficulty = std::make_shared<CLabel>(133, 430, FONT_SMALL, TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[492] + ":"); labelPlayerDifficulty = std::make_shared<CLabel>(133, 430, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[492] + ":");
labelRating = std::make_shared<CLabel>(290, 430, FONT_SMALL, TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[218] + ":"); labelRating = std::make_shared<CLabel>(290, 430, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[218] + ":");
labelScenarioName = std::make_shared<CLabel>(26, 22, FONT_SMALL, TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[495]); labelScenarioName = std::make_shared<CLabel>(26, 22, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[495]);
labelScenarioDescription = std::make_shared<CLabel>(26, 132, FONT_SMALL, TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[496]); labelScenarioDescription = std::make_shared<CLabel>(26, 132, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[496]);
labelVictoryCondition = std::make_shared<CLabel>(26, 283, FONT_SMALL, TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[497]); labelVictoryCondition = std::make_shared<CLabel>(26, 283, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[497]);
labelLossCondition = std::make_shared<CLabel>(26, 339, FONT_SMALL, TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[498]); labelLossCondition = std::make_shared<CLabel>(26, 339, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[498]);
iconsVictoryCondition = std::make_shared<CAnimImage>("SCNRVICT", 0, 0, 24, 302); iconsVictoryCondition = std::make_shared<CAnimImage>("SCNRVICT", 0, 0, 24, 302);
iconsLossCondition = std::make_shared<CAnimImage>("SCNRLOSS", 0, 0, 24, 359); iconsLossCondition = std::make_shared<CAnimImage>("SCNRLOSS", 0, 0, 24, 359);
labelVictoryConditionText = std::make_shared<CLabel>(60, 307, FONT_SMALL, TOPLEFT, Colors::WHITE); labelVictoryConditionText = std::make_shared<CLabel>(60, 307, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
labelLossConditionText = std::make_shared<CLabel>(60, 366, FONT_SMALL, TOPLEFT, Colors::WHITE); labelLossConditionText = std::make_shared<CLabel>(60, 366, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
labelDifficulty = std::make_shared<CLabel>(62, 472, FONT_SMALL, CENTER, Colors::WHITE); labelDifficulty = std::make_shared<CLabel>(62, 472, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
labelDifficultyPercent = std::make_shared<CLabel>(311, 472, FONT_SMALL, CENTER, Colors::WHITE); labelDifficultyPercent = std::make_shared<CLabel>(311, 472, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
labelGroupPlayersAssigned = std::make_shared<CLabelGroup>(FONT_SMALL, TOPLEFT, Colors::WHITE); labelGroupPlayersAssigned = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
labelGroupPlayersUnassigned = std::make_shared<CLabelGroup>(FONT_SMALL, TOPLEFT, Colors::WHITE); labelGroupPlayersUnassigned = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
disableLabelRedraws(); disableLabelRedraws();
} }
setChat(false); setChat(false);
@@ -219,8 +219,8 @@ void InfoCard::changeSelection()
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
// FIXME: We recreate them each time because CLabelGroup don't use smart pointers // FIXME: We recreate them each time because CLabelGroup don't use smart pointers
labelGroupPlayersAssigned = std::make_shared<CLabelGroup>(FONT_SMALL, TOPLEFT, Colors::WHITE); labelGroupPlayersAssigned = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
labelGroupPlayersUnassigned = std::make_shared<CLabelGroup>(FONT_SMALL, TOPLEFT, Colors::WHITE); labelGroupPlayersUnassigned = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
if(!showChat) if(!showChat)
{ {
labelGroupPlayersAssigned->disable(); labelGroupPlayersAssigned->disable();
@@ -346,8 +346,8 @@ CFlagBox::CFlagBox(const Rect & rect)
pos.h = rect.h; pos.h = rect.h;
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
labelAllies = std::make_shared<CLabel>(0, 0, FONT_SMALL, EAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[390] + ":"); 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, EAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[391] + ":"); labelEnemies = std::make_shared<CLabel>(133, 0, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[391] + ":");
iconsTeamFlags = std::make_shared<CAnimation>("ITGFLAGS.DEF"); iconsTeamFlags = std::make_shared<CAnimation>("ITGFLAGS.DEF");
iconsTeamFlags->preload(); iconsTeamFlags->preload();
@@ -389,8 +389,8 @@ CFlagBox::CFlagBoxTooltipBox::CFlagBoxTooltipBox(std::shared_ptr<CAnimation> ico
pos.w = 256; pos.w = 256;
pos.h = 90 + 50 * SEL->getMapInfo()->mapHeader->howManyTeams; pos.h = 90 + 50 * SEL->getMapInfo()->mapHeader->howManyTeams;
labelTeamAlignment = std::make_shared<CLabel>(128, 30, FONT_MEDIUM, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[657]); labelTeamAlignment = std::make_shared<CLabel>(128, 30, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[657]);
labelGroupTeams = std::make_shared<CLabelGroup>(FONT_SMALL, EAlignment::CENTER, Colors::WHITE); labelGroupTeams = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
for(int i = 0; i < SEL->getMapInfo()->mapHeader->howManyTeams; i++) for(int i = 0; i < SEL->getMapInfo()->mapHeader->howManyTeams; i++)
{ {
std::vector<ui8> flags; std::vector<ui8> flags;

View File

@@ -38,18 +38,18 @@ OptionsTab::OptionsTab() : humanPlayers(0)
OBJ_CONSTRUCTION; OBJ_CONSTRUCTION;
background = std::make_shared<CPicture>("ADVOPTBK", 0, 6); background = std::make_shared<CPicture>("ADVOPTBK", 0, 6);
pos = background->pos; pos = background->pos;
labelTitle = std::make_shared<CLabel>(222, 30, FONT_BIG, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[515]); labelTitle = std::make_shared<CLabel>(222, 30, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[515]);
labelSubTitle = std::make_shared<CMultiLineLabel>(Rect(60, 44, 320, (int)graphics->fonts[EFonts::FONT_SMALL]->getLineHeight()*2), EFonts::FONT_SMALL, EAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[516]); labelSubTitle = std::make_shared<CMultiLineLabel>(Rect(60, 44, 320, (int)graphics->fonts[EFonts::FONT_SMALL]->getLineHeight()*2), EFonts::FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[516]);
labelPlayerNameAndHandicap = std::make_shared<CMultiLineLabel>(Rect(58, 86, 100, (int)graphics->fonts[EFonts::FONT_SMALL]->getLineHeight()*2), EFonts::FONT_SMALL, EAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[517]); labelPlayerNameAndHandicap = std::make_shared<CMultiLineLabel>(Rect(58, 86, 100, (int)graphics->fonts[EFonts::FONT_SMALL]->getLineHeight()*2), EFonts::FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[517]);
labelStartingTown = std::make_shared<CMultiLineLabel>(Rect(163, 86, 70, (int)graphics->fonts[EFonts::FONT_SMALL]->getLineHeight()*2), EFonts::FONT_SMALL, EAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[518]); labelStartingTown = std::make_shared<CMultiLineLabel>(Rect(163, 86, 70, (int)graphics->fonts[EFonts::FONT_SMALL]->getLineHeight()*2), EFonts::FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[518]);
labelStartingHero = std::make_shared<CMultiLineLabel>(Rect(239, 86, 70, (int)graphics->fonts[EFonts::FONT_SMALL]->getLineHeight()*2), EFonts::FONT_SMALL, EAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[519]); labelStartingHero = std::make_shared<CMultiLineLabel>(Rect(239, 86, 70, (int)graphics->fonts[EFonts::FONT_SMALL]->getLineHeight()*2), EFonts::FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[519]);
labelStartingBonus = std::make_shared<CMultiLineLabel>(Rect(315, 86, 70, (int)graphics->fonts[EFonts::FONT_SMALL]->getLineHeight()*2), EFonts::FONT_SMALL, EAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[520]); labelStartingBonus = std::make_shared<CMultiLineLabel>(Rect(315, 86, 70, (int)graphics->fonts[EFonts::FONT_SMALL]->getLineHeight()*2), EFonts::FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[520]);
if(SEL->screenType == ESelectionScreen::newGame || SEL->screenType == ESelectionScreen::loadGame || SEL->screenType == ESelectionScreen::scenarioInfo) if(SEL->screenType == ESelectionScreen::newGame || SEL->screenType == ESelectionScreen::loadGame || SEL->screenType == ESelectionScreen::scenarioInfo)
{ {
sliderTurnDuration = std::make_shared<CSlider>(Point(55, 551), 194, std::bind(&IServerAPI::setTurnLength, CSH, _1), 1, (int)GameConstants::POSSIBLE_TURNTIME.size(), (int)GameConstants::POSSIBLE_TURNTIME.size(), true, CSlider::BLUE); sliderTurnDuration = std::make_shared<CSlider>(Point(55, 551), 194, std::bind(&IServerAPI::setTurnLength, CSH, _1), 1, (int)GameConstants::POSSIBLE_TURNTIME.size(), (int)GameConstants::POSSIBLE_TURNTIME.size(), true, CSlider::BLUE);
labelPlayerTurnDuration = std::make_shared<CLabel>(222, 538, FONT_SMALL, EAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[521]); labelPlayerTurnDuration = std::make_shared<CLabel>(222, 538, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[521]);
labelTurnDurationValue = std::make_shared<CLabel>(319, 559, FONT_SMALL, EAlignment::CENTER, Colors::WHITE); labelTurnDurationValue = std::make_shared<CLabel>(319, 559, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
} }
} }
@@ -368,8 +368,8 @@ void OptionsTab::CPlayerOptionTooltipBox::genHeader()
backgroundTexture = std::make_shared<CFilledTexture>("DIBOXBCK", pos); backgroundTexture = std::make_shared<CFilledTexture>("DIBOXBCK", pos);
updateShadow(); updateShadow();
labelTitle = std::make_shared<CLabel>(pos.w / 2 + 8, 21, FONT_MEDIUM, CENTER, Colors::YELLOW, getTitle()); labelTitle = std::make_shared<CLabel>(pos.w / 2 + 8, 21, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, getTitle());
labelSubTitle = std::make_shared<CLabel>(pos.w / 2, 88, FONT_SMALL, CENTER, Colors::WHITE, getSubtitle()); labelSubTitle = std::make_shared<CLabel>(pos.w / 2, 88, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, getSubtitle());
image = std::make_shared<CAnimImage>(getImageName(), getImageIndex(), 0, pos.w / 2 - 24, 45); image = std::make_shared<CAnimImage>(getImageName(), getImageIndex(), 0, pos.w / 2 - 24, 45);
} }
@@ -377,7 +377,7 @@ void OptionsTab::CPlayerOptionTooltipBox::genTownWindow()
{ {
pos = Rect(0, 0, 228, 290); pos = Rect(0, 0, 228, 290);
genHeader(); genHeader();
labelAssociatedCreatures = std::make_shared<CLabel>(pos.w / 2 + 8, 122, FONT_MEDIUM, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[79]); labelAssociatedCreatures = std::make_shared<CLabel>(pos.w / 2 + 8, 122, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[79]);
auto factionIndex = settings.castle >= CGI->townh->size() ? 0 : settings.castle; auto factionIndex = settings.castle >= CGI->townh->size() ? 0 : settings.castle;
std::vector<std::shared_ptr<CComponent>> components; std::vector<std::shared_ptr<CComponent>> components;
const CTown * town = (*CGI->townh)[factionIndex]->town; const CTown * town = (*CGI->townh)[factionIndex]->town;
@@ -394,11 +394,11 @@ void OptionsTab::CPlayerOptionTooltipBox::genHeroWindow()
{ {
pos = Rect(0, 0, 292, 226); pos = Rect(0, 0, 292, 226);
genHeader(); genHeader();
labelHeroSpeciality = std::make_shared<CLabel>(pos.w / 2 + 4, 117, FONT_MEDIUM, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[78]); labelHeroSpeciality = std::make_shared<CLabel>(pos.w / 2 + 4, 117, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[78]);
auto heroIndex = settings.hero >= CGI->heroh->size() ? 0 : settings.hero; auto heroIndex = settings.hero >= CGI->heroh->size() ? 0 : settings.hero;
imageSpeciality = std::make_shared<CAnimImage>("UN44", (*CGI->heroh)[heroIndex]->imageIndex, 0, pos.w / 2 - 22, 134); imageSpeciality = std::make_shared<CAnimImage>("UN44", (*CGI->heroh)[heroIndex]->imageIndex, 0, pos.w / 2 - 22, 134);
labelSpecialityName = std::make_shared<CLabel>(pos.w / 2, 188, FONT_SMALL, CENTER, Colors::WHITE, (*CGI->heroh)[heroIndex]->specName); labelSpecialityName = std::make_shared<CLabel>(pos.w / 2, 188, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, (*CGI->heroh)[heroIndex]->specName);
} }
void OptionsTab::CPlayerOptionTooltipBox::genBonusWindow() void OptionsTab::CPlayerOptionTooltipBox::genBonusWindow()
@@ -406,7 +406,7 @@ void OptionsTab::CPlayerOptionTooltipBox::genBonusWindow()
pos = Rect(0, 0, 228, 162); pos = Rect(0, 0, 228, 162);
genHeader(); genHeader();
textBonusDescription = std::make_shared<CTextBox>(getDescription(), Rect(10, 100, pos.w - 20, 70), 0, FONT_SMALL, CENTER, Colors::WHITE); textBonusDescription = std::make_shared<CTextBox>(getDescription(), Rect(10, 100, pos.w - 20, 70), 0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
} }
OptionsTab::SelectedBox::SelectedBox(Point position, PlayerSettings & settings, SelType type) OptionsTab::SelectedBox::SelectedBox(Point position, PlayerSettings & settings, SelType type)
@@ -415,7 +415,7 @@ OptionsTab::SelectedBox::SelectedBox(Point position, PlayerSettings & settings,
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
image = std::make_shared<CAnimImage>(getImageName(), getImageIndex()); image = std::make_shared<CAnimImage>(getImageName(), getImageIndex());
subtitle = std::make_shared<CLabel>(23, 39, FONT_TINY, CENTER, Colors::WHITE, getName()); subtitle = std::make_shared<CLabel>(23, 39, FONT_TINY, ETextAlignment::CENTER, Colors::WHITE, getName());
pos = image->pos; pos = image->pos;
} }
@@ -479,8 +479,8 @@ OptionsTab::PlayerOptionsEntry::PlayerOptionsEntry(const PlayerSettings & S, con
}; };
background = std::make_shared<CPicture>(bgs[s.color.getNum()], 0, 0); background = std::make_shared<CPicture>(bgs[s.color.getNum()], 0, 0);
labelPlayerName = std::make_shared<CLabel>(55, 10, EFonts::FONT_SMALL, EAlignment::CENTER, Colors::WHITE, s.name); labelPlayerName = std::make_shared<CLabel>(55, 10, EFonts::FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, s.name);
labelWhoCanPlay = std::make_shared<CMultiLineLabel>(Rect(6, 23, 45, (int)graphics->fonts[EFonts::FONT_TINY]->getLineHeight()*2), EFonts::FONT_TINY, EAlignment::CENTER, Colors::WHITE, CGI->generaltexth->arraytxt[206 + whoCanPlay]); labelWhoCanPlay = std::make_shared<CMultiLineLabel>(Rect(6, 23, 45, (int)graphics->fonts[EFonts::FONT_TINY]->getLineHeight()*2), EFonts::FONT_TINY, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->arraytxt[206 + whoCanPlay]);
if(SEL->screenType == ESelectionScreen::newGame) if(SEL->screenType == ESelectionScreen::newGame)
{ {

View File

@@ -35,10 +35,10 @@ RandomMapTab::RandomMapTab()
OBJ_CONSTRUCTION; OBJ_CONSTRUCTION;
background = std::make_shared<CPicture>("RANMAPBK", 0, 6); background = std::make_shared<CPicture>("RANMAPBK", 0, 6);
labelHeadlineBig = std::make_shared<CLabel>(222, 36, FONT_BIG, EAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[738]); labelHeadlineBig = std::make_shared<CLabel>(222, 36, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[738]);
labelHeadlineSmall = std::make_shared<CLabel>(222, 56, FONT_SMALL, EAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[739]); labelHeadlineSmall = std::make_shared<CLabel>(222, 56, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[739]);
labelMapSize = std::make_shared<CLabel>(104, 97, FONT_SMALL, EAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[752]); labelMapSize = std::make_shared<CLabel>(104, 97, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[752]);
groupMapSize = std::make_shared<CToggleGroup>(0); groupMapSize = std::make_shared<CToggleGroup>(0);
groupMapSize->pos.y += 81; groupMapSize->pos.y += 81;
groupMapSize->pos.x += 158; groupMapSize->pos.x += 158;
@@ -61,7 +61,7 @@ RandomMapTab::RandomMapTab()
updateMapInfoByHost(); updateMapInfoByHost();
}); });
labelGroupForOptions = std::make_shared<CLabelGroup>(FONT_SMALL, EAlignment::TOPLEFT, Colors::WHITE); labelGroupForOptions = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
// Create number defs list // Create number defs list
std::vector<std::string> numberDefs; std::vector<std::string> numberDefs;
for(int i = 0; i <= 8; ++i) for(int i = 0; i <= 8; ++i)

View File

@@ -141,7 +141,7 @@ SelectionTab::SelectionTab(ESelectionScreen Type)
pos = background->pos; pos = background->pos;
inputName = std::make_shared<CTextInput>(inputNameRect, Point(-32, -25), "GSSTRIP.bmp", 0); inputName = std::make_shared<CTextInput>(inputNameRect, Point(-32, -25), "GSSTRIP.bmp", 0);
inputName->filters += CTextInput::filenameFilter; inputName->filters += CTextInput::filenameFilter;
labelMapSizes = std::make_shared<CLabel>(87, 62, FONT_SMALL, EAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[510]); labelMapSizes = std::make_shared<CLabel>(87, 62, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[510]);
int sizes[] = {36, 72, 108, 144, 0}; int sizes[] = {36, 72, 108, 144, 0};
const char * filterIconNmes[] = {"SCSMBUT.DEF", "SCMDBUT.DEF", "SCLGBUT.DEF", "SCXLBUT.DEF", "SCALBUT.DEF"}; const char * filterIconNmes[] = {"SCSMBUT.DEF", "SCMDBUT.DEF", "SCLGBUT.DEF", "SCXLBUT.DEF", "SCALBUT.DEF"};
@@ -199,7 +199,7 @@ SelectionTab::SelectionTab(ESelectionScreen Type)
for(int i = 0; i < positionsToShow; i++) for(int i = 0; i < positionsToShow; i++)
listItems.push_back(std::make_shared<ListItem>(Point(30, 129 + i * 25), iconsMapFormats, iconsVictoryCondition, iconsLossCondition)); listItems.push_back(std::make_shared<ListItem>(Point(30, 129 + i * 25), iconsMapFormats, iconsVictoryCondition, iconsLossCondition));
labelTabTitle = std::make_shared<CLabel>(205, 28, FONT_MEDIUM, EAlignment::CENTER, Colors::YELLOW, tabTitle); labelTabTitle = std::make_shared<CLabel>(205, 28, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, tabTitle);
slider = std::make_shared<CSlider>(Point(372, 86), tabType != ESelectionScreen::saveGame ? 480 : 430, std::bind(&SelectionTab::sliderMove, this, _1), positionsToShow, (int)curItems.size(), 0, false, CSlider::BLUE); slider = std::make_shared<CSlider>(Point(372, 86), tabType != ESelectionScreen::saveGame ? 480 : 430, std::bind(&SelectionTab::sliderMove, this, _1), positionsToShow, (int)curItems.size(), 0, false, CSlider::BLUE);
filter(0); filter(0);
} }
@@ -622,13 +622,13 @@ SelectionTab::ListItem::ListItem(Point position, std::shared_ptr<CAnimation> ico
: CIntObject(LCLICK, position) : CIntObject(LCLICK, position)
{ {
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
labelName = std::make_shared<CLabel>(184, 0, FONT_SMALL, EAlignment::CENTER, Colors::WHITE); labelName = std::make_shared<CLabel>(184, 0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
labelName->setAutoRedraw(false); labelName->setAutoRedraw(false);
labelAmountOfPlayers = std::make_shared<CLabel>(8, 0, FONT_SMALL, EAlignment::CENTER, Colors::WHITE); labelAmountOfPlayers = std::make_shared<CLabel>(8, 0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
labelAmountOfPlayers->setAutoRedraw(false); labelAmountOfPlayers->setAutoRedraw(false);
labelNumberOfCampaignMaps = std::make_shared<CLabel>(8, 0, FONT_SMALL, EAlignment::CENTER, Colors::WHITE); labelNumberOfCampaignMaps = std::make_shared<CLabel>(8, 0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
labelNumberOfCampaignMaps->setAutoRedraw(false); labelNumberOfCampaignMaps->setAutoRedraw(false);
labelMapSizeLetter = std::make_shared<CLabel>(41, 0, FONT_SMALL, EAlignment::CENTER, Colors::WHITE); labelMapSizeLetter = std::make_shared<CLabel>(41, 0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
labelMapSizeLetter->setAutoRedraw(false); labelMapSizeLetter->setAutoRedraw(false);
// FIXME: This -12 should not be needed, but for some reason CAnimImage displaced otherwise // FIXME: This -12 should not be needed, but for some reason CAnimImage displaced otherwise
iconFormat = std::make_shared<CAnimImage>(iconsFormats, 0, 0, 59, -12); iconFormat = std::make_shared<CAnimImage>(iconsFormats, 0, 0, 59, -12);

View File

@@ -104,7 +104,7 @@ CCampaignScreen::CCampaignButton::CCampaignButton(const JsonNode & config)
addUsedEvents(LCLICK | HOVER); addUsedEvents(LCLICK | HOVER);
graphicsImage = std::make_shared<CPicture>(config["image"].String()); graphicsImage = std::make_shared<CPicture>(config["image"].String());
hoverLabel = std::make_shared<CLabel>(pos.w / 2, pos.h + 20, FONT_MEDIUM, CENTER, Colors::YELLOW, ""); hoverLabel = std::make_shared<CLabel>(pos.w / 2, pos.h + 20, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, "");
parent->addChild(hoverLabel.get()); parent->addChild(hoverLabel.get());
} }

View File

@@ -414,7 +414,7 @@ CMultiPlayers::CMultiPlayers(const std::string & firstPlayer, ESelectionScreen S
std::string text = CGI->generaltexth->allTexts[446]; std::string text = CGI->generaltexth->allTexts[446];
boost::replace_all(text, "\t", "\n"); boost::replace_all(text, "\t", "\n");
textTitle = std::make_shared<CTextBox>(text, Rect(25, 20, 315, 50), 0, FONT_BIG, CENTER, Colors::WHITE); //HOTSEAT Please enter names textTitle = std::make_shared<CTextBox>(text, Rect(25, 20, 315, 50), 0, FONT_BIG, ETextAlignment::CENTER, Colors::WHITE); //HOTSEAT Please enter names
for(int i = 0; i < inputNames.size(); i++) for(int i = 0; i < inputNames.size(); i++)
{ {
@@ -462,7 +462,7 @@ CSimpleJoinScreen::CSimpleJoinScreen(bool host)
background = std::make_shared<CPicture>("MUDIALOG.bmp"); // address background background = std::make_shared<CPicture>("MUDIALOG.bmp"); // address background
pos = background->center(); //center, window has size of bg graphic (x,y = 396,278 w=232 h=212) pos = background->center(); //center, window has size of bg graphic (x,y = 396,278 w=232 h=212)
textTitle = std::make_shared<CTextBox>("", Rect(20, 20, 205, 50), 0, FONT_BIG, CENTER, Colors::WHITE); textTitle = std::make_shared<CTextBox>("", Rect(20, 20, 205, 50), 0, FONT_BIG, ETextAlignment::CENTER, Colors::WHITE);
inputAddress = std::make_shared<CTextInput>(Rect(25, 68, 175, 16), *background.get()); inputAddress = std::make_shared<CTextInput>(Rect(25, 68, 175, 16), *background.get());
inputPort = std::make_shared<CTextInput>(Rect(25, 115, 175, 16), *background.get()); inputPort = std::make_shared<CTextInput>(Rect(25, 115, 175, 16), *background.get());
if(host && !settings["session"]["donotstartserver"].Bool()) if(host && !settings["session"]["donotstartserver"].Bool())

View File

@@ -33,7 +33,7 @@ CPrologEpilogVideo::CPrologEpilogVideo(CCampaignScenario::SScenarioPrologEpilog
// MPTODO: Custom campaign crashing on this? // MPTODO: Custom campaign crashing on this?
// voiceSoundHandle = CCS->soundh->playSound(CCampaignHandler::prologVoiceName(spe.prologVideo)); // voiceSoundHandle = CCS->soundh->playSound(CCampaignHandler::prologVoiceName(spe.prologVideo));
text = std::make_shared<CMultiLineLabel>(Rect(100, 500, 600, 100), EFonts::FONT_BIG, CENTER, Colors::METALLIC_GOLD, spe.prologText); text = std::make_shared<CMultiLineLabel>(Rect(100, 500, 600, 100), EFonts::FONT_BIG, ETextAlignment::CENTER, Colors::METALLIC_GOLD, spe.prologText);
text->scrollTextTo(-100); text->scrollTextTo(-100);
} }

View File

@@ -30,7 +30,7 @@ CreditsScreen::CreditsScreen(Rect rect)
std::string text((char *)textFile.first.get(), textFile.second); std::string text((char *)textFile.first.get(), textFile.second);
size_t firstQuote = text.find('\"') + 1; size_t firstQuote = text.find('\"') + 1;
text = text.substr(firstQuote, text.find('\"', firstQuote) - firstQuote); text = text.substr(firstQuote, text.find('\"', firstQuote) - firstQuote);
credits = std::make_shared<CMultiLineLabel>(Rect(pos.w - 350, 0, 350, 600), FONT_CREDITS, CENTER, Colors::WHITE, text); credits = std::make_shared<CMultiLineLabel>(Rect(pos.w - 350, 0, 350, 600), FONT_CREDITS, ETextAlignment::CENTER, Colors::WHITE, text);
credits->scrollTextTo(-600); // move all text below the screen credits->scrollTextTo(-600); // move all text below the screen
} }

View File

@@ -705,7 +705,7 @@ CInfoBar::VisibleDateInfo::VisibleDateInfo()
else else
labelText = CGI->generaltexth->allTexts[64] + " " + boost::lexical_cast<std::string>(LOCPLINT->cb->getDate(Date::DAY_OF_WEEK)); labelText = CGI->generaltexth->allTexts[64] + " " + boost::lexical_cast<std::string>(LOCPLINT->cb->getDate(Date::DAY_OF_WEEK));
label = std::make_shared<CLabel>(95, 31, FONT_MEDIUM, CENTER, Colors::WHITE, labelText); label = std::make_shared<CLabel>(95, 31, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, labelText);
forceRefresh.push_back(label); forceRefresh.push_back(label);
} }
@@ -771,8 +771,8 @@ CInfoBar::VisibleGameStatusInfo::VisibleGameStatusInfo()
//generate widgets //generate widgets
background = std::make_shared<CPicture>("ADSTATIN"); background = std::make_shared<CPicture>("ADSTATIN");
allyLabel = std::make_shared<CLabel>(10, 106, FONT_SMALL, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[390] + ":"); allyLabel = std::make_shared<CLabel>(10, 106, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[390] + ":");
enemyLabel = std::make_shared<CLabel>(10, 136, FONT_SMALL, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[391] + ":"); enemyLabel = std::make_shared<CLabel>(10, 136, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[391] + ":");
int posx = allyLabel->pos.w + allyLabel->pos.x - pos.x + 4; int posx = allyLabel->pos.w + allyLabel->pos.x - pos.x + 4;
for(PlayerColor & player : allies) for(PlayerColor & player : allies)
@@ -794,7 +794,7 @@ CInfoBar::VisibleGameStatusInfo::VisibleGameStatusInfo()
{ {
hallIcons.push_back(std::make_shared<CAnimImage>("itmtl", i, 0, 6 + 42 * (int)i , 11)); hallIcons.push_back(std::make_shared<CAnimImage>("itmtl", i, 0, 6 + 42 * (int)i , 11));
if(halls[i]) if(halls[i])
hallLabels.push_back(std::make_shared<CLabel>( 26 + 42 * (int)i, 64, FONT_SMALL, CENTER, Colors::WHITE, boost::lexical_cast<std::string>(halls[i]))); hallLabels.push_back(std::make_shared<CLabel>( 26 + 42 * (int)i, 64, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, boost::lexical_cast<std::string>(halls[i])));
} }
} }
@@ -807,7 +807,7 @@ CInfoBar::VisibleComponentInfo::VisibleComponentInfo(const Component & compToDis
comp = std::make_shared<CComponent>(compToDisplay); comp = std::make_shared<CComponent>(compToDisplay);
comp->moveTo(Point(pos.x+47, pos.y+50)); comp->moveTo(Point(pos.x+47, pos.y+50));
text = std::make_shared<CTextBox>(message, Rect(10, 4, 160, 50), 0, FONT_SMALL, CENTER, Colors::WHITE); text = std::make_shared<CTextBox>(message, Rect(10, 4, 160, 50), 0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
} }
void CInfoBar::playNewDaySound() void CInfoBar::playNewDaySound()
@@ -1137,7 +1137,7 @@ void CInGameConsole::startEnteringText()
enteredText = "_"; enteredText = "_";
statusBar->alignment = TOPLEFT; statusBar->alignment = ETextAlignment::TOPLEFT;
statusBar->write(enteredText); statusBar->write(enteredText);
statusBar->lock(true); statusBar->lock(true);
} }
@@ -1161,7 +1161,7 @@ void CInGameConsole::endEnteringText(bool printEnteredText)
if(statusBar) if(statusBar)
{ {
statusBar->alignment = CENTER; statusBar->alignment = ETextAlignment::CENTER;
} }
GH.statusbar->lock(false); GH.statusbar->lock(false);
GH.statusbar->clear(); GH.statusbar->clear();

View File

@@ -77,7 +77,7 @@ void CButton::addCallback(std::function<void()> callback)
void CButton::addTextOverlay(const std::string & Text, EFonts font, SDL_Color color) void CButton::addTextOverlay(const std::string & Text, EFonts font, SDL_Color color)
{ {
OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255-DISPOSE);
addOverlay(std::make_shared<CLabel>(pos.w/2, pos.h/2, font, CENTER, color, Text)); addOverlay(std::make_shared<CLabel>(pos.w/2, pos.h/2, font, ETextAlignment::CENTER, color, Text));
update(); update();
} }

View File

@@ -74,7 +74,7 @@ void CComponent::init(Etype Type, int Subtype, int Val, ESize imageSize)
for(auto & line : textLines) for(auto & line : textLines)
{ {
int height = static_cast<int>(graphics->fonts[font]->getLineHeight()); int height = static_cast<int>(graphics->fonts[font]->getLineHeight());
auto label = std::make_shared<CLabel>(pos.w/2, pos.h + height/2, font, CENTER, Colors::WHITE, line); auto label = std::make_shared<CLabel>(pos.w/2, pos.h + height/2, font, ETextAlignment::CENTER, Colors::WHITE, line);
pos.h += height; pos.h += height;
if(label->pos.w > pos.w) if(label->pos.w > pos.w)
@@ -423,7 +423,7 @@ void CComponentBox::placeComponents(bool selectable)
{ {
Point orPos = Point(currentX - freeSpace, currentY) + getOrTextPos(prevComp.get(), iter->get()); Point orPos = Point(currentX - freeSpace, currentY) + getOrTextPos(prevComp.get(), iter->get());
orLabels.push_back(std::make_shared<CLabel>(orPos.x, orPos.y, FONT_MEDIUM, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[4])); orLabels.push_back(std::make_shared<CLabel>(orPos.x, orPos.y, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[4]));
} }
currentX += getDistance(prevComp.get(), iter->get()); currentX += getDistance(prevComp.get(), iter->get());
} }

View File

@@ -418,7 +418,7 @@ CGarrisonSlot::CGarrisonSlot(CGarrisonInt * Owner, int x, int y, SlotID IID, CGa
pos.h = 64; pos.h = 64;
} }
stackCount = std::make_shared<CLabel>(pos.w, pos.h, owner->smallIcons ? FONT_TINY : FONT_MEDIUM, BOTTOMRIGHT, Colors::WHITE); stackCount = std::make_shared<CLabel>(pos.w, pos.h, owner->smallIcons ? FONT_TINY : FONT_MEDIUM, ETextAlignment::BOTTOMRIGHT, Colors::WHITE);
update(); update();
} }

View File

@@ -223,7 +223,7 @@ void CArmyTooltip::init(const InfoAboutArmy &army)
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
title = std::make_shared<CLabel>(66, 2, FONT_SMALL, TOPLEFT, Colors::WHITE, army.name); title = std::make_shared<CLabel>(66, 2, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, army.name);
std::vector<Point> slotsPos; std::vector<Point> slotsPos;
slotsPos.push_back(Point(36, 73)); slotsPos.push_back(Point(36, 73));
@@ -256,7 +256,7 @@ void CArmyTooltip::init(const InfoAboutArmy &army)
subtitle = CGI->generaltexth->arraytxt[171 + 3*(slot.second.count)]; subtitle = CGI->generaltexth->arraytxt[171 + 3*(slot.second.count)];
} }
subtitles.push_back(std::make_shared<CLabel>(slotsPos[slot.first.getNum()].x + 17, slotsPos[slot.first.getNum()].y + 41, FONT_TINY, CENTER, Colors::WHITE, subtitle)); subtitles.push_back(std::make_shared<CLabel>(slotsPos[slot.first.getNum()].x + 17, slotsPos[slot.first.getNum()].y + 41, FONT_TINY, ETextAlignment::CENTER, Colors::WHITE, subtitle));
} }
} }
@@ -281,10 +281,10 @@ void CHeroTooltip::init(const InfoAboutHero & hero)
if(hero.details) if(hero.details)
{ {
for(size_t i = 0; i < hero.details->primskills.size(); i++) for(size_t i = 0; i < hero.details->primskills.size(); i++)
labels.push_back(std::make_shared<CLabel>(75 + 28 * (int)i, 58, FONT_SMALL, CENTER, Colors::WHITE, labels.push_back(std::make_shared<CLabel>(75 + 28 * (int)i, 58, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE,
boost::lexical_cast<std::string>(hero.details->primskills[i]))); boost::lexical_cast<std::string>(hero.details->primskills[i])));
labels.push_back(std::make_shared<CLabel>(158, 98, FONT_TINY, CENTER, Colors::WHITE, boost::lexical_cast<std::string>(hero.details->mana))); labels.push_back(std::make_shared<CLabel>(158, 98, FONT_TINY, ETextAlignment::CENTER, Colors::WHITE, boost::lexical_cast<std::string>(hero.details->mana)));
morale = std::make_shared<CAnimImage>("IMRL22", hero.details->morale + 3, 0, 5, 74); morale = std::make_shared<CAnimImage>("IMRL22", hero.details->morale + 3, 0, 5, 74);
luck = std::make_shared<CAnimImage>("ILCK22", hero.details->luck + 3, 0, 5, 91); luck = std::make_shared<CAnimImage>("ILCK22", hero.details->luck + 3, 0, 5, 91);
@@ -324,7 +324,7 @@ void CTownTooltip::init(const InfoAboutTown & town)
if(town.details->goldIncome) if(town.details->goldIncome)
{ {
income = std::make_shared<CLabel>(157, 58, FONT_TINY, CENTER, Colors::WHITE, income = std::make_shared<CLabel>(157, 58, FONT_TINY, ETextAlignment::CENTER, Colors::WHITE,
boost::lexical_cast<std::string>(town.details->goldIncome)); boost::lexical_cast<std::string>(town.details->goldIncome));
} }
if(town.details->garrisonedHero) //garrisoned hero icon if(town.details->garrisonedHero) //garrisoned hero icon
@@ -452,7 +452,7 @@ CCreaturePic::CCreaturePic(int x, int y, const CCreature * cre, bool Big, bool A
anim->clipRect(cre->isDoubleWide()?170:150, 155, bg->pos.w, bg->pos.h); anim->clipRect(cre->isDoubleWide()?170:150, 155, bg->pos.w, bg->pos.h);
anim->startPreview(cre->hasBonusOfType(Bonus::SIEGE_WEAPON)); anim->startPreview(cre->hasBonusOfType(Bonus::SIEGE_WEAPON));
amount = std::make_shared<CLabel>(bg->pos.w, bg->pos.h, FONT_MEDIUM, BOTTOMRIGHT, Colors::WHITE); amount = std::make_shared<CLabel>(bg->pos.w, bg->pos.h, FONT_MEDIUM, ETextAlignment::BOTTOMRIGHT, Colors::WHITE);
pos.w = bg->pos.w; pos.w = bg->pos.w;
pos.h = bg->pos.h; pos.h = bg->pos.h;

View File

@@ -36,7 +36,7 @@ void CLabel::showAll(SDL_Surface * to)
} }
CLabel::CLabel(int x, int y, EFonts Font, EAlignment Align, const SDL_Color & Color, const std::string & Text) CLabel::CLabel(int x, int y, EFonts Font, ETextAlignment Align, const SDL_Color & Color, const std::string & Text)
: CTextContainer(Align, Font, Color), text(Text) : CTextContainer(Align, Font, Color), text(Text)
{ {
type |= REDRAW_PARENT; type |= REDRAW_PARENT;
@@ -45,7 +45,7 @@ CLabel::CLabel(int x, int y, EFonts Font, EAlignment Align, const SDL_Color & Co
pos.y += y; pos.y += y;
pos.w = pos.h = 0; pos.w = pos.h = 0;
if(alignment == TOPLEFT) // causes issues for MIDDLE if(alignment == ETextAlignment::TOPLEFT) // causes issues for MIDDLE
{ {
pos.w = (int)graphics->fonts[font]->getStringWidth(visibleText().c_str()); pos.w = (int)graphics->fonts[font]->getStringWidth(visibleText().c_str());
pos.h = (int)graphics->fonts[font]->getLineHeight(); pos.h = (int)graphics->fonts[font]->getLineHeight();
@@ -96,7 +96,7 @@ size_t CLabel::getWidth()
return graphics->fonts[font]->getStringWidth(visibleText());; return graphics->fonts[font]->getStringWidth(visibleText());;
} }
CMultiLineLabel::CMultiLineLabel(Rect position, EFonts Font, EAlignment Align, const SDL_Color & Color, const std::string & Text) : CMultiLineLabel::CMultiLineLabel(Rect position, EFonts Font, ETextAlignment Align, const SDL_Color & Color, const std::string & Text) :
CLabel(position.x, position.y, Font, Align, Color, Text), CLabel(position.x, position.y, Font, Align, Color, Text),
visibleSize(0, 0, position.w, position.h) visibleSize(0, 0, position.w, position.h)
{ {
@@ -137,19 +137,19 @@ void CTextContainer::blitLine(SDL_Surface * to, Rect destRect, std::string what)
// input is rect in which given text should be placed // input is rect in which given text should be placed
// calculate proper position for top-left corner of the text // calculate proper position for top-left corner of the text
if(alignment == TOPLEFT) if(alignment == ETextAlignment::TOPLEFT)
{ {
where.x += getBorderSize().x; where.x += getBorderSize().x;
where.y += getBorderSize().y; where.y += getBorderSize().y;
} }
if(alignment == CENTER) if(alignment == ETextAlignment::CENTER)
{ {
where.x += (int(destRect.w) - int(f->getStringWidth(what))) / 2; where.x += (int(destRect.w) - int(f->getStringWidth(what))) / 2;
where.y += (int(destRect.h) - int(f->getLineHeight())) / 2; where.y += (int(destRect.h) - int(f->getLineHeight())) / 2;
} }
if(alignment == BOTTOMRIGHT) if(alignment == ETextAlignment::BOTTOMRIGHT)
{ {
where.x += getBorderSize().x + destRect.w - (int)f->getStringWidth(what); where.x += getBorderSize().x + destRect.w - (int)f->getStringWidth(what);
where.y += getBorderSize().y + destRect.h - (int)f->getLineHeight(); where.y += getBorderSize().y + destRect.h - (int)f->getLineHeight();
@@ -178,7 +178,7 @@ void CTextContainer::blitLine(SDL_Surface * to, Rect destRect, std::string what)
} while(begin++ != std::string::npos); } while(begin++ != std::string::npos);
} }
CTextContainer::CTextContainer(EAlignment alignment, EFonts font, SDL_Color color) : CTextContainer::CTextContainer(ETextAlignment alignment, EFonts font, SDL_Color color) :
alignment(alignment), alignment(alignment),
font(font), font(font),
color(color) color(color)
@@ -252,15 +252,15 @@ Rect CMultiLineLabel::getTextLocation()
switch(alignment) switch(alignment)
{ {
case TOPLEFT: return Rect(pos.topLeft(), textSize); case ETextAlignment::TOPLEFT: return Rect(pos.topLeft(), textSize);
case CENTER: return Rect(pos.topLeft() + textOffset / 2, textSize); case ETextAlignment::CENTER: return Rect(pos.topLeft() + textOffset / 2, textSize);
case BOTTOMRIGHT: return Rect(pos.topLeft() + textOffset, textSize); case ETextAlignment::BOTTOMRIGHT: return Rect(pos.topLeft() + textOffset, textSize);
} }
assert(0); assert(0);
return Rect(); return Rect();
} }
CLabelGroup::CLabelGroup(EFonts Font, EAlignment Align, const SDL_Color & Color) CLabelGroup::CLabelGroup(EFonts Font, ETextAlignment Align, const SDL_Color & Color)
: font(Font), align(Align), color(Color) : font(Font), align(Align), color(Color)
{ {
defActions = 255 - DISPOSE; defActions = 255 - DISPOSE;
@@ -277,7 +277,7 @@ size_t CLabelGroup::currentSize() const
return labels.size(); return labels.size();
} }
CTextBox::CTextBox(std::string Text, const Rect & rect, int SliderStyle, EFonts Font, EAlignment Align, const SDL_Color & Color) : CTextBox::CTextBox(std::string Text, const Rect & rect, int SliderStyle, EFonts Font, ETextAlignment Align, const SDL_Color & Color) :
sliderStyle(SliderStyle), sliderStyle(SliderStyle),
slider(nullptr) slider(nullptr)
{ {
@@ -356,7 +356,7 @@ void CGStatusBar::clear()
setText(""); setText("");
} }
CGStatusBar::CGStatusBar(std::shared_ptr<CPicture> background_, EFonts Font, EAlignment Align, const SDL_Color & Color) CGStatusBar::CGStatusBar(std::shared_ptr<CPicture> background_, EFonts Font, ETextAlignment Align, const SDL_Color & Color)
: CLabel(background_->pos.x, background_->pos.y, Font, Align, Color, "") : CLabel(background_->pos.x, background_->pos.y, Font, Align, Color, "")
{ {
background = background_; background = background_;
@@ -368,7 +368,7 @@ CGStatusBar::CGStatusBar(std::shared_ptr<CPicture> background_, EFonts Font, EAl
} }
CGStatusBar::CGStatusBar(int x, int y, std::string name, int maxw) CGStatusBar::CGStatusBar(int x, int y, std::string name, int maxw)
: CLabel(x, y, FONT_SMALL, CENTER) : CLabel(x, y, FONT_SMALL, ETextAlignment::CENTER)
{ {
OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE);
background = std::make_shared<CPicture>(name); background = std::make_shared<CPicture>(name);
@@ -401,9 +401,9 @@ Point CGStatusBar::getBorderSize()
switch(alignment) switch(alignment)
{ {
case TOPLEFT: return Point(borderSize.x, borderSize.y); case ETextAlignment::TOPLEFT: return Point(borderSize.x, borderSize.y);
case CENTER: return Point(pos.w / 2, pos.h / 2); case ETextAlignment::CENTER: return Point(pos.w / 2, pos.h / 2);
case BOTTOMRIGHT: return Point(pos.w - borderSize.x, pos.h - borderSize.y); case ETextAlignment::BOTTOMRIGHT: return Point(pos.w - borderSize.x, pos.h - borderSize.y);
} }
assert(0); assert(0);
return Point(); return Point();
@@ -415,7 +415,7 @@ void CGStatusBar::lock(bool shouldLock)
} }
CTextInput::CTextInput(const Rect & Pos, EFonts font, const CFunctionList<void(const std::string &)> & CB) CTextInput::CTextInput(const Rect & Pos, EFonts font, const CFunctionList<void(const std::string &)> & CB)
: CLabel(Pos.x, Pos.y, font, CENTER), : CLabel(Pos.x, Pos.y, font, ETextAlignment::CENTER),
cb(CB), cb(CB),
CFocusable(std::make_shared<CKeyboardFocusListener>(this)) CFocusable(std::make_shared<CKeyboardFocusListener>(this))
{ {

View File

@@ -25,10 +25,10 @@ protected:
/// do actual blitting of line. Text "what" will be placed at "where" and aligned according to alignment /// do actual blitting of line. Text "what" will be placed at "where" and aligned according to alignment
void blitLine(SDL_Surface * to, Rect where, std::string what); void blitLine(SDL_Surface * to, Rect where, std::string what);
CTextContainer(EAlignment alignment, EFonts font, SDL_Color color); CTextContainer(ETextAlignment alignment, EFonts font, SDL_Color color);
public: public:
EAlignment alignment; ETextAlignment alignment;
EFonts font; EFonts font;
SDL_Color color; // default font color. Can be overridden by placing "{}" into the string SDL_Color color; // default font color. Can be overridden by placing "{}" into the string
}; };
@@ -52,7 +52,7 @@ public:
virtual void setColor(const SDL_Color & Color); virtual void setColor(const SDL_Color & Color);
size_t getWidth(); size_t getWidth();
CLabel(int x = 0, int y = 0, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, CLabel(int x = 0, int y = 0, EFonts Font = FONT_SMALL, ETextAlignment Align = ETextAlignment::TOPLEFT,
const SDL_Color & Color = Colors::WHITE, const std::string & Text = ""); const SDL_Color & Color = Colors::WHITE, const std::string & Text = "");
void showAll(SDL_Surface * to) override; //shows statusbar (with current text) void showAll(SDL_Surface * to) override; //shows statusbar (with current text)
}; };
@@ -62,10 +62,10 @@ class CLabelGroup : public CIntObject
{ {
std::vector<std::shared_ptr<CLabel>> labels; std::vector<std::shared_ptr<CLabel>> labels;
EFonts font; EFonts font;
EAlignment align; ETextAlignment align;
SDL_Color color; SDL_Color color;
public: public:
CLabelGroup(EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color & Color = Colors::WHITE); CLabelGroup(EFonts Font = FONT_SMALL, ETextAlignment Align = ETextAlignment::TOPLEFT, const SDL_Color & Color = Colors::WHITE);
void add(int x = 0, int y = 0, const std::string & text = ""); void add(int x = 0, int y = 0, const std::string & text = "");
size_t currentSize() const; size_t currentSize() const;
}; };
@@ -86,7 +86,7 @@ public:
// total size of text, x = longest line of text, y = total height of lines // total size of text, x = longest line of text, y = total height of lines
Point textSize; Point textSize;
CMultiLineLabel(Rect position, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color & Color = Colors::WHITE, const std::string & Text = ""); CMultiLineLabel(Rect position, EFonts Font = FONT_SMALL, ETextAlignment Align = ETextAlignment::TOPLEFT, const SDL_Color & Color = Colors::WHITE, const std::string & Text = "");
void setText(const std::string & Txt) override; void setText(const std::string & Txt) override;
void showAll(SDL_Surface * to) override; void showAll(SDL_Surface * to) override;
@@ -106,7 +106,7 @@ public:
std::shared_ptr<CMultiLineLabel> label; std::shared_ptr<CMultiLineLabel> label;
std::shared_ptr<CSlider> slider; std::shared_ptr<CSlider> slider;
CTextBox(std::string Text, const Rect & rect, int SliderStyle, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color & Color = Colors::WHITE); CTextBox(std::string Text, const Rect & rect, int SliderStyle, EFonts Font = FONT_SMALL, ETextAlignment Align = ETextAlignment::TOPLEFT, const SDL_Color & Color = Colors::WHITE);
void resize(Point newSize); void resize(Point newSize);
void setText(const std::string & Txt); void setText(const std::string & Txt);
@@ -119,7 +119,7 @@ class CGStatusBar : public CLabel, public std::enable_shared_from_this<CGStatusB
bool textLock; //Used for blocking changes to the text bool textLock; //Used for blocking changes to the text
void init(); void init();
CGStatusBar(std::shared_ptr<CPicture> background_, EFonts Font = FONT_SMALL, EAlignment Align = CENTER, const SDL_Color & Color = Colors::WHITE); CGStatusBar(std::shared_ptr<CPicture> background_, EFonts Font = FONT_SMALL, ETextAlignment Align = ETextAlignment::CENTER, const SDL_Color & Color = Colors::WHITE);
CGStatusBar(int x, int y, std::string name, int maxw = -1); CGStatusBar(int x, int y, std::string name, int maxw = -1);
protected: protected:
Point getBorderSize() override; Point getBorderSize() override;

View File

@@ -692,19 +692,19 @@ CAdvMapInt::CAdvMapInt():
for (int i = 0; i < 5; ++i) for (int i = 0; i < 5; ++i)
{ {
panelWorldView->addChildIcon(std::pair<int, Point>(i, Point(5, 58 + i * 20)), iconColorMultiplier); panelWorldView->addChildIcon(std::pair<int, Point>(i, Point(5, 58 + i * 20)), iconColorMultiplier);
panelWorldView->addChildToPanel(std::make_shared<CLabel>(wvLeft + 45, 263 + i * 20, EFonts::FONT_SMALL, EAlignment::TOPLEFT, panelWorldView->addChildToPanel(std::make_shared<CLabel>(wvLeft + 45, 263 + i * 20, EFonts::FONT_SMALL, ETextAlignment::TOPLEFT,
Colors::WHITE, CGI->generaltexth->allTexts[612 + i])); Colors::WHITE, CGI->generaltexth->allTexts[612 + i]));
} }
for (int i = 0; i < 7; ++i) for (int i = 0; i < 7; ++i)
{ {
panelWorldView->addChildIcon(std::pair<int, Point>(i + 5, Point(5, 182 + i * 20)), 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->addChildIcon(std::pair<int, Point>(i + 12, Point(160, 182 + i * 20)), iconColorMultiplier);
panelWorldView->addChildToPanel(std::make_shared<CLabel>(wvLeft + 45, 387 + i * 20, EFonts::FONT_SMALL, EAlignment::TOPLEFT, panelWorldView->addChildToPanel(std::make_shared<CLabel>(wvLeft + 45, 387 + i * 20, EFonts::FONT_SMALL, ETextAlignment::TOPLEFT,
Colors::WHITE, CGI->generaltexth->allTexts[619 + i])); Colors::WHITE, CGI->generaltexth->allTexts[619 + i]));
} }
panelWorldView->addChildToPanel(std::make_shared<CLabel>(wvLeft + 5, 367, EFonts::FONT_SMALL, EAlignment::TOPLEFT, panelWorldView->addChildToPanel(std::make_shared<CLabel>(wvLeft + 5, 367, EFonts::FONT_SMALL, ETextAlignment::TOPLEFT,
Colors::WHITE, CGI->generaltexth->allTexts[617])); Colors::WHITE, CGI->generaltexth->allTexts[617]));
panelWorldView->addChildToPanel(std::make_shared<CLabel>(wvLeft + 45, 367, EFonts::FONT_SMALL, EAlignment::TOPLEFT, panelWorldView->addChildToPanel(std::make_shared<CLabel>(wvLeft + 45, 367, EFonts::FONT_SMALL, ETextAlignment::TOPLEFT,
Colors::WHITE, CGI->generaltexth->allTexts[618])); Colors::WHITE, CGI->generaltexth->allTexts[618]));
activeMapPanel = panelMain; activeMapPanel = panelMain;
@@ -1804,7 +1804,7 @@ void CAdvMapInt::tileRClicked(const int3 &mapPos)
return; return;
} }
CRClickPopup::createAndPush(obj, GH.current->motion, CENTER); CRClickPopup::createAndPush(obj, GH.current->motion, ETextAlignment::CENTER);
} }
void CAdvMapInt::enterCastingMode(const CSpell * sp) void CAdvMapInt::enterCastingMode(const CSpell * sp)

View File

@@ -275,19 +275,19 @@ CDwellingInfoBox::CDwellingInfoBox(int centerX, int centerY, const CGTownInstanc
const CCreature * creature = CGI->creh->objects.at(Town->creatures.at(level).second.back()); const CCreature * creature = CGI->creh->objects.at(Town->creatures.at(level).second.back());
title = std::make_shared<CLabel>(80, 30, FONT_SMALL, CENTER, Colors::WHITE, creature->namePl); title = std::make_shared<CLabel>(80, 30, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, creature->namePl);
animation = std::make_shared<CCreaturePic>(30, 44, creature, true, true); animation = std::make_shared<CCreaturePic>(30, 44, creature, true, true);
std::string text = boost::lexical_cast<std::string>(Town->creatures.at(level).first); std::string text = boost::lexical_cast<std::string>(Town->creatures.at(level).first);
available = std::make_shared<CLabel>(80,190, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[217] + text); available = std::make_shared<CLabel>(80,190, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[217] + text);
costPerTroop = std::make_shared<CLabel>(80, 227, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[346]); costPerTroop = std::make_shared<CLabel>(80, 227, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[346]);
for(int i = 0; i<GameConstants::RESOURCE_QUANTITY; i++) for(int i = 0; i<GameConstants::RESOURCE_QUANTITY; i++)
{ {
if(creature->cost[i]) if(creature->cost[i])
{ {
resPicture.push_back(std::make_shared<CAnimImage>("RESOURCE", i, 0, 0, 0)); resPicture.push_back(std::make_shared<CAnimImage>("RESOURCE", i, 0, 0, 0));
resAmount.push_back(std::make_shared<CLabel>(0,0, FONT_SMALL, CENTER, Colors::WHITE, boost::lexical_cast<std::string>(creature->cost[i]))); resAmount.push_back(std::make_shared<CLabel>(0,0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, boost::lexical_cast<std::string>(creature->cost[i])));
} }
} }
@@ -996,14 +996,14 @@ CCreaInfo::CCreaInfo(Point position, const CGTownInstance * Town, int Level, boo
if(compact) if(compact)
{ {
label = std::make_shared<CLabel>(40, 32, FONT_TINY, BOTTOMRIGHT, Colors::WHITE, value); label = std::make_shared<CLabel>(40, 32, FONT_TINY, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, value);
pos.x += 8; pos.x += 8;
pos.w = 32; pos.w = 32;
pos.h = 32; pos.h = 32;
} }
else else
{ {
label = std::make_shared<CLabel>(24, 40, FONT_SMALL, CENTER, Colors::WHITE, value); label = std::make_shared<CLabel>(24, 40, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, value);
pos.w = 48; pos.w = 48;
pos.h = 48; pos.h = 48;
} }
@@ -1143,8 +1143,8 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInst
garr->type |= REDRAW_PARENT; garr->type |= REDRAW_PARENT;
heroes = std::make_shared<HeroSlots>(town, Point(241, 387), Point(241, 483), garr, true); heroes = std::make_shared<HeroSlots>(town, Point(241, 387), Point(241, 483), garr, true);
title = std::make_shared<CLabel>(85, 387, FONT_MEDIUM, TOPLEFT, Colors::WHITE, town->name); title = std::make_shared<CLabel>(85, 387, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, town->name);
income = std::make_shared<CLabel>(195, 443, FONT_SMALL, CENTER); income = std::make_shared<CLabel>(195, 443, FONT_SMALL, ETextAlignment::CENTER);
icon = std::make_shared<CAnimImage>("ITPT", 0, 0, 15, 387); icon = std::make_shared<CAnimImage>("ITPT", 0, 0, 15, 387);
exit = std::make_shared<CButton>(Point(744, 544), "TSBTNS", CButton::tooltip(CGI->generaltexth->tcommands[8]), [&](){close();}, SDLK_RETURN); exit = std::make_shared<CButton>(Point(744, 544), "TSBTNS", CButton::tooltip(CGI->generaltexth->tcommands[8]), [&](){close();}, SDLK_RETURN);
@@ -1307,7 +1307,7 @@ CHallInterface::CBuildingBox::CBuildingBox(int x, int y, const CGTownInstance *
header = std::make_shared<CAnimImage>("TPTHBAR", panelIndex[state], 0, 1, 73); header = std::make_shared<CAnimImage>("TPTHBAR", panelIndex[state], 0, 1, 73);
if(iconIndex[state] >=0) if(iconIndex[state] >=0)
mark = std::make_shared<CAnimImage>("TPTHCHK", iconIndex[state], 0, 136, 56); mark = std::make_shared<CAnimImage>("TPTHCHK", iconIndex[state], 0, 136, 56);
name = std::make_shared<CLabel>(75, 81, FONT_SMALL, CENTER, Colors::WHITE, building->Name()); name = std::make_shared<CLabel>(75, 81, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, building->Name());
//todo: add support for all possible states //todo: add support for all possible states
if(state >= EBuildingState::BUILDING_ERROR) if(state >= EBuildingState::BUILDING_ERROR)
@@ -1359,7 +1359,7 @@ CHallInterface::CHallInterface(const CGTownInstance * Town):
auto statusbarBackground = std::make_shared<CPicture>(*background, barRect, 5, 556, false); auto statusbarBackground = std::make_shared<CPicture>(*background, barRect, 5, 556, false);
statusbar = CGStatusBar::create(statusbarBackground); statusbar = CGStatusBar::create(statusbarBackground);
title = std::make_shared<CLabel>(399, 12, FONT_MEDIUM, CENTER, Colors::WHITE, town->town->buildings.at(BuildingID(town->hallLevel()+BuildingID::VILLAGE_HALL))->Name()); title = std::make_shared<CLabel>(399, 12, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, town->town->buildings.at(BuildingID(town->hallLevel()+BuildingID::VILLAGE_HALL))->Name());
exit = std::make_shared<CButton>(Point(748, 556), "TPMAGE1.DEF", CButton::tooltip(CGI->generaltexth->hcommands[8]), [&](){close();}, SDLK_RETURN); exit = std::make_shared<CButton>(Point(748, 556), "TPMAGE1.DEF", CButton::tooltip(CGI->generaltexth->hcommands[8]), [&](){close();}, SDLK_RETURN);
exit->assignedKeys.insert(SDLK_ESCAPE); exit->assignedKeys.insert(SDLK_ESCAPE);
@@ -1406,9 +1406,9 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin
auto statusbarBackground = std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26); auto statusbarBackground = std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26);
statusbar = CGStatusBar::create(statusbarBackground); statusbar = CGStatusBar::create(statusbarBackground);
name = std::make_shared<CLabel>(197, 30, FONT_MEDIUM, CENTER, Colors::WHITE, boost::str(boost::format(CGI->generaltexth->hcommands[7]) % building->Name())); name = std::make_shared<CLabel>(197, 30, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, boost::str(boost::format(CGI->generaltexth->hcommands[7]) % building->Name()));
description = std::make_shared<CTextBox>(building->Description(), Rect(33, 135, 329, 67), 0, FONT_MEDIUM, CENTER); description = std::make_shared<CTextBox>(building->Description(), Rect(33, 135, 329, 67), 0, FONT_MEDIUM, ETextAlignment::CENTER);
stateText = std::make_shared<CTextBox>(getTextForState(state), Rect(33, 216, 329, 67), 0, FONT_SMALL, CENTER); stateText = std::make_shared<CTextBox>(getTextForState(state), Rect(33, 216, 329, 67), 0, FONT_SMALL, ETextAlignment::CENTER);
//Create components for all required resources //Create components for all required resources
std::vector<std::shared_ptr<CComponent>> components; std::vector<std::shared_ptr<CComponent>> components;
@@ -1507,8 +1507,8 @@ void LabeledValue::init(std::string nameText, std::string descr, int min, int ma
if(min != max) if(min != max)
valueText += '-' + boost::lexical_cast<std::string>(max); valueText += '-' + boost::lexical_cast<std::string>(max);
} }
name = std::make_shared<CLabel>(3, 0, FONT_SMALL, TOPLEFT, Colors::WHITE, nameText); name = std::make_shared<CLabel>(3, 0, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, nameText);
value = std::make_shared<CLabel>(pos.w-3, pos.h-2, FONT_SMALL, BOTTOMRIGHT, Colors::WHITE, valueText); value = std::make_shared<CLabel>(pos.w-3, pos.h-2, FONT_SMALL, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, valueText);
} }
void LabeledValue::hover(bool on) void LabeledValue::hover(bool on)
@@ -1533,7 +1533,7 @@ CFortScreen::CFortScreen(const CGTownInstance * town):
fortSize--; fortSize--;
const CBuilding * fortBuilding = town->town->buildings.at(BuildingID(town->fortLevel()+6)); const CBuilding * fortBuilding = town->town->buildings.at(BuildingID(town->fortLevel()+6));
title = std::make_shared<CLabel>(400, 12, FONT_BIG, CENTER, Colors::WHITE, fortBuilding->Name()); title = std::make_shared<CLabel>(400, 12, FONT_BIG, ETextAlignment::CENTER, Colors::WHITE, fortBuilding->Name());
std::string text = boost::str(boost::format(CGI->generaltexth->fcommands[6]) % fortBuilding->Name()); std::string text = boost::str(boost::format(CGI->generaltexth->fcommands[6]) % fortBuilding->Name());
exit = std::make_shared<CButton>(Point(748, 556), "TPMAGE1", CButton::tooltip(text), [&](){ close(); }, SDLK_RETURN); exit = std::make_shared<CButton>(Point(748, 556), "TPMAGE1", CButton::tooltip(text), [&](){ close(); }, SDLK_RETURN);
@@ -1620,13 +1620,13 @@ CFortScreen::RecruitArea::RecruitArea(int posX, int posY, const CGTownInstance *
if(getMyBuilding() != nullptr) if(getMyBuilding() != nullptr)
{ {
buildingIcon = std::make_shared<CAnimImage>(town->town->clientInfo.buildingsIcons, getMyBuilding()->bid, 0, 4, 21); buildingIcon = std::make_shared<CAnimImage>(town->town->clientInfo.buildingsIcons, getMyBuilding()->bid, 0, 4, 21);
buildingName = std::make_shared<CLabel>(78, 101, FONT_SMALL, CENTER, Colors::WHITE, getMyBuilding()->Name()); buildingName = std::make_shared<CLabel>(78, 101, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, getMyBuilding()->Name());
if(vstd::contains(town->builtBuildings, getMyBuilding()->bid)) if(vstd::contains(town->builtBuildings, getMyBuilding()->bid))
{ {
ui32 available = town->creatures[level].first; ui32 available = town->creatures[level].first;
std::string availableText = CGI->generaltexth->allTexts[217]+ boost::lexical_cast<std::string>(available); std::string availableText = CGI->generaltexth->allTexts[217]+ boost::lexical_cast<std::string>(available);
availableCount = std::make_shared<CLabel>(78, 119, FONT_SMALL, CENTER, Colors::WHITE, availableText); availableCount = std::make_shared<CLabel>(78, 119, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, availableText);
} }
} }
@@ -1634,7 +1634,7 @@ CFortScreen::RecruitArea::RecruitArea(int posX, int posY, const CGTownInstance *
{ {
hoverText = boost::str(boost::format(CGI->generaltexth->tcommands[21]) % getMyCreature()->namePl); hoverText = boost::str(boost::format(CGI->generaltexth->tcommands[21]) % getMyCreature()->namePl);
new CCreaturePic(159, 4, getMyCreature(), false); new CCreaturePic(159, 4, getMyCreature(), false);
new CLabel(78, 11, FONT_SMALL, CENTER, Colors::WHITE, getMyCreature()->namePl); new CLabel(78, 11, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, getMyCreature()->namePl);
Rect sizes(287, 4, 96, 18); Rect sizes(287, 4, 96, 18);
values.push_back(std::make_shared<LabeledValue>(sizes, CGI->generaltexth->allTexts[190], CGI->generaltexth->fcommands[0], getMyCreature()->getAttack(false))); values.push_back(std::make_shared<LabeledValue>(sizes, CGI->generaltexth->allTexts[190], CGI->generaltexth->fcommands[0], getMyCreature()->getAttack(false)));
@@ -1797,10 +1797,10 @@ CBlacksmithDialog::CBlacksmithDialog(bool possible, CreatureID creMachineID, Art
anim = std::make_shared<CCreatureAnim>(64, 50, creature->animDefName); anim = std::make_shared<CCreatureAnim>(64, 50, creature->animDefName);
anim->clipRect(113,125,200,150); anim->clipRect(113,125,200,150);
title = std::make_shared<CLabel>(165, 28, FONT_BIG, CENTER, Colors::YELLOW, title = std::make_shared<CLabel>(165, 28, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW,
boost::str(boost::format(CGI->generaltexth->allTexts[274]) % creature->nameSing)); boost::str(boost::format(CGI->generaltexth->allTexts[274]) % creature->nameSing));
costText = std::make_shared<CLabel>(165, 218, FONT_MEDIUM, CENTER, Colors::WHITE, CGI->generaltexth->jktexts[43]); costText = std::make_shared<CLabel>(165, 218, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->jktexts[43]);
costValue = std::make_shared<CLabel>(165, 290, FONT_MEDIUM, CENTER, Colors::WHITE, costValue = std::make_shared<CLabel>(165, 290, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE,
boost::lexical_cast<std::string>(aid.toArtifact(CGI->artifacts())->getPrice())); boost::lexical_cast<std::string>(aid.toArtifact(CGI->artifacts())->getPrice()));
std::string text = boost::str(boost::format(CGI->generaltexth->allTexts[595]) % creature->nameSing); std::string text = boost::str(boost::format(CGI->generaltexth->allTexts[595]) % creature->nameSing);

View File

@@ -239,8 +239,8 @@ CStackWindow::BonusLineSection::BonusLineSection(CStackWindow * owner, size_t li
{ {
BonusInfo & bi = parent->activeBonuses[bonusIndex]; BonusInfo & bi = parent->activeBonuses[bonusIndex];
icon[leftRight] = std::make_shared<CPicture>(bi.imagePath, position.x, position.y); icon[leftRight] = std::make_shared<CPicture>(bi.imagePath, position.x, position.y);
name[leftRight] = std::make_shared<CLabel>(position.x + 60, position.y + 2, FONT_SMALL, TOPLEFT, Colors::WHITE, bi.name); name[leftRight] = std::make_shared<CLabel>(position.x + 60, position.y + 2, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, bi.name);
description[leftRight] = std::make_shared<CMultiLineLabel>(Rect(position.x + 60, position.y + 17, 137, 30), FONT_SMALL, TOPLEFT, Colors::WHITE, bi.description); description[leftRight] = std::make_shared<CMultiLineLabel>(Rect(position.x + 60, position.y + 17, 137, 30), FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, bi.description);
} }
} }
} }
@@ -511,7 +511,7 @@ CStackWindow::MainSection::MainSection(CStackWindow * owner, int yOffset, bool s
animation->setAmount(parent->info->creatureCount); animation->setAmount(parent->info->creatureCount);
} }
name = std::make_shared<CLabel>(215, 12, FONT_SMALL, CENTER, Colors::YELLOW, parent->info->getName()); name = std::make_shared<CLabel>(215, 12, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, parent->info->getName());
int dmgMultiply = 1; int dmgMultiply = 1;
if(parent->info->owner && parent->info->stackNode->hasBonusOfType(Bonus::SIEGE_WEAPON)) if(parent->info->owner && parent->info->stackNode->hasBonusOfType(Bonus::SIEGE_WEAPON))
@@ -585,7 +585,7 @@ CStackWindow::MainSection::MainSection(CStackWindow * owner, int yOffset, bool s
expArea->text = parent->generateStackExpDescription(); expArea->text = parent->generateStackExpDescription();
} }
expLabel = std::make_shared<CLabel>( expLabel = std::make_shared<CLabel>(
pos.x + 21, pos.y + 52, FONT_SMALL, CENTER, Colors::WHITE, pos.x + 21, pos.y + 52, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE,
makeNumberShort<TExpType>(stack->experience, 6)); makeNumberShort<TExpType>(stack->experience, 6));
} }
@@ -630,7 +630,7 @@ std::string CStackWindow::MainSection::getBackgroundName(bool showExp, bool show
void CStackWindow::MainSection::addStatLabel(EStat index, int64_t value1, int64_t value2) void CStackWindow::MainSection::addStatLabel(EStat index, int64_t value1, int64_t value2)
{ {
const auto title = statNames.at(static_cast<size_t>(index)); const auto title = statNames.at(static_cast<size_t>(index));
stats.push_back(std::make_shared<CLabel>(145, 32 + (int)index*19, FONT_SMALL, TOPLEFT, Colors::WHITE, title)); stats.push_back(std::make_shared<CLabel>(145, 32 + (int)index*19, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, title));
const bool useRange = value1 != value2; const bool useRange = value1 != value2;
std::string formatStr = useRange ? statFormats.at(static_cast<size_t>(index)) : "%d"; std::string formatStr = useRange ? statFormats.at(static_cast<size_t>(index)) : "%d";
@@ -640,7 +640,7 @@ void CStackWindow::MainSection::addStatLabel(EStat index, int64_t value1, int64_
if(useRange) if(useRange)
fmt % value2; fmt % value2;
stats.push_back(std::make_shared<CLabel>(307, 48 + (int)index*19, FONT_SMALL, BOTTOMRIGHT, Colors::WHITE, fmt.str())); stats.push_back(std::make_shared<CLabel>(307, 48 + (int)index*19, FONT_SMALL, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, fmt.str()));
} }
void CStackWindow::MainSection::addStatLabel(EStat index, int64_t value) void CStackWindow::MainSection::addStatLabel(EStat index, int64_t value)

View File

@@ -108,18 +108,18 @@ CHeroWindow::CHeroWindow(const CGHeroInstance * hero)
curHero = hero; curHero = hero;
banner = std::make_shared<CAnimImage>("CREST58", LOCPLINT->playerID.getNum(), 0, 606, 8); banner = std::make_shared<CAnimImage>("CREST58", LOCPLINT->playerID.getNum(), 0, 606, 8);
name = std::make_shared<CLabel>(190, 38, EFonts::FONT_BIG, EAlignment::CENTER, Colors::YELLOW); name = std::make_shared<CLabel>(190, 38, EFonts::FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW);
title = std::make_shared<CLabel>(190, 65, EFonts::FONT_MEDIUM, EAlignment::CENTER, Colors::WHITE); title = std::make_shared<CLabel>(190, 65, EFonts::FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE);
statusbar = CGStatusBar::create(7, 559, "ADROLLVR.bmp", 660); statusbar = CGStatusBar::create(7, 559, "ADROLLVR.bmp", 660);
quitButton = std::make_shared<CButton>(Point(609, 516), "hsbtns.def", CButton::tooltip(heroscrn[17]), [=](){ close(); }, SDLK_RETURN); quitButton = std::make_shared<CButton>(Point(609, 516), "hsbtns.def", CButton::tooltip(heroscrn[17]), [=](){ close(); }, SDLK_RETURN);
quitButton->assignedKeys.insert(SDLK_ESCAPE); quitButton->assignedKeys.insert(SDLK_ESCAPE);
dismissLabel = std::make_shared<CTextBox>(CGI->generaltexth->jktexts[8], Rect(370, 430, 65, 35), 0, FONT_SMALL, TOPLEFT, Colors::WHITE); dismissLabel = std::make_shared<CTextBox>(CGI->generaltexth->jktexts[8], Rect(370, 430, 65, 35), 0, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
dismissButton = std::make_shared<CButton>(Point(454, 429), "hsbtns2.def", CButton::tooltip(heroscrn[28]), [=](){ dismissCurrent(); }, SDLK_d); dismissButton = std::make_shared<CButton>(Point(454, 429), "hsbtns2.def", CButton::tooltip(heroscrn[28]), [=](){ dismissCurrent(); }, SDLK_d);
questlogLabel = std::make_shared<CTextBox>(CGI->generaltexth->jktexts[9], Rect(510, 430, 65, 35), 0, FONT_SMALL, TOPLEFT, Colors::WHITE); questlogLabel = std::make_shared<CTextBox>(CGI->generaltexth->jktexts[9], Rect(510, 430, 65, 35), 0, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
questlogButton = std::make_shared<CButton>(Point(314, 429), "hsbtns4.def", CButton::tooltip(heroscrn[0]), [=](){ LOCPLINT->showQuestLog(); }, SDLK_q); questlogButton = std::make_shared<CButton>(Point(314, 429), "hsbtns4.def", CButton::tooltip(heroscrn[0]), [=](){ LOCPLINT->showQuestLog(); }, SDLK_q);
formations = std::make_shared<CToggleGroup>(0); formations = std::make_shared<CToggleGroup>(0);
@@ -148,7 +148,7 @@ CHeroWindow::CHeroWindow(const CGHeroInstance * hero)
area->hoverText = boost::str(boost::format(CGI->generaltexth->heroscrn[1]) % CGI->generaltexth->primarySkillNames[v]); area->hoverText = boost::str(boost::format(CGI->generaltexth->heroscrn[1]) % CGI->generaltexth->primarySkillNames[v]);
primSkillAreas.push_back(area); primSkillAreas.push_back(area);
auto value = std::make_shared<CLabel>(53 + 70 * v, 166, FONT_SMALL, CENTER); auto value = std::make_shared<CLabel>(53 + 70 * v, 166, FONT_SMALL, ETextAlignment::CENTER);
primSkillValues.push_back(value); primSkillValues.push_back(value);
} }
@@ -183,19 +183,19 @@ CHeroWindow::CHeroWindow(const CGHeroInstance * hero)
int x = (i % 2) ? 212 : 68; int x = (i % 2) ? 212 : 68;
int y = 280 + 48 * (i/2); int y = 280 + 48 * (i/2);
secSkillValues.push_back(std::make_shared<CLabel>(x, y, FONT_SMALL, TOPLEFT)); secSkillValues.push_back(std::make_shared<CLabel>(x, y, FONT_SMALL, ETextAlignment::TOPLEFT));
secSkillNames.push_back(std::make_shared<CLabel>(x, y+20, FONT_SMALL, TOPLEFT)); secSkillNames.push_back(std::make_shared<CLabel>(x, y+20, FONT_SMALL, ETextAlignment::TOPLEFT));
} }
// various texts // various texts
labels.push_back(std::make_shared<CLabel>(52, 99, FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[1])); labels.push_back(std::make_shared<CLabel>(52, 99, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[1]));
labels.push_back(std::make_shared<CLabel>(123, 99, FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[2])); labels.push_back(std::make_shared<CLabel>(123, 99, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[2]));
labels.push_back(std::make_shared<CLabel>(193, 99, FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[3])); labels.push_back(std::make_shared<CLabel>(193, 99, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[3]));
labels.push_back(std::make_shared<CLabel>(262, 99, FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[4])); labels.push_back(std::make_shared<CLabel>(262, 99, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[4]));
labels.push_back(std::make_shared<CLabel>(69, 183, FONT_SMALL, TOPLEFT, Colors::YELLOW, CGI->generaltexth->jktexts[5])); labels.push_back(std::make_shared<CLabel>(69, 183, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->jktexts[5]));
labels.push_back(std::make_shared<CLabel>(69, 232, FONT_SMALL, TOPLEFT, Colors::YELLOW, CGI->generaltexth->jktexts[6])); labels.push_back(std::make_shared<CLabel>(69, 232, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->jktexts[6]));
labels.push_back(std::make_shared<CLabel>(213, 232, FONT_SMALL, TOPLEFT, Colors::YELLOW, CGI->generaltexth->jktexts[7])); labels.push_back(std::make_shared<CLabel>(213, 232, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->jktexts[7]));
update(hero); update(hero);
} }

View File

@@ -54,20 +54,20 @@ InfoBox::InfoBox(Point position, InfoPos Pos, InfoSize Size, std::shared_ptr<IIn
switch(infoPos) switch(infoPos)
{ {
case POS_CORNER: case POS_CORNER:
value = std::make_shared<CLabel>(pos.w, pos.h, font, BOTTOMRIGHT, Colors::WHITE, data->getValueText()); value = std::make_shared<CLabel>(pos.w, pos.h, font, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, data->getValueText());
break; break;
case POS_INSIDE: case POS_INSIDE:
value = std::make_shared<CLabel>(pos.w/2, pos.h-6, font, CENTER, Colors::WHITE, data->getValueText()); value = std::make_shared<CLabel>(pos.w/2, pos.h-6, font, ETextAlignment::CENTER, Colors::WHITE, data->getValueText());
break; break;
case POS_UP_DOWN: case POS_UP_DOWN:
name = std::make_shared<CLabel>(pos.w/2, -12, font, CENTER, Colors::WHITE, data->getNameText()); name = std::make_shared<CLabel>(pos.w/2, -12, font, ETextAlignment::CENTER, Colors::WHITE, data->getNameText());
FALLTHROUGH; FALLTHROUGH;
case POS_DOWN: case POS_DOWN:
value = std::make_shared<CLabel>(pos.w/2, pos.h+8, font, CENTER, Colors::WHITE, data->getValueText()); value = std::make_shared<CLabel>(pos.w/2, pos.h+8, font, ETextAlignment::CENTER, Colors::WHITE, data->getValueText());
break; break;
case POS_RIGHT: case POS_RIGHT:
name = std::make_shared<CLabel>(pos.w+6, 6, font, TOPLEFT, Colors::WHITE, data->getNameText()); name = std::make_shared<CLabel>(pos.w+6, 6, font, ETextAlignment::TOPLEFT, Colors::WHITE, data->getNameText());
value = std::make_shared<CLabel>(pos.w+6, pos.h-16, font, TOPLEFT, Colors::WHITE, data->getValueText()); value = std::make_shared<CLabel>(pos.w+6, pos.h-16, font, ETextAlignment::TOPLEFT, Colors::WHITE, data->getValueText());
break; break;
} }
@@ -601,7 +601,7 @@ void CKingdomInterface::generateMinesList(const std::vector<const CGObjectInstan
incomeArea = std::make_shared<CHoverableArea>(); incomeArea = std::make_shared<CHoverableArea>();
incomeArea->pos = Rect(pos.x+580, pos.y+31+footerPos, 136, 68); incomeArea->pos = Rect(pos.x+580, pos.y+31+footerPos, 136, 68);
incomeArea->hoverText = CGI->generaltexth->allTexts[255]; incomeArea->hoverText = CGI->generaltexth->allTexts[255];
incomeAmount = std::make_shared<CLabel>(628, footerPos + 70, FONT_SMALL, TOPLEFT, Colors::WHITE, boost::lexical_cast<std::string>(totalIncome)); incomeAmount = std::make_shared<CLabel>(628, footerPos + 70, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, boost::lexical_cast<std::string>(totalIncome));
} }
void CKingdomInterface::generateButtons() void CKingdomInterface::generateButtons()
@@ -682,8 +682,8 @@ CKingdHeroList::CKingdHeroList(size_t maxSize)
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
title = std::make_shared<CPicture>("OVTITLE",16,0); title = std::make_shared<CPicture>("OVTITLE",16,0);
title->colorize(LOCPLINT->playerID); title->colorize(LOCPLINT->playerID);
heroLabel = std::make_shared<CLabel>(150, 10, FONT_MEDIUM, CENTER, Colors::WHITE, CGI->generaltexth->overview[0]); heroLabel = std::make_shared<CLabel>(150, 10, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->overview[0]);
skillsLabel = std::make_shared<CLabel>(500, 10, FONT_MEDIUM, CENTER, Colors::WHITE, CGI->generaltexth->overview[1]); skillsLabel = std::make_shared<CLabel>(500, 10, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->overview[1]);
ui32 townCount = LOCPLINT->cb->howManyHeroes(false); ui32 townCount = LOCPLINT->cb->howManyHeroes(false);
ui32 size = conf.go()->ac.overviewSize*116 + 19; ui32 size = conf.go()->ac.overviewSize*116 + 19;
@@ -722,9 +722,9 @@ CKingdTownList::CKingdTownList(size_t maxSize)
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
title = std::make_shared<CPicture>("OVTITLE", 16, 0); title = std::make_shared<CPicture>("OVTITLE", 16, 0);
title->colorize(LOCPLINT->playerID); title->colorize(LOCPLINT->playerID);
townLabel = std::make_shared<CLabel>(146, 10,FONT_MEDIUM, CENTER, Colors::WHITE, CGI->generaltexth->overview[3]); townLabel = std::make_shared<CLabel>(146, 10,FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->overview[3]);
garrHeroLabel = std::make_shared<CLabel>(375, 10, FONT_MEDIUM, CENTER, Colors::WHITE, CGI->generaltexth->overview[4]); garrHeroLabel = std::make_shared<CLabel>(375, 10, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->overview[4]);
visitHeroLabel = std::make_shared<CLabel>(608, 10, FONT_MEDIUM, CENTER, Colors::WHITE, CGI->generaltexth->overview[5]); visitHeroLabel = std::make_shared<CLabel>(608, 10, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->overview[5]);
ui32 townCount = LOCPLINT->cb->howManyTowns(); ui32 townCount = LOCPLINT->cb->howManyTowns();
ui32 size = conf.go()->ac.overviewSize*116 + 19; ui32 size = conf.go()->ac.overviewSize*116 + 19;
@@ -767,9 +767,9 @@ CTownItem::CTownItem(const CGTownInstance * Town)
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
background = std::make_shared<CAnimImage>("OVSLOT", 6); background = std::make_shared<CAnimImage>("OVSLOT", 6);
name = std::make_shared<CLabel>(74, 8, FONT_SMALL, TOPLEFT, Colors::WHITE, town->name); name = std::make_shared<CLabel>(74, 8, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, town->name);
income = std::make_shared<CLabel>( 190, 60, FONT_SMALL, CENTER, Colors::WHITE, boost::lexical_cast<std::string>(town->dailyIncome()[Res::GOLD])); income = std::make_shared<CLabel>( 190, 60, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, boost::lexical_cast<std::string>(town->dailyIncome()[Res::GOLD]));
hall = std::make_shared<CTownInfo>( 69, 31, town, true); hall = std::make_shared<CTownInfo>( 69, 31, town, true);
fort = std::make_shared<CTownInfo>(111, 31, town, false); fort = std::make_shared<CTownInfo>(111, 31, town, false);
@@ -863,7 +863,7 @@ CHeroItem::CHeroItem(const CGHeroInstance * Hero)
arts2->recActions = SHARE_POS; arts2->recActions = SHARE_POS;
backpack->recActions = SHARE_POS; backpack->recActions = SHARE_POS;
name = std::make_shared<CLabel>(75, 7, FONT_SMALL, TOPLEFT, Colors::WHITE, hero->name); name = std::make_shared<CLabel>(75, 7, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, hero->name);
//layout is not trivial: MACH4 - catapult - excluded, MISC[x] rearranged //layout is not trivial: MACH4 - catapult - excluded, MISC[x] rearranged
assert(arts1->arts.size() == 9); assert(arts1->arts.size() == 9);
@@ -919,8 +919,8 @@ CHeroItem::CHeroItem(const CGHeroInstance * Hero)
portrait = std::make_shared<CAnimImage>("PortraitsLarge", hero->portrait, 0, 5, 6); portrait = std::make_shared<CAnimImage>("PortraitsLarge", hero->portrait, 0, 5, 6);
heroArea = std::make_shared<CHeroArea>(5, 6, hero); heroArea = std::make_shared<CHeroArea>(5, 6, hero);
name = std::make_shared<CLabel>(73, 7, FONT_SMALL, TOPLEFT, Colors::WHITE, hero->name); name = std::make_shared<CLabel>(73, 7, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, hero->name);
artsText = std::make_shared<CLabel>(320, 55, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->overview[2]); artsText = std::make_shared<CLabel>(320, 55, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->overview[2]);
for(size_t i=0; i<GameConstants::PRIMARY_SKILLS; i++) for(size_t i=0; i<GameConstants::PRIMARY_SKILLS; i++)
{ {

View File

@@ -130,11 +130,11 @@ CQuestLog::CQuestLog (const std::vector<QuestInfo> & Quests)
minimap = std::make_shared<CQuestMinimap>(Rect(12, 12, 169, 169)); minimap = std::make_shared<CQuestMinimap>(Rect(12, 12, 169, 169));
// TextBox have it's own 4 pixel padding from top at least for English. To achieve 10px from both left and top only add 6px margin // TextBox have it's own 4 pixel padding from top at least for English. To achieve 10px from both left and top only add 6px margin
description = std::make_shared<CTextBox>("", Rect(205, 18, 385, DESCRIPTION_HEIGHT_MAX), CSlider::BROWN, FONT_MEDIUM, TOPLEFT, Colors::WHITE); description = std::make_shared<CTextBox>("", Rect(205, 18, 385, DESCRIPTION_HEIGHT_MAX), CSlider::BROWN, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE);
ok = std::make_shared<CButton>(Point(539, 398), "IOKAY.DEF", CGI->generaltexth->zelp[445], std::bind(&CQuestLog::close, this), SDLK_RETURN); ok = std::make_shared<CButton>(Point(539, 398), "IOKAY.DEF", CGI->generaltexth->zelp[445], std::bind(&CQuestLog::close, this), SDLK_RETURN);
// Both button and lable are shifted to -2px by x and y to not make them actually look like they're on same line with quests list and ok button // Both button and lable are shifted to -2px by x and y to not make them actually look like they're on same line with quests list and ok button
hideCompleteButton = std::make_shared<CToggleButton>(Point(10, 396), "sysopchk.def", CButton::tooltip(texts["hideComplete"]), std::bind(&CQuestLog::toggleComplete, this, _1)); hideCompleteButton = std::make_shared<CToggleButton>(Point(10, 396), "sysopchk.def", CButton::tooltip(texts["hideComplete"]), std::bind(&CQuestLog::toggleComplete, this, _1));
hideCompleteLabel = std::make_shared<CLabel>(46, 398, FONT_MEDIUM, TOPLEFT, Colors::WHITE, texts["hideComplete"]["label"].String()); hideCompleteLabel = std::make_shared<CLabel>(46, 398, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, texts["hideComplete"]["label"].String());
slider = std::make_shared<CSlider>(Point(166, 195), 191, std::bind(&CQuestLog::sliderMoved, this, _1), QUEST_COUNT, 0, false, CSlider::BROWN); slider = std::make_shared<CSlider>(Point(166, 195), 191, std::bind(&CQuestLog::sliderMoved, this, _1), QUEST_COUNT, 0, false, CSlider::BROWN);
recreateLabelList(); recreateLabelList();
@@ -175,7 +175,7 @@ void CQuestLog::recreateLabelList()
else else
text.addReplacement(quests[i].obj->getObjectName()); //get name of the object text.addReplacement(quests[i].obj->getObjectName()); //get name of the object
} }
auto label = std::make_shared<CQuestLabel>(Rect(13, 195, 149,31), FONT_SMALL, TOPLEFT, Colors::WHITE, text.toString()); auto label = std::make_shared<CQuestLabel>(Rect(13, 195, 149,31), FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, text.toString());
label->disable(); label->disable();
label->callback = std::bind(&CQuestLog::selectQuest, this, i, currentLabel); label->callback = std::bind(&CQuestLog::selectQuest, this, i, currentLabel);

View File

@@ -43,8 +43,8 @@ class CQuestLabel : public LRClickableAreaWText, public CMultiLineLabel
public: public:
std::function<void()> callback; std::function<void()> callback;
CQuestLabel(Rect position, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color &Color = Colors::WHITE, const std::string &Text = "") CQuestLabel(Rect position, EFonts Font = FONT_SMALL, ETextAlignment Align = ETextAlignment::TOPLEFT, const SDL_Color &Color = Colors::WHITE, const std::string &Text = "")
: CMultiLineLabel (position, FONT_SMALL, TOPLEFT, Colors::WHITE, Text){}; : CMultiLineLabel (position, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, Text){};
void clickLeft(tribool down, bool previousState) override; void clickLeft(tribool down, bool previousState) override;
void showAll(SDL_Surface * to) override; void showAll(SDL_Surface * to) override;
}; };

View File

@@ -183,7 +183,7 @@ CSpellWindow::CSpellWindow(const CGHeroInstance * _myHero, CPlayerInterface * _m
for(auto item : schoolBorders) for(auto item : schoolBorders)
item->preload(); item->preload();
mana = std::make_shared<CLabel>(435, 426, FONT_SMALL, CENTER, Colors::YELLOW, boost::lexical_cast<std::string>(myHero->mana)); mana = std::make_shared<CLabel>(435, 426, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, boost::lexical_cast<std::string>(myHero->mana));
statusBar = CGStatusBar::create(7, 569, "Spelroll.bmp"); statusBar = CGStatusBar::create(7, 569, "Spelroll.bmp");
SDL_Rect temp_rect = genRect(45, 35, 479 + pos.x, 405 + pos.y); SDL_Rect temp_rect = genRect(45, 35, 479 + pos.x, 405 + pos.y);
@@ -508,9 +508,9 @@ CSpellWindow::SpellArea::SpellArea(SDL_Rect pos, CSpellWindow * owner)
image = std::make_shared<CAnimImage>(owner->spellIcons, 0, 0); image = std::make_shared<CAnimImage>(owner->spellIcons, 0, 0);
image->visible = false; image->visible = false;
name = std::make_shared<CLabel>(39, 70, FONT_TINY, CENTER); name = std::make_shared<CLabel>(39, 70, FONT_TINY, ETextAlignment::CENTER);
level = std::make_shared<CLabel>(39, 82, FONT_TINY, CENTER); level = std::make_shared<CLabel>(39, 82, FONT_TINY, ETextAlignment::CENTER);
cost = std::make_shared<CLabel>(39, 94, FONT_TINY, CENTER); cost = std::make_shared<CLabel>(39, 94, FONT_TINY, ETextAlignment::CENTER);
for(auto l : {name, level, cost}) for(auto l : {name, level, cost})
l->autoRedraw = false; l->autoRedraw = false;

View File

@@ -703,7 +703,7 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket * Market, const CGHeroInsta
} }
} }
titleLabel = std::make_shared<CLabel>(300, 27, FONT_BIG, CENTER, Colors::YELLOW, title); titleLabel = std::make_shared<CLabel>(300, 27, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, title);
initItems(false); initItems(false);
initItems(true); initItems(true);
@@ -730,15 +730,15 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket * Market, const CGHeroInsta
case EMarketMode::RESOURCE_RESOURCE: case EMarketMode::RESOURCE_RESOURCE:
case EMarketMode::RESOURCE_PLAYER: case EMarketMode::RESOURCE_PLAYER:
case EMarketMode::RESOURCE_ARTIFACT: case EMarketMode::RESOURCE_ARTIFACT:
labels.push_back(std::make_shared<CLabel>(154, 148, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[270])); labels.push_back(std::make_shared<CLabel>(154, 148, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[270]));
break; break;
case EMarketMode::CREATURE_RESOURCE: case EMarketMode::CREATURE_RESOURCE:
//%s's Creatures //%s's Creatures
labels.push_back(std::make_shared<CLabel>(152, 102, FONT_SMALL, CENTER, Colors::WHITE, boost::str(boost::format(CGI->generaltexth->allTexts[272]) % hero->name))); labels.push_back(std::make_shared<CLabel>(152, 102, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, boost::str(boost::format(CGI->generaltexth->allTexts[272]) % hero->name)));
break; break;
case EMarketMode::ARTIFACT_RESOURCE: case EMarketMode::ARTIFACT_RESOURCE:
//%s's Artifacts //%s's Artifacts
labels.push_back(std::make_shared<CLabel>(152, 56, FONT_SMALL, CENTER, Colors::WHITE, boost::str(boost::format(CGI->generaltexth->allTexts[271]) % hero->name))); labels.push_back(std::make_shared<CLabel>(152, 56, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, boost::str(boost::format(CGI->generaltexth->allTexts[271]) % hero->name)));
break; break;
} }
@@ -751,16 +751,16 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket * Market, const CGHeroInsta
case EMarketMode::CREATURE_RESOURCE: case EMarketMode::CREATURE_RESOURCE:
case EMarketMode::RESOURCE_ARTIFACT: case EMarketMode::RESOURCE_ARTIFACT:
case EMarketMode::ARTIFACT_RESOURCE: case EMarketMode::ARTIFACT_RESOURCE:
labels.push_back(std::make_shared<CLabel>(445, 148, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[168])); labels.push_back(std::make_shared<CLabel>(445, 148, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[168]));
traderTextRect = Rect(316, 48, 260, 75); traderTextRect = Rect(316, 48, 260, 75);
break; break;
case EMarketMode::RESOURCE_PLAYER: case EMarketMode::RESOURCE_PLAYER:
labels.push_back(std::make_shared<CLabel>(445, 55, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[169])); labels.push_back(std::make_shared<CLabel>(445, 55, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[169]));
traderTextRect = Rect(28, 48, 260, 75); traderTextRect = Rect(28, 48, 260, 75);
break; break;
} }
traderText = std::make_shared<CTextBox>("", traderTextRect, 0, FONT_SMALL, CENTER); traderText = std::make_shared<CTextBox>("", traderTextRect, 0, FONT_SMALL, ETextAlignment::CENTER);
int specialOffset = mode == EMarketMode::ARTIFACT_RESOURCE ? 35 : 0; //in selling artifacts mode we need to move res-res and art-res buttons down int specialOffset = mode == EMarketMode::ARTIFACT_RESOURCE ? 35 : 0; //in selling artifacts mode we need to move res-res and art-res buttons down
if(printButtonFor(EMarketMode::RESOURCE_PLAYER)) if(printButtonFor(EMarketMode::RESOURCE_PLAYER))
@@ -1094,14 +1094,14 @@ CAltarWindow::CAltarWindow(const IMarket * Market, const CGHeroInstance * Hero,
if(Mode == EMarketMode::CREATURE_EXP) if(Mode == EMarketMode::CREATURE_EXP)
{ {
//%s's Creatures //%s's Creatures
labels.push_back(std::make_shared<CLabel>(155, 30, FONT_SMALL, CENTER, Colors::YELLOW, labels.push_back(std::make_shared<CLabel>(155, 30, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW,
boost::str(boost::format(CGI->generaltexth->allTexts[272]) % hero->name))); boost::str(boost::format(CGI->generaltexth->allTexts[272]) % hero->name)));
//Altar of Sacrifice //Altar of Sacrifice
labels.push_back(std::make_shared<CLabel>(450, 30, FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[479])); labels.push_back(std::make_shared<CLabel>(450, 30, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[479]));
//To sacrifice creatures, move them from your army on to the Altar and click Sacrifice //To sacrifice creatures, move them from your army on to the Altar and click Sacrifice
new CTextBox(CGI->generaltexth->allTexts[480], Rect(320, 56, 256, 40), 0, FONT_SMALL, CENTER, Colors::YELLOW); new CTextBox(CGI->generaltexth->allTexts[480], Rect(320, 56, 256, 40), 0, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW);
slider = std::make_shared<CSlider>(Point(231,481),137,std::bind(&CAltarWindow::sliderMoved,this,_1),0,0); slider = std::make_shared<CSlider>(Point(231,481),137,std::bind(&CAltarWindow::sliderMoved,this,_1),0,0);
max = std::make_shared<CButton>(Point(147, 520), "IRCBTNS.DEF", CGI->generaltexth->zelp[578], std::bind(&CSlider::moveToMax, slider)); max = std::make_shared<CButton>(Point(147, 520), "IRCBTNS.DEF", CGI->generaltexth->zelp[578], std::bind(&CSlider::moveToMax, slider));
@@ -1115,9 +1115,9 @@ CAltarWindow::CAltarWindow(const IMarket * Market, const CGHeroInstance * Hero,
else else
{ {
//Sacrifice artifacts for experience //Sacrifice artifacts for experience
labels.push_back(std::make_shared<CLabel>(450, 34, FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[477])); labels.push_back(std::make_shared<CLabel>(450, 34, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[477]));
//%s's Creatures //%s's Creatures
labels.push_back(std::make_shared<CLabel>(302, 423, FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[478])); labels.push_back(std::make_shared<CLabel>(302, 423, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[478]));
sacrificeAll = std::make_shared<CButton>(Point(393, 520), "ALTFILL.DEF", CGI->generaltexth->zelp[571], std::bind(&CAltarWindow::SacrificeAll,this)); sacrificeAll = std::make_shared<CButton>(Point(393, 520), "ALTFILL.DEF", CGI->generaltexth->zelp[571], std::bind(&CAltarWindow::SacrificeAll,this));
sacrificeAll->block(hero->artifactsInBackpack.empty() && hero->artifactsWorn.empty()); sacrificeAll->block(hero->artifactsInBackpack.empty() && hero->artifactsWorn.empty());
@@ -1131,9 +1131,9 @@ CAltarWindow::CAltarWindow(const IMarket * Market, const CGHeroInstance * Hero,
} }
//Experience needed to reach next level //Experience needed to reach next level
texts.push_back(std::make_shared<CTextBox>(CGI->generaltexth->allTexts[475], Rect(15, 415, 125, 50), 0, FONT_SMALL, CENTER, Colors::YELLOW)); texts.push_back(std::make_shared<CTextBox>(CGI->generaltexth->allTexts[475], Rect(15, 415, 125, 50), 0, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW));
//Total experience on the Altar //Total experience on the Altar
texts.push_back(std::make_shared<CTextBox>(CGI->generaltexth->allTexts[476], Rect(15, 495, 125, 40), 0, FONT_SMALL, CENTER, Colors::YELLOW)); texts.push_back(std::make_shared<CTextBox>(CGI->generaltexth->allTexts[476], Rect(15, 495, 125, 40), 0, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW));
statusBar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26)); statusBar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
@@ -1160,8 +1160,8 @@ CAltarWindow::CAltarWindow(const IMarket * Market, const CGHeroInstance * Hero,
expPerUnit.resize(GameConstants::ARMY_SIZE, 0); expPerUnit.resize(GameConstants::ARMY_SIZE, 0);
getExpValues(); getExpValues();
expToLevel = std::make_shared<CLabel>(73, 475, FONT_SMALL, CENTER); expToLevel = std::make_shared<CLabel>(73, 475, FONT_SMALL, ETextAlignment::CENTER);
expOnAltar = std::make_shared<CLabel>(73, 543, FONT_SMALL, CENTER); expOnAltar = std::make_shared<CLabel>(73, 543, FONT_SMALL, ETextAlignment::CENTER);
setExpToLevel(); setExpToLevel();
calcTotalExp(); calcTotalExp();

View File

@@ -55,8 +55,8 @@ void CreaturePurchaseCard::switchCreatureLevel()
void CreaturePurchaseCard::initAmountInfo() void CreaturePurchaseCard::initAmountInfo()
{ {
availableAmount = std::make_shared<CLabel>(pos.x + 25, pos.y + 146, FONT_SMALL, CENTER, Colors::YELLOW); availableAmount = std::make_shared<CLabel>(pos.x + 25, pos.y + 146, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW);
purchaseAmount = std::make_shared<CLabel>(pos.x + 76, pos.y + 146, FONT_SMALL, CENTER, Colors::WHITE); purchaseAmount = std::make_shared<CLabel>(pos.x + 76, pos.y + 146, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
updateAmountInfo(0); updateAmountInfo(0);
} }

View File

@@ -212,15 +212,15 @@ CRecruitmentWindow::CRecruitmentWindow(const CGDwelling * Dwelling, int Level, c
buyButton = std::make_shared<CButton>(Point(212, 313), "IBY6432.DEF", CGI->generaltexth->zelp[554], std::bind(&CRecruitmentWindow::buy, this), SDLK_RETURN); buyButton = std::make_shared<CButton>(Point(212, 313), "IBY6432.DEF", CGI->generaltexth->zelp[554], std::bind(&CRecruitmentWindow::buy, this), SDLK_RETURN);
cancelButton = std::make_shared<CButton>(Point(290, 313), "ICN6432.DEF", CGI->generaltexth->zelp[555], std::bind(&CRecruitmentWindow::close, this), SDLK_ESCAPE); cancelButton = std::make_shared<CButton>(Point(290, 313), "ICN6432.DEF", CGI->generaltexth->zelp[555], std::bind(&CRecruitmentWindow::close, this), SDLK_ESCAPE);
title = std::make_shared<CLabel>(243, 32, FONT_BIG, CENTER, Colors::YELLOW); title = std::make_shared<CLabel>(243, 32, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW);
availableValue = std::make_shared<CLabel>(205, 253, FONT_SMALL, CENTER, Colors::WHITE); availableValue = std::make_shared<CLabel>(205, 253, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
toRecruitValue = std::make_shared<CLabel>(279, 253, FONT_SMALL, CENTER, Colors::WHITE); toRecruitValue = std::make_shared<CLabel>(279, 253, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
costPerTroopValue = std::make_shared<CreatureCostBox>(Rect(65, 222, 97, 74), CGI->generaltexth->allTexts[346]); costPerTroopValue = std::make_shared<CreatureCostBox>(Rect(65, 222, 97, 74), CGI->generaltexth->allTexts[346]);
totalCostValue = std::make_shared<CreatureCostBox>(Rect(323, 222, 97, 74), CGI->generaltexth->allTexts[466]); totalCostValue = std::make_shared<CreatureCostBox>(Rect(323, 222, 97, 74), CGI->generaltexth->allTexts[466]);
availableTitle = std::make_shared<CLabel>(205, 233, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[465]); availableTitle = std::make_shared<CLabel>(205, 233, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[465]);
toRecruitTitle = std::make_shared<CLabel>(279, 233, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[16]); toRecruitTitle = std::make_shared<CLabel>(279, 233, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[16]);
availableCreaturesChanged(); availableCreaturesChanged();
} }
@@ -333,7 +333,7 @@ CSplitWindow::CSplitWindow(const CCreature * creature, std::function<void(int, i
std::string titleStr = CGI->generaltexth->allTexts[256]; std::string titleStr = CGI->generaltexth->allTexts[256];
boost::algorithm::replace_first(titleStr,"%s", creature->namePl); boost::algorithm::replace_first(titleStr,"%s", creature->namePl);
title = std::make_shared<CLabel>(150, 34, FONT_BIG, CENTER, Colors::YELLOW, titleStr); title = std::make_shared<CLabel>(150, 34, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, titleStr);
} }
void CSplitWindow::setAmountText(std::string text, bool left) void CSplitWindow::setAmountText(std::string text, bool left)
@@ -404,15 +404,15 @@ CLevelWindow::CLevelWindow(const CGHeroInstance * hero, PrimarySkill::PrimarySki
ok = std::make_shared<CButton>(Point(297, 413), "IOKAY", CButton::tooltip(), std::bind(&CLevelWindow::close, this), SDLK_RETURN); ok = std::make_shared<CButton>(Point(297, 413), "IOKAY", CButton::tooltip(), std::bind(&CLevelWindow::close, this), SDLK_RETURN);
//%s has gained a level. //%s has gained a level.
mainTitle = std::make_shared<CLabel>(192, 33, FONT_MEDIUM, CENTER, Colors::WHITE, boost::str(boost::format(CGI->generaltexth->allTexts[444]) % hero->name)); mainTitle = std::make_shared<CLabel>(192, 33, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, boost::str(boost::format(CGI->generaltexth->allTexts[444]) % hero->name));
//%s is now a level %d %s. //%s is now a level %d %s.
levelTitle = std::make_shared<CLabel>(192, 162, FONT_MEDIUM, CENTER, Colors::WHITE, levelTitle = std::make_shared<CLabel>(192, 162, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE,
boost::str(boost::format(CGI->generaltexth->allTexts[445]) % hero->name % hero->level % hero->type->heroClass->name)); boost::str(boost::format(CGI->generaltexth->allTexts[445]) % hero->name % hero->level % hero->type->heroClass->name));
skillIcon = std::make_shared<CAnimImage>("PSKIL42", pskill, 0, 174, 190); skillIcon = std::make_shared<CAnimImage>("PSKIL42", pskill, 0, 174, 190);
skillValue = std::make_shared<CLabel>(192, 253, FONT_MEDIUM, CENTER, Colors::WHITE, CGI->generaltexth->primarySkillNames[pskill] + " +1"); skillValue = std::make_shared<CLabel>(192, 253, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->primarySkillNames[pskill] + " +1");
} }
@@ -447,12 +447,12 @@ CSystemOptionsWindow::CSystemOptionsWindow()
onFullscreenChanged(settings.listen["video"]["fullscreen"]) onFullscreenChanged(settings.listen["video"]["fullscreen"])
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
title = std::make_shared<CLabel>(242, 32, FONT_BIG, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[568]); title = std::make_shared<CLabel>(242, 32, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[568]);
const JsonNode & texts = CGI->generaltexth->localizedTexts["systemOptions"]; const JsonNode & texts = CGI->generaltexth->localizedTexts["systemOptions"];
//left window section //left window section
leftGroup = std::make_shared<CLabelGroup>(FONT_MEDIUM, CENTER, Colors::YELLOW); leftGroup = std::make_shared<CLabelGroup>(FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW);
leftGroup->add(122, 64, CGI->generaltexth->allTexts[569]); leftGroup->add(122, 64, CGI->generaltexth->allTexts[569]);
leftGroup->add(122, 130, CGI->generaltexth->allTexts[570]); leftGroup->add(122, 130, CGI->generaltexth->allTexts[570]);
leftGroup->add(122, 196, CGI->generaltexth->allTexts[571]); leftGroup->add(122, 196, CGI->generaltexth->allTexts[571]);
@@ -461,7 +461,7 @@ CSystemOptionsWindow::CSystemOptionsWindow()
leftGroup->add(122, 412, CGI->generaltexth->allTexts[395]); leftGroup->add(122, 412, CGI->generaltexth->allTexts[395]);
//right section //right section
rightGroup = std::make_shared<CLabelGroup>(FONT_MEDIUM, TOPLEFT, Colors::WHITE); rightGroup = std::make_shared<CLabelGroup>(FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE);
rightGroup->add(282, 57, CGI->generaltexth->allTexts[572]); rightGroup->add(282, 57, CGI->generaltexth->allTexts[572]);
rightGroup->add(282, 89, CGI->generaltexth->allTexts[573]); rightGroup->add(282, 89, CGI->generaltexth->allTexts[573]);
rightGroup->add(282, 121, CGI->generaltexth->allTexts[574]); rightGroup->add(282, 121, CGI->generaltexth->allTexts[574]);
@@ -555,7 +555,7 @@ CSystemOptionsWindow::CSystemOptionsWindow()
gameResButton = std::make_shared<CButton>(Point(28, 275),"buttons/resolution", CButton::tooltip(texts["resolutionButton"]), std::bind(&CSystemOptionsWindow::selectGameRes, this), SDLK_g); gameResButton = std::make_shared<CButton>(Point(28, 275),"buttons/resolution", CButton::tooltip(texts["resolutionButton"]), std::bind(&CSystemOptionsWindow::selectGameRes, this), SDLK_g);
const auto & screenRes = settings["video"]["screenRes"]; const auto & screenRes = settings["video"]["screenRes"];
gameResLabel = std::make_shared<CLabel>(170, 292, FONT_MEDIUM, CENTER, Colors::YELLOW, resolutionToString(screenRes["width"].Integer(), screenRes["height"].Integer())); gameResLabel = std::make_shared<CLabel>(170, 292, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, resolutionToString(screenRes["width"].Integer(), screenRes["height"].Integer()));
} }
void CSystemOptionsWindow::selectGameRes() void CSystemOptionsWindow::selectGameRes()
@@ -666,11 +666,11 @@ CTavernWindow::CTavernWindow(const CGObjectInstance * TavernObj)
h1 = std::make_shared<HeroPortrait>(selected, 0, 72, 299, h[0]); h1 = std::make_shared<HeroPortrait>(selected, 0, 72, 299, h[0]);
h2 = std::make_shared<HeroPortrait>(selected, 1, 162, 299, h[1]); h2 = std::make_shared<HeroPortrait>(selected, 1, 162, 299, h[1]);
title = std::make_shared<CLabel>(200, 35, FONT_BIG, CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[37]); title = std::make_shared<CLabel>(200, 35, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[37]);
cost = std::make_shared<CLabel>(320, 328, FONT_SMALL, CENTER, Colors::WHITE, boost::lexical_cast<std::string>(GameConstants::HERO_GOLD_COST)); cost = std::make_shared<CLabel>(320, 328, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, boost::lexical_cast<std::string>(GameConstants::HERO_GOLD_COST));
auto rumorText = boost::str(boost::format(CGI->generaltexth->allTexts[216]) % LOCPLINT->cb->getTavernRumor(tavernObj)); auto rumorText = boost::str(boost::format(CGI->generaltexth->allTexts[216]) % LOCPLINT->cb->getTavernRumor(tavernObj));
rumor = std::make_shared<CTextBox>(rumorText, Rect(32, 190, 330, 68), 0, FONT_SMALL, CENTER, Colors::WHITE); rumor = std::make_shared<CTextBox>(rumorText, Rect(32, 190, 330, 68), 0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
statusbar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26)); statusbar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
cancel = std::make_shared<CButton>(Point(310, 428), "ICANCEL.DEF", CButton::tooltip(CGI->generaltexth->tavernInfo[7]), std::bind(&CTavernWindow::close, this), SDLK_ESCAPE); cancel = std::make_shared<CButton>(Point(310, 428), "ICANCEL.DEF", CButton::tooltip(CGI->generaltexth->tavernInfo[7]), std::bind(&CTavernWindow::close, this), SDLK_ESCAPE);
@@ -1082,8 +1082,8 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
return boost::str(fmt); return boost::str(fmt);
}; };
titles[0] = std::make_shared<CLabel>(147, 25, FONT_SMALL, CENTER, Colors::WHITE, genTitle(heroInst[0])); 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, CENTER, Colors::WHITE, genTitle(heroInst[1])); titles[1] = std::make_shared<CLabel>(653, 25, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, genTitle(heroInst[1]));
auto PSKIL32 = std::make_shared<CAnimation>("PSKIL32"); auto PSKIL32 = std::make_shared<CAnimation>("PSKIL32");
PSKIL32->preload(); PSKIL32->preload();
@@ -1105,7 +1105,7 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
herosWArt[leftRight] = std::make_shared<CHeroWithMaybePickedArtifact>(this, hero); herosWArt[leftRight] = std::make_shared<CHeroWithMaybePickedArtifact>(this, hero);
for(int m=0; m<GameConstants::PRIMARY_SKILLS; ++m) for(int m=0; m<GameConstants::PRIMARY_SKILLS; ++m)
primSkillValues[leftRight].push_back(std::make_shared<CLabel>(352 + (qeLayout ? 96 : 93) * leftRight, (qeLayout ? 22 : 35) + (qeLayout ? 26 : 36) * m, FONT_SMALL, CENTER, Colors::WHITE)); primSkillValues[leftRight].push_back(std::make_shared<CLabel>(352 + (qeLayout ? 96 : 93) * leftRight, (qeLayout ? 22 : 35) + (qeLayout ? 26 : 36) * m, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE));
for(int m=0; m < hero->secSkills.size(); ++m) for(int m=0; m < hero->secSkills.size(); ++m)
@@ -1114,10 +1114,10 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
specImages[leftRight] = std::make_shared<CAnimImage>("UN32", hero->type->imageIndex, 0, 67 + 490 * leftRight, qeLayout ? 41 : 45); specImages[leftRight] = std::make_shared<CAnimImage>("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>(PSKIL32, 4, 0, 103 + 490 * leftRight, qeLayout ? 41 : 45);
expValues[leftRight] = std::make_shared<CLabel>(119 + 490 * leftRight, qeLayout ? 66 : 71, FONT_SMALL, CENTER, Colors::WHITE); 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>(PSKIL32, 5, 0, 139 + 490 * leftRight, qeLayout ? 41 : 45);
manaValues[leftRight] = std::make_shared<CLabel>(155 + 490 * leftRight, qeLayout ? 66 : 71, FONT_SMALL, CENTER, Colors::WHITE); manaValues[leftRight] = std::make_shared<CLabel>(155 + 490 * leftRight, qeLayout ? 66 : 71, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
} }
portraits[0] = std::make_shared<CAnimImage>("PortraitsLarge", heroInst[0]->portrait, 0, 257, 13); portraits[0] = std::make_shared<CAnimImage>("PortraitsLarge", heroInst[0]->portrait, 0, 257, 13);
@@ -1316,8 +1316,8 @@ CShipyardWindow::CShipyardWindow(const std::vector<si32> & cost, int state, int
std::string goldValue = boost::lexical_cast<std::string>(cost[Res::GOLD]); std::string goldValue = boost::lexical_cast<std::string>(cost[Res::GOLD]);
std::string woodValue = boost::lexical_cast<std::string>(cost[Res::WOOD]); std::string woodValue = boost::lexical_cast<std::string>(cost[Res::WOOD]);
goldCost = std::make_shared<CLabel>(118, 294, FONT_SMALL, CENTER, Colors::WHITE, goldValue); goldCost = std::make_shared<CLabel>(118, 294, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, goldValue);
woodCost = std::make_shared<CLabel>(212, 294, FONT_SMALL, CENTER, Colors::WHITE, woodValue); woodCost = std::make_shared<CLabel>(212, 294, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, woodValue);
goldPic = std::make_shared<CAnimImage>("RESOURCE", Res::GOLD, 0, 100, 244); goldPic = std::make_shared<CAnimImage>("RESOURCE", Res::GOLD, 0, 100, 244);
woodPic = std::make_shared<CAnimImage>("RESOURCE", Res::WOOD, 0, 196, 244); woodPic = std::make_shared<CAnimImage>("RESOURCE", Res::WOOD, 0, 196, 244);
@@ -1337,8 +1337,8 @@ CShipyardWindow::CShipyardWindow(const std::vector<si32> & cost, int state, int
statusbar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26)); statusbar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
title = std::make_shared<CLabel>(164, 27, FONT_BIG, CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[13]); title = std::make_shared<CLabel>(164, 27, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[13]);
costLabel = std::make_shared<CLabel>(164, 220, FONT_MEDIUM, CENTER, Colors::WHITE, CGI->generaltexth->jktexts[14]); costLabel = std::make_shared<CLabel>(164, 220, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->jktexts[14]);
} }
CPuzzleWindow::CPuzzleWindow(const int3 & GrailPos, double discoveredRatio) CPuzzleWindow::CPuzzleWindow(const int3 & GrailPos, double discoveredRatio)
@@ -1355,7 +1355,7 @@ CPuzzleWindow::CPuzzleWindow(const int3 & GrailPos, double discoveredRatio)
quitb->setBorderColor(Colors::METALLIC_GOLD); quitb->setBorderColor(Colors::METALLIC_GOLD);
logo = std::make_shared<CPicture>("PUZZLOGO", 607, 3); logo = std::make_shared<CPicture>("PUZZLOGO", 607, 3);
title = std::make_shared<CLabel>(700, 95, FONT_BIG, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[463]); title = std::make_shared<CLabel>(700, 95, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[463]);
resDataBar = std::make_shared<CResDataBar>("ARESBAR.bmp", 3, 575, 32, 2, 85, 85); resDataBar = std::make_shared<CResDataBar>("ARESBAR.bmp", 3, 575, 32, 2, 85, 85);
int faction = LOCPLINT->cb->getStartInfo()->playerInfos.find(LOCPLINT->playerID)->second.castle; int faction = LOCPLINT->cb->getStartInfo()->playerInfos.find(LOCPLINT->playerID)->second.castle;
@@ -1452,7 +1452,7 @@ CTransformerWindow::CItem::CItem(CTransformerWindow * parent_, int size_, int id
pos.x += 45 + (id%3)*83 + id/6*83; pos.x += 45 + (id%3)*83 + id/6*83;
pos.y += 109 + (id/3)*98; pos.y += 109 + (id/3)*98;
icon = std::make_shared<CAnimImage>("TWCRPORT", parent->army->getCreature(SlotID(id))->idNumber + 2); icon = std::make_shared<CAnimImage>("TWCRPORT", parent->army->getCreature(SlotID(id))->idNumber + 2);
count = std::make_shared<CLabel>(28, 76,FONT_SMALL, CENTER, Colors::WHITE, boost::lexical_cast<std::string>(size)); count = std::make_shared<CLabel>(28, 76,FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, boost::lexical_cast<std::string>(size));
} }
void CTransformerWindow::makeDeal() void CTransformerWindow::makeDeal()
@@ -1502,10 +1502,10 @@ CTransformerWindow::CTransformerWindow(const CGHeroInstance * _hero, const CGTow
cancel = std::make_shared<CButton>(Point(392, 416), "ICANCEL.DEF", CGI->generaltexth->zelp[592], [&](){ close(); },SDLK_ESCAPE); cancel = std::make_shared<CButton>(Point(392, 416), "ICANCEL.DEF", CGI->generaltexth->zelp[592], [&](){ close(); },SDLK_ESCAPE);
statusbar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26)); statusbar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
titleLeft = std::make_shared<CLabel>(153, 29,FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[485]);//holding area titleLeft = std::make_shared<CLabel>(153, 29,FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[485]);//holding area
titleRight = std::make_shared<CLabel>(153+295, 29, FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[486]);//transformer titleRight = std::make_shared<CLabel>(153+295, 29, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[486]);//transformer
helpLeft = std::make_shared<CTextBox>(CGI->generaltexth->allTexts[487], Rect(26, 56, 255, 40), 0, FONT_MEDIUM, CENTER, Colors::YELLOW);//move creatures to create skeletons helpLeft = std::make_shared<CTextBox>(CGI->generaltexth->allTexts[487], Rect(26, 56, 255, 40), 0, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW);//move creatures to create skeletons
helpRight = std::make_shared<CTextBox>(CGI->generaltexth->allTexts[488], Rect(320, 56, 255, 40), 0, FONT_MEDIUM, CENTER, Colors::YELLOW);//creatures here will become skeletons helpRight = std::make_shared<CTextBox>(CGI->generaltexth->allTexts[488], Rect(320, 56, 255, 40), 0, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW);//creatures here will become skeletons
} }
CUniversityWindow::CItem::CItem(CUniversityWindow * _parent, int _ID, int X, int Y) CUniversityWindow::CItem::CItem(CUniversityWindow * _parent, int _ID, int X, int Y)
@@ -1522,8 +1522,8 @@ CUniversityWindow::CItem::CItem(CUniversityWindow * _parent, int _ID, int X, int
icon = std::make_shared<CAnimImage>("SECSKILL", _ID * 3 + 3, 0); icon = std::make_shared<CAnimImage>("SECSKILL", _ID * 3 + 3, 0);
name = std::make_shared<CLabel>(22, -13, FONT_SMALL, CENTER, Colors::WHITE, CGI->skillh->skillName(ID)); name = std::make_shared<CLabel>(22, -13, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->skillh->skillName(ID));
level = std::make_shared<CLabel>(22, 57, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->levels[0]); level = std::make_shared<CLabel>(22, 57, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->levels[0]);
pos.h = icon->pos.h; pos.h = icon->pos.h;
pos.w = icon->pos.w; pos.w = icon->pos.w;
@@ -1604,8 +1604,8 @@ CUniversityWindow::CUniversityWindow(const CGHeroInstance * _hero, const IMarket
titlePic->center(Point(232 + pos.x, 76 + pos.y)); titlePic->center(Point(232 + pos.x, 76 + pos.y));
clerkSpeech = std::make_shared<CTextBox>(CGI->generaltexth->allTexts[603], Rect(24, 129, 413, 70), 0, FONT_SMALL, CENTER, Colors::WHITE); clerkSpeech = std::make_shared<CTextBox>(CGI->generaltexth->allTexts[603], Rect(24, 129, 413, 70), 0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
title = std::make_shared<CLabel>(231, 26, FONT_MEDIUM, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[602]); title = std::make_shared<CLabel>(231, 26, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[602]);
std::vector<int> goods = market->availableItemsIds(EMarketMode::RESOURCE_SKILL); std::vector<int> goods = market->availableItemsIds(EMarketMode::RESOURCE_SKILL);
assert(goods.size() == 4); assert(goods.size() == 4);
@@ -1634,14 +1634,14 @@ CUnivConfirmWindow::CUnivConfirmWindow(CUniversityWindow * owner_, int SKILL, bo
boost::replace_first(text, "%s", CGI->skillh->skillName(SKILL)); boost::replace_first(text, "%s", CGI->skillh->skillName(SKILL));
boost::replace_first(text, "%d", "2000"); boost::replace_first(text, "%d", "2000");
clerkSpeech = std::make_shared<CTextBox>(text, Rect(24, 129, 413, 70), 0, FONT_SMALL, CENTER, Colors::WHITE); clerkSpeech = std::make_shared<CTextBox>(text, Rect(24, 129, 413, 70), 0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
name = std::make_shared<CLabel>(230, 37, FONT_SMALL, CENTER, Colors::WHITE, CGI->skillh->skillName(SKILL)); name = std::make_shared<CLabel>(230, 37, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->skillh->skillName(SKILL));
icon = std::make_shared<CAnimImage>("SECSKILL", SKILL*3+3, 0, 211, 51); icon = std::make_shared<CAnimImage>("SECSKILL", SKILL*3+3, 0, 211, 51);
level = std::make_shared<CLabel>(230, 107, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->levels[1]); level = std::make_shared<CLabel>(230, 107, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->levels[1]);
costIcon = std::make_shared<CAnimImage>("RESOURCE", Res::GOLD, 0, 210, 210); costIcon = std::make_shared<CAnimImage>("RESOURCE", Res::GOLD, 0, 210, 210);
cost = std::make_shared<CLabel>(230, 267, FONT_SMALL, CENTER, Colors::WHITE, "2000"); cost = std::make_shared<CLabel>(230, 267, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, "2000");
std::string hoverText = CGI->generaltexth->allTexts[609]; std::string hoverText = CGI->generaltexth->allTexts[609];
boost::replace_first(hoverText, "%s", CGI->generaltexth->levels[0]+ " " + CGI->skillh->skillName(SKILL)); boost::replace_first(hoverText, "%s", CGI->generaltexth->levels[0]+ " " + CGI->skillh->skillName(SKILL));
@@ -1694,7 +1694,7 @@ CGarrisonWindow::CGarrisonWindow(const CArmedInstance * up, const CGHeroInstance
logGlobal->error("Invalid armed instance for garrison window."); logGlobal->error("Invalid armed instance for garrison window.");
} }
} }
title = std::make_shared<CLabel>(275, 30, FONT_BIG, CENTER, Colors::YELLOW, titleText); title = std::make_shared<CLabel>(275, 30, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, titleText);
banner = std::make_shared<CAnimImage>("CREST58", up->getOwner().getNum(), 0, 28, 124); banner = std::make_shared<CAnimImage>("CREST58", up->getOwner().getNum(), 0, 28, 124);
portrait = std::make_shared<CAnimImage>("PortraitsLarge", down->portrait, 0, 29, 222); portrait = std::make_shared<CAnimImage>("PortraitsLarge", down->portrait, 0, 29, 222);
@@ -1712,14 +1712,14 @@ CHillFortWindow::CHillFortWindow(const CGHeroInstance * visitor, const CGObjectI
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
title = std::make_shared<CLabel>(325, 32, FONT_BIG, CENTER, Colors::YELLOW, fort->getObjectName()); title = std::make_shared<CLabel>(325, 32, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, fort->getObjectName());
heroPic = std::make_shared<CHeroArea>(30, 60, hero); heroPic = std::make_shared<CHeroArea>(30, 60, hero);
for(int i=0; i < resCount; i++) for(int i=0; i < resCount; i++)
{ {
totalIcons[i] = std::make_shared<CAnimImage>("SMALRES", i, 0, 104 + 76 * i, 237); totalIcons[i] = std::make_shared<CAnimImage>("SMALRES", i, 0, 104 + 76 * i, 237);
totalLabels[i] = std::make_shared<CLabel>(166 + 76 * i, 253, FONT_SMALL, BOTTOMRIGHT); totalLabels[i] = std::make_shared<CLabel>(166 + 76 * i, 253, FONT_SMALL, ETextAlignment::BOTTOMRIGHT);
} }
for(int i = 0; i < slotsCount; i++) for(int i = 0; i < slotsCount; i++)
@@ -1731,7 +1731,7 @@ CHillFortWindow::CHillFortWindow(const CGHeroInstance * visitor, const CGObjectI
for(int j : {0,1}) for(int j : {0,1})
{ {
slotIcons[i][j] = std::make_shared<CAnimImage>("SMALRES", 0, 0, 104 + 76 * i, 128 + 20 * j); slotIcons[i][j] = std::make_shared<CAnimImage>("SMALRES", 0, 0, 104 + 76 * i, 128 + 20 * j);
slotLabels[i][j] = std::make_shared<CLabel>(168 + 76 * i, 144 + 20 * j, FONT_SMALL, BOTTOMRIGHT); slotLabels[i][j] = std::make_shared<CLabel>(168 + 76 * i, 144 + 20 * j, FONT_SMALL, ETextAlignment::BOTTOMRIGHT);
} }
} }
@@ -1944,7 +1944,7 @@ CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
std::string text = CGI->generaltexth->jktexts[24+g]; std::string text = CGI->generaltexth->jktexts[24+g];
boost::algorithm::trim_if(text,boost::algorithm::is_any_of("\"")); boost::algorithm::trim_if(text,boost::algorithm::is_any_of("\""));
rowHeaders.push_back(std::make_shared<CLabel>(135, y, FONT_MEDIUM, CENTER, Colors::YELLOW, text)); rowHeaders.push_back(std::make_shared<CLabel>(135, y, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, text));
} }
auto PRSTRIPS = std::make_shared<CAnimation>("PRSTRIPS"); auto PRSTRIPS = std::make_shared<CAnimation>("PRSTRIPS");
@@ -1954,7 +1954,7 @@ CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
columnBackgrounds.push_back(std::make_shared<CAnimImage>(PRSTRIPS, g-1, 0, 250 + 66*g, 7)); columnBackgrounds.push_back(std::make_shared<CAnimImage>(PRSTRIPS, g-1, 0, 250 + 66*g, 7));
for(int g=0; g<tgi.playerColors.size(); ++g) for(int g=0; g<tgi.playerColors.size(); ++g)
columnHeaders.push_back(std::make_shared<CLabel>(283 + 66*g, 24, FONT_BIG, CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[16+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 = std::make_shared<CAnimation>("itgflags"); auto itgflags = std::make_shared<CAnimation>("itgflags");
itgflags->preload(); itgflags->preload();
@@ -2003,11 +2003,11 @@ CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
if(iter.second.details) if(iter.second.details)
{ {
primSkillHeaders.push_back(std::make_shared<CTextBox>(CGI->generaltexth->allTexts[184], Rect(260 + 66*counter, 396, 52, 64), primSkillHeaders.push_back(std::make_shared<CTextBox>(CGI->generaltexth->allTexts[184], Rect(260 + 66*counter, 396, 52, 64),
0, FONT_TINY, TOPLEFT, Colors::WHITE)); 0, FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE));
for(int i=0; i<iter.second.details->primskills.size(); ++i) for(int i=0; i<iter.second.details->primskills.size(); ++i)
{ {
primSkillValues.push_back(std::make_shared<CLabel>(310 + 66 * counter, 407 + 11*i, FONT_TINY, BOTTOMRIGHT, Colors::WHITE, primSkillValues.push_back(std::make_shared<CLabel>(310 + 66 * counter, 407 + 11*i, FONT_TINY, ETextAlignment::BOTTOMRIGHT, Colors::WHITE,
boost::lexical_cast<std::string>(iter.second.details->primskills[i]))); boost::lexical_cast<std::string>(iter.second.details->primskills[i])));
} }
} }
@@ -2038,7 +2038,7 @@ CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
text = CGI->generaltexth->arraytxt[168 + it.second]; text = CGI->generaltexth->arraytxt[168 + it.second];
} }
personalities.push_back(std::make_shared<CLabel>(283 + 66*counter, 459, FONT_SMALL, CENTER, Colors::WHITE, text)); personalities.push_back(std::make_shared<CLabel>(283 + 66*counter, 459, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, text));
counter++; counter++;
} }
@@ -2055,7 +2055,7 @@ CObjectListWindow::CItem::CItem(CObjectListWindow * _parent, size_t _id, std::st
type |= REDRAW_PARENT; type |= REDRAW_PARENT;
text = std::make_shared<CLabel>(pos.w/2, pos.h/2, FONT_SMALL, CENTER, Colors::WHITE, _text); text = std::make_shared<CLabel>(pos.w/2, pos.h/2, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, _text);
select(index == parent->selected); select(index == parent->selected);
} }
@@ -2108,8 +2108,8 @@ void CObjectListWindow::init(std::shared_ptr<CIntObject> titleWidget_, std::stri
{ {
titleWidget = titleWidget_; titleWidget = titleWidget_;
title = std::make_shared<CLabel>(152, 27, FONT_BIG, CENTER, Colors::YELLOW, _title); title = std::make_shared<CLabel>(152, 27, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, _title);
descr = std::make_shared<CLabel>(145, 133, FONT_SMALL, CENTER, Colors::WHITE, _descr); descr = std::make_shared<CLabel>(145, 133, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, _descr);
exit = std::make_shared<CButton>( Point(228, 402), "ICANCEL.DEF", CButton::tooltip(), std::bind(&CObjectListWindow::exitPressed, this), SDLK_ESCAPE); exit = std::make_shared<CButton>( Point(228, 402), "ICANCEL.DEF", CButton::tooltip(), std::bind(&CObjectListWindow::exitPressed, this), SDLK_ESCAPE);
if(titleWidget) if(titleWidget)

View File

@@ -77,7 +77,7 @@ CSelWindow::CSelWindow(const std::string &Text, PlayerColor player, int charperl
buttons[i]->addCallback(std::bind(&CInfoWindow::close, this)); //each button will close the window apart from call-defined actions buttons[i]->addCallback(std::bind(&CInfoWindow::close, this)); //each button will close the window apart from call-defined actions
} }
text = std::make_shared<CTextBox>(Text, Rect(0, 0, 250, 100), 0, FONT_MEDIUM, CENTER, Colors::WHITE); text = std::make_shared<CTextBox>(Text, Rect(0, 0, 250, 100), 0, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE);
buttons.front()->assignedKeys.insert(SDLK_RETURN); //first button - reacts on enter buttons.front()->assignedKeys.insert(SDLK_RETURN); //first button - reacts on enter
buttons.back()->assignedKeys.insert(SDLK_ESCAPE); //last button - reacts on escape buttons.back()->assignedKeys.insert(SDLK_ESCAPE); //last button - reacts on escape
@@ -131,7 +131,7 @@ CInfoWindow::CInfoWindow(std::string Text, PlayerColor player, const TCompsInfo
buttons.push_back(button); buttons.push_back(button);
} }
text = std::make_shared<CTextBox>(Text, Rect(0, 0, 250, 100), 0, FONT_MEDIUM, CENTER, Colors::WHITE); text = std::make_shared<CTextBox>(Text, Rect(0, 0, 250, 100), 0, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE);
if(!text->slider) if(!text->slider)
{ {
text->resize(text->label->textSize); text->resize(text->label->textSize);
@@ -218,18 +218,18 @@ CInfoPopup::CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free)
} }
CInfoPopup::CInfoPopup(SDL_Surface * Bitmap, const Point &p, EAlignment alignment, bool Free) CInfoPopup::CInfoPopup(SDL_Surface * Bitmap, const Point &p, ETextAlignment alignment, bool Free)
: free(Free),bitmap(Bitmap) : free(Free),bitmap(Bitmap)
{ {
switch(alignment) switch(alignment)
{ {
case BOTTOMRIGHT: case ETextAlignment::BOTTOMRIGHT:
init(p.x - Bitmap->w, p.y - Bitmap->h); init(p.x - Bitmap->w, p.y - Bitmap->h);
break; break;
case CENTER: case ETextAlignment::CENTER:
init(p.x - Bitmap->w/2, p.y - Bitmap->h/2); init(p.x - Bitmap->w/2, p.y - Bitmap->h/2);
break; break;
case TOPLEFT: case ETextAlignment::TOPLEFT:
init(p.x, p.y); init(p.x, p.y);
break; break;
default: default:
@@ -324,7 +324,7 @@ void CRClickPopup::createAndPush(const std::string & txt, std::shared_ptr<CCompo
createAndPush(txt, intComps); createAndPush(txt, intComps);
} }
void CRClickPopup::createAndPush(const CGObjectInstance * obj, const Point & p, EAlignment alignment) void CRClickPopup::createAndPush(const CGObjectInstance * obj, const Point & p, ETextAlignment alignment)
{ {
auto iWin = createInfoWin(p, obj); //try get custom infowindow for this obj auto iWin = createInfoWin(p, obj); //try get custom infowindow for this obj
if(iWin) if(iWin)

View File

@@ -83,7 +83,7 @@ public:
static std::shared_ptr<WindowBase> createInfoWin(Point position, const CGObjectInstance * specific); static std::shared_ptr<WindowBase> createInfoWin(Point position, const CGObjectInstance * specific);
static void createAndPush(const std::string & txt, const CInfoWindow::TCompsInfo &comps = CInfoWindow::TCompsInfo()); static void createAndPush(const std::string & txt, const CInfoWindow::TCompsInfo &comps = CInfoWindow::TCompsInfo());
static void createAndPush(const std::string & txt, std::shared_ptr<CComponent> component); static void createAndPush(const std::string & txt, std::shared_ptr<CComponent> component);
static void createAndPush(const CGObjectInstance * obj, const Point & p, EAlignment alignment = BOTTOMRIGHT); static void createAndPush(const CGObjectInstance * obj, const Point & p, ETextAlignment alignment = ETextAlignment::BOTTOMRIGHT);
}; };
/// popup displayed on R-click /// popup displayed on R-click
@@ -103,7 +103,7 @@ public:
void close() override; void close() override;
void show(SDL_Surface * to) override; void show(SDL_Surface * to) override;
CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free=false); CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free=false);
CInfoPopup(SDL_Surface * Bitmap, const Point &p, EAlignment alignment, bool Free=false); CInfoPopup(SDL_Surface * Bitmap, const Point &p, ETextAlignment alignment, bool Free=false);
CInfoPopup(SDL_Surface * Bitmap = nullptr, bool Free = false); CInfoPopup(SDL_Surface * Bitmap = nullptr, bool Free = false);
void init(int x, int y); void init(int x, int y);

View File

@@ -168,7 +168,7 @@
"targetType": "NO_TARGET", "targetType": "NO_TARGET",
"animation":{ "animation":{
//missing "affect":["SP10_"]
}, },
"sounds": { "sounds": {
"cast": "PARALYZE" "cast": "PARALYZE"