diff --git a/client/battle/BattleActionsController.cpp b/client/battle/BattleActionsController.cpp index 17c617945..140acda81 100644 --- a/client/battle/BattleActionsController.cpp +++ b/client/battle/BattleActionsController.cpp @@ -668,7 +668,7 @@ void BattleActionsController::handleHex(BattleHex myNumber, int eventType) CCS->curh->changeGraphic(cursorType, cursorFrame); if (!currentConsoleMsg.empty()) - owner->controlPanel->console->clearMatching(currentConsoleMsg); + owner->controlPanel->console->clearIfMatching(currentConsoleMsg); if (!newConsoleMsg.empty()) owner->controlPanel->console->write(newConsoleMsg); diff --git a/client/battle/BattleInterfaceClasses.cpp b/client/battle/BattleInterfaceClasses.cpp index 616669f21..1e7a27d67 100644 --- a/client/battle/BattleInterfaceClasses.cpp +++ b/client/battle/BattleInterfaceClasses.cpp @@ -106,7 +106,7 @@ BattleConsole::BattleConsole(const Rect & position) : lastShown(-1) pos.h = position.h; } -void BattleConsole::clearMatching(const std::string & Text) +void BattleConsole::clearIfMatching(const std::string & Text) { if (ingcAlter == Text) clear(); diff --git a/client/battle/BattleInterfaceClasses.h b/client/battle/BattleInterfaceClasses.h index 353e455e5..ada4029ea 100644 --- a/client/battle/BattleInterfaceClasses.h +++ b/client/battle/BattleInterfaceClasses.h @@ -55,7 +55,7 @@ public: void scrollUp(ui32 by = 1); //scrolls console up by 'by' positions void scrollDown(ui32 by = 1); //scrolls console up by 'by' positions - void clearMatching(const std::string & Text) override; + void clearIfMatching(const std::string & Text) override; void clear() override; void write(const std::string & Text) override; void lock(bool shouldLock) override; diff --git a/client/battle/BattleStacksController.cpp b/client/battle/BattleStacksController.cpp index 8e5b4dd44..bf288cd77 100644 --- a/client/battle/BattleStacksController.cpp +++ b/client/battle/BattleStacksController.cpp @@ -76,10 +76,10 @@ BattleStacksController::BattleStacksController(BattleInterface * owner): amountNegative = IImage::createFromFile("CMNUMWIN.BMP"); amountEffNeutral = IImage::createFromFile("CMNUMWIN.BMP"); - ColorShifterAddMulExcept shifterNormal ({0,0,0,0}, {150, 50, 255, 255}, {255, 231, 132, 255}); - ColorShifterAddMulExcept shifterPositive({0,0,0,0}, { 50, 255, 50, 255}, {255, 231, 132, 255}); - ColorShifterAddMulExcept shifterNegative({0,0,0,0}, {255, 50, 50, 255}, {255, 231, 132, 255}); - ColorShifterAddMulExcept shifterNeutral ({0,0,0,0}, {255, 255, 50, 255}, {255, 231, 132, 255}); + static const ColorShifterMultiplyAndAddExcept shifterNormal ({150, 50, 255, 255}, {0,0,0,0}, {255, 231, 132, 255}); + static const ColorShifterMultiplyAndAddExcept shifterPositive({ 50, 255, 50, 255}, {0,0,0,0}, {255, 231, 132, 255}); + static const ColorShifterMultiplyAndAddExcept shifterNegative({255, 50, 50, 255}, {0,0,0,0}, {255, 231, 132, 255}); + static const ColorShifterMultiplyAndAddExcept shifterNeutral ({255, 255, 50, 255}, {0,0,0,0}, {255, 231, 132, 255}); amountNormal->adjustPalette(&shifterNormal); amountPositive->adjustPalette(&shifterPositive); @@ -160,10 +160,11 @@ void BattleStacksController::stackReset(const CStack * stack) if(stack->alive() && animation->isDeadOrDying()) animation->setType(CCreatureAnim::HOLDING); + static const ColorShifterMultiplyAndAdd shifterClone ({255, 255, 0, 255}, {0, 0, 255, 0}); + if (stack->isClone()) { - auto shifter = ColorShifterAddMul::deepBlue(); - animation->shiftColor(&shifter); + animation->shiftColor(&shifterClone); } //TODO: handle more cases diff --git a/client/gui/CIntObject.h b/client/gui/CIntObject.h index 0243d167f..ef265b816 100644 --- a/client/gui/CIntObject.h +++ b/client/gui/CIntObject.h @@ -221,7 +221,7 @@ class IStatusBar public: virtual ~IStatusBar(); virtual void clear() = 0; - virtual void clearMatching(const std::string & Text) = 0; + virtual void clearIfMatching(const std::string & Text) = 0; virtual void write(const std::string & Text) = 0; virtual void lock(bool shouldLock) = 0; }; diff --git a/client/gui/SDL_Extensions.h b/client/gui/SDL_Extensions.h index 98087675a..1bb31e743 100644 --- a/client/gui/SDL_Extensions.h +++ b/client/gui/SDL_Extensions.h @@ -158,6 +158,7 @@ struct ColorPutter typedef void (*BlitterWithRotationVal)(SDL_Surface *src,SDL_Rect srcRect, SDL_Surface * dst, SDL_Rect dstRect, ui8 rotation); +/// Base class for applying palette transformation on images class ColorShifter { public: @@ -165,39 +166,38 @@ public: virtual SDL_Color shiftColor(SDL_Color input) const = 0; }; -class ColorShifterAddMul : public ColorShifter +/// Generic class for palette transformation +/// formula: +/// result = input * factor + added +class ColorShifterMultiplyAndAdd : public ColorShifter { - SDL_Color add; - SDL_Color mul; + SDL_Color added; + SDL_Color factor; + public: - - static ColorShifterAddMul deepBlue() - { - return ColorShifterAddMul({0, 0, 255, 0}, {255, 255, 0, 255}); - } - - ColorShifterAddMul(SDL_Color add, SDL_Color mul) : - add(add), - mul(mul) + ColorShifterMultiplyAndAdd(SDL_Color factor, SDL_Color added) : + factor(factor), + added(added) {} SDL_Color shiftColor(SDL_Color input) const override { return { - uint8_t(std::min(255.f, std::round(input.r * float(mul.r) / 255 + add.r))), - uint8_t(std::min(255.f, std::round(input.g * float(mul.g) / 255 + add.g))), - uint8_t(std::min(255.f, std::round(input.b * float(mul.b) / 255 + add.b))), - uint8_t(std::min(255.f, std::round(input.a * float(mul.a) / 255 + add.a))), + uint8_t(std::min(255.f, std::round(input.r * float(factor.r) / 255.f + added.r))), + uint8_t(std::min(255.f, std::round(input.g * float(factor.g) / 255.f + added.g))), + uint8_t(std::min(255.f, std::round(input.b * float(factor.b) / 255.f + added.b))), + uint8_t(std::min(255.f, std::round(input.a * float(factor.a) / 255.f + added.a))), }; } }; -class ColorShifterAddMulExcept : public ColorShifterAddMul +/// Color shifter that allows to specify color to be excempt from changes +class ColorShifterMultiplyAndAddExcept : public ColorShifterMultiplyAndAdd { SDL_Color ignored; public: - ColorShifterAddMulExcept(SDL_Color add, SDL_Color mul, SDL_Color ignored) : - ColorShifterAddMul(add, mul), + ColorShifterMultiplyAndAddExcept(SDL_Color factor, SDL_Color added, SDL_Color ignored) : + ColorShifterMultiplyAndAdd(factor, added), ignored(ignored) {} @@ -205,7 +205,7 @@ public: { if ( input.r == ignored.r && input.g == ignored.g && input.b == ignored.b && input.a == ignored.a) return input; - return ColorShifterAddMul::shiftColor(input); + return ColorShifterMultiplyAndAdd::shiftColor(input); } }; diff --git a/client/mainmenu/CMainMenu.cpp b/client/mainmenu/CMainMenu.cpp index 00a594156..2cab437c9 100644 --- a/client/mainmenu/CMainMenu.cpp +++ b/client/mainmenu/CMainMenu.cpp @@ -369,11 +369,11 @@ CMultiMode::CMultiMode(ESelectionScreen ScreenType) : screenType(ScreenType) { OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; - background = std::make_shared("MUPOPUP.bmp"); - background->convertToScreenBPP(); //so we could draw without problems - blitAt(CPicture("MUMAP.bmp").getSurface(), 16, 77, background->getSurface()); pos = background->center(); //center, window has size of bg graphic + background = std::make_shared("MUPOPUP.bmp"); + picture = std::make_shared("MUMAP.bmp", 16, 77); + statusBar = CGStatusBar::create(std::make_shared(background->getSurface(), Rect(7, 465, 440, 18), 7, 465)); playerName = std::make_shared(Rect(19, 436, 334, 16), background->getSurface()); playerName->setText(settings["general"]["playerName"].String()); diff --git a/client/mainmenu/CMainMenu.h b/client/mainmenu/CMainMenu.h index 4fdebb93d..1a7fb5b6b 100644 --- a/client/mainmenu/CMainMenu.h +++ b/client/mainmenu/CMainMenu.h @@ -80,6 +80,7 @@ class CMultiMode : public WindowBase public: ESelectionScreen screenType; std::shared_ptr background; + std::shared_ptr picture; std::shared_ptr playerName; std::shared_ptr buttonHotseat; std::shared_ptr buttonHost; diff --git a/client/widgets/AdventureMapClasses.cpp b/client/widgets/AdventureMapClasses.cpp index f2e97c06d..911a19fca 100644 --- a/client/widgets/AdventureMapClasses.cpp +++ b/client/widgets/AdventureMapClasses.cpp @@ -1126,7 +1126,7 @@ void CInGameConsole::textEdited(const SDL_TextEditingEvent & event) void CInGameConsole::startEnteringText() { - auto * statusBar = dynamic_cast(GH.statusbar.get()); + auto statusBar = std::dynamic_pointer_cast(GH.statusbar); if (statusBar) { @@ -1158,7 +1158,7 @@ void CInGameConsole::endEnteringText(bool printEnteredText) } enteredText.clear(); - auto * statusBar = dynamic_cast(GH.statusbar.get()); + auto statusBar = std::dynamic_pointer_cast(GH.statusbar); if(statusBar) { diff --git a/client/widgets/Buttons.cpp b/client/widgets/Buttons.cpp index 3bb2fe0f3..e180181ae 100644 --- a/client/widgets/Buttons.cpp +++ b/client/widgets/Buttons.cpp @@ -210,7 +210,7 @@ void CButton::hover (bool on) if (on) GH.statusbar->write(name); else - GH.statusbar->clearMatching(name); + GH.statusbar->clearIfMatching(name); } } diff --git a/client/widgets/MiscWidgets.cpp b/client/widgets/MiscWidgets.cpp index 0529ab1cc..f57d09b49 100644 --- a/client/widgets/MiscWidgets.cpp +++ b/client/widgets/MiscWidgets.cpp @@ -35,7 +35,7 @@ void CHoverableArea::hover (bool on) if (on) GH.statusbar->write(hoverText); else - GH.statusbar->clearMatching(hoverText); + GH.statusbar->clearIfMatching(hoverText); } CHoverableArea::CHoverableArea() diff --git a/client/widgets/TextControls.cpp b/client/widgets/TextControls.cpp index 6902cc612..9b84af67e 100644 --- a/client/widgets/TextControls.cpp +++ b/client/widgets/TextControls.cpp @@ -345,7 +345,7 @@ void CGStatusBar::write(const std::string & Text) CLabel::setText(Text); } -void CGStatusBar::clearMatching(const std::string & Text) +void CGStatusBar::clearIfMatching(const std::string & Text) { if (getText() == Text) clear(); diff --git a/client/widgets/TextControls.h b/client/widgets/TextControls.h index 76e76c2fb..6cdecfb6d 100644 --- a/client/widgets/TextControls.h +++ b/client/widgets/TextControls.h @@ -138,7 +138,7 @@ public: return ret; } - void clearMatching(const std::string & Text) override; + void clearIfMatching(const std::string & Text) override; void clear() override;//clears statusbar and refreshes void write(const std::string & Text) override; //prints text and refreshes statusbar diff --git a/client/windows/CCastleInterface.cpp b/client/windows/CCastleInterface.cpp index 2adf92986..a89ab26c6 100644 --- a/client/windows/CCastleInterface.cpp +++ b/client/windows/CCastleInterface.cpp @@ -1035,7 +1035,7 @@ void CCreaInfo::hover(bool on) } else { - GH.statusbar->clearMatching(message); + GH.statusbar->clearIfMatching(message); } } diff --git a/lib/spells/effects/RemoveObstacle.cpp b/lib/spells/effects/RemoveObstacle.cpp index d6a6803a4..7c7de2901 100644 --- a/lib/spells/effects/RemoveObstacle.cpp +++ b/lib/spells/effects/RemoveObstacle.cpp @@ -47,6 +47,7 @@ bool RemoveObstacle::applicable(Problem & problem, const Mechanics * m) const { return m->adaptProblem(ESpellCastProblem::NO_APPROPRIATE_TARGET, problem); } + return true; } bool RemoveObstacle::applicable(Problem & problem, const Mechanics * m, const EffectTarget & target) const