mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	World view impl -- initial;
This commit is contained in:
		| @@ -96,7 +96,7 @@ static bool objectBlitOrderSorter(const std::pair<const CGObjectInstance*,SDL_Re | ||||
|  | ||||
| CPlayerInterface::CPlayerInterface(PlayerColor Player) | ||||
| { | ||||
|     logGlobal->traceStream() << "\tHuman player interface for player " << Player << " being constructed"; | ||||
| 	logGlobal->traceStream() << "\tHuman player interface for player " << Player << " being constructed"; | ||||
| 	observerInDuelMode = false; | ||||
| 	howManyPeople++; | ||||
| 	GH.defActionsDef = 0; | ||||
| @@ -115,7 +115,7 @@ CPlayerInterface::CPlayerInterface(PlayerColor Player) | ||||
| 	firstCall = 1; //if loading will be overwritten in serialize | ||||
| 	autosaveCount = 0; | ||||
| 	isAutoFightOn = false; | ||||
| 	 | ||||
|  | ||||
| 	duringMovement = false; | ||||
| 	ignoreEvents = false; | ||||
| 	locked = false; | ||||
| @@ -768,7 +768,7 @@ void CPlayerInterface::actionFinished(const BattleAction &action) | ||||
| BattleAction CPlayerInterface::activeStack(const CStack * stack) //called when it's turn of that stack | ||||
| { | ||||
| 	THREAD_CREATED_BY_CLIENT; | ||||
|     logGlobal->traceStream() << "Awaiting command for " << stack->nodeName(); | ||||
| 	logGlobal->traceStream() << "Awaiting command for " << stack->nodeName(); | ||||
|  | ||||
| 	if(autofightingAI) | ||||
| 	{ | ||||
| @@ -813,7 +813,7 @@ BattleAction CPlayerInterface::activeStack(const CStack * stack) //called when i | ||||
| 	b->givenCommand->data = nullptr; | ||||
|  | ||||
| 	//return command | ||||
|     logGlobal->traceStream() << "Giving command for " << stack->nodeName(); | ||||
| 	logGlobal->traceStream() << "Giving command for " << stack->nodeName(); | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| @@ -876,7 +876,7 @@ void CPlayerInterface::battleStacksAttacked(const std::vector<BattleStackAttacke | ||||
| { | ||||
| 	EVENT_HANDLER_CALLED_BY_CLIENT; | ||||
| 	BATTLE_EVENT_POSSIBLE_RETURN; | ||||
| 	 | ||||
|  | ||||
| 	std::vector<StackAttackedInfo> arg; | ||||
| 	for(auto & elem : bsa) | ||||
| 	{ | ||||
| @@ -890,7 +890,7 @@ void CPlayerInterface::battleStacksAttacked(const std::vector<BattleStackAttacke | ||||
| 		if(elem.isSpell()) | ||||
| 		{ | ||||
| 			if (defender) | ||||
| 				battleInt->displaySpellEffect(elem.spellID, defender->position);			 | ||||
| 				battleInt->displaySpellEffect(elem.spellID, defender->position); | ||||
| 		} | ||||
| 		//FIXME: why action is deleted during enchanter cast? | ||||
| 		bool remoteAttack = false; | ||||
| @@ -973,14 +973,14 @@ void CPlayerInterface::battleAttack(const BattleAttack *ba) | ||||
| 		const CStack * attacked = cb->battleGetStackByID(ba->bsa.begin()->stackAttacked); | ||||
| 		battleInt->stackAttacking( attacker, ba->counter() ? curAction->destinationTile + shift : curAction->additionalInfo, attacked, false); | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	//battleInt->waitForAnims(); //FIXME: freeze | ||||
| 	 | ||||
|  | ||||
| 	if(ba->spellLike()) | ||||
| 	{ | ||||
| 		//display hit animation		 | ||||
| 		SpellID spellID = ba->spellID;			 | ||||
| 		battleInt->displaySpellHit(spellID,curAction->destinationTile);	 | ||||
| 		//display hit animation | ||||
| 		SpellID spellID = ba->spellID; | ||||
| 		battleInt->displaySpellHit(spellID,curAction->destinationTile); | ||||
| 	} | ||||
| } | ||||
| void CPlayerInterface::battleObstaclePlaced(const CObstacleInstance &obstacle) | ||||
| @@ -1264,15 +1264,15 @@ template <typename Handler> void CPlayerInterface::serializeTempl( Handler &h, c | ||||
| 	{ | ||||
| 		h & pathsMap; | ||||
|  | ||||
|         if(cb) | ||||
|             for(auto &p : pathsMap) | ||||
|             { | ||||
|                 CGPath path; | ||||
|                 cb->getPathsInfo(p.first)->getPath(p.second, path); | ||||
|                 paths[p.first] = path; | ||||
|                 logGlobal->traceStream() << boost::format("Restored path for hero %s leading to %s with %d nodes") | ||||
|                     % p.first->nodeName() % p.second % path.nodes.size(); | ||||
|             } | ||||
| 		if(cb) | ||||
| 			for(auto &p : pathsMap) | ||||
| 			{ | ||||
| 				CGPath path; | ||||
| 				cb->getPathsInfo(p.first)->getPath(p.second, path); | ||||
| 				paths[p.first] = path; | ||||
| 				logGlobal->traceStream() << boost::format("Restored path for hero %s leading to %s with %d nodes") | ||||
| 					% p.first->nodeName() % p.second % path.nodes.size(); | ||||
| 			} | ||||
| 	} | ||||
|  | ||||
| 	h & spellbookSettings; | ||||
| @@ -1293,7 +1293,7 @@ void CPlayerInterface::loadGame( CISer & h, const int version ) | ||||
|  | ||||
| void CPlayerInterface::moveHero( const CGHeroInstance *h, CGPath path ) | ||||
| { | ||||
|     logGlobal->traceStream() << __FUNCTION__; | ||||
| 	logGlobal->traceStream() << __FUNCTION__; | ||||
| 	if(!LOCPLINT->makingTurn) | ||||
| 		return; | ||||
| 	if (!h) | ||||
| @@ -1304,7 +1304,7 @@ void CPlayerInterface::moveHero( const CGHeroInstance *h, CGPath path ) | ||||
| 		return; | ||||
|  | ||||
| 	duringMovement = true; | ||||
| 	 | ||||
|  | ||||
| 	if (adventureInt && adventureInt->isHeroSleeping(h)) | ||||
| 	{ | ||||
| 		adventureInt->sleepWake->clickLeft(true, false); | ||||
| @@ -1313,10 +1313,10 @@ void CPlayerInterface::moveHero( const CGHeroInstance *h, CGPath path ) | ||||
| 		//adventureInt->fsleepWake(); | ||||
| 		//but no authentic button click/sound ;-) | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	boost::thread moveHeroTask(std::bind(&CPlayerInterface::doMoveHero,this,h,path)); | ||||
|  | ||||
| 	 | ||||
|  | ||||
| } | ||||
|  | ||||
| bool CPlayerInterface::shiftPressed() const | ||||
| @@ -1480,7 +1480,7 @@ void CPlayerInterface::waitWhileDialog(bool unlockPim /*= true*/) | ||||
| { | ||||
| 	if(GH.amIGuiThread()) | ||||
| 	{ | ||||
|         logGlobal->warnStream() << "Cannot wait for dialogs in gui thread (deadlock risk)!"; | ||||
| 		logGlobal->warnStream() << "Cannot wait for dialogs in gui thread (deadlock risk)!"; | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| @@ -1539,7 +1539,7 @@ void CPlayerInterface::objectRemoved( const CGObjectInstance *obj ) | ||||
| 	EVENT_HANDLER_CALLED_BY_CLIENT; | ||||
| 	if (LOCPLINT->cb->getCurrentPlayer() == playerID) { | ||||
| 		std::string handlerName = VLC->objtypeh->getObjectHandlerName(obj->ID); | ||||
|         if ((handlerName == "pickable") || (handlerName == "scholar") || (handlerName== "artifact") || (handlerName == "pandora")) { | ||||
| 		if ((handlerName == "pickable") || (handlerName == "scholar") || (handlerName== "artifact") || (handlerName == "pandora")) { | ||||
| 			waitWhileDialog(); | ||||
| 			CCS->soundh->playSoundFromSet(CCS->soundh->pickupSounds); | ||||
| 		} else if ((handlerName == "monster") || (handlerName == "hero")) { | ||||
| @@ -1626,11 +1626,11 @@ void CPlayerInterface::runLocked(std::function<void(IUpdateable * )> functor) | ||||
| 	// While mutexes were locked away we may be have stopped being the active interface | ||||
| 	if(LOCPLINT != this) | ||||
| 		return; | ||||
| 		 | ||||
|  | ||||
| 	// Make sure that gamestate won't change when GUI objects may obtain its parts on event processing or drawing request | ||||
| 	boost::shared_lock<boost::shared_mutex> gsLock(cb->getGsMutex());		 | ||||
| 	 | ||||
| 	locked = true;	 | ||||
| 	boost::shared_lock<boost::shared_mutex> gsLock(cb->getGsMutex()); | ||||
|  | ||||
| 	locked = true; | ||||
| 	functor(this); | ||||
| 	locked = false; | ||||
| } | ||||
| @@ -2171,6 +2171,11 @@ void CPlayerInterface::showPuzzleMap() | ||||
| 	GH.pushInt(new CPuzzleWindow(grailPos, ratio)); | ||||
| } | ||||
|  | ||||
| void CPlayerInterface::viewWorldMap() | ||||
| { | ||||
| 	adventureInt->changeMode(EAdvMapMode::WORLD_VIEW); | ||||
| } | ||||
|  | ||||
| void CPlayerInterface::advmapSpellCast(const CGHeroInstance * caster, int spellID) | ||||
| { | ||||
| 	EVENT_HANDLER_CALLED_BY_CLIENT; | ||||
| @@ -2179,7 +2184,7 @@ void CPlayerInterface::advmapSpellCast(const CGHeroInstance * caster, int spellI | ||||
| 		eraseCurrentPathOf(caster, false); | ||||
| 	} | ||||
| 	const CSpell * spell = CGI->spellh->objects[spellID]; | ||||
| 	 | ||||
|  | ||||
| 	auto castSoundPath = spell->getCastSound(); | ||||
| 	if (!castSoundPath.empty()) | ||||
| 		CCS->soundh->playSound(castSoundPath); | ||||
| @@ -2216,7 +2221,7 @@ CGPath * CPlayerInterface::getAndVerifyPath(const CGHeroInstance * h) | ||||
| 		CGPath &path = paths[h]; | ||||
| 		if(!path.nodes.size()) | ||||
| 		{ | ||||
|             logGlobal->warnStream() << "Warning: empty path found..."; | ||||
| 			logGlobal->warnStream() << "Warning: empty path found..."; | ||||
| 			paths.erase(h); | ||||
| 		} | ||||
| 		else | ||||
| @@ -2601,7 +2606,7 @@ bool CPlayerInterface::capturedAllEvents() | ||||
| 		//just inform that we are capturing events. they will be processed by heroMoved() in client thread. | ||||
| 		return true; | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	if(ignoreEvents) | ||||
| 	{ | ||||
| 		boost::unique_lock<boost::mutex> un(eventsM); | ||||
| @@ -2611,7 +2616,7 @@ bool CPlayerInterface::capturedAllEvents() | ||||
| 		} | ||||
| 		return true; | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
| @@ -2690,7 +2695,7 @@ void CPlayerInterface::doMoveHero(const CGHeroInstance* h, CGPath path) | ||||
| 		// (i == 0) means hero went through all the path | ||||
| 		adventureInt->updateMoveHero(h, (i != 0)); | ||||
| 		adventureInt->updateNextHero(h); | ||||
| 	}	 | ||||
| 	 | ||||
| 	} | ||||
|  | ||||
| 	duringMovement = false; | ||||
| } | ||||
|   | ||||
| @@ -170,6 +170,7 @@ public: | ||||
| 	void showBlockingDialog(const std::string &text, const std::vector<Component> &components, QueryID askID, int soundID, bool selection, bool cancel) override; //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID. | ||||
| 	void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, QueryID queryID) override; | ||||
| 	void showPuzzleMap() override; | ||||
| 	void viewWorldMap() override; | ||||
| 	void showMarketWindow(const IMarket *market, const CGHeroInstance *visitor) override; | ||||
| 	void showUniversityWindow(const IMarket *market, const CGHeroInstance *visitor) override; | ||||
| 	void showHillFortWindow(const CGObjectInstance *object, const CGHeroInstance *visitor) override; | ||||
| @@ -267,15 +268,15 @@ public: | ||||
| 	~CPlayerInterface();//d-tor | ||||
|  | ||||
| 	static CondSh<bool> terminate_cond; // confirm termination | ||||
| 	 | ||||
|  | ||||
|  | ||||
|  | ||||
| private: | ||||
|  | ||||
| 	template <typename Handler> void serializeTempl(Handler &h, const int version); | ||||
|  | ||||
| private:	 | ||||
| 	 | ||||
| private: | ||||
|  | ||||
| 	struct IgnoreEvents | ||||
| 	{ | ||||
| 		CPlayerInterface & owner; | ||||
| @@ -287,16 +288,16 @@ private: | ||||
| 		{ | ||||
| 			owner.ignoreEvents = false; | ||||
| 		}; | ||||
| 		 | ||||
|  | ||||
| 	}; | ||||
| 	 | ||||
| 	 | ||||
| 	 | ||||
|  | ||||
|  | ||||
|  | ||||
| 	bool duringMovement; | ||||
| 	bool ignoreEvents; | ||||
| 	 | ||||
|  | ||||
| 	bool locked; | ||||
| 	 | ||||
|  | ||||
| 	void doMoveHero(const CGHeroInstance *h, CGPath path); | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -12,7 +12,7 @@ IShowActivatable::IShowActivatable() | ||||
|  | ||||
| void ILockedUpdatable::runLocked(std::function<void(IUpdateable*)> cb) | ||||
| { | ||||
| 	boost::unique_lock<boost::recursive_mutex> lock(updateGuard);	 | ||||
| 	boost::unique_lock<boost::recursive_mutex> lock(updateGuard); | ||||
| 	cb(this); | ||||
| } | ||||
|  | ||||
| @@ -82,7 +82,7 @@ void CIntObject::activate() | ||||
| 			return; | ||||
| 		else | ||||
| 		{ | ||||
|             logGlobal->warnStream() << "Warning: IntObject re-activated with mismatching used and active"; | ||||
| 			logGlobal->warnStream() << "Warning: IntObject re-activated with mismatching used and active"; | ||||
| 			deactivate(); //FIXME: better to avoid such possibility at all | ||||
| 		} | ||||
| 	} | ||||
| @@ -145,6 +145,11 @@ void CIntObject::printAtLoc( const std::string & text, int x, int y, EFonts font | ||||
| 	graphics->fonts[font]->renderTextLeft(dst, text, kolor, Point(pos.x + x, pos.y + y)); | ||||
| } | ||||
|  | ||||
| void CIntObject::printAtRightLoc( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=Colors::WHITE*/, SDL_Surface * dst/*=screen*/ ) | ||||
| { | ||||
| 	graphics->fonts[font]->renderTextRight(dst, text, kolor, Point(pos.x + x, pos.y + y)); | ||||
| } | ||||
|  | ||||
| void CIntObject::printAtMiddleLoc( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=Colors::WHITE*/, SDL_Surface * dst/*=screen*/ ) | ||||
| { | ||||
| 	printAtMiddleLoc(text, Point(x,y), font, kolor, dst); | ||||
| @@ -312,8 +317,8 @@ const Rect & CIntObject::center( bool propagate ) | ||||
|  | ||||
| const Rect & CIntObject::center(const Point &p, bool propagate /*= true*/) | ||||
| { | ||||
| 	moveBy(Point(p.x - pos.w/2 - pos.x,  | ||||
| 		p.y - pos.h/2 - pos.y),  | ||||
| 	moveBy(Point(p.x - pos.w/2 - pos.x, | ||||
| 		p.y - pos.h/2 - pos.y), | ||||
| 		propagate); | ||||
| 	return pos; | ||||
| } | ||||
| @@ -333,7 +338,7 @@ CKeyShortcut::CKeyShortcut(int key) | ||||
| } | ||||
|  | ||||
| CKeyShortcut::CKeyShortcut(std::set<int> Keys) | ||||
|     :assignedKeys(Keys) | ||||
| 	:assignedKeys(Keys) | ||||
| {} | ||||
|  | ||||
| void CKeyShortcut::keyPressed(const SDL_KeyboardEvent & key) | ||||
| @@ -342,12 +347,12 @@ void CKeyShortcut::keyPressed(const SDL_KeyboardEvent & key) | ||||
| 	 || vstd::contains(assignedKeys, CGuiHandler::numToDigit(key.keysym.sym))) | ||||
| 	{ | ||||
| 		bool prev = pressedL; | ||||
| 		if(key.state == SDL_PRESSED)  | ||||
| 		if(key.state == SDL_PRESSED) | ||||
| 		{ | ||||
| 			pressedL = true; | ||||
| 			clickLeft(true, prev); | ||||
| 		}  | ||||
| 		else  | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			pressedL = false; | ||||
| 			clickLeft(false, prev); | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|  * Full text of license available in license.txt file, in main folder | ||||
|  * | ||||
|  */ | ||||
|   | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #include <SDL_events.h> | ||||
| @@ -42,8 +42,8 @@ class ILockedUpdatable: public IUpdateable | ||||
| { | ||||
| 	boost::recursive_mutex updateGuard; | ||||
| public: | ||||
| 	virtual void runLocked(std::function<void(IUpdateable * )> cb);	 | ||||
| 	virtual ~ILockedUpdatable(){}; //d-tor	 | ||||
| 	virtual void runLocked(std::function<void(IUpdateable * )> cb); | ||||
| 	virtual ~ILockedUpdatable(){}; //d-tor | ||||
| }; | ||||
|  | ||||
| // Defines a show method | ||||
| @@ -97,7 +97,7 @@ public: | ||||
|  * Don't use them unless you really know what they are for | ||||
|  */ | ||||
| 	std::vector<CIntObject *> children; | ||||
| 	 | ||||
|  | ||||
| 	//FIXME: workaround | ||||
| 	void deactivateKeyboard() | ||||
| 	{ | ||||
| @@ -133,7 +133,7 @@ public: | ||||
| 	bool captureAllKeys; //if true, only this object should get info about pressed keys | ||||
| 	virtual void keyPressed(const SDL_KeyboardEvent & key){} | ||||
| 	virtual bool captureThisEvent(const SDL_KeyboardEvent & key); //allows refining captureAllKeys against specific events (eg. don't capture ENTER) | ||||
| 	 | ||||
|  | ||||
| #ifndef VCMI_SDL1 | ||||
| 	virtual void textInputed(const SDL_TextInputEvent & event){}; | ||||
| 	virtual void textEdited(const SDL_TextEditingEvent & event){}; | ||||
| @@ -201,6 +201,7 @@ public: | ||||
| 	//functions for printing text. Use CLabel where possible instead | ||||
| 	void printAtLoc(const std::string & text, int x, int y, EFonts font, SDL_Color color, SDL_Surface * dst); | ||||
| 	void printToLoc(const std::string & text, int x, int y, EFonts font, SDL_Color color, SDL_Surface * dst); | ||||
| 	void printAtRightLoc(const std::string & text, int x, int y, EFonts font, SDL_Color color, SDL_Surface * dst); | ||||
| 	void printAtMiddleLoc(const std::string & text, int x, int y, EFonts font, SDL_Color color, SDL_Surface * dst); | ||||
| 	void printAtMiddleLoc(const std::string & text, const Point &p, EFonts font, SDL_Color color, SDL_Surface * dst); | ||||
| 	void printAtMiddleWBLoc(const std::string & text, int x, int y, EFonts font, int charsPerLine, SDL_Color color, SDL_Surface * dst); | ||||
|   | ||||
| @@ -33,39 +33,39 @@ | ||||
|  | ||||
| std::string nameFromType (int typ) | ||||
| { | ||||
|     switch(ETerrainType(typ)) | ||||
| 	switch(ETerrainType(typ)) | ||||
| 	{ | ||||
|         case ETerrainType::DIRT: | ||||
| 		case ETerrainType::DIRT: | ||||
| 			return std::string("DIRTTL.DEF"); | ||||
|  | ||||
|         case ETerrainType::SAND: | ||||
| 		case ETerrainType::SAND: | ||||
| 			return std::string("SANDTL.DEF"); | ||||
|  | ||||
|         case ETerrainType::GRASS: | ||||
| 		case ETerrainType::GRASS: | ||||
| 			return std::string("GRASTL.DEF"); | ||||
|  | ||||
|         case ETerrainType::SNOW: | ||||
| 		case ETerrainType::SNOW: | ||||
| 			return std::string("SNOWTL.DEF"); | ||||
|  | ||||
|         case ETerrainType::SWAMP: | ||||
| 		case ETerrainType::SWAMP: | ||||
| 			return std::string("SWMPTL.DEF"); | ||||
|  | ||||
|         case ETerrainType::ROUGH: | ||||
| 		case ETerrainType::ROUGH: | ||||
| 			return std::string("ROUGTL.DEF"); | ||||
|  | ||||
|         case ETerrainType::SUBTERRANEAN: | ||||
| 		case ETerrainType::SUBTERRANEAN: | ||||
| 			return std::string("SUBBTL.DEF"); | ||||
|  | ||||
|         case ETerrainType::LAVA: | ||||
| 		case ETerrainType::LAVA: | ||||
| 			return std::string("LAVATL.DEF"); | ||||
|  | ||||
|         case ETerrainType::WATER: | ||||
| 		case ETerrainType::WATER: | ||||
| 			return std::string("WATRTL.DEF"); | ||||
|  | ||||
|         case ETerrainType::ROCK: | ||||
| 		case ETerrainType::ROCK: | ||||
| 			return std::string("ROCKTL.DEF"); | ||||
|  | ||||
|         case ETerrainType::BORDER: | ||||
| 		case ETerrainType::BORDER: | ||||
| 		//TODO use me | ||||
| 		break; | ||||
| 		default: | ||||
| @@ -110,12 +110,12 @@ struct NeighborTilesInfo | ||||
| 		d2 = getTile( 0, +1); | ||||
| 		d3 = getTile(+1, +1); | ||||
| 	} | ||||
| 	 | ||||
| 	bool areAllHidden() const  | ||||
|  | ||||
| 	bool areAllHidden() const | ||||
| 	{ | ||||
| 		return !(d1 || d2 || d3 || d4 || d5 || d6 || d7 || d8 || d8 ); | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	int getBitmapID() const | ||||
| 	{ | ||||
| 		//NOTE: some images have unused in VCMI pair (same blockmap but a bit different look) | ||||
| @@ -137,9 +137,9 @@ struct NeighborTilesInfo | ||||
| 			13,  27,  44,  44,  13,  27,  44,  44,   8,   8,  10,  10,   8,   8,  10,  10, //224 | ||||
| 			 0,  45,  29,  29,  24,  33,  29,  29,  37,  37,   7,   7,  50,  50,   7,   7, //240 | ||||
| 			13,  27,  44,  44,  13,  27,  44,  44,   8,   8,  10,  10,   8,   8,  10,  10  //256 | ||||
| 		};	 | ||||
| 		 | ||||
| 		return visBitmaps[d1 + d2 * 2 + d3 * 4 + d4 * 8 + d6 * 16 + d7 * 32 + d8 * 64 + d9 * 128]; // >=0 -> partial hide, <0 - full hide	 | ||||
| 		}; | ||||
|  | ||||
| 		return visBitmaps[d1 + d2 * 2 + d3 * 4 + d4 * 8 + d6 * 16 + d7 * 32 + d8 * 64 + d9 * 128]; // >=0 -> partial hide, <0 - full hide | ||||
| 	} | ||||
| }; | ||||
|  | ||||
| @@ -341,7 +341,7 @@ void CMapHandler::initObjectRects() | ||||
| 				cr.x = bitmap->w - fx * 32 - 32; | ||||
| 				cr.y = bitmap->h - fy * 32 - 32; | ||||
| 				std::pair<const CGObjectInstance*,SDL_Rect> toAdd = std::make_pair(obj,cr); | ||||
| 				 | ||||
|  | ||||
|  | ||||
| 				if( map->isInTheMap(currTile) && // within map | ||||
| 					cr.x + cr.w > 0 &&           // image has data on this tile | ||||
| @@ -407,12 +407,445 @@ void CMapHandler::init() | ||||
| 	prepareFOWDefs(); | ||||
| 	roadsRiverTerrainInit();	//road's and river's DefHandlers; and simple values initialization | ||||
| 	borderAndTerrainBitmapInit(); | ||||
|     logGlobal->infoStream()<<"\tPreparing FoW, roads, rivers,borders: "<<th.getDiff(); | ||||
| 	logGlobal->infoStream()<<"\tPreparing FoW, roads, rivers,borders: "<<th.getDiff(); | ||||
| 	initObjectRects(); | ||||
|     logGlobal->infoStream()<<"\tMaking object rects: "<<th.getDiff(); | ||||
| 	logGlobal->infoStream()<<"\tMaking object rects: "<<th.getDiff(); | ||||
|  | ||||
| } | ||||
|  | ||||
| void CMapHandler::drawWorldViewOverlay(int targetTilesX, int targetTilesY, int srx_init, int sry_init, CDefHandler * iconsDef, const std::vector< std::vector< std::vector<ui8> > > * visibilityMap, float scale, int targetTileSize, int3 top_tile, SDL_Surface * extSurf) | ||||
| { | ||||
| 	int srx = srx_init; | ||||
|  | ||||
| 	int bxStart = top_tile.x; | ||||
| 	int byStart = top_tile.y; | ||||
| 	for (int bx = bxStart; bx < top_tile.x + targetTilesX; bx++, srx+=targetTileSize) | ||||
| 	{ | ||||
| 		if (bx < 0 || bx >= sizes.x) | ||||
| 		{ | ||||
| 			continue; | ||||
| 		} | ||||
|  | ||||
| 		int sry = sry_init; | ||||
|  | ||||
| 		for (int by = byStart; by < top_tile.y + targetTilesY; by++, sry+=targetTileSize) | ||||
| 		{ | ||||
| 			if (by < 0 || by >= sizes.y) | ||||
| 			{ | ||||
| 				continue; | ||||
| 			} | ||||
|  | ||||
| 			int3 pos(bx, by, top_tile.z); | ||||
| 			const TerrainTile2 & tile = ttiles[pos.x][pos.y][pos.z]; | ||||
|  | ||||
| 			auto &objects = tile.objects; | ||||
| 			for(auto & object : objects) | ||||
| 			{ | ||||
| 				const CGObjectInstance *obj = object.first; | ||||
|  | ||||
| 				if (obj->pos.z != top_tile.z) | ||||
| 					continue; | ||||
| 				if (!(*visibilityMap)[pos.x][pos.y][top_tile.z]) | ||||
| 					continue; | ||||
| 				if (!obj->visitableAt(pos.x, pos.y)) | ||||
| 					continue; | ||||
|  | ||||
| 				auto &ownerRaw = obj->tempOwner; | ||||
| 				int ownerIndex = 0; | ||||
| 				if (ownerRaw < PlayerColor::PLAYER_LIMIT) | ||||
| 				{ | ||||
| 					ownerIndex = ownerRaw.getNum() * 19; | ||||
| 				} | ||||
| 				else if (ownerRaw == PlayerColor::NEUTRAL) | ||||
| 				{ | ||||
| 					ownerIndex = PlayerColor::PLAYER_LIMIT.getNum() * 19; | ||||
| 				} | ||||
|  | ||||
| 				SDL_Surface * wvIcon = nullptr; | ||||
| 				switch (obj->ID) | ||||
| 				{ | ||||
| 				default: | ||||
| 					continue; | ||||
| 				case Obj::MONOLITH_ONE_WAY_ENTRANCE: | ||||
| 				case Obj::MONOLITH_ONE_WAY_EXIT: | ||||
| 				case Obj::MONOLITH_TWO_WAY: | ||||
| 					wvIcon = iconsDef->ourImages[(int)EWorldViewIcon::TELEPORT].bitmap; | ||||
| 					break; | ||||
| 				case Obj::SUBTERRANEAN_GATE: | ||||
| 					wvIcon = iconsDef->ourImages[(int)EWorldViewIcon::GATE].bitmap; | ||||
| 					break; | ||||
| 				case Obj::ARTIFACT: | ||||
| 					wvIcon = iconsDef->ourImages[(int)EWorldViewIcon::ARTIFACT].bitmap; | ||||
| 					break; | ||||
| 				case Obj::TOWN: | ||||
| 					wvIcon = iconsDef->ourImages[(int)EWorldViewIcon::TOWN + ownerIndex].bitmap; | ||||
| 					break; | ||||
| 				case Obj::HERO: | ||||
| 					wvIcon = iconsDef->ourImages[(int)EWorldViewIcon::HERO + ownerIndex].bitmap; | ||||
| 					break; | ||||
| 				case Obj::MINE: | ||||
| 					wvIcon = iconsDef->ourImages[(int)EWorldViewIcon::MINE_WOOD + obj->subID + ownerIndex].bitmap; | ||||
| 					break; | ||||
| 				case Obj::RESOURCE: | ||||
| 					wvIcon = iconsDef->ourImages[(int)EWorldViewIcon::RES_WOOD + obj->subID + ownerIndex].bitmap; | ||||
| 					break; | ||||
| 				} | ||||
|  | ||||
| 				if (wvIcon) | ||||
| 				{ | ||||
| 					Rect tempDst; | ||||
| 					tempDst.x = srx + targetTileSize / 2 - wvIcon->w / 2; | ||||
| 					tempDst.y = sry + targetTileSize / 2 - wvIcon->h / 2; | ||||
| 					tempDst.w = wvIcon->w; | ||||
| 					tempDst.h = wvIcon->h; | ||||
| 					CSDL_Ext::blitSurface(wvIcon, nullptr, extSurf, &tempDst); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void CMapHandler::calculateWorldViewCameraPos(int targetTilesX, int targetTilesY, int3 &top_tile) | ||||
| { | ||||
| 	bool outsideLeft = top_tile.x < 0; | ||||
| 	bool outsideTop = top_tile.y < 0; | ||||
| 	bool outsideRight = std::max(0, top_tile.x) + targetTilesX > sizes.x; | ||||
| 	bool outsideBottom = std::max(0, top_tile.y) + targetTilesY > sizes.y; | ||||
|  | ||||
| 	if (targetTilesX > sizes.x) | ||||
| 		top_tile.x = sizes.x / 2 - targetTilesX / 2; // center viewport if the whole map can fit into the screen at once | ||||
| 	else if (outsideLeft) | ||||
| 	{ | ||||
| 		if (outsideRight) | ||||
| 		{ | ||||
| 			top_tile.x = sizes.x / 2 - targetTilesX / 2; | ||||
| 		} | ||||
| 		else | ||||
| 			top_tile.x = 0; | ||||
| 	} | ||||
| 	else if (outsideRight) | ||||
| 		top_tile.x = sizes.x - targetTilesX; | ||||
|  | ||||
| 	if (targetTilesY > sizes.y) | ||||
| 		top_tile.y = sizes.y / 2 - targetTilesY / 2; | ||||
| 	else if (outsideTop) | ||||
| 	{ | ||||
| 		if (outsideBottom) | ||||
| 		{ | ||||
| 			top_tile.y = sizes.y / 2 - targetTilesY / 2; | ||||
| 		} | ||||
| 		else | ||||
| 			top_tile.y = 0; | ||||
| 	} | ||||
| 	else if (outsideBottom) | ||||
| 		top_tile.y = sizes.y - targetTilesY; | ||||
| } | ||||
|  | ||||
| // updates map terrain when adventure map is in world view mode; | ||||
| // this method was copied from terrainRect(), so some parts are the same -- that probably should be refactored slightly | ||||
| void CMapHandler::terrainRectScaled(int3 topTile, const std::vector< std::vector< std::vector<ui8> > > * visibilityMap, SDL_Surface * extSurf, const SDL_Rect * extRect, float scale, CDefHandler * iconsDef) | ||||
| { | ||||
| 	cache.updateWorldViewScale(scale); | ||||
|  | ||||
| 	int targetTileSize = (int) floorf(32.0f * scale); | ||||
| 	int targetTilesX = (int) ceilf(tilesW / scale) + 1; | ||||
| 	int targetTilesY = (int) ceilf(tilesH / scale) + 1; | ||||
|  | ||||
| 	SDL_Rect rtile = { 0, 0, targetTileSize, targetTileSize }; | ||||
|  | ||||
| 	// Absolute coords of the first pixel in the top left corner | ||||
| 	int srx_init = offsetX + extRect->x; | ||||
| 	int sry_init = offsetY + extRect->y; | ||||
| 	int srx, sry;	// absolute screen coordinates in pixels | ||||
|  | ||||
| 	calculateWorldViewCameraPos(targetTilesX, targetTilesY, topTile); | ||||
|  | ||||
| 	SDL_FillRect(extSurf, extRect, SDL_MapRGB(extSurf->format, 0, 0, 0)); | ||||
|  | ||||
| 	// makes the clip area smaller if the map is smaller than the screen frame | ||||
| 	Rect clipRect(std::max(extRect->x, -topTile.x * targetTileSize), | ||||
| 				  std::max(extRect->y, -topTile.y * targetTileSize), | ||||
| 				  std::min(extRect->w, sizes.x * targetTileSize), | ||||
| 				  std::min(extRect->h, sizes.y * targetTileSize)); | ||||
| 	SDL_Rect prevClip; | ||||
| 	SDL_GetClipRect(extSurf, &prevClip); | ||||
| 	SDL_SetClipRect(extSurf, &clipRect); //preventing blitting outside of that rect | ||||
|  | ||||
| 	const BlitterWithRotationVal blitterWithRotation = CSDL_Ext::getBlitterWithRotation(extSurf); | ||||
| 	const BlitterWithRotationVal blitterWithRotationAndAlpha = CSDL_Ext::getBlitterWithRotationAndAlpha(extSurf); | ||||
|  | ||||
| 	// printing terrain | ||||
| 	srx = srx_init; | ||||
|  | ||||
| 	for (int bx = topTile.x; bx < topTile.x + targetTilesX; bx++, srx+=targetTileSize) | ||||
| 	{ | ||||
| 		// Skip column if not in map | ||||
| 		if (bx < 0 || bx >= sizes.x) | ||||
| 		{ | ||||
| 			continue; | ||||
| 		} | ||||
|  | ||||
| 		sry = sry_init; | ||||
|  | ||||
| 		for (int by = topTile.y; by < topTile.y + targetTilesY; by++, sry+=targetTileSize) | ||||
| 		{ | ||||
| 			int3 pos(bx, by, topTile.z); //blitted tile position | ||||
|  | ||||
| 			// Skip tile if not in map | ||||
| 			if (by < 0 || by >= sizes.y) | ||||
| 			{ | ||||
| 				continue; | ||||
| 			} | ||||
|  | ||||
| 			const NeighborTilesInfo info(pos,sizes,*visibilityMap); | ||||
|  | ||||
| 			if(info.areAllHidden()) | ||||
| 				continue; | ||||
|  | ||||
| 			const TerrainTile2 & tile = ttiles[pos.x][pos.y][pos.z]; | ||||
| 			const TerrainTile &tinfo = map->getTile(int3(pos.x, pos.y, pos.z)); | ||||
|  | ||||
| 			SDL_Rect sr; | ||||
| 			sr.x=srx; | ||||
| 			sr.y=sry; | ||||
| 			sr.h=sr.w=targetTileSize; | ||||
|  | ||||
| 			//blit terrain with river/road | ||||
| 			if(tile.terbitmap) | ||||
| 			{ //if custom terrain graphic - use it | ||||
| 				auto scaledSurf = cache.requestWorldViewCacheOrCreate(EMapCacheType::TERRAIN_CUSTOM, (int)tile.terbitmap, tile.terbitmap, scale); | ||||
| //				Rect tempSrc = Rect(0, 0, scaledSurf->w, scaledSurf->h); | ||||
| 				Rect tempDst = Rect(sr.x, sr.y, scaledSurf->w, scaledSurf->h); | ||||
| 				CSDL_Ext::blitSurface(scaledSurf, nullptr, extSurf, &tempDst); | ||||
| 			} | ||||
| 			else //use default terrain graphic | ||||
| 			{ | ||||
| 				auto baseSurf = terrainGraphics[tinfo.terType][tinfo.terView]; | ||||
| 				auto scaledSurf = cache.requestWorldViewCacheOrCreate(EMapCacheType::TERRAIN, (int)baseSurf, baseSurf, scale); | ||||
| 				Rect tempSrc = Rect(0, 0, scaledSurf->w, scaledSurf->h); | ||||
| 				Rect tempDst = Rect(sr.x, sr.y, scaledSurf->w, scaledSurf->h); | ||||
| 				blitterWithRotation(scaledSurf, tempSrc, extSurf, tempDst, tinfo.extTileFlags%4); | ||||
| 			} | ||||
|  | ||||
| 			if(tinfo.riverType) //print river if present | ||||
| 			{ | ||||
| 				auto baseSurf = staticRiverDefs[tinfo.riverType-1]->ourImages[tinfo.riverDir].bitmap; | ||||
| 				auto scaledSurf = cache.requestWorldViewCacheOrCreate(EMapCacheType::RIVERS, (int)baseSurf, baseSurf, scale); | ||||
| 				blitterWithRotationAndAlpha(scaledSurf, rtile, extSurf, sr, (tinfo.extTileFlags>>2)%4); | ||||
| 			} | ||||
|  | ||||
| 			//Roads are shifted by 16 pixels to bottom. We have to draw both parts separately | ||||
| 			if (pos.y > 0 && map->getTile(int3(pos.x, pos.y-1, pos.z)).roadType != ERoadType::NO_ROAD) | ||||
| 			{ //part from top tile | ||||
| 				const TerrainTile &topTile = map->getTile(int3(pos.x, pos.y-1, pos.z)); | ||||
| 				Rect source(0, targetTileSize / 2, targetTileSize, targetTileSize / 2); | ||||
| 				Rect dest(sr.x, sr.y, sr.w, sr.h/2); | ||||
| 				auto baseSurf = roadDefs[topTile.roadType - 1]->ourImages[topTile.roadDir].bitmap; | ||||
| 				auto scaledSurf = cache.requestWorldViewCacheOrCreate(EMapCacheType::ROADS, (int)baseSurf, baseSurf, scale); | ||||
| 				blitterWithRotationAndAlpha(scaledSurf, source, extSurf, dest, (topTile.extTileFlags>>4)%4); | ||||
| 			} | ||||
|  | ||||
| 			if(tinfo.roadType != ERoadType::NO_ROAD) //print road from this tile | ||||
| 			{ | ||||
| 				Rect source(0, 0, targetTileSize, targetTileSize); | ||||
| 				Rect dest(sr.x, sr.y + targetTileSize / 2, sr.w, sr.h / 2); | ||||
| 				auto baseSurf = roadDefs[tinfo.roadType-1]->ourImages[tinfo.roadDir].bitmap; | ||||
| 				auto scaledSurf = cache.requestWorldViewCacheOrCreate(EMapCacheType::ROADS, (int)baseSurf, baseSurf, scale); | ||||
| 				blitterWithRotationAndAlpha(scaledSurf, source, extSurf, dest, (tinfo.extTileFlags>>4)%4); | ||||
| 			} | ||||
|  | ||||
| 			//blit objects | ||||
| 			const std::vector < std::pair<const CGObjectInstance*,SDL_Rect> > &objects = tile.objects; | ||||
| 			for(auto & object : objects) | ||||
| 			{ | ||||
| 				const CGObjectInstance *obj = object.first; | ||||
| 				if (!graphics->getDef(obj)) | ||||
| 					processDef(obj->appearance); | ||||
| 				if (!graphics->getDef(obj) && !obj->appearance.animationFile.empty()) | ||||
| 				{ | ||||
| 					logGlobal->errorStream() << "Failed to load image " << obj->appearance.animationFile; | ||||
| 				} | ||||
|  | ||||
| 				PlayerColor color = obj->tempOwner; | ||||
|  | ||||
| 				//checking if object has non-empty graphic on this tile | ||||
| 				if(obj->ID != Obj::HERO && !obj->coveringAt(bx, by)) | ||||
| 					continue; | ||||
|  | ||||
| 				SDL_Rect sr2(sr); | ||||
|  | ||||
| 				SDL_Rect pp = object.second; | ||||
| 				pp.h = sr.h; | ||||
| 				pp.w = sr.w; | ||||
|  | ||||
| 				const CGHeroInstance * themp = (obj->ID != Obj::HERO | ||||
| 					? nullptr | ||||
| 					: static_cast<const CGHeroInstance*>(obj)); | ||||
|  | ||||
| 				//print hero / boat and flag | ||||
| 				if((themp && themp->moveDir && themp->type) || (obj->ID == Obj::BOAT)) //it's hero or boat | ||||
| 				{ | ||||
| 					const int IMGVAL = 8; //frames per group of movement animation | ||||
| 					ui8 dir; | ||||
| 					std::vector<Cimage> * iv = nullptr; | ||||
| 					std::vector<CDefEssential *> Graphics::*flg = nullptr; | ||||
| 					SDL_Surface * tb = nullptr; //surface to blitted | ||||
|  | ||||
| 					if(themp) //hero | ||||
| 					{ | ||||
| 						if(themp->tempOwner >= PlayerColor::PLAYER_LIMIT) //Neutral hero? | ||||
| 						{ | ||||
| 							logGlobal->errorStream() << "A neutral hero (" << themp->name << ") at " << themp->pos << ". Should not happen!"; | ||||
| 							continue; | ||||
| 						} | ||||
|  | ||||
| 						dir = themp->moveDir; | ||||
|  | ||||
| 						//pick graphics of hero (or boat if hero is sailing) | ||||
| 						if (themp->boat) | ||||
| 							iv = &graphics->boatAnims[themp->boat->subID]->ourImages; | ||||
| 						else | ||||
| 							iv = &graphics->heroAnims[themp->appearance.animationFile]->ourImages; | ||||
|  | ||||
| 						//pick appropriate flag set | ||||
| 						if(themp->boat) | ||||
| 						{ | ||||
| 							switch (themp->boat->subID) | ||||
| 							{ | ||||
| 								case 0: flg = &Graphics::flags1; break; | ||||
| 								case 1: flg = &Graphics::flags2; break; | ||||
| 								case 2: flg = &Graphics::flags3; break; | ||||
| 								default: logGlobal->errorStream() << "Not supported boat subtype: " << themp->boat->subID; | ||||
| 							} | ||||
| 						} | ||||
| 						else | ||||
| 						{ | ||||
| 							flg = &Graphics::flags4; | ||||
| 						} | ||||
| 					} | ||||
| 					else //boat | ||||
| 					{ | ||||
| 						const CGBoat *boat = static_cast<const CGBoat*>(obj); | ||||
| 						dir = boat->direction; | ||||
| 						iv = &graphics->boatAnims[boat->subID]->ourImages; | ||||
| 					} | ||||
|  | ||||
| 					if(themp && !themp->isStanding) //hero is moving | ||||
| 					{ | ||||
| 						size_t gg; | ||||
| 						for(gg=0; gg<iv->size(); ++gg) | ||||
| 						{ | ||||
| 							if((*iv)[gg].groupNumber==getHeroFrameNum(dir, true)) | ||||
| 							{ | ||||
| 								tb = (*iv)[gg].bitmap; | ||||
| 								break; | ||||
| 							} | ||||
| 						} | ||||
| 						CSDL_Ext::blit8bppAlphaTo24bpp(tb,&pp,extSurf,&sr2); | ||||
|  | ||||
| 						//printing flag | ||||
| 						pp.y+=IMGVAL*2-32; | ||||
| 						sr2.y-=16; | ||||
| 						CSDL_Ext::blitSurface((graphics->*flg)[color.getNum()]->ourImages[gg+35].bitmap, &pp, extSurf, &sr2); | ||||
| 					} | ||||
| 					else //hero / boat stands still | ||||
| 					{ | ||||
| 						size_t gg; | ||||
| 						for(gg=0; gg < iv->size(); ++gg) | ||||
| 						{ | ||||
| 							if((*iv)[gg].groupNumber==getHeroFrameNum(dir, false)) | ||||
| 							{ | ||||
| 								tb = (*iv)[gg].bitmap; | ||||
| 								break; | ||||
| 							} | ||||
| 						} | ||||
| 						CSDL_Ext::blit8bppAlphaTo24bpp(tb,&pp,extSurf,&sr2); | ||||
|  | ||||
| 						//printing flag | ||||
| 						if(flg | ||||
| 							&&  obj->pos.x == pos.x | ||||
| 							&&  obj->pos.y == pos.y) | ||||
| 						{ | ||||
| 							SDL_Rect bufr = sr2; | ||||
| 							bufr.x-=2*32; | ||||
| 							bufr.y-=1*32; | ||||
| 							bufr.h = 64; | ||||
| 							bufr.w = 96; | ||||
| 							if(bufr.x-extRect->x>-64) | ||||
| 								CSDL_Ext::blitSurface((graphics->*flg)[color.getNum()]->ourImages[getHeroFrameNum(dir, false) * 8].bitmap, nullptr, extSurf, &bufr); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				else //blit normal object | ||||
| 				{ | ||||
| 					const std::vector<Cimage> &ourImages = graphics->getDef(obj)->ourImages; | ||||
| 					SDL_Surface *bitmap = ourImages[0].bitmap; | ||||
|  | ||||
| 					//setting appropriate flag color | ||||
| 					if(color < PlayerColor::PLAYER_LIMIT || color==PlayerColor::NEUTRAL) | ||||
| 						CSDL_Ext::setPlayerColor(bitmap, color); | ||||
|  | ||||
| 					auto scaledSurf = cache.requestWorldViewCacheOrCreate(EMapCacheType::OBJECTS, obj->id.getNum(), bitmap, scale); | ||||
| 					Rect tempSrc = Rect(pp.x * scale, pp.y * scale, pp.w, pp.h); | ||||
| 					Rect tempDst = Rect(sr2.x, sr2.y, pp.w, pp.h); | ||||
| 					CSDL_Ext::blit8bppAlphaTo24bpp(scaledSurf,&tempSrc,extSurf,&tempDst); | ||||
| 				} | ||||
| 			} | ||||
| 			//objects blitted | ||||
| 		} | ||||
| 	} | ||||
| 	// terrain printed | ||||
|  | ||||
| 	// blitting world view overlay | ||||
| 	drawWorldViewOverlay(targetTilesX, targetTilesY, srx_init, sry_init, iconsDef, visibilityMap, scale, targetTileSize, topTile, extSurf); | ||||
| 	// world view overlay blitted | ||||
|  | ||||
|  | ||||
| 	// printing borders | ||||
| 	srx = srx_init; | ||||
|  | ||||
| 	for (int bx = topTile.x; bx < topTile.x + targetTilesX; bx++, srx+=targetTileSize) | ||||
| 	{ | ||||
| 		sry = sry_init; | ||||
|  | ||||
| 		for (int by = topTile.y; by < topTile.y + targetTilesY; by++, sry+=targetTileSize) | ||||
| 		{ | ||||
| 			int3 pos(bx, by, topTile.z); //blitted tile position | ||||
|  | ||||
| 			SDL_Rect sr; | ||||
| 			sr.x=srx; | ||||
| 			sr.y=sry; | ||||
| 			sr.h=sr.w=targetTileSize; | ||||
|  | ||||
| 			if (pos.x < 0 || pos.x >= sizes.x || | ||||
| 				pos.y < 0 || pos.y >= sizes.y) | ||||
| 			{ | ||||
| 				// no borders in world view | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				//blitting Fog of War | ||||
| 				if (pos.x >= 0 && | ||||
| 					pos.y >= 0 && | ||||
| 					pos.x < sizes.x && | ||||
| 					pos.y < sizes.y && | ||||
| 					!(*visibilityMap)[pos.x][pos.y][topTile.z]) | ||||
| 				{ | ||||
| 					std::pair<SDL_Surface *, bool> hide = getVisBitmap(pos, *visibilityMap); | ||||
| 					auto scaledSurf = cache.requestWorldViewCacheOrCreate(EMapCacheType::FOW, (int)hide.first, hide.first, scale); | ||||
| 					if(hide.second) | ||||
| 						CSDL_Ext::blit8bppAlphaTo24bpp(scaledSurf, &rtile, extSurf, &sr); | ||||
| 					else | ||||
| 						CSDL_Ext::blitSurface(scaledSurf, &rtile, extSurf, &sr); | ||||
| 				} | ||||
| 				//FoW blitted | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	// borders printed | ||||
|  | ||||
| 	SDL_SetClipRect(extSurf, &prevClip); //restoring clip_rect | ||||
| } | ||||
| // Update map window screen | ||||
| // top_tile top left tile to draw. Not necessarily visible. | ||||
| // extRect, extRect = map window on screen | ||||
| @@ -433,11 +866,11 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std:: | ||||
| 	int srx, sry;	// absolute screen coordinates in pixels | ||||
|  | ||||
| 	// If moving, we need to add an extra column/line | ||||
| 	if (moveX != 0)  | ||||
| 	if (moveX != 0) | ||||
| 	{ | ||||
| 		dx++; | ||||
| 		srx_init += moveX; | ||||
| 		if (moveX > 0)  | ||||
| 		if (moveX > 0) | ||||
| 		{ | ||||
| 			// Moving right. We still need to draw the old tile on the | ||||
| 			// left, so adjust our referential | ||||
| @@ -446,11 +879,11 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std:: | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if (moveY != 0)  | ||||
| 	if (moveY != 0) | ||||
| 	{ | ||||
| 		dy++; | ||||
| 		sry_init += moveY; | ||||
| 		if (moveY > 0)  | ||||
| 		if (moveY > 0) | ||||
| 		{ | ||||
| 			// Moving down. We still need to draw the tile on the top, | ||||
| 			// so adjust our referential. | ||||
| @@ -468,7 +901,7 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std:: | ||||
| 		dx = sizes.x + frameW - top_tile.x; | ||||
| 	if (top_tile.y + dy > sizes.y + frameH) | ||||
| 		dy = sizes.y + frameH - top_tile.y; | ||||
| 	 | ||||
|  | ||||
| 	if(!otherHeroAnim) | ||||
| 		heroAnim = anim; //the same, as it should be | ||||
|  | ||||
| @@ -498,15 +931,15 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std:: | ||||
| 			// Skip tile if not in map | ||||
| 			if (pos.y < 0 || pos.y >= sizes.y) | ||||
| 				continue; | ||||
| 			 | ||||
|  | ||||
| 			//we should not render fully hidden tiles | ||||
| 			if(!puzzleMode) | ||||
| 			{ | ||||
| 				const NeighborTilesInfo info(pos,sizes,*visibilityMap); | ||||
| 				 | ||||
|  | ||||
| 				if(info.areAllHidden()) | ||||
| 					continue; | ||||
| 			}			 | ||||
| 			} | ||||
|  | ||||
| 			const TerrainTile2 & tile = ttiles[pos.x][pos.y][pos.z]; | ||||
| 			const TerrainTile &tinfo = map->getTile(int3(pos.x, pos.y, pos.z)); | ||||
| @@ -524,11 +957,11 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std:: | ||||
| 			} | ||||
| 			else //use default terrain graphic | ||||
| 			{ | ||||
|                 blitterWithRotation(terrainGraphics[tinfo.terType][tinfo.terView],rtile, extSurf, sr, tinfo.extTileFlags%4); | ||||
| 				blitterWithRotation(terrainGraphics[tinfo.terType][tinfo.terView],rtile, extSurf, sr, tinfo.extTileFlags%4); | ||||
| 			} | ||||
|             if(tinfo.riverType) //print river if present | ||||
| 			if(tinfo.riverType) //print river if present | ||||
| 			{ | ||||
|                 blitterWithRotationAndAlpha(staticRiverDefs[tinfo.riverType-1]->ourImages[tinfo.riverDir].bitmap,rtile, extSurf, sr, (tinfo.extTileFlags>>2)%4); | ||||
| 				blitterWithRotationAndAlpha(staticRiverDefs[tinfo.riverType-1]->ourImages[tinfo.riverDir].bitmap,rtile, extSurf, sr, (tinfo.extTileFlags>>2)%4); | ||||
| 			} | ||||
|  | ||||
| 			//Roads are shifted by 16 pixels to bottom. We have to draw both parts separately | ||||
| @@ -537,14 +970,14 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std:: | ||||
| 				const TerrainTile &topTile = map->getTile(int3(pos.x, pos.y-1, pos.z)); | ||||
| 				Rect source(0, 16, 32, 16); | ||||
| 				Rect dest(sr.x, sr.y, sr.w, sr.h/2); | ||||
|                 blitterWithRotationAndAlpha(roadDefs[topTile.roadType - 1]->ourImages[topTile.roadDir].bitmap, source, extSurf, dest, (topTile.extTileFlags>>4)%4); | ||||
| 				blitterWithRotationAndAlpha(roadDefs[topTile.roadType - 1]->ourImages[topTile.roadDir].bitmap, source, extSurf, dest, (topTile.extTileFlags>>4)%4); | ||||
| 			} | ||||
|  | ||||
|             if(tinfo.roadType != ERoadType::NO_ROAD) //print road from this tile | ||||
| 			if(tinfo.roadType != ERoadType::NO_ROAD) //print road from this tile | ||||
| 			{ | ||||
| 				Rect source(0, 0, 32, 32); | ||||
| 				Rect dest(sr.x, sr.y+16, sr.w, sr.h/2); | ||||
|                 blitterWithRotationAndAlpha(roadDefs[tinfo.roadType-1]->ourImages[tinfo.roadDir].bitmap, source, extSurf, dest, (tinfo.extTileFlags>>4)%4); | ||||
| 				blitterWithRotationAndAlpha(roadDefs[tinfo.roadType-1]->ourImages[tinfo.roadDir].bitmap, source, extSurf, dest, (tinfo.extTileFlags>>4)%4); | ||||
| 			} | ||||
|  | ||||
| 			//blit objects | ||||
| @@ -571,14 +1004,14 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std:: | ||||
| 				if(puzzleMode && (obj->isVisitable() || std::find(notBlittedInPuzzleMode, notBlittedInPuzzleMode+1, obj->ID) != notBlittedInPuzzleMode+1)) //? | ||||
| 					continue; | ||||
|  | ||||
|  				SDL_Rect sr2(sr);  | ||||
| 				SDL_Rect sr2(sr); | ||||
|  | ||||
| 				SDL_Rect pp = object.second; | ||||
| 				pp.h = sr.h; | ||||
| 				pp.w = sr.w; | ||||
|  | ||||
| 				const CGHeroInstance * themp = (obj->ID != Obj::HERO | ||||
| 					? nullptr   | ||||
| 					? nullptr | ||||
| 					: static_cast<const CGHeroInstance*>(obj)); | ||||
|  | ||||
| 				//print hero / boat and flag | ||||
| @@ -594,7 +1027,7 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std:: | ||||
| 					{ | ||||
| 						if(themp->tempOwner >= PlayerColor::PLAYER_LIMIT) //Neutral hero? | ||||
| 						{ | ||||
|                             logGlobal->errorStream() << "A neutral hero (" << themp->name << ") at " << themp->pos << ". Should not happen!"; | ||||
| 							logGlobal->errorStream() << "A neutral hero (" << themp->name << ") at " << themp->pos << ". Should not happen!"; | ||||
| 							continue; | ||||
| 						} | ||||
|  | ||||
| @@ -614,7 +1047,7 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std:: | ||||
| 							case 0: flg = &Graphics::flags1; break; | ||||
| 							case 1: flg = &Graphics::flags2; break; | ||||
| 							case 2: flg = &Graphics::flags3; break; | ||||
|                             default: logGlobal->errorStream() << "Not supported boat subtype: " << themp->boat->subID; | ||||
| 							default: logGlobal->errorStream() << "Not supported boat subtype: " << themp->boat->subID; | ||||
| 							} | ||||
| 						} | ||||
| 						else | ||||
| @@ -662,8 +1095,8 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std:: | ||||
| 						CSDL_Ext::blit8bppAlphaTo24bpp(tb,&pp,extSurf,&sr2); | ||||
|  | ||||
| 						//printing flag | ||||
| 						if(flg   | ||||
| 							&&  obj->pos.x == top_tile.x + bx   | ||||
| 						if(flg | ||||
| 							&&  obj->pos.x == top_tile.x + bx | ||||
| 							&&  obj->pos.y == top_tile.y + by) | ||||
| 						{ | ||||
| 							SDL_Rect bufr = sr2; | ||||
| @@ -729,7 +1162,7 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std:: | ||||
|  | ||||
| 				CSDL_Ext::blitSurface(src, &temp_rect,extSurf,&sr); | ||||
| 			} | ||||
| 			else  | ||||
| 			else | ||||
| 			{ | ||||
| 				//blitting Fog of War | ||||
| 				if (!puzzleMode) | ||||
| @@ -747,7 +1180,7 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std:: | ||||
| 							CSDL_Ext::blitSurface(hide.first, &rtile, extSurf, &sr); | ||||
| 					} | ||||
| 				} | ||||
| 				 | ||||
|  | ||||
| 				//FoW blitted | ||||
|  | ||||
| 				SDL_Rect tileRect = genRect(sr.h, sr.w, 0, 0); | ||||
| @@ -846,7 +1279,7 @@ std::pair<SDL_Surface *, bool> CMapHandler::getVisBitmap( const int3 & pos, cons | ||||
| 	{ | ||||
| 		retBitmapID = - hideBitmap[pos.x][pos.y][pos.z] - 1; //fully hidden | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	if (retBitmapID >= 0) | ||||
| 	{ | ||||
| 		return std::make_pair(graphics->FoWpartialHide->ourImages[retBitmapID].bitmap, true); | ||||
| @@ -859,10 +1292,10 @@ std::pair<SDL_Surface *, bool> CMapHandler::getVisBitmap( const int3 & pos, cons | ||||
|  | ||||
| bool CMapHandler::printObject(const CGObjectInstance *obj) | ||||
| { | ||||
|     if (!graphics->getDef(obj)) | ||||
| 	if (!graphics->getDef(obj)) | ||||
| 		processDef(obj->appearance); | ||||
|  | ||||
| 	const SDL_Surface *bitmap = graphics->getDef(obj)->ourImages[0].bitmap;  | ||||
| 	const SDL_Surface *bitmap = graphics->getDef(obj)->ourImages[0].bitmap; | ||||
| 	const int tilesW = bitmap->w/32; | ||||
| 	const int tilesH = bitmap->h/32; | ||||
|  | ||||
| @@ -1029,27 +1462,27 @@ void CMapHandler::updateWater() //shift colors in palettes of water tiles | ||||
| { | ||||
| 	for(auto & elem : terrainGraphics[7]) | ||||
| 	{ | ||||
| 		shiftColors(elem,246, 9);  | ||||
| 		shiftColors(elem,246, 9); | ||||
| 	} | ||||
| 	for(auto & elem : terrainGraphics[8]) | ||||
| 	{ | ||||
| 		shiftColors(elem,229, 12);  | ||||
| 		shiftColors(elem,242, 14);  | ||||
| 		shiftColors(elem,229, 12); | ||||
| 		shiftColors(elem,242, 14); | ||||
| 	} | ||||
| 	for(auto & elem : staticRiverDefs[0]->ourImages) | ||||
| 	{ | ||||
| 		shiftColors(elem.bitmap,183, 12);  | ||||
| 		shiftColors(elem.bitmap,195, 6);  | ||||
| 		shiftColors(elem.bitmap,183, 12); | ||||
| 		shiftColors(elem.bitmap,195, 6); | ||||
| 	} | ||||
| 	for(auto & elem : staticRiverDefs[2]->ourImages) | ||||
| 	{ | ||||
| 		shiftColors(elem.bitmap,228, 12);  | ||||
| 		shiftColors(elem.bitmap,183, 6);  | ||||
| 		shiftColors(elem.bitmap,240, 6);  | ||||
| 		shiftColors(elem.bitmap,228, 12); | ||||
| 		shiftColors(elem.bitmap,183, 6); | ||||
| 		shiftColors(elem.bitmap,240, 6); | ||||
| 	} | ||||
| 	for(auto & elem : staticRiverDefs[3]->ourImages) | ||||
| 	{ | ||||
| 		shiftColors(elem.bitmap,240, 9);  | ||||
| 		shiftColors(elem.bitmap,240, 9); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -1096,7 +1529,7 @@ void CMapHandler::getTerrainDescr( const int3 &pos, std::string & out, bool terN | ||||
| 	if(t.hasFavourableWinds()) | ||||
| 		out = CGI->objtypeh->getObjectName(Obj::FAVORABLE_WINDS); | ||||
| 	else if(terName) | ||||
|         out = CGI->generaltexth->terrainNames[t.terType]; | ||||
| 		out = CGI->generaltexth->terrainNames[t.terType]; | ||||
| } | ||||
|  | ||||
| ui8 CMapHandler::getPhaseShift(const CGObjectInstance *object) const | ||||
| @@ -1112,6 +1545,76 @@ ui8 CMapHandler::getPhaseShift(const CGObjectInstance *object) const | ||||
| 	return i->second; | ||||
| } | ||||
|  | ||||
| void CMapHandler::discardWorldViewCache() | ||||
| { | ||||
| 	cache.discardWorldViewCache(); | ||||
| } | ||||
|  | ||||
| void CMapHandler::CMapCache::discardWorldViewCache() | ||||
| { | ||||
| 	for (auto &cacheDataPair : data) | ||||
| 	{ | ||||
| 		for (auto &cacheEntryPair : cacheDataPair.second) | ||||
| 		{ | ||||
| 			if (cacheEntryPair.second) | ||||
| 			{ | ||||
| 				SDL_FreeSurface(cacheEntryPair.second); | ||||
| 			} | ||||
| 		} | ||||
| 		data[cacheDataPair.first].clear(); | ||||
| 	} | ||||
| 	logGlobal->debugStream() << "Discarded world view cache"; | ||||
| } | ||||
|  | ||||
| void CMapHandler::CMapCache::updateWorldViewScale(float scale) | ||||
| { | ||||
| 	if (fabs(scale - worldViewCachedScale) > 0.001f) | ||||
| 		discardWorldViewCache(); | ||||
| 	worldViewCachedScale = scale; | ||||
| } | ||||
|  | ||||
| void CMapHandler::CMapCache::removeFromWorldViewCache(CMapHandler::EMapCacheType type, int key) | ||||
| { | ||||
| 	auto iter = data[type].find(key); | ||||
| 	if (iter != data[type].end()) | ||||
| 	{ | ||||
| 		SDL_FreeSurface((*iter).second); | ||||
| 		data[type].erase(iter); | ||||
| //		logGlobal->errorStream() << "Removed world view cache entry: type=" << (int)type << ", key=" << key; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| SDL_Surface * CMapHandler::CMapCache::requestWorldViewCache(CMapHandler::EMapCacheType type, int key) | ||||
| { | ||||
| 	auto iter = data[type].find(key); | ||||
| 	if (iter == data[type].end()) | ||||
| 		return nullptr; | ||||
| //	logGlobal->errorStream() << "Returning requested world view cache entry: type=" << (int)type << ", key=" << key << ", ptr=" << (*iter).second; | ||||
| 	return (*iter).second; | ||||
| } | ||||
|  | ||||
| SDL_Surface * CMapHandler::CMapCache::requestWorldViewCacheOrCreate(CMapHandler::EMapCacheType type, int key, SDL_Surface * fullSurface, float scale) | ||||
| { | ||||
| 	auto cached = requestWorldViewCache(type, key); | ||||
| 	if (cached) | ||||
| 		return cached; | ||||
|  | ||||
| 	auto scaled = CSDL_Ext::scaleSurfaceFast(fullSurface, fullSurface->w * scale, fullSurface->h * scale); | ||||
| 	return cacheWorldViewEntry(type, key, scaled); | ||||
| } | ||||
|  | ||||
| SDL_Surface *CMapHandler::CMapCache::cacheWorldViewEntry(CMapHandler::EMapCacheType type, int key, SDL_Surface * entry) | ||||
| { | ||||
| 	if (!entry) | ||||
| 		return nullptr; | ||||
| 	if (requestWorldViewCache(type, key)) // valid cache already present, no need to do it again | ||||
| 		return requestWorldViewCache(type, key); | ||||
|  | ||||
| //	logGlobal->errorStream() << "Added world view cache entry: type=" << (int)type << ", key=" << key << ", ptr=" << entry; | ||||
| 	data[type][key] = entry; | ||||
| 	return entry; | ||||
| } | ||||
|  | ||||
| TerrainTile2::TerrainTile2() | ||||
|  :terbitmap(nullptr) | ||||
| {} | ||||
|   | ||||
| @@ -25,6 +25,30 @@ struct SDL_Surface; | ||||
| //struct SDL_Rect; | ||||
| class CDefEssential; | ||||
|  | ||||
| enum class EWorldViewIcon | ||||
| { | ||||
| 	TOWN = 0, | ||||
| 	HERO, | ||||
| 	ARTIFACT, | ||||
| 	TELEPORT, | ||||
| 	GATE, | ||||
| 	MINE_WOOD, | ||||
| 	MINE_MERCURY, | ||||
| 	MINE_STONE, | ||||
| 	MINE_SULFUR, | ||||
| 	MINE_CRYSTAL, | ||||
| 	MINE_GEM, | ||||
| 	MINE_GOLD, | ||||
| 	RES_WOOD, | ||||
| 	RES_MERCURY, | ||||
| 	RES_STONE, | ||||
| 	RES_SULFUR, | ||||
| 	RES_CRYSTAL, | ||||
| 	RES_GEM, | ||||
| 	RES_GOLD, | ||||
|  | ||||
| }; | ||||
|  | ||||
| struct TerrainTile2 | ||||
| { | ||||
| 	SDL_Surface * terbitmap; //bitmap of terrain | ||||
| @@ -72,6 +96,33 @@ private: | ||||
|  | ||||
| class CMapHandler | ||||
| { | ||||
| 	enum class EMapCacheType | ||||
| 	{ | ||||
| 		TERRAIN, TERRAIN_CUSTOM, OBJECTS, ROADS, RIVERS, FOW | ||||
| 	}; | ||||
|  | ||||
| 	/// temporarily caches rescaled sdl surfaces for map world view redrawing | ||||
| 	class CMapCache | ||||
| 	{ | ||||
| 		std::map<EMapCacheType, std::map<int, SDL_Surface *>> data; | ||||
| 		float worldViewCachedScale; | ||||
| 	public: | ||||
| 		/// destroys all cached data (frees surfaces) | ||||
| 		void discardWorldViewCache(); | ||||
| 		/// updates scale and determines if currently cached data is still valid | ||||
| 		void updateWorldViewScale(float scale); | ||||
| 		void removeFromWorldViewCache(EMapCacheType type, int key); | ||||
| 		/// asks for cached data; @returns nullptr if data is not in cache | ||||
| 		SDL_Surface * requestWorldViewCache(EMapCacheType type, int key); | ||||
| 		/// asks for cached data; @returns cached data if found, new scaled surface otherwise | ||||
| 		SDL_Surface * requestWorldViewCacheOrCreate(EMapCacheType type, int key, SDL_Surface * fullSurface, float scale); | ||||
| 		SDL_Surface * cacheWorldViewEntry(EMapCacheType type, int key, SDL_Surface * entry); | ||||
| 	}; | ||||
|  | ||||
| 	CMapCache cache; | ||||
|  | ||||
| 	void drawWorldViewOverlay(int targetTilesX, int targetTilesY, int srx_init, int sry_init, CDefHandler * iconsDef, const std::vector< std::vector< std::vector<ui8> > > * visibilityMap, float scale, int targetTileSize, int3 top_tile, SDL_Surface * extSurf); | ||||
| 	void calculateWorldViewCameraPos(int targetTilesX, int targetTilesY, int3 &top_tile); | ||||
| public: | ||||
| 	PseudoV< PseudoV< PseudoV<TerrainTile2> > > ttiles; //informations about map tiles | ||||
| 	int3 sizes; //map size (x = width, y = height, z = number of levels) | ||||
| @@ -121,11 +172,13 @@ public: | ||||
| 	void prepareFOWDefs(); | ||||
|  | ||||
| 	void terrainRect(int3 top_tile, ui8 anim, const std::vector< std::vector< std::vector<ui8> > > * visibilityMap, bool otherHeroAnim, ui8 heroAnim, SDL_Surface * extSurf, const SDL_Rect * extRect, int moveX, int moveY, bool puzzleMode, int3 grailPosRel) const; | ||||
| 	void terrainRectScaled(int3 top_tile, const std::vector< std::vector< std::vector<ui8> > > * visibilityMap, SDL_Surface * extSurf, const SDL_Rect * extRect, float scale, CDefHandler * iconsDef); | ||||
| 	void updateWater(); | ||||
| 	ui8 getHeroFrameNum(ui8 dir, bool isMoving) const; //terrainRect helper function | ||||
| 	void validateRectTerr(SDL_Rect * val, const SDL_Rect * ext); //terrainRect helper | ||||
| 	static ui8 getDir(const int3 & a, const int3 & b);  //returns direction number in range 0 - 7 (0 is left top, clockwise) [direction: form a to b] | ||||
|  | ||||
| 	static bool compareObjectBlitOrder(const CGObjectInstance * a, const CGObjectInstance * b); | ||||
| 	void discardWorldViewCache(); | ||||
|  | ||||
| 	static bool compareObjectBlitOrder(const CGObjectInstance * a, const CGObjectInstance * b); | ||||
| }; | ||||
|   | ||||
| @@ -47,9 +47,9 @@ | ||||
|  */ | ||||
|  | ||||
| CList::CListItem::CListItem(CList * Parent): | ||||
|     CIntObject(LCLICK | RCLICK | HOVER), | ||||
|     parent(Parent), | ||||
|     selection(nullptr) | ||||
| 	CIntObject(LCLICK | RCLICK | HOVER), | ||||
| 	parent(Parent), | ||||
| 	selection(nullptr) | ||||
| { | ||||
| } | ||||
|  | ||||
| @@ -100,10 +100,10 @@ void CList::CListItem::onSelect(bool on) | ||||
| } | ||||
|  | ||||
| CList::CList(int Size, Point position, std::string btnUp, std::string btnDown, size_t listAmount, | ||||
|              int helpUp, int helpDown, CListBox::CreateFunc create, CListBox::DestroyFunc destroy): | ||||
|     CIntObject(0, position), | ||||
|     size(Size), | ||||
|     selected(nullptr) | ||||
| 			 int helpUp, int helpDown, CListBox::CreateFunc create, CListBox::DestroyFunc destroy): | ||||
| 	CIntObject(0, position), | ||||
| 	size(Size), | ||||
| 	selected(nullptr) | ||||
| { | ||||
| 	OBJ_CONSTRUCTION_CAPTURING_ALL; | ||||
| 	scrollUp = new CButton(Point(0, 0), btnUp, CGI->generaltexth->zelp[helpUp]); | ||||
| @@ -194,8 +194,8 @@ CHeroList::CEmptyHeroItem::CEmptyHeroItem() | ||||
| } | ||||
|  | ||||
| CHeroList::CHeroItem::CHeroItem(CHeroList *parent, const CGHeroInstance * Hero): | ||||
|     CListItem(parent), | ||||
|     hero(Hero) | ||||
| 	CListItem(parent), | ||||
| 	hero(Hero) | ||||
| { | ||||
| 	OBJ_CONSTRUCTION_CAPTURING_ALL; | ||||
| 	movement = new CAnimImage("IMOBIL", 0, 0, 0, 1); | ||||
| @@ -249,7 +249,7 @@ CIntObject * CHeroList::createHeroItem(size_t index) | ||||
| } | ||||
|  | ||||
| CHeroList::CHeroList(int size, Point position, std::string btnUp, std::string btnDown): | ||||
|     CList(size, position, btnUp, btnDown, LOCPLINT->wanderingHeroes.size(), 303, 304, std::bind(&CHeroList::createHeroItem, this, _1)) | ||||
| 	CList(size, position, btnUp, btnDown, LOCPLINT->wanderingHeroes.size(), 303, 304, std::bind(&CHeroList::createHeroItem, this, _1)) | ||||
| { | ||||
| } | ||||
|  | ||||
| @@ -290,8 +290,8 @@ CIntObject * CTownList::createTownItem(size_t index) | ||||
| } | ||||
|  | ||||
| CTownList::CTownItem::CTownItem(CTownList *parent, const CGTownInstance *Town): | ||||
|     CListItem(parent), | ||||
|     town(Town) | ||||
| 	CListItem(parent), | ||||
| 	town(Town) | ||||
| { | ||||
| 	OBJ_CONSTRUCTION_CAPTURING_ALL; | ||||
| 	picture = new CAnimImage("ITPA", 0); | ||||
| @@ -334,7 +334,7 @@ std::string CTownList::CTownItem::getHoverText() | ||||
| } | ||||
|  | ||||
| CTownList::CTownList(int size, Point position, std::string btnUp, std::string btnDown): | ||||
|     CList(size, position, btnUp, btnDown, LOCPLINT->towns.size(),  306, 307, std::bind(&CTownList::createTownItem, this, _1)) | ||||
| 	CList(size, position, btnUp, btnDown, LOCPLINT->towns.size(),  306, 307, std::bind(&CTownList::createTownItem, this, _1)) | ||||
| { | ||||
| } | ||||
|  | ||||
| @@ -460,9 +460,9 @@ void CMinimapInstance::drawScaled(int level) | ||||
| } | ||||
|  | ||||
| CMinimapInstance::CMinimapInstance(CMinimap *Parent, int Level): | ||||
|     parent(Parent), | ||||
|     minimap(CSDL_Ext::createSurfaceWithBpp<4>(parent->pos.w, parent->pos.h)), | ||||
|     level(Level) | ||||
| 	parent(Parent), | ||||
| 	minimap(CSDL_Ext::createSurfaceWithBpp<4>(parent->pos.w, parent->pos.h)), | ||||
| 	level(Level) | ||||
| { | ||||
| 	pos.w = parent->pos.w; | ||||
| 	pos.h = parent->pos.h; | ||||
| @@ -479,7 +479,7 @@ void CMinimapInstance::showAll(SDL_Surface *to) | ||||
| 	blitAtLoc(minimap, 0, 0, to); | ||||
|  | ||||
| 	//draw heroes | ||||
| 	std::vector <const CGHeroInstance *> heroes = LOCPLINT->cb->getHeroesInfo(false); //TODO: do we really need separate function for drawing heroes?  | ||||
| 	std::vector <const CGHeroInstance *> heroes = LOCPLINT->cb->getHeroesInfo(false); //TODO: do we really need separate function for drawing heroes? | ||||
| 	for(auto & hero : heroes) | ||||
| 	{ | ||||
| 		int3 position = hero->getPosition(false); | ||||
| @@ -502,7 +502,7 @@ std::map<int, std::pair<SDL_Color, SDL_Color> > CMinimap::loadColors(std::string | ||||
| 		auto index = boost::find(GameConstants::TERRAIN_NAMES, m.first); | ||||
| 		if (index == std::end(GameConstants::TERRAIN_NAMES)) | ||||
| 		{ | ||||
|             logGlobal->errorStream() << "Error: unknown terrain in terrains.json: " << m.first; | ||||
| 			logGlobal->errorStream() << "Error: unknown terrain in terrains.json: " << m.first; | ||||
| 			continue; | ||||
| 		} | ||||
| 		int terrainID = index - std::begin(GameConstants::TERRAIN_NAMES); | ||||
| @@ -531,11 +531,11 @@ std::map<int, std::pair<SDL_Color, SDL_Color> > CMinimap::loadColors(std::string | ||||
| } | ||||
|  | ||||
| CMinimap::CMinimap(const Rect &position): | ||||
|     CIntObject(LCLICK | RCLICK | HOVER | MOVE, position.topLeft()), | ||||
|     aiShield(nullptr), | ||||
|     minimap(nullptr), | ||||
|     level(0), | ||||
|     colors(loadColors("config/terrains.json")) | ||||
| 	CIntObject(LCLICK | RCLICK | HOVER | MOVE, position.topLeft()), | ||||
| 	aiShield(nullptr), | ||||
| 	minimap(nullptr), | ||||
| 	level(0), | ||||
| 	colors(loadColors("config/terrains.json")) | ||||
| { | ||||
| 	pos.w = position.w; | ||||
| 	pos.h = position.h; | ||||
| @@ -595,6 +595,7 @@ void CMinimap::showAll(SDL_Surface * to) | ||||
| 	if (minimap) | ||||
| 	{ | ||||
| 		int3 mapSizes = LOCPLINT->cb->getMapSize(); | ||||
| 		int3 tileCountOnScreen = adventureInt->terrain.tileCountOnScreen(); | ||||
|  | ||||
| 		//draw radar | ||||
| 		SDL_Rect oldClip; | ||||
| @@ -602,8 +603,8 @@ void CMinimap::showAll(SDL_Surface * to) | ||||
| 		{ | ||||
| 			si16(adventureInt->position.x * pos.w / mapSizes.x + pos.x), | ||||
| 			si16(adventureInt->position.y * pos.h / mapSizes.y + pos.y), | ||||
| 			ui16(adventureInt->terrain.tilesw * pos.w / mapSizes.x), | ||||
| 			ui16(adventureInt->terrain.tilesh * pos.h / mapSizes.y) | ||||
| 			ui16(tileCountOnScreen.x * pos.w / mapSizes.x), | ||||
| 			ui16(tileCountOnScreen.y * pos.h / mapSizes.y) | ||||
| 		}; | ||||
|  | ||||
| 		SDL_GetClipRect(to, &oldClip); | ||||
| @@ -662,8 +663,8 @@ void CMinimap::showTile(const int3 &pos) | ||||
| } | ||||
|  | ||||
| CInfoBar::CVisibleInfo::CVisibleInfo(Point position): | ||||
|     CIntObject(0, position), | ||||
|     aiProgress(nullptr) | ||||
| 	CIntObject(0, position), | ||||
| 	aiProgress(nullptr) | ||||
| { | ||||
|  | ||||
| } | ||||
| @@ -898,10 +899,10 @@ void CInfoBar::hover(bool on) | ||||
| } | ||||
|  | ||||
| CInfoBar::CInfoBar(const Rect &position): | ||||
|     CIntObject(LCLICK | RCLICK | HOVER, position.topLeft()), | ||||
|     visibleInfo(nullptr), | ||||
|     state(EMPTY), | ||||
|     currentObject(nullptr) | ||||
| 	CIntObject(LCLICK | RCLICK | HOVER, position.topLeft()), | ||||
| 	visibleInfo(nullptr), | ||||
| 	state(EMPTY), | ||||
| 	currentObject(nullptr) | ||||
| { | ||||
| 	pos.w = position.w; | ||||
| 	pos.h = position.h; | ||||
|   | ||||
| @@ -61,7 +61,7 @@ CAdvMapInt *adventureInt; | ||||
|  | ||||
|  | ||||
| CTerrainRect::CTerrainRect() | ||||
| 	:curHoveredTile(-1,-1,-1), currentPath(nullptr) | ||||
| 	: curHoveredTile(-1,-1,-1), currentPath(nullptr) | ||||
| { | ||||
| 	tilesw=(ADVOPT.advmapW+31)/32; | ||||
| 	tilesh=(ADVOPT.advmapH+31)/32; | ||||
| @@ -81,6 +81,8 @@ void CTerrainRect::deactivate() | ||||
|  | ||||
| void CTerrainRect::clickLeft(tribool down, bool previousState) | ||||
| { | ||||
| 	if (adventureInt->mode == EAdvMapMode::WORLD_VIEW) | ||||
| 		return; | ||||
| 	if ((down==false) || indeterminate(down)) | ||||
| 		return; | ||||
|  | ||||
| @@ -93,6 +95,8 @@ void CTerrainRect::clickLeft(tribool down, bool previousState) | ||||
|  | ||||
| void CTerrainRect::clickRight(tribool down, bool previousState) | ||||
| { | ||||
| 	if (adventureInt->mode == EAdvMapMode::WORLD_VIEW) | ||||
| 		return; | ||||
| 	int3 mp = whichTileIsIt(); | ||||
|  | ||||
| 	if (CGI->mh->map->isInTheMap(mp) && down) | ||||
| @@ -260,23 +264,35 @@ void CTerrainRect::showPath(const SDL_Rect * extRect, SDL_Surface * to) | ||||
|  | ||||
| void CTerrainRect::show(SDL_Surface * to) | ||||
| { | ||||
| 	if(ADVOPT.smoothMove) | ||||
| 		CGI->mh->terrainRect | ||||
| 			(adventureInt->position, adventureInt->anim, | ||||
| 			 &LOCPLINT->cb->getVisibilityMap(), true, adventureInt->heroAnim, | ||||
| 			 to, &pos, moveX, moveY, false, int3()); | ||||
| 	else | ||||
| 		CGI->mh->terrainRect | ||||
| 			(adventureInt->position, adventureInt->anim, | ||||
| 			 &LOCPLINT->cb->getVisibilityMap(), true, adventureInt->heroAnim, | ||||
| 			 to, &pos, 0, 0, false, int3()); | ||||
| 	if (adventureInt->mode == EAdvMapMode::NORMAL) | ||||
| 	{ | ||||
| 		if (ADVOPT.smoothMove) | ||||
| 			CGI->mh->terrainRect | ||||
| 				(adventureInt->position, adventureInt->anim, | ||||
| 					&LOCPLINT->cb->getVisibilityMap(), true, adventureInt->heroAnim, | ||||
| 					to, &pos, moveX, moveY, false, int3()); | ||||
| 		else | ||||
| 			CGI->mh->terrainRect | ||||
| 				(adventureInt->position, adventureInt->anim, | ||||
| 					&LOCPLINT->cb->getVisibilityMap(), true, adventureInt->heroAnim, | ||||
| 					to, &pos, 0, 0, false, int3()); | ||||
|  | ||||
| 		if (currentPath/* && adventureInt->position.z==currentPath->startPos().z*/) //drawing path | ||||
| 		{ | ||||
| 			showPath(&pos, to); | ||||
| 		} | ||||
| 	} | ||||
| 	//SDL_BlitSurface(teren,&genRect(pos.h,pos.w,0,0),screen,&genRect(547,594,7,6)); | ||||
| 	//SDL_FreeSurface(teren); | ||||
| 	if (currentPath/* && adventureInt->position.z==currentPath->startPos().z*/) //drawing path | ||||
| 	{ | ||||
| 		showPath(&pos, to); | ||||
| 	} | ||||
|  | ||||
| } | ||||
|  | ||||
| void CTerrainRect::showAll(SDL_Surface * to) | ||||
| { | ||||
| 	// world view map is static and doesn't need redraw every frame | ||||
| 	if (adventureInt->mode == EAdvMapMode::WORLD_VIEW) | ||||
| 		CGI->mh->terrainRectScaled (adventureInt->position, &LOCPLINT->cb->getVisibilityMap(), | ||||
| 									to, &pos, adventureInt->worldViewScale, adventureInt->worldViewIconsDef); | ||||
| } | ||||
|  | ||||
| int3 CTerrainRect::whichTileIsIt(const int & x, const int & y) | ||||
| @@ -293,6 +309,20 @@ int3 CTerrainRect::whichTileIsIt() | ||||
| 	return whichTileIsIt(GH.current->motion.x,GH.current->motion.y); | ||||
| } | ||||
|  | ||||
| int3 CTerrainRect::tileCountOnScreen() | ||||
| { | ||||
| 	switch (adventureInt->mode) | ||||
| 	{ | ||||
| 	default: | ||||
| 		logGlobal->errorStream() << "Unhandled map mode " << (int)adventureInt->mode; | ||||
| 		return int3(); | ||||
| 	case EAdvMapMode::NORMAL: | ||||
| 		return int3(tilesw, tilesh, 1); | ||||
| 	case EAdvMapMode::WORLD_VIEW: | ||||
| 		return int3(tilesw / adventureInt->worldViewScale, tilesh / adventureInt->worldViewScale, 1); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void CResDataBar::clickRight(tribool down, bool previousState) | ||||
| { | ||||
| } | ||||
| @@ -300,7 +330,7 @@ void CResDataBar::clickRight(tribool down, bool previousState) | ||||
| CResDataBar::CResDataBar(const std::string &defname, int x, int y, int offx, int offy, int resdist, int datedist) | ||||
| { | ||||
| 	bg = BitmapHandler::loadBitmap(defname); | ||||
| 	CSDL_Ext::setDefaultColorKey(bg);	 | ||||
| 	CSDL_Ext::setDefaultColorKey(bg); | ||||
| 	graphics->blueToPlayersAdv(bg,LOCPLINT->playerID); | ||||
| 	pos = genRect(bg->h, bg->w, pos.x+x, pos.y+y); | ||||
|  | ||||
| @@ -319,7 +349,7 @@ CResDataBar::CResDataBar(const std::string &defname, int x, int y, int offx, int | ||||
| CResDataBar::CResDataBar() | ||||
| { | ||||
| 	bg = BitmapHandler::loadBitmap(ADVOPT.resdatabarG); | ||||
| 	CSDL_Ext::setDefaultColorKey(bg);	 | ||||
| 	CSDL_Ext::setDefaultColorKey(bg); | ||||
| 	graphics->blueToPlayersAdv(bg,LOCPLINT->playerID); | ||||
| 	pos = genRect(bg->h,bg->w,ADVOPT.resdatabarX,ADVOPT.resdatabarY); | ||||
|  | ||||
| @@ -367,7 +397,8 @@ void CResDataBar::showAll(SDL_Surface * to) | ||||
| } | ||||
|  | ||||
| CAdvMapInt::CAdvMapInt(): | ||||
|     minimap(Rect(ADVOPT.minimapX, ADVOPT.minimapY, ADVOPT.minimapW, ADVOPT.minimapH)), | ||||
| 	mode(EAdvMapMode::NORMAL), | ||||
| 	minimap(Rect(ADVOPT.minimapX, ADVOPT.minimapY, ADVOPT.minimapW, ADVOPT.minimapH)), | ||||
| statusbar(ADVOPT.statusbarX,ADVOPT.statusbarY,ADVOPT.statusbarG), | ||||
| heroList(ADVOPT.hlistSize, Point(ADVOPT.hlistX, ADVOPT.hlistY), ADVOPT.hlistAU, ADVOPT.hlistAD), | ||||
| townList(ADVOPT.tlistSize, Point(ADVOPT.tlistX, ADVOPT.tlistY), ADVOPT.tlistAU, ADVOPT.tlistAD), | ||||
| @@ -384,6 +415,7 @@ infoBar(Rect(ADVOPT.infoboxX, ADVOPT.infoboxY, 192, 192) ) | ||||
| 	townList.onSelect = std::bind(&CAdvMapInt::selectionChanged,this); | ||||
| 	adventureInt=this; | ||||
| 	bg = BitmapHandler::loadBitmap(ADVOPT.mainGraphic); | ||||
| 	bgWorldView = BitmapHandler::loadBitmap(ADVOPT.worldViewGraphic); | ||||
| 	scrollingDir = 0; | ||||
| 	updateScreen  = false; | ||||
| 	anim=0; | ||||
| @@ -391,6 +423,13 @@ infoBar(Rect(ADVOPT.infoboxX, ADVOPT.infoboxY, 192, 192) ) | ||||
| 	heroAnim=0; | ||||
| 	heroAnimValHitCount=0; // hero animation frame | ||||
|  | ||||
| 	if (!bgWorldView) | ||||
| 	{ | ||||
| 		logGlobal->warn("bgWorldView not defined in resolution config; fallback to VWorld.bmp"); | ||||
| 		bgWorldView = BitmapHandler::loadBitmap("VWorld.bmp"); | ||||
| 	} | ||||
| 	worldViewIconsDef = CDefHandler::giveDef("VwSymbol.def"); | ||||
|  | ||||
| 	for (int g=0; g<ADVOPT.gemG.size(); ++g) | ||||
| 	{ | ||||
| 		gems.push_back(CDefHandler::giveDef(ADVOPT.gemG[g])); | ||||
| @@ -416,23 +455,133 @@ infoBar(Rect(ADVOPT.infoboxX, ADVOPT.infoboxY, 192, 192) ) | ||||
| 	nextHero     = makeButton(301, std::bind(&CAdvMapInt::fnextHero,this),         ADVOPT.nextHero,     SDLK_h); | ||||
| 	endTurn      = makeButton(302, std::bind(&CAdvMapInt::fendTurn,this),          ADVOPT.endTurn,      SDLK_e); | ||||
|  | ||||
| 	// TODO move configs to resolutions.json, similarly to previous buttons | ||||
| 	config::ButtonInfo worldViewBackConfig = config::ButtonInfo(); | ||||
| 	worldViewBackConfig.defName = "IOK6432.DEF"; | ||||
| 	worldViewBackConfig.x = screen->w - 73; | ||||
| 	worldViewBackConfig.y = 343 + 195; | ||||
| 	worldViewBackConfig.playerColoured = false; | ||||
| 	worldViewUIObjects.push_back(makeButton(288, std::bind(&CAdvMapInt::fworldViewBack,this), worldViewBackConfig, SDLK_ESCAPE)); | ||||
|  | ||||
| 	config::ButtonInfo worldViewScale1xConfig = config::ButtonInfo(); | ||||
| 	worldViewScale1xConfig.defName = "VWMAG1.DEF"; | ||||
| 	worldViewScale1xConfig.x = screen->w - 191; | ||||
| 	worldViewScale1xConfig.y = 23 + 195; | ||||
| 	worldViewScale1xConfig.playerColoured = false; | ||||
| 	worldViewUIObjects.push_back(makeButton(291, std::bind(&CAdvMapInt::fworldViewScale1x,this), worldViewScale1xConfig, SDLK_y)); | ||||
|  | ||||
| 	config::ButtonInfo worldViewScale2xConfig = config::ButtonInfo(); | ||||
| 	worldViewScale2xConfig.defName = "VWMAG2.DEF"; | ||||
| 	worldViewScale2xConfig.x = screen->w - 191 + 63; | ||||
| 	worldViewScale2xConfig.y = 23 + 195; | ||||
| 	worldViewScale2xConfig.playerColoured = false; | ||||
| 	worldViewUIObjects.push_back(makeButton(291, std::bind(&CAdvMapInt::fworldViewScale2x,this), worldViewScale2xConfig, SDLK_y)); | ||||
|  | ||||
| 	config::ButtonInfo worldViewScale4xConfig = config::ButtonInfo(); | ||||
| 	worldViewScale4xConfig.defName = "VWMAG4.DEF"; | ||||
| 	worldViewScale4xConfig.x = screen->w - 191 + 126; | ||||
| 	worldViewScale4xConfig.y = 23 + 195; | ||||
| 	worldViewScale4xConfig.playerColoured = false; | ||||
| 	worldViewUIObjects.push_back(makeButton(291, std::bind(&CAdvMapInt::fworldViewScale4x,this), worldViewScale4xConfig, SDLK_y)); | ||||
|  | ||||
| 	config::ButtonInfo worldViewUndergroundConfig = config::ButtonInfo(); | ||||
| 	worldViewUndergroundConfig.defName = "IAM010.DEF"; | ||||
| 	worldViewUndergroundConfig.additionalDefs.push_back("IAM003.DEF"); | ||||
| 	worldViewUndergroundConfig.x = screen->w - 115; | ||||
| 	worldViewUndergroundConfig.y = 343 + 195; | ||||
| 	worldViewUndergroundConfig.playerColoured = true; | ||||
| 	worldViewUnderground = makeButton(294, std::bind(&CAdvMapInt::fworldViewSwitchLevel,this), worldViewUndergroundConfig, SDLK_u); | ||||
| 	worldViewUIObjects.push_back(worldViewUnderground); | ||||
|  | ||||
| 	setPlayer(LOCPLINT->playerID); | ||||
|  | ||||
|  | ||||
| 	int iconColorMultiplier = player.getNum() * 19; | ||||
| 	int wvLeft = heroList.pos.x - 2; // TODO correct drawing position? | ||||
| 	for (int i = 0; i < 5; ++i) | ||||
| 	{ | ||||
| 		worldViewUIObjects.push_back(new CPicture(worldViewIconsDef->ourImages[i].bitmap, wvLeft + 5, 253 + i * 20)); | ||||
| 		worldViewUIObjects.push_back(new CLabel(wvLeft + 45, 263 + i * 20, EFonts::FONT_SMALL, EAlignment::TOPLEFT, | ||||
| 												Colors::WHITE, CGI->generaltexth->allTexts[612 + i])); | ||||
| 	} | ||||
| 	for (int i = 0; i < 7; ++i) | ||||
| 	{ | ||||
| 		worldViewUIObjects.push_back(new CPicture(worldViewIconsDef->ourImages[i +  5 + iconColorMultiplier].bitmap, wvLeft +   5, 377 + i * 20)); | ||||
| 		worldViewUIObjects.push_back(new CPicture(worldViewIconsDef->ourImages[i + 12 + iconColorMultiplier].bitmap, wvLeft + 160, 377 + i * 20)); | ||||
| 		worldViewUIObjects.push_back(new CLabel(wvLeft + 45, 387 + i * 20, EFonts::FONT_SMALL, EAlignment::TOPLEFT, | ||||
| 												Colors::WHITE, CGI->generaltexth->allTexts[619 + i])); | ||||
| 	} | ||||
| 	worldViewUIObjects.push_back(new CLabel(wvLeft +   5, 367, EFonts::FONT_SMALL, EAlignment::TOPLEFT, | ||||
| 											Colors::WHITE, CGI->generaltexth->allTexts[617])); | ||||
| 	worldViewUIObjects.push_back(new CLabel(wvLeft + 185, 387, EFonts::FONT_SMALL, EAlignment::BOTTOMRIGHT, | ||||
| 											Colors::WHITE, CGI->generaltexth->allTexts[618])); | ||||
|  | ||||
|  | ||||
| 	underground->block(!CGI->mh->map->twoLevel); | ||||
| 	worldViewUnderground->block(!CGI->mh->map->twoLevel); | ||||
| 	addUsedEvents(MOVE); | ||||
| } | ||||
|  | ||||
| CAdvMapInt::~CAdvMapInt() | ||||
| { | ||||
| 	SDL_FreeSurface(bg); | ||||
| 	SDL_FreeSurface(bgWorldView); | ||||
|  | ||||
| 	for(int i=0; i<gems.size(); i++) | ||||
| 		delete gems[i]; | ||||
|  | ||||
| 	delete worldViewIconsDef; | ||||
| } | ||||
|  | ||||
| void CAdvMapInt::fshowOverview() | ||||
| { | ||||
| 	GH.pushInt(new CKingdomInterface); | ||||
| } | ||||
|  | ||||
| void CAdvMapInt::fworldViewBack() | ||||
| { | ||||
| 	changeMode(EAdvMapMode::NORMAL); | ||||
| 	CGI->mh->discardWorldViewCache(); | ||||
| } | ||||
|  | ||||
| void CAdvMapInt::fworldViewScale1x() | ||||
| { | ||||
| 	// TODO set corresponding scale button to "selected" mode | ||||
| 	changeMode(EAdvMapMode::WORLD_VIEW, 0.25f); // TODO find out correct scale values from OH3 | ||||
| } | ||||
|  | ||||
| void CAdvMapInt::fworldViewScale2x() | ||||
| { | ||||
| 	changeMode(EAdvMapMode::WORLD_VIEW, 0.4f); | ||||
| } | ||||
|  | ||||
| void CAdvMapInt::fworldViewScale4x() | ||||
| { | ||||
| 	changeMode(EAdvMapMode::WORLD_VIEW, 0.6f); | ||||
| } | ||||
|  | ||||
| void CAdvMapInt::fworldViewSwitchLevel() | ||||
| { | ||||
| 	if(!CGI->mh->map->twoLevel) | ||||
| 		return; | ||||
| 	if (position.z) | ||||
| 	{ | ||||
| 		position.z--; | ||||
| 		worldViewUnderground->setIndex(0,false); | ||||
| 		worldViewUnderground->showAll(screenBuf); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		worldViewUnderground->setIndex(1,false); | ||||
| 		position.z++; | ||||
| 		worldViewUnderground->showAll(screenBuf); | ||||
| 	} | ||||
| 	updateScreen = true; | ||||
| 	minimap.setLevel(position.z); | ||||
|  | ||||
| 	terrain.redraw(); | ||||
| } | ||||
|  | ||||
| void CAdvMapInt::fswitchLevel() | ||||
| { | ||||
| 	if(!CGI->mh->map->twoLevel) | ||||
| @@ -599,27 +748,35 @@ void CAdvMapInt::activate() | ||||
| 	GH.statusbar = &statusbar; | ||||
| 	if(!duringAITurn) | ||||
| 	{ | ||||
| 		kingOverview->activate(); | ||||
| 		underground->activate(); | ||||
| 		questlog->activate(); | ||||
| 		sleepWake->activate(); | ||||
| 		moveHero->activate(); | ||||
| 		spellbook->activate(); | ||||
| 		sysOptions->activate(); | ||||
| 		advOptions->activate(); | ||||
| 		nextHero->activate(); | ||||
| 		endTurn->activate(); | ||||
|  | ||||
| 		if (mode == EAdvMapMode::NORMAL) | ||||
| 		{ | ||||
| 			kingOverview->activate(); | ||||
| 			underground->activate(); | ||||
| 			questlog->activate(); | ||||
| 			sleepWake->activate(); | ||||
| 			moveHero->activate(); | ||||
| 			spellbook->activate(); | ||||
| 			sysOptions->activate(); | ||||
| 			advOptions->activate(); | ||||
| 			nextHero->activate(); | ||||
| 			endTurn->activate(); | ||||
| 			heroList.activate(); | ||||
| 			townList.activate(); | ||||
| 			infoBar.activate(); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			for (auto &uiElem : worldViewUIObjects) | ||||
| 				uiElem->activate(); | ||||
| 		} | ||||
| 		minimap.activate(); | ||||
| 		heroList.activate(); | ||||
| 		townList.activate(); | ||||
| 		terrain.activate(); | ||||
| 		infoBar.activate(); | ||||
| 		LOCPLINT->cingconsole->activate(); | ||||
|  | ||||
| 		GH.fakeMouseMove(); //to restore the cursor | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void CAdvMapInt::deactivate() | ||||
| { | ||||
| 	CIntObject::deactivate(); | ||||
| @@ -629,25 +786,34 @@ void CAdvMapInt::deactivate() | ||||
| 		scrollingDir = 0; | ||||
|  | ||||
| 		CCS->curh->changeGraphic(ECursor::ADVENTURE,0); | ||||
| 		kingOverview->deactivate(); | ||||
| 		underground->deactivate(); | ||||
| 		questlog->deactivate(); | ||||
| 		sleepWake->deactivate(); | ||||
| 		moveHero->deactivate(); | ||||
| 		spellbook->deactivate(); | ||||
| 		advOptions->deactivate(); | ||||
| 		sysOptions->deactivate(); | ||||
| 		nextHero->deactivate(); | ||||
| 		endTurn->deactivate(); | ||||
| 		if (mode == EAdvMapMode::NORMAL) | ||||
| 		{ | ||||
| 			kingOverview->deactivate(); | ||||
| 			underground->deactivate(); | ||||
| 			questlog->deactivate(); | ||||
| 			sleepWake->deactivate(); | ||||
| 			moveHero->deactivate(); | ||||
| 			spellbook->deactivate(); | ||||
| 			advOptions->deactivate(); | ||||
| 			sysOptions->deactivate(); | ||||
| 			nextHero->deactivate(); | ||||
| 			endTurn->deactivate(); | ||||
| 			heroList.deactivate(); | ||||
| 			townList.deactivate(); | ||||
| 			infoBar.deactivate(); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			for (auto &uiElem : worldViewUIObjects) | ||||
| 				uiElem->deactivate(); | ||||
| 		} | ||||
| 		minimap.deactivate(); | ||||
| 		heroList.deactivate(); | ||||
| 		townList.deactivate(); | ||||
| 		terrain.deactivate(); | ||||
| 		infoBar.deactivate(); | ||||
| 		if(LOCPLINT) | ||||
| 			LOCPLINT->cingconsole->deactivate(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void CAdvMapInt::showAll(SDL_Surface * to) | ||||
| { | ||||
| 	blitAt(bg,0,0,to); | ||||
| @@ -655,28 +821,43 @@ void CAdvMapInt::showAll(SDL_Surface * to) | ||||
| 	if(state != INGAME) | ||||
| 		return; | ||||
|  | ||||
| 	kingOverview->showAll(to); | ||||
| 	underground->showAll(to); | ||||
| 	questlog->showAll(to); | ||||
| 	sleepWake->showAll(to); | ||||
| 	moveHero->showAll(to); | ||||
| 	spellbook->showAll(to); | ||||
| 	advOptions->showAll(to); | ||||
| 	sysOptions->showAll(to); | ||||
| 	nextHero->showAll(to); | ||||
| 	endTurn->showAll(to); | ||||
| 	switch (mode) | ||||
| 	{ | ||||
| 	case EAdvMapMode::NORMAL: | ||||
| 		kingOverview->showAll(to); | ||||
| 		underground->showAll(to); | ||||
| 		questlog->showAll(to); | ||||
| 		sleepWake->showAll(to); | ||||
| 		moveHero->showAll(to); | ||||
| 		spellbook->showAll(to); | ||||
| 		advOptions->showAll(to); | ||||
| 		sysOptions->showAll(to); | ||||
| 		nextHero->showAll(to); | ||||
| 		endTurn->showAll(to); | ||||
|  | ||||
| 		heroList.showAll(to); | ||||
| 		townList.showAll(to); | ||||
| 		infoBar.showAll(to); | ||||
| 		break; | ||||
| 	case EAdvMapMode::WORLD_VIEW: | ||||
| 		blitAt(bgWorldView, heroList.pos.x - 2, 195, to); // TODO correct drawing position | ||||
|  | ||||
| 		for (auto &uiElem : worldViewUIObjects) | ||||
| 			uiElem->showAll(to); | ||||
|  | ||||
| 		terrain.showAll(to); | ||||
| 		break; | ||||
| 	} | ||||
|  | ||||
| 	minimap.showAll(to); | ||||
| 	heroList.showAll(to); | ||||
| 	townList.showAll(to); | ||||
| 	updateScreen = true; | ||||
| 	minimap.showAll(to); | ||||
| 	show(to); | ||||
|  | ||||
|  | ||||
| 	resdatabar.draw(to); | ||||
|  | ||||
| 	statusbar.show(to); | ||||
|  | ||||
| 	infoBar.showAll(to); | ||||
| 	LOCPLINT->cingconsole->showAll(to); | ||||
| } | ||||
|  | ||||
| @@ -737,6 +918,8 @@ void CAdvMapInt::show(SDL_Surface * to) | ||||
| 		{ | ||||
| 			updateScreen = true; | ||||
| 			minimap.redraw(); | ||||
| 			if (mode == EAdvMapMode::WORLD_VIEW) | ||||
| 				terrain.redraw(); | ||||
| 		} | ||||
| 	} | ||||
| 	if(updateScreen) | ||||
| @@ -781,6 +964,9 @@ void CAdvMapInt::centerOn(int3 on) | ||||
| 	if (switchedLevels) | ||||
| 		minimap.setLevel(position.z); | ||||
| 	minimap.redraw(); | ||||
|  | ||||
| 	if (mode == EAdvMapMode::WORLD_VIEW) | ||||
| 		terrain.redraw(); | ||||
| } | ||||
|  | ||||
| void CAdvMapInt::centerOn(const CGObjectInstance *obj) | ||||
| @@ -852,7 +1038,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key) | ||||
| 			{ | ||||
| 				auto unlockPim = vstd::makeUnlockGuard(*LOCPLINT->pim); | ||||
| 				//TODO!!!!!!! possible freeze, when GS mutex is locked and network thread can't apply package | ||||
| 				//this thread leaves scope and tries to lock pim while holding gs,  | ||||
| 				//this thread leaves scope and tries to lock pim while holding gs, | ||||
| 				//network thread tries to lock gs (appluy cl) while holding pim | ||||
| 				//this thread should first lock pim, however gs locking/unlocking is done inside cb | ||||
| 				LOCPLINT->cb->moveHero(h,h->pos); | ||||
| @@ -916,12 +1102,12 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key) | ||||
| 			//numpad arrow | ||||
| 			if(CGuiHandler::isArrowKey(SDLKey(k))) | ||||
| 				k = CGuiHandler::arrowToNum(SDLKey(k)); | ||||
| 			 | ||||
|  | ||||
| 			#ifdef VCMI_SDL1 | ||||
| 			k -= SDLK_KP0 + 1; | ||||
| 			#else | ||||
| 			k -= SDLK_KP_1; | ||||
| 			#endif // VCMI_SDL1			 | ||||
| 			#endif // VCMI_SDL1 | ||||
| 			if(k < 0 || k > 8) | ||||
| 				return; | ||||
|  | ||||
| @@ -1039,8 +1225,9 @@ void CAdvMapInt::select(const CArmedInstance *sel, bool centerView /*= true*/) | ||||
|  | ||||
| void CAdvMapInt::mouseMoved( const SDL_MouseMotionEvent & sEvent ) | ||||
| { | ||||
| 	//adventure map scrolling with mouse | ||||
| 	if(!isCtrlKeyDown() &&  isActive()) | ||||
| 	// adventure map scrolling with mouse | ||||
| 	// currently blocked in world view mode (as it is in OH3), but should work correctly if mode check is removed | ||||
| 	if(!isCtrlKeyDown() &&  isActive() && mode == EAdvMapMode::NORMAL) | ||||
| 	{ | ||||
| 		if(sEvent.x<15) | ||||
| 		{ | ||||
| @@ -1143,6 +1330,8 @@ const CGObjectInstance* CAdvMapInt::getActiveObject(const int3 &mapPos) | ||||
|  | ||||
| void CAdvMapInt::tileLClicked(const int3 &mapPos) | ||||
| { | ||||
| 	if(mode != EAdvMapMode::NORMAL) | ||||
| 		return; | ||||
| 	if(!LOCPLINT->cb->isVisible(mapPos) || !LOCPLINT->makingTurn) | ||||
| 		return; | ||||
|  | ||||
| @@ -1227,6 +1416,8 @@ void CAdvMapInt::tileLClicked(const int3 &mapPos) | ||||
|  | ||||
| void CAdvMapInt::tileHovered(const int3 &mapPos) | ||||
| { | ||||
| 	if(mode != EAdvMapMode::NORMAL) | ||||
| 		return; | ||||
| 	if(!LOCPLINT->cb->isVisible(mapPos)) | ||||
| 	{ | ||||
| 		CCS->curh->changeGraphic(ECursor::ADVENTURE, 0); | ||||
| @@ -1394,12 +1585,12 @@ void CAdvMapInt::tileHovered(const int3 &mapPos) | ||||
| 				if (guardingCreature) | ||||
| 				{ | ||||
| 					CCS->curh->changeGraphic(ECursor::ADVENTURE, 5 + turns*6); | ||||
| 				}  | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					if(pnode->land) | ||||
| 					{ | ||||
|                         if(LOCPLINT->cb->getTile(h->getPosition(false))->terType != ETerrainType::WATER) | ||||
| 						if(LOCPLINT->cb->getTile(h->getPosition(false))->terType != ETerrainType::WATER) | ||||
| 							CCS->curh->changeGraphic(ECursor::ADVENTURE, 4 + turns*6); | ||||
| 						else | ||||
| 							CCS->curh->changeGraphic(ECursor::ADVENTURE, 7 + turns*6); //anchor | ||||
| @@ -1421,6 +1612,8 @@ void CAdvMapInt::tileHovered(const int3 &mapPos) | ||||
|  | ||||
| void CAdvMapInt::tileRClicked(const int3 &mapPos) | ||||
| { | ||||
| 	if(mode != EAdvMapMode::NORMAL) | ||||
| 		return; | ||||
| 	if(spellBeingCasted) | ||||
| 	{ | ||||
| 		leaveCastingMode(); | ||||
| @@ -1512,26 +1705,84 @@ void CAdvMapInt::adjustActiveness(bool aiTurnStart) | ||||
| { | ||||
| 	bool wasActive = isActive(); | ||||
|  | ||||
| 	if(wasActive)  | ||||
| 	if(wasActive) | ||||
| 		deactivate(); | ||||
| 	adventureInt->duringAITurn = aiTurnStart; | ||||
| 	if(wasActive)  | ||||
| 	if(wasActive) | ||||
| 		activate(); | ||||
| } | ||||
|  | ||||
| void CAdvMapInt::changeMode(EAdvMapMode newMode, float newScale /* = 0.65f */) | ||||
| { | ||||
| 	if (mode != newMode) | ||||
| 	{ | ||||
| 		mode = newMode; | ||||
|  | ||||
| 		switch (mode) | ||||
| 		{ | ||||
| 		case EAdvMapMode::NORMAL: | ||||
| 			kingOverview->activate(); | ||||
| 			underground->activate(); | ||||
| 			questlog->activate(); | ||||
| 			sleepWake->activate(); | ||||
| 			moveHero->activate(); | ||||
| 			spellbook->activate(); | ||||
| 			sysOptions->activate(); | ||||
| 			advOptions->activate(); | ||||
| 			nextHero->activate(); | ||||
| 			endTurn->activate(); | ||||
| 			townList.activate(); | ||||
| 			heroList.activate(); | ||||
| 			infoBar.activate(); | ||||
|  | ||||
| 			for (auto &uiElem : worldViewUIObjects) | ||||
| 				uiElem->deactivate(); | ||||
| 			break; | ||||
| 		case EAdvMapMode::WORLD_VIEW: | ||||
| 			kingOverview->deactivate(); | ||||
| 			underground->deactivate(); | ||||
| 			questlog->deactivate(); | ||||
| 			sleepWake->deactivate(); | ||||
| 			moveHero->deactivate(); | ||||
| 			spellbook->deactivate(); | ||||
| 			sysOptions->deactivate(); | ||||
| 			advOptions->deactivate(); | ||||
| 			nextHero->deactivate(); | ||||
| 			endTurn->deactivate(); | ||||
| 			townList.deactivate(); | ||||
| 			heroList.deactivate(); | ||||
| 			infoBar.showSelection(); // to prevent new day animation interfering world view mode | ||||
| 			infoBar.deactivate(); | ||||
|  | ||||
| 			for (auto &uiElem : worldViewUIObjects) | ||||
| 				uiElem->activate(); | ||||
| 			break; | ||||
| 		} | ||||
| 		worldViewScale = newScale; | ||||
| 		redraw(); | ||||
| 	} | ||||
| 	else if (worldViewScale != newScale) // still in world view mode, but the scale changed | ||||
| 	{ | ||||
| 		worldViewScale = newScale; | ||||
| 		terrain.redraw(); | ||||
| 		minimap.redraw(); // to recalculate radar rect on minimap | ||||
| 	} | ||||
| } | ||||
|  | ||||
| CAdventureOptions::CAdventureOptions(): | ||||
| 	CWindowObject(PLAYER_COLORED, "ADVOPTS") | ||||
| { | ||||
| 	OBJ_CONSTRUCTION_CAPTURING_ALL; | ||||
|  | ||||
| 	viewWorld = new CButton(Point(24, 23), "ADVVIEW.DEF", CButton::tooltip(), [&]{ close(); }, SDLK_x); | ||||
| 	viewWorld->addCallback(std::bind(&CPlayerInterface::viewWorldMap, LOCPLINT)); | ||||
|  | ||||
| 	exit = new CButton(Point(204, 313), "IOK6432.DEF", CButton::tooltip(), std::bind(&CAdventureOptions::close, this), SDLK_RETURN); | ||||
| 	exit->assignedKeys.insert(SDLK_ESCAPE); | ||||
|  | ||||
| 	scenInfo = new CButton(Point(24, 198), "ADVINFO.DEF", CButton::tooltip(), [&]{ close(); }, SDLK_i); | ||||
| 	scenInfo->addCallback(CAdventureOptions::showScenarioInfo); | ||||
|  | ||||
| 	//viewWorld = new CButton("","",std::bind(&CGuiHandler::popIntTotally, &GH, this), 204, 313, "IOK6432.DEF",SDLK_RETURN); | ||||
|  | ||||
| 	puzzle = new CButton(Point(24, 81), "ADVPUZ.DEF", CButton::tooltip(), [&]{ close(); }, SDLK_p); | ||||
| 	puzzle->addCallback(std::bind(&CPlayerInterface::showPuzzleMap, LOCPLINT)); | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include <client/CDefHandler.h> | ||||
| #include "../widgets/AdventureMapClasses.h" | ||||
| #include "CWindowObject.h" | ||||
|  | ||||
| @@ -28,6 +29,12 @@ class IShipyard; | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| enum class EAdvMapMode | ||||
| { | ||||
| 	NORMAL, | ||||
| 	WORLD_VIEW | ||||
| }; | ||||
|  | ||||
| /// Adventure options dialogue where you can view the world, dig, play the replay of the last turn,... | ||||
| class CAdventureOptions : public CWindowObject | ||||
| { | ||||
| @@ -55,9 +62,12 @@ public: | ||||
| 	void hover(bool on); | ||||
| 	void mouseMoved (const SDL_MouseMotionEvent & sEvent); | ||||
| 	void show(SDL_Surface * to); | ||||
| 	void showAll(SDL_Surface * to); | ||||
| 	void showPath(const SDL_Rect * extRect, SDL_Surface * to); | ||||
| 	int3 whichTileIsIt(const int & x, const int & y); //x,y are cursor position | ||||
| 	int3 whichTileIsIt(); //uses current cursor pos | ||||
| 	/// @returns number of visible tiles on screen respecting current map scaling | ||||
| 	int3 tileCountOnScreen(); | ||||
| }; | ||||
|  | ||||
| /// Resources bar which shows information about how many gold, crystals,... you have | ||||
| @@ -79,9 +89,9 @@ public: | ||||
| 	void showAll(SDL_Surface * to); | ||||
| }; | ||||
|  | ||||
| /// That's a huge class which handles general adventure map actions and  | ||||
| /// shows the right menu(questlog, spellbook, end turn,..) from where you  | ||||
| /// can get to the towns and heroes.  | ||||
| /// That's a huge class which handles general adventure map actions and | ||||
| /// shows the right menu(questlog, spellbook, end turn,..) from where you | ||||
| /// can get to the towns and heroes. | ||||
| class CAdvMapInt : public CIntObject | ||||
| { | ||||
| 	//Return object that must be active at this tile (=clickable) | ||||
| @@ -105,7 +115,11 @@ public: | ||||
| 	ui8 anim, animValHitCount; //animation frame | ||||
| 	ui8 heroAnim, heroAnimValHitCount; //animation frame | ||||
|  | ||||
| 	EAdvMapMode mode; | ||||
| 	float worldViewScale; | ||||
|  | ||||
| 	SDL_Surface * bg; | ||||
| 	SDL_Surface * bgWorldView; | ||||
| 	std::vector<CDefHandler *> gems; | ||||
| 	CMinimap minimap; | ||||
| 	CGStatusBar statusbar; | ||||
| @@ -121,18 +135,28 @@ public: | ||||
| 	CButton * nextHero; | ||||
| 	CButton * endTurn; | ||||
|  | ||||
| 	CButton * worldViewUnderground; | ||||
| 	std::vector<CIntObject *> worldViewUIObjects; // all ui objects visible in the right panel in world view mode | ||||
|  | ||||
| 	CTerrainRect terrain; //visible terrain | ||||
| 	CResDataBar resdatabar; | ||||
| 	CHeroList heroList; | ||||
| 	CTownList townList; | ||||
| 	CInfoBar infoBar; | ||||
|  | ||||
| 	CDefHandler * worldViewIconsDef; // images for world view overlay | ||||
|  | ||||
| 	const CSpell *spellBeingCasted; //nullptr if none | ||||
|  | ||||
| 	const CArmedInstance *selection; //currently selected town/hero | ||||
|  | ||||
| 	//functions bound to buttons | ||||
| 	void fshowOverview(); | ||||
| 	void fworldViewBack(); | ||||
| 	void fworldViewScale1x(); | ||||
| 	void fworldViewScale2x(); | ||||
| 	void fworldViewScale4x(); | ||||
| 	void fworldViewSwitchLevel(); | ||||
| 	void fswitchLevel(); | ||||
| 	void fshowQuestlog(); | ||||
| 	void fsleepWake(); | ||||
| @@ -179,9 +203,12 @@ public: | ||||
| 	const CGTownInstance * curTown() const; | ||||
| 	const IShipyard * ourInaccessibleShipyard(const CGObjectInstance *obj) const; //checks if obj is our ashipyard and cursor is 0,0 -> returns shipyard or nullptr else | ||||
| 	//button updates | ||||
| 	void updateSleepWake(const CGHeroInstance *h);  | ||||
| 	void updateSleepWake(const CGHeroInstance *h); | ||||
| 	void updateMoveHero(const CGHeroInstance *h, tribool hasPath = boost::logic::indeterminate); | ||||
| 	void updateNextHero(const CGHeroInstance *h); | ||||
|  | ||||
| 	/// changes current adventure map mode; used to switch between default view and world view; scale is ignored if EAdvMapMode == NORMAL | ||||
| 	void changeMode(EAdvMapMode newMode, float newScale = 0.4f); | ||||
| }; | ||||
|  | ||||
| extern CAdvMapInt *adventureInt; | ||||
|   | ||||
| @@ -11,6 +11,7 @@ | ||||
| 			"gem2": { "x": 6, "y": 6, "graphic": "agemUL.def" }, | ||||
| 			"gem3": { "x": 556, "y": 6, "graphic": "agemUR.def" }, | ||||
| 			"background": "AdvMap.bmp", | ||||
| 			"backgroundWorldView": "VWorld.bmp", | ||||
| 			"HeroList": { "size": 5, "x": 609, "y": 196, "movePoints": "IMOBIL.DEF", "manaPoints": "IMANA.DEF", "arrowUp": "IAM012.DEF", "arrowDown": "IAM013.DEF" }, | ||||
| 			"TownList": { "size": 5, "x": 747, "y": 196, "arrowUp": "IAM014.DEF", "arrowDown": "IAM015.DEF" }, | ||||
| 			"Minimap": { "width": 144, "height": 144, "x": 630, "y": 26 }, | ||||
|   | ||||
| @@ -238,6 +238,7 @@ void config::CConfigHandler::init() | ||||
| 		setGem(current->ac, 3, g["gem3"]); | ||||
|  | ||||
| 		current->ac.mainGraphic = g["background"].String(); | ||||
| 		current->ac.worldViewGraphic = g["backgroundWorldView"].String(); | ||||
|  | ||||
| 		current->ac.hlistX = g["HeroList"]["x"].Float(); | ||||
| 		current->ac.hlistY = g["HeroList"]["y"].Float(); | ||||
|   | ||||
| @@ -135,6 +135,7 @@ namespace config | ||||
| 		bool puzzleSepia; | ||||
| 		//general properties | ||||
| 		std::string mainGraphic; | ||||
| 		std::string worldViewGraphic; | ||||
| 		//buttons | ||||
| 		ButtonInfo kingOverview, underground, questlog,	sleepWake, moveHero, spellbook,	advOptions, | ||||
| 			sysOptions,	nextHero, endTurn; | ||||
|   | ||||
| @@ -109,6 +109,7 @@ public: | ||||
| 	virtual void showShipyardDialog(const IShipyard *obj){} //obj may be town or shipyard; state: 0 - can buid, 1 - lack of resources, 2 - dest tile is blocked, 3 - no water | ||||
|  | ||||
| 	virtual void showPuzzleMap(){}; | ||||
| 	virtual void viewWorldMap(){}; | ||||
| 	virtual void showMarketWindow(const IMarket *market, const CGHeroInstance *visitor){}; | ||||
| 	virtual void showUniversityWindow(const IMarket *market, const CGHeroInstance *visitor){}; | ||||
| 	virtual void showHillFortWindow(const CGObjectInstance *object, const CGHeroInstance *visitor){}; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user