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

another part of hero window and other improvements

This commit is contained in:
mateuszb 2008-01-15 18:50:52 +00:00
parent 0fc7d5b795
commit bce31ba91b
10 changed files with 202 additions and 65 deletions

View File

@ -8,9 +8,11 @@
#include "SDL_Extensions.h"
#include "CAdvmapInterface.h"
#include "AdventureMapButton.h"
#include "CMessage.h"
#include <sstream>
extern SDL_Surface * ekran;
extern TTF_Font * GEOR16;
CHeroWindow::CHeroWindow(int playerColor)
{
@ -21,6 +23,8 @@ CHeroWindow::CHeroWindow(int playerColor)
pos.y = 8;
pos.h = background->h;
pos.w = background->w;
curBack = NULL;
curHero = NULL;
quitButton = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::quit, 674, 524, "hsbtns.def", this);
dismissButton = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::dismissCurrent, 519, 437, "hsbtns2.def", this);
@ -131,68 +135,7 @@ void CHeroWindow::activate()
{
heroList[g]->activate();
}
curBack = CSDL_Ext::copySurface(background);
blitAt(skillpics->ourImages[0].bitmap, 32, 111, curBack);
blitAt(skillpics->ourImages[1].bitmap, 102, 111, curBack);
blitAt(skillpics->ourImages[2].bitmap, 172, 111, curBack);
blitAt(skillpics->ourImages[5].bitmap, 242, 111, curBack);
blitAt(skillpics->ourImages[4].bitmap, 20, 230, curBack);
blitAt(skillpics->ourImages[3].bitmap, 162, 230, curBack);
blitAt(curHero->type->portraitLarge, 19, 19, curBack);
CSDL_Ext::printAtMiddle(curHero->name, 190, 40, GEORXX, tytulowy, curBack);
std::stringstream secondLine;
secondLine<<"Level "<<curHero->level<<" "<<curHero->type->heroClass->name;
CSDL_Ext::printAtMiddle(secondLine.str(), 190, 66, TNRB16, zwykly, curBack);
//TODO: find missing texts and remove these ugly hardcoded names
CSDL_Ext::printAtMiddle("Attack", 53, 98, GEOR13, tytulowy, curBack);
CSDL_Ext::printAtMiddle("Defence", 123, 98, GEOR13, tytulowy, curBack);
CSDL_Ext::printAtMiddle("Power", 193, 98, GEOR13, tytulowy, curBack);
CSDL_Ext::printAtMiddle("Knowledge", 263, 98, GEOR13, tytulowy, curBack);
std::stringstream primarySkill1;
primarySkill1<<curHero->primSkills[0];
CSDL_Ext::printAtMiddle(primarySkill1.str(), 53, 165, TNRB16, zwykly, curBack);
std::stringstream primarySkill2;
primarySkill2<<curHero->primSkills[1];
CSDL_Ext::printAtMiddle(primarySkill2.str(), 123, 165, TNRB16, zwykly, curBack);
std::stringstream primarySkill3;
primarySkill3<<curHero->primSkills[2];
CSDL_Ext::printAtMiddle(primarySkill3.str(), 193, 165, TNRB16, zwykly, curBack);
std::stringstream primarySkill4;
primarySkill4<<curHero->primSkills[3];
CSDL_Ext::printAtMiddle(primarySkill4.str(), 263, 165, TNRB16, zwykly, curBack);
blitAt(LOCPLINT->luck42->ourImages[curHero->getCurrentLuck()+3].bitmap, 239, 182, curBack);
blitAt(LOCPLINT->morale42->ourImages[curHero->getCurrentMorale()+3].bitmap, 181, 182, curBack);
blitAt(flags->ourImages[player].bitmap, 606, 8, curBack);
//hero list blitting
for(int g=0; g<LOCPLINT->cb->howManyHeroes(); ++g)
{
const CGHeroInstance * cur = LOCPLINT->cb->getHeroInfo(player, g, false);
blitAt(cur->type->portraitSmall, 611, 87+g*54, curBack);
//printing yellow border
if(cur->name == curHero->name)
{
for(int f=0; f<cur->type->portraitSmall->w; ++f)
{
for(int h=0; h<cur->type->portraitSmall->h; ++h)
if(f==0 || h==0 || f==cur->type->portraitSmall->w-1 || h==cur->type->portraitSmall->h-1)
{
CSDL_Ext::SDL_PutPixel(curBack, 611+f, 87+g*54+h, 240, 220, 120);
}
}
}
}
redrawCurBack();
}
void CHeroWindow::dismissCurrent()
@ -235,9 +178,167 @@ void CHeroWindow::switchHero()
{
if(y>=94+54*g)
{
quit();
//quit();
setHero(LOCPLINT->cb->getHeroInfo(player, g, false));
LOCPLINT->openHeroWindow(curHero);
//LOCPLINT->openHeroWindow(curHero);
redrawCurBack();
}
}
}
void CHeroWindow::redrawCurBack()
{
if(curBack)
SDL_FreeSurface(curBack);
curBack = CSDL_Ext::copySurface(background);
blitAt(skillpics->ourImages[0].bitmap, 32, 111, curBack);
blitAt(skillpics->ourImages[1].bitmap, 102, 111, curBack);
blitAt(skillpics->ourImages[2].bitmap, 172, 111, curBack);
blitAt(skillpics->ourImages[5].bitmap, 242, 111, curBack);
blitAt(skillpics->ourImages[4].bitmap, 20, 230, curBack);
blitAt(skillpics->ourImages[3].bitmap, 162, 230, curBack);
blitAt(curHero->type->portraitLarge, 19, 19, curBack);
CSDL_Ext::printAtMiddle(curHero->name, 190, 40, GEORXX, tytulowy, curBack);
std::stringstream secondLine;
secondLine<<"Level "<<curHero->level<<" "<<curHero->type->heroClass->name;
CSDL_Ext::printAtMiddle(secondLine.str(), 190, 66, TNRB16, zwykly, curBack);
//primary skliis names
CSDL_Ext::printAtMiddle(CGI->generaltexth->jktexts[1], 53, 98, GEOR13, tytulowy, curBack);
CSDL_Ext::printAtMiddle(CGI->generaltexth->jktexts[2], 123, 98, GEOR13, tytulowy, curBack);
CSDL_Ext::printAtMiddle(CGI->generaltexth->jktexts[3], 193, 98, GEOR13, tytulowy, curBack);
CSDL_Ext::printAtMiddle(CGI->generaltexth->jktexts[4], 263, 98, GEOR13, tytulowy, curBack);
//dismiss / quest log
std::vector<std::string> * toPrin = CMessage::breakText(CGI->generaltexth->jktexts[8].substr(1, CGI->generaltexth->jktexts[8].size()-2));
if(toPrin->size()==1)
{
CSDL_Ext::printAt((*toPrin)[0], 372, 440, GEOR13, zwykly, curBack);
}
else
{
CSDL_Ext::printAt((*toPrin)[0], 372, 431, GEOR13, zwykly, curBack);
CSDL_Ext::printAt((*toPrin)[1], 372, 447, GEOR13, zwykly, curBack);
}
delete toPrin;
toPrin = CMessage::breakText(CGI->generaltexth->jktexts[9].substr(1, CGI->generaltexth->jktexts[9].size()-2));
if(toPrin->size()==1)
{
CSDL_Ext::printAt((*toPrin)[0], 512, 440, GEOR13, zwykly, curBack);
}
else
{
CSDL_Ext::printAt((*toPrin)[0], 512, 431, GEOR13, zwykly, curBack);
CSDL_Ext::printAt((*toPrin)[1], 512, 447, GEOR13, zwykly, curBack);
}
delete toPrin;
//printing primary skills' amounts
std::stringstream primarySkill1;
primarySkill1<<curHero->primSkills[0];
CSDL_Ext::printAtMiddle(primarySkill1.str(), 53, 165, TNRB16, zwykly, curBack);
std::stringstream primarySkill2;
primarySkill2<<curHero->primSkills[1];
CSDL_Ext::printAtMiddle(primarySkill2.str(), 123, 165, TNRB16, zwykly, curBack);
std::stringstream primarySkill3;
primarySkill3<<curHero->primSkills[2];
CSDL_Ext::printAtMiddle(primarySkill3.str(), 193, 165, TNRB16, zwykly, curBack);
std::stringstream primarySkill4;
primarySkill4<<curHero->primSkills[3];
CSDL_Ext::printAtMiddle(primarySkill4.str(), 263, 165, TNRB16, zwykly, curBack);
blitAt(LOCPLINT->luck42->ourImages[curHero->getCurrentLuck()+3].bitmap, 239, 182, curBack);
blitAt(LOCPLINT->morale42->ourImages[curHero->getCurrentMorale()+3].bitmap, 181, 182, curBack);
blitAt(flags->ourImages[player].bitmap, 606, 8, curBack);
//hero list blitting
for(int g=0; g<LOCPLINT->cb->howManyHeroes(); ++g)
{
const CGHeroInstance * cur = LOCPLINT->cb->getHeroInfo(player, g, false);
blitAt(cur->type->portraitSmall, 611, 87+g*54, curBack);
//printing yellow border
if(cur->name == curHero->name)
{
for(int f=0; f<cur->type->portraitSmall->w; ++f)
{
for(int h=0; h<cur->type->portraitSmall->h; ++h)
if(f==0 || h==0 || f==cur->type->portraitSmall->w-1 || h==cur->type->portraitSmall->h-1)
{
CSDL_Ext::SDL_PutPixel(curBack, 611+f, 87+g*54+h, 240, 220, 120);
}
}
}
}
//secondary skills
if(curHero->secSkills.size()>=1)
{
blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[0].first*3+3+curHero->secSkills[0].second].bitmap, 18, 276, curBack);
CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[0].second], 69, 279, GEOR13, zwykly, curBack);
CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[0].first]->name, 69, 299, GEOR13, zwykly, curBack);
}
if(curHero->secSkills.size()>=2)
{
blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[1].first*3+3+curHero->secSkills[1].second].bitmap, 161, 276, curBack);
CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[1].second], 213, 279, GEOR13, zwykly, curBack);
CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[1].first]->name, 213, 299, GEOR13, zwykly, curBack);
}
if(curHero->secSkills.size()>=3)
{
blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[2].first*3+3+curHero->secSkills[2].second].bitmap, 18, 324, curBack);
CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[2].second], 69, 327, GEOR13, zwykly, curBack);
CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[2].first]->name, 69, 347, GEOR13, zwykly, curBack);
}
if(curHero->secSkills.size()>=4)
{
blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[3].first*3+3+curHero->secSkills[3].second].bitmap, 161, 324, curBack);
CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[3].second], 213, 327, GEOR13, zwykly, curBack);
CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[3].first]->name, 213, 347, GEOR13, zwykly, curBack);
}
if(curHero->secSkills.size()>=5)
{
blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[4].first*3+3+curHero->secSkills[4].second].bitmap, 18, 372, curBack);
CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[4].second], 69, 375, GEOR13, zwykly, curBack);
CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[4].first]->name, 69, 395, GEOR13, zwykly, curBack);
}
if(curHero->secSkills.size()>=6)
{
blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[5].first*3+3+curHero->secSkills[5].second].bitmap, 161, 372, curBack);
CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[5].second], 213, 375, GEOR13, zwykly, curBack);
CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[5].first]->name, 213, 395, GEOR13, zwykly, curBack);
}
if(curHero->secSkills.size()>=7)
{
blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[6].first*3+3+curHero->secSkills[6].second].bitmap, 18, 420, curBack);
CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[6].second], 69, 423, GEOR13, zwykly, curBack);
CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[6].first]->name, 69, 443, GEOR13, zwykly, curBack);
}
if(curHero->secSkills.size()>=8)
{
blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[7].first*3+3+curHero->secSkills[7].second].bitmap, 161, 420, curBack);
CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[7].second], 213, 423, GEOR13, zwykly, curBack);
CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[7].first]->name, 213, 443, GEOR13, zwykly, curBack);
}
//printing special ability
blitAt(CGI->heroh->un44->ourImages[curHero->subID].bitmap, 18, 180, curBack);
//printing necessery texts
CSDL_Ext::printAt(CGI->generaltexth->jktexts[6].substr(1, CGI->generaltexth->jktexts[6].size()-2), 69, 231, GEOR13, tytulowy, curBack);
std::stringstream expstr;
expstr<<curHero->exp;
CSDL_Ext::printAt(expstr.str(), 69, 247, GEOR16, zwykly, curBack);
CSDL_Ext::printAt(CGI->generaltexth->jktexts[7].substr(1, CGI->generaltexth->jktexts[7].size()-2), 212, 231, GEOR13, tytulowy, curBack);
std::stringstream manastr;
manastr<<curHero->mana<<'/'<<curHero->primSkills[3]*10;
CSDL_Ext::printAt(manastr.str(), 212, 247, GEOR16, zwykly, curBack);
}

View File

@ -26,6 +26,7 @@ public:
void setHero(const CGHeroInstance * hero); //sets main displayed hero
void activate(); //activates hero window;
virtual void show(SDL_Surface * to = NULL); //shows hero window
void redrawCurBack(); //redraws curBAck from scratch
void quit(); //stops displaying hero window
void dismissCurrent(); //dissmissed currently displayed hero (curHero) //TODO: make it working
void questlog(); //show quest log in hero window

View File

@ -59,7 +59,7 @@
const char * NAME = "VCMI 0.5 \"Tirion\"";
SDL_Surface * ekran, * screen, * screen2;
TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX, *GEORM;
TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX, *GEORM, *GEOR16;
void handleCPPObjS(std::map<int,CCPPObjectScript*> * mapa, CCPPObjectScript * script)
{
std::vector<int> tempv = script->yourObjects();
@ -299,6 +299,7 @@ int _tmain(int argc, _TCHAR* argv[])
TNRB16 = TTF_OpenFont("Fonts\\tnrb.ttf",16);
//TNR = TTF_OpenFont("Fonts\\tnr.ttf",10);
GEOR13 = TTF_OpenFont("Fonts\\georgia.ttf",13);
GEOR16 = TTF_OpenFont("Fonts\\georgia.ttf",16);
GEORXX = TTF_OpenFont("Fonts\\tnrb.ttf",22);
GEORM = TTF_OpenFont("Fonts\\georgia.ttf",10);

View File

@ -3,6 +3,8 @@
#include "../CGameInfo.h"
#include "CGeneralTextHandler.h"
#include "CLodHandler.h"
#include "CDefHandler.h"
void CAbilityHandler::loadAbilities()
{
std::string buf = CGameInfo::mainObj->bitmaph->getTextFile("SSTRAITS.TXT");
@ -22,4 +24,16 @@ void CAbilityHandler::loadAbilities()
nab->idNumber = abilities.size();
abilities.push_back(nab);
}
abils32 = CGI->spriteh->giveDef("SECSK32.DEF");
abils44 = CGI->spriteh->giveDef("SECSKILL.DEF");
abils82 = CGI->spriteh->giveDef("SECSK82.DEF");
buf = CGameInfo::mainObj->bitmaph->getTextFile("SKILLLEV.TXT");
it=0;
for(int i=0; i<6; ++i)
{
std::string buffo;
CGeneralTextHandler::loadToIt(buffo,buf,it,3);
levels.push_back(buffo);
}
}

View File

@ -4,6 +4,8 @@
#include <string>
#include <vector>
class CDefHandler;
class CAbility
{
public:
@ -19,6 +21,8 @@ class CAbilityHandler
{
public:
std::vector<CAbility *> abilities;
CDefHandler * abils32, * abils44, * abils82;
std::vector<std::string> levels;
void loadAbilities();
};

View File

@ -955,6 +955,10 @@ void CAmbarCendamo::deh3m()
nhi->type = spec->type;
nhi->army = spec->garrison;
nhi->portrait = -1; // TODO: przypisywac portret
for(int qq=0; qq<spec->abilities.size(); ++qq)
{
nhi->secSkills.push_back(std::make_pair(spec->abilities[qq]->idNumber, spec->abilityLevels[qq]-1));
}
CGI->heroh->heroInstances.push_back(nhi);
break;
}

View File

@ -41,6 +41,15 @@ void CGeneralTextHandler::load()
primarySkillNames.push_back(tmp);
}
itr = 0;
std::string strin2 = CGI->bitmaph->getTextFile("JKTEXT.TXT");
for(int hh=0; hh<45; ++hh)
{
std::string tmp;
CGeneralTextHandler::loadToIt(tmp, strin2, itr, 3);
jktexts.push_back(tmp);
}
//std::ofstream ofs("arraytxts.txt");
//for (int i=0;i<arraytxt.size();i++)
// ofs << i <<".\t" << arraytxt[i] << std::endl<< std::endl;

View File

@ -11,6 +11,7 @@ public:
std::vector<std::string> arraytxt;
std::vector<std::string> primarySkillNames;
std::vector<std::string> jktexts;
/*std::string cantAddManager, experienceLimitScenarioReached, heroExperienceInfo, perDay, or, somethingVanquished, lastTownLostInfo, heroesAbandonedYou, heroesAbandonedHim;
std::string couldNotSaveGame, errorOpeningFile, newgameUppercase, sureToDismissArmy, playersTurn, errorReceivingDataKeepTrying, somethingTheSomething, recruit, noRoomInGarrision, numberOFAdventuringHeroes, heroWithoutCreatures;
std::string videoQuality, itemCantBeTraded, sureDismissHero, selectSpellTarget, invalidTeleportDestination, teleportHere, castSomething, castSomethingOnSomething, sureRetreat, notEnoughGold, capturedEnemyArtifact, none;

View File

@ -48,6 +48,7 @@ void CHeroHandler::loadPortraits()
of.close();
pskillsb = CGI->spriteh->giveDef("PSKILL.DEF");
resources = CGI->spriteh->giveDef("RESOUR82.DEF");
un44 = CGI->spriteh->giveDef("UN44.DEF");
std::string strs = CGI->bitmaph->getTextFile("PRISKILL.TXT");
int itr=0;

View File

@ -90,6 +90,7 @@ public:
std::vector<CHeroClass *> heroClasses;
std::vector<CDefHandler *> flags1, flags2, flags3, flags4; //flags blitted on heroes when ,
CDefHandler * pskillsb, *resources; //82x93
CDefHandler * un44; //many things
std::vector<std::string> pskillsn;
unsigned int level(unsigned int experience);
void loadHeroes();