From dfb0150a7dfcf9684553d9866235772465465d6a Mon Sep 17 00:00:00 2001 From: Henrique Santiago Date: Sun, 10 Feb 2013 01:17:20 -0200 Subject: [PATCH] Fix signalCall, healthinfo tooltips --- data/locales/pt.lua | 3 ++ modules/client/client.lua | 6 +-- modules/corelib/ui/uiprogressbar.lua | 1 - modules/game_healthinfo/healthinfo.lua | 47 +++++++++++++++++------- src/framework/core/application.cpp | 1 + src/framework/luaengine/luainterface.cpp | 2 +- 6 files changed, 41 insertions(+), 19 deletions(-) diff --git a/data/locales/pt.lua b/data/locales/pt.lua index 153bd637..1f73d4c2 100644 --- a/data/locales/pt.lua +++ b/data/locales/pt.lua @@ -375,6 +375,7 @@ locale = { ["You are strengthened"] = "Você está reforçado", ["You are within a protection zone"] = "Você está dentro de uma zona de proteção", ["You can enter new text."] = "Você pode entrar com um novo texto.", + ["You have %d%% to advance to level %d."] = "Você tem %d%% para avançar para o nível %d.", ["You have %s percent to go"] = "Você tem %s porcento para avançar", ["You have %s percent"] = "Você tem %s porcento", ["You may not logout during a fight"] = "Você não pode sair durante um combate", @@ -385,6 +386,8 @@ locale = { ["You read the following, written by \n%s\n"] = "Você lê o seguinte, escrito por \n%s\n", ["You read the following, written on \n%s.\n"] = "Você lê o seguinte, escrito em \n%s.\n", ["Your Capacity"] = "Sua capacidade", + ["Your character health is %d out of %d."] = "A vida do seu personagem é %d de %d.", + ["Your character mana is %d out of %d."] = "A mana do seu personagem é %d de %d.", ["Your Money"] = "Seu dinheiro", } } diff --git a/modules/client/client.lua b/modules/client/client.lua index bc166920..b29238c2 100644 --- a/modules/client/client.lua +++ b/modules/client/client.lua @@ -54,7 +54,7 @@ end function init() connect(g_app, { onRun = startup, - onClose = exit }) + onExit = exit }) g_window.setMinimumSize({ width = 600, height = 480 }) g_sounds.preload(musicFilename) @@ -99,7 +99,7 @@ end function terminate() disconnect(g_app, { onRun = startup, - onClose = exit }) + onExit = exit }) -- save window configs g_settings.set('window-size', g_window.getUnmaximizedSize()) g_settings.set('window-pos', g_window.getUnmaximizedPos()) @@ -113,4 +113,4 @@ end function exit() g_logger.info("Exiting application..") -end \ No newline at end of file +end diff --git a/modules/corelib/ui/uiprogressbar.lua b/modules/corelib/ui/uiprogressbar.lua index 1005a7ef..dd4d8343 100644 --- a/modules/corelib/ui/uiprogressbar.lua +++ b/modules/corelib/ui/uiprogressbar.lua @@ -4,7 +4,6 @@ UIProgressBar = extends(UIWidget) function UIProgressBar.create() local progressbar = UIProgressBar.internalCreate() progressbar:setFocusable(false) - progressbar:setPhantom(true) progressbar.min = 0 progressbar.max = 100 progressbar.value = 0 diff --git a/modules/game_healthinfo/healthinfo.lua b/modules/game_healthinfo/healthinfo.lua index 33b14110..01b6567f 100644 --- a/modules/game_healthinfo/healthinfo.lua +++ b/modules/game_healthinfo/healthinfo.lua @@ -23,6 +23,9 @@ manaBar = nil experienceBar = nil soulLabel = nil capLabel = nil +healthTooltip = 'Your character health is %d out of %d.' +manaTooltip = 'Your character mana is %d out of %d.' +experienceTooltip = 'You have %d%% to advance to level %d.' function init() connect(LocalPlayer, { onHealthChange = onHealthChange, @@ -96,19 +99,6 @@ function toggleIcon(bitChanged) end end -function hideLabels() - local removeHeight = math.max(capLabel:getMarginRect().height, soulLabel:getMarginRect().height) - capLabel:setOn(false) - soulLabel:setOn(false) - healthInfoWindow:setHeight(math.max(healthInfoWindow.minimizedHeight, healthInfoWindow:getHeight() - removeHeight)) -end - -function hideExperience() - local removeHeight = experienceBar:getMarginRect().height - experienceBar:setOn(false) - healthInfoWindow:setHeight(math.max(healthInfoWindow.minimizedHeight, healthInfoWindow:getHeight() - removeHeight)) -end - function offline() healthInfoWindow:recursiveGetChildById('conditionPanel'):destroyChildren() end @@ -120,16 +110,19 @@ end function onHealthChange(localPlayer, health, maxHealth) healthBar:setText(health .. ' / ' .. maxHealth) + healthBar:setTooltip(tr(healthTooltip, health, maxHealth)) healthBar:setValue(health, 0, maxHealth) end function onManaChange(localPlayer, mana, maxMana) manaBar:setText(mana .. ' / ' .. maxMana) + manaBar:setTooltip(tr(manaTooltip, mana, maxMana)) manaBar:setValue(mana, 0, maxMana) end function onLevelChange(localPlayer, value, percent) - experienceBar:setText(percent .. "%") + experienceBar:setText(percent .. '%') + experienceBar:setTooltip(tr(experienceTooltip, percent, value+1)) experienceBar:setPercent(percent) end @@ -154,3 +147,29 @@ function onStatesChange(localPlayer, now, old) end end end + +-- personalization functions +function hideLabels() + local removeHeight = math.max(capLabel:getMarginRect().height, soulLabel:getMarginRect().height) + capLabel:setOn(false) + soulLabel:setOn(false) + healthInfoWindow:setHeight(math.max(healthInfoWindow.minimizedHeight, healthInfoWindow:getHeight() - removeHeight)) +end + +function hideExperience() + local removeHeight = experienceBar:getMarginRect().height + experienceBar:setOn(false) + healthInfoWindow:setHeight(math.max(healthInfoWindow.minimizedHeight, healthInfoWindow:getHeight() - removeHeight)) +end + +function setHealthTooltip(tooltip) + healthTooltip = tooltip +end + +function setManaTooltip(tooltip) + manaTooltip = tooltip +end + +function setExperienceTooltip(tooltip) + experienceTooltip = tooltip +end diff --git a/src/framework/core/application.cpp b/src/framework/core/application.cpp index 8e5d7684..46aef63a 100644 --- a/src/framework/core/application.cpp +++ b/src/framework/core/application.cpp @@ -152,6 +152,7 @@ void Application::poll() void Application::exit() { + g_lua.callGlobalField("g_app", "onExit"); m_stopping = true; } diff --git a/src/framework/luaengine/luainterface.cpp b/src/framework/luaengine/luainterface.cpp index 230e27b6..c2f4f253 100644 --- a/src/framework/luaengine/luainterface.cpp +++ b/src/framework/luaengine/luainterface.cpp @@ -506,7 +506,7 @@ int LuaInterface::signalCall(int numArgs, int numRets) } pop(numArgs + 1); // pops the table of function and arguments - if(numRets == 1) { + if(numRets == 1 || numRets == -1) { rets = 1; pushBoolean(done); }