1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

- some bugfixing

- removed redundant or unused code in GUI
This commit is contained in:
Ivan Savenko 2012-06-16 22:40:28 +00:00
parent 1b50082e43
commit 7a6133a824
5 changed files with 55 additions and 102 deletions

View File

@ -193,8 +193,8 @@ CHeroList::CHeroItem::CHeroItem(CHeroList *parent, const CGHeroInstance * Hero):
void CHeroList::CHeroItem::update()
{
movement->setFrame(std::min<size_t>(movement->size(), hero->movement / 100));
mana->setFrame(std::min<size_t>(mana->size(), hero->mana / 5));
movement->setFrame(std::min<size_t>(movement->size()-1, hero->movement / 100));
mana->setFrame(std::min<size_t>(mana->size()-1, hero->mana / 5));
redraw();
}
@ -243,19 +243,15 @@ void CHeroList::select(const CGHeroInstance * hero)
void CHeroList::update(const CGHeroInstance * hero)
{
if (vstd::contains(LOCPLINT->wanderingHeroes, hero))
//this hero is already present, update its status
for (auto iter = list->getItems().begin(); iter != list->getItems().end(); iter++)
{
//this hero is already present, update its status
for (auto iter = list->getItems().begin(); iter != list->getItems().end(); iter++)
auto item = dynamic_cast<CHeroItem*>(*iter);
if (item && item->hero == hero)
{
auto item = dynamic_cast<CHeroItem*>(*iter);
if (item && item->hero == hero)
{
item->update();
return;
}
item->update();
return;
}
return;
}
//simplest solution for now: reset list and restore selection
@ -909,6 +905,9 @@ void CInfoBar::updateEnemyTurn(double progress)
void CInfoBar::showHeroSelection(const CGHeroInstance * hero, bool onlyUpdate)
{
if (!hero)
return;
reset(HERO);
currentObject = hero;
visibleInfo->loadHero(hero);
@ -917,6 +916,9 @@ void CInfoBar::showHeroSelection(const CGHeroInstance * hero, bool onlyUpdate)
void CInfoBar::showTownSelection(const CGTownInstance * town, bool onlyUpdate)
{
if (!town)
return;
reset(TOWN);
currentObject = town;
visibleInfo->loadTown(town);

View File

@ -597,6 +597,8 @@ void CAdvMapInt::updateNextHero(const CGHeroInstance *h)
void CAdvMapInt::activate()
{
CIntObject::activate();
if (!(active & KEYBOARD))
activateKeys();
screenBuf = screen;
GH.statusbar = &statusbar;

View File

@ -425,12 +425,14 @@ void CPlayerInterface::heroManaPointsChanged(const CGHeroInstance * hero)
{
EVENT_HANDLER_CALLED_BY_CLIENT;
updateInfo(hero);
if(makingTurn && hero->tempOwner == playerID)
adventureInt->heroList.update(hero);
}
void CPlayerInterface::heroMovePointsChanged(const CGHeroInstance * hero)
{
EVENT_HANDLER_CALLED_BY_CLIENT;
if(makingTurn && hero->tempOwner == playerID)
adventureInt->heroList.redraw();
adventureInt->heroList.update(hero);
}
void CPlayerInterface::receivedResource(int type, int val)
{
@ -2357,7 +2359,6 @@ void CPlayerInterface::playerStartsTurn(ui8 player)
if(!GH.listInt.size())
{
GH.pushInt(adventureInt);
adventureInt->activateKeys();
}
if(howManyPeople == 1)
{

View File

@ -3313,6 +3313,7 @@ CTavernWindow::HeroPortrait::HeroPortrait(int &sel, int id, int x, int y, const
: h(H), _sel(&sel), _id(id)
{
addUsedEvents(LCLICK | RCLICK | HOVER);
OBJ_CONSTRUCTION_CAPTURING_ALL;
h = H;
pos.x += x;
pos.y += y;
@ -3331,13 +3332,9 @@ CTavernWindow::HeroPortrait::HeroPortrait(int &sel, int id, int x, int y, const
sprintf_s(descr, sizeof(descr),CGI->generaltexth->allTexts[215].c_str(),
h->name.c_str(), h->level, h->type->heroClass->name.c_str(), artifs);
descr[sizeof(descr)-1] = '\0';
new CAnimImage("portraitsLarge", h->subID);
}
}
void CTavernWindow::HeroPortrait::show(SDL_Surface * to)
{
blitAt(graphics->portraitLarge[h->subID],pos,to);
}
void CTavernWindow::HeroPortrait::hover( bool on )
@ -3533,7 +3530,6 @@ void CInGameConsole::endEnteringText(bool printEnteredText)
{
LOCPLINT->battleInt->console->ingcAlter = "";
}
}
void CInGameConsole::refreshEnteredText()
@ -3574,20 +3570,12 @@ CGarrisonWindow::CGarrisonWindow( const CArmedInstance *up, const CGHeroInstance
titleText = CGI->generaltexth->allTexts[35];
boost::algorithm::replace_first(titleText, "%s", garr->armedObjs[0]->Slots().begin()->second->type->namePl);
}
title = new CLabel(275, 30, FONT_BIG, CENTER, Colors::Jasmine, titleText);
new CLabel(275, 30, FONT_BIG, CENTER, Colors::Jasmine, titleText);
new CAnimImage("CREST58", garr->armedObjs[0]->getOwner(), 0, 28, 124);
new CAnimImage("PortraitsLarge", dynamic_cast<const CGHeroInstance*>(garr->armedObjs[1])->portrait, 0, 29, 222);
}
CGarrisonWindow::~CGarrisonWindow()
{
}
void CGarrisonWindow::showAll(SDL_Surface * to)
{
CWindowObject::showAll(to);
blitAtLoc(graphics->flags->ourImages[garr->armedObjs[1]->getOwner()].bitmap,28,124,to);
blitAtLoc(graphics->portraitLarge[static_cast<const CGHeroInstance*>(garr->armedObjs[1])->portrait],29,222,to);
}
IShowActivatable::IShowActivatable()
{
@ -3874,11 +3862,6 @@ bool CArtPlace::fitsHere(const CArtifactInstance * art) const
return art->canBePutAt(ArtifactLocation(ourOwner->curHero, slotID), true);
}
CArtPlace::~CArtPlace()
{
deactivate();
}
void CArtPlace::setMeAsDest(bool backpackAsVoid /*= true*/)
{
ourOwner->commonInfo->dst.setTo(this, backpackAsVoid);
@ -4521,15 +4504,6 @@ void CArtifactsOfHero::updateSlot(int slotID)
setSlotData(getArtPlace(slotID), slotID);
}
void CExchangeWindow::showAll(SDL_Surface * to)
{
CWindowObject::showAll(to);
//printing border around window
if(screen->w != 800 || screen->h !=600)
CMessage::drawBorder(LOCPLINT->playerID,to,828,628,pos.x-14,pos.y-15);
}
void CExchangeWindow::questlog(int whichHero)
{
CCS->curh->dragAndDropCursor(NULL);
@ -4586,7 +4560,7 @@ void CExchangeWindow::prepareBackground()
}
CExchangeWindow::CExchangeWindow(si32 hero1, si32 hero2):
CWindowObject(PLAYER_COLORED, "TRADE2")
CWindowObject(PLAYER_COLORED | BORDERED, "TRADE2")
{
OBJ_CONSTRUCTION_CAPTURING_ALL;
char bufor[400];
@ -4802,12 +4776,6 @@ void CPuzzleWindow::show(SDL_Surface * to)
CWindowObject::show(to);
}
void CTransformerWindow::CItem::showAll(SDL_Surface * to)
{
CIntObject::showAll(to);
printAtMiddle(boost::lexical_cast<std::string>(size),pos.x+28, pos.y+76,FONT_SMALL,Colors::Cornsilk,to);//stack size
}
void CTransformerWindow::CItem::move()
{
if (left)
@ -4826,6 +4794,11 @@ void CTransformerWindow::CItem::clickLeft(tribool down, bool previousState)
}
}
void CTransformerWindow::CItem::update()
{
icon->setFrame(parent->army->getCreature(id)->idNumber + 2);
}
CTransformerWindow::CItem::CItem(CTransformerWindow * _parent, int _size, int _id):
id(_id), size(_size), parent(_parent)
{
@ -4837,16 +4810,8 @@ CTransformerWindow::CItem::CItem(CTransformerWindow * _parent, int _size, int _i
pos.x += 45 + (id%3)*83 + id/6*83;
pos.y += 109 + (id/3)*98;
icon = new CAnimImage("TWCRPORT", parent->army->getCreature(id)->idNumber);
}
void CTransformerWindow::showAll(SDL_Surface * to)
{
CWindowObject::showAll(to);
printAtMiddleLoc( CGI->generaltexth->allTexts[485], 153, 29,FONT_SMALL, Colors::Jasmine,to);//holding area
printAtMiddleLoc( CGI->generaltexth->allTexts[486], 153+295, 29,FONT_SMALL, Colors::Jasmine,to);//transformer
printAtMiddleWBLoc(CGI->generaltexth->allTexts[487], 153, 75,FONT_MEDIUM, 32,Colors::Jasmine,to);//move creatures to create skeletons
printAtMiddleWBLoc(CGI->generaltexth->allTexts[488], 153+295, 75,FONT_MEDIUM, 32,Colors::Jasmine,to);//creatures here will become skeletons
icon = new CAnimImage("TWCRPORT", parent->army->getCreature(id)->idNumber + 2);
new CLabel(28, 76,FONT_SMALL, CENTER, Colors::Cornsilk, boost::lexical_cast<std::string>(size));//stack size
}
void CTransformerWindow::makeDeal()
@ -4864,6 +4829,14 @@ void CTransformerWindow::addAll()
showAll(screen2);
}
void CTransformerWindow::updateGarrisons()
{
BOOST_FOREACH(auto & item, items)
{
item->update();
}
}
CTransformerWindow::CTransformerWindow(const CGHeroInstance * _hero, const CGTownInstance * _town):
CWindowObject(PLAYER_COLORED, "SKTRNBK"),
hero(_hero),
@ -4883,6 +4856,12 @@ CTransformerWindow::CTransformerWindow(const CGHeroInstance * _hero, const CGTow
convert= new CAdventureMapButton(CGI->generaltexth->zelp[591],boost::bind(&CTransformerWindow::makeDeal,this), 269,416,"ALTSACR.DEF",SDLK_RETURN);
cancel = new CAdventureMapButton(CGI->generaltexth->zelp[592],boost::bind(&CTransformerWindow::close, this),392,416,"ICANCEL.DEF",SDLK_ESCAPE);
bar = new CGStatusBar(new CPicture(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
new CLabel(153, 29,FONT_SMALL, CENTER, Colors::Jasmine, CGI->generaltexth->allTexts[485]);//holding area
new CLabel(153+295, 29, FONT_SMALL, CENTER, Colors::Jasmine, CGI->generaltexth->allTexts[486]);//transformer
new CTextBox(CGI->generaltexth->allTexts[487], Rect(26, 56, 255, 40), 0, FONT_MEDIUM, CENTER, Colors::Jasmine);//move creatures to create skeletons
new CTextBox(CGI->generaltexth->allTexts[488], Rect(320, 56, 255, 40), 0, FONT_MEDIUM, CENTER, Colors::Jasmine);//creatures here will become skeletons
}
void CUniversityWindow::CItem::clickLeft(tribool down, bool previousState)
@ -4929,8 +4908,6 @@ int CUniversityWindow::CItem::state()
return 0;
if (parent->hero->type->heroClass->proSec[ID]==0)//can't learn this skill (like necromancy for most of non-necros)
return 0;
/* if (LOCPLINT->cb->getResourceAmount(6) < 2000 )//no gold - allowed in H3, confirm button is blocked instead
return 0;*/
return 2;
}
@ -5094,15 +5071,8 @@ CHillFortWindow::CHillFortWindow(const CGHeroInstance *visitor, const CGObjectIn
updateGarrisons();
}
void CHillFortWindow::activate()
{
CIntObject::activate();
GH.statusbar = bar;
}
void CHillFortWindow::updateGarrisons()
{
for (int i=0; i<GameConstants::RESOURCE_QUANTITY; i++)
totalSumm[i]=0;
@ -5244,12 +5214,6 @@ int CHillFortWindow::getState(int slot)
return 2;//can upgrade
}
void CThievesGuildWindow::activate()
{
CIntObject::activate();
GH.statusbar = statusBar;
}
CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
CWindowObject(PLAYER_COLORED | BORDERED, "TpRank"),
owner(_owner)
@ -5261,7 +5225,7 @@ CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
LOCPLINT->cb->getThievesGuildInfo(tgi, owner);
exitb = new CAdventureMapButton (CGI->generaltexth->allTexts[600], "", boost::bind(&CThievesGuildWindow::close,this), 748, 556, "TPMAGE1", SDLK_RETURN);
statusBar = new CGStatusBar(new CPicture(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
statusBar = new CGStatusBar(3, 555, "TStatBar.bmp", 742);
resdatabar = new CMinorResDataBar();
resdatabar->pos.x += pos.x;
@ -5301,7 +5265,7 @@ CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
{
for(int b=0; b<(tgi .* fields[g]).size(); ++b) //by places (1st, 2nd, ...)
{
std::vector<ui8> players = (tgi .* fields[g])[b]; //get players with this place in this line
std::vector<ui8> &players = (tgi .* fields[g])[b]; //get players with this place in this line
//position of box
int xpos = 259 + 66 * b;
@ -5440,11 +5404,6 @@ MoraleLuckBox::MoraleLuckBox(bool Morale, const Rect &r, bool Small):
pos = r + pos;
}
MoraleLuckBox::~MoraleLuckBox()
{
}
CArtifactHolder::CArtifactHolder()
{
}

View File

@ -693,7 +693,6 @@ public:
void clickRight(tribool down, bool previousState);
void hover (bool on);
HeroPortrait(int &sel, int id, int x, int y, const CGHeroInstance *H);
void show(SDL_Surface * to);
private:
int *_sel;
@ -761,7 +760,6 @@ public:
void set(const IBonusBearer *node);
MoraleLuckBox(bool Morale, const Rect &r, bool Small=false);
~MoraleLuckBox();
};
/// Opens hero window by left-clicking on it
@ -811,8 +809,6 @@ public:
void setMeAsDest(bool backpackAsVoid = true);
void setArtifact(const CArtifactInstance *art);
~CArtPlace(); //d-tor
};
/// Contains artifacts of hero. Distincts which artifacts are worn or backpacked
@ -887,7 +883,7 @@ class CGarrisonHolder
{
public:
CGarrisonHolder();
virtual void updateGarrisons(){}
virtual void updateGarrisons()=0;
};
class CWindowWithGarrison : public virtual CGarrisonHolder
@ -901,12 +897,9 @@ public:
class CGarrisonWindow : public CWindowObject, public CWindowWithGarrison
{
public:
CLabel *title;
CAdventureMapButton *quit;
CAdventureMapButton * quit;
void showAll(SDL_Surface * to);
CGarrisonWindow(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits); //c-tor
~CGarrisonWindow(); //d-tor
};
class CExchangeWindow : public CWindowObject, public CWindowWithGarrison, public CWindowWithArtifacts
@ -929,8 +922,6 @@ public:
const CGHeroInstance* heroInst[2];
CArtifactsOfHero * artifs[2];
void showAll(SDL_Surface * to);
void questlog(int whichHero); //questlog button callback; whichHero: 0 - left, 1 - right
void prepareBackground(); //prepares or redraws bg
@ -979,7 +970,7 @@ public:
};
/// Creature transformer window
class CTransformerWindow : public CWindowObject
class CTransformerWindow : public CWindowObject, public CGarrisonHolder
{
public:
class CItem : public CIntObject
@ -992,8 +983,8 @@ public:
CAnimImage *icon;
void move();
void showAll(SDL_Surface * to);
void clickLeft(tribool down, bool previousState);
void update();
CItem(CTransformerWindow * _parent, int _size, int _id);
};
@ -1004,9 +995,9 @@ public:
CAdventureMapButton *all, *convert, *cancel;
CGStatusBar *bar;
void showAll(SDL_Surface * to);
void makeDeal();
void addAll();
void updateGarrisons();
CTransformerWindow(const CGHeroInstance * _hero, const CGTownInstance * _town); //c-tor
};
@ -1072,7 +1063,6 @@ public:
CHillFortWindow(const CGHeroInstance *visitor, const CGObjectInstance *object); //c-tor
void activate();
void showAll (SDL_Surface *to);
std::string getDefForSlot(int slot);//return def name for this slot
std::string getTextForSlot(int slot);//return hover text for this slot
@ -1090,6 +1080,5 @@ class CThievesGuildWindow : public CWindowObject
CMinorResDataBar * resdatabar;
public:
void activate();
CThievesGuildWindow(const CGObjectInstance * _owner);
};