1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Implemented stack artifact handling, no tested yet

This commit is contained in:
Ivan Savenko 2014-07-05 01:22:56 +03:00
parent ac6cfdfb92
commit 60e5815014
11 changed files with 48 additions and 12 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,8 @@
{
"basepath" : "stackWindow/",
"images" :
[
{ "frame" : 0, "file" : "cancel-normal.png"},
{ "frame" : 1, "file" : "cancel-pressed.png"}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1,8 +0,0 @@
{
"basepath" : "stackWindow/",
"images" :
[
{ "frame" : 0, "file" : "switch-mode-normal.png"},
{ "frame" : 1, "file" : "switch-mode-pressed.png"}
]
}

View File

@ -226,7 +226,32 @@ void CStackWindow::CWindowSection::createStackInfo(bool showExp, bool showArt)
auto luck = new MoraleLuckBox(false, genRect(42, 42, 375, 110));
luck->set(parent->info->stackNode);
//TODO: stack artifact
//TODO: TEST
//TODO: delete "pass artifact" button on removal
//TODO: refactor into give art / take art methods
if (showArt)
{
const CStackInstance * stack = parent->info->stackNode;
if (stack->getArt(ArtifactPosition::CREATURE_SLOT))
{
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)
{
@ -481,7 +506,6 @@ void CStackWindow::CWindowSection::createBonuses(boost::optional<size_t> preferr
void CStackWindow::CWindowSection::createButtonPanel()
{
//TODO: localization, place creature icon on button, proper path to animation-button
OBJ_CONSTRUCTION_CAPTURING_ALL;
createBackground("button-panel");
@ -647,8 +671,8 @@ void CStackWindow::initSections()
OBJ_CONSTRUCTION_CAPTURING_ALL;
CWindowSection * currentSection;
bool showArt = CGI->modh->modules.STACK_ARTIFACT && info->commander == nullptr;
bool showExp = CGI->modh->modules.STACK_EXP || info->commander != nullptr;
bool showArt = CGI->modh->modules.STACK_ARTIFACT && info->commander == nullptr && info->stackNode;
bool showExp = (CGI->modh->modules.STACK_EXP || info->commander != nullptr) && info->stackNode;
currentSection = new CWindowSection(this);
currentSection->createStackInfo(showExp, showArt);
pos.w = currentSection->pos.w;
@ -732,6 +756,9 @@ void CStackWindow::initBonusesList()
void CStackWindow::init()
{
stackArtifactHelp = nullptr;
stackArtifactIcon = nullptr;
selectedIcon = nullptr;
selectedSkill = 0;
if (info->levelupInfo)

View File

@ -18,6 +18,7 @@ class CCommanderInstance;
class CStackInstance;
class CStack;
struct UpgradeInfo;
class LRClickableAreaWTextComp;
class CClickableObject : public LRClickableAreaWText
{
@ -68,6 +69,9 @@ class CStackWindow : public CWindowObject
CWindowSection(CStackWindow * parent);
};
CAnimImage * stackArtifactIcon;
LRClickableAreaWTextComp * stackArtifactHelp;
std::unique_ptr<StackWindowInfo> info;
std::vector<BonusInfo> activeBonuses;
size_t activeTab;

View File

@ -66,6 +66,11 @@
{
"label" : "Switch to skills view",
"help" : "Displays all learned skills of the commander"
},
"returnArtifact" :
{
"label" : "Give back artifact",
"help" : "Use this button to return stack artifact back into hero backpack"
}
}
}