1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

first part of artifacts on hero window - small problem with misc5 slot (most probably in AmbarCendamo)

This commit is contained in:
mateuszb 2008-01-19 13:19:58 +00:00
parent 231593e83d
commit e3f40e6907
9 changed files with 250 additions and 7 deletions

View File

@ -17,8 +17,11 @@
#include "CLua.h"
#include "hch/CHeroHandler.h"
#include <sstream>
extern TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX; //fonts
#include "AdventureMapButton.h"
#include "CHeroWindow.h"
extern TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX; //fonts
using namespace boost::logic;
using namespace boost::assign;
using namespace CSDL_Ext;

View File

@ -5,7 +5,6 @@
#include "SDL.h"
#include "CPlayerInterface.h"
#include <map>
#include "CHeroWindow.h"
class CDefHandler;
class CCallback;
class CTownInstance;
@ -13,6 +12,7 @@ class CPath;
class CAdvMapInt;
class CGHeroInstance;
class CGTownInstance;
class CHeroWindow;
template <typename T=CAdvMapInt>
class AdventureMapButton
: public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public CButtonBase

View File

@ -11,10 +11,13 @@
#include "CMessage.h"
#include <sstream>
extern SDL_Surface * ekran;
extern SDL_Surface * screen;
extern TTF_Font * GEOR16;
CHeroWindow::CHeroWindow(int playerColor)
CHeroWindow::CHeroWindow(int playerColor): artFeet(0), artHead(0), artLHand(0),
artLRing(0), artMach1(0), artMach2(0), artMach3(0), artMach4(0), artMisc1(0),
artMisc2(0), artMisc3(0), artMisc4(0), artMisc5(0), artNeck(0), artRhand(0),
artRRing(0), artShoulders(0), artSpellBook(0), artTorso(0)
{
player = playerColor;
background = CGI->bitmaph->loadBitmap("HEROSCR4.bmp");
@ -68,6 +71,26 @@ CHeroWindow::~CHeroWindow()
delete skillpics;
delete flags;
delete artFeet;
delete artHead;
delete artLHand;
delete artLRing;
delete artMach1;
delete artMach2;
delete artMach3;
delete artMach4;
delete artMisc1;
delete artMisc2;
delete artMisc3;
delete artMisc4;
delete artMisc5;
delete artNeck;
delete artRhand;
delete artRRing;
delete artShoulders;
delete artSpellBook;
delete artTorso;
}
void CHeroWindow::show(SDL_Surface *to)
@ -84,11 +107,128 @@ void CHeroWindow::show(SDL_Surface *to)
gar4button->show();
leftArtRoll->show();
rightArtRoll->show();
artFeet->show(to);
artHead->show(to);
artLHand->show(to);
artLRing->show(to);
artMach1->show(to);
artMach2->show(to);
artMach3->show(to);
artMach4->show(to);
artMisc1->show(to);
artMisc2->show(to);
artMisc3->show(to);
artMisc4->show(to);
artMisc5->show(to);
artNeck->show(to);
artRhand->show(to);
artRRing->show(to);
artShoulders->show(to);
artSpellBook->show(to);
artTorso->show(to);
}
void CHeroWindow::setHero(const CGHeroInstance *hero)
{
curHero = hero;
delete artFeet;
delete artHead;
delete artLHand;
delete artLRing;
delete artMach1;
delete artMach2;
delete artMach3;
delete artMach4;
delete artMisc1;
delete artMisc2;
delete artMisc3;
delete artMisc4;
delete artMisc5;
delete artNeck;
delete artRhand;
delete artRRing;
delete artShoulders;
delete artSpellBook;
delete artTorso;
artFeet = new CArtPlace(hero->artFeet);
artFeet->pos.x = 515;
artFeet->pos.y = 295;
artFeet->pos.h = artFeet->pos.w = 44;
artHead = new CArtPlace(hero->artHead);
artHead->pos.x = 509;
artHead->pos.y = 30;
artHead->pos.h = artHead->pos.h = 44;
artLHand = new CArtPlace(hero->artLHand);
artLHand->pos.x = 564;
artLHand->pos.y = 183;
artLHand->pos.h = artLHand->pos.h = 44;
artLRing = new CArtPlace(hero->artLRing);
artLRing->pos.x = 610;
artLRing->pos.y = 183;
artLRing->pos.h = artLRing->pos.h = 44;
artMach1 = new CArtPlace(hero->artMach1);
artMach1->pos.x = 564;
artMach1->pos.y = 30;
artMach1->pos.h = artMach1->pos.h = 44;
artMach2 = new CArtPlace(hero->artMach2);
artMach2->pos.x = 610;
artMach2->pos.y = 30;
artMach2->pos.h = artMach2->pos.h = 44;
artMach3 = new CArtPlace(hero->artMach3);
artMach3->pos.x = 610;
artMach3->pos.y = 76;
artMach3->pos.h = artMach3->pos.h = 44;
artMach4 = new CArtPlace(hero->artMach4);
artMach4->pos.x = 610;
artMach4->pos.y = 122;
artMach4->pos.h = artMach4->pos.h = 44;
artMisc1 = new CArtPlace(hero->artMisc1);
artMisc1->pos.x = 383;
artMisc1->pos.y = 143;
artMisc1->pos.h = artMisc1->pos.h = 44;
artMisc2 = new CArtPlace(hero->artMisc2);
artMisc2->pos.x = 399;
artMisc2->pos.y = 194;
artMisc2->pos.h = artMisc2->pos.h = 44;
artMisc3 = new CArtPlace(hero->artMisc3);
artMisc3->pos.x = 415;
artMisc3->pos.y = 245;
artMisc3->pos.h = artMisc3->pos.h = 44;
artMisc4 = new CArtPlace(hero->artMisc4);
artMisc4->pos.x = 431;
artMisc4->pos.y = 296;
artMisc4->pos.h = artMisc4->pos.h = 44;
artMisc5 = new CArtPlace(hero->artMisc5);
artMisc5->pos.x = 381;
artMisc5->pos.y = 296;
artMisc5->pos.h = artMisc5->pos.h = 44;
artNeck = new CArtPlace(hero->artNeck);
artNeck->pos.x = 508;
artNeck->pos.y = 79;
artNeck->pos.h = artNeck->pos.h = 44;
artRhand = new CArtPlace(hero->artRhand);
artRhand->pos.x = 383;
artRhand->pos.y = 68;
artRhand->pos.h = artRhand->pos.h = 44;
artRRing = new CArtPlace(hero->artRRing);
artRRing->pos.x = 431;
artRRing->pos.y = 68;
artRRing->pos.h = artRRing->pos.h = 44;
artShoulders = new CArtPlace(hero->artShoulders);
artShoulders->pos.x = 567;
artShoulders->pos.y = 240;
artShoulders->pos.h = artShoulders->pos.h = 44;
artSpellBook = new CArtPlace(hero->artSpellBook);
artSpellBook->pos.x = 610;
artSpellBook->pos.y = 310;
artSpellBook->pos.h = artSpellBook->pos.h = 44;
artTorso = new CArtPlace(hero->artTorso);
artTorso->pos.x = 509;
artTorso->pos.y = 130;
artTorso->pos.h = artTorso->pos.h = 44;
}
void CHeroWindow::quit()
@ -118,6 +258,14 @@ void CHeroWindow::quit()
SDL_FreeSurface(curBack);
curBack = NULL;
for(int v=0; v<LOCPLINT->lclickable.size(); ++v)
{
if(dynamic_cast<CArtPlace*>(LOCPLINT->lclickable[v]))
LOCPLINT->lclickable.erase(LOCPLINT->lclickable.begin()+v);
}
delete artFeet;
artFeet = 0;
}
void CHeroWindow::activate()
@ -136,6 +284,7 @@ void CHeroWindow::activate()
heroList[g]->activate();
}
redrawCurBack();
//LOCPLINT->lclickable.push_back(artFeet);
}
void CHeroWindow::dismissCurrent()
@ -341,4 +490,22 @@ void CHeroWindow::redrawCurBack()
std::stringstream manastr;
manastr<<curHero->mana<<'/'<<curHero->primSkills[3]*10;
CSDL_Ext::printAt(manastr.str(), 212, 247, GEOR16, zwykly, curBack);
}
}
CArtPlace::CArtPlace(CArtifact *art): ourArt(art){}
void CArtPlace::activate()
{
}
void CArtPlace::clickLeft(boost::logic::tribool down)
{
}
void CArtPlace::deactivate()
{
}
void CArtPlace::show(SDL_Surface *to)
{
if(ourArt)
{
blitAt(CGI->arth->artDefs->ourImages[ourArt->id].bitmap, pos.x, pos.y, to);
}
}

View File

@ -1,10 +1,23 @@
#pragma once
#include "CPlayerInterface.h"
#include "CAdvmapInterface.h"
template <typename T> class AdventureMapButton;
class SDL_Surface;
struct SDL_Surface;
class CGHeroInstance;
class CDefHandler;
class CArtifact;
class CArtPlace: public ClickableL, public IShowable
{
public:
const CArtifact * ourArt;
CArtPlace(CArtifact * art);
void clickLeft (tribool down);
void activate();
void deactivate();
void show(SDL_Surface * to = NULL);
};
class CHeroWindow: public IShowable, public virtual CIntObject
{
@ -20,6 +33,12 @@ class CHeroWindow: public IShowable, public virtual CIntObject
* gar1button, * gar2button, * gar3button, * gar4button, //garrison / formation handling
* leftArtRoll, * rightArtRoll;
std::vector< AdventureMapButton<CHeroWindow> * > heroList; //list of heroes
//artifact places
CArtPlace * artHead, * artLRing, * artRRing, * artLHand, * artRhand,
* artFeet, * artSpellBook, * artMach1, * artMach2, * artMach3,
* artMach4, * artMisc1, * artMisc2, * artMisc3, * artMisc4,
* artMisc5, * artTorso, * artNeck, * artShoulders; //heroes' artifacts
public:
CHeroWindow(int playerColor); //c-tor
~CHeroWindow(); //d-tor
@ -37,4 +56,4 @@ public:
void leftArtRoller(); //scrolls artifacts in bag left
void rightArtRoller(); //scrolls artifacts in bag right
void switchHero(); //changes displayed hero
};
};

View File

@ -16,6 +16,7 @@
#include "SDL_framerate.h"
#include "hch/CGeneralTextHandler.h"
#include "CCastleInterface.h"
#include "CHeroWindow.h"
using namespace CSDL_Ext;
class OCM_HLP_CGIN

View File

@ -860,6 +860,28 @@ void CAmbarCendamo::deh3m()
}
}
} //artifacts
else
{
spec->artFeet = NULL;
spec->artHead = NULL;
spec->artLHand = NULL;
spec->artLRing = NULL;
spec->artMach1 = NULL;
spec->artMach2 = NULL;
spec->artMach3 = NULL;
spec->artMach4 = NULL;
spec->artMisc1 = NULL;
spec->artMisc2 = NULL;
spec->artMisc3 = NULL;
spec->artMisc4 = NULL;
spec->artMisc5 = NULL;
spec->artNeck = NULL;
spec->artRhand = NULL;
spec->artRRing = NULL;
spec->artShoulders = NULL;
spec->artSpellBook = NULL;
spec->artTorso = NULL;
}
spec->guardRange = readNormalNr(i, 1); ++i;
if(spec->guardRange == 0xff)
spec->isGuarding = false;
@ -956,6 +978,26 @@ void CAmbarCendamo::deh3m()
nhi->type = spec->type;
nhi->army = spec->garrison;
nhi->portrait = -1; // TODO: przypisywac portret
nhi->artFeet = spec->artFeet;
nhi->artHead = spec->artHead;
nhi->artifacts = spec->artifacts;
nhi->artLHand = spec->artLHand;
nhi->artLRing = spec->artLRing;
nhi->artMach1 = spec->artMach1;
nhi->artMach2 = spec->artMach2;
nhi->artMach3 = spec->artMach3;
nhi->artMach4 = spec->artMach4 = new CArtifact(CGI->arth->artifacts[3]);
nhi->artMisc1 = spec->artMisc1;
nhi->artMisc2 = spec->artMisc2;
nhi->artMisc3 = spec->artMisc3;
nhi->artMisc4 = spec->artMisc4;
nhi->artMisc5 = spec->artMisc5;
nhi->artNeck = spec->artNeck;
nhi->artRhand = spec->artRhand;
nhi->artRRing = spec->artRRing;
nhi->artShoulders = spec->artShoulders;
nhi->artSpellBook = spec->artSpellBook;
nhi->artTorso = spec->artTorso;
for(int qq=0; qq<spec->abilities.size(); ++qq)
{
nhi->secSkills.push_back(std::make_pair(spec->abilities[qq]->idNumber, spec->abilityLevels[qq]-1));

View File

@ -6,6 +6,8 @@
void CArtHandler::loadArtifacts()
{
artDefs = CGI->spriteh->giveDef("ARTIFACT.DEF");
std::string buf = CGameInfo::mainObj->bitmaph->getTextFile("ARTRAITS.TXT");
int it=0;
std::string dump;

View File

@ -5,6 +5,7 @@
#include <vector>
enum EartClass {SartClass=0, TartClass, NartClass, JartClass, RartClass}; //artifact class (relict, treasure, strong, weak etc.)
class CDefHandler;
class CArtifact //container for artifacts
{
@ -23,6 +24,7 @@ public:
class CArtHandler //handles artifacts
{
public:
CDefHandler * artDefs;
std::vector<CArtifact> artifacts;
void loadArtifacts();
bool loadArtEvents();

View File

@ -403,6 +403,13 @@ public:
int movement; //remaining movement points
bool inTownGarrison; // if hero is in town garrison
std::vector<CArtifact *> artifacts; //hero's artifacts from bag
CArtifact * artHead, * artLRing, * artRRing, * artLHand,
* artRhand, * artFeet, * artSpellBook, * artMach1,
* artMach2, * artMach3, * artMach4, * artMisc1, * artMisc2,
* artMisc3, * artMisc4, * artMisc5, * artTorso, * artNeck,
* artShoulders; //working artifacts
virtual bool isHero() const;
unsigned int getTileCost(EterrainType & ttype, Eroad & rdtype, Eriver & rvtype);
unsigned int getLowestCreatureSpeed();