Rework options visual
This commit is contained in:
parent
a144174c41
commit
c982ca81a5
|
@ -0,0 +1,40 @@
|
|||
VolumeScrollbar < HorizontalScrollBar
|
||||
step: 1
|
||||
@onValueChange: modules.client_options.setOption(self:getId(), self:getValue())
|
||||
@onSetup: |
|
||||
UIScrollBar.onSetup(self)
|
||||
local value = modules.client_options.getOption(self:getId())
|
||||
self:setValue(value)
|
||||
|
||||
Panel
|
||||
OptionCheckBox
|
||||
id: enableAudio
|
||||
!text: tr('Enable audio')
|
||||
|
||||
OptionCheckBox
|
||||
id: enableMusicSound
|
||||
!text: tr('Enable music sound')
|
||||
|
||||
OptionCheckBox
|
||||
id: enableEffectsSound
|
||||
!text: tr('Enable effects sound')
|
||||
|
||||
Label
|
||||
id: musicSoundVolumeLabel
|
||||
!text: tr('Music volume: %d', 100)
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 6
|
||||
@onSetup: |
|
||||
local value = modules.client_options.getOption('musicSoundVolume')
|
||||
self:setText(tr('Music volume: %d', value))
|
||||
|
||||
VolumeScrollbar
|
||||
id: musicSoundVolume
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 3
|
||||
minimum: 0
|
||||
maximum: 100
|
|
@ -12,14 +12,10 @@ Panel
|
|||
!text: tr('Enable smart walking')
|
||||
!tooltip: tr('Will detect when to use diagonal step based on the\nkeys you are pressing')
|
||||
|
||||
OptionCheckBox
|
||||
id: walkBooster
|
||||
!text: tr('Enable walk booster')
|
||||
!tooltip: tr('Also known as dash in tibia community, recommended\nfor playing characters with high speed')
|
||||
|
||||
OptionCheckBox
|
||||
id: enableMusic
|
||||
!text: tr('Enable music')
|
||||
//OptionCheckBox
|
||||
//id: walkBooster
|
||||
//!text: tr('Enable walk booster')
|
||||
//!tooltip: tr('Also known as dash in community, recommended\nfor playing characters with high speed')
|
||||
|
||||
OptionCheckBox
|
||||
id: showPing
|
||||
|
|
|
@ -8,18 +8,12 @@ FrameRateScrollbar < HorizontalScrollBar
|
|||
self:setValue(value)
|
||||
|
||||
Panel
|
||||
Label
|
||||
!text: tr('Graphics Engine:')
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
|
||||
ButtonBox
|
||||
id: opengl1
|
||||
anchors.left: prev.right
|
||||
anchors.verticalCenter: prev.verticalCenter
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
text: OpenGL 1
|
||||
size: 80 20
|
||||
margin-left: 6
|
||||
|
||||
ButtonBox
|
||||
id: opengl2
|
||||
|
@ -29,6 +23,14 @@ Panel
|
|||
size: 80 20
|
||||
margin-left: 4
|
||||
|
||||
ButtonBox
|
||||
id: directx9
|
||||
anchors.left: prev.right
|
||||
anchors.verticalCenter: prev.verticalCenter
|
||||
text: DirectX 9
|
||||
size: 80 20
|
||||
margin-left: 4
|
||||
|
||||
OptionCheckBox
|
||||
id: vsync
|
||||
!text: tr('Enable vertical synchronization')
|
||||
|
@ -39,12 +41,17 @@ Panel
|
|||
!text: tr('Show frame rate')
|
||||
|
||||
OptionCheckBox
|
||||
id: fullscreen
|
||||
!text: tr('Fullscreen')
|
||||
id: enableLights
|
||||
!text: tr('Enable lights')
|
||||
|
||||
OptionCheckBox
|
||||
id: dontStretchShrink
|
||||
!text: tr("Don't stretch or shrink Game Window")
|
||||
id: enableShaders
|
||||
!text: tr('Enable shader effects')
|
||||
|
||||
OptionCheckBox
|
||||
id: fullscreen
|
||||
!text: tr('Fullscreen')
|
||||
tooltip: Ctrl+Shift+F
|
||||
|
||||
Label
|
||||
id: backgroundFrameRateLabel
|
||||
|
@ -52,7 +59,7 @@ Panel
|
|||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 16
|
||||
margin-top: 6
|
||||
@onSetup: |
|
||||
local value = modules.client_options.getOption('backgroundFrameRate')
|
||||
local text = value
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
local defaultOptions = {
|
||||
vsync = false,
|
||||
showFps = true,
|
||||
showPing = true,
|
||||
showFps = false,
|
||||
showPing = false,
|
||||
fullscreen = false,
|
||||
dontStretchShrink = false,
|
||||
classicControl = false,
|
||||
walkBooster = false,
|
||||
smartWalk = false,
|
||||
|
@ -15,38 +14,58 @@ local defaultOptions = {
|
|||
showLevelsInConsole = true,
|
||||
showPrivateMessagesInConsole = false,
|
||||
showPrivateMessagesOnScreen = true,
|
||||
enableMusic = true,
|
||||
showLeftPanel = false,
|
||||
foregroundFrameRate = 61,
|
||||
backgroundFrameRate = 201,
|
||||
ambientLight = 15,
|
||||
painterEngine = 0
|
||||
painterEngine = 0,
|
||||
enableAudio = true,
|
||||
enableMusicSound = true,
|
||||
enableShaders = true,
|
||||
musicSoundVolume = 100,
|
||||
enableLights = true,
|
||||
enableShaders = true,
|
||||
ambientLight = 25,
|
||||
enableEffectsSound = 0
|
||||
}
|
||||
|
||||
local warningWindow
|
||||
local optionsWindow
|
||||
local optionsButton
|
||||
local optionsTabBar
|
||||
local options = {}
|
||||
local gamePanel
|
||||
local generalPanel
|
||||
local consolePanel
|
||||
local graphicsPanel
|
||||
local soundPanel
|
||||
local audioButton
|
||||
|
||||
local function setupGraphicsEngines()
|
||||
local enginesRadioGroup = UIRadioGroup.create()
|
||||
local ogl1 = graphicsPanel:getChildById('opengl1')
|
||||
local ogl2 = graphicsPanel:getChildById('opengl2')
|
||||
local dx9 = graphicsPanel:getChildById('directx9')
|
||||
enginesRadioGroup:addWidget(ogl1)
|
||||
enginesRadioGroup:addWidget(ogl2)
|
||||
enginesRadioGroup:addWidget(dx9)
|
||||
|
||||
if g_window.getPlatformType() == 'WIN32-EGL' then
|
||||
enginesRadioGroup:selectWidget(dx9)
|
||||
ogl1:setEnabled(false)
|
||||
ogl2:setEnabled(false)
|
||||
dx9:setEnabled(true)
|
||||
else
|
||||
ogl1:setEnabled(g_graphics.isPainterEngineAvailable(1))
|
||||
ogl2:setEnabled(g_graphics.isPainterEngineAvailable(2))
|
||||
dx9:setEnabled(false)
|
||||
if g_graphics.getPainterEngine() == 2 then
|
||||
enginesRadioGroup:selectWidget(ogl2)
|
||||
else
|
||||
enginesRadioGroup:selectWidget(ogl1)
|
||||
end
|
||||
|
||||
ogl1:setEnabled(g_graphics.isPainterEngineAvailable(1))
|
||||
ogl2:setEnabled(g_graphics.isPainterEngineAvailable(2))
|
||||
if g_app.getOs() ~= 'windows' then
|
||||
dx9:hide()
|
||||
end
|
||||
end
|
||||
|
||||
enginesRadioGroup.onSelectionChange = function(self, selected)
|
||||
if selected == ogl1 then
|
||||
|
@ -60,21 +79,9 @@ local function setupGraphicsEngines()
|
|||
graphicsPanel:getChildById('foregroundFrameRate'):disable()
|
||||
graphicsPanel:getChildById('foregroundFrameRateLabel'):disable()
|
||||
end
|
||||
end
|
||||
|
||||
function displayWarning(widget, warning)
|
||||
if warningWindow and warningWindow:isVisible() then
|
||||
return
|
||||
end
|
||||
if widget:isChecked() then
|
||||
local yesCallback = function() warningWindow:destroy() warningWindow=nil end
|
||||
local noCallback = function() widget:setChecked(false) warningWindow:destroy() warningWindow=nil end
|
||||
|
||||
warningWindow = displayGeneralBox('Warning', tr(warning), {
|
||||
{ text='Yes', callback=yesCallback },
|
||||
{ text='No', callback=noCallback },
|
||||
anchor=AnchorHorizontalCenter}, yesCallback, noCallback)
|
||||
end
|
||||
local shadersBox = graphicsPanel:getChildById('enableShaders')
|
||||
shadersBox:setEnabled(g_graphics.getPainterEngine() == 2)
|
||||
end
|
||||
|
||||
function init()
|
||||
|
@ -88,49 +95,45 @@ function init()
|
|||
end
|
||||
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)
|
||||
g_keyboard.bindKeyDown('Ctrl+Shift+F', function() toggleOption('fullscreen') end)
|
||||
--g_keyboard.bindKeyDown('Ctrl+D', function() toggleOption('walkBooster') end)
|
||||
|
||||
optionsWindow = g_ui.displayUI('options')
|
||||
optionsWindow:hide()
|
||||
optionsButton = modules.client_topmenu.addLeftButton('optionsButton', tr('Options') .. ' (Ctrl+D)', '/images/topbuttons/options', toggle)
|
||||
optionsButton = modules.client_topmenu.addLeftButton('optionsButton', tr('Options'), '/images/topbuttons/options', toggle)
|
||||
|
||||
optionsTabBar = optionsWindow:getChildById('optionsTabBar')
|
||||
optionsTabBar:setContentWidget(optionsWindow:getChildById('optionsTabContent'))
|
||||
|
||||
gamePanel = g_ui.loadUI('game')
|
||||
optionsTabBar:addTab(tr('Game'), gamePanel)
|
||||
generalPanel = g_ui.loadUI('game')
|
||||
optionsTabBar:addTab(tr('Game'), generalPanel, '/images/optionstab/game')
|
||||
|
||||
consolePanel = g_ui.loadUI('console')
|
||||
optionsTabBar:addTab(tr('Console'), consolePanel)
|
||||
optionsTabBar:addTab(tr('Console'), consolePanel, '/images/optionstab/console')
|
||||
|
||||
graphicsPanel = g_ui.loadUI('graphics')
|
||||
optionsTabBar:addTab(tr('Graphics'), graphicsPanel)
|
||||
optionsTabBar:addTab(tr('Graphics'), graphicsPanel, '/images/optionstab/graphics')
|
||||
|
||||
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?")
|
||||
setOption(widget:getId(), widget:isChecked())
|
||||
end
|
||||
end
|
||||
audioPanel = g_ui.loadUI('audio')
|
||||
optionsTabBar:addTab(tr('Audio'), audioPanel, '/images/optionstab/audio')
|
||||
|
||||
audioButton = modules.client_topmenu.addLeftButton('audioButton', tr('Audio'), '/images/topbuttons/audio', function() toggleOption('enableAudio') end)
|
||||
|
||||
setupGraphicsEngines()
|
||||
end
|
||||
|
||||
function terminate()
|
||||
g_keyboard.unbindKeyDown('Ctrl+D')
|
||||
g_keyboard.unbindKeyDown('Ctrl+F')
|
||||
g_keyboard.unbindKeyDown('Ctrl+Shift+D')
|
||||
--g_keyboard.unbindKeyDown('Ctrl+D')
|
||||
g_keyboard.unbindKeyDown('Ctrl+Shift+F')
|
||||
optionsWindow:destroy()
|
||||
optionsWindow = nil
|
||||
optionsButton:destroy()
|
||||
optionsButton = nil
|
||||
optionsTabBar = nil
|
||||
gamePanel = nil
|
||||
generalPanel = nil
|
||||
consolePanel = nil
|
||||
graphicsPanel = nil
|
||||
audioPanel = nil
|
||||
end
|
||||
|
||||
function toggle()
|
||||
|
@ -152,12 +155,7 @@ function hide()
|
|||
end
|
||||
|
||||
function toggleOption(key)
|
||||
local optionWidget = optionsWindow:recursiveGetChildById(key)
|
||||
if optionWidget then
|
||||
optionWidget:setChecked(not getOption(key))
|
||||
else
|
||||
setOption(key, not getOption(key))
|
||||
end
|
||||
end
|
||||
|
||||
function setOption(key, value)
|
||||
|
@ -176,12 +174,22 @@ function setOption(key, value)
|
|||
end)
|
||||
elseif key == 'fullscreen' then
|
||||
g_window.setFullscreen(value)
|
||||
elseif key == 'dontStretchShrink' then
|
||||
addEvent(function()
|
||||
modules.game_interface.updateStretchShrink()
|
||||
end)
|
||||
elseif key == 'enableMusic' then
|
||||
elseif key == 'enableAudio' then
|
||||
g_sounds.setAudioEnabled(value)
|
||||
addEvent(function()
|
||||
if value then
|
||||
audioButton:setIcon('/images/topbuttons/audio')
|
||||
else
|
||||
audioButton:setIcon('/images/topbuttons/audio_mute')
|
||||
end
|
||||
end)
|
||||
elseif key == 'enableMusicSound' then
|
||||
g_sounds.getChannel(SoundChannels.Music):setEnabled(value)
|
||||
elseif key == 'musicSoundVolume' then
|
||||
g_sounds.getChannel(SoundChannels.Music):setGain(value/100)
|
||||
if audioPanel then
|
||||
audioPanel:getChildById('musicSoundVolumeLabel'):setText(tr('Music volume: %d', value))
|
||||
end
|
||||
elseif key == 'showLeftPanel' then
|
||||
addEvent(function()
|
||||
modules.game_interface.getLeftPanel():setOn(value)
|
||||
|
@ -208,19 +216,35 @@ function setOption(key, value)
|
|||
graphicsPanel:getChildById('foregroundFrameRateLabel'):setText(tr('Interface framerate limit: %s', text))
|
||||
end
|
||||
g_app.setForegroundPaneMaxFps(value)
|
||||
elseif key == 'enableLights' then
|
||||
addEvent(function()
|
||||
local map = modules.game_interface.getMapPanel()
|
||||
map:setDrawLights(value and options['ambientLight'] < 100)
|
||||
|
||||
if graphicsPanel then
|
||||
graphicsPanel:getChildById('ambientLight'):setEnabled(value)
|
||||
graphicsPanel:getChildById('ambientLightLabel'):setEnabled(value)
|
||||
end
|
||||
end)
|
||||
elseif key == 'enableShaders' then
|
||||
g_graphics.setShouldUseShaders(value)
|
||||
elseif key == 'ambientLight' then
|
||||
addEvent(function()
|
||||
local map = rootWidget:recursiveGetChildById('gameMapPanel')
|
||||
local map = modules.game_interface.getMapPanel()
|
||||
if graphicsPanel then
|
||||
graphicsPanel:getChildById('ambientLightLabel'):setText(tr('Ambient light: %s%%', value))
|
||||
end
|
||||
if map then
|
||||
map:setMinimumAmbientLight(value/100)
|
||||
map:setDrawLights(value < 100)
|
||||
end
|
||||
map:setDrawLights(options['enableLights'] and value < 100)
|
||||
end)
|
||||
elseif key == 'painterEngine' then
|
||||
g_graphics.selectPainterEngine(value)
|
||||
addEvent(function()
|
||||
if graphicsPanel then
|
||||
local shadersBox = graphicsPanel:getChildById('enableShaders')
|
||||
shadersBox:setEnabled(value == 2)
|
||||
end
|
||||
end)
|
||||
end
|
||||
g_settings.set(key, value)
|
||||
options[key] = value
|
||||
|
@ -230,4 +254,6 @@ function getOption(key)
|
|||
return options[key]
|
||||
end
|
||||
|
||||
|
||||
function addTab(name, panel, icon)
|
||||
optionsTabBar:addTab(name, panel, icon)
|
||||
end
|
||||
|
|
|
@ -17,24 +17,24 @@ OptionCheckBox < CheckBox
|
|||
MainWindow
|
||||
id: optionsWindow
|
||||
!text: tr('Options')
|
||||
size: 350 310
|
||||
size: 480 340
|
||||
|
||||
@onEnter: modules.client_options.hide()
|
||||
@onEscape: modules.client_options.hide()
|
||||
|
||||
TabBarRounded
|
||||
TabBarVertical
|
||||
id: optionsTabBar
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
Panel
|
||||
id: optionsTabContent
|
||||
anchors.top: optionsTabBar.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.top: optionsTabBar.top
|
||||
anchors.left: optionsTabBar.right
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin-top: 10
|
||||
anchors.bottom: optionsTabBar.bottom
|
||||
margin-left: 10
|
||||
|
||||
Button
|
||||
!text: tr('Ok')
|
||||
|
|
|
@ -296,7 +296,7 @@ KeyCodeDescs = {
|
|||
[KeyNumpad6] = 'Numpad6',
|
||||
[KeyNumpad7] = 'Numpad7',
|
||||
[KeyNumpad8] = 'Numpad8',
|
||||
[KeyNumpad9] = 'Numpad9'
|
||||
[KeyNumpad9] = 'Numpad9',
|
||||
}
|
||||
|
||||
NetworkMessageTypes = {
|
||||
|
@ -307,5 +307,10 @@ NetworkMessageTypes = {
|
|||
U64 = 5,
|
||||
NumberString = 6,
|
||||
String = 7,
|
||||
Table = 8
|
||||
Table = 8,
|
||||
}
|
||||
|
||||
SoundChannels = {
|
||||
Music = 1,
|
||||
Ambient = 2,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue