mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
Replace highdpi window flag with t.highdpi in love.conf
This commit is contained in:
@@ -65,6 +65,11 @@
|
||||
# include "graphics/Graphics.h"
|
||||
#endif
|
||||
|
||||
// For love::window::setHighDPIAllowed
|
||||
#ifdef LOVE_ENABLE_WINDOW
|
||||
# include "window/Window.h"
|
||||
#endif
|
||||
|
||||
// For love::audio::Audio::setMixWithSystem.
|
||||
#ifdef LOVE_ENABLE_AUDIO
|
||||
# include "audio/Audio.h"
|
||||
@@ -318,6 +323,14 @@ static int w__setGammaCorrect(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int w__setHighDPIAllowed(lua_State *L)
|
||||
{
|
||||
#ifdef LOVE_ENABLE_WINDOW
|
||||
love::window::setHighDPIAllowed((bool) lua_toboolean(L, 1));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int w__setAudioMixWithSystem(lua_State *L)
|
||||
{
|
||||
bool success = false;
|
||||
@@ -395,6 +408,9 @@ int luaopen_love(lua_State *L)
|
||||
lua_pushcfunction(L, w__setGammaCorrect);
|
||||
lua_setfield(L, -2, "_setGammaCorrect");
|
||||
|
||||
lua_pushcfunction(L, w__setHighDPIAllowed);
|
||||
lua_setfield(L, -2, "_setHighDPIAllowed");
|
||||
|
||||
// Exposed here because we need to be able to call it before the audio
|
||||
// module is initialized.
|
||||
lua_pushcfunction(L, w__setAudioMixWithSystem);
|
||||
|
||||
@@ -26,6 +26,18 @@ namespace love
|
||||
namespace window
|
||||
{
|
||||
|
||||
static bool highDPIAllowed = false;
|
||||
|
||||
void setHighDPIAllowed(bool enable)
|
||||
{
|
||||
highDPIAllowed = enable;
|
||||
}
|
||||
|
||||
bool isHighDPIAllowed()
|
||||
{
|
||||
return highDPIAllowed;
|
||||
}
|
||||
|
||||
Window::~Window()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -43,6 +43,10 @@ class Graphics;
|
||||
namespace window
|
||||
{
|
||||
|
||||
// Applied when the window is first created.
|
||||
void setHighDPIAllowed(bool enable);
|
||||
bool isHighDPIAllowed();
|
||||
|
||||
// Forward-declared so it can be used in the class methods. We can't define the
|
||||
// whole thing here because it uses the Window::Type enum.
|
||||
struct WindowSettings;
|
||||
@@ -66,7 +70,7 @@ public:
|
||||
SETTING_BORDERLESS,
|
||||
SETTING_CENTERED,
|
||||
SETTING_DISPLAY,
|
||||
SETTING_HIGHDPI,
|
||||
SETTING_HIGHDPI, // Deprecated
|
||||
SETTING_USE_DPISCALE,
|
||||
SETTING_REFRESHRATE,
|
||||
SETTING_X,
|
||||
@@ -261,7 +265,6 @@ struct WindowSettings
|
||||
bool borderless = false;
|
||||
bool centered = true;
|
||||
int display = 0;
|
||||
bool highdpi = false;
|
||||
bool usedpiscale = true;
|
||||
double refreshrate = 0.0;
|
||||
bool useposition = false;
|
||||
|
||||
@@ -477,7 +477,7 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
if (f.borderless)
|
||||
sdlflags |= SDL_WINDOW_BORDERLESS;
|
||||
|
||||
if (f.highdpi)
|
||||
if (isHighDPIAllowed())
|
||||
sdlflags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
|
||||
int x = f.x;
|
||||
@@ -596,7 +596,8 @@ void Window::updateSettings(const WindowSettings &newsettings, bool updateGraphi
|
||||
|
||||
getPosition(settings.x, settings.y, settings.display);
|
||||
|
||||
settings.highdpi = (wflags & SDL_WINDOW_ALLOW_HIGHDPI) != 0;
|
||||
setHighDPIAllowed((wflags & SDL_WINDOW_ALLOW_HIGHDPI) != 0);
|
||||
|
||||
settings.usedpiscale = newsettings.usedpiscale;
|
||||
|
||||
// Only minimize on focus loss if the window is in exclusive-fullscreen mode
|
||||
|
||||
@@ -75,9 +75,19 @@ static int readWindowSettings(lua_State *L, int idx, WindowSettings &settings)
|
||||
settings.borderless = luax_boolflag(L, idx, settingName(Window::SETTING_BORDERLESS), settings.borderless);
|
||||
settings.centered = luax_boolflag(L, idx, settingName(Window::SETTING_CENTERED), settings.centered);
|
||||
settings.display = luax_intflag(L, idx, settingName(Window::SETTING_DISPLAY), settings.display+1) - 1;
|
||||
settings.highdpi = luax_boolflag(L, idx, settingName(Window::SETTING_HIGHDPI), settings.highdpi);
|
||||
settings.usedpiscale = luax_boolflag(L, idx, settingName(Window::SETTING_USE_DPISCALE), settings.usedpiscale);
|
||||
|
||||
lua_getfield(L, idx, settingName(Window::SETTING_HIGHDPI));
|
||||
if (!lua_isnoneornil(L, -1))
|
||||
{
|
||||
luax_markdeprecated(L, "window.highdpi", API_FIELD, DEPRECATED_REPLACED, "t.highdpi in love.conf");
|
||||
bool highdpi = luax_checkboolean(L, -1);
|
||||
if (!instance()->isOpen())
|
||||
setHighDPIAllowed(highdpi);
|
||||
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_getfield(L, idx, settingName(Window::SETTING_VSYNC));
|
||||
if (lua_isnumber(L, -1))
|
||||
settings.vsync = (int) lua_tointeger(L, -1);
|
||||
@@ -201,9 +211,6 @@ int w_getMode(lua_State *L)
|
||||
lua_pushinteger(L, settings.display + 1);
|
||||
lua_setfield(L, -2, settingName(Window::SETTING_DISPLAY));
|
||||
|
||||
luax_pushboolean(L, settings.highdpi);
|
||||
lua_setfield(L, -2, settingName(Window::SETTING_HIGHDPI));
|
||||
|
||||
luax_pushboolean(L, settings.usedpiscale);
|
||||
lua_setfield(L, -2, settingName(Window::SETTING_USE_DPISCALE));
|
||||
|
||||
@@ -219,6 +226,12 @@ int w_getMode(lua_State *L)
|
||||
return 3;
|
||||
}
|
||||
|
||||
int w_isHighDPIAllowed(lua_State *L)
|
||||
{
|
||||
luax_pushboolean(L, isHighDPIAllowed());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_getDisplayOrientation(lua_State *L)
|
||||
{
|
||||
int displayindex = 0;
|
||||
@@ -618,6 +631,7 @@ static const luaL_Reg functions[] =
|
||||
{ "setMode", w_setMode },
|
||||
{ "updateMode", w_updateMode },
|
||||
{ "getMode", w_getMode },
|
||||
{ "isHighDPIAllowed", w_isHighDPIAllowed },
|
||||
{ "getDisplayOrientation", w_getDisplayOrientation },
|
||||
{ "getFullscreenModes", w_getFullscreenModes },
|
||||
{ "setFullscreen", w_setFullscreen },
|
||||
|
||||
@@ -400,7 +400,6 @@ function love.init()
|
||||
borderless = false,
|
||||
resizable = false,
|
||||
centered = true,
|
||||
highdpi = false,
|
||||
usedpiscale = true,
|
||||
},
|
||||
modules = {
|
||||
@@ -433,6 +432,7 @@ function love.init()
|
||||
externalstorage = false, -- Only relevant for Android.
|
||||
accelerometerjoystick = true, -- Only relevant for Android / iOS.
|
||||
gammacorrect = false,
|
||||
highdpi = false,
|
||||
}
|
||||
|
||||
-- Console hack, part 1.
|
||||
@@ -470,6 +470,10 @@ function love.init()
|
||||
love._setGammaCorrect(c.gammacorrect)
|
||||
end
|
||||
|
||||
if love._setHighDPIAllowed then
|
||||
love._setHighDPIAllowed(c.highdpi)
|
||||
end
|
||||
|
||||
if love._setAudioMixWithSystem then
|
||||
if c.audio and c.audio.mixwithsystem ~= nil then
|
||||
love._setAudioMixWithSystem(c.audio.mixwithsystem)
|
||||
@@ -547,7 +551,7 @@ function love.init()
|
||||
borderless = c.window.borderless,
|
||||
centered = c.window.centered,
|
||||
display = c.window.display,
|
||||
highdpi = c.window.highdpi,
|
||||
highdpi = c.window.highdpi, -- deprecated
|
||||
usedpiscale = c.window.usedpiscale,
|
||||
x = c.window.x,
|
||||
y = c.window.y,
|
||||
|
||||
@@ -808,8 +808,6 @@ const unsigned char boot_lua[] =
|
||||
0x73, 0x65, 0x2c, 0x0a,
|
||||
0x09, 0x09, 0x09, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65,
|
||||
0x2c, 0x0a,
|
||||
0x09, 0x09, 0x09, 0x68, 0x69, 0x67, 0x68, 0x64, 0x70, 0x69, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65,
|
||||
0x2c, 0x0a,
|
||||
0x09, 0x09, 0x09, 0x75, 0x73, 0x65, 0x64, 0x70, 0x69, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0x74,
|
||||
0x72, 0x75, 0x65, 0x2c, 0x0a,
|
||||
0x09, 0x09, 0x7d, 0x2c, 0x0a,
|
||||
@@ -862,6 +860,7 @@ const unsigned char boot_lua[] =
|
||||
0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x20, 0x2f, 0x20, 0x69, 0x4f, 0x53, 0x2e, 0x0a,
|
||||
0x09, 0x09, 0x67, 0x61, 0x6d, 0x6d, 0x61, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x20, 0x3d, 0x20, 0x66,
|
||||
0x61, 0x6c, 0x73, 0x65, 0x2c, 0x0a,
|
||||
0x09, 0x09, 0x68, 0x69, 0x67, 0x68, 0x64, 0x70, 0x69, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x0a,
|
||||
0x09, 0x7d, 0x0a,
|
||||
0x0a,
|
||||
0x09, 0x2d, 0x2d, 0x20, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x20, 0x68, 0x61, 0x63, 0x6b, 0x2c, 0x20,
|
||||
@@ -946,6 +945,12 @@ const unsigned char boot_lua[] =
|
||||
0x63, 0x74, 0x29, 0x0a,
|
||||
0x09, 0x65, 0x6e, 0x64, 0x0a,
|
||||
0x0a,
|
||||
0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x5f, 0x73, 0x65, 0x74, 0x48, 0x69, 0x67, 0x68, 0x44,
|
||||
0x50, 0x49, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a,
|
||||
0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x5f, 0x73, 0x65, 0x74, 0x48, 0x69, 0x67, 0x68, 0x44, 0x50, 0x49,
|
||||
0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x28, 0x63, 0x2e, 0x68, 0x69, 0x67, 0x68, 0x64, 0x70, 0x69, 0x29, 0x0a,
|
||||
0x09, 0x65, 0x6e, 0x64, 0x0a,
|
||||
0x0a,
|
||||
0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x5f, 0x73, 0x65, 0x74, 0x41, 0x75, 0x64, 0x69, 0x6f,
|
||||
0x4d, 0x69, 0x78, 0x57, 0x69, 0x74, 0x68, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a,
|
||||
0x09, 0x09, 0x69, 0x66, 0x20, 0x63, 0x2e, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x63,
|
||||
@@ -1089,7 +1094,8 @@ const unsigned char boot_lua[] =
|
||||
0x09, 0x09, 0x09, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x3d, 0x20, 0x63, 0x2e, 0x77, 0x69, 0x6e,
|
||||
0x64, 0x6f, 0x77, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x2c, 0x0a,
|
||||
0x09, 0x09, 0x09, 0x68, 0x69, 0x67, 0x68, 0x64, 0x70, 0x69, 0x20, 0x3d, 0x20, 0x63, 0x2e, 0x77, 0x69, 0x6e,
|
||||
0x64, 0x6f, 0x77, 0x2e, 0x68, 0x69, 0x67, 0x68, 0x64, 0x70, 0x69, 0x2c, 0x0a,
|
||||
0x64, 0x6f, 0x77, 0x2e, 0x68, 0x69, 0x67, 0x68, 0x64, 0x70, 0x69, 0x2c, 0x20, 0x2d, 0x2d, 0x20, 0x64, 0x65,
|
||||
0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x0a,
|
||||
0x09, 0x09, 0x09, 0x75, 0x73, 0x65, 0x64, 0x70, 0x69, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0x63,
|
||||
0x2e, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x75, 0x73, 0x65, 0x64, 0x70, 0x69, 0x73, 0x63, 0x61, 0x6c,
|
||||
0x65, 0x2c, 0x0a,
|
||||
|
||||
@@ -3274,7 +3274,7 @@ function love.nogame()
|
||||
t.modules.sound = false
|
||||
t.modules.joystick = false
|
||||
t.window.resizable = true
|
||||
t.window.highdpi = true
|
||||
t.highdpi = true
|
||||
|
||||
if love._os == "iOS" then
|
||||
t.window.borderless = true
|
||||
|
||||
@@ -12115,8 +12115,7 @@ const unsigned char nogame_lua[] =
|
||||
0x63, 0x6b, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x0a,
|
||||
0x09, 0x09, 0x74, 0x2e, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x72, 0x65, 0x73, 0x69, 0x7a, 0x61, 0x62,
|
||||
0x6c, 0x65, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65, 0x0a,
|
||||
0x09, 0x09, 0x74, 0x2e, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x68, 0x69, 0x67, 0x68, 0x64, 0x70, 0x69,
|
||||
0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65, 0x0a,
|
||||
0x09, 0x09, 0x74, 0x2e, 0x68, 0x69, 0x67, 0x68, 0x64, 0x70, 0x69, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65, 0x0a,
|
||||
0x0a,
|
||||
0x09, 0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x5f, 0x6f, 0x73, 0x20, 0x3d, 0x3d, 0x20, 0x22,
|
||||
0x69, 0x4f, 0x53, 0x22, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a,
|
||||
|
||||
Reference in New Issue
Block a user