diff --git a/modules/game/thing.lua b/modules/game/thing.lua index cf9d2b2b..4d12bb33 100644 --- a/modules/game/thing.lua +++ b/modules/game/thing.lua @@ -46,13 +46,13 @@ function Game.createThingMenu(menuPosition, lookThing, useThing, creatureThing) menu:addOption('Message to ' .. creatureThing:getName(), function() print('message') end) menu:addOption('Add to VIP list', function() Game.addVip(creatureThing:getName()) end) menu:addOption('Ignore ' .. creatureThing:getName(), function() print('ignore') end) - menu:addOption('Invite to Party', function() print('invite to party') end) + menu:addOption('Invite to Party', function() Game.inviteToParty(creatureThing:getId()) end) end end menu:addSeparator() - menu:addOption('Copy Name', function() print('copy name') end) + menu:addOption('Copy Name', function() g_window.setClipboardText(creatureThing:getName()) end) end diff --git a/modules/game_viplist/viplist.lua b/modules/game_viplist/viplist.lua index 9df3013c..4009ff75 100644 --- a/modules/game_viplist/viplist.lua +++ b/modules/game_viplist/viplist.lua @@ -79,7 +79,7 @@ function VipList.onVipListLabelMousePress(widget, mousePos, mouseButton) menu:addOption('Add new VIP', function() VipList.createAddWindow() end) menu:addOption('Remove ' .. widget:getText(), function() if widget then Game.removeVip(widget:getId():sub(4)) vipList:removeChild(widget) end end) menu:addSeparator() - menu:addOption('Copy Name', function() end) + menu:addOption('Copy Name', function() g_window.setClipboardText(widget:getText()) end) menu:display(mousePos) return true diff --git a/src/framework/luafunctions.cpp b/src/framework/luafunctions.cpp index 559c9007..b72509ab 100644 --- a/src/framework/luafunctions.cpp +++ b/src/framework/luafunctions.cpp @@ -239,10 +239,12 @@ void Application::registerLuaFunctions() g_lua.bindClassStaticFunction("g_window", "setFullscreen", std::bind(&PlatformWindow::setFullscreen, &g_window, _1)); g_lua.bindClassStaticFunction("g_window", "setTitle", std::bind(&PlatformWindow::setTitle, &g_window, _1)); g_lua.bindClassStaticFunction("g_window", "setIcon", std::bind(&PlatformWindow::setIcon, &g_window, _1)); + g_lua.bindClassStaticFunction("g_window", "setClipboardText", std::bind(&PlatformWindow::setClipboardText, &g_window, _1)); g_lua.bindClassStaticFunction("g_window", "getMousePos", std::bind(&PlatformWindow::getMousePos, &g_window)); g_lua.bindClassStaticFunction("g_window", "getSize", std::bind(&PlatformWindow::getSize, &g_window)); g_lua.bindClassStaticFunction("g_window", "getDisplaySize", std::bind(&PlatformWindow::getDisplaySize, &g_window)); g_lua.bindClassStaticFunction("g_window", "getPlatformType", std::bind(&PlatformWindow::getPlatformType, &g_window)); + g_lua.bindClassStaticFunction("g_window", "getClipboardText", std::bind(&PlatformWindow::getClipboardText, &g_window)); // Logger g_lua.registerClass(); diff --git a/src/otclient/core/game.cpp b/src/otclient/core/game.cpp index 23361fea..585e04f1 100644 --- a/src/otclient/core/game.cpp +++ b/src/otclient/core/game.cpp @@ -26,6 +26,7 @@ #include "tile.h" #include #include +#include Game g_game; @@ -105,7 +106,7 @@ void Game::processInventoryChange(int slot, const ItemPtr& item) void Game::walk(Otc::Direction direction) { - if(!m_online || !m_localPlayer->canWalk(direction)) + if(!m_online || !m_localPlayer->canWalk(direction) || !g_ui.isOnInputEvent()) return; m_localPlayer->clientWalk(direction); @@ -161,7 +162,7 @@ void Game::turn(Otc::Direction direction) void Game::look(const ThingPtr& thing) { - if(!m_online || !thing) + if(!m_online || !thing || !g_ui.isOnInputEvent()) return; int stackpos = getThingStackpos(thing); @@ -171,7 +172,7 @@ void Game::look(const ThingPtr& thing) void Game::use(const ThingPtr& thing) { - if(!m_online || !thing) + if(!m_online || !thing || !g_ui.isOnInputEvent()) return; int stackpos = getThingStackpos(thing); @@ -181,7 +182,7 @@ void Game::use(const ThingPtr& thing) void Game::attack(const CreaturePtr& creature) { - if(!m_online || !creature) + if(!m_online || !creature || !g_ui.isOnInputEvent()) return; m_protocolGame->sendAttack(creature->getId()); @@ -189,7 +190,7 @@ void Game::attack(const CreaturePtr& creature) void Game::follow(const CreaturePtr& creature) { - if(!m_online || !creature) + if(!m_online || !creature || !g_ui.isOnInputEvent()) return; m_protocolGame->sendFollow(creature->getId()); @@ -197,7 +198,7 @@ void Game::follow(const CreaturePtr& creature) void Game::rotate(const ThingPtr& thing) { - if(!m_online || !thing) + if(!m_online || !thing || !g_ui.isOnInputEvent()) return; int stackpos = getThingStackpos(thing); @@ -219,7 +220,7 @@ int Game::getThingStackpos(const ThingPtr& thing) void Game::talkChannel(int channelType, int channelId, const std::string& message) { - if(!m_online) + if(!m_online || !g_ui.isOnInputEvent()) return; m_protocolGame->sendTalk(channelType, channelId, "", message); @@ -227,15 +228,23 @@ void Game::talkChannel(int channelType, int channelId, const std::string& messag void Game::talkPrivate(int channelType, const std::string& receiver, const std::string& message) { - if(!m_online) + if(!m_online || !g_ui.isOnInputEvent()) return; m_protocolGame->sendTalk(channelType, 0, receiver, message); } +void Game::inviteToParty(int creatureId) +{ + if(!m_online || !g_ui.isOnInputEvent()) + return; + + m_protocolGame->sendInviteToParty(creatureId); +} + void Game::openOutfitWindow() { - if(!m_online) + if(!m_online || !g_ui.isOnInputEvent()) return; m_protocolGame->sendGetOutfit(); @@ -243,7 +252,7 @@ void Game::openOutfitWindow() void Game::setOutfit(const Outfit& outfit) { - if(!m_online) + if(!m_online || !g_ui.isOnInputEvent()) return; m_protocolGame->sendSetOutfit(outfit); @@ -251,7 +260,7 @@ void Game::setOutfit(const Outfit& outfit) void Game::addVip(const std::string& name) { - if(!m_online || name.empty()) + if(!m_online || name.empty() || !g_ui.isOnInputEvent()) return; m_protocolGame->sendAddVip(name); @@ -259,7 +268,7 @@ void Game::addVip(const std::string& name) void Game::removeVip(int playerId) { - if(!m_online) + if(!m_online || !g_ui.isOnInputEvent()) return; m_protocolGame->sendRemoveVip(playerId); diff --git a/src/otclient/core/game.h b/src/otclient/core/game.h index 189fdbce..709c9e0f 100644 --- a/src/otclient/core/game.h +++ b/src/otclient/core/game.h @@ -55,6 +55,7 @@ public: void rotate(const ThingPtr& thing); void talkChannel(int channelType, int channelId, const std::string& message); void talkPrivate(int channelType, const std::string& receiver, const std::string& message); + void inviteToParty(int creatureId); void openOutfitWindow(); void setOutfit(const Outfit& outfit); void addVip(const std::string& name); diff --git a/src/otclient/luafunctions.cpp b/src/otclient/luafunctions.cpp index 4a96e5af..6cdbfbe7 100644 --- a/src/otclient/luafunctions.cpp +++ b/src/otclient/luafunctions.cpp @@ -75,6 +75,7 @@ void OTClient::registerLuaFunctions() g_lua.bindClassStaticFunction("attack", std::bind(&Game::attack, &g_game, _1)); g_lua.bindClassStaticFunction("follow", std::bind(&Game::follow, &g_game, _1)); g_lua.bindClassStaticFunction("rotate", std::bind(&Game::rotate, &g_game, _1)); + g_lua.bindClassStaticFunction("inviteToParty", std::bind(&Game::inviteToParty, &g_game, _1)); g_lua.bindClassStaticFunction("addVip", std::bind(&Game::addVip, &g_game, _1)); g_lua.bindClassStaticFunction("removeVip", std::bind(&Game::removeVip, &g_game, _1)); diff --git a/src/otclient/ui/uigame.cpp b/src/otclient/ui/uigame.cpp index fae7c0d6..dd375945 100644 --- a/src/otclient/ui/uigame.cpp +++ b/src/otclient/ui/uigame.cpp @@ -23,7 +23,7 @@ #include "uigame.h" #include #include -#include +#include bool UIGame::onKeyPress(uchar keyCode, std::string keyText, int keyboardModifiers) { @@ -83,7 +83,6 @@ bool UIGame::onKeyPress(uchar keyCode, std::string keyText, int keyboardModifier return true; } else if(keyCode == Fw::KeyRight || keyCode == Fw::KeyNumpad6) { g_game.turn(Otc::East); - //g_particleManager.load("particle.otpa"); return true; } else if(keyCode == Fw::KeyDown || keyCode == Fw::KeyNumpad2) { g_game.turn(Otc::South); @@ -91,6 +90,8 @@ bool UIGame::onKeyPress(uchar keyCode, std::string keyText, int keyboardModifier } else if(keyCode == Fw::KeyLeft || keyCode == Fw::KeyNumpad4) { g_game.turn(Otc::West); return true; + } else if(keyCode == Fw::KeyV) { + chatLineEdit->appendText(g_window.getClipboardText()); } } else if(keyboardModifiers == Fw::KeyboardShiftModifier) { if(keyCode == Fw::KeyRight || keyCode == Fw::KeyNumpad6) {