mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-17 00:07:41 +02:00
misc slots. fixed combined arts moving
This commit is contained in:
@ -149,19 +149,12 @@ void CHeroArtPlace::clickLeft(tribool down, bool previousState)
|
|||||||
select();
|
select();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(ourArt == ourOwner->commonInfo->src.art) //restore previously picked artifact
|
// Perform artifact transition
|
||||||
{
|
else if(ourArt != ourOwner->commonInfo->src.art)
|
||||||
deselect();
|
|
||||||
}
|
|
||||||
else //perform artifact transition
|
|
||||||
{
|
{
|
||||||
if(inBackpack) // Backpack destination.
|
if(inBackpack) // Backpack destination.
|
||||||
{
|
{
|
||||||
if(srcInBackpack && slotID == ourOwner->commonInfo->src.slotID + 1) //next slot (our is not visible, so visually same as "old" place) to the art -> make nothing, return artifact to slot
|
if(!srcInBackpack || slotID != ourOwner->commonInfo->src.slotID + 1)
|
||||||
{
|
|
||||||
deselect();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
const CArtifact * const cur = ourOwner->commonInfo->src.art->artType;
|
const CArtifact * const cur = ourOwner->commonInfo->src.art->artType;
|
||||||
|
|
||||||
@ -186,9 +179,7 @@ void CHeroArtPlace::clickLeft(tribool down, bool previousState)
|
|||||||
|| ourOwner->commonInfo->src.slotID < ourOwner->commonInfo->dst.slotID) //rearranging arts in backpack after taking src artifact, the dest id will be shifted
|
|| ourOwner->commonInfo->src.slotID < ourOwner->commonInfo->dst.slotID) //rearranging arts in backpack after taking src artifact, the dest id will be shifted
|
||||||
vstd::advance(ourOwner->commonInfo->dst.slotID, -1);
|
vstd::advance(ourOwner->commonInfo->dst.slotID, -1);
|
||||||
}
|
}
|
||||||
if(srcInSameHero && ourOwner->commonInfo->dst.slotID == ourOwner->commonInfo->src.slotID) //we came to src == dst
|
if(!srcInSameHero || ourOwner->commonInfo->dst.slotID != ourOwner->commonInfo->src.slotID)
|
||||||
deselect();
|
|
||||||
else
|
|
||||||
ourOwner->realizeCurrentTransaction();
|
ourOwner->realizeCurrentTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -274,13 +265,13 @@ void CArtifactsOfHero::deactivate()
|
|||||||
/**
|
/**
|
||||||
* Selects artifact slot so that the containing artifact looks like it's picked up.
|
* Selects artifact slot so that the containing artifact looks like it's picked up.
|
||||||
*/
|
*/
|
||||||
void CHeroArtPlace::select ()
|
void CHeroArtPlace::select()
|
||||||
{
|
{
|
||||||
if (locked)
|
if(locked)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pickSlot(true);
|
pickSlot(true);
|
||||||
if(ourArt->canBeDisassembled() && slotID < GameConstants::BACKPACK_START) //worn combined artifact -> locks have to disappear
|
if(ourArt->canBeDisassembled() && ArtifactUtils::isSlotEquipment(slotID)) //worn combined artifact -> locks have to disappear
|
||||||
{
|
{
|
||||||
for(auto slot : ArtifactUtils::constituentWornSlots())
|
for(auto slot : ArtifactUtils::constituentWornSlots())
|
||||||
{
|
{
|
||||||
@ -292,41 +283,10 @@ void CHeroArtPlace::select ()
|
|||||||
|
|
||||||
CCS->curh->dragAndDropCursor("artifact", ourArt->artType->getIconIndex());
|
CCS->curh->dragAndDropCursor("artifact", ourArt->artType->getIconIndex());
|
||||||
ourOwner->commonInfo->src.setTo(this, false);
|
ourOwner->commonInfo->src.setTo(this, false);
|
||||||
ourOwner->markPossibleSlots(ourArt);
|
ourOwner->commonInfo->src.slotID = ArtifactPosition::TRANSITION_POS;
|
||||||
|
|
||||||
if(slotID >= GameConstants::BACKPACK_START)
|
LOCPLINT->cb->swapArtifacts(ArtifactLocation(ourOwner->curHero, slotID),
|
||||||
ourOwner->scrollBackpack(0); //will update slots
|
ArtifactLocation(ourOwner->curHero, ArtifactPosition::TRANSITION_POS));
|
||||||
|
|
||||||
ourOwner->updateParentWindow();
|
|
||||||
ourOwner->safeRedraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deselects the artifact slot.
|
|
||||||
*/
|
|
||||||
void CHeroArtPlace::deselect ()
|
|
||||||
{
|
|
||||||
pickSlot(false);
|
|
||||||
if(ourArt && ourArt->canBeDisassembled()) //combined art returned to its slot -> restore locks
|
|
||||||
{
|
|
||||||
for(auto slot : ArtifactUtils::constituentWornSlots())
|
|
||||||
{
|
|
||||||
auto place = ourOwner->getArtPlace(slot);
|
|
||||||
|
|
||||||
if(nullptr != place)//getArtPlace may return null
|
|
||||||
place->pickSlot(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CCS->curh->dragAndDropCursor(nullptr);
|
|
||||||
ourOwner->unmarkSlots();
|
|
||||||
ourOwner->commonInfo->src.clear();
|
|
||||||
if(slotID >= GameConstants::BACKPACK_START)
|
|
||||||
ourOwner->scrollBackpack(0); //will update slots
|
|
||||||
|
|
||||||
|
|
||||||
ourOwner->updateParentWindow();
|
|
||||||
ourOwner->safeRedraw();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHeroArtPlace::showAll(SDL_Surface * to)
|
void CHeroArtPlace::showAll(SDL_Surface * to)
|
||||||
@ -760,35 +720,41 @@ void CArtifactsOfHero::artifactMoved(const ArtifactLocation & src, const Artifac
|
|||||||
commonInfo->src.slotID = src.slot;
|
commonInfo->src.slotID = src.slot;
|
||||||
}
|
}
|
||||||
// Artifact was taken from us
|
// Artifact was taken from us
|
||||||
else if(commonInfo->src == src)
|
else if(commonInfo->src == src && dst.slot != ArtifactPosition::TRANSITION_POS)
|
||||||
{
|
{
|
||||||
// Expected movement from slot ot slot
|
// Expected movement from slot ot slot
|
||||||
assert(commonInfo->dst == dst
|
assert(commonInfo->dst == dst
|
||||||
// Artifact moved back to backpack (eg. to make place for art we are moving)
|
// Artifact moved back to backpack (eg. to make place for art we are moving)
|
||||||
|| dst.slot == dst.getHolderArtSet()->artifactsInBackpack.size() + GameConstants::BACKPACK_START
|
|| dst.slot == dst.getHolderArtSet()->artifactsInBackpack.size() + GameConstants::BACKPACK_START
|
||||||
|| dst.getHolderArtSet()->bearerType() != ArtBearer::HERO);
|
|| dst.getHolderArtSet()->bearerType() != ArtBearer::HERO);
|
||||||
commonInfo->reset();
|
commonInfo->reset();
|
||||||
unmarkSlots();
|
unmarkSlots();
|
||||||
}
|
}
|
||||||
// The dest artifact was moved after the swap -> we are picking it
|
else
|
||||||
else if(commonInfo->dst == src)
|
|
||||||
{
|
{
|
||||||
assert(dst.slot == ArtifactPosition::TRANSITION_POS);
|
// The dest artifact was moved after the swap -> we are picking it
|
||||||
commonInfo->reset();
|
if(commonInfo->dst == src)
|
||||||
|
|
||||||
for(CArtifactsOfHero * aoh : commonInfo->participants)
|
|
||||||
{
|
{
|
||||||
if(dst.isHolder(aoh->curHero))
|
assert(dst.slot == ArtifactPosition::TRANSITION_POS);
|
||||||
{
|
commonInfo->reset();
|
||||||
commonInfo->src.AOH = aoh;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
commonInfo->src.art = dst.getArt();
|
for(CArtifactsOfHero * aoh : commonInfo->participants)
|
||||||
commonInfo->src.slotID = dst.slot;
|
{
|
||||||
assert(commonInfo->src.AOH);
|
if(dst.isHolder(aoh->curHero))
|
||||||
CCS->curh->dragAndDropCursor("artifact", dst.getArt()->artType->getIconIndex());
|
{
|
||||||
|
commonInfo->src.AOH = aoh;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
commonInfo->src.art = dst.getArt();
|
||||||
|
commonInfo->src.slotID = dst.slot;
|
||||||
|
assert(commonInfo->src.AOH);
|
||||||
|
CCS->curh->dragAndDropCursor("artifact", dst.getArt()->artType->getIconIndex());
|
||||||
|
}
|
||||||
|
auto art = dst.getArt();
|
||||||
|
if(art && dst.slot == ArtifactPosition::TRANSITION_POS)
|
||||||
|
markPossibleSlots(art);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateParentWindow();
|
updateParentWindow();
|
||||||
|
@ -90,7 +90,6 @@ public:
|
|||||||
void clickLeft(tribool down, bool previousState) override;
|
void clickLeft(tribool down, bool previousState) override;
|
||||||
void clickRight(tribool down, bool previousState) override;
|
void clickRight(tribool down, bool previousState) override;
|
||||||
void select();
|
void select();
|
||||||
void deselect();
|
|
||||||
void showAll(SDL_Surface * to) override;
|
void showAll(SDL_Surface * to) override;
|
||||||
bool fitsHere (const CArtifactInstance * art) const; //returns true if given artifact can be placed here
|
bool fitsHere (const CArtifactInstance * art) const; //returns true if given artifact can be placed here
|
||||||
|
|
||||||
|
@ -1365,8 +1365,10 @@ const ArtSlotInfo * CArtifactSet::getSlot(ArtifactPosition pos) const
|
|||||||
if(pos == ArtifactPosition::TRANSITION_POS)
|
if(pos == ArtifactPosition::TRANSITION_POS)
|
||||||
{
|
{
|
||||||
// Always add to the end. Always take from the beginning.
|
// Always add to the end. Always take from the beginning.
|
||||||
assert(!artifactsTransitionPos.empty());
|
if(artifactsTransitionPos.empty())
|
||||||
return &(*artifactsTransitionPos.begin());
|
return nullptr;
|
||||||
|
else
|
||||||
|
return &(*artifactsTransitionPos.begin());
|
||||||
}
|
}
|
||||||
if(vstd::contains(artifactsWorn, pos))
|
if(vstd::contains(artifactsWorn, pos))
|
||||||
return &artifactsWorn.at(pos);
|
return &artifactsWorn.at(pos);
|
||||||
|
Reference in New Issue
Block a user