Skip to content
Snippets Groups Projects
Commit 4381f7bf authored by DarkGod's avatar DarkGod
Browse files

The game will detect if it was not started sucessfully (up to the main menu)...

The game will detect if it was not started sucessfully (up to the main menu) last time it was run and automatically enable safe mode in this case
parent 8e48c691
No related branches found
No related tags found
No related merge requests found
......@@ -548,6 +548,7 @@ end
--- Called when the game window is moved around
function _M:onWindowMoved(x, y)
config.settings.window.pos = config.settings.window.pos or {}
config.settings.window.pos.x = x
config.settings.window.pos.y = y
self:saveSettings("window_pos", ("window.pos = {x=%d, y=%d}\n"):format(x, y))
......
......@@ -74,6 +74,11 @@ for i, file in ipairs(fs.list("/settings/")) do
end
end
if config.settings.force_safeboot then
util.removeForceSafeBoot()
core.display.forceSafeMode()
end
if core.display.safeMode() then
config.settings.aa_text = false
config.settings.fbo_active = false
......
......@@ -1986,6 +1986,24 @@ function util.browserOpenUrl(url)
return false
end
--- Safeboot mode
function util.setForceSafeBoot()
local restore = fs.getWritePath()
fs.setWritePath(engine.homepath)
local f = fs.open("/settings/force_safeboot.cfg", "w")
if f then
f:write("force_safeboot = true\n")
f:close()
end
if restore then fs.setWritePath(restore) end
end
function util.removeForceSafeBoot()
local restore = fs.getWritePath()
fs.setWritePath(engine.homepath)
fs.delete("/settings/force_safeboot.cfg")
if restore then fs.setWritePath(restore) end
end
-- Ultra weird, this is used by the C serialization code because I'm too dumb to make lua_dump() work on windows ...
function __dump_fct(f)
return string.format("%q", string.dump(f))
......
......@@ -167,6 +167,17 @@ For the same reason the save per level option should not be used unless you have
end
self:grabAddons()
-- We are running fine, remove the flag so that if we crash we will not restart into safe mode
util.removeForceSafeBoot()
if core.display.safeMode() then
Dialog:simpleLongPopup("Safe Mode", [[Oops! Either you activated safe mode manually or the game detected it did not start correctly last time and thus you are in #LIGHT_GREEN#safe mode#WHITE#.
Safe Mode disabled all graphical options and sets a low FPS. It is not advisable to play this way (as it will be very painful and ugly).
Please go to the Video Options and try enabling/disabling options and then restarting until you do not get this message.
A usual problem is shaders and thus should be your first target to disable.]], 700)
end
end
function _M:grabAddons()
......
......@@ -17,6 +17,9 @@
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
-- We are running, set a flag so that if we crash we will restart into safe mode
util.setForceSafeBoot()
-- This file loads the game module, and loads data
local KeyBind = require "engine.KeyBind"
local DamageType = require "engine.DamageType"
......
......@@ -2686,6 +2686,15 @@ static int is_safe_mode(lua_State *L)
return 1;
}
static int set_safe_mode(lua_State *L)
{
safe_mode = TRUE;
fbo_active = FALSE;
shaders_active = FALSE;
multitexture_active = FALSE;
return 0;
}
static int sdl_get_modes_list(lua_State *L)
{
SDL_PixelFormat format;
......@@ -2954,6 +2963,7 @@ static const struct luaL_Reg displaylib[] =
{"drawQuadPart", gl_draw_quad_part},
{"FBOActive", gl_fbo_is_active},
{"safeMode", is_safe_mode},
{"forceSafeMode", set_safe_mode},
{"disableFBO", gl_fbo_disable},
{"drawStringNewSurface", sdl_surface_drawstring_newsurface},
{"drawStringBlendedNewSurface", sdl_surface_drawstring_newsurface_aa},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment