1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-15 13:33:36 +02:00

forgot to fix line endings and one file

This commit is contained in:
Ivan Savenko 2010-01-31 23:30:47 +00:00
parent eefdd686de
commit ddd0786739
6 changed files with 356 additions and 258 deletions

View File

@ -51,7 +51,7 @@ CHeroWindow::CHeroWindow(int playerColor):
pos.w = background->w;
curBack = NULL;
curHero = NULL;
char bufor[400];
char bufor[400];
artifs = new CArtifactsOfHero(pos);
artifs->commonInfo = new CArtifactsOfHero::SCommonPart;
@ -95,15 +95,15 @@ CHeroWindow::CHeroWindow(int playerColor):
primSkillAreas[v]->text = CGI->generaltexth->arraytxt[2+v];
primSkillAreas[v]->type = v;
primSkillAreas[v]->bonus = -1; // to be initilized when hero is being set
primSkillAreas[v]->baseType = 0;
primSkillAreas[v]->baseType = 0;
sprintf(bufor, CGI->generaltexth->heroscrn[1].c_str(), CGI->generaltexth->primarySkillNames[v].c_str());
primSkillAreas[v]->hoverText = std::string(bufor);
}
}
specArea = new LRClickableAreaWText();
specArea->pos = genRect(42, 136, pos.x+83, pos.y + 188);
specArea->hoverText = CGI->generaltexth->heroscrn[27];
specArea->hoverText = CGI->generaltexth->heroscrn[27];
expArea = new LRClickableAreaWText();
expArea->pos = genRect(42, 136, pos.x+83, pos.y + 236);
@ -162,7 +162,7 @@ CHeroWindow::~CHeroWindow()
delete portraitArea;
delete expArea;
delete luck;
delete morale;
delete morale;
delete specArea;
delete spellPointsArea;
for(size_t v=0; v<primSkillAreas.size(); ++v)
@ -205,8 +205,8 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
//pos temporarily switched, restored later
pos.x -= 65;
pos.y -= 8;
specArea->text = CGI->generaltexth->hTxts[hero->subID].longBonus;
specArea->text = CGI->generaltexth->hTxts[hero->subID].longBonus;
gar2button->callback.clear();
gar2button->callback2.clear();
@ -254,7 +254,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
boost::replace_first(expArea->text, "%d", boost::lexical_cast<std::string>(hero->exp));
//printing spell points
sprintf(bufor, CGI->generaltexth->allTexts[205].c_str(), hero->name.c_str(), hero->mana, hero->manaLimit());
sprintf(bufor, CGI->generaltexth->allTexts[205].c_str(), hero->name.c_str(), hero->mana, hero->manaLimit());
spellPointsArea->text = std::string(bufor);
artifs->setHero(hero);
@ -283,8 +283,8 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
morale->bonus = mrlv;
morale->text = CGI->generaltexth->arraytxt[88];
boost::algorithm::replace_first(morale->text,"%s",CGI->generaltexth->arraytxt[86-mrlt]);
if (!mrl.size())
morale->text += CGI->generaltexth->arraytxt[108];
if (!mrl.size())
morale->text += CGI->generaltexth->arraytxt[108];
else
for(int it=0; it < mrl.size(); it++)
morale->text += mrl[it].second;
@ -299,8 +299,8 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
luck->bonus = mrlv;
luck->text = CGI->generaltexth->arraytxt[62];
boost::algorithm::replace_first(luck->text,"%s",CGI->generaltexth->arraytxt[60-mrlt]);
if (!mrl.size())
luck->text += CGI->generaltexth->arraytxt[77];
if (!mrl.size())
luck->text += CGI->generaltexth->arraytxt[77];
else
for(int it=0; it < mrl.size(); it++)
luck->text += mrl[it].second;
@ -326,7 +326,7 @@ void CHeroWindow::activate()
gar2button->activate();
formations->activate();
//gar4button->activate();
portraitArea->activate();
portraitArea->activate();
specArea->activate();
expArea->activate();
spellPointsArea->activate();
@ -360,7 +360,7 @@ void CHeroWindow::deactivate()
dismissButton->deactivate();
questlogButton->deactivate();
gar2button->deactivate();
formations->deactivate();
formations->deactivate();
specArea->deactivate();
//gar4button->deactivate();
portraitArea->deactivate();
@ -508,7 +508,7 @@ void CHeroWindow::redrawCurBack()
}
//printing special ability
blitAt(graphics->un44->ourImages[curHero->subID].bitmap, 18, 180, curBack);
blitAt(graphics->un44->ourImages[curHero->subID].bitmap, 18, 180, curBack);
CSDL_Ext::printAt(CGI->generaltexth->jktexts[5].substr(1, CGI->generaltexth->jktexts[5].size()-2), 69, 183, GEOR13, tytulowy, curBack);
CSDL_Ext::printAt(CGI->generaltexth->hTxts[curHero->subID].bonusName, 69, 199, GEOR16, zwykly, curBack);

View File

@ -46,7 +46,7 @@ class CHeroWindow: public CWindowWithGarrison
std::vector<LRClickableAreaWTextComp *> primSkillAreas;
LRClickableAreaWText * expArea;
LRClickableAreaWText * spellPointsArea;
LRClickableAreaWTextComp * luck;
LRClickableAreaWTextComp * luck;
LRClickableAreaWText * specArea;//speciality
LRClickableAreaWTextComp * morale;
std::vector<LRClickableAreaWTextComp *> secSkillAreas;

View File

@ -2,6 +2,7 @@
#include "AdventureMapButton.h"
#include "CAdvmapInterface.h"
#include "../CCallback.h"
#include "../global.h"
#include "CConfigHandler.h"
#include "CGameInfo.h"
#include "CHeroWindow.h"
@ -10,10 +11,10 @@
#include "SDL_Extensions.h"
#include "Graphics.h"
#include "../hch/CArtHandler.h"
#include "../hch/CBuildingHandler.h"
#include "../hch/CDefHandler.h"
#include "../hch/CGeneralTextHandler.h"
#include "../hch/CObjectHandler.h"
#include "../hch/CHeroHandler.h"
#include "../hch/CTownHandler.h"
#include "../lib/map.h"
#include "../lib/NetPacks.h"
@ -42,23 +43,23 @@ CDefEssential* CKingdomInterface::hall;
CKingdomInterface::CKingdomInterface()
{
OBJ_CONSTRUCTION_CAPTURING_ALL;
defActions =/* ACTIVATE | DEACTIVATE | */SHARE_POS | DISPOSE;
defActions = SHARE_POS | DISPOSE;
PicCount = ADVOPT.overviewPics;
size = ADVOPT.overviewSize;
size = ADVOPT.overviewSize;
pos.x = screen->w/2 - 400;
pos.y = screen->h/2 - (68+58*size);
heroPos = townPos = objPos = 0;
state = 0;
showHarrisoned = false;//set to true if you want to see garrisoned heroes
heroPos = townPos = objPos = state = 0;
bg = BitmapHandler::loadBitmap(ADVOPT.overviewBg);
graphics->blueToPlayersAdv(bg, LOCPLINT->playerID);
mines = CDefHandler::giveDefEss("OVMINES.DEF");
title = CDefHandler::giveDefEss("OVTITLE.DEF");
hall = CDefHandler::giveDefEss("ITMTL.DEF");
fort = CDefHandler::giveDefEss("ITMCL.DEF");
mines = CDefHandler::giveDefEss("OVMINES.DEF");
title = CDefHandler::giveDefEss("OVTITLE.DEF");
hall = CDefHandler::giveDefEss("ITMTL.DEF");
fort = CDefHandler::giveDefEss("ITMCL.DEF");
objPics = CDefHandler::giveDefEss("FLAGPORT.DEF");
slots = CDefHandler::giveDefEss("OVSLOT.DEF");
slots = CDefHandler::giveDefEss("OVSLOT.DEF");
toHeroes = new AdventureMapButton (CGI->generaltexth->overview[11],"",
boost::bind(&CKingdomInterface::listToHeroes,this),748,28+size*116,"OVBUTN1.DEF");
@ -75,24 +76,16 @@ CKingdomInterface::CKingdomInterface()
statusbar = new CStatusBar(pos.x+7,pos.y+91+size*116,"TSTATBAR.bmp",732);
resdatabar = new CResDataBar("KRESBAR.bmp",pos.x+3,pos.y+111+size*116,32,2,76,76);
for (int i = 0; i<size; i++)
blitAt(slots->ourImages[PicCount].bitmap,23,26+i*116,bg);
for (size_t i=0; i<RESOURCE_QUANTITY; i++)
incomes.push_back(new CResIncomePic(i,mines,this));//bottom panel with mines
heroes.resize(size);
for(size_t i=0;i<size;i++)//creating empty hero/town lists for input
heroes[i] = new CHeroItem(i,this);
towns.resize(size);
for(size_t i=0;i<size;i++)
towns[i] = new CTownItem(i,this);
{
heroes.push_back( new CHeroItem(i,this));
towns.push_back( new CTownItem(i,this));
}
slider = new CSlider(4, 4, size*116+19, boost::bind (&CKingdomInterface::sliderMoved, this, _1),
size, LOCPLINT->cb->howManyHeroes(showHarrisoned), 0, false, 0);
//creating objects list
ObjTop = new AdventureMapButton ("","", boost::bind(&CKingdomInterface::moveObjectList,this,0),
733,4,"OVBUTN4.DEF");
@ -108,6 +101,16 @@ CKingdomInterface::CKingdomInterface()
733,size*116+2,"OVBUTN4.DEF");
ObjBottom->bitmapOffset = 2;
for (size_t i=0; i<SKILL_PER_HERO; i++)
{
incomes.push_back(new HoverableArea());//bottom panel with mines
incomes[i]->pos = genRect(54,68,pos.x+20+i*80,pos.y+31+size*116);
incomes[i]->hoverText = CGI->generaltexth->mines[i].first;
}
incomes[7]->pos.w = 136;
incomes[7]->hoverText = CGI->generaltexth->allTexts[255];
incomesVal+=0,0,0,0,0,0,0,0;//for mines images
std::map<std::pair<int,int>,int> addObjects;//objects to print, except 17th dwelling
//format: (id,subID),image index
#define INSERT_MAP addObjects.insert(std::pair<std::pair<int,int>,int>(std::pair<int,int>
@ -121,15 +124,15 @@ CKingdomInterface::CKingdomInterface()
INSERT_MAP (20,0) ,86));//Conflux
INSERT_MAP (87,0) ,87));//Harbor
#undef INSERT_MAP
for(size_t i = 0; i<CGI->state->map->objects.size(); i++)
{
CGObjectInstance* obj = CGI->state->map->objects[i];//current object
if (obj)
{
std::pair<int,int > curElm = std::pair<int,int >(obj->ID, obj->subID);
if (obj->tempOwner == CGI->state->currentPlayer)//if object is our
{
std::pair<int,int > curElm = std::pair<int,int >(obj->ID, obj->subID);
if ( obj->ID == 17 )//dwelling, text is a plural name of a creature
{
objList[obj->subID].first += 1;
@ -140,9 +143,12 @@ CKingdomInterface::CKingdomInterface()
objList[addObjects[curElm]].first += 1;
objList[addObjects[curElm]].second = & obj->hoverName;
}
else if ( obj->ID == 53 )//TODO: abandoned mines
incomesVal[obj->subID]+=1;
}
}
}
addObjects.clear();
objSize = (size*116-64)/57; //in object list will fit (height of panel)/(height of one element) items
ObjList.resize(objSize);
@ -151,6 +157,25 @@ CKingdomInterface::CKingdomInterface()
ObjList[i] = new HoverableArea();
ObjList[i]->pos = genRect(50,50,pos.x+740,pos.y+44+i*57);
}
incomesVal[7] = incomesVal[6]*1000;//gold mines -> total income
std::vector<const CGHeroInstance*> heroes = LOCPLINT->cb->getHeroesInfo(true);
for(size_t i=0; i<heroes.size();i++)
switch(heroes[i]->getSecSkillLevel(13))//some heroes may have estates
{
case 1: //basic
incomesVal[7] += 125;
break;
case 2: //advanced
incomesVal[7] += 250;
break;
case 3: //expert
incomesVal[7] += 500;
break;
}
std::vector<const CGTownInstance*> towns = LOCPLINT->cb->getTownsInfo(true);
for(size_t i=0; i<towns.size();i++)
incomesVal[7] += towns[i]->dailyIncome();
}
void CKingdomInterface::moveObjectList(int newPos)
@ -179,8 +204,8 @@ CKingdomInterface::~CKingdomInterface()
delete slots;
delete fort;
delete hall;
delete mines;
delete objPics;
delete mines;
towns.clear();//deleting lists
heroes.clear();
@ -246,9 +271,15 @@ void CKingdomInterface::showAll( SDL_Surface * to/*=NULL*/)
for (size_t i=0; i<size; i++)
heroes[i]->showAll(to);//show hero list
}
for (int i = 0; i<7; i++)
blitAt(mines->ourImages[i].bitmap,pos.x + 20 + i*80,pos.y + 31+size*116,to);
for(size_t i=0;i<incomes.size();i++)
incomes[i]->show(to);//printing resource incomes
{
std::ostringstream oss;
oss << incomesVal[i];
CSDL_Ext::printAtMiddle(oss.str(),incomes[i]->pos.x+incomes[i]->pos.w/2,incomes[i]->pos.y+50,GEOR13,zwykly,to);
}
slider->showAll(to);
if(screen->w != 800 || screen->h !=600)
@ -412,112 +443,152 @@ void CKingdomInterface::sliderMoved(int newpos)
}
}
CKingdomInterface::CResIncomePic::CResIncomePic(int RID, CDefEssential * Mines, CKingdomInterface * Owner)
{
used = HOVER;
recActions =/* ACTIVATE | DEACTIVATE | SHOWALL |*/ DISPOSE | SHARE_POS;
resID = RID;
pos.x += 20 + RID*80;
pos.y += 31+Owner->size*116;
pos.h = 54;
pos.w = (resID!=7)?68:136;//gold pile is bigger
mines = Mines;
if ( resID != 7)
{
MetaString ms;
ms << std::pair<ui8,ui32>(9,resID);
ms.toString(hoverText);
}
else
hoverText = CGI->generaltexth->allTexts[255];
value = 0;
int resource = resID==7?6:resID;
for(size_t i = 0; i<CGI->state->map->objects.size(); i++)
{
CGObjectInstance* obj = CGI->state->map->objects[i];
if (obj)
if (obj->ID == 53 && obj->subID == resource && //this is mine, produce required resource
CGI->state->currentPlayer == obj->tempOwner )//mine is ours
value++;
}
if (resID == 7)//we need to calculate income of whole kingdom
{
value *=1000;// mines = 1000 gold
std::vector<const CGHeroInstance*> heroes = LOCPLINT->cb->getHeroesInfo(true);
for(size_t i=0; i<heroes.size();i++)
switch(heroes[i]->getSecSkillLevel(13))//some heroes may have estates
{
case 1: //basic
value += 125;
break;
case 2: //advanced
value += 250;
break;
case 3: //expert
value += 500;
break;
}
std::vector<const CGTownInstance*> towns = LOCPLINT->cb->getTownsInfo(true);
for(size_t i=0; i<towns.size();i++)
value += towns[i]->dailyIncome();
}
}
CKingdomInterface::CResIncomePic::~CResIncomePic()
{
}
void CKingdomInterface::CResIncomePic::hover(bool on)
{
if (on)
{
LOCPLINT->statusbar->print(hoverText);
}
else
LOCPLINT->statusbar->clear();
}
void CKingdomInterface::CResIncomePic::show(SDL_Surface * to)
{
if (resID < 7)//this is not income
blitAt(mines->ourImages[resID].bitmap,pos.x,pos.y,to);
std::ostringstream oss;
oss << value;
CSDL_Ext::printAtMiddle(oss.str(),pos.x+pos.w/2,pos.y+50,GEOR13,zwykly,to);
}
CKingdomInterface::CTownItem::CTownItem(int num, CKingdomInterface * Owner)
{
recActions = DISPOSE | SHARE_POS;
owner = Owner;
numb = num;
pos.x += 23;
pos.y += 26+num*116;
pos.y += 25+num*116;
pos.w = 702;
pos.h = 114;
town = NULL;
garr = NULL;
garrHero = new HoverableArea();
garrHero->pos = genRect(64, 58, pos.x+244, pos.y + 6);
visitHero = new HoverableArea();
visitHero->pos = genRect(64, 58, pos.x+476, pos.y + 6);
for (int i=0; i<CREATURES_PER_TOWN;i++)
{//creatures info
creaGrowth.push_back(new HoverableArea());
creaGrowth[i]->pos = genRect(32, 32, pos.x+56+i*37, pos.y + 78);
creaCount.push_back(new CCreaPlace());
creaCount[i]->pos = genRect(32, 32, pos.x+409+i*37, pos.y + 78);
creaCount[i]->type = i;
}
hallArea = new HoverableArea();
hallArea->pos = genRect(38, 38, pos.x+69, pos.y + 31);
fortArea = new HoverableArea();
fortArea->pos = genRect(38, 38, pos.x+111, pos.y + 31);
townImage = new HoverableArea();
townImage->pos = genRect(64, 58, pos.x+5, pos.y + 6);
incomeArea = new HoverableArea();
incomeArea->pos = genRect(42, 64, pos.x+154, pos.y + 31);
incomeArea->hoverText = CGI->generaltexth->allTexts[255];
}
CKingdomInterface::CTownItem::~CTownItem()
{
creaGrowth.clear();
creaCount.clear();
delete garr;
}
void CKingdomInterface::CTownItem::setTown(const CGTownInstance * newTown)
{
BLOCK_CAPTURING;
delete garr;
town = newTown;
if (!town)
{
return;
garr = NULL;
}
garr = new CGarrisonInt(pos.x+313,pos.y+3,4,Point(232,0),slots->ourImages[owner->PicCount+2].bitmap,Point(313,2),town,town->visitingHero,false,true, 4,Point(-126,37));
garr->update = false;
/*for (int i=4; i<7; i++)
{
garr->sup[0][i][0].pos.x -= 126;
garr->sup[0][i][0].pos.y += 37;
garr->sdown[0][i][0].pos.x -= 126;
garr->sdown[0][i][0].pos.y += 37;
}*/
for (int i=0; i<CREATURES_PER_TOWN;i++)
{
creaCount[i]->town = NULL;
int crid = -1;
if (!vstd::contains(town->builtBuildings,30+i))
continue;
if (vstd::contains(town->builtBuildings,30+i+CREATURES_PER_TOWN))
crid = town->town->upgradedCreatures[i];
else
crid = town->town->basicCreatures[i];
std::string descr=CGI->generaltexth->allTexts[588];
boost::algorithm::replace_first(descr,"%s",CGI->creh->creatures[crid].namePl);
creaGrowth[i]->hoverText = descr;
descr=CGI->generaltexth->heroscrn[1];
boost::algorithm::replace_first(descr,"%s",CGI->creh->creatures[crid].namePl);
creaCount[i]->hoverText = descr;
creaCount[i]->town = town;
}
townImage->hoverText = town->name;
hallArea->hoverText = CGI->buildh->buildings[town->subID][10+town->hallLevel()]->Name();
if (town->hasFort())
fortArea->hoverText = CGI->buildh->buildings[town->subID][6+town->fortLevel()]->Name();
else
fortArea->hoverText = "";
}
void CKingdomInterface::CTownItem::activate()
{
if (!town)
return;
garr->activate();
hallArea->activate();
fortArea->activate();
incomeArea->activate();
townImage->activate();
if (town->garrisonHero)
garrHero->activate();
if (town->visitingHero)
visitHero->activate();
for (int i=0; i<CREATURES_PER_TOWN;i++)
if (vstd::contains(town->builtBuildings,30+i))
{
creaGrowth[i]->activate();
creaCount [i]->activate();
}
}
void CKingdomInterface::CTownItem::deactivate()
{
if (!town)
return;
garr->deactivate();
hallArea->deactivate();
fortArea->deactivate();
incomeArea->deactivate();
townImage->deactivate();
if (town->garrisonHero)
garrHero->deactivate();
if (town->visitingHero)
visitHero->deactivate();
for (int i=0; i<CREATURES_PER_TOWN;i++)
if (vstd::contains(town->builtBuildings,30+i))
{
creaGrowth[i]->deactivate();
creaCount [i]->deactivate();
}
}
void CKingdomInterface::CTownItem::showAll(SDL_Surface * to)
@ -575,29 +646,13 @@ void CKingdomInterface::CTownItem::showAll(SDL_Surface * to)
ostrs << town->creatures[i].first;
CSDL_Ext::printTo(ostrs.str(),pos.x+440+i*37,pos.y+110,GEORM,zwykly,to);
}
const CGHeroInstance * hero = town->garrisonHero;
int posX = 244;
for (int i=0;i<2;i++)
{//heroes info
if (hero)
{
int iter = 0;//portrait
blitAt(graphics->portraitLarge[hero->portrait],pos.x+posX,pos.y+6,to);
for(std::map<si32,std::pair<ui32,si32> >::const_iterator
j=hero->army.slots.begin(); j!=hero->army.slots.end(); j++)
{//army
int X = (iter<4)?(pos.x+posX+70+36*iter):(pos.x+posX+88+36*(iter-4));
int Y = (iter<4)?(pos.y+3):(pos.y+40);
iter++;
blitAt(graphics->smallImgs[j->second.first],X,Y,to);
std::ostringstream creanum;
creanum << (j->second.second);
CSDL_Ext::printTo(creanum.str(),X+30,Y+32,GEORM,zwykly,to);
}
}
hero = town->visitingHero;
posX = 476;
}
garr->show(to);
if (town->garrisonHero)
blitAt(graphics->portraitLarge[town->garrisonHero->portrait],pos.x+244,pos.y+6,to);
if (town->visitingHero)
blitAt(graphics->portraitLarge[town->visitingHero->portrait],pos.x+476,pos.y+6,to);
}
CKingdomInterface::CHeroItem::CHeroItem(int num, CKingdomInterface * Owner)
@ -608,7 +663,7 @@ CKingdomInterface::CHeroItem::CHeroItem(int num, CKingdomInterface * Owner)
owner = Owner;
numb = num;
pos.x += 23;
pos.y += 26+num*116;
pos.y += 25+num*116;
pos.w = 702;
pos.h = 114;
hero = NULL;
@ -635,7 +690,7 @@ CKingdomInterface::CHeroItem::CHeroItem(int num, CKingdomInterface * Owner)
portrait = new LRClickableAreaWText();
portrait->pos = genRect(64, 58, pos.x+5, pos.y + 5);
char bufor[400];
for(int i=0; i<4; i++)
for(int i=0; i<PRIMARY_SKILLS; i++)
{
primarySkills.push_back(new LRClickableAreaWTextComp());
primarySkills[i]->pos = genRect(45, 32, pos.x+77 + 36*i, pos.y+26);
@ -646,7 +701,7 @@ CKingdomInterface::CHeroItem::CHeroItem(int num, CKingdomInterface * Owner)
primarySkills[i]->hoverText = std::string(bufor);
};
experience = new LRClickableAreaWText();
experience->pos = genRect(33, 49, pos.x+322, pos.y+4);
experience->pos = genRect(33, 49, pos.x+322, pos.y+5);
experience->hoverText = CGI->generaltexth->heroscrn[9];
morale = new LRClickableAreaWTextComp();
@ -656,17 +711,17 @@ CKingdomInterface::CHeroItem::CHeroItem(int num, CKingdomInterface * Owner)
luck->pos = genRect(20,32,pos.x+221,pos.y+28);
spellPoints = new LRClickableAreaWText();
spellPoints->pos = genRect(32, 48, pos.x+271, pos.y+4);
spellPoints->pos = genRect(33, 49, pos.x+270, pos.y+5);
spellPoints->hoverText = CGI->generaltexth->heroscrn[22];
speciality = new LRClickableAreaWText();
speciality->pos = genRect(32, 48, pos.x+271, pos.y+4);
speciality->pos = genRect(32, 32, pos.x+374, pos.y+5);
speciality->hoverText = CGI->generaltexth->heroscrn[27];
for(int i=0; i<8; ++i)
for(int i=0; i<SKILL_PER_HERO; ++i)
{
secondarySkills.push_back(new LRClickableAreaWTextComp());
secondarySkills[i]->pos = genRect(32, 32, pos.x+410+i*37, pos.y+4);
secondarySkills[i]->pos = genRect(32, 32, pos.x+410+i*37, pos.y+5);
secondarySkills[i]->baseType = 1;
};
@ -688,7 +743,12 @@ CKingdomInterface::CHeroItem::CHeroItem(int num, CKingdomInterface * Owner)
CKingdomInterface::CHeroItem::~CHeroItem()
{
delete garr;
delete artButtons;
primarySkills.clear();
secondarySkills.clear();
artifacts.clear();
backpack.clear();
}
void CKingdomInterface::CHeroItem::setHero(const CGHeroInstance * newHero)
@ -701,10 +761,11 @@ void CKingdomInterface::CHeroItem::setHero(const CGHeroInstance * newHero)
return;
garr = NULL;
}
char bufor[400];
char bufor[4000];
artLeft->block(hero->artifacts.size() <= 8);
artRight->block(hero->artifacts.size() <= 8);
garr = new CGarrisonInt(pos.x+6, pos.y+78, 4, Point(), owner->bg, Point(29,104), hero, NULL, false, true);
garr = new CGarrisonInt(pos.x+6, pos.y+78, 4, Point(), slots->ourImages[owner->PicCount].bitmap,
Point(6,78), hero, NULL, false, true);
garr->update = false;
for (int i=0; i<artifacts.size(); i++)
@ -735,6 +796,8 @@ void CKingdomInterface::CHeroItem::setHero(const CGHeroInstance * newHero)
portrait->hoverText = std::string(bufor);
portrait->text = hero->getBiography();
speciality->text = CGI->generaltexth->hTxts[hero->subID].longBonus;
//primary skills
for(size_t g=0; g<primarySkills.size(); ++g)
primarySkills[g]->bonus = hero->getPrimSkillLevel(g);
@ -769,8 +832,11 @@ void CKingdomInterface::CHeroItem::setHero(const CGHeroInstance * newHero)
morale->bonus = mrlv;
morale->text = CGI->generaltexth->arraytxt[88];
boost::algorithm::replace_first(morale->text,"%s",CGI->generaltexth->arraytxt[86-mrlt]);
for(int it=0; it < mrl.size(); it++)
morale->text += mrl[it].second;
if (!mrl.size())
morale->text += CGI->generaltexth->arraytxt[108];
else
for(int it=0; it < mrl.size(); it++)
morale->text += mrl[it].second;
//setting luck
mrl = hero->getCurrentLuckModifiers();
@ -781,9 +847,11 @@ void CKingdomInterface::CHeroItem::setHero(const CGHeroInstance * newHero)
luck->bonus = mrlv;
luck->text = CGI->generaltexth->arraytxt[62];
boost::algorithm::replace_first(luck->text,"%s",CGI->generaltexth->arraytxt[60-mrlt]);
for(int it=0; it < mrl.size(); it++)
luck->text += mrl[it].second;
// redrawCurBack();
if (!mrl.size())
luck->text += CGI->generaltexth->arraytxt[77];
else
for(int it=0; it < mrl.size(); it++)
luck->text += mrl[it].second;
}
void CKingdomInterface::CHeroItem::scrollArts(int move)
@ -800,7 +868,6 @@ void CKingdomInterface::CHeroItem::scrollArts(int move)
backpack[i]->hoverText = boost::str(boost::format(CGI->generaltexth->heroscrn[1].c_str()) % CGI->arth->artifacts[backpack[i]->type].Name());
}
}
GH.totalRedraw();
}
void CKingdomInterface::CHeroItem::showAll(SDL_Surface * to)
@ -959,7 +1026,7 @@ void CKingdomInterface::CHeroItem::CArtPlace::activate()
}
void CKingdomInterface::CHeroItem::CArtPlace::clickLeft(tribool down, bool previousState)
{tlog1<<pos.x<<" "<<type<<"\n";
{
if (!down && previousState && type>=0)
{
if(type == 0)
@ -982,3 +1049,34 @@ void CKingdomInterface::CHeroItem::CArtPlace::deactivate()
{
LRClickableAreaWTextComp::deactivate();
}
CKingdomInterface::CTownItem::CCreaPlace::CCreaPlace()
{
town = NULL;
used = LCLICK | RCLICK | HOVER;
}
void CKingdomInterface::CTownItem::CCreaPlace::activate()
{
LRClickableAreaWTextComp::activate();
}
void CKingdomInterface::CTownItem::CCreaPlace::clickLeft(tribool down, bool previousState)
{
if (!down && previousState && town)
{
GH.pushInt (new CRecruitmentWindow(town, type, town, boost::bind
(&CCallback::recruitCreatures,LOCPLINT->cb,town,_1,_2)));
}
}
void CKingdomInterface::CTownItem::CCreaPlace::clickRight(tribool down, bool previousState)
{
//TODO
}
void CKingdomInterface::CTownItem::CCreaPlace::deactivate()
{
LRClickableAreaWTextComp::deactivate();
}

View File

@ -5,7 +5,7 @@
#include "../global.h"
#include <SDL.h>
#include "GUIBase.h"
#include "GUIBase.h"
#include "GUIClasses.h"
#include "../hch/CMusicBase.h"
class AdventureMapButton;
@ -15,8 +15,8 @@ class CStatusBar;
class CSlider;
class CMinorResDataBar;
class HoverableArea;
/*class LRClickableAreaWText
class LRClickableAreaWTextComp*/
/*class LRClickableAreaWText
class LRClickableAreaWTextComp*/
/*
* CKingdomInterface.h, part of VCMI engine
@ -29,9 +29,9 @@ class LRClickableAreaWTextComp*/
*/
class CKingdomInterface : public CIntObject
{
{
class CTownItem : public CWindowWithGarrison
{
{
class CCreaPlace: public LRClickableAreaWTextComp
{
public:
@ -41,25 +41,25 @@ class CKingdomInterface : public CIntObject
void clickRight(tribool down, bool previousState);
void activate();
void deactivate();
};
public:
const CGTownInstance * town;
};
public:
const CGTownInstance * town;
CKingdomInterface * owner;
int numb;//position on screen (1..size)
HoverableArea *hallArea, *fortArea, *incomeArea;//hoverable text for town hall, fort, income
HoverableArea * garrHero, *visitHero;//portraits of heroes
HoverableArea * townImage;//town image
std::vector < HoverableArea * > creaGrowth;
std::vector < CCreaPlace * > creaCount;
int numb;//position on screen (1..size)
HoverableArea *hallArea, *fortArea, *incomeArea;//hoverable text for town hall, fort, income
HoverableArea * garrHero, *visitHero;//portraits of heroes
HoverableArea * townImage;//town image
std::vector < HoverableArea * > creaGrowth;
std::vector < CCreaPlace * > creaCount;
void setTown(const CGTownInstance * newTown);//change town and update info
void showAll(SDL_Surface * to);
void showAll(SDL_Surface * to);
void activate();
void deactivate();
void deactivate();
CTownItem (int num, CKingdomInterface * Owner);//c-tor
~CTownItem();//d-tor
};
class CHeroItem : public CWindowWithGarrison
{
class CHeroItem : public CWindowWithGarrison
{
class CArtPlace: public LRClickableAreaWTextComp
{
public:
@ -69,38 +69,38 @@ class CKingdomInterface : public CIntObject
void clickRight(tribool down, bool previousState);
void activate();
void deactivate();
};
public:
const CGHeroInstance * hero;
};
public:
const CGHeroInstance * hero;
CKingdomInterface * owner;
int artGroup,numb;//current art group (0 = equiped, 1 = misc, 2 = backpack)
int backpackPos;//first visible artifact in backpack
AdventureMapButton * artLeft, * artRight;//buttons for backpack
LRClickableAreaWText * portrait;
LRClickableAreaWText * experience;
LRClickableAreaWTextComp * morale, * luck;
LRClickableAreaWText * spellPoints;
LRClickableAreaWText * speciality;
std::vector<LRClickableAreaWTextComp *> primarySkills;
std::vector<LRClickableAreaWTextComp *> secondarySkills;
std::vector<LRClickableAreaWTextComp *> artifacts;
std::vector<LRClickableAreaWTextComp *> backpack;
CHighlightableButtonsGroup * artButtons;
void setHero(const CGHeroInstance * newHero);//change hero and update info
int artGroup,numb;//current art group (0 = equiped, 1 = misc, 2 = backpack)
int backpackPos;//first visible artifact in backpack
AdventureMapButton * artLeft, * artRight;//buttons for backpack
LRClickableAreaWText * portrait;
LRClickableAreaWText * experience;
LRClickableAreaWTextComp * morale, * luck;
LRClickableAreaWText * spellPoints;
LRClickableAreaWText * speciality;
std::vector<LRClickableAreaWTextComp *> primarySkills;
std::vector<LRClickableAreaWTextComp *> secondarySkills;
std::vector<LRClickableAreaWTextComp *> artifacts;
std::vector<LRClickableAreaWTextComp *> backpack;
CHighlightableButtonsGroup * artButtons;
void setHero(const CGHeroInstance * newHero);//change hero and update info
void scrollArts(int move);//moving backpack, receiving distance
void onArtChange(int newstate);//changes artgroup
void showAll(SDL_Surface * to);
void showAll(SDL_Surface * to);
void activate();
void deactivate();
CHeroItem (int num, CKingdomInterface * Owner);//c-tor
~CHeroItem();//d-tor
~CHeroItem();//d-tor
};
public:
//common data
int state;//1 = towns showed, 2 = heroes;
SDL_Surface * bg;//background
CStatusBar * statusbar;//statusbar
CResDataBar *resdatabar;//resources
CResDataBar *resdatabar;//resources
int size,PicCount;
//buttons
@ -125,8 +125,8 @@ public:
AdventureMapButton* ObjUp, *ObjDown, *ObjTop, *ObjBottom;//buttons for dwellings list
//income pics
std::vector<HoverableArea*> incomes;//mines + incomes
std::vector<int> incomesVal;//values to print
std::vector<HoverableArea*> incomes;//mines + incomes
std::vector<int> incomesVal;//values to print
CDefEssential * mines;
CKingdomInterface(); //c-tor

View File

@ -495,12 +495,12 @@ void CGarrisonInt::createSlots()
for(int i=0; i<sup->size(); i++)
if((*sup)[i] == NULL)
(*sup)[i] = new CGarrisonSlot(this, pos.x + (i*(w+interx)), pos.y,i,0,NULL, 0);
if (shiftPos)
for (int i=shiftPos; i<sup->size(); i++)
{
(*sup)[i]->pos.x += shiftPoint.x;
(*sup)[i]->pos.y += shiftPoint.y;
};
if (shiftPos)
for (int i=shiftPos; i<sup->size(); i++)
{
(*sup)[i]->pos.x += shiftPoint.x;
(*sup)[i]->pos.y += shiftPoint.y;
};
}
if(set2)
{
@ -516,12 +516,12 @@ void CGarrisonInt::createSlots()
for(int i=0; i<sdown->size(); i++)
if((*sdown)[i] == NULL)
(*sdown)[i] = new CGarrisonSlot(this, pos.x + (i*(w+interx)) + garOffset.x, pos.y + garOffset.y,i,1, NULL, 0);
if (shiftPos)
for (int i=shiftPos; i<sup->size(); i++)
{
(*sdown)[i]->pos.x += shiftPoint.x;
(*sdown)[i]->pos.y += shiftPoint.y;
};
if (shiftPos)
for (int i=shiftPos; i<sup->size(); i++)
{
(*sdown)[i]->pos.x += shiftPoint.x;
(*sdown)[i]->pos.y += shiftPoint.y;
};
}
}
void CGarrisonInt::deleteSlots()
@ -4189,18 +4189,18 @@ void CExchangeWindow::activate()
for(int g=0; g<ARRAY_COUNT(luck); g++)
luck[g]->activate();
for(int g=0; g<ARRAY_COUNT(portrait); g++)
portrait[g]->activate();
portrait[g]->activate();
for(int g=0; g<ARRAY_COUNT(spellPoints); g++)
spellPoints[g]->activate();
spellPoints[g]->activate();
for(int g=0; g<ARRAY_COUNT(experience); g++)
experience[g]->activate();
experience[g]->activate();
for(int g=0; g<ARRAY_COUNT(speciality); g++)
speciality[g]->activate();
speciality[g]->activate();
}
void CExchangeWindow::deactivate()
@ -4229,17 +4229,17 @@ void CExchangeWindow::deactivate()
morale[g]->deactivate();
for(int g=0; g<ARRAY_COUNT(luck); g++)
luck[g]->deactivate();
luck[g]->deactivate();
for(int g=0; g<ARRAY_COUNT(portrait); g++)
portrait[g]->deactivate();
portrait[g]->deactivate();
for(int g=0; g<ARRAY_COUNT(spellPoints); g++)
spellPoints[g]->deactivate();
spellPoints[g]->deactivate();
for(int g=0; g<ARRAY_COUNT(experience); g++)
experience[g]->deactivate();
experience[g]->deactivate();
for(int g=0; g<ARRAY_COUNT(speciality); g++)
speciality[g]->deactivate();
}
@ -4374,7 +4374,7 @@ CExchangeWindow::CExchangeWindow(si32 hero1, si32 hero2) : bg(NULL)
primSkillAreas[g]->text = CGI->generaltexth->arraytxt[2+g];
primSkillAreas[g]->type = g;
primSkillAreas[g]->bonus = -1;
primSkillAreas[g]->baseType = 0;
primSkillAreas[g]->baseType = 0;
sprintf(bufor, CGI->generaltexth->heroscrn[1].c_str(), CGI->generaltexth->primarySkillNames[g].c_str());
primSkillAreas[g]->hoverText = std::string(bufor);
}
@ -4398,31 +4398,31 @@ CExchangeWindow::CExchangeWindow(si32 hero1, si32 hero2) : bg(NULL)
sprintf(bufor, CGI->generaltexth->heroscrn[21].c_str(), CGI->generaltexth->levels[level - 1].c_str(), CGI->generaltexth->skillName[skill].c_str());
secSkillAreas[b][g]->hoverText = std::string(bufor);
}
portrait[b] = new LRClickableAreaWText();
portrait[b]->pos = genRect(64, 58, pos.x + 257 + 228*b, pos.y + 13);
portrait[b]->text = heroInst[b]->getBiography();
portrait[b]->pos = genRect(64, 58, pos.x + 257 + 228*b, pos.y + 13);
portrait[b]->text = heroInst[b]->getBiography();
sprintf(bufor, CGI->generaltexth->allTexts[15].c_str(), heroInst[b]->name.c_str(), heroInst[b]->type->heroClass->name.c_str());
portrait[b]->hoverText = std::string(bufor);
portrait[b]->hoverText = std::string(bufor);
speciality[b] = new LRClickableAreaWText();
speciality[b]->pos = genRect(32, 32, pos.x + 69 + 490*b, pos.y + 45);
speciality[b]->hoverText = CGI->generaltexth->heroscrn[27];
speciality[b]->text = CGI->generaltexth->hTxts[heroInst[b]->subID].longBonus;
speciality[b]->hoverText = CGI->generaltexth->heroscrn[27];
speciality[b]->text = CGI->generaltexth->hTxts[heroInst[b]->subID].longBonus;
experience[b] = new LRClickableAreaWText();
experience[b]->pos = genRect(32, 32, pos.x + 105 + 490*b, pos.y + 45);
experience[b]->hoverText = CGI->generaltexth->heroscrn[9];
experience[b]->hoverText = CGI->generaltexth->heroscrn[9];
experience[b]->text = CGI->generaltexth->allTexts[2].c_str();
boost::replace_first(experience[b]->text, "%d", boost::lexical_cast<std::string>(heroInst[b]->level));
boost::replace_first(experience[b]->text, "%d", boost::lexical_cast<std::string>(CGI->heroh->reqExp(heroInst[b]->level+1)));
boost::replace_first(experience[b]->text, "%d", boost::lexical_cast<std::string>(heroInst[b]->exp));
boost::replace_first(experience[b]->text, "%d", boost::lexical_cast<std::string>(heroInst[b]->exp));
spellPoints[b] = new LRClickableAreaWText();
spellPoints[b]->pos = genRect(32, 32, pos.x + 141 + 490*b, pos.y + 45);
spellPoints[b]->hoverText = CGI->generaltexth->heroscrn[22];
sprintf(bufor, CGI->generaltexth->allTexts[205].c_str(), heroInst[b]->name.c_str(), heroInst[b]->mana, heroInst[b]->manaLimit());
spellPoints[b]->text = std::string(bufor);
spellPoints[b]->hoverText = CGI->generaltexth->heroscrn[22];
sprintf(bufor, CGI->generaltexth->allTexts[205].c_str(), heroInst[b]->name.c_str(), heroInst[b]->mana, heroInst[b]->manaLimit());
spellPoints[b]->text = std::string(bufor);
//setting morale
morale[b] = new LRClickableAreaWTextComp();
@ -4511,16 +4511,16 @@ CExchangeWindow::~CExchangeWindow() //d-tor
for(int g=0; g<ARRAY_COUNT(luck); g++)
delete luck[g];
for(int g=0; g<ARRAY_COUNT(portrait); g++)
delete portrait[g];
delete portrait[g];
for(int g=0; g<ARRAY_COUNT(spellPoints); g++)
delete spellPoints[g];
delete spellPoints[g];
for(int g=0; g<ARRAY_COUNT(experience); g++)
delete experience[g];
delete experience[g];
for(int g=0; g<ARRAY_COUNT(speciality); g++)
delete speciality[g];
}

View File

@ -207,13 +207,13 @@ class CGarrisonInt :public CIntObject
public:
int interx; //space between slots
Point garOffset, //offset between garrisons (not used if only one hero)
surOffset, //offset between garrison position on the bg surface and position on the screen
surOffset, //offset between garrison position on the bg surface and position on the screen
shiftPoint;//how last slots will be shifted (for second row, set shiftPoint for effect)
CGarrisonSlot *highlighted; //chosen slot
std::vector<AdventureMapButton *> splitButtons; //may be empty if no buttons
SDL_Surface *&sur; //bg surface
int p2, //TODO: comment me
int p2, //TODO: comment me
shiftPos;//1st slot of the second row, set shiftPoint for effect
bool ignoreEvent, update, active, splitting, pb,
smallIcons; //true - 32x32 imgs, false - 58x64
@ -735,11 +735,11 @@ class CExchangeWindow : public CWindowWithGarrison
std::vector<LRClickableAreaWTextComp *> secSkillAreas[2], primSkillAreas;
LRClickableAreaWTextComp *morale[2], *luck[2];
LRClickableAreaWText *speciality[2];
LRClickableAreaWText *experience[2];
LRClickableAreaWText *spellPoints[2];
LRClickableAreaWTextComp *morale[2], *luck[2];
LRClickableAreaWText *speciality[2];
LRClickableAreaWText *experience[2];
LRClickableAreaWText *spellPoints[2];
LRClickableAreaWText *portrait[2];
public: