mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-03 00:46:55 +02:00
Fix clang-tidy warnings
This commit is contained in:
@ -124,7 +124,7 @@ bool BattleConsole::addText(const std::string & text)
|
||||
auto newLines = splitText(text);
|
||||
|
||||
logEntries.insert(logEntries.end(), newLines.begin(), newLines.end());
|
||||
scrollPosition = (int)logEntries.size() - 1;
|
||||
scrollPosition = static_cast<int>(logEntries.size()) - 1;
|
||||
redraw();
|
||||
return true;
|
||||
}
|
||||
@ -142,7 +142,7 @@ void BattleConsole::scrollDown(ui32 by)
|
||||
redraw();
|
||||
}
|
||||
|
||||
BattleConsole::BattleConsole(const BattleInterface & owner, std::shared_ptr<CPicture> backgroundSource, const Point & objectPos, const Point & imagePos, const Point &size)
|
||||
BattleConsole::BattleConsole(const BattleInterface & owner, const std::shared_ptr<CPicture> & backgroundSource, const Point & objectPos, const Point & imagePos, const Point &size)
|
||||
: CIntObject(LCLICK)
|
||||
, owner(owner)
|
||||
, scrollPosition(-1)
|
||||
|
@ -59,7 +59,7 @@ private:
|
||||
std::vector<std::string> getVisibleText() const;
|
||||
|
||||
public:
|
||||
BattleConsole(const BattleInterface & owner, std::shared_ptr<CPicture> backgroundSource, const Point & objectPos, const Point & imagePos, const Point & size);
|
||||
BattleConsole(const BattleInterface & owner, const std::shared_ptr<CPicture> & backgroundSource, const Point & objectPos, const Point & imagePos, const Point & size);
|
||||
|
||||
void showAll(Canvas & to) override;
|
||||
void deactivate() override;
|
||||
|
@ -147,7 +147,7 @@ void BattleHero::heroRightClicked()
|
||||
InfoAboutHero targetHero;
|
||||
if(owner.makingTurn() || settings["session"]["spectate"].Bool())
|
||||
{
|
||||
auto h = defender ? owner.defendingHeroInstance : owner.attackingHeroInstance;
|
||||
const auto * h = defender ? owner.defendingHeroInstance : owner.attackingHeroInstance;
|
||||
targetHero.initFromHero(h, InfoAboutHero::EInfoLevel::INBATTLE);
|
||||
ENGINE->windows().createAndPushWindow<HeroInfoWindow>(targetHero, &windowPosition);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ BattleResultWindow::BattleResultWindow(const BattleResult & br, CPlayerInterface
|
||||
labels.push_back(std::make_shared<CLabel>(232, 332, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, LIBRARY->generaltexth->allTexts[408]));
|
||||
labels.push_back(std::make_shared<CLabel>(232, 428, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, LIBRARY->generaltexth->allTexts[409]));
|
||||
|
||||
std::string sideNames[2] = {"N/A", "N/A"};
|
||||
std::array<std::string, 2> sideNames = {"N/A", "N/A"};
|
||||
|
||||
for(auto i : {BattleSide::ATTACKER, BattleSide::DEFENDER})
|
||||
{
|
||||
@ -114,17 +114,18 @@ BattleResultWindow::BattleResultWindow(const BattleResult & br, CPlayerInterface
|
||||
//printing casualties
|
||||
for(auto step : {BattleSide::ATTACKER, BattleSide::DEFENDER})
|
||||
{
|
||||
if(br.casualties[step].size()==0)
|
||||
if(br.casualties[step].empty())
|
||||
{
|
||||
labels.push_back(std::make_shared<CLabel>(235, 360 + 97 * static_cast<int>(step), FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, LIBRARY->generaltexth->allTexts[523]));
|
||||
}
|
||||
else
|
||||
{
|
||||
int xPos = 235 - ((int)br.casualties[step].size()*32 + ((int)br.casualties[step].size() - 1)*10)/2; //increment by 42 with each picture
|
||||
int casualties = br.casualties[step].size();
|
||||
int xPos = 235 - (casualties*32 + (casualties - 1)*10)/2; //increment by 42 with each picture
|
||||
int yPos = 344 + static_cast<int>(step) * 97;
|
||||
for(auto & elem : br.casualties[step])
|
||||
{
|
||||
auto creature = elem.first.toEntity(LIBRARY);
|
||||
const auto * creature = elem.first.toEntity(LIBRARY);
|
||||
if (creature->getId() == CreatureID::ARROW_TOWERS )
|
||||
continue; // do not show destroyed towers in battle results
|
||||
|
||||
|
@ -430,7 +430,7 @@ void BattleWindow::updateStackInfoWindow(const CStack * stack)
|
||||
|
||||
if(stack && stack->unitSide() == BattleSide::DEFENDER)
|
||||
{
|
||||
defenderStackWindow = std::make_shared<StackInfoBasicPanel>(stack);
|
||||
defenderStackWindow = std::make_shared<StackInfoBasicPanel>(stack, true);
|
||||
defenderStackWindow->setEnabled(showInfoWindows);
|
||||
}
|
||||
else
|
||||
@ -438,7 +438,7 @@ void BattleWindow::updateStackInfoWindow(const CStack * stack)
|
||||
|
||||
if(stack && stack->unitSide() == BattleSide::ATTACKER)
|
||||
{
|
||||
attackerStackWindow = std::make_shared<StackInfoBasicPanel>(stack);
|
||||
attackerStackWindow = std::make_shared<StackInfoBasicPanel>(stack, true);
|
||||
attackerStackWindow->setEnabled(showInfoWindows);
|
||||
}
|
||||
else
|
||||
|
@ -31,6 +31,7 @@
|
||||
QuickSpellPanel::QuickSpellPanel(BattleInterface & owner)
|
||||
: CIntObject(0)
|
||||
, owner(owner)
|
||||
, isEnabled(true)
|
||||
{
|
||||
OBJECT_CONSTRUCTION;
|
||||
|
||||
@ -64,7 +65,7 @@ std::vector<std::tuple<SpellID, bool>> QuickSpellPanel::getSpells() const
|
||||
}
|
||||
|
||||
// autofill empty slots with spells if possible
|
||||
auto hero = owner.getBattle()->battleGetMyHero();
|
||||
const auto * hero = owner.getBattle()->battleGetMyHero();
|
||||
for(int i = 0; i < QUICKSPELL_SLOTS; i++)
|
||||
{
|
||||
if(spellIds[i] != SpellID::NONE)
|
||||
@ -97,7 +98,7 @@ void QuickSpellPanel::create()
|
||||
buttons.clear();
|
||||
buttonsDisabled.clear();
|
||||
|
||||
auto hero = owner.getBattle()->battleGetMyHero();
|
||||
const auto * hero = owner.getBattle()->battleGetMyHero();
|
||||
if(!hero)
|
||||
return;
|
||||
|
||||
|
@ -30,7 +30,7 @@ private:
|
||||
BattleInterface & owner;
|
||||
|
||||
public:
|
||||
int QUICKSPELL_SLOTS = 12;
|
||||
static constexpr int QUICKSPELL_SLOTS = 12;
|
||||
|
||||
bool isEnabled; // isActive() is not working on multiple conditions, because of this we need a seperate flag
|
||||
|
||||
|
@ -63,7 +63,7 @@ void StackInfoBasicPanel::initializeData(const CStack * stack)
|
||||
auto luck = stack->luckVal();
|
||||
|
||||
auto killed = stack->getKilled();
|
||||
auto healthRemaining = TextOperations::formatMetric(std::max(stack->getAvailableHealth() - (stack->getCount() - 1) * health, (si64)0), 4);
|
||||
auto healthRemaining = TextOperations::formatMetric(std::max<int64_t>(stack->getAvailableHealth() - static_cast<int64_t>(stack->getCount() - 1) * health, 0), 4);
|
||||
|
||||
//primary stats*/
|
||||
labels.push_back(std::make_shared<CLabel>(9, 75, EFonts::FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, LIBRARY->generaltexth->allTexts[380] + ":"));
|
||||
@ -118,12 +118,14 @@ void StackInfoBasicPanel::initializeData(const CStack * stack)
|
||||
icons.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("SpellInt"), effect.getNum() + 1, 0, firstPos.x + offset.x * printed, firstPos.y + offset.y * printed));
|
||||
if(settings["general"]["enableUiEnhancements"].Bool())
|
||||
labels.push_back(std::make_shared<CLabel>(firstPos.x + offset.x * printed + 46, firstPos.y + offset.y * printed + 36, EFonts::FONT_TINY, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, std::to_string(duration)));
|
||||
if(++printed >= 3 || (printed == 2 && spells.size() > 3)) // interface limit reached
|
||||
|
||||
++printed;
|
||||
if(printed >= 3 || (printed == 2 && spells.size() > 3)) // interface limit reached
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(spells.size() == 0)
|
||||
if(spells.empty())
|
||||
labelsMultiline.push_back(std::make_shared<CMultiLineLabel>(Rect(firstPos.x, firstPos.y, 48, 36), EFonts::FONT_TINY, ETextAlignment::CENTER, Colors::WHITE, LIBRARY->generaltexth->allTexts[674]));
|
||||
if(spells.size() > 3)
|
||||
labelsMultiline.push_back(std::make_shared<CMultiLineLabel>(Rect(firstPos.x + offset.x * 2, firstPos.y + offset.y * 2 - 4, 48, 36), EFonts::FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, "..."));
|
||||
|
@ -29,7 +29,7 @@ private:
|
||||
std::vector<std::shared_ptr<CAnimImage>> icons;
|
||||
|
||||
public:
|
||||
StackInfoBasicPanel(const CStack * stack, bool initializeBackground = true);
|
||||
StackInfoBasicPanel(const CStack * stack, bool initializeBackground);
|
||||
|
||||
void show(Canvas & to) override;
|
||||
|
||||
|
@ -97,7 +97,7 @@ void StackQueue::update()
|
||||
stackBoxes[boxIndex]->setUnit(nullptr);
|
||||
}
|
||||
|
||||
int32_t StackQueue::getSiegeShooterIconID()
|
||||
int32_t StackQueue::getSiegeShooterIconID() const
|
||||
{
|
||||
return owner.siegeController->getSiegedTown()->getFactionID().getNum();
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class StackQueue : public CIntObject
|
||||
std::vector<std::shared_ptr<StackBox>> stackBoxes;
|
||||
BattleInterface & owner;
|
||||
|
||||
int32_t getSiegeShooterIconID();
|
||||
int32_t getSiegeShooterIconID() const;
|
||||
|
||||
public:
|
||||
const bool embedded;
|
||||
|
Reference in New Issue
Block a user