reorganize modules

This commit is contained in:
Eduardo Bart
2011-12-05 16:27:07 -02:00
parent ffeb34e0e7
commit cf0aab6d4d
90 changed files with 186 additions and 181 deletions

View File

@@ -0,0 +1,72 @@
Options = {}
-- private variables
local options
local fpsEnabled = false
local vsyncEnabled = false
function getConfig(name, default)
if g_configs.exists(name) then
local val = string.trim(g_configs.get(name))
if val == 'true' or val == 'false' then
return toboolean(val)
else
return val
end
else
if default ~= nil then
g_configs.set(name, default)
return default
else
return nil
end
end
end
function setConfig(name, value)
g_configs.set(name, tostring(value))
end
-- private functions
function Options.enableVsync(on)
vsyncEnabled = on
g_window.setVerticalSync(on)
setConfig('vsync', on)
end
function Options.enableFps(on)
fpsEnabled = on
local frameCounter = UI.root:recursiveGetChildById('frameCounter')
frameCounter:setVisible(on)
setConfig('showfps', on)
end
-- public functions
function Options.create()
options = UI.display('options.otui', { locked = true })
local fpsBox = options:getChildById('fpsCheckBox')
local vsyncBox = options:getChildById('vsyncCheckBox')
fpsBox:setChecked(fpsEnabled)
vsyncBox:setChecked(vsyncEnabled)
fpsBox.onCheckChange = function(self, checked) Options.enableFps(checked) end
vsyncBox.onCheckChange = function(self, checked) Options.enableVsync(checked) end
end
function Options.load()
Options.enableVsync(getConfig('vsync', true))
Options.enableFps(getConfig('showfps', true))
end
function Options.destroy()
options:destroy()
options = nil
end
function Options.openWebpage()
displayErrorBox("Error", "Not implemented yet")
end
addEvent(Options.load)

View File

@@ -0,0 +1,10 @@
Module
name: client_options
description: Create the options window
author: OTClient team
website: https://github.com/edubart/otclient
onLoad: |
require 'options'
return true

View File

@@ -0,0 +1,34 @@
MainWindow
id: optionsWindow
title: Options
size: 286 100
CheckBox
id: vsyncCheckBox
text: Enable vertical synchronization
tooltip: Limits FPS to 60
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
margin-top: 28
margin-left: 18
margin-right: 18
CheckBox
id: fpsCheckBox
text: Show frame rate
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 10
margin-left: 18
margin-right: 18
Button
text: Ok
width: 64
anchors.right: parent.right
anchors.bottom: parent.bottom
margin-right: 10
margin-bottom: 10
@onClick: Options.destroy()