From 62921dee9bff48f44d40c9447602427c6000ba63 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Sat, 2 Mar 2013 17:01:29 -0300 Subject: [PATCH] Fixes in options, hotkeys and viplist --- modules/client_options/audio.otui | 10 +--------- modules/client_options/graphics.otui | 15 +++----------- modules/client_options/options.lua | 29 ++++++++++++++-------------- modules/client_options/options.otui | 5 ++++- modules/corelib/table.lua | 14 ++++++++++++++ modules/corelib/ui/uitabbar.lua | 8 ++++++++ modules/game_console/console.lua | 4 ++++ src/client/game.cpp | 5 +++++ src/framework/ui/uimanager.cpp | 2 ++ src/framework/ui/uitextedit.cpp | 2 +- 10 files changed, 56 insertions(+), 38 deletions(-) diff --git a/modules/client_options/audio.otui b/modules/client_options/audio.otui index c688352b..704f715d 100644 --- a/modules/client_options/audio.otui +++ b/modules/client_options/audio.otui @@ -1,11 +1,3 @@ -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 @@ -26,7 +18,7 @@ Panel local value = modules.client_options.getOption('musicSoundVolume') self:setText(tr('Music volume: %d', value)) - VolumeScrollbar + OptionScrollbar id: musicSoundVolume anchors.left: parent.left anchors.right: parent.right diff --git a/modules/client_options/graphics.otui b/modules/client_options/graphics.otui index c0df08de..f1cddfb6 100644 --- a/modules/client_options/graphics.otui +++ b/modules/client_options/graphics.otui @@ -1,12 +1,3 @@ -FrameRateScrollbar < HorizontalScrollBar - step: 1 - @onValueChange: modules.client_options.setOption(self:getId(), self:getValue()) - @onSetup: | - UIScrollBar.onSetup(self) - local value = modules.client_options.getOption(self:getId()) - if value == 0 then value = self:getMaximum() end - self:setValue(value) - Panel ButtonBox id: opengl1 @@ -65,7 +56,7 @@ Panel self:setText(tr('Game framerate limit: %s', text)) - FrameRateScrollbar + OptionScrollbar id: backgroundFrameRate anchors.left: parent.left anchors.right: parent.right @@ -89,7 +80,7 @@ Panel self:setText(tr('Interface framerate limit: %s', text)) - FrameRateScrollbar + OptionScrollbar id: foregroundFrameRate anchors.left: parent.left anchors.right: parent.right @@ -108,7 +99,7 @@ Panel local value = modules.client_options.getOption('ambientLight') self:setText(tr('Ambient light: %s%%', value)) - FrameRateScrollbar + OptionScrollbar id: ambientLight anchors.left: parent.left anchors.right: parent.right diff --git a/modules/client_options/options.lua b/modules/client_options/options.lua index 0fc0431f..2088b2f5 100644 --- a/modules/client_options/options.lua +++ b/modules/client_options/options.lua @@ -175,7 +175,6 @@ function setOption(key, value, force) if not force and options[key] == value then return end local gameMapPanel = modules.game_interface.getMapPanel() - local panel = nil if key == 'vsync' then g_window.setVerticalSync(value) elseif key == 'showFps' then @@ -184,7 +183,6 @@ function setOption(key, value, force) modules.client_topmenu.setPingVisible(value) elseif key == 'fullscreen' then g_window.setFullscreen(value) - panel = graphicsPanel elseif key == 'enableAudio' then g_sounds.setAudioEnabled(value) if value then @@ -192,7 +190,6 @@ function setOption(key, value, force) else audioButton:setIcon('/images/topbuttons/audio_mute') end - panel = audioPanel elseif key == 'enableMusicSound' then g_sounds.getChannel(SoundChannels.Music):setEnabled(value) elseif key == 'musicSoundVolume' then @@ -201,15 +198,15 @@ function setOption(key, value, force) elseif key == 'showLeftPanel' then modules.game_interface.getLeftPanel():setOn(value) elseif key == 'backgroundFrameRate' then - local text = value - if value <= 0 or value >= 201 then text = 'max' value = 0 end + local text, v = value, value + if value <= 0 or value >= 201 then text = 'max' v = 0 end graphicsPanel:getChildById('backgroundFrameRateLabel'):setText(tr('Game framerate limit: %s', text)) - g_app.setBackgroundPaneMaxFps(value) + g_app.setBackgroundPaneMaxFps(v) elseif key == 'foregroundFrameRate' then - local text = value - if value <= 0 or value >= 61 then text = 'max' value = 0 end + local text, v = value, value + if value <= 0 or value >= 61 then text = 'max' v = 0 end graphicsPanel:getChildById('foregroundFrameRateLabel'):setText(tr('Interface framerate limit: %s', text)) - g_app.setForegroundPaneMaxFps(value) + g_app.setForegroundPaneMaxFps(v) elseif key == 'enableLights' then gameMapPanel:setDrawLights(value and options['ambientLight'] < 100) graphicsPanel:getChildById('ambientLight'):setEnabled(value) @@ -222,20 +219,22 @@ function setOption(key, value, force) g_graphics.selectPainterEngine(value) elseif key == 'displayNames' then gameMapPanel:setDrawNames(value) - panel = generalPanel elseif key == 'displayHealth' then gameMapPanel:setDrawHealthBars(value) - panel = generalPanel elseif key == 'displayText' then gameMapPanel:setDrawTexts(value) - panel = generalPanel end -- change value for keybind updates - if panel then + for _,panel in pairs(optionsTabBar:getTabsPanel()) do local widget = panel:recursiveGetChildById(key) - if widget and widget:getStyle().__class == 'UICheckBox' then - widget:setChecked(value) + if widget then + if widget:getStyle().__class == 'UICheckBox' then + widget:setChecked(value) + elseif widget:getStyle().__class == 'UIScrollBar' then + widget:setValue(value) + end + break end end diff --git a/modules/client_options/options.otui b/modules/client_options/options.otui index 13ead11a..edebbd0d 100644 --- a/modules/client_options/options.otui +++ b/modules/client_options/options.otui @@ -1,6 +1,5 @@ OptionCheckBox < CheckBox @onCheckChange: modules.client_options.setOption(self:getId(), self:isChecked()) - @onSetup: self:setChecked(modules.client_options.getOption(self:getId())) height: 16 $first: @@ -14,6 +13,10 @@ OptionCheckBox < CheckBox anchors.top: prev.bottom margin-top: 2 +OptionScrollbar < HorizontalScrollBar + step: 1 + @onValueChange: modules.client_options.setOption(self:getId(), self:getValue()) + MainWindow id: optionsWindow !text: tr('Options') diff --git a/modules/corelib/table.lua b/modules/corelib/table.lua index 8a7b0d59..d9a56293 100644 --- a/modules/corelib/table.lua +++ b/modules/corelib/table.lua @@ -167,3 +167,17 @@ function table.tostring(t) end return str end + +function table.collect(t, func) + local res = {} + for k,v in pairs(t) do + local a,b = func(k,v) + if a and b then + res[a] = b + elseif a ~= nil then + table.insert(res,a) + end + end + return res +end + diff --git a/modules/corelib/ui/uitabbar.lua b/modules/corelib/ui/uitabbar.lua index f2a5d0ab..c6779fea 100644 --- a/modules/corelib/ui/uitabbar.lua +++ b/modules/corelib/ui/uitabbar.lua @@ -144,3 +144,11 @@ end function UITabBar:getCurrentTab() return self.currentTab end + +function UITabBar:getTabs() + return self.tabs +end + +function UITabBar:getTabsPanel() + return table.collect(self.tabs, function(_,tab) return tab.tabPanel end) +end diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index 456e6f3a..48699082 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -680,6 +680,10 @@ function sendMessage(message, tab) elseif tab.npcChat then speaktypedesc = 'privatePlayerToNpc' elseif tab == violationReportTab then + if violationReportTab.locked then + modules.game_textmessage.displayFailureMessage('Wait for a gamemaster reply.') + return + end speaktypedesc = 'rvrContinue' tabname = tr('Report Rule') .. '...' elseif tab.violationChatName then diff --git a/src/client/game.cpp b/src/client/game.cpp index 6a38bf7f..8fc0a9c9 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -1129,6 +1129,11 @@ void Game::removeVip(int playerId) { if(!canPerformGameAction()) return; + + auto it = m_vips.find(playerId); + if(it == m_vips.end()) + return; + m_vips.erase(it); m_protocolGame->sendRemoveVip(playerId); } diff --git a/src/framework/ui/uimanager.cpp b/src/framework/ui/uimanager.cpp index 0f88e6d9..59953f89 100644 --- a/src/framework/ui/uimanager.cpp +++ b/src/framework/ui/uimanager.cpp @@ -349,11 +349,13 @@ void UIManager::importStyleFromOTML(const OTMLNodePtr& styleNode) OTMLNodePtr oldStyle = m_styles[name]; // Warn about redefined styles + /* if(!g_app.isRunning() && (oldStyle && !oldStyle->valueAt("__unique", false))) { auto it = m_styles.find(name); if(it != m_styles.end()) g_logger.warning(stdext::format("style '%s' is being redefined", name)); } + */ if(!oldStyle || !oldStyle->valueAt("__unique", false) || unique) { OTMLNodePtr originalStyle = getStyle(base); diff --git a/src/framework/ui/uitextedit.cpp b/src/framework/ui/uitextedit.cpp index 28974ca3..f2c8f588 100644 --- a/src/framework/ui/uitextedit.cpp +++ b/src/framework/ui/uitextedit.cpp @@ -41,7 +41,7 @@ UITextEdit::UITextEdit() m_maxLength = 0; m_editable = true; m_selectable = true; - m_autoScroll = false; + m_autoScroll = true; m_changeCursorImage = true; m_selectionReference = 0; m_selectionStart = 0;