mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	| @@ -47,7 +47,11 @@ void CButtonBase::update() | |||||||
| 		else | 		else | ||||||
| 			text->moveTo(Point(pos.x+pos.w/2, pos.y+pos.h/2)); | 			text->moveTo(Point(pos.x+pos.w/2, pos.y+pos.h/2)); | ||||||
| 	} | 	} | ||||||
|  | 	 | ||||||
| 	size_t newPos = (int)state + bitmapOffset; | 	size_t newPos = (int)state + bitmapOffset; | ||||||
|  | 	if (state == HIGHLIGHTED && image->size() < 4) | ||||||
|  | 		newPos = image->size()-1; | ||||||
|  |  | ||||||
| 	if (swappedImages) | 	if (swappedImages) | ||||||
| 	{ | 	{ | ||||||
| 		     if (newPos == 0) newPos = 1; | 		     if (newPos == 0) newPos = 1; | ||||||
| @@ -55,7 +59,9 @@ void CButtonBase::update() | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (!keepFrame) | 	if (!keepFrame) | ||||||
|  | 	{ | ||||||
| 		image->setFrame(newPos); | 		image->setFrame(newPos); | ||||||
|  | 	} | ||||||
| 	 | 	 | ||||||
| 	if (active) | 	if (active) | ||||||
| 	{ | 	{ | ||||||
| @@ -277,6 +283,7 @@ void AdventureMapButton::showAll(SDL_Surface *to) | |||||||
|  |  | ||||||
| void CHighlightableButton::select(bool on) | void CHighlightableButton::select(bool on) | ||||||
| { | { | ||||||
|  | 	selected = on; | ||||||
| 	if (on) | 	if (on) | ||||||
| 	{ | 	{ | ||||||
| 		setState(HIGHLIGHTED); | 		setState(HIGHLIGHTED); | ||||||
| @@ -311,7 +318,7 @@ void CHighlightableButton::clickLeft(tribool down, bool previousState) | |||||||
| 	if(previousState  &&  down == false && getState() == PRESSED) | 	if(previousState  &&  down == false && getState() == PRESSED) | ||||||
| 	{ | 	{ | ||||||
| 		//if(!onlyOn || !isHighlighted()) | 		//if(!onlyOn || !isHighlighted()) | ||||||
| 			select(!isHighlighted()); | 			select(!selected); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -104,6 +104,7 @@ public: | |||||||
| 	CHighlightableButton(const std::pair<std::string, std::string> &help, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key=0, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor | 	CHighlightableButton(const std::pair<std::string, std::string> &help, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key=0, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor | ||||||
| 	CHighlightableButton(const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key=0, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor | 	CHighlightableButton(const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key=0, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor | ||||||
| 	bool onlyOn;//button can not be de-selected | 	bool onlyOn;//button can not be de-selected | ||||||
|  | 	bool selected;//state of highlightable button | ||||||
| 	int ID; //for identification | 	int ID; //for identification | ||||||
| 	CFunctionList<void()> callback2; //when de-selecting | 	CFunctionList<void()> callback2; //when de-selecting | ||||||
| 	void select(bool on); | 	void select(bool on); | ||||||
|   | |||||||
| @@ -591,13 +591,19 @@ SDLImage::SDLImage(std::string filename, bool compressed): | |||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		tlog0<<"Error: file not found: "<<filename<<"\n"; |  | ||||||
| 		surf = NULL; | 		surf = NULL; | ||||||
| 		return; |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if (surf == NULL) | ||||||
|  | 	{ | ||||||
|  | 		tlog1 << "Error: failed to load image "<<filename<<"\n"; | ||||||
|  | 	} | ||||||
|  | 	else | ||||||
|  | 	{ | ||||||
| 		fullSize.x = surf->w; | 		fullSize.x = surf->w; | ||||||
| 		fullSize.y = surf->h; | 		fullSize.y = surf->h; | ||||||
| 	} | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
| void SDLImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, unsigned char rotation) const | void SDLImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, unsigned char rotation) const | ||||||
| { | { | ||||||
| @@ -1160,6 +1166,11 @@ CAnimImage::CAnimImage(CAnimation *Anim, size_t Frame, size_t Group, int x, int | |||||||
| 	init(); | 	init(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | size_t CAnimImage::size() | ||||||
|  | { | ||||||
|  | 	return anim->size(group); | ||||||
|  | } | ||||||
|  |  | ||||||
| void CAnimImage::init() | void CAnimImage::init() | ||||||
| { | { | ||||||
| 	anim->load(frame, group); | 	anim->load(frame, group); | ||||||
|   | |||||||
| @@ -245,6 +245,9 @@ public: | |||||||
| 	CAnimImage(CAnimation* anim, size_t Frame, size_t Group=0, int x=0, int y=0, unsigned char Flags=0); | 	CAnimImage(CAnimation* anim, size_t Frame, size_t Group=0, int x=0, int y=0, unsigned char Flags=0); | ||||||
| 	~CAnimImage();//d-tor | 	~CAnimImage();//d-tor | ||||||
|  |  | ||||||
|  | 	//size of animation | ||||||
|  | 	size_t size(); | ||||||
|  |  | ||||||
| 	//change displayed frame on this one | 	//change displayed frame on this one | ||||||
| 	void setFrame(size_t Frame, size_t Group=0); | 	void setFrame(size_t Frame, size_t Group=0); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1118,9 +1118,9 @@ void CBattleInterface::addNewAnim(CBattleAnimation * anim) | |||||||
| CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2, const SDL_Rect & myRect, CPlayerInterface * att, CPlayerInterface * defen) | CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2, const SDL_Rect & myRect, CPlayerInterface * att, CPlayerInterface * defen) | ||||||
| 	: queue(NULL), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0),  | 	: queue(NULL), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0),  | ||||||
| 	  activeStack(NULL), stackToActivate(NULL), mouseHoveredStack(-1), previouslyHoveredHex(-1), | 	  activeStack(NULL), stackToActivate(NULL), mouseHoveredStack(-1), previouslyHoveredHex(-1), | ||||||
| 	  currentlyHoveredHex(-1), spellDestSelectMode(false), spellToCast(NULL), siegeH(NULL), | 	  currentlyHoveredHex(-1), tacticianInterface(NULL),  spellDestSelectMode(false), spellToCast(NULL), | ||||||
| 	  attackerInt(att), defenderInt(defen), curInt(att), animIDhelper(0), givenCommand(NULL), | 	  siegeH(NULL), attackerInt(att), defenderInt(defen), curInt(att), animIDhelper(0), givenCommand(NULL), | ||||||
| 	  myTurn(false), resWindow(NULL), moveStarted(false), moveSh(-1), bresult(NULL), tacticianInterface(NULL) | 	  myTurn(false), resWindow(NULL), moveStarted(false), moveSh(-1), bresult(NULL) | ||||||
| { | { | ||||||
| 	ObjectConstruction h__l__p(this); | 	ObjectConstruction h__l__p(this); | ||||||
|  |  | ||||||
| @@ -2523,9 +2523,9 @@ void CBattleInterface::newRoundFirst( int round ) | |||||||
| { | { | ||||||
| 	//handle regeneration | 	//handle regeneration | ||||||
| 	std::vector<const CStack*> stacks = curInt->cb->battleGetStacks(); //gets only alive stacks | 	std::vector<const CStack*> stacks = curInt->cb->battleGetStacks(); //gets only alive stacks | ||||||
| 	BOOST_FOREACH(const CStack *s, stacks) | //	BOOST_FOREACH(const CStack *s, stacks) | ||||||
| 	{ | //	{ | ||||||
| 	} | //	} | ||||||
| 	waitForAnims(); | 	waitForAnims(); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -3549,11 +3549,13 @@ void CBattleInterface::projectileShowHelper(SDL_Surface * to) | |||||||
| 		// Creature have to be in a shooting anim and the anim start delay must be over. | 		// Creature have to be in a shooting anim and the anim start delay must be over. | ||||||
| 		// Otherwise abort to start moving the projectile. | 		// Otherwise abort to start moving the projectile. | ||||||
| 		if (it->animStartDelay > 0) | 		if (it->animStartDelay > 0) | ||||||
|  | 		{ | ||||||
| 			if(it->animStartDelay == creAnims[it->stackID]->getAnimationFrame() + 1 | 			if(it->animStartDelay == creAnims[it->stackID]->getAnimationFrame() + 1 | ||||||
| 					&& creAnims[it->stackID]->getType() >= 14 && creAnims[it->stackID]->getType() <= 16) | 					&& creAnims[it->stackID]->getType() >= 14 && creAnims[it->stackID]->getType() <= 16) | ||||||
| 				it->animStartDelay = 0; | 				it->animStartDelay = 0; | ||||||
| 			else | 			else | ||||||
| 				continue; | 				continue; | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		SDL_Rect dst; | 		SDL_Rect dst; | ||||||
| 		dst.h = idToProjectile[it->creID]->ourImages[it->frameNum].bitmap->h; | 		dst.h = idToProjectile[it->creID]->ourImages[it->frameNum].bitmap->h; | ||||||
| @@ -4372,10 +4374,10 @@ CBattleOptionsWindow::CBattleOptionsWindow(const SDL_Rect & position, CBattleInt | |||||||
| 	animSpeeds->select(owner->getAnimSpeed(), 1); | 	animSpeeds->select(owner->getAnimSpeed(), 1); | ||||||
| 	animSpeeds->onChange = boost::bind(&CBattleInterface::setAnimSpeed, owner, _1); | 	animSpeeds->onChange = boost::bind(&CBattleInterface::setAnimSpeed, owner, _1); | ||||||
|  |  | ||||||
| 	setToDefault = new AdventureMapButton (CGI->generaltexth->zelp[392].first, CGI->generaltexth->zelp[392].second, boost::bind(&CBattleOptionsWindow::bDefaultf,this), 405, 443, "codefaul.def"); | 	setToDefault = new AdventureMapButton (CGI->generaltexth->zelp[393], boost::bind(&CBattleOptionsWindow::bDefaultf,this), 405, 443, "codefaul.def"); | ||||||
| 	setToDefault->swappedImages = true; | 	setToDefault->swappedImages = true; | ||||||
| 	setToDefault->update(); | 	setToDefault->update(); | ||||||
| 	exit = new AdventureMapButton (CGI->generaltexth->zelp[393].first, CGI->generaltexth->zelp[393].second, boost::bind(&CBattleOptionsWindow::bExitf,this), 516, 443, "soretrn.def",SDLK_RETURN); | 	exit = new AdventureMapButton (CGI->generaltexth->zelp[392], boost::bind(&CBattleOptionsWindow::bExitf,this), 516, 443, "soretrn.def",SDLK_RETURN); | ||||||
| 	exit->swappedImages = true; | 	exit->swappedImages = true; | ||||||
| 	exit->update(); | 	exit->update(); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user