Browse Source

Fixed recoloring world view panel info icons after current player change;
Refactored ui objects handling in CAdvMapInt to slightly reduce clutter;
Minor other improvements;

Fay 10 năm trước cách đây
mục cha
commit
3823631a57

+ 19 - 29
client/mapHandler.cpp

@@ -547,7 +547,9 @@ void CMapHandler::terrainRectScaled(int3 topTile, const std::vector< std::vector
 {
 	cache.updateWorldViewScale(scale);
 
+	// size of a map tile in pixels given the world view scale
 	int targetTileSize = (int) floorf(32.0f * scale);
+	// number of tiles that fit in the viewport
 	int targetTilesX = (int) ceilf(tilesW / scale) + 1;
 	int targetTilesY = (int) ceilf(tilesH / scale) + 1;
 
@@ -685,7 +687,6 @@ void CMapHandler::terrainRectScaled(int3 topTile, const std::vector< std::vector
 				//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;
@@ -732,21 +733,8 @@ void CMapHandler::terrainRectScaled(int3 topTile, const std::vector< std::vector
 
 					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);
+						// not the case for world view
 
-						//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
 					{
@@ -759,7 +747,8 @@ void CMapHandler::terrainRectScaled(int3 topTile, const std::vector< std::vector
 								break;
 							}
 						}
-						CSDL_Ext::blit8bppAlphaTo24bpp(tb,&pp,extSurf,&sr2);
+						auto scaledSurf = cache.requestWorldViewCacheOrCreate(EMapCacheType::HEROES, (int)tb, tb, scale);
+						CSDL_Ext::blit8bppAlphaTo24bpp(scaledSurf,&pp,extSurf,&sr2);
 
 						//printing flag
 						if(flg
@@ -767,12 +756,18 @@ void CMapHandler::terrainRectScaled(int3 topTile, const std::vector< std::vector
 							&&  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);
+							bufr.x-=2*targetTileSize;
+							bufr.y-=1*targetTileSize;
+							bufr.h = 2 * targetTileSize;
+							bufr.w = 3 * targetTileSize;
+							if(bufr.x-extRect-> x > -targetTileSize * 2)
+							{
+								// flag drawing currently does not work (some color keying issues with scaling)
+
+//								auto baseSurf = (graphics->*flg)[color.getNum()]->ourImages[getHeroFrameNum(dir, false) * 8].bitmap;
+//								auto scaledSurf = cache.requestWorldViewCacheOrCreate(EMapCacheType::HERO_FLAGS, (int)baseSurf, baseSurf, scale);
+//								CSDL_Ext::blitSurface(scaledSurf, nullptr, extSurf, &bufr);
+							}
 						}
 					}
 				}
@@ -796,12 +791,9 @@ void CMapHandler::terrainRectScaled(int3 topTile, const std::vector< std::vector
 	}
 	// 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
+	//blitting Fog of War
 	srx = srx_init;
 
 	for (int bx = topTile.x; bx < topTile.x + targetTilesX; bx++, srx+=targetTileSize)
@@ -824,7 +816,6 @@ void CMapHandler::terrainRectScaled(int3 topTile, const std::vector< std::vector
 			}
 			else
 			{
-				//blitting Fog of War
 				if (pos.x >= 0 &&
 					pos.y >= 0 &&
 					pos.x < sizes.x &&
@@ -838,11 +829,10 @@ void CMapHandler::terrainRectScaled(int3 topTile, const std::vector< std::vector
 					else
 						CSDL_Ext::blitSurface(scaledSurf, &rtile, extSurf, &sr);
 				}
-				//FoW blitted
 			}
 		}
 	}
-	// borders printed
+	//FoW blitted
 
 	SDL_SetClipRect(extSurf, &prevClip); //restoring clip_rect
 }

+ 2 - 2
client/mapHandler.h

@@ -98,7 +98,7 @@ class CMapHandler
 {
 	enum class EMapCacheType
 	{
-		TERRAIN, TERRAIN_CUSTOM, OBJECTS, ROADS, RIVERS, FOW
+		TERRAIN, TERRAIN_CUSTOM, OBJECTS, ROADS, RIVERS, FOW, HEROES, HERO_FLAGS
 	};
 
 	/// temporarily caches rescaled sdl surfaces for map world view redrawing
@@ -112,7 +112,7 @@ class CMapHandler
 		/// 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
+		/// asks for cached data; @returns cached surface or 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);

+ 79 - 0
client/widgets/AdventureMapClasses.cpp

@@ -8,6 +8,7 @@
 
 #include "../CGameInfo.h"
 #include "../CMusicHandler.h"
+#include "../CDefHandler.h"
 #include "../CPlayerInterface.h"
 #include "../CPreGame.h"
 #include "../Graphics.h"
@@ -1213,3 +1214,81 @@ CInGameConsole::CInGameConsole() : prevEntDisp(-1), defaultTimeout(10000), maxDi
 	addUsedEvents(KEYBOARD | TEXTINPUT);
 	#endif
 }
+
+
+CAdvMapPanel::CAdvMapPanel(SDL_Surface * bg, Point position)
+	: CIntObject(),
+	  background(bg)
+{
+//	addUsedEvents(LCLICK | RCLICK | KEYBOARD | HOVER);
+	defActions = 255;
+	recActions = 255;
+	pos.x += position.x;
+	pos.y += position.y;
+}
+
+CAdvMapPanel::~CAdvMapPanel()
+{
+	if (background)
+		SDL_FreeSurface(background);
+}
+
+void CAdvMapPanel::addChildColorableButton(CButton * btn)
+{
+	buttons.push_back(btn);
+	addChildToPanel(btn, ACTIVATE | DEACTIVATE);
+}
+
+void CAdvMapPanel::setPlayerColor(const PlayerColor & clr)
+{
+	for (auto &btn : buttons)
+	{
+		btn->setPlayerColor(clr);
+	}
+}
+
+void CAdvMapPanel::showAll(SDL_Surface * to)
+{
+	if (background)
+		blitAt(background, pos.x, pos.y, to);
+
+	CIntObject::showAll(to);
+}
+
+void CAdvMapPanel::addChildToPanel(CIntObject * obj, ui8 actions /* = 0 */)
+{
+	obj->recActions |= actions | SHOWALL;
+	addChild(obj, false);
+}
+
+CAdvMapWorldViewPanel::CAdvMapWorldViewPanel(SDL_Surface * bg, Point position)
+	: CAdvMapPanel(bg, position)
+{
+
+}
+
+void CAdvMapWorldViewPanel::recolorIcons(const CDefHandler *def, int indexOffset)
+{
+	for (auto &pic : currentIcons)
+	{
+		removeChild(pic);
+		delete pic;
+	}
+	currentIcons.clear();
+
+	for (auto &data : iconsData)
+	{
+		auto pic = new CPicture(def->ourImages[data.first + indexOffset].bitmap, data.second.x, data.second.y, false);
+		pic->recActions |= SHOWALL;
+		currentIcons.push_back(pic);
+		addChildToPanel(pic);
+	}
+}
+
+void CAdvMapWorldViewPanel::addChildIcon(std::pair<int, Point> data, const CDefHandler *def, int indexOffset)
+{
+	iconsData.push_back(data);
+	auto pic = new CPicture(def->ourImages[data.first + indexOffset].bitmap, data.second.x, data.second.y, false);
+	currentIcons.push_back(pic);
+	addChildToPanel(pic);
+}

+ 36 - 1
client/widgets/AdventureMapClasses.h

@@ -71,7 +71,7 @@ protected:
 	 * @param destroy - function for deleting items in listbox
 	 */
 	CList(int size, Point position, std::string btnUp, std::string btnDown, size_t listAmount, int helpUp, int helpDown,
-	      CListBox::CreateFunc create, CListBox::DestroyFunc destroy = CListBox::DestroyFunc());
+		  CListBox::CreateFunc create, CListBox::DestroyFunc destroy = CListBox::DestroyFunc());
 
 	//for selection\deselection
 	CListItem *selected;
@@ -315,6 +315,41 @@ public:
 	void showGameStatus();
 };
 
+/// simple panel that contains other displayable elements; used to separate groups of controls
+class CAdvMapPanel : public CIntObject
+{
+	/// ptrs to child-buttons that can be recolored with setPlayerColor()
+	std::vector<CButton *> buttons;
+	/// the surface passed to this obj will be freed in dtor
+	SDL_Surface * background;
+public:
+	CAdvMapPanel(SDL_Surface * bg, Point position);
+	virtual ~CAdvMapPanel();
+
+	void addChildToPanel(CIntObject * obj, ui8 actions = 0);
+	void addChildColorableButton(CButton * btn);
+	/// recolors all buttons to given player color
+	void setPlayerColor(const PlayerColor & clr);
+
+	void showAll(SDL_Surface * to);
+};
+
+/// specialized version of CAdvMapPanel that handles recolorable def-based pictures for world view info panel
+class CAdvMapWorldViewPanel : public CAdvMapPanel
+{
+	/// data that allows reconstruction of panel info icons
+	std::vector<std::pair<int, Point>> iconsData;
+	/// ptrs to child-pictures constructed from iconsData
+	std::vector<CPicture *> currentIcons;
+public:
+	CAdvMapWorldViewPanel(SDL_Surface * bg, Point position);
+	virtual ~CAdvMapWorldViewPanel(){}
+
+	void addChildIcon(std::pair<int, Point> data, const CDefHandler *def, int indexOffset);
+	/// recreates all pictures from given def to recolor them according to current player color
+	void recolorIcons(const CDefHandler *def, int indexOffset);
+};
+
 class CInGameConsole : public CIntObject
 {
 private:

+ 53 - 98
client/windows/CAdvmapInterface.cpp

@@ -438,7 +438,6 @@ infoBar(Rect(ADVOPT.infoboxX, ADVOPT.infoboxY, 192, 192) )
 	auto makeButton = [&] (int textID, std::function<void()> callback, config::ButtonInfo info, int key) -> CButton *
 	{
 		auto button = new CButton(Point(info.x, info.y), info.defName, CGI->generaltexth->zelp[textID], callback, key, info.playerColoured);
-
 		for (auto image : info.additionalDefs)
 			button->addImage(image);
 		return button;
@@ -455,34 +454,53 @@ 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);
 
+	panelMain = new CAdvMapPanel(nullptr, Point(0, 0));
+	panelWorldView = new CAdvMapWorldViewPanel(bgWorldView, Point(heroList.pos.x - 2, 195)); // TODO correct drawing position
+
+	panelMain->addChildColorableButton(kingOverview);
+	panelMain->addChildColorableButton(underground);
+	panelMain->addChildColorableButton(questlog);
+	panelMain->addChildColorableButton(sleepWake);
+	panelMain->addChildColorableButton(moveHero);
+	panelMain->addChildColorableButton(spellbook);
+	panelMain->addChildColorableButton(advOptions);
+	panelMain->addChildColorableButton(sysOptions);
+	panelMain->addChildColorableButton(nextHero);
+	panelMain->addChildColorableButton(endTurn);
+
+
 	// 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));
+	panelWorldView->addChildToPanel(
+		makeButton(288, std::bind(&CAdvMapInt::fworldViewBack,this), worldViewBackConfig, SDLK_ESCAPE), ACTIVATE | DEACTIVATE);
 
 	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));
+	panelWorldView->addChildToPanel(
+		makeButton(291, std::bind(&CAdvMapInt::fworldViewScale1x,this), worldViewScale1xConfig, SDLK_y), ACTIVATE | DEACTIVATE);
 
 	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));
+	panelWorldView->addChildToPanel(
+		makeButton(291, std::bind(&CAdvMapInt::fworldViewScale2x,this), worldViewScale2xConfig, SDLK_y), ACTIVATE | DEACTIVATE);
 
 	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));
+	panelWorldView->addChildToPanel(
+		makeButton(291, std::bind(&CAdvMapInt::fworldViewScale4x,this), worldViewScale4xConfig, SDLK_y), ACTIVATE | DEACTIVATE);
 
 	config::ButtonInfo worldViewUndergroundConfig = config::ButtonInfo();
 	worldViewUndergroundConfig.defName = "IAM010.DEF";
@@ -491,31 +509,32 @@ infoBar(Rect(ADVOPT.infoboxX, ADVOPT.infoboxY, 192, 192) )
 	worldViewUndergroundConfig.y = 343 + 195;
 	worldViewUndergroundConfig.playerColoured = true;
 	worldViewUnderground = makeButton(294, std::bind(&CAdvMapInt::fworldViewSwitchLevel,this), worldViewUndergroundConfig, SDLK_u);
-	worldViewUIObjects.push_back(worldViewUnderground);
+	panelWorldView->addChildColorableButton(worldViewUnderground);
 
 	setPlayer(LOCPLINT->playerID);
 
 
 	int iconColorMultiplier = player.getNum() * 19;
-	int wvLeft = heroList.pos.x - 2; // TODO correct drawing position?
+	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,
+		panelWorldView->addChildIcon(std::pair<int, Point>(i, Point(wvLeft + 5, 253 + i * 20)), worldViewIconsDef, iconColorMultiplier);
+		panelWorldView->addChildToPanel(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,
+		panelWorldView->addChildIcon(std::pair<int, Point>(i +  5, Point(wvLeft +   5, 377 + i * 20)), worldViewIconsDef, iconColorMultiplier);
+		panelWorldView->addChildIcon(std::pair<int, Point>(i + 12, Point(wvLeft + 160, 377 + i * 20)), worldViewIconsDef, iconColorMultiplier);
+		panelWorldView->addChildToPanel(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,
+	panelWorldView->addChildToPanel(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,
+	panelWorldView->addChildToPanel(new CLabel(wvLeft + 185, 387, EFonts::FONT_SMALL, EAlignment::BOTTOMRIGHT,
 											Colors::WHITE, CGI->generaltexth->allTexts[618]));
 
+	activeMapPanel = panelMain;
 
 	underground->block(!CGI->mh->map->twoLevel);
 	worldViewUnderground->block(!CGI->mh->map->twoLevel);
@@ -525,7 +544,6 @@ infoBar(Rect(ADVOPT.infoboxX, ADVOPT.infoboxY, 192, 192) )
 CAdvMapInt::~CAdvMapInt()
 {
 	SDL_FreeSurface(bg);
-	SDL_FreeSurface(bgWorldView);
 
 	for(int i=0; i<gems.size(); i++)
 		delete gems[i];
@@ -560,6 +578,7 @@ void CAdvMapInt::fworldViewScale4x()
 	changeMode(EAdvMapMode::WORLD_VIEW, 0.6f);
 }
 
+// this method is nearly identical to fswitchLevel, so they could probably be merged
 void CAdvMapInt::fworldViewSwitchLevel()
 {
 	if(!CGI->mh->map->twoLevel)
@@ -567,12 +586,12 @@ void CAdvMapInt::fworldViewSwitchLevel()
 	if (position.z)
 	{
 		position.z--;
-		worldViewUnderground->setIndex(0,false);
+		worldViewUnderground->setIndex(0, true);
 		worldViewUnderground->showAll(screenBuf);
 	}
 	else
 	{
-		worldViewUnderground->setIndex(1,false);
+		worldViewUnderground->setIndex(1, true);
 		position.z++;
 		worldViewUnderground->showAll(screenBuf);
 	}
@@ -748,27 +767,13 @@ void CAdvMapInt::activate()
 	GH.statusbar = &statusbar;
 	if(!duringAITurn)
 	{
+		activeMapPanel->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();
 		terrain.activate();
 		LOCPLINT->cingconsole->activate();
@@ -786,27 +791,13 @@ void CAdvMapInt::deactivate()
 		scrollingDir = 0;
 
 		CCS->curh->changeGraphic(ECursor::ADVENTURE,0);
+		activeMapPanel->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();
 		terrain.deactivate();
 		if(LOCPLINT)
@@ -824,30 +815,17 @@ void CAdvMapInt::showAll(SDL_Surface * 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;
 	}
+	activeMapPanel->showAll(to);
 
 	updateScreen = true;
 	minimap.showAll(to);
@@ -1226,7 +1204,7 @@ void CAdvMapInt::select(const CArmedInstance *sel, bool centerView /*= true*/)
 void CAdvMapInt::mouseMoved( const SDL_MouseMotionEvent & sEvent )
 {
 	// 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
+	// currently disabled 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)
@@ -1279,16 +1257,9 @@ void CAdvMapInt::setPlayer(PlayerColor Player)
 	player = Player;
 	graphics->blueToPlayersAdv(bg,player);
 
-	kingOverview->setPlayerColor(player);
-	underground->setPlayerColor(player);
-	questlog->setPlayerColor(player);
-	sleepWake->setPlayerColor(player);
-	moveHero->setPlayerColor(player);
-	spellbook->setPlayerColor(player);
-	sysOptions->setPlayerColor(player);
-	advOptions->setPlayerColor(player);
-	nextHero->setPlayerColor(player);
-	endTurn->setPlayerColor(player);
+	panelMain->setPlayerColor(player);
+	panelWorldView->setPlayerColor(player);
+	panelWorldView->recolorIcons(worldViewIconsDef, player.getNum() * 19);
 	graphics->blueToPlayersAdv(resdatabar.bg,player);
 
 	//heroList.updateHList();
@@ -1712,7 +1683,7 @@ void CAdvMapInt::adjustActiveness(bool aiTurnStart)
 		activate();
 }
 
-void CAdvMapInt::changeMode(EAdvMapMode newMode, float newScale /* = 0.65f */)
+void CAdvMapInt::changeMode(EAdvMapMode newMode, float newScale /* = 0.4f */)
 {
 	if (mode != newMode)
 	{
@@ -1721,41 +1692,25 @@ void CAdvMapInt::changeMode(EAdvMapMode newMode, float newScale /* = 0.65f */)
 		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();
+			panelMain->activate();
+			panelWorldView->deactivate();
+			activeMapPanel = panelMain;
+
 			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();
+			panelMain->deactivate();
+			panelWorldView->activate();
+
+			activeMapPanel = panelWorldView;
+
 			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;

+ 4 - 2
client/windows/CAdvmapInterface.h

@@ -1,6 +1,5 @@
 #pragma once
 
-#include <client/CDefHandler.h>
 #include "../widgets/AdventureMapClasses.h"
 #include "CWindowObject.h"
 
@@ -136,7 +135,6 @@ public:
 	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;
@@ -144,6 +142,10 @@ public:
 	CTownList townList;
 	CInfoBar infoBar;
 
+	CAdvMapPanel *panelMain; // panel that holds all right-side buttons in normal view
+	CAdvMapWorldViewPanel *panelWorldView; // panel that holds all buttons and other ui in world view
+	CAdvMapPanel *activeMapPanel; // currently active panel (either main or world view, depending on current mode)
+
 	CDefHandler * worldViewIconsDef; // images for world view overlay
 
 	const CSpell *spellBeingCasted; //nullptr if none