mirror of
https://github.com/edubart/otclient.git
synced 2025-11-30 07:26:49 +01:00
BEAWARE all game functionality is disabled with this commit for a while
* rework client modules * hide main window when loading * remake top menu functions * rework modules autoload * improve path resolving for otml and lua * move core_widgets to core_lib * fix tooltip issues * split some styles * add bit32 lua library * fix assert issues * fix compilation on linux 32 systems * rework gcc compile options * renable and fix some warnings * remove unused constants * speedup sprite cache * move UIGame to lua (not funcional yet) * fix a lot of issues in x11 window * fix crash handler * add some warnings do uiwidget and much more...
This commit is contained in:
@@ -2,29 +2,29 @@ Options = {}
|
||||
|
||||
local optionsWindow
|
||||
local optionsButton
|
||||
local options = { vsync = true,
|
||||
showfps = true,
|
||||
fullscreen = false,
|
||||
classicControl = false,
|
||||
showStatusMessagesInConsole = true,
|
||||
showEventMessagesInConsole = true,
|
||||
showInfoMessagesInConsole = true,
|
||||
showTimestampsInConsole = true,
|
||||
showLevelsInConsole = true,
|
||||
showPrivateMessagesInConsole = true }
|
||||
|
||||
function Options.init()
|
||||
-- load settings
|
||||
local booleanOptions = { vsync = true,
|
||||
showfps = true,
|
||||
fullscreen = false,
|
||||
classicControl = false,
|
||||
showStatusMessagesInConsole = true,
|
||||
showEventMessagesInConsole = true,
|
||||
showInfoMessagesInConsole = true,
|
||||
showTimestampsInConsole = true,
|
||||
showLevelsInConsole = true,
|
||||
showPrivateMessagesInConsole = true,
|
||||
}
|
||||
|
||||
for k,v in pairs(booleanOptions) do
|
||||
Settings.setDefault(k, v)
|
||||
Options.changeOption(k, Settings.getBoolean(k))
|
||||
-- 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
|
||||
end
|
||||
|
||||
optionsWindow = displayUI('options.otui')
|
||||
optionsWindow:setVisible(false)
|
||||
optionsButton = TopMenu.addButton('optionsButton', 'Options (Ctrl+O)', 'options.png', Options.toggle)
|
||||
optionsWindow:hide()
|
||||
optionsButton = TopMenu.addLeftButton('optionsButton', 'Options (Ctrl+O)', 'options.png', Options.toggle)
|
||||
Keyboard.bindKeyDown('Ctrl+O', Options.toggle)
|
||||
end
|
||||
|
||||
@@ -47,11 +47,11 @@ end
|
||||
|
||||
function Options.show()
|
||||
optionsWindow:show()
|
||||
optionsWindow:lock()
|
||||
optionsWindow:raise()
|
||||
optionsWindow:focus()
|
||||
end
|
||||
|
||||
function Options.hide()
|
||||
optionsWindow:unlock()
|
||||
optionsWindow:hide()
|
||||
end
|
||||
|
||||
@@ -59,20 +59,24 @@ function Options.openWebpage()
|
||||
displayErrorBox("Error", "Not implemented yet")
|
||||
end
|
||||
|
||||
-- private functions
|
||||
function Options.changeOption(key, status)
|
||||
function Options.setOption(key, value)
|
||||
if key == 'vsync' then
|
||||
g_window.setVerticalSync(status)
|
||||
g_window.setVerticalSync(value)
|
||||
elseif key == 'showfps' then
|
||||
addEvent(function()
|
||||
local frameCounter = rootWidget:recursiveGetChildById('frameCounter')
|
||||
if frameCounter then frameCounter:setVisible(status) end
|
||||
if frameCounter then frameCounter:setVisible(value) end
|
||||
end)
|
||||
elseif key == 'fullscreen' then
|
||||
addEvent(function()
|
||||
g_window.setFullscreen(status)
|
||||
g_window.setFullscreen(value)
|
||||
end)
|
||||
end
|
||||
Settings.set(key, status)
|
||||
Options[key] = status
|
||||
Settings.set(key, value)
|
||||
options[key] = value
|
||||
end
|
||||
|
||||
function Options.getOption(key)
|
||||
return options[key]
|
||||
end
|
||||
|
||||
|
||||
@@ -3,15 +3,14 @@ Module
|
||||
description: Create the options window
|
||||
author: OTClient team
|
||||
website: https://github.com/edubart/otclient
|
||||
autoload: true
|
||||
autoload-antecedence: 130
|
||||
reloadable: true
|
||||
|
||||
dependencies:
|
||||
- client_topmenu
|
||||
|
||||
onLoad: |
|
||||
@onLoad: |
|
||||
dofile 'options'
|
||||
Options.init()
|
||||
|
||||
onUnload: |
|
||||
@onUnload: |
|
||||
Options.terminate()
|
||||
@@ -1,6 +1,6 @@
|
||||
OptionCheckBox < CheckBox
|
||||
@onCheckChange: Options.changeOption(self:getId(), self:isChecked())
|
||||
@onSetup: self:setChecked(Options[self:getId()])
|
||||
@onCheckChange: Options.setOption(self:getId(), self:isChecked())
|
||||
@onSetup: self:setChecked(Options.getOption(self:getId()))
|
||||
|
||||
$first:
|
||||
anchors.left: parent.left
|
||||
@@ -67,4 +67,4 @@ MainWindow
|
||||
width: 64
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
@onClick: Options.hide()
|
||||
@onClick: Options.hide()
|
||||
|
||||
Reference in New Issue
Block a user