|
@@ -960,7 +960,7 @@ void CArtPlace::clickRight(tribool down, bool previousState)
|
|
LRClickableAreaWTextComp::clickRight(down, previousState);
|
|
LRClickableAreaWTextComp::clickRight(down, previousState);
|
|
}
|
|
}
|
|
|
|
|
|
-CCommanderArtPlace::CCommanderArtPlace(Point position, const CArtifactInstance * Art) : CArtPlace(position, Art)
|
|
|
|
|
|
+CCommanderArtPlace::CCommanderArtPlace(Point position, const CGHeroInstance * commanderOwner, ArtifactPosition artSlot, const CArtifactInstance * Art) : CArtPlace(position, Art), commanderOwner(commanderOwner), commanderSlotID(artSlot.num)
|
|
{
|
|
{
|
|
createImage();
|
|
createImage();
|
|
setArtifact(Art);
|
|
setArtifact(Art);
|
|
@@ -968,8 +968,9 @@ CCommanderArtPlace::CCommanderArtPlace(Point position, const CArtifactInstance *
|
|
|
|
|
|
void CCommanderArtPlace::clickLeft(tribool down, bool previousState)
|
|
void CCommanderArtPlace::clickLeft(tribool down, bool previousState)
|
|
{
|
|
{
|
|
- if(ourArt && text.size())
|
|
|
|
- CArtPlace::clickLeft(down, previousState);
|
|
|
|
|
|
+ if (down && ourArt && text.size())
|
|
|
|
+ LOCPLINT->showYesNoDialog("Do you want to give this artifact back to hero?", [this] { returnArtToHeroCallback(); }, [] {});
|
|
|
|
+ //CArtPlace::clickLeft(down, previousState);
|
|
}
|
|
}
|
|
|
|
|
|
void CCommanderArtPlace::clickRight(tribool down, bool previousState)
|
|
void CCommanderArtPlace::clickRight(tribool down, bool previousState)
|
|
@@ -991,6 +992,22 @@ void CCommanderArtPlace::createImage()
|
|
image->disable();
|
|
image->disable();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void CCommanderArtPlace::returnArtToHeroCallback()
|
|
|
|
+{
|
|
|
|
+ ArtifactPosition artifactPos = commanderSlotID;;
|
|
|
|
+ ArtifactPosition freeSlot = ourArt->firstBackpackSlot(commanderOwner);
|
|
|
|
+
|
|
|
|
+ ArtifactLocation src(commanderOwner->commander.get(), artifactPos);
|
|
|
|
+ ArtifactLocation dst(commanderOwner, freeSlot);
|
|
|
|
+
|
|
|
|
+ if (ourArt->canBePutAt(dst, true))
|
|
|
|
+ {
|
|
|
|
+ LOCPLINT->cb->swapArtifacts(src, dst);
|
|
|
|
+ setArtifact(nullptr);
|
|
|
|
+ parent->redraw();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
void CCommanderArtPlace::setArtifact(const CArtifactInstance * art)
|
|
void CCommanderArtPlace::setArtifact(const CArtifactInstance * art)
|
|
{
|
|
{
|
|
baseType = -1; //by default we don't store any component
|
|
baseType = -1; //by default we don't store any component
|