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

Stack artifact backup.

Still doesn't serialize properly, though.
This commit is contained in:
DjWarmonger 2012-02-10 10:32:21 +00:00
parent 2bddf29cbf
commit 9e5fcc3152
8 changed files with 37 additions and 12 deletions

View File

@ -19,6 +19,7 @@
#include "../lib/CGameState.h"
#include "../lib/BattleState.h"
#include "../lib/CSpellHandler.h"
#include "../lib/CArtHandler.h"
#include "UIFramework/CGuiHandler.h"
#include "UIFramework/CIntObjectClasses.h"
@ -26,6 +27,7 @@
using namespace CSDL_Ext;
class CBonusItem;
class CCreatureArtifactInstance;
/*
* CCreatureWindow.cpp, part of VCMI engine
@ -260,7 +262,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
if (heroOwner)
passArtToHero = new CAdventureMapButton(std::string(), std::string(), boost::bind (&CCreatureWindow::scrollArt, this, 0), 437, 148, "OVBUTN1.DEF", SDLK_HOME);
}
if (ConstTransitivePtr<CArtifactInstance> art = stack->activeArtifact.artifact)
if (const CArtifactInstance * art = stack->getArt(GameConstants::CREATURE_ART))
blitAt(graphics->artDefs->ourImages[art->id].bitmap, 466, 161, *bitmap);
}
else
@ -393,6 +395,13 @@ void CCreatureWindow::sliderMoved(int newpos)
void CCreatureWindow::scrollArt(int dir)
{
//TODO: get next artifact
creatureArtifact = const_cast<CArtifactInstance*>(stack->getArt(GameConstants::CREATURE_ART));
}
void CCreatureWindow::passArtifactToHero()
{
creatureArtifact->artType;
}
void CCreatureWindow::clickRight(tribool down, bool previousState)

View File

@ -18,6 +18,7 @@ struct Bonus;
class CCreature;
class CStackInstance;
class CStack;
class CCreatureArtifactInstance;
class CAdventureMapButton;
class CBonusItem;
class CGHeroInstance;
@ -29,12 +30,11 @@ struct UpgradeInfo;
class CPicture;
class CCreaturePic;
class LRClickableAreaWTextComp;
class CArtPlace;
class CSlider;
class CLabel;
class CAnimImage;
// Classical creature window
// New creature window
class CCreatureWindow : public CIntObject
{
public:
@ -48,6 +48,7 @@ public:
const CStackInstance *stack;
const CBonusSystemNode *stackNode;
const CGHeroInstance *heroOwner;
CArtifactInstance *creatureArtifact; //currently worn artifact
std::vector<CComponent*> upgResCost; //cost of upgrade (if not possible then empty)
std::vector<CBonusItem*> bonusItems;
std::vector<LRClickableAreaWText*> spellEffects;
@ -56,7 +57,6 @@ public:
CCreaturePic *anim; //related creature's animation
MoraleLuckBox *luck, *morale;
LRClickableAreaWTextComp * expArea; //displays exp details
CArtPlace *creatureArtifact;
CSlider * slider; //Abilities
CAdventureMapButton *dismiss, *upgrade, *ok;
CAdventureMapButton * leftArtRoll, * rightArtRoll; //artifact selection
@ -69,19 +69,19 @@ public:
CCreatureWindow (const CStackInstance &stack, int Type); //pop-up c-tor
CCreatureWindow(const CStackInstance &st, int Type, boost::function<void()> Upg, boost::function<void()> Dsm, UpgradeInfo *ui); //full garrison window
CCreatureWindow(int Cid, int Type, int creatureCount); //c-tor
void init(const CStackInstance *stack, const CBonusSystemNode *stackNode, const CGHeroInstance *heroOwner);
void showAll(SDL_Surface * to);
void show(SDL_Surface * to);
void printLine(int nr, const std::string &text, int baseVal, int val=-1, bool range=false);
void recreateSkillList(int pos);
~CCreatureWindow(); //d-tor
//void activate();
//void deactivate();
void close();
void clickRight(tribool down, bool previousState); //call-in
void sliderMoved(int newpos);
//void keyPressed (const SDL_KeyboardEvent & key); //call-in
~CCreatureWindow(); //d-tor
void recreateSkillList(int pos);
void scrollArt(int dir);
void passArtifactToHero();
};
class CBonusItem : public LRClickableAreaWTextComp //responsible for displaying creature skill, active or not
@ -99,7 +99,7 @@ public:
void showAll (SDL_Surface * to);
};
/// New Creature info window
/// original creature info window
class CCreInfoWindow : public CIntObject
{
public:

View File

@ -738,6 +738,15 @@ void CArtHandler::addBonuses()
giveArtBonus(140, Bonus::GENERATE_RESOURCE, +4, Res::SULFUR);
giveArtBonus(140, Bonus::GENERATE_RESOURCE, +4, Res::CRYSTAL);
giveArtBonus(140, Bonus::GENERATE_RESOURCE, +4, Res::GEMS);
//Stack artifact test
if (GameConstants::STACK_ARTIFACT)
{
giveArtBonus(141, Bonus::STACK_HEALTH, +400, -1, Bonus::PERCENT_TO_BASE); //Magic Wans
giveArtBonus(142, Bonus::STACK_HEALTH, +400, -1, Bonus::PERCENT_TO_BASE); //Tower Arrow
giveArtBonus(143, Bonus::STACK_HEALTH, +400, -1, Bonus::PERCENT_TO_BASE); //Monster's Power
giveArtBonus(156, Bonus::STACK_HEALTH, +2); //Warlord's banner
}
}
void CArtHandler::clear()

View File

@ -171,7 +171,7 @@ public:
template <typename Handler> void serialize(Handler &h, const int version)
{
h & static_cast<CArtifactInstance&>(*this);
BONUS_TREE_DESERIALIZATION_FIX
//BONUS_TREE_DESERIALIZATION_FIX
}
};
@ -329,7 +329,7 @@ class DLL_LINKAGE CCreatureArtifactSet : public IArtifactSetBase
{ ///creature artifacts
public:
std::vector<ArtSlotInfo> artifactsInBackpack; //artifacts carried by creature - 4 max (according to WoG)
ArtSlotInfo activeArtifact; //position 0 - Arts::CREATURE_ART
ArtSlotInfo activeArtifact; //position 0 - GameConstants::CREATURE_ART
ArtSlotInfo &retreiveNewArtSlot(ui16 slot);
void eraseArtSlot(ui16 slot);

View File

@ -930,6 +930,9 @@ void CStackInstance::deserializationFix()
const CArmedInstance *armyBackup = _armyObj;
_armyObj = NULL;
setArmyObj(armyBackup);
if(activeArtifact.artifact)
attachTo(activeArtifact.artifact);
}
int CStackInstance::getCreatureID() const

View File

@ -851,6 +851,8 @@ struct ArtifactLocation
ArtifactLocation()
{
slot = -1;
stack = NULL;
hero = NULL;
}
ArtifactLocation(const CGHeroInstance *Hero, TArtPos Slot)
{

View File

@ -564,6 +564,7 @@ DLL_LINKAGE const ArtSlotInfo *ArtifactLocation::getSlot() const
return hero->getSlot(slot);
if (stack)
return stack->getSlot(slot);
return NULL;
}
DLL_LINKAGE void ChangeStackCount::applyGs( CGameState *gs )

View File

@ -95,6 +95,7 @@ void registerTypes1(Serializer &s)
s.template registerType<CArtifactInstance>();
s.template registerType<CCombinedArtifactInstance>();
s.template registerType<CCreatureArtifactInstance>();
//s.template registerType<ArtSlotInfo>();
//s.template registerType<ArtifactLocation>();
//s.template registerType<StackLocation>();
}