From 5a367cfe2729ac293caa04a18f73985629ac4dd4 Mon Sep 17 00:00:00 2001 From: Henrique Santiago Date: Mon, 27 Aug 2012 04:47:08 -0300 Subject: [PATCH] Some flexibility changes --- modules/client_locales/locales.lua | 4 ++++ modules/corelib/ui/uicombobox.lua | 14 ++++++++++++++ modules/corelib/ui/uiminiwindowcontainer.lua | 16 ++++++++++++---- modules/gamelib/protocollogin.lua | 2 +- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/modules/client_locales/locales.lua b/modules/client_locales/locales.lua index 108eb686..e657160e 100644 --- a/modules/client_locales/locales.lua +++ b/modules/client_locales/locales.lua @@ -143,6 +143,10 @@ function Locales.setLocale(name) return true end +function Locales.getComboBox() + return localeComboBox +end + -- global function used to translate texts function tr(text, ...) if currentLocale then diff --git a/modules/corelib/ui/uicombobox.lua b/modules/corelib/ui/uicombobox.lua index 1b957d4c..ecee16db 100644 --- a/modules/corelib/ui/uicombobox.lua +++ b/modules/corelib/ui/uicombobox.lua @@ -48,6 +48,20 @@ function UIComboBox:addOption(text, data) return index end +function UIComboBox:removeOption(text) + for i,v in ipairs(self.options) do + if v.text == text then + table.remove(self.options, i) + if self.currentIndex == i then + self:setCurrentIndex(1) + elseif self.currentIndex > i then + self.currentIndex = self.currentIndex - 1 + end + return + end + end +end + function UIComboBox:onMousePress(mousePos, mouseButton) local menu = g_ui.createWidget(self:getStyleName() .. 'PopupMenu') menu:setId(self:getId() .. 'PopupMenu') diff --git a/modules/corelib/ui/uiminiwindowcontainer.lua b/modules/corelib/ui/uiminiwindowcontainer.lua index b6c22cac..0ece341c 100644 --- a/modules/corelib/ui/uiminiwindowcontainer.lua +++ b/modules/corelib/ui/uiminiwindowcontainer.lua @@ -13,11 +13,23 @@ function UIMiniWindowContainer:getClassName() return 'UIMiniWindowContainer' end +-- TODO: connect to window onResize event +-- TODO: try to resize another widget? +-- TODO: try to find another panel? function UIMiniWindowContainer:fitAll(noRemoveChild) if not self:isVisible() then return end + if not noRemoveChild then + local children = self:getChildren() + if #children > 0 then + noRemoveChild = children[#children] + else + return + end + end + local sumHeight = 0 local children = self:getChildren() for i=1,#children do @@ -40,10 +52,6 @@ function UIMiniWindowContainer:fitAll(noRemoveChild) addEvent(function() noRemoveChild:setHeight(maximumHeight) end) end - -- TODO: most likely, minimum and maximum size are not set yet, so code above might not work properly. onSetup event - -- TODO: try to resize another widget? - -- TODO: try to find another panel? - -- try to remove no-save widget for i=#children,1,-1 do if sumHeight <= selfHeight then diff --git a/modules/gamelib/protocollogin.lua b/modules/gamelib/protocollogin.lua index 9c2d9764..b6c6686a 100644 --- a/modules/gamelib/protocollogin.lua +++ b/modules/gamelib/protocollogin.lua @@ -80,7 +80,7 @@ function ProtocolLogin:onRecv(msg) elseif opcode == LoginServerMotd then self:parseMotd(msg) elseif opcode == LoginServerUpdateNeeded then - signalcall(self.onError, self, tr("Client needs update.")) + signalcall(self.onError, self, tr("Client needs update. Verify your spr/dat/pic versions.")) elseif opcode == LoginServerCharacterList then self:parseCharacterList(msg) else