parent
0cb5facd7a
commit
028441831d
@ -0,0 +1,14 @@
|
||||
MapEffects = {}
|
||||
|
||||
function MapEffects.init()
|
||||
local box = createWidget('ComboBox')
|
||||
box:moveTo({x=100, y=8})
|
||||
box:addOption('Normal')
|
||||
box:addOption('Bloom')
|
||||
box:addOption('TV')
|
||||
--displayUI(box)
|
||||
end
|
||||
|
||||
function MapEffects.terminate()
|
||||
|
||||
end
|
@ -0,0 +1,16 @@
|
||||
Module
|
||||
name: mapeffects
|
||||
description: Contains experimental shader effects for map
|
||||
author: OTClient team
|
||||
website: https://github.com/edubart/otclient
|
||||
|
||||
// console can be loaded after core
|
||||
autoLoad: true
|
||||
autoLoadPriority: 1000
|
||||
|
||||
onLoad: |
|
||||
require 'mapeffects'
|
||||
MapEffects.init()
|
||||
|
||||
onUnload: |
|
||||
MapEffects.terminate()
|
@ -1,72 +1,34 @@
|
||||
Options = {}
|
||||
|
||||
-- private variables
|
||||
local options
|
||||
local fpsEnabled = false
|
||||
local vsyncEnabled = false
|
||||
-- public functions
|
||||
function Options.load()
|
||||
-- set default settings
|
||||
Settings.setDefault('vsync', true)
|
||||
Settings.setDefault('showfps', true)
|
||||
|
||||
-- load the options
|
||||
Options.enableVsync(Settings.getBoolean('vsync'))
|
||||
Options.enableFps(Settings.getBoolean('showfps'))
|
||||
end
|
||||
|
||||
function getConfig(name, default)
|
||||
if g_configs.exists(name) then
|
||||
local val = g_configs.get(name):trim()
|
||||
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
|
||||
function Options.show()
|
||||
displayUI('options.otui', { locked = true })
|
||||
end
|
||||
|
||||
function setConfig(name, value)
|
||||
g_configs.set(name, tostring(value))
|
||||
function Options.openWebpage()
|
||||
displayErrorBox("Error", "Not implemented yet")
|
||||
end
|
||||
|
||||
-- private functions
|
||||
function Options.enableVsync(on)
|
||||
vsyncEnabled = on
|
||||
g_window.setVerticalSync(on)
|
||||
setConfig('vsync', on)
|
||||
Settings.set('vsync', on)
|
||||
Options.vsync = on
|
||||
end
|
||||
|
||||
function Options.enableFps(on)
|
||||
fpsEnabled = on
|
||||
local frameCounter = rootWidget:recursiveGetChildById('frameCounter')
|
||||
frameCounter:setVisible(on)
|
||||
setConfig('showfps', on)
|
||||
end
|
||||
|
||||
-- public functions
|
||||
function Options.create()
|
||||
options = displayUI('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
|
||||
Settings.set('showfps', on)
|
||||
Options.fps = on
|
||||
end
|
||||
|
||||
function Options.openWebpage()
|
||||
displayErrorBox("Error", "Not implemented yet")
|
||||
end
|
||||
|
||||
addEvent(Options.load)
|
@ -0,0 +1,79 @@
|
||||
Settings = {}
|
||||
|
||||
local function convertSettingValue(value)
|
||||
if type(value) == 'table' then
|
||||
if value.x and value.width then
|
||||
return recttostring(value)
|
||||
elseif value.x then
|
||||
return pointtostring(value)
|
||||
elseif value.width then
|
||||
return sizetostring(value)
|
||||
elseif value.r then
|
||||
return colortostring(value)
|
||||
end
|
||||
else
|
||||
return tostring(value)
|
||||
end
|
||||
end
|
||||
|
||||
function Settings.exists(key)
|
||||
return g_configs.exists(key)
|
||||
end
|
||||
|
||||
function Settings.remove(key)
|
||||
g_configs.remove(key)
|
||||
end
|
||||
|
||||
function Settings.set(key, value)
|
||||
g_configs.set(key, convertSettingValue(value))
|
||||
end
|
||||
|
||||
function Settings.setDefault(key, value)
|
||||
if Settings.exists(key) then return false end
|
||||
Settings.set(key, value)
|
||||
return true
|
||||
end
|
||||
|
||||
function Settings.get(key, default)
|
||||
if Settings.exists(key) then
|
||||
elseif default ~= nil then
|
||||
Settings.set(key, default)
|
||||
end
|
||||
return g_configs.get(key)
|
||||
end
|
||||
|
||||
function Settings.getString(key, default)
|
||||
return Settings.get(key, default)
|
||||
end
|
||||
|
||||
function Settings.getInteger(key, default)
|
||||
return tonumber(Settings.get(key, default))
|
||||
end
|
||||
|
||||
function Settings.getNumber(key, default)
|
||||
return tonumber(Settings.get(key, default))
|
||||
end
|
||||
|
||||
function Settings.getBoolean(key, default)
|
||||
return toboolean(Settings.get(key, default))
|
||||
end
|
||||
|
||||
function Settings.getPoint(key, default)
|
||||
return topoint(Settings.get(key, default))
|
||||
end
|
||||
|
||||
function Settings.getRect(key, default)
|
||||
return torect(Settings.get(key, default))
|
||||
end
|
||||
|
||||
function Settings.getSize(key, default)
|
||||
return tosize(Settings.get(key, default))
|
||||
end
|
||||
|
||||
function Settings.getColor(key, default)
|
||||
return tocolor(Settings.get(key, default))
|
||||
end
|
||||
|
||||
function Settings.getColor(key, default)
|
||||
return tocolor(Settings.get(key, default))
|
||||
end
|
Loading…
Reference in new issue