mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Cleanup of stack artifacts code
This commit is contained in:
@@ -171,6 +171,36 @@ std::string CStackWindow::generateStackExpDescription()
|
|||||||
return expText;
|
return expText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CStackWindow::removeStackArtifact(ArtifactPosition pos)
|
||||||
|
{
|
||||||
|
auto art = info->stackNode->getArt(ArtifactPosition::CREATURE_SLOT);
|
||||||
|
LOCPLINT->cb->swapArtifacts(ArtifactLocation(info->stackNode, pos),
|
||||||
|
ArtifactLocation(info->owner, art->firstBackpackSlot(info->owner)));
|
||||||
|
delete stackArtifactButton;
|
||||||
|
delete stackArtifactHelp;
|
||||||
|
delete stackArtifactIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CStackWindow::setStackArtifact(const CArtifactInstance * art, Point artPos)
|
||||||
|
{
|
||||||
|
if (art)
|
||||||
|
{
|
||||||
|
stackArtifactIcon = new CAnimImage("ARTIFACT", art->artType->iconIndex, 0, pos.x, pos.y);
|
||||||
|
stackArtifactHelp = new LRClickableAreaWTextComp(Rect(artPos, Point(44, 44)), CComponent::artifact);
|
||||||
|
stackArtifactHelp->type = art->artType->id;
|
||||||
|
|
||||||
|
const JsonNode & text = VLC->generaltexth->localizedTexts["creatureWindow"]["returnArtifact"];
|
||||||
|
|
||||||
|
if (info->owner)
|
||||||
|
{
|
||||||
|
stackArtifactButton = new CAdventureMapButton(text["label"].String(), text["help"].String(),[=]{
|
||||||
|
removeStackArtifact(ArtifactPosition::CREATURE_SLOT);
|
||||||
|
}, artPos.x - 2 , artPos.y + 46, "stackWindow/cancelButton");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void CStackWindow::CWindowSection::createStackInfo(bool showExp, bool showArt)
|
void CStackWindow::CWindowSection::createStackInfo(bool showExp, bool showArt)
|
||||||
{
|
{
|
||||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||||
@@ -226,31 +256,10 @@ void CStackWindow::CWindowSection::createStackInfo(bool showExp, bool showArt)
|
|||||||
auto luck = new MoraleLuckBox(false, genRect(42, 42, 375, 110));
|
auto luck = new MoraleLuckBox(false, genRect(42, 42, 375, 110));
|
||||||
luck->set(parent->info->stackNode);
|
luck->set(parent->info->stackNode);
|
||||||
|
|
||||||
//TODO: TEST
|
|
||||||
//TODO: delete "pass artifact" button on removal
|
|
||||||
//TODO: refactor into give art / take art methods
|
|
||||||
if (showArt)
|
if (showArt)
|
||||||
{
|
{
|
||||||
const CStackInstance * stack = parent->info->stackNode;
|
Point pos = showExp ? Point(375, 32) : Point(347, 32);
|
||||||
if (stack->getArt(ArtifactPosition::CREATURE_SLOT))
|
parent->setStackArtifact(parent->info->stackNode->getArt(ArtifactPosition::CREATURE_SLOT), pos);
|
||||||
{
|
|
||||||
auto art = stack->getArt(ArtifactPosition::CREATURE_SLOT);
|
|
||||||
|
|
||||||
Point pos = showExp ? Point(375, 32) : Point(347, 32);
|
|
||||||
parent->stackArtifactIcon = new CAnimImage("ARTIFACT", art->artType->iconIndex, 0, pos.x, pos.y);
|
|
||||||
parent->stackArtifactHelp = new LRClickableAreaWTextComp(Rect(pos, Point(44, 44)), CComponent::artifact);
|
|
||||||
parent->stackArtifactHelp->type = art->artType->id;
|
|
||||||
|
|
||||||
const JsonNode & text = VLC->generaltexth->localizedTexts["creatureWindow"]["returnArtifact"];
|
|
||||||
|
|
||||||
if (parent->info->owner)
|
|
||||||
{
|
|
||||||
new CAdventureMapButton(text["label"].String(), text["help"].String(),[=]{
|
|
||||||
LOCPLINT->cb->swapArtifacts(ArtifactLocation(stack, ArtifactPosition::CREATURE_SLOT),
|
|
||||||
ArtifactLocation(parent->info->owner, art->firstBackpackSlot(parent->info->owner)));
|
|
||||||
}, pos.x - 2 , pos.y + 46, "stackWindow/cancelButton");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showExp)
|
if (showExp)
|
||||||
@@ -404,7 +413,6 @@ void CStackWindow::CWindowSection::createCommander()
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: commander artifacts
|
//TODO: commander artifacts
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -758,6 +766,7 @@ void CStackWindow::init()
|
|||||||
{
|
{
|
||||||
stackArtifactHelp = nullptr;
|
stackArtifactHelp = nullptr;
|
||||||
stackArtifactIcon = nullptr;
|
stackArtifactIcon = nullptr;
|
||||||
|
stackArtifactButton = nullptr;
|
||||||
|
|
||||||
selectedIcon = nullptr;
|
selectedIcon = nullptr;
|
||||||
selectedSkill = 0;
|
selectedSkill = 0;
|
||||||
|
@@ -71,6 +71,7 @@ class CStackWindow : public CWindowObject
|
|||||||
|
|
||||||
CAnimImage * stackArtifactIcon;
|
CAnimImage * stackArtifactIcon;
|
||||||
LRClickableAreaWTextComp * stackArtifactHelp;
|
LRClickableAreaWTextComp * stackArtifactHelp;
|
||||||
|
CAdventureMapButton * stackArtifactButton;
|
||||||
|
|
||||||
std::unique_ptr<StackWindowInfo> info;
|
std::unique_ptr<StackWindowInfo> info;
|
||||||
std::vector<BonusInfo> activeBonuses;
|
std::vector<BonusInfo> activeBonuses;
|
||||||
@@ -86,6 +87,9 @@ class CStackWindow : public CWindowObject
|
|||||||
CIntObject * createBonusEntry(size_t index);
|
CIntObject * createBonusEntry(size_t index);
|
||||||
CIntObject * switchTab(size_t index);
|
CIntObject * switchTab(size_t index);
|
||||||
|
|
||||||
|
void removeStackArtifact(ArtifactPosition pos);
|
||||||
|
void setStackArtifact(const CArtifactInstance * art, Point artPos);
|
||||||
|
|
||||||
void initSections();
|
void initSections();
|
||||||
void initBonusesList();
|
void initBonusesList();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user