← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/1733279-ingame-clock into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/1733279-ingame-clock into lp:widelands.

Commit message:
Show in-game clock in release builds too.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1733279 in widelands: "Add in-game clock to release builds"
  https://bugs.launchpad.net/widelands/+bug/1733279

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/1733279-ingame-clock/+merge/343486

Testing: in-game and in-editor for both release builds and debug builds. The only change should be the gametime clock showing up in release build games.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/1733279-ingame-clock into lp:widelands.
=== modified file 'src/wui/interactive_base.cc'
--- src/wui/interactive_base.cc	2018-04-07 16:59:00 +0000
+++ src/wui/interactive_base.cc	2018-04-18 07:52:16 +0000
@@ -428,33 +428,39 @@
 		}
 	}
 
-	// Blit node information when in debug mode.
-	if (get_display_flag(dfDebug) || game == nullptr) {
-		std::string node_text;
-		if (game != nullptr) {
-			const std::string gametime(gametimestring(egbase().get_gametime(), true));
-			std::shared_ptr<const UI::RenderedText> rendered_text =
-			   UI::g_fh1->render(as_condensed(gametime));
-			rendered_text->draw(dst, Vector2i(5, 5));
-
-			static boost::format node_format("(%i, %i)");
-			node_text = as_condensed((node_format % sel_.pos.node.x % sel_.pos.node.y).str());
-		} else {  // This is an editor
-			static boost::format node_format("(%i, %i, %i)");
-			const int32_t height = egbase().map()[sel_.pos.node].get_height();
-			node_text = as_condensed((node_format % sel_.pos.node.x % sel_.pos.node.y % height).str());
-		}
-		std::shared_ptr<const UI::RenderedText> rendered_text = UI::g_fh1->render(node_text);
+	// Node information
+	std::string node_text("");
+	if (game == nullptr) {
+		// Always blit node information in the editor
+		static boost::format node_format("(%i, %i, %i)");
+		const int32_t height = egbase().map()[sel_.pos.node].get_height();
+		node_text = (node_format % sel_.pos.node.x % sel_.pos.node.y % height).str();
+	} else if (get_display_flag(dfDebug)) {
+		// Blit node information for games in debug mode - we're not interested in the height
+		static boost::format node_format("(%i, %i)");
+		node_text = (node_format % sel_.pos.node.x % sel_.pos.node.y).str();
+	}
+	if (!node_text.empty()) {
+		std::shared_ptr<const UI::RenderedText> rendered_text = UI::g_fh1->render(as_condensed(node_text));
 		rendered_text->draw(
-		   dst, Vector2i(get_w() - 5, get_h() - rendered_text->height() - 5), UI::Align::kRight);
+			dst, Vector2i(get_w() - 5, get_h() - rendered_text->height() - 5), UI::Align::kRight);
 	}
 
-	// Blit FPS when playing a game in debug mode.
-	if (get_display_flag(dfDebug) && game != nullptr) {
-		static boost::format fps_format("%5.1f fps (avg: %5.1f fps)");
-		std::shared_ptr<const UI::RenderedText> rendered_text = UI::g_fh1->render(as_condensed(
-		   (fps_format % (1000.0 / frametime_) % (1000.0 / (avg_usframetime_ / 1000))).str()));
-		rendered_text->draw(dst, Vector2i((get_w() - rendered_text->width()) / 2, 5));
+	// In-game clock and FPS
+	if (game != nullptr) {
+		// Blit in-game clock.
+		const std::string gametime(gametimestring(egbase().get_gametime(), true));
+		std::shared_ptr<const UI::RenderedText> rendered_text =
+		   UI::g_fh1->render(as_condensed(gametime));
+		rendered_text->draw(dst, Vector2i(5, 5));
+
+		// Blit FPS when playing a game in debug mode.
+		if (get_display_flag(dfDebug)) {
+			static boost::format fps_format("%5.1f fps (avg: %5.1f fps)");
+			rendered_text = UI::g_fh1->render(as_condensed(
+			   (fps_format % (1000.0 / frametime_) % (1000.0 / (avg_usframetime_ / 1000))).str()));
+			rendered_text->draw(dst, Vector2i((get_w() - rendered_text->width()) / 2, 5));
+		}
 	}
 }
 


Follow ups