Skip to content
Snippets Groups Projects
Commit f3b952c5 authored by dg's avatar dg
Browse files

Pressing escape on the self target dialog will properly cancel

git-svn-id: http://svn.net-core.org/repos/t-engine4@3004 51575b47-30f0-44d4-a5cc-537603b46e54
parent 62b1651b
No related branches found
No related tags found
No related merge requests found
......@@ -125,7 +125,7 @@ function _M:targetMode(v, msg, co, typ)
end
end
if self.target_warning and self.target.target.x == self.player.x and self.target.target.y == self.player.y then
Dialog:yesnoPopup(type(self.target_warning) == "string" and self.target_warning or "Target yourself?", "Are you sure you want to target yourself?", fct, "No", "Yes")
Dialog:yesnoPopup(type(self.target_warning) == "string" and self.target_warning or "Target yourself?", "Are you sure you want to target yourself?", fct, "No", "Yes", nil, true)
else
fct(false)
end
......
......@@ -77,14 +77,14 @@ function _M:simpleLongPopup(title, text, w, fct, no_leave, force_height)
end
--- Requests a simple yes-no dialog
function _M:yesnoPopup(title, text, fct, yes_text, no_text, no_leave)
function _M:yesnoPopup(title, text, fct, yes_text, no_text, no_leave, escape)
local w, h = self.font:size(text)
local d = new(title, 1, 1)
-- d.key:addBind("EXIT", function() game:unregisterDialog(d) fct(false) end)
local ok = require("engine.ui.Button").new{text=yes_text or "Yes", fct=function() game:unregisterDialog(d) fct(true) end}
local cancel = require("engine.ui.Button").new{text=no_text or "No", fct=function() game:unregisterDialog(d) fct(false) end}
if not no_leave then d.key:addBind("EXIT", function() game:unregisterDialog(d) game:unregisterDialog(d) fct(false) end) end
if not no_leave then d.key:addBind("EXIT", function() game:unregisterDialog(d) game:unregisterDialog(d) fct(escape) end) end
d:loadUI{
{left = 3, top = 3, ui=require("engine.ui.Textzone").new{width=w+20, height=h+5, text=text}},
{left = 3, bottom = 3, ui=ok},
......@@ -98,14 +98,14 @@ function _M:yesnoPopup(title, text, fct, yes_text, no_text, no_leave)
end
--- Requests a long yes-no dialog
function _M:yesnoLongPopup(title, text, w, fct, yes_text, no_text, no_leave)
function _M:yesnoLongPopup(title, text, w, fct, yes_text, no_text, no_leave, escape)
local list = text:splitLines(w - 10, font)
local d = new(title, 1, 1)
-- d.key:addBind("EXIT", function() game:unregisterDialog(d) fct(false) end)
local ok = require("engine.ui.Button").new{text=yes_text or "Yes", fct=function() game:unregisterDialog(d) fct(true) end}
local cancel = require("engine.ui.Button").new{text=no_text or "No", fct=function() game:unregisterDialog(d) fct(false) end}
if not no_leave then d.key:addBind("EXIT", function() game:unregisterDialog(d) game:unregisterDialog(d) fct(false) end) end
if not no_leave then d.key:addBind("EXIT", function() game:unregisterDialog(d) game:unregisterDialog(d) fct(escape) end) end
d:loadUI{
{left = 3, top = 3, ui=require("engine.ui.Textzone").new{width=w+20, height=self.font_h * #list, text=text}},
{left = 3, bottom = 3, ui=ok},
......
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