From 4c0c6e635e87d907e7aacc188953e309cb1ceebf Mon Sep 17 00:00:00 2001 From: Jeffrey Date: Mon, 7 Jan 2013 19:38:23 -0600 Subject: [PATCH 1/4] Fix Vip List sorting Fixes Vip list sorting issues for both alphabetical sorting and online/offline sorting. Fixes Issue #169 Tested in 8.61 --- modules/game_viplist/viplist.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/game_viplist/viplist.lua b/modules/game_viplist/viplist.lua index 911180f6..68fe4c4b 100644 --- a/modules/game_viplist/viplist.lua +++ b/modules/game_viplist/viplist.lua @@ -94,16 +94,17 @@ function onAddVip(id, name, state) local nameLower = name:lower() local childrenCount = vipList:getChildCount() - + for i=1,childrenCount do local child = vipList:getChildByIndex(i) - if state == VipState.Online and not child.vipState == VipState.Online then + if state == VipState.Online and child.vipState ~= VipState.Online then vipList:insertChild(i, label) return end - if (not state == VipState.Online and not child.vipState == VipState.Online) + if (state ~= VipState.Online and child.vipState ~= VipState.Online) or (state == VipState.Online and child.vipState == VipState.Online) then + local childText = child:getText():lower() local length = math.min(childText:len(), nameLower:len()) @@ -113,6 +114,8 @@ function onAddVip(id, name, state) return elseif nameLower:byte(j) > childText:byte(j) then break + elseif j == nameLower:len() then -- We are at the end of nameLower, and its shorter than childText, thus insert before + vipList:insertChild(i, label) end end end From 5921c8e4207a9c7f8818865f2a08ba31b44a27e2 Mon Sep 17 00:00:00 2001 From: Jeffrey Date: Mon, 7 Jan 2013 20:22:32 -0600 Subject: [PATCH 2/4] Fixed Exit button not being created It will now show/hide appropriately instead of not being created and thus throwing errors. --- modules/client_exit/exit.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/client_exit/exit.lua b/modules/client_exit/exit.lua index 14db6b66..2859f1bf 100644 --- a/modules/client_exit/exit.lua +++ b/modules/client_exit/exit.lua @@ -4,8 +4,12 @@ local exitWindow local exitButton function Exit.init() - if not g_game.isOnline() then - exitButton = TopMenu.addRightButton('exitButton', tr('Exit Client'), 'exit.png', Exit.tryExit) + exitButton = TopMenu.addRightButton('exitButton', tr('Exit Client'), 'exit.png', Exit.tryExit) + + if g_game.isOnline() then + exitButton:hide() + else + exitButton:show() end connect(g_game, { From a1f5a88fe71fac27fb907c702724778830f2ce51 Mon Sep 17 00:00:00 2001 From: Jeffrey Date: Mon, 7 Jan 2013 23:09:00 -0600 Subject: [PATCH 3/4] Minor Edits to UIMiniWindow Allow for a double click on the Top Bar of a UIMiniWindow to function the same as pessing the minimize/maximize button. --- .../client_skins/skins/default/styles/miniwindow.otui | 11 +++++++++++ modules/corelib/ui/uiminiwindow.lua | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/modules/client_skins/skins/default/styles/miniwindow.otui b/modules/client_skins/skins/default/styles/miniwindow.otui index 8546eb0c..681e909a 100644 --- a/modules/client_skins/skins/default/styles/miniwindow.otui +++ b/modules/client_skins/skins/default/styles/miniwindow.otui @@ -15,6 +15,17 @@ MiniWindow < UIMiniWindow $on: image-border-bottom: 2 + UIWidget + id: miniwindowTopBar + anchors.top: parent.top + anchors.right: parent.right + anchors.left: parent.left + margin-right: 3 + margin-left: 3 + margin-top: 3 + size: 258 18 + phantom: true + UIButton id: closeButton anchors.top: parent.top diff --git a/modules/corelib/ui/uiminiwindow.lua b/modules/corelib/ui/uiminiwindow.lua index e0b4ddb4..496020eb 100644 --- a/modules/corelib/ui/uiminiwindow.lua +++ b/modules/corelib/ui/uiminiwindow.lua @@ -81,6 +81,15 @@ function UIMiniWindow:setup() self:minimize() end end + + self:getChildById('miniwindowTopBar').onDoubleClick = + function() + if self:isOn() then + self:maximize() + else + self:minimize() + end + end local oldParent = self:getParent() From 52f0b21ea6699df08dc600c74b1145f171d1f32b Mon Sep 17 00:00:00 2001 From: Jeffrey Date: Tue, 8 Jan 2013 00:30:33 -0600 Subject: [PATCH 4/4] Fixed error in the NPC Trade system error message item[1] was user data, so the error message now prints out the item name. --- modules/game_npctrade/npctrade.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/game_npctrade/npctrade.lua b/modules/game_npctrade/npctrade.lua index ee14b83f..040a36a5 100644 --- a/modules/game_npctrade/npctrade.lua +++ b/modules/game_npctrade/npctrade.lua @@ -376,7 +376,7 @@ function onOpenNpcTrade(items) newItem.price = item[5] table.insert(tradeItems[SELL], newItem) else - error("server error: item name " .. item[1] .. " has neither buy or sell price.") + error("server error: item name " .. item[2] .. " has neither buy or sell price.") end end