浏览代码

another part of hero window and other improvements

mateuszb 18 年之前
父节点
当前提交
bce31ba91b
共有 10 个文件被更改,包括 188 次插入51 次删除
  1. 151 50
      CHeroWindow.cpp
  2. 1 0
      CHeroWindow.h
  3. 2 1
      CMT.cpp
  4. 14 0
      hch/CAbilityHandler.cpp
  5. 4 0
      hch/CAbilityHandler.h
  6. 4 0
      hch/CAmbarCendamo.cpp
  7. 9 0
      hch/CGeneralTextHandler.cpp
  8. 1 0
      hch/CGeneralTextHandler.h
  9. 1 0
      hch/CHeroHandler.cpp
  10. 1 0
      hch/CHeroHandler.h

+ 151 - 50
CHeroWindow.cpp

@@ -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,8 +135,63 @@ void CHeroWindow::activate()
 	{
 		heroList[g]->activate();
 	}
+	redrawCurBack();
+}
+
+void CHeroWindow::dismissCurrent()
+{
+}
+
+void CHeroWindow::questlog()
+{
+}
+
+void CHeroWindow::gar1()
+{
+}
+
+void CHeroWindow::gar2()
+{
+}
+
+void CHeroWindow::gar3()
+{
+}
+
+void CHeroWindow::gar4()
+{
+}
+
+void CHeroWindow::leftArtRoller()
+{
+}
+
+void CHeroWindow::rightArtRoller()
+{
+}
+
+void CHeroWindow::switchHero()
+{
+	int y;
+	SDL_GetMouseState(NULL, &y);
+	for(int g=0; g<heroList.size(); ++g)
+	{
+		if(y>=94+54*g)
+		{
+			//quit();
+			setHero(LOCPLINT->cb->getHeroInfo(player, g, false));
+			//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);
@@ -148,12 +207,38 @@ void CHeroWindow::activate()
 	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);
+	//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);
@@ -193,51 +278,67 @@ void CHeroWindow::activate()
 			}
 		}
 	}
-}
-
-void CHeroWindow::dismissCurrent()
-{
-}
-
-void CHeroWindow::questlog()
-{
-}
-
-void CHeroWindow::gar1()
-{
-}
-
-void CHeroWindow::gar2()
-{
-}
-
-void CHeroWindow::gar3()
-{
-}
-
-void CHeroWindow::gar4()
-{
-}
-
-void CHeroWindow::leftArtRoller()
-{
-}
 
-void CHeroWindow::rightArtRoller()
-{
-}
-
-void CHeroWindow::switchHero()
-{
-	int y;
-	SDL_GetMouseState(NULL, &y);
-	for(int g=0; g<heroList.size(); ++g)
+	//secondary skills
+	if(curHero->secSkills.size()>=1)
 	{
-		if(y>=94+54*g)
-		{
-			quit();
-			setHero(LOCPLINT->cb->getHeroInfo(player, g, false));
-			LOCPLINT->openHeroWindow(curHero);
-		}
+		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);
+}

+ 1 - 0
CHeroWindow.h

@@ -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

+ 2 - 1
CMT.cpp

@@ -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);
 

+ 14 - 0
hch/CAbilityHandler.cpp

@@ -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);
+	}
 }

+ 4 - 0
hch/CAbilityHandler.h

@@ -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();
 };
 

+ 4 - 0
hch/CAmbarCendamo.cpp

@@ -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;
 			}

+ 9 - 0
hch/CGeneralTextHandler.cpp

@@ -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;

+ 1 - 0
hch/CGeneralTextHandler.h

@@ -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;

+ 1 - 0
hch/CHeroHandler.cpp

@@ -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;

+ 1 - 0
hch/CHeroHandler.h

@@ -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();