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

graphical mode menu

git-svn-id: http://svn.net-core.org/repos/t-engine4@481 51575b47-30f0-44d4-a5cc-537603b46e54
parent 17ea4a83
No related branches found
No related tags found
No related merge requests found
......@@ -544,7 +544,14 @@ function _M:setupCommands()
end,
EXIT = function()
local menu = require("engine.dialogs.GameMenu").new{"resume", "keybinds", "resolution", "save", "quit"}
local menu menu = require("engine.dialogs.GameMenu").new{
"resume",
"keybinds",
{"Graphic Mode", function() game:unregisterDialog(menu) game:registerDialog(require("mod.dialogs.GraphicMode").new()) end},
"resolution",
"save",
"quit"
}
self:registerDialog(menu)
end,
......
require "engine.class"
require "engine.Dialog"
module(..., package.seeall, class.inherit(engine.Dialog))
function _M:init()
self:generateList()
engine.Dialog.init(self, "Change graphic mode", 300, #self.list * 30 + 20)
self.sel = 1
self.scroll = 1
self.max = math.floor((self.ih - 5) / self.font_h) - 1
self:keyCommands({
__TEXTINPUT = function(c)
if c:find("^[a-z]$") then
self.sel = util.bound(1 + string.byte(c) - string.byte('a'), 1, #self.list)
self:use()
end
end,
},{
MOVE_UP = function() self.sel = util.boundWrap(self.sel - 1, 1, #self.list) self.scroll = util.scroll(self.sel, self.scroll, self.max) self.changed = true end,
MOVE_DOWN = function() self.sel = util.boundWrap(self.sel + 1, 1, #self.list) self.scroll = util.scroll(self.sel, self.scroll, self.max) self.changed = true end,
ACCEPT = function() self:use() end,
EXIT = function() game:unregisterDialog(self) end,
})
self:mouseZones{
{ x=2, y=5, w=350, h=self.font_h*self.max, fct=function(button, x, y, xrel, yrel, tx, ty)
self.sel = util.bound(self.scroll + math.floor(ty / self.font_h), 1, #self.list)
if button == "left" then self:use()
elseif button == "right" then
end
end },
}
end
function _M:use()
game.gfxmode = self.list[self.sel].mode
game:setupDisplayMode()
game:unregisterDialog(self)
end
function _M:generateList()
local list = {
{name="32x32 Graphical", mode=1},
{name="16x16 Graphical", mode=2},
{name="16x16 ASCII", mode=3},
}
self.list = list
end
function _M:drawDialog(s)
self:drawSelectionList(s, 2, 5, self.font_h, self.list, self.sel, "name", self.scroll, self.max)
end
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