copy name, invite to party

This commit is contained in:
Henrique Santiago 2012-01-05 10:48:10 -02:00
parent c9280ecf9d
commit 320b67e292
7 changed files with 31 additions and 17 deletions

View File

@ -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

View File

@ -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

View File

@ -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<Logger>();

View File

@ -26,6 +26,7 @@
#include "tile.h"
#include <otclient/net/protocolgame.h>
#include <framework/core/eventdispatcher.h>
#include <framework/ui/uimanager.h>
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);

View File

@ -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);

View File

@ -75,6 +75,7 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassStaticFunction<Game>("attack", std::bind(&Game::attack, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("follow", std::bind(&Game::follow, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("rotate", std::bind(&Game::rotate, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("inviteToParty", std::bind(&Game::inviteToParty, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("addVip", std::bind(&Game::addVip, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("removeVip", std::bind(&Game::removeVip, &g_game, _1));

View File

@ -23,7 +23,7 @@
#include "uigame.h"
#include <otclient/core/game.h>
#include <framework/ui/uilineedit.h>
#include <framework/graphics/particlemanager.h>
#include <framework/platform/platformwindow.h>
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) {