1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Show SDL version in the About tab (#16046)

This commit is contained in:
y5nw 2025-04-20 20:20:22 +02:00 committed by GitHub
parent 2bb7ed208c
commit bf15036831
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 3 deletions

View file

@ -16,6 +16,7 @@
#include "IrrCompileConfig.h" #include "IrrCompileConfig.h"
#include "position2d.h" #include "position2d.h"
#include "SColor.h" // video::ECOLOR_FORMAT #include "SColor.h" // video::ECOLOR_FORMAT
#include <string>
#include <variant> #include <variant>
namespace irr namespace irr
@ -332,6 +333,12 @@ public:
used. */ used. */
virtual E_DEVICE_TYPE getType() const = 0; virtual E_DEVICE_TYPE getType() const = 0;
//! Get the version string of the underlying system (e.g. SDL)
virtual std::string getVersionString() const
{
return "";
}
//! Get the display density in dots per inch. //! Get the display density in dots per inch.
//! Returns 0.0f on failure. //! Returns 0.0f on failure.
virtual float getDisplayDensity() const = 0; virtual float getDisplayDensity() const = 0;

View file

@ -109,6 +109,14 @@ public:
return EIDT_SDL; return EIDT_SDL;
} }
//! Get the SDL version
std::string getVersionString() const override
{
SDL_version ver;
SDL_GetVersion(&ver);
return std::to_string(ver.major) + "." + std::to_string(ver.minor) + "." + std::to_string(ver.patch);
}
//! Get the display density in dots per inch. //! Get the display density in dots per inch.
float getDisplayDensity() const override; float getDisplayDensity() const override;

View file

@ -945,8 +945,9 @@ int ModApiMainMenu::l_get_active_renderer(lua_State *L)
/******************************************************************************/ /******************************************************************************/
int ModApiMainMenu::l_get_active_irrlicht_device(lua_State *L) int ModApiMainMenu::l_get_active_irrlicht_device(lua_State *L)
{ {
const char *device_name = [] { auto device = RenderingEngine::get_raw_device();
switch (RenderingEngine::get_raw_device()->getType()) { std::string device_name = [device] {
switch (device->getType()) {
case EIDT_WIN32: return "WIN32"; case EIDT_WIN32: return "WIN32";
case EIDT_X11: return "X11"; case EIDT_X11: return "X11";
case EIDT_OSX: return "OSX"; case EIDT_OSX: return "OSX";
@ -955,7 +956,9 @@ int ModApiMainMenu::l_get_active_irrlicht_device(lua_State *L)
default: return "Unknown"; default: return "Unknown";
} }
}(); }();
lua_pushstring(L, device_name); if (auto version = device->getVersionString(); !version.empty())
device_name.append(" " + version);
lua_pushstring(L, device_name.c_str());
return 1; return 1;
} }