From 5396ced0a6d0babe96006b938aee38f6b7b8c045 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Fri, 27 Dec 2024 17:26:47 +0100 Subject: [PATCH 1/9] don't showing 3 buttons for sharpsh. upgr. (gelu) --- lib/gameState/UpgradeInfo.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/gameState/UpgradeInfo.cpp b/lib/gameState/UpgradeInfo.cpp index 03cfe2a6b..c4c6c288b 100644 --- a/lib/gameState/UpgradeInfo.cpp +++ b/lib/gameState/UpgradeInfo.cpp @@ -15,6 +15,9 @@ VCMI_LIB_NAMESPACE_BEGIN void UpgradeInfo::addUpgrade(const CreatureID & upgradeID, const Creature * creature, int costPercentageModifier) { + if(vstd::contains(upgradesIDs, upgradeID)) + return; + isAvailable = costPercentageModifier >= 0; upgradesIDs.push_back(upgradeID); From d657bd8e20356e891c1fb4540103e359b6736645 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Fri, 27 Dec 2024 17:59:54 +0100 Subject: [PATCH 2/9] fix campaign scenario order #3601 --- server/NetPacksLobbyServer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/NetPacksLobbyServer.cpp b/server/NetPacksLobbyServer.cpp index 33cc714ff..9e81db3b2 100644 --- a/server/NetPacksLobbyServer.cpp +++ b/server/NetPacksLobbyServer.cpp @@ -170,8 +170,10 @@ void ApplyOnServerNetPackVisitor::visitLobbySetCampaign(LobbySetCampaign & pack) bool isCurrentMapConquerable = pack.ourCampaign->currentScenario() && pack.ourCampaign->isAvailable(*pack.ourCampaign->currentScenario()); - for(auto scenarioID : pack.ourCampaign->allScenarios()) + auto scenarios = pack.ourCampaign->allScenarios(); + for(std::set::reverse_iterator itr = scenarios.rbegin(); itr != scenarios.rend(); itr++) // reverse -> on multiple scenario selection set lowest id at the end { + auto scenarioID = *itr; if(pack.ourCampaign->isAvailable(scenarioID)) { if(!isCurrentMapConquerable || (isCurrentMapConquerable && scenarioID == *pack.ourCampaign->currentScenario())) From 72f498f2c8f0f895aae1f45ff7a81abc5bf1a638 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Fri, 27 Dec 2024 18:57:34 +0100 Subject: [PATCH 3/9] add region blink #3601 --- client/lobby/CBonusSelection.cpp | 29 ++++++++++++++++++++++++++--- client/lobby/CBonusSelection.h | 9 ++++++++- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/client/lobby/CBonusSelection.cpp b/client/lobby/CBonusSelection.cpp index ced7705fd..3e27d660a 100644 --- a/client/lobby/CBonusSelection.cpp +++ b/client/lobby/CBonusSelection.cpp @@ -484,7 +484,7 @@ void CBonusSelection::decreaseDifficulty() } CBonusSelection::CRegion::CRegion(CampaignScenarioID id, bool accessible, bool selectable, bool labelOnly, const CampaignRegions & campDsc) - : CIntObject(LCLICK | SHOW_POPUP), idOfMapAndRegion(id), accessible(accessible), selectable(selectable), labelOnly(labelOnly) + : CIntObject(LCLICK | SHOW_POPUP | TIME), idOfMapAndRegion(id), accessible(accessible), selectable(selectable), labelOnly(labelOnly), blinkAnim({}) { OBJECT_CONSTRUCTION; @@ -509,12 +509,18 @@ CBonusSelection::CRegion::CRegion(CampaignScenarioID id, bool accessible, bool s } } -void CBonusSelection::CRegion::updateState() +void CBonusSelection::CRegion::updateState(bool disableAll) { if(labelOnly) return; - if(!accessible) + if(disableAll) + { + graphicsNotSelected->disable(); + graphicsSelected->disable(); + graphicsStriped->disable(); + } + else if(!accessible) { graphicsNotSelected->disable(); graphicsSelected->disable(); @@ -534,6 +540,23 @@ void CBonusSelection::CRegion::updateState() } } +void CBonusSelection::CRegion::tick(uint32_t msPassed) +{ + blinkAnim.msPassed += msPassed; + if(blinkAnim.msPassed >= 150) + { + blinkAnim.state = !blinkAnim.state; + blinkAnim.msPassed -= 150; + if(blinkAnim.state) + blinkAnim.count++; + else if(blinkAnim.count >= 3) + removeUsedEvents(TIME); + } + updateState(blinkAnim.state); + setRedrawParent(true); + redraw(); +} + void CBonusSelection::CRegion::clickReleased(const Point & cursorPosition) { if(!labelOnly && selectable && !graphicsNotSelected->getSurface()->isTransparent(cursorPosition - pos.topLeft())) diff --git a/client/lobby/CBonusSelection.h b/client/lobby/CBonusSelection.h index 7b26bcc88..8d5b77c15 100644 --- a/client/lobby/CBonusSelection.h +++ b/client/lobby/CBonusSelection.h @@ -51,9 +51,16 @@ public: bool selectable; // true if region should be selectable bool labelOnly; std::shared_ptr label; + struct BlinkAnim + { + uint32_t msPassed; + uint32_t count; + bool state; + } blinkAnim; public: CRegion(CampaignScenarioID id, bool accessible, bool selectable, bool labelOnly, const CampaignRegions & campDsc); - void updateState(); + void updateState(bool disableAll = false); + void tick(uint32_t msPassed) override; void clickReleased(const Point & cursorPosition) override; void showPopupWindow(const Point & cursorPosition) override; }; From 97e2480e7df362136f3837693c1efafbb2d1c0ad Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Fri, 27 Dec 2024 19:09:01 +0100 Subject: [PATCH 4/9] blink only accessible scenarios --- client/lobby/CBonusSelection.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/lobby/CBonusSelection.cpp b/client/lobby/CBonusSelection.cpp index 3e27d660a..d6bdd7ba4 100644 --- a/client/lobby/CBonusSelection.cpp +++ b/client/lobby/CBonusSelection.cpp @@ -542,6 +542,12 @@ void CBonusSelection::CRegion::updateState(bool disableAll) void CBonusSelection::CRegion::tick(uint32_t msPassed) { + if(!accessible) + { + removeUsedEvents(TIME); + return; + } + blinkAnim.msPassed += msPassed; if(blinkAnim.msPassed >= 150) { From 50d3e71468f3827d41ef19f26f31262dfd004de2 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Fri, 27 Dec 2024 20:17:43 +0100 Subject: [PATCH 5/9] fix surrender video --- client/battle/BattleInterfaceClasses.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/battle/BattleInterfaceClasses.cpp b/client/battle/BattleInterfaceClasses.cpp index 30f687919..596bdbd1e 100644 --- a/client/battle/BattleInterfaceClasses.cpp +++ b/client/battle/BattleInterfaceClasses.cpp @@ -908,7 +908,7 @@ BattleResultResources BattleResultWindow::getResources(const BattleResult & br) case EBattleResult::SURRENDER: resources.resultText.appendTextID("core.genrltxt.309"); resources.musicName = AudioPath::builtin("Music/Surrender Battle"); - resources.prologueVideo = VideoPath(); + resources.prologueVideo = VideoPath::builtin("SURRENDER.BIK"); resources.loopedVideo = VideoPath::builtin("SURRENDER.BIK"); break; default: From 7dba34c16efec3cd265f1dcdae651c9d86159441 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Fri, 27 Dec 2024 21:22:45 +0100 Subject: [PATCH 6/9] campaign list workaround --- client/NetPacksLobbyClient.cpp | 2 +- client/lobby/CLobbyScreen.cpp | 9 ++++++++- client/lobby/CLobbyScreen.h | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/client/NetPacksLobbyClient.cpp b/client/NetPacksLobbyClient.cpp index 49c86f11d..3c5fc26a2 100644 --- a/client/NetPacksLobbyClient.cpp +++ b/client/NetPacksLobbyClient.cpp @@ -78,7 +78,7 @@ void ApplyOnLobbyHandlerNetPackVisitor::visitLobbyClientConnected(LobbyClientCon GH.windows().popWindows(1); } - GH.windows().createAndPushWindow(handler.screenType); + GH.windows().createAndPushWindow(handler.screenType, handler.campaignStateToSend && !handler.campaignStateToSend->campaignSet.empty()); } handler.setState(EClientState::LOBBY); } diff --git a/client/lobby/CLobbyScreen.cpp b/client/lobby/CLobbyScreen.cpp index ead6f3ef3..56b375300 100644 --- a/client/lobby/CLobbyScreen.cpp +++ b/client/lobby/CLobbyScreen.cpp @@ -21,6 +21,7 @@ #include "../gui/CGuiHandler.h" #include "../gui/Shortcut.h" #include "../widgets/Buttons.h" +#include "../widgets/GraphicalPrimitiveCanvas.h" #include "../windows/InfoWindows.h" #include "../render/Colors.h" #include "../globalLobby/GlobalLobbyClient.h" @@ -35,7 +36,7 @@ #include "../../lib/rmg/CMapGenOptions.h" #include "../CGameInfo.h" -CLobbyScreen::CLobbyScreen(ESelectionScreen screenType) +CLobbyScreen::CLobbyScreen(ESelectionScreen screenType, bool fromCampaignSet) : CSelectionBase(screenType), bonusSel(nullptr) { OBJECT_CONSTRUCTION; @@ -114,6 +115,12 @@ CLobbyScreen::CLobbyScreen(ESelectionScreen screenType) if (wasInLobbyRoom) CSH->getGlobalLobby().activateInterface(); }, EShortcut::GLOBAL_CANCEL); + + if(fromCampaignSet) // workaround to avoid confusing players by custom campaign list displaying for a few ms -> instead of this draw a black screen while "loading" + { + blackScreen = std::make_shared(Rect(Point(0, 0), pos.dimensions())); + blackScreen->addBox(Point(0, 0), pos.dimensions(), Colors::BLACK); + } } CLobbyScreen::~CLobbyScreen() diff --git a/client/lobby/CLobbyScreen.h b/client/lobby/CLobbyScreen.h index db42d9600..73de37340 100644 --- a/client/lobby/CLobbyScreen.h +++ b/client/lobby/CLobbyScreen.h @@ -12,13 +12,15 @@ #include "CSelectionBase.h" class CBonusSelection; +class GraphicalPrimitiveCanvas; class CLobbyScreen final : public CSelectionBase { public: std::shared_ptr buttonChat; + std::shared_ptr blackScreen; - CLobbyScreen(ESelectionScreen type); + CLobbyScreen(ESelectionScreen type, bool fromCampaignSet = false); ~CLobbyScreen(); void toggleTab(std::shared_ptr tab) final; void startCampaign(); From 0db8794d8b51090b95aca9aa5dbdb59a01c8c716 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Fri, 27 Dec 2024 21:40:09 +0100 Subject: [PATCH 7/9] hide screen also for second custom campaign scen. --- client/NetPacksLobbyClient.cpp | 3 ++- client/lobby/CLobbyScreen.cpp | 4 ++-- client/lobby/CLobbyScreen.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/NetPacksLobbyClient.cpp b/client/NetPacksLobbyClient.cpp index 3c5fc26a2..015fd856f 100644 --- a/client/NetPacksLobbyClient.cpp +++ b/client/NetPacksLobbyClient.cpp @@ -78,7 +78,8 @@ void ApplyOnLobbyHandlerNetPackVisitor::visitLobbyClientConnected(LobbyClientCon GH.windows().popWindows(1); } - GH.windows().createAndPushWindow(handler.screenType, handler.campaignStateToSend && !handler.campaignStateToSend->campaignSet.empty()); + bool hideScreen = handler.campaignStateToSend && (!handler.campaignStateToSend->campaignSet.empty() || handler.campaignStateToSend->lastScenario()); + GH.windows().createAndPushWindow(handler.screenType, hideScreen); } handler.setState(EClientState::LOBBY); } diff --git a/client/lobby/CLobbyScreen.cpp b/client/lobby/CLobbyScreen.cpp index 56b375300..adc47a8c5 100644 --- a/client/lobby/CLobbyScreen.cpp +++ b/client/lobby/CLobbyScreen.cpp @@ -36,7 +36,7 @@ #include "../../lib/rmg/CMapGenOptions.h" #include "../CGameInfo.h" -CLobbyScreen::CLobbyScreen(ESelectionScreen screenType, bool fromCampaignSet) +CLobbyScreen::CLobbyScreen(ESelectionScreen screenType, bool hideScreen) : CSelectionBase(screenType), bonusSel(nullptr) { OBJECT_CONSTRUCTION; @@ -116,7 +116,7 @@ CLobbyScreen::CLobbyScreen(ESelectionScreen screenType, bool fromCampaignSet) CSH->getGlobalLobby().activateInterface(); }, EShortcut::GLOBAL_CANCEL); - if(fromCampaignSet) // workaround to avoid confusing players by custom campaign list displaying for a few ms -> instead of this draw a black screen while "loading" + if(hideScreen) // workaround to avoid confusing players by custom campaign list displaying for a few ms -> instead of this draw a black screen while "loading" { blackScreen = std::make_shared(Rect(Point(0, 0), pos.dimensions())); blackScreen->addBox(Point(0, 0), pos.dimensions(), Colors::BLACK); diff --git a/client/lobby/CLobbyScreen.h b/client/lobby/CLobbyScreen.h index 73de37340..d8377b5d8 100644 --- a/client/lobby/CLobbyScreen.h +++ b/client/lobby/CLobbyScreen.h @@ -20,7 +20,7 @@ public: std::shared_ptr buttonChat; std::shared_ptr blackScreen; - CLobbyScreen(ESelectionScreen type, bool fromCampaignSet = false); + CLobbyScreen(ESelectionScreen type, bool hideScreen = false); ~CLobbyScreen(); void toggleTab(std::shared_ptr tab) final; void startCampaign(); From f72084cb26e8c733c257b12c5b52ff307d10de66 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Sun, 29 Dec 2024 03:15:58 +0100 Subject: [PATCH 8/9] fix upgrades --- lib/gameState/UpgradeInfo.cpp | 3 --- lib/mapObjects/CGHeroInstance.cpp | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/gameState/UpgradeInfo.cpp b/lib/gameState/UpgradeInfo.cpp index c4c6c288b..03cfe2a6b 100644 --- a/lib/gameState/UpgradeInfo.cpp +++ b/lib/gameState/UpgradeInfo.cpp @@ -15,9 +15,6 @@ VCMI_LIB_NAMESPACE_BEGIN void UpgradeInfo::addUpgrade(const CreatureID & upgradeID, const Creature * creature, int costPercentageModifier) { - if(vstd::contains(upgradesIDs, upgradeID)) - return; - isAvailable = costPercentageModifier >= 0; upgradesIDs.push_back(upgradeID); diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index 81ef94c21..4d23a8ae7 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -1893,7 +1893,7 @@ bool CGHeroInstance::isMissionCritical() const void CGHeroInstance::fillUpgradeInfo(UpgradeInfo & info, const CStackInstance & stack) const { - TConstBonusListPtr lista = getBonusesOfType(BonusType::SPECIAL_UPGRADE, BonusSubtypeID(stack.getId())); + TConstBonusListPtr lista = getBonuses(Selector::typeSubtype(BonusType::SPECIAL_UPGRADE, BonusSubtypeID(stack.getId()))); for(const auto & it : *lista) { auto nid = CreatureID(it->additionalInfo[0]); From 5c6ce47371c2984a1e1db62b68f40ac6a0ce7319 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Mon, 30 Dec 2024 18:08:49 +0100 Subject: [PATCH 9/9] better fix --- lib/bonuses/IBonusBearer.cpp | 2 +- lib/mapObjects/CGHeroInstance.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bonuses/IBonusBearer.cpp b/lib/bonuses/IBonusBearer.cpp index fa3f8b250..2e6f29d12 100644 --- a/lib/bonuses/IBonusBearer.cpp +++ b/lib/bonuses/IBonusBearer.cpp @@ -59,7 +59,7 @@ TConstBonusListPtr IBonusBearer::getBonusesOfType(BonusType type) const TConstBonusListPtr IBonusBearer::getBonusesOfType(BonusType type, BonusSubtypeID subtype) const { std::string cachingStr = "type_" + std::to_string(static_cast(type)) + "_" + subtype.toString(); - CSelector s = Selector::type()(type); + CSelector s = Selector::typeSubtype(type, subtype); return getBonuses(s, cachingStr); } diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index 4d23a8ae7..81ef94c21 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -1893,7 +1893,7 @@ bool CGHeroInstance::isMissionCritical() const void CGHeroInstance::fillUpgradeInfo(UpgradeInfo & info, const CStackInstance & stack) const { - TConstBonusListPtr lista = getBonuses(Selector::typeSubtype(BonusType::SPECIAL_UPGRADE, BonusSubtypeID(stack.getId()))); + TConstBonusListPtr lista = getBonusesOfType(BonusType::SPECIAL_UPGRADE, BonusSubtypeID(stack.getId())); for(const auto & it : *lista) { auto nid = CreatureID(it->additionalInfo[0]);