1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

a bit more of hero window

This commit is contained in:
mateuszb
2008-01-13 16:24:24 +00:00
parent 2d8a513fc2
commit d55b020dbd
5 changed files with 107 additions and 3 deletions

View File

@@ -1,14 +1,20 @@
#include "stdafx.h"
#include "global.h"
#include "CHeroWindow.h"
#include "CGameInfo.h"
#include "hch\CHeroHandler.h"
#include "hch\CGeneralTextHandler.h"
#include "SDL.h"
#include "SDL_Extensions.h"
#include "CAdvmapInterface.h"
#include "AdventureMapButton.h"
#include <sstream>
extern SDL_Surface * ekran;
CHeroWindow::CHeroWindow(int playerColor)
{
player = playerColor;
background = CGI->bitmaph->loadBitmap("HEROSCR4.bmp");
CSDL_Ext::blueToPlayersAdv(background, playerColor);
pos.x = 65;
@@ -20,7 +26,13 @@ CHeroWindow::CHeroWindow(int playerColor)
dismissButton = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::dismissCurrent, 519, 437, "hsbtns2.def", this);
questlogButton = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::questlog, 379, 437, "hsbtns4.def", this);
gar1button = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::gar1, 546, 491, "hsbtns6.def", this);
gar2button = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::gar2, 604, 491, "hsbtns8.def", this);
gar3button = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::gar3, 546, 527, "hsbtns7.def", this);
gar4button = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::gar4, 604, 527, "hsbtns9.def", this);
skillpics = CGI->spriteh->giveDef("pskil42.def");
flags = CGI->spriteh->giveDef("CREST58.DEF");
}
CHeroWindow::~CHeroWindow()
@@ -29,11 +41,16 @@ CHeroWindow::~CHeroWindow()
delete quitButton;
delete dismissButton;
delete questlogButton;
delete gar1button;
delete gar2button;
delete gar3button;
delete gar4button;
if(curBack)
SDL_FreeSurface(curBack);
delete skillpics;
delete flags;
}
void CHeroWindow::show(SDL_Surface *to)
@@ -44,6 +61,10 @@ void CHeroWindow::show(SDL_Surface *to)
quitButton->show();
dismissButton->show();
questlogButton->show();
gar1button->show();
gar2button->show();
gar3button->show();
gar4button->show();
}
void CHeroWindow::setHero(const CGHeroInstance *hero)
@@ -63,6 +84,11 @@ void CHeroWindow::quit()
quitButton->deactivate();
dismissButton->deactivate();
questlogButton->deactivate();
gar1button->deactivate();
gar2button->deactivate();
gar3button->deactivate();
gar4button->deactivate();
LOCPLINT->adventureInt->show();
SDL_FreeSurface(curBack);
@@ -74,6 +100,10 @@ void CHeroWindow::activate()
quitButton->activate();
dismissButton->activate();
questlogButton->activate();
gar1button->activate();
gar2button->activate();
gar3button->activate();
gar4button->activate();
curBack = CSDL_Ext::copySurface(background);
blitAt(skillpics->ourImages[0].bitmap, 32, 111, curBack);
@@ -82,6 +112,41 @@ void CHeroWindow::activate()
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);
}
void CHeroWindow::dismissCurrent()
@@ -91,3 +156,19 @@ void CHeroWindow::dismissCurrent()
void CHeroWindow::questlog()
{
}
void CHeroWindow::gar1()
{
}
void CHeroWindow::gar2()
{
}
void CHeroWindow::gar3()
{
}
void CHeroWindow::gar4()
{
}

View File

@@ -10,12 +10,14 @@ class CHeroWindow: public IShowable, public virtual CIntObject
{
SDL_Surface * background, * curBack;
const CGHeroInstance * curHero;
int player;
//general graphics
CDefHandler * skillpics;
CDefHandler * skillpics, *flags;
//buttons
AdventureMapButton<CHeroWindow> * quitButton, * dismissButton, * questlogButton;
AdventureMapButton<CHeroWindow> * quitButton, * dismissButton, * questlogButton, //general
* gar1button, * gar2button, * gar3button, * gar4button; //garrison / formation handling
public:
CHeroWindow(int playerColor); //c-tor
~CHeroWindow(); //d-tor
@@ -25,4 +27,8 @@ public:
void quit(); //stops displaying hero window
void dismissCurrent(); //dissmissed currently displayed hero (curHero) //TODO: make it working
void questlog(); //show quest log in
void gar1(); //garrison / formation handling
void gar2(); //garrison / formation handling
void gar3(); //garrison / formation handling
void gar4(); //garrison / formation handling
};

View File

@@ -32,6 +32,15 @@ void CGeneralTextHandler::load()
arraytxt.push_back(tmp);
}
itr = 0;
std::string strin = CGI->bitmaph->getTextFile("PRISKILL.TXT");
for(int hh=0; hh<4; ++hh)
{
std::string tmp;
CGeneralTextHandler::loadToIt(tmp, strin, itr, 3);
primarySkillNames.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

@@ -10,6 +10,7 @@ public:
std::vector<std::string> allTexts;
std::vector<std::string> arraytxt;
std::vector<std::string> primarySkillNames;
/*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

@@ -31,7 +31,14 @@ void CHeroHandler::loadPortraits()
heroes[ID]->portraitSmall=CGI->bitmaph->loadBitmap(path);
if (!heroes[ID]->portraitSmall)
std::cout<<"Can't read small portrait for "<<ID<<" ("<<path<<")\n";
path.replace(2,1,"L");
for(int ff=0; ff<path.size(); ++ff) //size letter is usually third one, but there are exceptions an it should fix the problem
{
if(path[ff]=='S')
{
path[ff]='L';
break;
}
}
heroes[ID]->portraitLarge=CGI->bitmaph->loadBitmap(path);
if (!heroes[ID]->portraitLarge)
std::cout<<"Can't read large portrait for "<<ID<<" ("<<path<<")\n";