diff --git a/game/engines/default/engine/Key.lua b/game/engines/default/engine/Key.lua index 79c639db98f9c5113a7d119789a1ff4a3f29f1a9..62cc552b1df74caa846eaa0c2ef73ea6368e6436 100644 --- a/game/engines/default/engine/Key.lua +++ b/game/engines/default/engine/Key.lua @@ -29,6 +29,18 @@ function _M:init() self.status = {} end +--- Check if we are disabled +function _M:isEnabled() + if not self.disable_until then return true end + if core.game.getTime() < self.disable_until then + if game.log then game.log("#LIGHT_RED#Keyboard input temporarily disabled.") end + return false + else + self.disable_until = nil + return true + end +end + --- Called when a key is pressed -- @number sym a number representing the key, see all the _FOO fields -- @param[type=boolean] ctrl is the control key pressed? @@ -39,6 +51,7 @@ end -- @param[type=boolean] isup true if the key was released, false if pressed -- @string key the unicode representation of the key pressed (without accounting for modifiers) function _M:receiveKey(sym, ctrl, shift, alt, meta, unicode, isup, key) + if not self:isEnabled() then return end self:handleStatus(sym, ctrl, shift, alt, meta, unicode, isup) end diff --git a/game/engines/default/engine/KeyBind.lua b/game/engines/default/engine/KeyBind.lua index ed2bb3f22f3c9f648f43258169122da997a50899..2d80d7fc8ee1a288b9b625c61d35f493b2187a4b 100644 --- a/game/engines/default/engine/KeyBind.lua +++ b/game/engines/default/engine/KeyBind.lua @@ -212,6 +212,7 @@ function _M:formatKeyString(ks) end function _M:receiveKey(sym, ctrl, shift, alt, meta, unicode, isup, key, ismouse) + if not self:isEnabled() then return end if unicode and not self.use_unicode then return end self:handleStatus(sym, ctrl, shift, alt, meta, unicode, isup) diff --git a/game/engines/default/engine/KeyCommand.lua b/game/engines/default/engine/KeyCommand.lua index 31b31ec0a72c440c3126c6a76b6bfe00e9406b9c..4fcfdcbdc32080d72c883eba2b00ce374da8c062 100644 --- a/game/engines/default/engine/KeyCommand.lua +++ b/game/engines/default/engine/KeyCommand.lua @@ -61,6 +61,7 @@ function _M:setupRebootKeys() end function _M:receiveKey(sym, ctrl, shift, alt, meta, unicode, isup, key) + if not self:isEnabled() then return end self:handleStatus(sym, ctrl, shift, alt, meta, unicode, isup) if self.ignore[sym] then return end diff --git a/game/engines/default/engine/Mouse.lua b/game/engines/default/engine/Mouse.lua index 92c67e324c5e42db9c258119d366ce289b74cc84..645a689d7aad58fc5f7b347729c483161e277f67 100644 --- a/game/engines/default/engine/Mouse.lua +++ b/game/engines/default/engine/Mouse.lua @@ -35,6 +35,18 @@ function _M:allowDownEvent(v) self.allow_down = v end +--- Check if we are disabled +function _M:isEnabled() + if not self.disable_until then return true end + if core.game.getTime() < self.disable_until then + if game.log then game.log("#LIGHT_RED#Mouse input temporarily disabled.") end + return false + else + self.disable_until = nil + return true + end +end + --- Called when a mouse is pressed -- @param button -- @param x coordinate of the click @@ -45,6 +57,7 @@ end function _M:receiveMouse(button, x, y, isup, force_name, extra) self.last_pos = { x = x, y = y } self.status[button] = not isup + if not self:isEnabled() then return end if not self.allow_down and not isup then return end if _M.drag then diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index da5c50c6f0de03c3b7b115c2dc75acc5a9576036..2a3f0af184ca9d83e1775feb9f43542ba1518910 100644 --- a/game/modules/tome/class/Player.lua +++ b/game/modules/tome/class/Player.lua @@ -380,6 +380,15 @@ function _M:act() -- Funky shader things ! self:updateMainShader() + if config.settings.tome.life_lost_warning then + local perc = (self.shader_old_life - self.life) / self.max_life + if perc > (config.settings.tome.life_lost_warning / 100) then + game.bignews:say(100, "#LIGHT_RED#LIFE LOST WARNING!") + game.key.disable_until = core.game.getTime() + 2000 + game.mouse.disable_until = core.game.getTime() + 2000 + end + end + self.shader_old_life = self.life self.old_air = self.air self.old_psi = self.psi diff --git a/game/modules/tome/data/zones/gorbat-pride/zone.lua b/game/modules/tome/data/zones/gorbat-pride/zone.lua index 0cdbce9e588721376cbb0dc6ab7f0fafd0f83547..a8d154c19988fe7f538baf66b23fc79be5af752a 100644 --- a/game/modules/tome/data/zones/gorbat-pride/zone.lua +++ b/game/modules/tome/data/zones/gorbat-pride/zone.lua @@ -70,7 +70,7 @@ return { { [1] = { generator = { map = { - up = "UP_WILDERNESS", + ['<'] = "UP_WILDERNESS", }, }, }, }, diff --git a/game/modules/tome/dialogs/GameOptions.lua b/game/modules/tome/dialogs/GameOptions.lua index b4e26831918d159908f12bed399de22e37d1e152..c955181c439add3002ca1552ffe293aa9fd2804b 100644 --- a/game/modules/tome/dialogs/GameOptions.lua +++ b/game/modules/tome/dialogs/GameOptions.lua @@ -482,6 +482,18 @@ function _M:generateListGameplay() end, 1)) end,} + local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"If you loose more than this percentage of life in a turn, a warning will display and all key/mouse input will be ignored for 2 seconds to prevent mistakes.#WHITE#"} + list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Life Lost Warning#WHITE##{normal}#", status=function(item) + return (not config.settings.tome.life_lost_warning or config.settings.tome.life_lost_warning == 100) and "disabled" or tostring(config.settings.tome.life_lost_warning).."%" + end, fct=function(item) + game:registerDialog(GetQuantity.new("Life lost percentage (out of max life)", "From 1 to 99 (100 to disable)", config.settings.tome.life_lost_warning or 100, 100, function(qty) + qty = util.bound(qty, 1, 100) + game:saveSettings("tome.life_lost_warning", ("tome.life_lost_warning = %d\n"):format(qty)) + config.settings.tome.life_lost_warning = qty + self.c_list:drawItem(item) + end, 1)) + end,} + local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Enables or disables weather effects in some zones.\nDisabling it can gain some performance. It will not affect previously visited zones.#WHITE#"} list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Weather effects#WHITE##{normal}#", status=function(item) return tostring(config.settings.tome.weather_effects and "enabled" or "disabled")