tibia-client/modules/client_options/options.lua

90 lines
2.3 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
local optionsTabBar
local options = { vsync = true,
showfps = true,
fullscreen = false,
classicControl = false,
showStatusMessagesInConsole = true,
showEventMessagesInConsole = true,
showInfoMessagesInConsole = true,
showTimestampsInConsole = true,
showLevelsInConsole = true,
2012-04-03 16:18:45 +02:00
showPrivateMessagesInConsole = false }
2012-01-07 18:36:58 +01:00
function Options.init()
-- load options
for k,v in pairs(options) do
if type(v) == 'boolean' then
Settings.setDefault(k, v)
Options.setOption(k, Settings.getBoolean(k))
end
2012-01-06 10:10:55 +01:00
end
2012-01-07 22:19:40 +01:00
Keyboard.bindKeyDown('Ctrl+P', Options.toggle)
2012-01-07 22:19:40 +01:00
optionsWindow = displayUI('options.otui')
optionsWindow:hide()
optionsButton = TopMenu.addLeftButton('optionsButton', 'Options (Ctrl+O)', 'options.png', Options.toggle)
optionsTabBar = optionsWindow:getChildById('optionsTabBar')
optionsTabBar:setContentWidget(optionsWindow:getChildById('optionsTabContent'))
optionsTabBar:addTab('General', loadUI('general.otui'))
optionsTabBar:addTab('Graphics', loadUI('graphics.otui'))
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()
Keyboard.unbindKeyDown('Ctrl+P')
2012-01-07 21:00:07 +01:00
optionsWindow:destroy()
optionsWindow = nil
optionsButton:destroy()
optionsButton = nil
optionsTabBar = nil
2012-02-07 01:41:53 +01:00
Options = nil
2012-01-07 21:00:07 +01:00
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:raise()
optionsWindow:focus()
2012-01-07 21:00:07 +01:00
end
function Options.hide()
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
function Options.setOption(key, value)
2012-01-06 10:10:55 +01:00
if key == 'vsync' then
g_window.setVerticalSync(value)
2012-01-06 10:10:55 +01:00
elseif key == 'showfps' then
2012-01-07 01:18:08 +01:00
addEvent(function()
local frameCounter = rootWidget:recursiveGetChildById('frameCounter')
if frameCounter then frameCounter:setVisible(value) end
2012-01-07 01:18:08 +01:00
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(value)
2012-01-07 01:18:08 +01:00
end)
2012-01-06 10:10:55 +01:00
end
Settings.set(key, value)
options[key] = value
end
function Options.getOption(key)
return options[key]
end