improvment in connect
This commit is contained in:
parent
175f97b98f
commit
55fbb5f1a6
|
@ -20,6 +20,15 @@ end
|
|||
|
||||
function connect(object, signalsAndSlots, pushFront)
|
||||
for signal,slot in pairs(signalsAndSlots) do
|
||||
if not object[signal] then
|
||||
local mt = getmetatable(object)
|
||||
if mt then
|
||||
object[signal] = function(...)
|
||||
return signalcall(mt[signal], ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not object[signal] then
|
||||
object[signal] = slot
|
||||
elseif type(object[signal]) == 'function' then
|
||||
|
@ -140,7 +149,7 @@ function signalcall(param, ...)
|
|||
return param(...)
|
||||
elseif type(param) == 'table' then
|
||||
for k,v in pairs(param) do
|
||||
if param(...) then
|
||||
if v(...) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,7 +44,7 @@ function ToolTip.init()
|
|||
toolTipLabel = createWidget('Label', rootWidget)
|
||||
toolTipLabel:setId('toolTip')
|
||||
toolTipLabel:setBackgroundColor('#111111bb')
|
||||
connect(toolTipLabel, { onMouseMove = moveToolTip })
|
||||
toolTipLabel.onMouseMove = moveToolTip
|
||||
|
||||
connect(UIWidget, { onStyleApply = onWidgetStyleApply,
|
||||
onHoverChange = onWidgetHoverChange})
|
||||
|
|
|
@ -30,9 +30,9 @@ end
|
|||
function UIPopupMenu:addOption(optionName, optionCallback)
|
||||
local optionWidget = createWidget(self:getStyleName() .. 'Button', self)
|
||||
local lastOptionWidget = self:getLastChild()
|
||||
optionWidget.onClick = function()
|
||||
optionWidget.onClick = function(self)
|
||||
optionCallback()
|
||||
self:destroy()
|
||||
self:getParent():destroy()
|
||||
end
|
||||
optionWidget:setText(optionName)
|
||||
local width = optionWidget:getTextSize().width + optionWidget:getMarginLeft() + optionWidget:getMarginRight() + 6
|
||||
|
|
|
@ -36,7 +36,11 @@ function UIMap:onDrop(widget, mousePos)
|
|||
spinbox:setCurrentIndex(count)
|
||||
|
||||
local okButton = moveWindow:getChildById('buttonOk')
|
||||
okButton.onClick = function() g_game.move(widget.currentDragThing, tile:getPosition(), spinbox:getCurrentIndex()) okButton:getParent():destroy() widget.currentDragThing = nil end
|
||||
okButton.onClick = function()
|
||||
g_game.move(widget.currentDragThing, tile:getPosition(), spinbox:getCurrentIndex())
|
||||
okButton:getParent():destroy()
|
||||
widget.currentDragThing = nil
|
||||
end
|
||||
moveWindow.onEnter = okButton.onClick
|
||||
else
|
||||
g_game.move(widget.currentDragThing, tile:getPosition(), 1)
|
||||
|
|
|
@ -473,19 +473,19 @@ void Creature::setOutfit(const Outfit& outfit)
|
|||
void Creature::setSkull(uint8 skull)
|
||||
{
|
||||
m_skull = skull;
|
||||
g_lua.callGlobalField("Creature","onSkullChange", asCreature(), m_skull);
|
||||
callLuaField("onSkullChange", m_skull);
|
||||
}
|
||||
|
||||
void Creature::setShield(uint8 shield)
|
||||
{
|
||||
m_shield = shield;
|
||||
g_lua.callGlobalField("Creature","onShieldChange", asCreature(), m_shield);
|
||||
callLuaField("onShieldChange", m_shield);
|
||||
}
|
||||
|
||||
void Creature::setEmblem(uint8 emblem)
|
||||
{
|
||||
m_emblem = emblem;
|
||||
g_lua.callGlobalField("Creature","onEmblemChange", asCreature(), m_emblem);
|
||||
callLuaField("onEmblemChange", m_emblem);
|
||||
}
|
||||
|
||||
void Creature::setSkullTexture(const std::string& filename)
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <otclient/global.h>
|
||||
|
||||
class Map;
|
||||
class Game;
|
||||
class MapView;
|
||||
class Tile;
|
||||
class Thing;
|
||||
|
|
|
@ -21,10 +21,7 @@
|
|||
*/
|
||||
|
||||
#include "effect.h"
|
||||
#include "thingstype.h"
|
||||
#include "map.h"
|
||||
#include "tile.h"
|
||||
#include <framework/core/clock.h>
|
||||
#include <framework/core/eventdispatcher.h>
|
||||
|
||||
void Effect::draw(const Point& dest, float scaleFactor, bool animate)
|
||||
|
|
|
@ -64,7 +64,7 @@ void Game::processConnectionError(const boost::system::error_code& error)
|
|||
void Game::processDisconnect()
|
||||
{
|
||||
if(isOnline()) {
|
||||
// only process logout event if a previous the player is known
|
||||
// only process logout event if the player is known
|
||||
if(m_localPlayer->isKnown())
|
||||
processLogout();
|
||||
|
||||
|
@ -86,7 +86,7 @@ void Game::processLoginError(const std::string& error)
|
|||
|
||||
void Game::processLoginAdvice(const std::string& message)
|
||||
{
|
||||
g_lua.callGlobalField("Game," "onLoginAdvice", message);
|
||||
g_lua.callGlobalField("g_game", "onLoginAdvice", message);
|
||||
}
|
||||
|
||||
void Game::processLoginWait(const std::string& message, int time)
|
||||
|
@ -113,7 +113,7 @@ void Game::processGameEnd()
|
|||
{
|
||||
g_lua.callGlobalField("g_game", "onGameEnd");
|
||||
|
||||
// reset game states
|
||||
// reset game state
|
||||
resetGameStates();
|
||||
}
|
||||
|
||||
|
@ -232,9 +232,7 @@ void Game::processOpenContainer(int containerId, int itemId, const std::string&
|
|||
|
||||
void Game::processContainerAddItem(int containerId, const ItemPtr& item)
|
||||
{
|
||||
if(item)
|
||||
item->setPosition(Position(65535, containerId + 0x40, 0));
|
||||
|
||||
item->setPosition(Position(65535, containerId + 0x40, 0));
|
||||
g_lua.callGlobalField("g_game", "onContainerAddItem", containerId, item);
|
||||
}
|
||||
|
||||
|
|
|
@ -156,5 +156,3 @@ void LocalPlayer::terminateWalk()
|
|||
Creature::terminateWalk();
|
||||
m_preWalking = false;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue