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 = {}
|
Options = {}
|
||||||
|
|
||||||
-- private variables
|
-- public functions
|
||||||
local options
|
function Options.load()
|
||||||
local fpsEnabled = false
|
-- set default settings
|
||||||
local vsyncEnabled = false
|
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)
|
function Options.show()
|
||||||
if g_configs.exists(name) then
|
displayUI('options.otui', { locked = true })
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function setConfig(name, value)
|
function Options.openWebpage()
|
||||||
g_configs.set(name, tostring(value))
|
displayErrorBox("Error", "Not implemented yet")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- private functions
|
-- private functions
|
||||||
function Options.enableVsync(on)
|
function Options.enableVsync(on)
|
||||||
vsyncEnabled = on
|
|
||||||
g_window.setVerticalSync(on)
|
g_window.setVerticalSync(on)
|
||||||
setConfig('vsync', on)
|
Settings.set('vsync', on)
|
||||||
|
Options.vsync = on
|
||||||
end
|
end
|
||||||
|
|
||||||
function Options.enableFps(on)
|
function Options.enableFps(on)
|
||||||
fpsEnabled = on
|
|
||||||
local frameCounter = rootWidget:recursiveGetChildById('frameCounter')
|
local frameCounter = rootWidget:recursiveGetChildById('frameCounter')
|
||||||
frameCounter:setVisible(on)
|
frameCounter:setVisible(on)
|
||||||
setConfig('showfps', on)
|
Settings.set('showfps', on)
|
||||||
end
|
Options.fps = on
|
||||||
|
|
||||||
-- 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
|
|
||||||
end
|
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