瀏覽代碼

Changed zoom factors to resemble OH3 as closely as possible;
Minor refactoring;

Fay 10 年之前
父節點
當前提交
447119e2f5
共有 4 個文件被更改,包括 21 次插入43 次删除
  1. 1 1
      client/mapHandler.cpp
  2. 2 2
      client/mapHandler.h
  3. 18 39
      client/windows/CAdvmapInterface.cpp
  4. 0 1
      client/windows/CAdvmapInterface.h

+ 1 - 1
client/mapHandler.cpp

@@ -784,7 +784,7 @@ void CMapHandler::terrainRectScaled(int3 topTile, const std::vector< std::vector
 							if(bufr.x-extRect-> x > -targetTileSize * 2)
 							{
 								auto baseSurf = (graphics->*flg)[color.getNum()]->ourImages[getHeroFrameNum(dir, false) * 8].bitmap;
-								auto scaledSurf = cache.requestWorldViewCacheOrCreate(EMapCacheType::HERO_FLAGS, (int)baseSurf, baseSurf, scale);
+								auto scaledSurf = cache.requestWorldViewCacheOrCreate(EMapCacheType::HERO_FLAGS, (intptr_t)baseSurf, baseSurf, scale);
 								CSDL_Ext::blit8bppAlphaTo24bpp(scaledSurf, nullptr, extSurf, &bufr);
 							}
 						}

+ 2 - 2
client/mapHandler.h

@@ -123,8 +123,8 @@ class CMapHandler
 	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);
+							  const std::vector< std::vector< std::vector<ui8> > > * visibilityMap, float scale,
+							  int targetTileSize, int3 top_tile, SDL_Surface * extSurf);
 	void drawScaledRotatedElement(EMapCacheType type, SDL_Surface * baseSurf, SDL_Surface * targetSurf, ui8 rotation,
 								  float scale, SDL_Rect * dstRect, SDL_Rect * srcRect = nullptr);
 	void calculateWorldViewCameraPos(int targetTilesX, int targetTilesY, int3 &top_tile);

+ 18 - 39
client/windows/CAdvmapInterface.cpp

@@ -508,7 +508,7 @@ infoBar(Rect(ADVOPT.infoboxX, ADVOPT.infoboxY, 192, 192) )
 	worldViewUndergroundConfig.x = screen->w - 115;
 	worldViewUndergroundConfig.y = 343 + 195;
 	worldViewUndergroundConfig.playerColoured = true;
-	worldViewUnderground = makeButton(294, std::bind(&CAdvMapInt::fworldViewSwitchLevel,this), worldViewUndergroundConfig, SDLK_u);
+	worldViewUnderground = makeButton(294, std::bind(&CAdvMapInt::fswitchLevel,this), worldViewUndergroundConfig, SDLK_u);
 	panelWorldView->addChildColorableButton(worldViewUnderground);
 
 	setPlayer(LOCPLINT->playerID);
@@ -565,60 +565,39 @@ void CAdvMapInt::fworldViewBack()
 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
+	changeMode(EAdvMapMode::WORLD_VIEW, 0.22f);
 }
 
 void CAdvMapInt::fworldViewScale2x()
 {
-	changeMode(EAdvMapMode::WORLD_VIEW, 0.4f);
+	changeMode(EAdvMapMode::WORLD_VIEW, 0.36f);
 }
 
 void CAdvMapInt::fworldViewScale4x()
 {
-	changeMode(EAdvMapMode::WORLD_VIEW, 0.6f);
+	changeMode(EAdvMapMode::WORLD_VIEW, 0.5f);
 }
 
-// this method is nearly identical to fswitchLevel, so they could probably be merged
-void CAdvMapInt::fworldViewSwitchLevel()
+void CAdvMapInt::fswitchLevel()
 {
-	if(!CGI->mh->map->twoLevel)
+	// with support for future multi-level maps :)
+	int maxLevels = CGI->mh->map->twoLevel ? 2 : 1;
+	if (maxLevels < 2)
 		return;
-	if (position.z)
-	{
-		position.z--;
-		worldViewUnderground->setIndex(0, true);
-		worldViewUnderground->showAll(screenBuf);
-	}
-	else
-	{
-		worldViewUnderground->setIndex(1, true);
-		position.z++;
-		worldViewUnderground->showAll(screenBuf);
-	}
-	updateScreen = true;
-	minimap.setLevel(position.z);
 
-	terrain.redraw();
-}
+	position.z = (position.z + 1) % maxLevels;
+
+	underground->setIndex(position.z, true);
+	underground->redraw();
+
+	worldViewUnderground->setIndex(position.z, true);
+	worldViewUnderground->redraw();
 
-void CAdvMapInt::fswitchLevel()
-{
-	if(!CGI->mh->map->twoLevel)
-		return;
-	if (position.z)
-	{
-		position.z--;
-		underground->setIndex(0,true);
-		underground->showAll(screenBuf);
-	}
-	else
-	{
-		underground->setIndex(1,true);
-		position.z++;
-		underground->showAll(screenBuf);
-	}
 	updateScreen = true;
 	minimap.setLevel(position.z);
+
+	if (mode == EAdvMapMode::WORLD_VIEW)
+		terrain.redraw();
 }
 void CAdvMapInt::fshowQuestlog()
 {

+ 0 - 1
client/windows/CAdvmapInterface.h

@@ -158,7 +158,6 @@ public:
 	void fworldViewScale1x();
 	void fworldViewScale2x();
 	void fworldViewScale4x();
-	void fworldViewSwitchLevel();
 	void fswitchLevel();
 	void fshowQuestlog();
 	void fsleepWake();