[Scummvm-git-logs] scummvm master -> e4be1e25dc570154415c29cd6e61c3047c2d1d03

criezy noreply at scummvm.org
Mon Jun 5 19:24:26 UTC 2023


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
a50f64931d AGS: Expose the FPS display option in the game options
e4be1e25dc AGS: Remove std::numeric_limits replacement


Commit: a50f64931dda15347d9f0f300bd0201f5d5df750
    https://github.com/scummvm/scummvm/commit/a50f64931dda15347d9f0f300bd0201f5d5df750
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2023-06-05T20:12:08+01:00

Commit Message:
AGS: Expose the FPS display option in the game options

The option already existed, but required the user to manually edit
the scummvm.ini file. It is now shown in the game options widget.

Changed paths:
    engines/ags/dialogs.cpp


diff --git a/engines/ags/dialogs.cpp b/engines/ags/dialogs.cpp
index 901fb89e470..9cb83fc725b 100644
--- a/engines/ags/dialogs.cpp
+++ b/engines/ags/dialogs.cpp
@@ -49,6 +49,7 @@ private:
 	Common::StringArray _traFileNames;
 
 	GUI::CheckboxWidget *_forceTextAACheckbox;
+	GUI::CheckboxWidget *_displayFPSCheckbox;
 };
 
 AGSOptionsWidget::AGSOptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain) :
@@ -76,6 +77,9 @@ AGSOptionsWidget::AGSOptionsWidget(GuiObject *boss, const Common::String &name,
 
 	// Force font antialiasing
 	_forceTextAACheckbox = new GUI::CheckboxWidget(widgetsBoss(), _dialogLayout + ".textAA", _("Force antialiased text"), _("Use antialiasing to draw text even if the game does not ask for it"));
+
+	// Display fps
+	_displayFPSCheckbox = new GUI::CheckboxWidget(widgetsBoss(), _dialogLayout + ".displayFPS", _("Show FPS"), _("Show the current FPS-rate, while you play."));
 }
 
 void AGSOptionsWidget::defineLayout(GUI::ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const {
@@ -87,6 +91,7 @@ void AGSOptionsWidget::defineLayout(GUI::ThemeEval &layouts, const Common::Strin
 	layouts.addWidget("translation", "PopUp").closeLayout();
 
 	layouts.addWidget("textAA", "Checkbox");
+	layouts.addWidget("displayFPS", "Checkbox");
 
 	layouts.closeLayout().closeDialog();
 }
@@ -116,6 +121,14 @@ void AGSOptionsWidget::load() {
 		if (parseBool(forceTextAA, val))
 			_forceTextAACheckbox->setState(val);
 	}
+
+	Common::String displayFPS;
+	gameConfig->tryGetVal("display_fps", displayFPS);
+	if (!displayFPS.empty()) {
+		bool val;
+		if (parseBool(displayFPS, val))
+			_displayFPSCheckbox->setState(val);
+	}
 }
 
 bool AGSOptionsWidget::save() {
@@ -126,6 +139,7 @@ bool AGSOptionsWidget::save() {
 		ConfMan.removeKey("translation", _domain);
 
 	ConfMan.setBool("force_text_aa", _forceTextAACheckbox->getState(), _domain);
+	ConfMan.setBool("display_fps", _displayFPSCheckbox->getState(), _domain);
 
 	return true;
 }


Commit: e4be1e25dc570154415c29cd6e61c3047c2d1d03
    https://github.com/scummvm/scummvm/commit/e4be1e25dc570154415c29cd6e61c3047c2d1d03
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2023-06-05T20:18:16+01:00

Commit Message:
AGS: Remove std::numeric_limits replacement

As per bc6b225eed3c43c86a5b216a03b087cba082acd5, we can use std::numeric_limits
directly.

Changed paths:
    engines/ags/engine/ac/draw.cpp
    engines/ags/engine/main/game_run.cpp
    engines/ags/globals.cpp
    engines/ags/lib/std/limits.h
    engines/ags/lib/std/math.h


diff --git a/engines/ags/engine/ac/draw.cpp b/engines/ags/engine/ac/draw.cpp
index 7bc938aac11..83733d9ab65 100644
--- a/engines/ags/engine/ac/draw.cpp
+++ b/engines/ags/engine/ac/draw.cpp
@@ -1853,7 +1853,7 @@ void draw_fps(const Rect &viewport) {
 
 	char fps_buffer[60];
 	// Don't display fps if we don't have enough information (because loop count was just reset)
-	if (!std::isUndefined(_G(fps))) {
+	if (!std::isnan(_G(fps))) {
 		snprintf(fps_buffer, sizeof(fps_buffer), "FPS: %2.1f / %s", _G(fps), base_buffer);
 	} else {
 		snprintf(fps_buffer, sizeof(fps_buffer), "FPS: --.- / %s", base_buffer);
diff --git a/engines/ags/engine/main/game_run.cpp b/engines/ags/engine/main/game_run.cpp
index 00a32ef3935..91badc056f9 100644
--- a/engines/ags/engine/main/game_run.cpp
+++ b/engines/ags/engine/main/game_run.cpp
@@ -771,7 +771,7 @@ void set_loop_counter(unsigned int new_counter) {
 	_G(loopcounter) = new_counter;
 	_G(t1) = AGS_Clock::now();
 	_G(lastcounter) = _G(loopcounter);
-	_G(fps) = std::numeric_limits<float>::quiet_undefined();
+	_G(fps) = std::numeric_limits<float>::quiet_NaN();
 }
 
 void UpdateGameOnce(bool checkControls, IDriverDependantBitmap *extraBitmap, int extraX, int extraY) {
diff --git a/engines/ags/globals.cpp b/engines/ags/globals.cpp
index 8904d7f07a7..35388581c0f 100644
--- a/engines/ags/globals.cpp
+++ b/engines/ags/globals.cpp
@@ -154,7 +154,7 @@ Globals::Globals() {
 	_pushbuttonlightcolor = COL253;
 
 	// debug.cpp globals
-	_fps = std::numeric_limits<float>::quiet_undefined();
+	_fps = std::numeric_limits<float>::quiet_NaN();
 	_display_fps = kFPS_Hide;
 	_debug_line = new String[DEBUG_CONSOLE_NUMLINES];
 	_DebugMsgBuff = new std::unique_ptr<AGS::Engine::MessageBuffer>();
diff --git a/engines/ags/lib/std/limits.h b/engines/ags/lib/std/limits.h
index 1f3d930ff04..cac5ac6a011 100644
--- a/engines/ags/lib/std/limits.h
+++ b/engines/ags/lib/std/limits.h
@@ -19,52 +19,16 @@
  *
  */
 
-#include "ags/lib/std/math.h"
-#include "ags/shared/core/types.h"
-
 #ifndef AGS_STD_LIMITS_H
 #define AGS_STD_LIMITS_H
 
+#include "common/scummsys.h"
+
 namespace AGS3 {
 namespace std {
 
-class _Num_base {
-};
-
-template <class _Ty>
-class numeric_limits : public _Num_base {
-public:
-	static constexpr _Ty(min)() {
-		return _Ty();
-	}
-
-	static constexpr _Ty(max)() {
-		return _Ty();
-	}
-};
-
-template <>
-class numeric_limits<float> {
-public:
-	static constexpr float quiet_undefined() {
-		return FLOAT_UNASSIGNED;
-	}
-};
-
-template <>
-class numeric_limits<uint16_t> {
-public:
-	static constexpr uint16_t quiet_undefined() {
-		return 0;
-	}
-
-	static constexpr uint16_t min() {
-		return 0;
-	}
-	static constexpr uint16_t max() {
-		return UINT16_MAX;
-	}
-};
+template<class T>
+using numeric_limits = ::std::numeric_limits<T>;
 
 } // namespace std
 } // namespace AGS3
diff --git a/engines/ags/lib/std/math.h b/engines/ags/lib/std/math.h
index 03f96325b4d..5215c788f3c 100644
--- a/engines/ags/lib/std/math.h
+++ b/engines/ags/lib/std/math.h
@@ -22,22 +22,16 @@
 #ifndef AGS_STD_MATH_H
 #define AGS_STD_MATH_H
 
-#include "common/hashmap.h"
-#include "ags/lib/std/utility.h"
+#include "common/scummsys.h"
 
 namespace AGS3 {
 namespace std {
 
-// Not all platforms define INFINITY
-#ifndef INFINITY
-#define INFINITY   ((float)(1e+300 * 1e+300)) // This must overflow
-#endif
-
-#define FLOAT_UNASSIGNED (float)999999.0
-
+// In scummsys we include <math.h> and not <cmath>
+// Make sure we have isnan in the std namespace.
 template<class T>
-inline bool isUndefined(T val) {
-	return val == FLOAT_UNASSIGNED;
+inline bool isnan(T val) {
+	return ::isnan(val);
 }
 
 } // namespace std




More information about the Scummvm-git-logs mailing list