fix warnings and some reloading issues

This commit is contained in:
Eduardo Bart 2012-04-27 01:54:14 -03:00
parent da1baf9673
commit d0b839a4eb
28 changed files with 106 additions and 62 deletions

View File

@ -8,8 +8,8 @@ Module
reloadable: false
load-later:
- client_topmenu
- client_locales
- client_topmenu
- client_background
//- client_about
- client_options

View File

@ -28,7 +28,7 @@ function Locales.init()
Locales.setLocale(defaultLocaleName)
Settings.set('locale', defaultLocaleName)
end
--[[
addEvent( function()
localeComboBox = createWidget('ComboBox', rootWidget:recursiveGetChildById('rightButtonsPanel'))
for key,value in pairs(installedLocales) do
@ -37,6 +37,7 @@ function Locales.init()
localeComboBox:setCurrentOption(currentLocale.languageName)
localeComboBox.onOptionChange = onLocaleComboBoxOptionChange
end, false)
]]--
end
function Locales.terminate()

View File

@ -182,6 +182,7 @@ locale = {
["You are burning"] = "Você está queimando",
["You are cursed"] = "Você está amaldiçoado",
["You are dazzled"] = "Você está deslumbrado",
["You are dead."] = "Você está morto.",
["You are drowing"] = "Você está se afogando",
["You are electrified"] = "Você está eletrificado",
["You are freezing"] = "Você está congelando",

View File

@ -177,19 +177,19 @@ function Terminal.hide()
end
function Terminal.addLine(text, color)
-- create new line label
local numLines = terminalBuffer:getChildCount() + 1
local label = createWidget('TerminalLabel', terminalBuffer)
label:setId('terminalLabel' .. numLines)
label:setText(text)
label:setColor(color)
-- delete old lines if needed
local numLines = terminalBuffer:getChildCount() + 1
if numLines > MaxLogLines then
terminalBuffer:getChildByIndex(1):destroy()
else
terminalBuffer:setHeight(terminalBuffer:getHeight() + LabelHeight)
end
-- create new line label
local label = createWidget('TerminalLabel', terminalBuffer)
label:setId('terminalLabel' .. numLines)
label:setText(text)
label:setColor(color)
end
function Terminal.executeCommand(command)

View File

@ -8,7 +8,7 @@ end
local function tabBlink(tab)
if not tab.blinking then return end
tab:setOn(not tab:isOn())
scheduleEvent(function() tabBlink(tab) end, 500)
tab.blinkEvent = scheduleEvent(function() tabBlink(tab) end, 500)
end
-- public functions
@ -29,12 +29,14 @@ end
function UITabBar:addTab(text, panel)
if panel == nil then
panel = createWidget(self:getStyleName() .. 'Panel')
panel:setId('tabPanel')
end
local tab = createWidget(self:getStyleName() .. 'Button', self)
panel.isTab = true
tab.tabPanel = panel
tab.tabBar = self
tab:setId('tab')
tab:setText(text)
tab:setWidth(tab:getTextSize().width + tab:getPaddingLeft() + tab:getPaddingRight())
tab.onClick = onTabClick
@ -55,6 +57,9 @@ function UITabBar:removeTab(tab)
self:selectPrevTab()
end
table.remove(self.tabs, index)
if tab.blinkEvent then
removeEvent(tab.blinkEvent)
end
tab:destroy()
end

View File

@ -81,11 +81,15 @@ function Battle.terminate()
battleButton = nil
battleWindow:destroy()
battleWindow = nil
mouseWidget:destroy()
mouseWidget = nil
disconnect(Creature, { onSkullChange = Battle.checkCreatureSkull,
onEmblemChange = Battle.checkCreatureEmblem } )
disconnect(g_game, { onAttackingCreatureChange = Battle.onAttack } )
Battle = nil
end
function Battle.toggle()

View File

@ -5,10 +5,13 @@ Module
website: https://github.com/edubart/otclient
icon: battle.png
dependencies:
- game
@onLoad: |
dofile 'battle'
Battle.init()
@onUnload:
@onUnload: |
Battle.terminate()

View File

@ -4,6 +4,9 @@ Module
author: OTClient team
website: https://github.com/edubart/otclient
dependencies:
- game
@onLoad: |
dofile 'combatcontrols'
CombatControls.init()

View File

@ -42,17 +42,18 @@ local SayModes = {
[3] = { speakTypeDesc = 'yell', icon = '/core_styles/icons/yell.png' }
}
local MAX_HISTORY = 1000
local MAX_LINES = 100
local consolePanel
local consoleContentPanel
local consoleTabBar
local consoleTextEdit
local channels
local messageHistory = { }
local currentMessageIndex = 0
local MaxHistory = 1000
local channelsWindow
local MAX_LINES = 100
local ownPrivateName
local messageHistory = {}
local currentMessageIndex = 0
-- private functions
local function navigateMessageHistory(step)
@ -252,9 +253,9 @@ function Console.terminate()
consoleContentPanel = nil
consoleTabBar = nil
Console = nil
ownPrivateName = nil
Console = nil
end
function Console.clear()
@ -418,7 +419,7 @@ function Console.sendCurrentMessage()
-- add new command to history
currentMessageIndex = 0
table.insert(messageHistory, originalMessage)
if #messageHistory > MaxHistory then
if #messageHistory > MAX_HISTORY then
table.remove(messageHistory, 1)
end

View File

@ -4,7 +4,7 @@ Module
author: OTClient team
website: https://github.com/edubart/otclient
dependecies:
dependencies:
- game
@onLoad: |

View File

@ -4,7 +4,7 @@ Module
author: OTClient team
website: https://github.com/edubart/otclient
dependecies:
dependencies:
- game
@onLoad: |

View File

@ -63,6 +63,8 @@ function HealthBar.terminate()
manaBar = nil
healthLabel = nil
manaLabel = nil
HealthBar = nil
end
function HealthBar.toggle()

View File

@ -4,7 +4,7 @@ Module
author: OTClient team
website: https://github.com/edubart/otclient
dependecies:
dependencies:
- game
@onLoad: |

View File

@ -116,6 +116,8 @@ function HotkeysManager.terminate()
hotkeysWindow = nil
hotkeysButton:destroy()
hotkeysButton = nil
HotkeysManager = nil
end
function HotkeysManager.toggle()

View File

@ -38,6 +38,8 @@ function Inventory.terminate()
inventoryWindow = nil
inventoryButton = nil
inventoryPanel = nil
Inventory = nil
end
function Inventory.toggle()

View File

@ -4,7 +4,7 @@ Module
author: OTClient team
website: https://github.com/edubart/otclient
dependecies:
dependencies:
- game
@onLoad: |

View File

@ -43,13 +43,15 @@ function Minimap.init()
end
function Minimap.terminate()
Keyboard.unbindKeyDown('Ctrl+M')
disconnect(g_game, { onLogin = Minimap.reset })
Keyboard.unbindKeyDown('Ctrl+M')
minimapWidget:destroy()
minimapWidget = nil
minimapButton:destroy()
minimapButton = nil
Minimap = nil
end
function Minimap.toggle()

View File

@ -4,12 +4,12 @@ Module
author: OTClient team
website: https://github.com/edubart/otclient
dependecies:
dependencies:
- game
@onLoad: |
dofile 'minimap'
Minimap.init()
@onUnload:
@onUnload: |
Minimap.terminate()

View File

@ -87,11 +87,15 @@ function NPCTrade.terminate()
cacheItems = nil
cacheGoods = nil
buyTab = nil
sellTab = nil
disconnect(g_game, { onGameEnd = NPCTrade.hide,
onOpenNpcTrade = NPCTrade.onOpenNpcTrade,
onPlayerGoods = NPCTrade.onPlayerGoods,
onCloseNpcTrade = NPCTrade.onCloseNpcTrade } )
NPCTrade = nil
end
-- private functions

View File

@ -126,6 +126,8 @@ function Outfit.terminate()
disconnect(g_game, { onOpenOutfitWindow = Outfit.create,
onGameEnd = Outfit.destroy })
Outfit.destroy()
Outfit = nil
end
function Outfit.create(creature, outfitList)

View File

@ -4,6 +4,9 @@ Module
author: OTClient team
website: https://github.com/edubart/otclient
dependencies:
- game
@onLoad: |
dofile 'outfit'
Outfit.init()

View File

@ -59,6 +59,8 @@ function Skills.terminate()
skillsButton = nil
skillsWindow:destroy()
skillsWindow = nil
Skills = nil
end
function Skills.toggle()

View File

@ -4,6 +4,9 @@ Module
author: OTClient team
website: https://github.com/edubart/otclient
dependencies:
- game
@onLoad: |
dofile 'skills'
Skills.init()

View File

@ -131,5 +131,5 @@ end
function TextMessage.displayDeadMessage()
local advanceLabel = GameInterface.getMapPanel():recursiveGetChildById('centerAdvance')
if advanceLabel:isVisible() then return end
TextMessage.displayEventAdvance('You are dead.')
TextMessage.displayEventAdvance(tr('You are dead.'))
end

View File

@ -4,7 +4,7 @@ Module
author: OTClient team
website: https://github.com/edubart/otclient
dependecies:
dependencies:
- game
@onLoad: |

View File

@ -26,6 +26,8 @@ function VipList.terminate()
vipWindow = nil
vipButton:destroy()
vipButton = nil
VipList = nil
end
function VipList.clear()

View File

@ -8,5 +8,5 @@ Module
dofile 'viplist'
VipList.init()
@onUnload:
@onUnload: |
VipList.terminate()

View File

@ -281,13 +281,15 @@ void UIManager::onWidgetDestroy(const UIWidgetPtr& widget)
checkEvent = g_eventDispatcher.scheduleEvent([] {
g_lua.collectGarbage();
g_eventDispatcher.addEvent([] {
UIWidgetList backupList = destroyedWidgets;
destroyedWidgets.clear();
g_eventDispatcher.scheduleEvent([backupList] {
g_lua.collectGarbage();
for(const UIWidgetPtr& widget : destroyedWidgets) {
for(const UIWidgetPtr& widget : backupList) {
if(widget->getUseCount() != 1)
logWarning("widget '", widget->getId(), "' destroyed but still have ", widget->getUseCount()-1, " reference(s) left");
}
});
}, 1);
}, 1000);
#endif
}