From 1dec5e56a987db589ee906986adbd9588c89290a Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Fri, 19 Jul 2024 19:35:39 +0000 Subject: [PATCH 1/5] Fix cursor shadow option in battles --- client/battle/BattleFieldController.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/battle/BattleFieldController.cpp b/client/battle/BattleFieldController.cpp index 439e5ab71..ee25131e0 100644 --- a/client/battle/BattleFieldController.cpp +++ b/client/battle/BattleFieldController.cpp @@ -356,9 +356,6 @@ std::set BattleFieldController::getHighlightedHexesForSpellRange() std::set result; auto hoveredHex = getHoveredHex(); - if(!settings["battle"]["mouseShadow"].Bool()) - return result; - const spells::Caster *caster = nullptr; const CSpell *spell = nullptr; @@ -549,6 +546,8 @@ void BattleFieldController::showHighlightedHexes(Canvas & canvas) std::set hoveredMoveHexes = getHighlightedHexesForMovementTarget(); BattleHex hoveredHex = getHoveredHex(); + std::set hoveredMouseHex = hoveredHex.isValid() ? std::set({ hoveredHex }) : std::set(); + const CStack * hoveredStack = getHoveredStack(); if(!hoveredStack && hoveredHex == BattleHex::INVALID) return; @@ -565,7 +564,10 @@ void BattleFieldController::showHighlightedHexes(Canvas & canvas) calculateRangeLimitAndHighlightImages(shootingRangeDistance, shootingRangeLimitImages, shootingRangeLimitHexes, shootingRangeLimitHexesHighlights); } - auto const & hoveredMouseHexes = hoveredHex != BattleHex::INVALID && owner.actionsController->currentActionSpellcasting(getHoveredHex()) ? hoveredSpellHexes : hoveredMoveHexes; + bool useSpellRangeForMouse = hoveredHex != BattleHex::INVALID && owner.actionsController->currentActionSpellcasting(getHoveredHex()); + bool useMoveRangeForMouse = !hoveredMoveHexes.empty() || !settings["battle"]["mouseShadow"].Bool(); + + const auto & hoveredMouseHexes = useSpellRangeForMouse ? hoveredSpellHexes : ( useMoveRangeForMouse ? hoveredMoveHexes : hoveredMouseHex); for(int hex = 0; hex < GameConstants::BFIELD_SIZE; ++hex) { From 75fd67a92197e1e815fa24696240d44ab5eef048 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Fri, 19 Jul 2024 19:36:05 +0000 Subject: [PATCH 2/5] Fix mouse scroll not working in right-click popups --- client/windows/InfoWindows.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/windows/InfoWindows.cpp b/client/windows/InfoWindows.cpp index b124c547b..0370fe13d 100644 --- a/client/windows/InfoWindows.cpp +++ b/client/windows/InfoWindows.cpp @@ -248,7 +248,7 @@ void CRClickPopup::createAndPush(const CGObjectInstance * obj, const Point & p, CRClickPopupInt::CRClickPopupInt(const std::shared_ptr & our) { CCS->curh->hide(); - defActions = SHOWALL | UPDATE; + defActions = 255-DISPOSE; our->recActions = defActions; inner = our; addChild(our.get(), false); From e862b9c86895d66178e06e8d7171c0bb1e33cff3 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Fri, 19 Jul 2024 19:37:22 +0000 Subject: [PATCH 3/5] Fix crash on opening creature window with bonuses that don't have icon --- client/renderSDL/SDLImage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/renderSDL/SDLImage.cpp b/client/renderSDL/SDLImage.cpp index c7e47cd97..6a9a61d6f 100644 --- a/client/renderSDL/SDLImage.cpp +++ b/client/renderSDL/SDLImage.cpp @@ -196,7 +196,7 @@ Point SDLImageConst::dimensions() const std::shared_ptr SDLImageConst::createImageReference(EImageBlitMode mode) { - if (surf->format->palette) + if (surf && surf->format->palette) return std::make_shared(shared_from_this(), mode); else return std::make_shared(shared_from_this(), mode); From 8d4f8dcf9c2ce801ae8d7af711b74f2212cd7037 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Fri, 19 Jul 2024 19:38:40 +0000 Subject: [PATCH 4/5] Add unassigned by default hotkeys to show visitable or blocked tiles --- client/adventureMap/AdventureMapShortcuts.cpp | 14 ++++++++++++++ client/adventureMap/AdventureMapShortcuts.h | 2 ++ client/gui/Shortcut.h | 2 ++ client/gui/ShortcutHandler.cpp | 2 ++ config/shortcutsConfig.json | 2 ++ 5 files changed, 22 insertions(+) diff --git a/client/adventureMap/AdventureMapShortcuts.cpp b/client/adventureMap/AdventureMapShortcuts.cpp index 2db16f04b..222553e78 100644 --- a/client/adventureMap/AdventureMapShortcuts.cpp +++ b/client/adventureMap/AdventureMapShortcuts.cpp @@ -71,6 +71,8 @@ std::vector AdventureMapShortcuts::getShortcuts() { EShortcut::ADVENTURE_QUEST_LOG, optionCanViewQuests(), [this]() { this->showQuestlog(); } }, { EShortcut::ADVENTURE_TOGGLE_SLEEP, optionHeroSelected(), [this]() { this->toggleSleepWake(); } }, { EShortcut::ADVENTURE_TOGGLE_GRID, optionInMapView(), [this]() { this->toggleGrid(); } }, + { EShortcut::ADVENTURE_TOGGLE_VISITABLE, optionInMapView(), [this]() { this->toggleVisitable(); } }, + { EShortcut::ADVENTURE_TOGGLE_BLOCKED, optionInMapView(), [this]() { this->toggleBlocked(); } }, { EShortcut::ADVENTURE_TRACK_HERO, optionInMapView(), [this]() { this->toggleTrackHero(); } }, { EShortcut::ADVENTURE_SET_HERO_ASLEEP, optionHeroAwake(), [this]() { this->setHeroSleeping(); } }, { EShortcut::ADVENTURE_SET_HERO_AWAKE, optionHeroSleeping(), [this]() { this->setHeroAwake(); } }, @@ -168,6 +170,18 @@ void AdventureMapShortcuts::toggleGrid() s["showGrid"].Bool() = !settings["gameTweaks"]["showGrid"].Bool(); } +void AdventureMapShortcuts::toggleVisitable() +{ + Settings s = settings.write["session"]; + s["showVisitable"].Bool() = !settings["session"]["showVisitable"].Bool(); +} + +void AdventureMapShortcuts::toggleBlocked() +{ + Settings s = settings.write["session"]; + s["showBlocked"].Bool() = !settings["session"]["showBlocked"].Bool(); +} + void AdventureMapShortcuts::toggleSleepWake() { if (!optionHeroSelected()) diff --git a/client/adventureMap/AdventureMapShortcuts.h b/client/adventureMap/AdventureMapShortcuts.h index 7b1e1ec7d..b32f3ea29 100644 --- a/client/adventureMap/AdventureMapShortcuts.h +++ b/client/adventureMap/AdventureMapShortcuts.h @@ -42,6 +42,8 @@ class AdventureMapShortcuts void showQuestlog(); void toggleTrackHero(); void toggleGrid(); + void toggleVisitable(); + void toggleBlocked(); void toggleSleepWake(); void setHeroSleeping(); void setHeroAwake(); diff --git a/client/gui/Shortcut.h b/client/gui/Shortcut.h index aedf695d9..64891abe3 100644 --- a/client/gui/Shortcut.h +++ b/client/gui/Shortcut.h @@ -120,6 +120,8 @@ enum class EShortcut // Adventure map screen ADVENTURE_GAME_OPTIONS, // 'o', Open CAdventureOptions window ADVENTURE_TOGGLE_GRID, // F6, Toggles map grid + ADVENTURE_TOGGLE_VISITABLE, // Toggles visitable tiles overlay + ADVENTURE_TOGGLE_BLOCKED, // Toggles blocked tiles overlay ADVENTURE_TOGGLE_SLEEP, // Toggles hero sleep status ADVENTURE_SET_HERO_ASLEEP, // Moves hero to sleep state ADVENTURE_SET_HERO_AWAKE, // Move hero to awake state diff --git a/client/gui/ShortcutHandler.cpp b/client/gui/ShortcutHandler.cpp index 259a1c6cb..e07bcb8bb 100644 --- a/client/gui/ShortcutHandler.cpp +++ b/client/gui/ShortcutHandler.cpp @@ -171,6 +171,8 @@ EShortcut ShortcutHandler::findShortcut(const std::string & identifier ) const {"gameActivateConsole", EShortcut::GAME_ACTIVATE_CONSOLE }, {"adventureGameOptions", EShortcut::ADVENTURE_GAME_OPTIONS }, {"adventureToggleGrid", EShortcut::ADVENTURE_TOGGLE_GRID }, + {"adventureToggleVisitable", EShortcut::ADVENTURE_TOGGLE_VISITABLE}, + {"adventureToggleBlocked", EShortcut::ADVENTURE_TOGGLE_BLOCKED }, {"adventureToggleSleep", EShortcut::ADVENTURE_TOGGLE_SLEEP }, {"adventureSetHeroAsleep", EShortcut::ADVENTURE_SET_HERO_ASLEEP }, {"adventureSetHeroAwake", EShortcut::ADVENTURE_SET_HERO_AWAKE }, diff --git a/config/shortcutsConfig.json b/config/shortcutsConfig.json index 817d89b96..fd57c1a80 100644 --- a/config/shortcutsConfig.json +++ b/config/shortcutsConfig.json @@ -40,6 +40,8 @@ "adventureSetHeroAwake": "W", "adventureThievesGuild": "G", "adventureToggleGrid": "F6", + "adventureToggleVisitable": [], + "adventureToggleBlocked": [], "adventureToggleMapLevel": "U", "adventureToggleSleep": [], "adventureTrackHero": "F5", From 2796931259385a5aea8a4384b83039170088c370 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sat, 20 Jul 2024 08:28:35 +0000 Subject: [PATCH 5/5] Fix credits scrolling --- client/mainmenu/CreditsScreen.cpp | 16 +++++++++------- client/mainmenu/CreditsScreen.h | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/client/mainmenu/CreditsScreen.cpp b/client/mainmenu/CreditsScreen.cpp index bd36ce98b..5811b7621 100644 --- a/client/mainmenu/CreditsScreen.cpp +++ b/client/mainmenu/CreditsScreen.cpp @@ -22,13 +22,15 @@ #include "../../AUTHORS.h" CreditsScreen::CreditsScreen(Rect rect) - : CIntObject(LCLICK), positionCounter(0) + : CIntObject(LCLICK), timePassed(0) { pos.w = rect.w; pos.h = rect.h; setRedrawParent(true); OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; + addUsedEvents(TIME); + std::string contributorsText = ""; std::string contributorsTask = ""; for (auto & element : contributors) @@ -48,15 +50,15 @@ CreditsScreen::CreditsScreen(Rect rect) credits->scrollTextTo(-600); // move all text below the screen } -void CreditsScreen::show(Canvas & to) +void CreditsScreen::tick(uint32_t msPassed) { - CIntObject::show(to); - positionCounter++; - if(positionCounter % 2 == 0) - credits->scrollTextBy(1); + static const int timeToScrollByOnePx = 20; + timePassed += msPassed; + int scrollPosition = timePassed / timeToScrollByOnePx - 600; + credits->scrollTextTo(scrollPosition); //end of credits, close this screen - if(credits->textSize.y + 600 < positionCounter / 2) + if(credits->textSize.y < scrollPosition) clickPressed(GH.getCursorPosition()); } diff --git a/client/mainmenu/CreditsScreen.h b/client/mainmenu/CreditsScreen.h index d6055cfd0..d70287363 100644 --- a/client/mainmenu/CreditsScreen.h +++ b/client/mainmenu/CreditsScreen.h @@ -15,11 +15,11 @@ class CMultiLineLabel; class CreditsScreen : public CIntObject { - int positionCounter; + int timePassed; std::shared_ptr credits; public: CreditsScreen(Rect rect); - void show(Canvas & to) override; + void tick(uint32_t msPassed) override; void clickPressed(const Point & cursorPosition) override; };