From 8d4b74b441b4ce9fe56424439f5631054114714d Mon Sep 17 00:00:00 2001 From: SoundSSGood <87084363+SoundSSGood@users.noreply.github.com> Date: Thu, 18 Jan 2024 12:49:08 +0200 Subject: [PATCH 1/2] Assembling in backpack fixed --- lib/CArtHandler.cpp | 2 +- server/CGameHandler.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/CArtHandler.cpp b/lib/CArtHandler.cpp index c6c4b0e6f..814e2fe5c 100644 --- a/lib/CArtHandler.cpp +++ b/lib/CArtHandler.cpp @@ -183,7 +183,7 @@ bool CArtifact::canBePutAt(const CArtifactSet * artSet, ArtifactPosition slot, b { if(ArtifactUtils::isSlotBackpack(slot)) { - if(isBig() || !ArtifactUtils::isBackpackFreeSlots(artSet)) + if(isBig() || (!assumeDestRemoved && !ArtifactUtils::isBackpackFreeSlots(artSet))) return false; return true; } diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index a19375da1..34ca599a0 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -2870,8 +2870,8 @@ bool CGameHandler::assembleArtifacts(ObjectInstanceID heroID, ArtifactPosition a { COMPLAIN_RET("assembleArtifacts: It's impossible to assemble requested artifact!"); } - if(!destArtifact->canBePutAt(hero, artifactSlot) - && !destArtifact->canBePutAt(hero, ArtifactPosition::BACKPACK_START)) + if(!destArtifact->canBePutAt(hero, artifactSlot, true) + && !destArtifact->canBePutAt(hero, ArtifactPosition::BACKPACK_START, true)) { COMPLAIN_RET("assembleArtifacts: It's impossible to give the artholder requested artifact!"); } From a753319ad0cc2a1ade2102859a6095a1c1a89bfd Mon Sep 17 00:00:00 2001 From: SoundSSGood <87084363+SoundSSGood@users.noreply.github.com> Date: Thu, 18 Jan 2024 13:42:52 +0200 Subject: [PATCH 2/2] backpack window statusbar --- client/widgets/CWindowWithArtifacts.cpp | 3 +++ client/windows/CHeroBackpackWindow.cpp | 9 +++++++-- client/windows/CHeroBackpackWindow.h | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/client/widgets/CWindowWithArtifacts.cpp b/client/widgets/CWindowWithArtifacts.cpp index 360d896de..0902df564 100644 --- a/client/widgets/CWindowWithArtifacts.cpp +++ b/client/widgets/CWindowWithArtifacts.cpp @@ -279,6 +279,9 @@ void CWindowWithArtifacts::gestureArtPlaceHero(CArtifactsOfHeroBase & artsInst, std::is_same_v> || std::is_same_v>) { + if(!settings["general"]["enableUiEnhancements"].Bool()) + return; + GH.windows().createAndPushWindow(artSetPtr->getHero(), artPlace.slot); auto backpackWindow = GH.windows().topWindow(); backpackWindow->moveTo(cursorPosition - Point(1, 1)); diff --git a/client/windows/CHeroBackpackWindow.cpp b/client/windows/CHeroBackpackWindow.cpp index 82186774d..250f4d00f 100644 --- a/client/windows/CHeroBackpackWindow.cpp +++ b/client/windows/CHeroBackpackWindow.cpp @@ -15,12 +15,13 @@ #include "../widgets/Buttons.h" #include "../widgets/Images.h" +#include "../widgets/TextControls.h" #include "CMessage.h" #include "render/Canvas.h" #include "CPlayerInterface.h" CHeroBackpackWindow::CHeroBackpackWindow(const CGHeroInstance * hero) - : CWindowObject((EOptions)0) + : CStatusbarWindow((EOptions)0) { OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE); @@ -30,10 +31,14 @@ CHeroBackpackWindow::CHeroBackpackWindow(const CGHeroInstance * hero) addSetAndCallbacks(arts); arts->setHero(hero); addCloseCallback(std::bind(&CHeroBackpackWindow::close, this)); - quitButton = std::make_shared(Point(), AnimationPath::builtin("IOKAY32.def"), CButton::tooltip(""), [this]() { close(); }, EShortcut::GLOBAL_RETURN); + quitButton = std::make_shared(Point(), AnimationPath::builtin("IOKAY32.def"), CButton::tooltip(""), + [this]() { WindowBase::close(); }, EShortcut::GLOBAL_RETURN); pos.w = stretchedBackground->pos.w = arts->pos.w + 2 * windowMargin; pos.h = stretchedBackground->pos.h = arts->pos.h + quitButton->pos.h + 3 * windowMargin; quitButton->moveTo(Point(pos.x + pos.w / 2 - quitButton->pos.w / 2, pos.y + arts->pos.h + 2 * windowMargin)); + statusbar = CGStatusBar::create(0, pos.h, ImagePath::builtin("ADROLLVR.bmp"), pos.w); + pos.h += statusbar->pos.h; + center(); } diff --git a/client/windows/CHeroBackpackWindow.h b/client/windows/CHeroBackpackWindow.h index 894d13343..9126e320c 100644 --- a/client/windows/CHeroBackpackWindow.h +++ b/client/windows/CHeroBackpackWindow.h @@ -14,7 +14,7 @@ class CFilledTexture; -class CHeroBackpackWindow : public CWindowObject, public CWindowWithArtifacts +class CHeroBackpackWindow : public CStatusbarWindow, public CWindowWithArtifacts { public: CHeroBackpackWindow(const CGHeroInstance * hero);