瀏覽代碼

code review

Michael 2 年之前
父節點
當前提交
e3a4c65100
共有 2 個文件被更改,包括 24 次插入12 次删除
  1. 11 11
      client/lobby/SelectionTab.cpp
  2. 13 1
      config/schemas/settings.json

+ 11 - 11
client/lobby/SelectionTab.cpp

@@ -807,7 +807,7 @@ SelectionTab::CMapInfoTooltipBox::CMapInfoTooltipBox(std::string text, ResourceI
 	: CWindowObject(BORDERED | RCLICK_POPUP)
 	: CWindowObject(BORDERED | RCLICK_POPUP)
 {
 {
 	drawPlayerElements = tabType == ESelectionScreen::newGame;
 	drawPlayerElements = tabType == ESelectionScreen::newGame;
-	renderImage = tabType == ESelectionScreen::newGame;
+	renderImage = tabType == ESelectionScreen::newGame && settings["lobby"]["mapPreview"].Bool();
 
 
 	OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
 	OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
 
 
@@ -815,13 +815,16 @@ SelectionTab::CMapInfoTooltipBox::CMapInfoTooltipBox(std::string text, ResourceI
 	if(renderImage)
 	if(renderImage)
 		mapLayerImages = createMinimaps(ResourceID(resource.getName(), EResType::MAP), IMAGE_SIZE);
 		mapLayerImages = createMinimaps(ResourceID(resource.getName(), EResType::MAP), IMAGE_SIZE);
 
 
-	pos = Rect(0, 0, 2*BORDER + IMAGE_SIZE, 2000);
+	pos = Rect(0, 0, 2 * BORDER + IMAGE_SIZE, 2000);
 	if(renderImage && mapLayerImages.size() > 1)
 	if(renderImage && mapLayerImages.size() > 1)
 		pos.w += IMAGE_SIZE + BORDER;
 		pos.w += IMAGE_SIZE + BORDER;
 
 
-	label = std::make_shared<CTextBox>(text, Rect(BORDER, BORDER, pos.w-2*BORDER, 350), 0, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE);
-	if(!label->slider)
-		label->resize(label->label->textSize);
+	auto drawLabel = [&]() {
+		label = std::make_shared<CTextBox>(text, Rect(BORDER, BORDER, pos.w - 2 * BORDER, 350), 0, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE);
+		if(!label->slider)
+			label->resize(label->label->textSize);
+	};
+	drawLabel();
 
 
 	pos.h = BORDER + label->label->textSize.y + BORDER;
 	pos.h = BORDER + label->label->textSize.y + BORDER;
 	if(renderImage)
 	if(renderImage)
@@ -829,16 +832,13 @@ SelectionTab::CMapInfoTooltipBox::CMapInfoTooltipBox(std::string text, ResourceI
 	backgroundTexture = std::make_shared<CFilledTexture>("DIBOXBCK", pos);
 	backgroundTexture = std::make_shared<CFilledTexture>("DIBOXBCK", pos);
 	updateShadow();
 	updateShadow();
 
 
-	// TODO: hacky redraw
-	label = std::make_shared<CTextBox>(text, Rect(BORDER, BORDER, pos.w-2*BORDER, 350), 0, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE);
-	if(!label->slider)
-		label->resize(label->label->textSize);
+	drawLabel();
 
 
 	if(renderImage)
 	if(renderImage)
 	{
 	{
-		image1 = std::make_shared<CPicture>(mapLayerImages[0], Point(BORDER, label->label->textSize.y + 2*BORDER));
+		image1 = std::make_shared<CPicture>(mapLayerImages[0], Point(BORDER, label->label->textSize.y + 2 * BORDER));
 		if(mapLayerImages.size()>1)
 		if(mapLayerImages.size()>1)
-			image2 = std::make_shared<CPicture>(mapLayerImages[1], Point(BORDER + IMAGE_SIZE + BORDER, label->label->textSize.y + 2*BORDER));
+			image2 = std::make_shared<CPicture>(mapLayerImages[1], Point(BORDER + IMAGE_SIZE + BORDER, label->label->textSize.y + 2 * BORDER));
 	}
 	}
 
 
 	center(GH.getCursorPosition()); //center on mouse
 	center(GH.getCursorPosition()); //center on mouse

+ 13 - 1
config/schemas/settings.json

@@ -3,7 +3,7 @@
 {
 {
 	"type" : "object",
 	"type" : "object",
 	"$schema" : "http://json-schema.org/draft-04/schema",
 	"$schema" : "http://json-schema.org/draft-04/schema",
-	"required" : [ "general", "video", "adventure", "battle", "input", "server", "logging", "launcher", "gameTweaks" ],
+	"required" : [ "general", "video", "adventure", "battle", "input", "server", "logging", "launcher", "lobby", "gameTweaks" ],
 	"definitions" : {
 	"definitions" : {
 		"logLevelEnum" : {
 		"logLevelEnum" : {
 			"type" : "string",
 			"type" : "string",
@@ -526,6 +526,18 @@
 				}
 				}
 			}
 			}
 		},
 		},
+		"lobby" : {
+			"type" : "object",
+			"additionalProperties" : false,
+			"default" : {},
+			"required" : [ "mapPreview" ],
+			"properties" : {
+				"mapPreview" : {
+					"type" : "boolean",
+					"default" : true
+				}
+			}
+		},
 		"gameTweaks" : {
 		"gameTweaks" : {
 			"type" : "object",
 			"type" : "object",
 			"default" : {},
 			"default" : {},