mirror of
https://github.com/edubart/otclient.git
synced 2025-11-30 15:26:49 +01:00
Refactor modules, closes #223
* All modules are sandboxed now * All images,sounds,fonts,translations and styles were moved to "data" folder * Reorganize image files folders * Remove unmaintained modules: client_particles, client_shaders * Implement new automatic way to load styles and fonts * Add hide/show offline option in VipList * Add invite/exclude to/from private channel in players menus * Many other minor changes
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
FrameRateScrollbar < HorizontalScrollBar
|
||||
step: 1
|
||||
@onValueChange: Options.setOption(self:getId(), self:getValue())
|
||||
@onValueChange: modules.client_options.setOption(self:getId(), self:getValue())
|
||||
@onSetup: |
|
||||
UIScrollBar.onSetup(self)
|
||||
local value = Options.getOption(self:getId())
|
||||
local value = modules.client_options.getOption(self:getId())
|
||||
if value == 0 then value = self:getMaximum() end
|
||||
self:setValue(value)
|
||||
|
||||
@@ -54,7 +54,7 @@ Panel
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 16
|
||||
@onSetup: |
|
||||
local value = Options.getOption('backgroundFrameRate')
|
||||
local value = modules.client_options.getOption('backgroundFrameRate')
|
||||
local text = value
|
||||
if value <= 0 or value >= 201 then
|
||||
text = 'max'
|
||||
@@ -78,7 +78,7 @@ Panel
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 6
|
||||
@onSetup: |
|
||||
local value = Options.getOption('foregroundFrameRate')
|
||||
local value = modules.client_options.getOption('foregroundFrameRate')
|
||||
local text = value
|
||||
if value <= 0 or value >= 61 then
|
||||
text = 'max'
|
||||
@@ -102,7 +102,7 @@ Panel
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 6
|
||||
@onSetup: |
|
||||
local value = Options.getOption('ambientLight')
|
||||
local value = modules.client_options.getOption('ambientLight')
|
||||
self:setText(tr('Ambient light: %s%%', value))
|
||||
|
||||
FrameRateScrollbar
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
Options = {}
|
||||
|
||||
local defaultOptions = {
|
||||
vsync = false,
|
||||
showFps = true,
|
||||
@@ -52,9 +50,9 @@ local function setupGraphicsEngines()
|
||||
|
||||
enginesRadioGroup.onSelectionChange = function(self, selected)
|
||||
if selected == ogl1 then
|
||||
Options.setOption('painterEngine', 1)
|
||||
setOption('painterEngine', 1)
|
||||
elseif selected == ogl2 then
|
||||
Options.setOption('painterEngine', 2)
|
||||
setOption('painterEngine', 2)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -79,49 +77,49 @@ function displayWarning(widget, warning)
|
||||
end
|
||||
end
|
||||
|
||||
function Options.init()
|
||||
function init()
|
||||
-- load options
|
||||
for k,v in pairs(defaultOptions) do
|
||||
g_settings.setDefault(k, v)
|
||||
if type(v) == 'boolean' then
|
||||
Options.setOption(k, g_settings.getBoolean(k))
|
||||
setOption(k, g_settings.getBoolean(k))
|
||||
elseif type(v) == 'number' then
|
||||
Options.setOption(k, g_settings.getNumber(k))
|
||||
setOption(k, g_settings.getNumber(k))
|
||||
end
|
||||
end
|
||||
|
||||
g_keyboard.bindKeyDown('Ctrl+D', function() Options.toggle() end)
|
||||
g_keyboard.bindKeyDown('Ctrl+F', function() Options.toggleOption('fullscreen') end)
|
||||
g_keyboard.bindKeyDown('Ctrl+Shift+D', function() Options.toggleOption('walkBooster') end)
|
||||
g_keyboard.bindKeyDown('Ctrl+D', function() toggle() end)
|
||||
g_keyboard.bindKeyDown('Ctrl+F', function() toggleOption('fullscreen') end)
|
||||
g_keyboard.bindKeyDown('Ctrl+Shift+D', function() toggleOption('walkBooster') end)
|
||||
|
||||
optionsWindow = g_ui.displayUI('options.otui')
|
||||
optionsWindow = g_ui.displayUI('options')
|
||||
optionsWindow:hide()
|
||||
optionsButton = TopMenu.addLeftButton('optionsButton', tr('Options') .. ' (Ctrl+D)', 'options.png', Options.toggle)
|
||||
optionsButton = modules.client_topmenu.addLeftButton('optionsButton', tr('Options') .. ' (Ctrl+D)', '/images/topbuttons/options', toggle)
|
||||
|
||||
optionsTabBar = optionsWindow:getChildById('optionsTabBar')
|
||||
optionsTabBar:setContentWidget(optionsWindow:getChildById('optionsTabContent'))
|
||||
|
||||
gamePanel = g_ui.loadUI('game.otui')
|
||||
gamePanel = g_ui.loadUI('game')
|
||||
optionsTabBar:addTab(tr('Game'), gamePanel)
|
||||
|
||||
consolePanel = g_ui.loadUI('console.otui')
|
||||
consolePanel = g_ui.loadUI('console')
|
||||
optionsTabBar:addTab(tr('Console'), consolePanel)
|
||||
|
||||
graphicsPanel = g_ui.loadUI('graphics.otui')
|
||||
graphicsPanel = g_ui.loadUI('graphics')
|
||||
optionsTabBar:addTab(tr('Graphics'), graphicsPanel)
|
||||
|
||||
if g_game.isOfficialTibia() then
|
||||
local optionWalkBooster = gamePanel:getChildById('walkBooster')
|
||||
optionWalkBooster.onCheckChange = function(widget)
|
||||
displayWarning(widget, "This feature could be detectable by official Tibia servers. Would like to continue?")
|
||||
Options.setOption(widget:getId(), widget:isChecked())
|
||||
setOption(widget:getId(), widget:isChecked())
|
||||
end
|
||||
end
|
||||
|
||||
setupGraphicsEngines()
|
||||
end
|
||||
|
||||
function Options.terminate()
|
||||
function terminate()
|
||||
g_keyboard.unbindKeyDown('Ctrl+D')
|
||||
g_keyboard.unbindKeyDown('Ctrl+F')
|
||||
g_keyboard.unbindKeyDown('Ctrl+Shift+D')
|
||||
@@ -133,37 +131,36 @@ function Options.terminate()
|
||||
gamePanel = nil
|
||||
consolePanel = nil
|
||||
graphicsPanel = nil
|
||||
Options = nil
|
||||
end
|
||||
|
||||
function Options.toggle()
|
||||
function toggle()
|
||||
if optionsWindow:isVisible() then
|
||||
Options.hide()
|
||||
hide()
|
||||
else
|
||||
Options.show()
|
||||
show()
|
||||
end
|
||||
end
|
||||
|
||||
function Options.show()
|
||||
function show()
|
||||
optionsWindow:show()
|
||||
optionsWindow:raise()
|
||||
optionsWindow:focus()
|
||||
end
|
||||
|
||||
function Options.hide()
|
||||
function hide()
|
||||
optionsWindow:hide()
|
||||
end
|
||||
|
||||
function Options.toggleOption(key)
|
||||
function toggleOption(key)
|
||||
local optionWidget = optionsWindow:recursiveGetChildById(key)
|
||||
if optionWidget then
|
||||
optionWidget:setChecked(not Options.getOption(key))
|
||||
optionWidget:setChecked(not getOption(key))
|
||||
else
|
||||
Options.setOption(key, not Options.getOption(key))
|
||||
setOption(key, not getOption(key))
|
||||
end
|
||||
end
|
||||
|
||||
function Options.setOption(key, value)
|
||||
function setOption(key, value)
|
||||
if options[key] == value then return end
|
||||
if key == 'vsync' then
|
||||
g_window.setVerticalSync(value)
|
||||
@@ -229,7 +226,7 @@ function Options.setOption(key, value)
|
||||
options[key] = value
|
||||
end
|
||||
|
||||
function Options.getOption(key)
|
||||
function getOption(key)
|
||||
return options[key]
|
||||
end
|
||||
|
||||
|
||||
@@ -3,13 +3,8 @@ Module
|
||||
description: Create the options window
|
||||
author: edubart, BeniS
|
||||
website: www.otclient.info
|
||||
|
||||
dependencies:
|
||||
- client_topmenu
|
||||
|
||||
@onLoad: |
|
||||
dofile 'options'
|
||||
Options.init()
|
||||
|
||||
@onUnload: |
|
||||
Options.terminate()
|
||||
sandboxed: true
|
||||
dependencies: [ client_topmenu ]
|
||||
scripts: [ options ]
|
||||
@onLoad: init()
|
||||
@onUnload: terminate()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
OptionCheckBox < CheckBox
|
||||
@onCheckChange: Options.setOption(self:getId(), self:isChecked())
|
||||
@onSetup: self:setChecked(Options.getOption(self:getId()))
|
||||
@onCheckChange: modules.client_options.setOption(self:getId(), self:isChecked())
|
||||
@onSetup: self:setChecked(modules.client_options.getOption(self:getId()))
|
||||
height: 16
|
||||
|
||||
$first:
|
||||
@@ -19,8 +19,8 @@ MainWindow
|
||||
!text: tr('Options')
|
||||
size: 350 310
|
||||
|
||||
@onEnter: Options.hide()
|
||||
@onEscape: Options.hide()
|
||||
@onEnter: modules.client_options.hide()
|
||||
@onEscape: modules.client_options.hide()
|
||||
|
||||
TabBarRounded
|
||||
id: optionsTabBar
|
||||
@@ -41,4 +41,4 @@ MainWindow
|
||||
width: 64
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
@onClick: Options.hide()
|
||||
@onClick: modules.client_options.hide()
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 660 B |
Reference in New Issue
Block a user