diff --git a/Makefile.amiga b/Makefile.amiga index f5e5085ab..e74e598ca 100644 --- a/Makefile.amiga +++ b/Makefile.amiga @@ -12,6 +12,7 @@ SOURCES = AdventureMapButton.cpp \ CBattleInterface.cpp \ CCallback.cpp \ CCastleInterface.cpp \ + CKingdomInterface.cpp \ CConsoleHandler.cpp \ CCursorHandler.cpp \ CGameInfo.cpp \ diff --git a/client/CAdvmapInterface.cpp b/client/CAdvmapInterface.cpp index fcbd90546..84d822f54 100644 --- a/client/CAdvmapInterface.cpp +++ b/client/CAdvmapInterface.cpp @@ -5,6 +5,7 @@ #include "CCursorHandler.h" #include "CGameInfo.h" #include "CHeroWindow.h" +#include "CKingdomInterface.h" #include "CMessage.h" #include "SDL_Extensions.h" #include "CBitmapHandler.h" @@ -1550,6 +1551,7 @@ CAdvMapInt::~CAdvMapInt() void CAdvMapInt::fshowOverview() { + GH.pushInt(new CKingdomInterface); } void CAdvMapInt::fswitchLevel() { diff --git a/client/CCastleInterface.cpp b/client/CCastleInterface.cpp index 907ac7c50..9aa3a3f7e 100644 --- a/client/CCastleInterface.cpp +++ b/client/CCastleInterface.cpp @@ -621,52 +621,82 @@ void CCastleInterface::buildingClicked(int building) GH.pushInt(cmw); break; } - //case 15: //resource silo - default handling should be enought + //case 15: //resource silo - default handling only case 16: //blacksmith - { - const CGHeroInstance *hero = town->visitingHero; - if(!hero) - { - std::string pom = CGI->generaltexth->allTexts[273]; - boost::algorithm::replace_first(pom,"%s",CGI->buildh->buildings[town->subID][16]->Name()); - LOCPLINT->showInfoDialog(pom,std::vector(), soundBase::sound_todo); - return; - } - int aid = town->town->warMachine; - int price = CGI->arth->artifacts[aid].price; - bool possible = (LOCPLINT->cb->getResourceAmount(6) >= price); - if(vstd::contains(hero->artifWorn,ui16(aid+9))) //hero already has machine - possible = false; - - GH.pushInt(new CBlacksmithDialog(possible,CArtHandler::convertMachineID(aid,false),aid,hero->id)); - break; - } - //TODO: case 17: //special 1 - //TODO: case 18: //basic horde 1 - //TODO: case 19: //upg horde 1 - case 20: //ship at shipyard - LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[51]); //Cannot build another boat + enterBlacksmith(town->town->warMachine); break; - //TODO: case 21: //special 2 - case 22: //special 3 + case 17: { switch(town->subID) { - case 0: //brotherhood of sword - enterTavern(); + /*Rampart*/ case 1://Mystic Pond + enterFountain(building); + break; + /*Tower*/ case 2://Artifact Merchant + /*Dungeon*/ case 5://Artifact Merchant + /*Conflux*/ case 8://Artifact Merchant + tlog4<<"Artifact Merchant not handled\n"; break; - default: defaultBuildingClicked(building); break; } break; } - //TODO: case 23: //special 4 - //TODO: case 24: //basic horde 2 - //TODO: case 25: //upg horde 2 - //TODO: case 26: //grail + //case 18: //basic horde 1 - can't be selected + //case 19: //upg horde 1 - can't be selected + case 20: //ship at shipyard + LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[51]); //Cannot build another boat + break; + case 21: //special 2 + { + switch(town->subID) + { + /*Rampart*/ case 1: //Fountain of Fortune + enterFountain(building); + break; + /*Stronghold*/ case 6: //Freelancer's Guild + tlog4<<"Freelancer's Guild not handled\n"; + break; + /*Conflux*/ case 8: //Magic University + tlog4<<"Magic University not handled\n"; + break; + default: + defaultBuildingClicked(building); + break; + } + break; + } + case 22: //special 3 + { + switch(town->subID) + { + /*Castle*/ case 0: //brotherhood of sword + enterTavern(); + break; + /*Inferno*/ case 3: //Castle Gate + tlog4<<"Castle Gate not handled\n"; + break; + /*Necropolis*/ case 4: //Skeleton Transformer + tlog4<<"Skeleton Transformer not handled\n"; + break; + /*Dungeon*/ case 5: //Portal of Summoning + tlog4<<"Portal of Summoning not handled\n"; + break; + /*Stronghold*/ case 6: //Ballista Yard + enterBlacksmith(4); + break; + default: + defaultBuildingClicked(building); + break; + } + break; + } + //case 23: //special 4 - default handling only + //case 24: //basic horde 2 - can't be selected + //case 25: //upg horde 2 - can't be selected + //case 26: //grail - default handling only default: defaultBuildingClicked(building); break; @@ -676,13 +706,51 @@ void CCastleInterface::buildingClicked(int building) void CCastleInterface::defaultBuildingClicked(int building) { std::vector comps(1, - new CCustomImgComponent(SComponent::building,town->subID,building,bicons->ourImages[building].bitmap,false)); + new CCustomImgComponent(SComponent::building,town->subID,building,bicons->ourImages[building].bitmap,false)); LOCPLINT->showInfoDialog( CGI->buildh->buildings[town->subID][building]->Description(), comps, soundBase::sound_todo); } +void CCastleInterface::enterFountain(int building) +{ + std::vector comps(1, + new CCustomImgComponent(SComponent::building,town->subID,building,bicons->ourImages[building].bitmap,false)); + + std::string descr = CGI->buildh->buildings[town->subID][building]->Description(); + if ( building == 21)//we need description for mystic pond as well + descr += "\n\n"+CGI->buildh->buildings[town->subID][17]->Description(); +// if (true)//fountain was builded this week + descr += "\n\n"+ CGI->generaltexth->allTexts[677]; +/* else//fountain produced something; + { + descr+= "\n\n"+ CGI->generaltexth->allTexts[678]; + boost::algorithm::replace_first(descr,"%s",CGI->generaltexth->restypes[resID]); + char buf[10]; + SDL_itoa(ResCount,buf,10); + boost::algorithm::replace_first(descr,"%d",buf); + }*/ + LOCPLINT->showInfoDialog(descr, comps, soundBase::sound_todo); +} + +void CCastleInterface::enterBlacksmith(int ArtifactID) +{ + const CGHeroInstance *hero = town->visitingHero; + if(!hero) + { + std::string pom = CGI->generaltexth->allTexts[273]; + boost::algorithm::replace_first(pom,"%s",CGI->buildh->buildings[town->subID][16]->Name()); + LOCPLINT->showInfoDialog(pom,std::vector(), soundBase::sound_todo); + return; + } + int price = CGI->arth->artifacts[ArtifactID].price; + bool possible = (LOCPLINT->cb->getResourceAmount(6) >= price); + if(vstd::contains(hero->artifWorn,ui16(ArtifactID+9))) //hero already has machine + possible = false; + GH.pushInt(new CBlacksmithDialog(possible,CArtHandler::convertMachineID(ArtifactID,false),ArtifactID,hero->id)); +} + void CCastleInterface::enterHall() { CHallInterface *h = new CHallInterface(this); diff --git a/client/CCastleInterface.h b/client/CCastleInterface.h index e62a98d3d..11664b65f 100644 --- a/client/CCastleInterface.h +++ b/client/CCastleInterface.h @@ -130,6 +130,8 @@ public: void showAll(SDL_Surface * to); void buildingClicked(int building); void defaultBuildingClicked(int building);//for buildings with simple description + pic left-click messages + void enterFountain(int building); + void enterBlacksmith(int ArtifactID);//support for blacksmith + ballista yard void enterTavern(); void enterMageGuild(); void splitClicked(); //for hero meeting (splitting stacks is handled by garrison int) @@ -154,7 +156,7 @@ public: { public: int BID; - int state;// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements + int state;// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - already builded today, 6 - cannot afford, 7 - build, 8 - lack of requirements //(-1) - forbidden in this town, 0 - possible, 1 - lack of res, 2 - requirements/buildings per turn limit, (3) - already exists void hover(bool on); void clickLeft(tribool down, bool previousState); diff --git a/client/CKingdomInterface.cpp b/client/CKingdomInterface.cpp new file mode 100644 index 000000000..e9cad539f --- /dev/null +++ b/client/CKingdomInterface.cpp @@ -0,0 +1,533 @@ +#include "CKingdomInterface.h" +#include "AdventureMapButton.h" +#include "CAdvmapInterface.h" +#include "../CCallback.h" +#include "CGameInfo.h" +#include "CHeroWindow.h" +#include "CMessage.h" +#include "SDL_Extensions.h" +#include "Graphics.h" +#include "../hch/CArtHandler.h" +#include "../hch/CDefHandler.h" +#include "../hch/CGeneralTextHandler.h" +#include "../hch/CObjectHandler.h" +#include +#include +using namespace boost::assign; +using namespace CSDL_Ext; + +/* + * CKingdomInterface.cpp, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +int PicCount = 4; + +CDefEssential* CKingdomInterface::slots; +CDefEssential* CKingdomInterface::fort; +CDefEssential* CKingdomInterface::hall; + +CKingdomInterface::CKingdomInterface() +{ + OBJ_CONSTRUCTION_CAPTURING_ALL; + defActions = SHARE_POS; + pos.x = screen->w/2 - 400; + pos.y = screen->h/2 - 300; + size = 4;//we have 4 visible items in the list, would be nice to move this value to configs later + heroPos = townPos = 0; + state = 2; + showHarrisoned = false; + + bg = BitmapHandler::loadBitmap("OVCAST.bmp"); + graphics->blueToPlayersAdv(bg, LOCPLINT->playerID); + mines = CDefHandler::giveDefEss("OVMINES.DEF"); + slots = CDefHandler::giveDefEss("OVSLOT.DEF"); + title = CDefHandler::giveDefEss("OVTITLE.DEF"); + hall = CDefHandler::giveDefEss("ITMTL.DEF"); + fort = CDefHandler::giveDefEss("ITMCL.DEF"); + + toHeroes = new AdventureMapButton (CGI->generaltexth->overview[11],"", + boost::bind(&CKingdomInterface::listToHeroes,this),748,492,"OVBUTN1.DEF"); + toHeroes->block(2); + + toTowns = new AdventureMapButton (CGI->generaltexth->overview[12],"", + boost::bind(&CKingdomInterface::listToTowns,this),748,528,"OVBUTN6.DEF"); + toTowns->block(0); + + exit = new AdventureMapButton (CGI->generaltexth->allTexts[600],"", + boost::bind(&CKingdomInterface::close,this),748,563,"OVBUTN1.DEF"); + exit->bitmapOffset = 3; + + statusbar = new CStatusBar(pos.x+7,pos.y+555,"TSTATBAR.bmp",732); + resdatabar = new CResDataBar("KRESBAR.bmp",pos.x+3,pos.y+575,32,2,76,76); + + for (int i=0; icb->howManyHeroes(showHarrisoned), 0, false, 0); +} + +CKingdomInterface::~CKingdomInterface() +{ + SDL_FreeSurface(bg); + + delete statusbar; + delete resdatabar; + + delete exit; + delete toTowns; + delete toHeroes; + + delete slider; + delete title; + delete slots; + delete fort; + delete hall; + delete mines; + +/* for(size_t i=0;iadventureInt->resdatabar.draw(to); + blitAt(bg,pos,to); + resdatabar->draw(to); + toTowns->show(to); + toHeroes->show(to); + exit->show(to); + if (state == 1) + {//printing text "Town", "Harrisoned hero", "Visiting hero" + CSDL_Ext::printAtMiddle(CGI->generaltexth->overview[3],pos.x+145,pos.y+12,TNRB16,zwykly,to); + CSDL_Ext::printAtMiddle(CGI->generaltexth->overview[4],pos.x+370,pos.y+12,TNRB16,zwykly,to); + CSDL_Ext::printAtMiddle(CGI->generaltexth->overview[5],pos.x+600,pos.y+12,TNRB16,zwykly,to); + for (size_t i=0; ishow(to);//show town list + } + else + {//text "Hero/stats" and "Skills" + CSDL_Ext::printAtMiddle(CGI->generaltexth->overview[0],pos.x+150,pos.y+12,TNRB16,zwykly,to); + CSDL_Ext::printAtMiddle(CGI->generaltexth->overview[1],pos.x+500,pos.y+12,TNRB16,zwykly,to); + for (size_t i=0; ishow(to);//show hero list + } + + for(size_t i=0;ishow(to);//printing resource incomes + + if(screen->w != 800 || screen->h !=600) + CMessage::drawBorder(LOCPLINT->playerID,to,828,628,pos.x-14,pos.y-15); + show(to); +} + +void CKingdomInterface::show(SDL_Surface * to) +{ + statusbar->show(to); +} + +void CKingdomInterface::activate() +{ + LOCPLINT->statusbar = statusbar; + exit->activate(); + toTowns->activate(); + toHeroes->activate(); + if (state == 1) + for (int i=0; iactivate(); + else + for (int i=0; iactivate(); + + slider->activate(); +} + +void CKingdomInterface::deactivate() +{ + exit->deactivate(); + toTowns->deactivate(); + toHeroes->deactivate(); + if (state == 1) + for (int i=0; ideactivate(); + else + for (int i=0; ideactivate(); + slider->deactivate(); +} + +void CKingdomInterface::keyPressed(const SDL_KeyboardEvent & key) +{ +} + +void CKingdomInterface::recreateHeroList(int pos) +{ + for (int j=0; j Heroes = LOCPLINT->cb->getHeroesInfo(true); + int i=0, cnt=0; + for (int j = 0; ((jinTownGarrison && (!showHarrisoned))//if hero in garrison and we don't show them + { + continue; + } + if (cnt Towns = LOCPLINT->cb->getTownsInfo(true); + for(int i=0;iblock(0); + toTowns->block(2); + heroPos = slider->value; + slider->setAmount(LOCPLINT->cb->howManyTowns()); + slider->value=townPos;//moving slider + recreateTownList(townPos); + for (size_t i=0;ideactivate(); + heroes[i]->activate(); + } +} + +void CKingdomInterface::listToHeroes() +{ + state = 2; + toHeroes->block(2); + toTowns->block(0); + townPos = slider->value; + slider->setAmount(LOCPLINT->cb->howManyHeroes(showHarrisoned)); + slider->value=heroPos;//moving slider + recreateHeroList(heroPos); + for (size_t i=0;ideactivate(); + heroes[i]->activate(); + } +} + +void CKingdomInterface::sliderMoved(int newpos) +{ + if ( state == 1 )//towns + { + townPos = newpos; + recreateTownList(newpos); + } + else//heroes + { + heroPos = newpos; + recreateHeroList(newpos); + } +} + +CKingdomInterface::CResIncomePic::CResIncomePic(int RID, CDefEssential * Mines) +{ + resID = RID; + pos.x += 20 + RID*80; + pos.y += 495; + pos.h = 54; + pos.w = (resID!=7)?68:136;//gold pile is bigger + mines = Mines; + + value = 0; + int resource = resID==7?6:resID; + + for(size_t i = 0; istate->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 heroes = LOCPLINT->cb->getHeroesInfo(true); + for(size_t i=0; igetSecSkillLevel(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 towns = LOCPLINT->cb->getTownsInfo(true); + for(size_t i=0; idailyIncome(); + } +} + +CKingdomInterface::CResIncomePic::~CResIncomePic() +{ +} + +void CKingdomInterface::CResIncomePic::hover(bool on) +{ +} + +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, const CGTownInstance * Town) +{ +// defActions = ACTIVATE | DEACTIVATE | SHOWALL | DISPOSE; + numb = num; + pos.x = screen->w/2 - 400 + 23; + pos.y = screen->h/2 - 300 + 26+num*116; + pos.w = 702; + pos.h = 114; + town = Town; +} + +CKingdomInterface::CTownItem::~CTownItem() +{ +} + +void CKingdomInterface::CTownItem::activate() +{ +} + +void CKingdomInterface::CTownItem::deactivate() +{ +} + +void CKingdomInterface::CTownItem::show(SDL_Surface * to) +{ + if (!town) + {//if NULL - print background & exit + blitAt(slots->ourImages[numb % PicCount].bitmap,pos.x,pos.y,to); + return; + }//background + blitAt(slots->ourImages[6].bitmap,pos.x,pos.y,to); + //town pic/name + int townPic = town->subID*2; + if (!town->hasFort()) + townPic += F_NUMBER*2; + if(town->builded >= MAX_BUILDING_PER_TURN) + townPic++; + blitAt(graphics->bigTownPic->ourImages[townPic].bitmap,pos.x+5,pos.y+6,to); + CSDL_Ext::printAt(town->name,pos.x+73,pos.y+7,GEOR13,zwykly,to); + //fort pic + townPic = town->fortLevel()-1; + if (townPic==-1) townPic = 3; + blitAt(fort->ourImages[townPic].bitmap,pos.x+111,pos.y+31,to); + //hall pic + townPic = town->hallLevel(); + blitAt(hall->ourImages[townPic].bitmap,pos.x+69,pos.y+31,to); + //income pic + std::ostringstream oss; + oss << town->dailyIncome(); + CSDL_Ext::printAtMiddle(oss.str(),pos.x+188,pos.y+60,GEOR13,zwykly,to); +// Creature bonuses/ Creature available texts - need to find text wrapper thingy +// CSDL_Ext::printAtWR(CGI->generaltexth->allTexts[265],pos.x,pos.y+80,GEOR13,zwykly,to); +// CSDL_Ext::printTo(CGI->generaltexth->allTexts[266],pos.x+350,pos.y+80,GEOR13,zwykly,to); + for (int i=0; ibuiltBuildings,bid)) + continue; + + if (vstd::contains(town->builtBuildings,bid+CREATURES_PER_TOWN)) + { + crid = town->town->upgradedCreatures[i]; + bid += CREATURES_PER_TOWN; + } + else + crid = town->town->basicCreatures[i]; + //creature growth + blitAt(graphics->smallImgs[crid],pos.x+56+i*37,pos.y+78,to); + std::ostringstream oss; + oss << '+' << town->creatureGrowth(i); + CSDL_Ext::printTo(oss.str(),pos.x+87+i*37,pos.y+110,GEORM,zwykly,to); + //creature available + blitAt(graphics->smallImgs[crid],pos.x+409+i*37,pos.y+78,to); + std::ostringstream ostrs; + 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 >::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; + } +} + +CKingdomInterface::CHeroItem::CHeroItem(int num, const CGHeroInstance * Hero) +{ + numb = num; + pos.x = screen->w/2 - 400 + 23; + pos.y = screen->h/2 - 300 + 26+num*116; + pos.w = 702; + pos.h = 114; + hero = Hero; + artGroup = 0; +} + +CKingdomInterface::CHeroItem::~CHeroItem() +{ +} + +void CKingdomInterface::CHeroItem::show(SDL_Surface * to) +{ + if (!hero) + {//if we have no hero for this slot - print background & exit + blitAt(slots->ourImages[numb % PicCount].bitmap,pos.x,pos.y,to); + return; + }//print background, different for arts view/backpack mode + blitAt(slots->ourImages[(artGroup=2)?4:5].bitmap,pos.x,pos.y,to); + //text "Artifacts" + CSDL_Ext::printAtMiddle(CGI->generaltexth->overview[2],pos.x+320,pos.y+55,GEOR13,zwykly,to); + int X = pos.x+6;//portrait + blitAt(graphics->portraitLarge[hero->portrait],pos.x+5,pos.y+6,to); + for(std::map >::const_iterator + j=hero->army.slots.begin(); j!=hero->army.slots.end(); j++) + {//army + blitAt(graphics->smallImgs[j->second.first],X,pos.y+78,to); + std::ostringstream creanum; + creanum << (j->second.second); + CSDL_Ext::printTo(creanum.str(),X+30,pos.y+110,GEOR13,zwykly,to); + X+=36; + }//hero name + CSDL_Ext::printAt(hero->name,pos.x+73,pos.y+7,GEOR13,zwykly,to); + for (int i = 0; i<6; i++) + {//primary skills, mana and exp. pics + blitAt(graphics->pskillst->ourImages[i].bitmap,(i<4)?(pos.x+78+36*i):(pos.x+539-52*i), + (i<4)?(pos.y+26):(pos.y+6),to); + if (i>3) continue;//primary skills text + std::ostringstream str; + str << (hero->primSkills[i]); + CSDL_Ext::printAtMiddle(str.str(),pos.x+95+36*i,pos.y+65,GEOR13,zwykly,to); + } + {//luck and morale pics, experience and mana text + blitAt(graphics->luck30->ourImages[hero->getCurrentLuck()+3].bitmap,pos.x+222,pos.y+30,to); + blitAt(graphics->morale30->ourImages[hero->getCurrentMorale()+3].bitmap,pos.x+222,pos.y+54,to); + std::ostringstream str; + str << (hero->exp); + CSDL_Ext::printAtMiddle(str.str(),(pos.x+348),(pos.y+31),GEORM,zwykly,to); + std::ostringstream strnew; + strnew << (hero->mana)<<"/"<<(hero->manaLimit()); + CSDL_Ext::printAtMiddle(strnew.str(),(pos.x+298),(pos.y+31),GEORM,zwykly,to); + } + //hero speciality + blitAt(graphics->un32->ourImages[hero->subID].bitmap, pos.x+375, pos.y+6, to); + + for(int i=0; isecSkills.size(); i++) + {//secondary skills + int skill = hero->secSkills[i].first, + level = hero->secSkills[i].second; + blitAt(graphics->abils32->ourImages[skill*3+level+2].bitmap,pos.x+411+i*36,pos.y+6,to); + } + + int iter=0; + switch (artGroup) + {//arts + case 1:iter = 9;//misc. arts, spellbook, war machines + case 0://equipped arts + for (int i = iter ; igetArtAtPos(i); + if (artID>=0) + blitAt(graphics->artDefs->ourImages[artID].bitmap,pos.x+268+48*(i%9),pos.y+66,to); + } + break; + case 2://TODO:backpack + break; + default: tlog1<<"Unknown artifact group: "< +#include "GUIBase.h" +#include "../hch/CMusicBase.h" +class AdventureMapButton; +class CHighlightableButtonsGroup; +class CResDataBar; +class CStatusBar; +class CSlider; +class CMinorResDataBar; + +/* + * CKingdomInterface.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +class CKingdomInterface : public CIntObject +{ +/* class CDwellingList : public + { + public: + void mouseMoved (const SDL_MouseMotionEvent & sEvent); + void genList(); + void select(int which); + void draw(SDL_Surface * to); + int size(); //how many elements do we have + }*/ + class CResIncomePic : public CIntObject + { + public: + int resID,value;//resource ID + CResIncomePic(int RID, CDefEssential * Mines);//c-tor + ~CResIncomePic();//d-tor + void hover(bool on); + void show(SDL_Surface * to); + CDefEssential * mines;//pointer to mines pictures; + }; + class CTownItem : public CIntObject + { + public: + int numb;//position on screen (1..4) + const CGTownInstance * town; + void show(SDL_Surface * to); + void activate(); + void deactivate(); + CTownItem (int num, const CGTownInstance * Town);//c-tor + ~CTownItem();//d-tor + }; + class CHeroItem : public CIntObject + { + public: + const CGHeroInstance * hero; + int artGroup,numb;//current art group (0 = equiped, 1 = misc, 2 = backpack) + void onArtChange(int newstate);//changes artgroup + void show(SDL_Surface * to); + void activate(); + void deactivate(); + CHeroItem (int num, const CGHeroInstance * Hero);//c-tor + ~CHeroItem();//d-tor + }; +public: + //common data + int state;//0 = initialisation 1 = towns showed, 2 = heroes; + SDL_Surface * bg;//background + CStatusBar * statusbar;//statusbar + CResDataBar *resdatabar;//resources + + AdventureMapButton *exit;//exit button + AdventureMapButton *toTowns;//town button + AdventureMapButton *toHeroes;//hero button + CDefEssential * title; //title bar + //hero/town lists + bool showHarrisoned;//show harrisoned hero in heroes list or not + CSlider * slider;//slider + int heroPos,townPos,size;//position of lists; size of list + std::vector heroes;//heroes list + std::vector towns;//towns list + static CDefEssential * slots, *fort, *hall; + + //income pics + std::vector incomes;//mines + incomes + CDefEssential * mines;//picture of mines + + CKingdomInterface(); //c-tor + ~CKingdomInterface(); //d-tor + void recreateHeroList(int pos);//recreating heroes list (on slider move) + void recreateTownList(int pos);//same for town list + void keyPressed(const SDL_KeyboardEvent & key); + void listToTowns();//changing list to town view + void listToHeroes();//changing list to heroes view + void sliderMoved(int newpos);//when we move a slider... + void show(SDL_Surface * to); + void showAll(SDL_Surface * to); + void close(); + void activate(); + void deactivate(); +}; + +#endif // __CCASTLEINTERFACE_H__ diff --git a/client/Graphics.cpp b/client/Graphics.cpp index ed48d3a5f..4c46db88f 100644 --- a/client/Graphics.cpp +++ b/client/Graphics.cpp @@ -291,9 +291,10 @@ Graphics::Graphics() tasks += GET_DEF_ESS(halls,"ITMTLS.DEF"); tasks += GET_DEF_ESS(bigTownPic,"ITPT.DEF"); tasks += GET_DEF_ESS(pskillsb,"PSKILL.DEF"); - tasks += GET_DEF_ESS(pskillsm,"PSKIL42.DEF"); + tasks += GET_DEF_ESS(pskillsm,"PSKIL42.DEF"); tasks += GET_DEF_ESS(pskillst,"PSKIL32.DEF"); tasks += GET_DEF_ESS(resources,"RESOUR82.DEF"); + tasks += GET_DEF_ESS(un32,"UN32.DEF"); tasks += GET_DEF_ESS(un44,"UN44.DEF"); tasks += GET_DEF_ESS(smallIcons,"ITPA.DEF"); tasks += GET_DEF_ESS(resources32,"RESOURCE.DEF"); @@ -676,3 +677,10 @@ int Font::getWidth(const char *text ) const return ret; } +/* +void Font::WriteAt(const char *text, SDL_Surface *sur, int x, int y ) +{ + SDL_Surface *SDL_CreateRGBSurfaceFrom(pixels, w, h, 8, int pitch, + 224, 28, 3, 0); +} +*/ diff --git a/client/Graphics.h b/client/Graphics.h index 243ee2bd4..bdbc6fc91 100644 --- a/client/Graphics.h +++ b/client/Graphics.h @@ -70,8 +70,9 @@ public: std::vector portraitLarge; //58x64 px portraits of heroes std::vector flags1, flags2, flags3, flags4; //flags blitted on heroes when , CDefEssential * pskillsb, *resources; //82x93 - CDefEssential * pskillsm; //42x42 primary skills + CDefEssential * pskillsm; //42x42 primary skills CDefEssential * pskillst; //32x32 + CDefEssential * un32; //many small things CDefEssential * un44; //many things CDefEssential * smallIcons, *resources32; //resources 32x32 CDefEssential * flags; diff --git a/client/Makefile.am b/client/Makefile.am index 5e0d74562..dbb40e9f0 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -54,6 +54,8 @@ vcmiclient_SOURCES = \ CGameInfo.h \ CHeroWindow.cpp \ CHeroWindow.h \ + CKingdomInterface.cpp \ + CKingdomInterface.h \ CMT.cpp \ CMessage.cpp \ CMessage.h \ diff --git a/client/Makefile.in b/client/Makefile.in index aefd6357b..db04291a5 100644 --- a/client/Makefile.in +++ b/client/Makefile.in @@ -73,7 +73,9 @@ am_vcmiclient_OBJECTS = vcmiclient-CCallback.$(OBJEXT) \ vcmiclient-CCreatureAnimation.$(OBJEXT) \ vcmiclient-CCursorHandler.$(OBJEXT) \ vcmiclient-CGameInfo.$(OBJEXT) \ - vcmiclient-CHeroWindow.$(OBJEXT) vcmiclient-CMT.$(OBJEXT) \ + vcmiclient-CHeroWindow.$(OBJEXT) \ + vcmiclient-CKingdomInterface.$(OBJEXT) \ + vcmiclient-CMT.$(OBJEXT) \ vcmiclient-CMessage.$(OBJEXT) \ vcmiclient-CPlayerInterface.$(OBJEXT) \ vcmiclient-CPreGame.$(OBJEXT) \ @@ -296,6 +298,8 @@ vcmiclient_SOURCES = \ CGameInfo.h \ CHeroWindow.cpp \ CHeroWindow.h \ + CKingdomInterface.cpp \ + CKingdomInterface.h \ CMT.cpp \ CMessage.cpp \ CMessage.h \ @@ -421,6 +425,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CGameInfo.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CGameInterface.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CHeroWindow.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CKingdomInterface.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CMT.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CMessage.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcmiclient-CMusicHandler.Po@am__quote@ @@ -712,6 +717,20 @@ vcmiclient-CHeroWindow.obj: CHeroWindow.cpp @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CHeroWindow.obj `if test -f 'CHeroWindow.cpp'; then $(CYGPATH_W) 'CHeroWindow.cpp'; else $(CYGPATH_W) '$(srcdir)/CHeroWindow.cpp'; fi` +vcmiclient-CKingdomInterface.o: CKingdomInterface.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CKingdomInterface.o -MD -MP -MF $(DEPDIR)/vcmiclient-CKingdomInterface.Tpo -c -o vcmiclient-CKingdomInterface.o `test -f 'CKingdomInterface.cpp' || echo '$(srcdir)/'`CKingdomInterface.cpp +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/vcmiclient-CKingdomInterface.Tpo $(DEPDIR)/vcmiclient-CKingdomInterface.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='CKingdomInterface.cpp' object='vcmiclient-CKingdomInterface.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CKingdomInterface.o `test -f 'CKingdomInterface.cpp' || echo '$(srcdir)/'`CKingdomInterface.cpp + +vcmiclient-CKingdomInterface.obj: CKingdomInterface.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CKingdomInterface.obj -MD -MP -MF $(DEPDIR)/vcmiclient-CKingdomInterface.Tpo -c -o vcmiclient-CKingdomInterface.obj `if test -f 'CKingdomInterface.cpp'; then $(CYGPATH_W) 'CKingdomInterface.cpp'; else $(CYGPATH_W) '$(srcdir)/CKingdomInterface.cpp'; fi` +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/vcmiclient-CKingdomInterface.Tpo $(DEPDIR)/vcmiclient-CKingdomInterface.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='CKingdomInterface.cpp' object='vcmiclient-CKingdomInterface.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -c -o vcmiclient-CKingdomInterface.obj `if test -f 'CKingdomInterface.cpp'; then $(CYGPATH_W) 'CKingdomInterface.cpp'; else $(CYGPATH_W) '$(srcdir)/CKingdomInterface.cpp'; fi` + vcmiclient-CMT.o: CMT.cpp @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcmiclient_CXXFLAGS) $(CXXFLAGS) -MT vcmiclient-CMT.o -MD -MP -MF $(DEPDIR)/vcmiclient-CMT.Tpo -c -o vcmiclient-CMT.o `test -f 'CMT.cpp' || echo '$(srcdir)/'`CMT.cpp @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/vcmiclient-CMT.Tpo $(DEPDIR)/vcmiclient-CMT.Po diff --git a/client/NetPacksClient.cpp b/client/NetPacksClient.cpp index aa6ff18da..4816606df 100644 --- a/client/NetPacksClient.cpp +++ b/client/NetPacksClient.cpp @@ -98,7 +98,8 @@ void FoWChange::applyCl( CClient *cl ) else cl->playerint[player]->tileHidden(tiles); - GS(cl)->calculatePaths(cl->IGameCallback::getSelectedHero(player), *cl->pathInfo); + if (cl->IGameCallback::getSelectedHero(player))//if we have selected hero... + GS(cl)->calculatePaths(cl->IGameCallback::getSelectedHero(player), *cl->pathInfo); } void SetAvailableHeroes::applyCl( CClient *cl ) diff --git a/hch/CGeneralTextHandler.cpp b/hch/CGeneralTextHandler.cpp index 96e91ca6b..39154755a 100644 --- a/hch/CGeneralTextHandler.cpp +++ b/hch/CGeneralTextHandler.cpp @@ -352,6 +352,15 @@ void CGeneralTextHandler::load() allTexts.push_back(buflet); } + std::string stro = bitmaph->getTextFile("Overview.txt"); + itr=0; + while(itrgetTextFile("ARRAYTXT.TXT"); itr=0; diff --git a/hch/CGeneralTextHandler.h b/hch/CGeneralTextHandler.h index 0e4d6da62..ee26a1f88 100644 --- a/hch/CGeneralTextHandler.h +++ b/hch/CGeneralTextHandler.h @@ -33,6 +33,7 @@ public: std::vector primarySkillNames; std::vector jktexts; std::vector heroscrn; + std::vector overview;//text for Kingdom Overview window //artifacts std::vector artifEvents; diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 4c3554f5c..5ecc7d045 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -774,6 +774,9 @@ void CGameHandler::newTurn() NewTurn n; n.day = gs->day + 1; n.resetBuilded = true; + + std::map hadGold;//starting gold - for buildings like dwarven treasury + srand(time(NULL)); std::map pool = gs->hpool.heroesPool; @@ -782,6 +785,10 @@ void CGameHandler::newTurn() if(i->first == 255) continue; else if(i->first > PLAYER_LIMIT) assert(0); //illegal player number! + std::pair playerGold(i->first,i->second.resources[6]); + hadGold.insert(playerGold); + tlog1<first<<" & "<second.resources[6]<<"\n"; + if(gs->getDate(1)==7) //first day of week - new heroes in tavern { SetAvailableHeroes sah; @@ -849,6 +856,20 @@ void CGameHandler::newTurn() ui8 player = (*j)->tempOwner; if(gs->getDate(1)==7) //first day of week { + if ( ((**j).subID == 1) && (gs->getDate(0)) && (player < PLAYER_LIMIT) )//this is rampart and not a first day + { + if (vstd::contains((**j).builtBuildings,22))//we have treasury + { + n.res[player][6] += hadGold[player]/10; //give 10% of starting gold + } + if (vstd::contains((**j).builtBuildings,17))//we have mystic pond + {//TODO: whole week pond should have message "pond produced %d" - need vars to store it + int restype = rand()%4+2;//bonus to random rare resource + restype = (restype==2)?1:restype; + int cnt = rand()%4+1;//with size 1..4 + n.res[player][restype] += cnt; + } + } SetAvailableCreatures sac; sac.tid = (**j).id; sac.creatures = (**j).creatures;