Rework options visual

master
Henrique Santiago 11 years ago
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') !text: tr('Enable smart walking')
!tooltip: tr('Will detect when to use diagonal step based on the\nkeys you are pressing') !tooltip: tr('Will detect when to use diagonal step based on the\nkeys you are pressing')
OptionCheckBox //OptionCheckBox
id: walkBooster //id: walkBooster
!text: tr('Enable walk booster') //!text: tr('Enable walk booster')
!tooltip: tr('Also known as dash in tibia community, recommended\nfor playing characters with high speed') //!tooltip: tr('Also known as dash in community, recommended\nfor playing characters with high speed')
OptionCheckBox
id: enableMusic
!text: tr('Enable music')
OptionCheckBox OptionCheckBox
id: showPing id: showPing

@ -8,24 +8,26 @@ FrameRateScrollbar < HorizontalScrollBar
self:setValue(value) self:setValue(value)
Panel Panel
Label ButtonBox
!text: tr('Graphics Engine:') id: opengl1
anchors.left: parent.left anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
text: OpenGL 1
size: 80 20
ButtonBox ButtonBox
id: opengl1 id: opengl2
anchors.left: prev.right anchors.left: prev.right
anchors.verticalCenter: prev.verticalCenter anchors.verticalCenter: prev.verticalCenter
text: OpenGL 1 text: OpenGL 2
size: 80 20 size: 80 20
margin-left: 6 margin-left: 4
ButtonBox ButtonBox
id: opengl2 id: directx9
anchors.left: prev.right anchors.left: prev.right
anchors.verticalCenter: prev.verticalCenter anchors.verticalCenter: prev.verticalCenter
text: OpenGL 2 text: DirectX 9
size: 80 20 size: 80 20
margin-left: 4 margin-left: 4
@ -39,12 +41,17 @@ Panel
!text: tr('Show frame rate') !text: tr('Show frame rate')
OptionCheckBox OptionCheckBox
id: fullscreen id: enableLights
!text: tr('Fullscreen') !text: tr('Enable lights')
OptionCheckBox OptionCheckBox
id: dontStretchShrink id: enableShaders
!text: tr("Don't stretch or shrink Game Window") !text: tr('Enable shader effects')
OptionCheckBox
id: fullscreen
!text: tr('Fullscreen')
tooltip: Ctrl+Shift+F
Label Label
id: backgroundFrameRateLabel id: backgroundFrameRateLabel
@ -52,7 +59,7 @@ Panel
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: prev.bottom anchors.top: prev.bottom
margin-top: 16 margin-top: 6
@onSetup: | @onSetup: |
local value = modules.client_options.getOption('backgroundFrameRate') local value = modules.client_options.getOption('backgroundFrameRate')
local text = value local text = value

@ -1,9 +1,8 @@
local defaultOptions = { local defaultOptions = {
vsync = false, vsync = false,
showFps = true, showFps = false,
showPing = true, showPing = false,
fullscreen = false, fullscreen = false,
dontStretchShrink = false,
classicControl = false, classicControl = false,
walkBooster = false, walkBooster = false,
smartWalk = false, smartWalk = false,
@ -15,38 +14,58 @@ local defaultOptions = {
showLevelsInConsole = true, showLevelsInConsole = true,
showPrivateMessagesInConsole = false, showPrivateMessagesInConsole = false,
showPrivateMessagesOnScreen = true, showPrivateMessagesOnScreen = true,
enableMusic = true,
showLeftPanel = false, showLeftPanel = false,
foregroundFrameRate = 61, foregroundFrameRate = 61,
backgroundFrameRate = 201, 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 optionsWindow
local optionsButton local optionsButton
local optionsTabBar local optionsTabBar
local options = {} local options = {}
local gamePanel local generalPanel
local consolePanel local consolePanel
local graphicsPanel local graphicsPanel
local soundPanel
local audioButton
local function setupGraphicsEngines() local function setupGraphicsEngines()
local enginesRadioGroup = UIRadioGroup.create() local enginesRadioGroup = UIRadioGroup.create()
local ogl1 = graphicsPanel:getChildById('opengl1') local ogl1 = graphicsPanel:getChildById('opengl1')
local ogl2 = graphicsPanel:getChildById('opengl2') local ogl2 = graphicsPanel:getChildById('opengl2')
local dx9 = graphicsPanel:getChildById('directx9')
enginesRadioGroup:addWidget(ogl1) enginesRadioGroup:addWidget(ogl1)
enginesRadioGroup:addWidget(ogl2) enginesRadioGroup:addWidget(ogl2)
enginesRadioGroup:addWidget(dx9)
if g_graphics.getPainterEngine() == 2 then if g_window.getPlatformType() == 'WIN32-EGL' then
enginesRadioGroup:selectWidget(ogl2) enginesRadioGroup:selectWidget(dx9)
ogl1:setEnabled(false)
ogl2:setEnabled(false)
dx9:setEnabled(true)
else else
enginesRadioGroup:selectWidget(ogl1) ogl1:setEnabled(g_graphics.isPainterEngineAvailable(1))
end 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)) if g_app.getOs() ~= 'windows' then
ogl2:setEnabled(g_graphics.isPainterEngineAvailable(2)) dx9:hide()
end
end
enginesRadioGroup.onSelectionChange = function(self, selected) enginesRadioGroup.onSelectionChange = function(self, selected)
if selected == ogl1 then if selected == ogl1 then
@ -60,21 +79,9 @@ local function setupGraphicsEngines()
graphicsPanel:getChildById('foregroundFrameRate'):disable() graphicsPanel:getChildById('foregroundFrameRate'):disable()
graphicsPanel:getChildById('foregroundFrameRateLabel'):disable() graphicsPanel:getChildById('foregroundFrameRateLabel'):disable()
end end
end
function displayWarning(widget, warning) local shadersBox = graphicsPanel:getChildById('enableShaders')
if warningWindow and warningWindow:isVisible() then shadersBox:setEnabled(g_graphics.getPainterEngine() == 2)
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
end end
function init() function init()
@ -88,49 +95,45 @@ function init()
end end
end end
g_keyboard.bindKeyDown('Ctrl+D', function() toggle() end) g_keyboard.bindKeyDown('Ctrl+Shift+F', function() toggleOption('fullscreen') end)
g_keyboard.bindKeyDown('Ctrl+F', function() toggleOption('fullscreen') end) --g_keyboard.bindKeyDown('Ctrl+D', function() toggleOption('walkBooster') end)
g_keyboard.bindKeyDown('Ctrl+Shift+D', function() toggleOption('walkBooster') end)
optionsWindow = g_ui.displayUI('options') optionsWindow = g_ui.displayUI('options')
optionsWindow:hide() 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 = optionsWindow:getChildById('optionsTabBar')
optionsTabBar:setContentWidget(optionsWindow:getChildById('optionsTabContent')) optionsTabBar:setContentWidget(optionsWindow:getChildById('optionsTabContent'))
gamePanel = g_ui.loadUI('game') generalPanel = g_ui.loadUI('game')
optionsTabBar:addTab(tr('Game'), gamePanel) optionsTabBar:addTab(tr('Game'), generalPanel, '/images/optionstab/game')
consolePanel = g_ui.loadUI('console') consolePanel = g_ui.loadUI('console')
optionsTabBar:addTab(tr('Console'), consolePanel) optionsTabBar:addTab(tr('Console'), consolePanel, '/images/optionstab/console')
graphicsPanel = g_ui.loadUI('graphics') graphicsPanel = g_ui.loadUI('graphics')
optionsTabBar:addTab(tr('Graphics'), graphicsPanel) optionsTabBar:addTab(tr('Graphics'), graphicsPanel, '/images/optionstab/graphics')
if g_game.isOfficialTibia() then audioPanel = g_ui.loadUI('audio')
local optionWalkBooster = gamePanel:getChildById('walkBooster') optionsTabBar:addTab(tr('Audio'), audioPanel, '/images/optionstab/audio')
optionWalkBooster.onCheckChange = function(widget)
displayWarning(widget, "This feature could be detectable by official Tibia servers. Would like to continue?") audioButton = modules.client_topmenu.addLeftButton('audioButton', tr('Audio'), '/images/topbuttons/audio', function() toggleOption('enableAudio') end)
setOption(widget:getId(), widget:isChecked())
end
end
setupGraphicsEngines() setupGraphicsEngines()
end end
function terminate() function terminate()
g_keyboard.unbindKeyDown('Ctrl+D') --g_keyboard.unbindKeyDown('Ctrl+D')
g_keyboard.unbindKeyDown('Ctrl+F') g_keyboard.unbindKeyDown('Ctrl+Shift+F')
g_keyboard.unbindKeyDown('Ctrl+Shift+D')
optionsWindow:destroy() optionsWindow:destroy()
optionsWindow = nil optionsWindow = nil
optionsButton:destroy() optionsButton:destroy()
optionsButton = nil optionsButton = nil
optionsTabBar = nil optionsTabBar = nil
gamePanel = nil generalPanel = nil
consolePanel = nil consolePanel = nil
graphicsPanel = nil graphicsPanel = nil
audioPanel = nil
end end
function toggle() function toggle()
@ -152,12 +155,7 @@ function hide()
end end
function toggleOption(key) function toggleOption(key)
local optionWidget = optionsWindow:recursiveGetChildById(key) setOption(key, not getOption(key))
if optionWidget then
optionWidget:setChecked(not getOption(key))
else
setOption(key, not getOption(key))
end
end end
function setOption(key, value) function setOption(key, value)
@ -176,12 +174,22 @@ function setOption(key, value)
end) end)
elseif key == 'fullscreen' then elseif key == 'fullscreen' then
g_window.setFullscreen(value) g_window.setFullscreen(value)
elseif key == 'dontStretchShrink' then elseif key == 'enableAudio' then
g_sounds.setAudioEnabled(value)
addEvent(function() addEvent(function()
modules.game_interface.updateStretchShrink() if value then
audioButton:setIcon('/images/topbuttons/audio')
else
audioButton:setIcon('/images/topbuttons/audio_mute')
end
end) end)
elseif key == 'enableMusic' then elseif key == 'enableMusicSound' then
g_sounds.setAudioEnabled(value) 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 elseif key == 'showLeftPanel' then
addEvent(function() addEvent(function()
modules.game_interface.getLeftPanel():setOn(value) modules.game_interface.getLeftPanel():setOn(value)
@ -208,19 +216,35 @@ function setOption(key, value)
graphicsPanel:getChildById('foregroundFrameRateLabel'):setText(tr('Interface framerate limit: %s', text)) graphicsPanel:getChildById('foregroundFrameRateLabel'):setText(tr('Interface framerate limit: %s', text))
end end
g_app.setForegroundPaneMaxFps(value) 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 elseif key == 'ambientLight' then
addEvent(function() addEvent(function()
local map = rootWidget:recursiveGetChildById('gameMapPanel') local map = modules.game_interface.getMapPanel()
if graphicsPanel then if graphicsPanel then
graphicsPanel:getChildById('ambientLightLabel'):setText(tr('Ambient light: %s%%', value)) graphicsPanel:getChildById('ambientLightLabel'):setText(tr('Ambient light: %s%%', value))
end end
if map then map:setMinimumAmbientLight(value/100)
map:setMinimumAmbientLight(value/100) map:setDrawLights(options['enableLights'] and value < 100)
map:setDrawLights(value < 100)
end
end) end)
elseif key == 'painterEngine' then elseif key == 'painterEngine' then
g_graphics.selectPainterEngine(value) g_graphics.selectPainterEngine(value)
addEvent(function()
if graphicsPanel then
local shadersBox = graphicsPanel:getChildById('enableShaders')
shadersBox:setEnabled(value == 2)
end
end)
end end
g_settings.set(key, value) g_settings.set(key, value)
options[key] = value options[key] = value
@ -230,4 +254,6 @@ function getOption(key)
return options[key] return options[key]
end end
function addTab(name, panel, icon)
optionsTabBar:addTab(name, panel, icon)
end

@ -17,24 +17,24 @@ OptionCheckBox < CheckBox
MainWindow MainWindow
id: optionsWindow id: optionsWindow
!text: tr('Options') !text: tr('Options')
size: 350 310 size: 480 340
@onEnter: modules.client_options.hide() @onEnter: modules.client_options.hide()
@onEscape: modules.client_options.hide() @onEscape: modules.client_options.hide()
TabBarRounded TabBarVertical
id: optionsTabBar id: optionsTabBar
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.bottom: parent.bottom
Panel Panel
id: optionsTabContent id: optionsTabContent
anchors.top: optionsTabBar.bottom anchors.top: optionsTabBar.top
anchors.left: parent.left anchors.left: optionsTabBar.right
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: optionsTabBar.bottom
margin-top: 10 margin-left: 10
Button Button
!text: tr('Ok') !text: tr('Ok')

@ -296,7 +296,7 @@ KeyCodeDescs = {
[KeyNumpad6] = 'Numpad6', [KeyNumpad6] = 'Numpad6',
[KeyNumpad7] = 'Numpad7', [KeyNumpad7] = 'Numpad7',
[KeyNumpad8] = 'Numpad8', [KeyNumpad8] = 'Numpad8',
[KeyNumpad9] = 'Numpad9' [KeyNumpad9] = 'Numpad9',
} }
NetworkMessageTypes = { NetworkMessageTypes = {
@ -307,5 +307,10 @@ NetworkMessageTypes = {
U64 = 5, U64 = 5,
NumberString = 6, NumberString = 6,
String = 7, String = 7,
Table = 8 Table = 8,
}
SoundChannels = {
Music = 1,
Ambient = 2,
} }

Loading…
Cancel
Save