mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	* mostly done battle options (although they're not saved)
* general improvements in rendering of battle interface
This commit is contained in:
		| @@ -11,6 +11,7 @@ | ||||
| #include "CCallback.h" | ||||
| #include "CGameState.h" | ||||
| #include "hch/CGeneralTextHandler.h" | ||||
| #include "hch/CPreGameTextHandler.h" | ||||
| #include "client/CCreatureAnimation.h" | ||||
| #include "client/Graphics.h" | ||||
| #include "client/CSpellWindow.h" | ||||
| @@ -18,6 +19,7 @@ | ||||
| #include <sstream> | ||||
| #include "lib/CondSh.h" | ||||
| #include "lib/NetPacks.h" | ||||
| #include <boost/assign/list_of.hpp> | ||||
| #ifndef __GNUC__ | ||||
| const double M_PI = 3.14159265358979323846; | ||||
| #else | ||||
| @@ -39,7 +41,7 @@ public: | ||||
| } cmpst2 ; | ||||
|  | ||||
| CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2) | ||||
| : printCellBorders(true), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0), activeStack(-1), givenCommand(NULL), attackingInfo(NULL), myTurn(false), resWindow(NULL), showStackQueue(false), animSpeed(1) | ||||
| : printCellBorders(true), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0), activeStack(-1), givenCommand(NULL), attackingInfo(NULL), myTurn(false), resWindow(NULL), showStackQueue(false), animSpeed(2), printStackRange(true) | ||||
| { | ||||
| 	givenCommand = new CondSh<BattleAction *>(NULL); | ||||
| 	//initializing armies | ||||
| @@ -227,6 +229,23 @@ CBattleInterface::~CBattleInterface() | ||||
| 		delete g->second; | ||||
| } | ||||
|  | ||||
| void CBattleInterface::setPrintCellBorders(bool set) | ||||
| { | ||||
| 	printCellBorders = set; | ||||
| 	redrawBackgroundWithHexes(activeStack); | ||||
| } | ||||
|  | ||||
| void CBattleInterface::setPrintStackRange(bool set) | ||||
| { | ||||
| 	printStackRange = set; | ||||
| 	redrawBackgroundWithHexes(activeStack); | ||||
| } | ||||
|  | ||||
| void CBattleInterface::setPrintMouseShadow(bool set) | ||||
| { | ||||
| 	printMouseShadow = set; | ||||
| } | ||||
|  | ||||
| void CBattleInterface::activate() | ||||
| { | ||||
| 	subInt = NULL; | ||||
| @@ -292,13 +311,16 @@ void CBattleInterface::show(SDL_Surface * to) | ||||
| 		} | ||||
| 	} | ||||
| 	//printing hovered cell | ||||
| 	for(int b=0; b<187; ++b) | ||||
| 	if(printMouseShadow) | ||||
| 	{ | ||||
| 		if(bfield[b].strictHovered && bfield[b].hovered) | ||||
| 		for(int b=0; b<187; ++b) | ||||
| 		{ | ||||
| 			int x = 14 + ((b/17)%2==0 ? 22 : 0) + 44*(b%17); | ||||
| 			int y = 86 + 42 * (b/17); | ||||
| 			CSDL_Ext::blit8bppAlphaTo24bpp(cellShade, NULL, to, &genRect(cellShade->h, cellShade->w, x, y)); | ||||
| 			if(bfield[b].strictHovered && bfield[b].hovered) | ||||
| 			{ | ||||
| 				int x = 14 + ((b/17)%2==0 ? 22 : 0) + 44*(b%17); | ||||
| 				int y = 86 + 42 * (b/17); | ||||
| 				CSDL_Ext::blit8bppAlphaTo24bpp(cellShade, NULL, to, &genRect(cellShade->h, cellShade->w, x, y)); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -444,7 +466,8 @@ bool CBattleInterface::reverseCreature(int number, int hex, bool wideTrick) | ||||
| 	if(creAnims[number]==NULL) | ||||
| 		return false; //there is no such creature | ||||
| 	creAnims[number]->setType(8); | ||||
| 	for(int g=0; g<creAnims[number]->framesInGroup(8); ++g) | ||||
| 	int firstFrame = creAnims[number]->getFrame(); | ||||
| 	for(int g=0; creAnims[number]->getFrame() != creAnims[number]->framesInGroup(8) + firstFrame - 1; ++g) | ||||
| 	{ | ||||
| 		show(); | ||||
| 		CSDL_Ext::update(); | ||||
| @@ -466,7 +489,8 @@ bool CBattleInterface::reverseCreature(int number, int hex, bool wideTrick) | ||||
| 	} | ||||
|  | ||||
| 	creAnims[number]->setType(7); | ||||
| 	for(int g=0; g<creAnims[number]->framesInGroup(7); ++g) | ||||
| 	firstFrame = creAnims[number]->getFrame(); | ||||
| 	for(int g=0; creAnims[number]->getFrame() != creAnims[number]->framesInGroup(7) + firstFrame - 1; ++g) | ||||
| 	{ | ||||
| 		show(); | ||||
| 		CSDL_Ext::update(); | ||||
| @@ -588,7 +612,8 @@ void CBattleInterface::stackKilled(int ID, int dmg, int killed, int IDby, bool b | ||||
| 		} | ||||
| 	} | ||||
| 	creAnims[ID]->setType(5); //death | ||||
| 	for(int i=0; i<creAnims[ID]->framesInGroup(5)*3+1; ++i) | ||||
| 	int firstFrame = creAnims[ID]->getFrame(); | ||||
| 	for(int i=0; creAnims[ID]->getFrame() != creAnims[ID]->framesInGroup(5) + firstFrame - 1; ++i) | ||||
| 	{ | ||||
| 		if((animCount%(4/animSpeed))==0) | ||||
| 			creAnims[ID]->incrementFrame(); | ||||
| @@ -604,40 +629,15 @@ void CBattleInterface::stackActivated(int number) | ||||
| { | ||||
| 	//givenCommand = NULL; | ||||
| 	activeStack = number; | ||||
| 	shadedHexes = LOCPLINT->cb->battleGetAvailableHexes(number); | ||||
| 	myTurn = true; | ||||
|  | ||||
| 	//preparating background graphic with hexes and shaded hexes | ||||
| 	blitAt(background, 0, 0, backgroundWithHexes); | ||||
| 	if(printCellBorders) | ||||
| 		CSDL_Ext::blit8bppAlphaTo24bpp(cellBorders, NULL, backgroundWithHexes, NULL); | ||||
|  | ||||
| 	for(int m=0; m<shadedHexes.size(); ++m) //rows | ||||
| 	{ | ||||
| 		int i = shadedHexes[m]/17; //row | ||||
| 		int j = shadedHexes[m]%17-1; //column | ||||
| 		int x = 58 + (i%2==0 ? 22 : 0) + 44*j; | ||||
| 		int y = 86 + 42 * i; | ||||
| 		CSDL_Ext::blit8bppAlphaTo24bpp(cellShade, NULL, backgroundWithHexes, &genRect(cellShade->h, cellShade->w, x, y)); | ||||
| 	} | ||||
| 	redrawBackgroundWithHexes(number); | ||||
| } | ||||
|  | ||||
| void CBattleInterface::stackMoved(int number, int destHex, bool startMoving, bool endMoving) | ||||
| { | ||||
| 	//a few useful variables | ||||
| 	int curStackPos = LOCPLINT->cb->battleGetPos(number); | ||||
| 	int steps; | ||||
| 	switch(animSpeed) | ||||
| 	{ | ||||
| 	case 1: | ||||
| 		steps = creAnims[number]->framesInGroup(0)*3.5; | ||||
| 		break; | ||||
| 	case 2: | ||||
| 		steps = creAnims[number]->framesInGroup(0)*2.2; | ||||
| 		break; | ||||
| 	case 4: | ||||
| 		steps = creAnims[number]->framesInGroup(0); | ||||
| 	} | ||||
| 	int steps = creAnims[number]->framesInGroup(0)*getAnimSpeedMultiplier()-1; | ||||
| 	int hexWbase = 44, hexHbase = 42; | ||||
| 	bool twoTiles = LOCPLINT->cb->battleGetCreature(number).isDoubleWide(); | ||||
|  | ||||
| @@ -647,7 +647,7 @@ void CBattleInterface::stackMoved(int number, int destHex, bool startMoving, boo | ||||
| 		CGI->curh->hide(); | ||||
| 		creAnims[number]->setType(20); | ||||
| 		//LOCPLINT->objsToBlit.erase(std::find(LOCPLINT->objsToBlit.begin(),LOCPLINT->objsToBlit.end(),this)); | ||||
| 		for(int i=0; i<creAnims[number]->framesInGroup(20)*3+1; ++i) | ||||
| 		for(int i=0; i<creAnims[number]->framesInGroup(20)*getAnimSpeedMultiplier()-1; ++i) | ||||
| 		{ | ||||
| 			show(); | ||||
| 			CSDL_Ext::update(); | ||||
| @@ -724,7 +724,7 @@ void CBattleInterface::stackMoved(int number, int destHex, bool startMoving, boo | ||||
| 		if(creAnims[number]->framesInGroup(21)!=0) // some units don't have this animation (ie. halberdier) | ||||
| 		{ | ||||
| 			creAnims[number]->setType(21); | ||||
| 			for(int i=0; i<creAnims[number]->framesInGroup(21)*3+1; ++i) | ||||
| 			for(int i=0; i<creAnims[number]->framesInGroup(21)*getAnimSpeedMultiplier()-1; ++i) | ||||
| 			{ | ||||
| 				show(); | ||||
| 				CSDL_Ext::update(); | ||||
| @@ -784,7 +784,8 @@ void CBattleInterface::stackIsAttacked(int ID, int dmg, int killed, int IDby, bo | ||||
| 		} | ||||
| 	} | ||||
| 	creAnims[ID]->setType(3); //getting hit | ||||
| 	for(int i=0; i<creAnims[ID]->framesInGroup(3)*3+1; ++i) | ||||
| 	int firstFrame = creAnims[ID]->getFrame(); | ||||
| 	for(int i=0; creAnims[ID]->getFrame() != creAnims[ID]->framesInGroup(3) + firstFrame - 1; ++i) | ||||
| 	{ | ||||
| 		show(); | ||||
| 		CSDL_Ext::update(); | ||||
| @@ -1068,15 +1069,28 @@ void CBattleInterface::battleFinished(const BattleResult& br) | ||||
| 	resWindow->activate(); | ||||
| } | ||||
|  | ||||
| void CBattleInterface::showRange(SDL_Surface * to, int ID) | ||||
| void CBattleInterface::setAnimSpeed(int set) | ||||
| { | ||||
| 	/*for(int i=0; i<shadedHexes.size(); ++i) | ||||
| 	{ | ||||
| 		CSDL_Ext::blit8bppAlphaTo24bpp(CBattleInterface::cellShade, NULL, to, &bfield[shadedHexes[i]].pos); | ||||
| 	}*/ | ||||
| 	//CSDL_Ext::blit8bppAlphaTo24bpp(shadedHexesGraphic, NULL, to, NULL); | ||||
| 	animSpeed = set; | ||||
| } | ||||
|  | ||||
| int CBattleInterface::getAnimSpeed() const | ||||
| { | ||||
| 	return animSpeed; | ||||
| } | ||||
|  | ||||
| float CBattleInterface::getAnimSpeedMultiplier() const | ||||
| { | ||||
| 	switch(animSpeed) | ||||
| 	{ | ||||
| 	case 1: | ||||
| 		return 3.5f; | ||||
| 	case 2: | ||||
| 		return 2.2f; | ||||
| 	case 4: | ||||
| 		return 1.0f; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void CBattleInterface::attackingShowHelper() | ||||
| { | ||||
| @@ -1257,6 +1271,28 @@ void CBattleInterface::attackingShowHelper() | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void CBattleInterface::redrawBackgroundWithHexes(int activeStack) | ||||
| { | ||||
| 	shadedHexes = LOCPLINT->cb->battleGetAvailableHexes(activeStack); | ||||
|  | ||||
| 	//preparating background graphic with hexes and shaded hexes | ||||
| 	blitAt(background, 0, 0, backgroundWithHexes); | ||||
| 	if(printCellBorders) | ||||
| 		CSDL_Ext::blit8bppAlphaTo24bpp(cellBorders, NULL, backgroundWithHexes, NULL); | ||||
|  | ||||
| 	if(printStackRange) | ||||
| 	{ | ||||
| 		for(int m=0; m<shadedHexes.size(); ++m) //rows | ||||
| 		{ | ||||
| 			int i = shadedHexes[m]/17; //row | ||||
| 			int j = shadedHexes[m]%17-1; //column | ||||
| 			int x = 58 + (i%2==0 ? 22 : 0) + 44*j; | ||||
| 			int y = 86 + 42 * i; | ||||
| 			CSDL_Ext::blit8bppAlphaTo24bpp(cellShade, NULL, backgroundWithHexes, &genRect(cellShade->h, cellShade->w, x, y)); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void CBattleInterface::printConsoleAttacked(int ID, int dmg, int killed, int IDby) | ||||
| { | ||||
| 	char tabh[200]; | ||||
| @@ -1332,6 +1368,8 @@ void CBattleHero::show(SDL_Surface *to) | ||||
| 	{ | ||||
| 		CSDL_Ext::blit8bppAlphaTo24bpp(flag->ourImages[flagAnim].bitmap, NULL, screen, &genRect(flag->ourImages[flagAnim].bitmap->h, flag->ourImages[flagAnim].bitmap->w, 31, 39)); | ||||
| 	} | ||||
| 	++flagAnimCount; | ||||
| 	if(flagAnimCount%4==0) | ||||
| 	{ | ||||
| 		++flagAnim; | ||||
| 		flagAnim %= flag->ourImages.size(); | ||||
| @@ -1411,7 +1449,7 @@ CBattleHero::~CBattleHero() | ||||
| 	delete flag; | ||||
| } | ||||
|  | ||||
| std::pair<int, int> CBattleHex::getXYUnitAnim(int hexNum, bool attacker, CCreature * creature) | ||||
| std::pair<int, int> CBattleHex::getXYUnitAnim(const int & hexNum, const bool & attacker, const CCreature * creature) | ||||
| { | ||||
| 	std::pair<int, int> ret = std::make_pair(-500, -500); //returned value | ||||
| 	ret.second = -139 + 42 * (hexNum/17); //counting y | ||||
| @@ -1642,7 +1680,7 @@ void CBattleConsole::scrollDown(unsigned int by) | ||||
| 		lastShown += by; | ||||
| } | ||||
|  | ||||
| CBattleReslutWindow::CBattleReslutWindow(const BattleResult &br, SDL_Rect & pos, const CBattleInterface * owner) | ||||
| CBattleReslutWindow::CBattleReslutWindow(const BattleResult &br, const SDL_Rect & pos, const CBattleInterface * owner) | ||||
| { | ||||
| 	this->pos = pos; | ||||
| 	background = BitmapHandler::loadBitmap("CPRESULT.BMP", true); | ||||
| @@ -1806,17 +1844,29 @@ void CBattleReslutWindow::bExitf() | ||||
| 	LOCPLINT->battleResultQuited(); | ||||
| } | ||||
|  | ||||
| CBattleOptionsWindow::CBattleOptionsWindow(SDL_Rect & position, CBattleInterface *owner): myInt(owner) | ||||
| CBattleOptionsWindow::CBattleOptionsWindow(const SDL_Rect & position, CBattleInterface *owner): myInt(owner) | ||||
| { | ||||
| 	pos = position; | ||||
| 	background = BitmapHandler::loadBitmap("comopbck.bmp", true); | ||||
| 	graphics->blueToPlayersAdv(background, LOCPLINT->playerID); | ||||
|  | ||||
| 	check = CDefHandler::giveDef("SYSOPCHK.DEF"); | ||||
| 	viewGrid = new CHighlightableButton(boost::bind(&CBattleInterface::setPrintCellBorders, owner, true), boost::bind(&CBattleInterface::setPrintCellBorders, owner, false), boost::assign::map_list_of(0,CGI->preth->zelp[427].first)(3,CGI->preth->zelp[427].first), CGI->preth->zelp[427].second, false, "sysopchk.def", NULL, 185, 140, false); | ||||
| 	viewGrid->select(owner->printCellBorders); | ||||
| 	movementShadow = new CHighlightableButton(boost::bind(&CBattleInterface::setPrintStackRange, owner, true), boost::bind(&CBattleInterface::setPrintStackRange, owner, false), boost::assign::map_list_of(0,CGI->preth->zelp[428].first)(3,CGI->preth->zelp[428].first), CGI->preth->zelp[428].second, false, "sysopchk.def", NULL, 185, 173, false); | ||||
| 	movementShadow->select(owner->printStackRange); | ||||
| 	mouseShadow = new CHighlightableButton(boost::bind(&CBattleInterface::setPrintMouseShadow, owner, true), boost::bind(&CBattleInterface::setPrintMouseShadow, owner, false), boost::assign::map_list_of(0,CGI->preth->zelp[429].first)(3,CGI->preth->zelp[429].first), CGI->preth->zelp[429].second, false, "sysopchk.def", NULL, 185, 207, false); | ||||
| 	mouseShadow->select(owner->printMouseShadow); | ||||
|  | ||||
| 	setToDefault = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleOptionsWindow::bDefaultf,this), 405, 443, "codefaul.def", false, NULL, false); | ||||
| 	animSpeeds = new CHighlightableButtonsGroup(0); | ||||
| 	animSpeeds->addButton(boost::assign::map_list_of(0,CGI->preth->zelp[422].first),CGI->preth->zelp[422].second, "sysopb9.def",188, 309, 1); | ||||
| 	animSpeeds->addButton(boost::assign::map_list_of(0,CGI->preth->zelp[423].first),CGI->preth->zelp[423].second, "sysob10.def",252, 309, 2); | ||||
| 	animSpeeds->addButton(boost::assign::map_list_of(0,CGI->preth->zelp[424].first),CGI->preth->zelp[424].second, "sysob11.def",315, 309, 4); | ||||
| 	animSpeeds->select(owner->getAnimSpeed(), 1); | ||||
| 	animSpeeds->onChange = boost::bind(&CBattleInterface::setAnimSpeed, owner, _1); | ||||
|  | ||||
| 	setToDefault = new AdventureMapButton (CGI->preth->zelp[392].first, CGI->preth->zelp[392].second, boost::bind(&CBattleOptionsWindow::bDefaultf,this), 405, 443, "codefaul.def", false, NULL, false); | ||||
| 	std::swap(setToDefault->imgs[0][0], setToDefault->imgs[0][1]); | ||||
| 	exit = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleOptionsWindow::bExitf,this), 516, 443, "soretrn.def", false, NULL, false); | ||||
| 	exit = new AdventureMapButton (CGI->preth->zelp[393].first, CGI->preth->zelp[393].second, boost::bind(&CBattleOptionsWindow::bExitf,this), 516, 443, "soretrn.def", false, NULL, false); | ||||
| 	std::swap(exit->imgs[0][0], exit->imgs[0][1]); | ||||
|  | ||||
| 	//printing texts to background | ||||
| @@ -1852,19 +1902,31 @@ CBattleOptionsWindow::~CBattleOptionsWindow() | ||||
|  | ||||
| 	delete setToDefault; | ||||
| 	delete exit; | ||||
| 	delete check; | ||||
|  | ||||
| 	delete viewGrid; | ||||
| 	delete movementShadow; | ||||
| 	delete animSpeeds; | ||||
| 	delete mouseShadow; | ||||
| } | ||||
|  | ||||
| void CBattleOptionsWindow::activate() | ||||
| { | ||||
| 	setToDefault->activate(); | ||||
| 	exit->activate(); | ||||
| 	viewGrid->activate(); | ||||
| 	movementShadow->activate(); | ||||
| 	animSpeeds->activate(); | ||||
| 	mouseShadow->activate(); | ||||
| } | ||||
|  | ||||
| void CBattleOptionsWindow::deactivate() | ||||
| { | ||||
| 	setToDefault->deactivate(); | ||||
| 	exit->deactivate(); | ||||
| 	viewGrid->deactivate(); | ||||
| 	movementShadow->deactivate(); | ||||
| 	animSpeeds->deactivate(); | ||||
| 	mouseShadow->deactivate(); | ||||
| } | ||||
|  | ||||
| void CBattleOptionsWindow::show(SDL_Surface *to) | ||||
| @@ -1876,6 +1938,10 @@ void CBattleOptionsWindow::show(SDL_Surface *to) | ||||
|  | ||||
| 	setToDefault->show(to); | ||||
| 	exit->show(to); | ||||
| 	viewGrid->show(to); | ||||
| 	movementShadow->show(to); | ||||
| 	animSpeeds->show(to); | ||||
| 	mouseShadow->show(to); | ||||
| } | ||||
|  | ||||
| void CBattleOptionsWindow::bDefaultf() | ||||
|   | ||||
| @@ -9,6 +9,8 @@ class CDefHandler; | ||||
| class CStack; | ||||
| class CCallback; | ||||
| class AdventureMapButton; | ||||
| class CHighlightableButton; | ||||
| class CHighlightableButtonsGroup; | ||||
| struct BattleResult; | ||||
| template <typename T> struct CondSh; | ||||
|  | ||||
| @@ -41,7 +43,7 @@ public: | ||||
| 	//CStack * ourStack; | ||||
| 	bool hovered, strictHovered; | ||||
| 	CBattleInterface * myInterface; //interface that owns me | ||||
| 	static std::pair<int, int> getXYUnitAnim(int hexNum, bool attacker, CCreature * creature); //returns (x, y) of left top corner of animation | ||||
| 	static std::pair<int, int> getXYUnitAnim(const int & hexNum, const bool & attacker, const CCreature * creature); //returns (x, y) of left top corner of animation | ||||
| 	//for user interactions | ||||
| 	void hover (bool on); | ||||
| 	void activate(); | ||||
| @@ -80,7 +82,7 @@ private: | ||||
| 	SDL_Surface * background; | ||||
| 	AdventureMapButton * exit; | ||||
| public: | ||||
| 	CBattleReslutWindow(const BattleResult & br, SDL_Rect & pos, const CBattleInterface * owner); //c-tor | ||||
| 	CBattleReslutWindow(const BattleResult & br, const SDL_Rect & pos, const CBattleInterface * owner); //c-tor | ||||
| 	~CBattleReslutWindow(); //d-tor | ||||
|  | ||||
| 	void bExitf(); | ||||
| @@ -96,9 +98,10 @@ private: | ||||
| 	CBattleInterface * myInt; | ||||
| 	SDL_Surface * background; | ||||
| 	AdventureMapButton * setToDefault, * exit; | ||||
| 	CDefHandler * check; | ||||
| 	CHighlightableButton * viewGrid, * movementShadow, * mouseShadow; | ||||
| 	CHighlightableButtonsGroup * animSpeeds; | ||||
| public: | ||||
| 	CBattleOptionsWindow(SDL_Rect & position, CBattleInterface * owner); //c-tor | ||||
| 	CBattleOptionsWindow(const SDL_Rect & position, CBattleInterface * owner); //c-tor | ||||
| 	~CBattleOptionsWindow(); //d-tor | ||||
|  | ||||
| 	void bDefaultf(); | ||||
| @@ -125,8 +128,8 @@ private: | ||||
| 	unsigned char animCount; | ||||
| 	int activeStack; //number of active stack; -1 - no one | ||||
| 	std::vector<int> shadedHexes; //hexes available for active stack | ||||
| 	void showRange(SDL_Surface * to, int ID); //show helper funtion ot mark range of a unit | ||||
| 	int animSpeed; //speed of animation; 1 - slowest, 2 - medium, 4 - fastest | ||||
| 	float getAnimSpeedMultiplier() const; //returns multiplier for number of frames in a group | ||||
|  | ||||
| 	class CAttHelper | ||||
| 	{ | ||||
| @@ -141,6 +144,7 @@ private: | ||||
| 		int shootingGroup; //if shooting is true, print this animation group | ||||
| 	} * attackingInfo; | ||||
| 	void attackingShowHelper(); | ||||
| 	void redrawBackgroundWithHexes(int activeStack); | ||||
| 	void printConsoleAttacked(int ID, int dmg, int killed, int IDby); | ||||
|  | ||||
| 	struct SProjectileInfo | ||||
| @@ -162,6 +166,14 @@ public: | ||||
|  | ||||
| 	//std::vector<TimeInterested*> timeinterested; //animation handling | ||||
| 	bool printCellBorders; //if true, cell borders will be printed | ||||
| 	void setPrintCellBorders(bool set); //set for above member | ||||
| 	bool printStackRange; //if true,range of active stack will be printed | ||||
| 	void setPrintStackRange(bool set); //set for above member | ||||
| 	bool printMouseShadow; //if true, hex under mouse will be shaded | ||||
| 	void setPrintMouseShadow(bool set); //set for above member | ||||
| 	void setAnimSpeed(int set); //set for animSpeed | ||||
| 	int getAnimSpeed() const; //get for animSpeed | ||||
|  | ||||
| 	CBattleHex bfield[187]; //11 lines, 17 hexes on each | ||||
| 	std::vector< CBattleObstacle * > obstacles; //vector of obstacles on the battlefield | ||||
| 	SDL_Surface * cellBorder, * cellShade; | ||||
|   | ||||
| @@ -153,6 +153,12 @@ void CCreatureAnimation::incrementFrame() | ||||
| 			curFrame = 0; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| int CCreatureAnimation::getFrame() const | ||||
| { | ||||
| 	return curFrame; | ||||
| } | ||||
|  | ||||
| int CCreatureAnimation::nextFrame(SDL_Surface *dest, int x, int y, bool attacker, bool IncrementFrame, bool yellowBorder, SDL_Rect * destRect) | ||||
| { | ||||
| 	if(dest->format->BytesPerPixel<3) | ||||
|   | ||||
| @@ -41,6 +41,7 @@ public: | ||||
| 	int nextFrame(SDL_Surface * dest, int x, int y, bool attacker, bool incrementFrame = true, bool yellowBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next  | ||||
| 	int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, bool IncrementFrame = true, bool yellowBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next  | ||||
| 	void incrementFrame(); | ||||
| 	int getFrame() const; | ||||
|  | ||||
| 	int framesInGroup(int group) const; //retirns number of fromes in given group | ||||
| }; | ||||
|   | ||||
							
								
								
									
										2
									
								
								global.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								global.h
									
									
									
									
									
								
							| @@ -3,9 +3,11 @@ | ||||
| #include <iostream> | ||||
| #include <boost/logic/tribool.hpp> | ||||
| #include <boost/cstdint.hpp> | ||||
| typedef boost::uint64_t ui64; //unsigned int 64 bits (8 bytes) | ||||
| typedef boost::uint32_t ui32;  //unsigned int 32 bits (4 bytes) | ||||
| typedef boost::uint16_t ui16; //unsigned int 16 bits (2 bytes) | ||||
| typedef boost::uint8_t ui8; //unsigned int 8 bits (1 byte) | ||||
| typedef boost::int64_t si64; //signed int 64 bits (8 bytes) | ||||
| typedef boost::int32_t si32; //signed int 32 bits (4 bytes) | ||||
| typedef boost::int16_t si16; //signed int 16 bits (2 bytes) | ||||
| typedef boost::int8_t si8; //signed int 8 bits (1 byte) | ||||
|   | ||||
| @@ -15,7 +15,7 @@ CCreatureHandler::CCreatureHandler() | ||||
| { | ||||
| 	VLC->creh = this; | ||||
| } | ||||
| int CCreature::getQuantityID(int quantity) | ||||
| int CCreature::getQuantityID(const int & quantity) | ||||
| { | ||||
| 	if (quantity<5) | ||||
| 		return 0; | ||||
| @@ -38,16 +38,16 @@ int CCreature::getQuantityID(int quantity) | ||||
| 	return 8; | ||||
| } | ||||
|  | ||||
| bool CCreature::isDoubleWide() | ||||
| bool CCreature::isDoubleWide() const | ||||
| { | ||||
| 	return vstd::contains(abilities,DOUBLE_WIDE); | ||||
| } | ||||
|  | ||||
| bool CCreature::isFlying() | ||||
| bool CCreature::isFlying() const | ||||
| { | ||||
| 	return vstd::contains(abilities,FLYING); | ||||
| } | ||||
| bool CCreature::isShooting() | ||||
| bool CCreature::isShooting() const | ||||
| { | ||||
| 	return vstd::contains(abilities,SHOOTER); | ||||
| } | ||||
|   | ||||
| @@ -39,11 +39,11 @@ public: | ||||
|  | ||||
| 	//TODO - zdolno�ci (abilities) - na typie wyliczeniowym czy czym� - albo lepiej secie czego� | ||||
|  | ||||
| 	bool isDoubleWide(); //returns true if unit is double wide on battlefield | ||||
| 	bool isFlying(); //returns true if it is a flying unit | ||||
| 	bool isShooting(); //returns true if unit can shoot | ||||
| 	bool isDoubleWide() const; //returns true if unit is double wide on battlefield | ||||
| 	bool isFlying() const; //returns true if it is a flying unit | ||||
| 	bool isShooting() const; //returns true if unit can shoot | ||||
| 	si32 maxAmount(const std::vector<si32> &res) const; //how many creatures can be bought | ||||
| 	static int getQuantityID(int quantity); //0 - a few, 1 - several, 2 - pack, 3 - lots, 4 - horde, 5 - throng, 6 - swarm, 7 - zounds, 8 - legion | ||||
| 	static int getQuantityID(const int & quantity); //0 - a few, 1 - several, 2 - pack, 3 - lots, 4 - horde, 5 - throng, 6 - swarm, 7 - zounds, 8 - legion | ||||
| }; | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -190,7 +190,7 @@ unsigned char * CDefHandler::writeNormalNr (int nr, int bytCon) | ||||
| 		if(ret!=NULL) | ||||
| 			break; | ||||
| 	} | ||||
| 	long long amp = pow(256,bytCon-1); | ||||
| 	long long amp = pow((long long int)256,bytCon-1); | ||||
| 	for (int i=bytCon-1; i>=0;i--) | ||||
| 	{ | ||||
| 		int test2 = nr/(amp); | ||||
| @@ -564,6 +564,8 @@ CDefHandler * CDefHandler::giveDef(std::string defName, CLodHandler * spriteh) | ||||
| { | ||||
| 	if(!spriteh) spriteh=Spriteh; | ||||
| 	unsigned char * data = spriteh->giveFile(defName); | ||||
| 	if(!data) | ||||
| 		throw "bad def name!"; | ||||
| 	CDefHandler * nh = new CDefHandler(); | ||||
| 	nh->openFromMemory(data, defName); | ||||
| 	nh->alphaTransformed = false; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user