tibia-client/modules/client_options/options.lua

78 lines
2.0 KiB
Lua
Raw Normal View History

Options = {}
2012-01-07 21:00:07 +01:00
local optionsWindow
2012-01-07 18:36:58 +01:00
local optionsButton
function Options.init()
2012-01-07 21:00:07 +01:00
-- load settings
2012-01-06 10:10:55 +01:00
local booleanOptions = { vsync = true,
showfps = true,
2012-01-07 02:48:16 +01:00
fullscreen = false,
classicControl = false,
2012-01-09 00:28:49 +01:00
showStatusMessagesInConsole = true,
showEventMessagesInConsole = true,
showInfoMessagesInConsole = true,
showTimestampsInConsole = true,
showLevelsInConsole = true,
showPrivateMessagesInConsole = true,
}
2012-01-06 09:48:59 +01:00
2012-01-06 10:10:55 +01:00
for k,v in pairs(booleanOptions) do
Settings.setDefault(k, v)
Options.changeOption(k, Settings.getBoolean(k))
end
2012-01-07 22:19:40 +01:00
optionsWindow = displayUI('options.otui')
optionsWindow:setVisible(false)
optionsButton = TopMenu.addButton('settingsButton', 'Options (Ctrl+O)', '/core_styles/icons/settings.png', Options.toggle)
Hotkeys.bind('Ctrl+O', Options.toggle)
2012-01-06 09:48:59 +01:00
end
2011-11-17 01:12:11 +01:00
2012-01-07 21:00:07 +01:00
function Options.terminate()
Hotkeys.unbind('Ctrl+O')
optionsWindow:destroy()
optionsWindow = nil
optionsButton:destroy()
optionsButton = nil
end
function Options.toggle()
if optionsWindow:isVisible() then
Options.hide()
else
Options.show()
end
end
2012-01-06 09:48:59 +01:00
function Options.show()
2012-01-07 21:00:07 +01:00
optionsWindow:show()
optionsWindow:lock()
end
function Options.hide()
optionsWindow:unlock()
optionsWindow:hide()
2011-11-17 01:12:11 +01:00
end
2012-01-06 09:48:59 +01:00
function Options.openWebpage()
displayErrorBox("Error", "Not implemented yet")
2011-11-17 01:12:11 +01:00
end
-- private functions
2012-01-06 10:10:55 +01:00
function Options.changeOption(key, status)
if key == 'vsync' then
g_window.setVerticalSync(status)
elseif key == 'showfps' then
2012-01-07 01:18:08 +01:00
addEvent(function()
local frameCounter = rootWidget:recursiveGetChildById('frameCounter')
if frameCounter then frameCounter:setVisible(status) end
end)
2012-01-06 10:10:55 +01:00
elseif key == 'fullscreen' then
2012-01-07 01:18:08 +01:00
addEvent(function()
g_window.setFullscreen(status)
end)
2012-01-06 10:10:55 +01:00
end
Settings.set(key, status)
Options[key] = status
end