implement more chat...
This commit is contained in:
parent
61aa710d1c
commit
c6013dfeda
|
@ -14,7 +14,7 @@ local SpeakTypes = {
|
||||||
channelOrange = { color = '#FE6500' },
|
channelOrange = { color = '#FE6500' },
|
||||||
private = { color = '#5FF7F7', private = true },
|
private = { color = '#5FF7F7', private = true },
|
||||||
playerToNpc = { color = '#9F9DFD', private = true, npcChat = true },
|
playerToNpc = { color = '#9F9DFD', private = true, npcChat = true },
|
||||||
broadcast = { color = '#F55E5E', private = true },
|
broadcast = { color = '#F55E5E' },
|
||||||
privateRed = { color = '#F55E5E', private = true }
|
privateRed = { color = '#F55E5E', private = true }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,29 +114,39 @@ function Console.sendCurrentMessage()
|
||||||
if #message == 0 then return end
|
if #message == 0 then return end
|
||||||
consoleLineEdit:clearText()
|
consoleLineEdit:clearText()
|
||||||
|
|
||||||
|
-- get current channel
|
||||||
local tab = Console.getCurrentTab()
|
local tab = Console.getCurrentTab()
|
||||||
local name = tab:getText()
|
|
||||||
if name == 'Server Log' then name = 'Default' end
|
|
||||||
|
|
||||||
local speaktypedesc = 'say'
|
-- when talking on server log, the message goes to default channel
|
||||||
if tab.npcChat then
|
local name = tab:getText()
|
||||||
speaktypedesc = 'playerToNpc'
|
if name == 'Server Log' then
|
||||||
|
tab = Console.getTab('Default')
|
||||||
|
name = 'Default'
|
||||||
end
|
end
|
||||||
|
local speaktypedesc
|
||||||
|
|
||||||
if tab.channelId then
|
if tab.channelId then
|
||||||
if tab.channelId ~= 0 then
|
if tab.channelId == 0 then
|
||||||
|
speaktypedesc = 'say'
|
||||||
|
else
|
||||||
speaktypedesc = 'channelYellow'
|
speaktypedesc = 'channelYellow'
|
||||||
end
|
end
|
||||||
|
|
||||||
Game.talkChannel(speaktypedesc, tab.channelId, message)
|
Game.talkChannel(speaktypedesc, tab.channelId, message)
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
|
if tab.npcChat then
|
||||||
|
speaktypedesc = 'playerToNpc'
|
||||||
|
else
|
||||||
|
speaktypedesc = 'private'
|
||||||
|
end
|
||||||
|
|
||||||
local speaktype = SpeakTypes[speaktypedesc]
|
local speaktype = SpeakTypes[speaktypedesc]
|
||||||
local player = Game.getLocalPlayer()
|
local player = Game.getLocalPlayer()
|
||||||
|
Game.talkPrivate(speaktypedesc, name, message)
|
||||||
|
|
||||||
message = applyMessagePrefixies(player:getName(), player:getLevel(), message)
|
message = applyMessagePrefixies(player:getName(), player:getLevel(), message)
|
||||||
Console.addPrivateText(message, speaktype, name)
|
Console.addPrivateText(message, speaktype, name)
|
||||||
|
|
||||||
Game.talkPrivate(speaktypedesc, name, message)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -164,8 +174,7 @@ local function onChannelList(channelList)
|
||||||
channelsWindow.onEnter = function(self)
|
channelsWindow.onEnter = function(self)
|
||||||
local selectedChannelLabel = channelListPanel:getFocusedChild()
|
local selectedChannelLabel = channelListPanel:getFocusedChild()
|
||||||
if not selectedChannelLabel then return end
|
if not selectedChannelLabel then return end
|
||||||
--Game.joinChannel(selectedChannelLabel.channelId)
|
Game.joinChannel(selectedChannelLabel.channelId)
|
||||||
--Console.addChannel(selectedChannelLabel:getText(), selectedChannelLabel .channelId)
|
|
||||||
channelsWindow:destroy()
|
channelsWindow:destroy()
|
||||||
end
|
end
|
||||||
for k,v in pairs(channelList) do
|
for k,v in pairs(channelList) do
|
||||||
|
@ -174,7 +183,6 @@ local function onChannelList(channelList)
|
||||||
|
|
||||||
if channelId ~= 0 and #channelName > 0 then
|
if channelId ~= 0 and #channelName > 0 then
|
||||||
local label = createWidget('ChannelListLabel', channelListPanel)
|
local label = createWidget('ChannelListLabel', channelListPanel)
|
||||||
print(channelId, channelName)
|
|
||||||
label.channelId = channelId
|
label.channelId = channelId
|
||||||
label:setText(channelName)
|
label:setText(channelName)
|
||||||
end
|
end
|
||||||
|
|
|
@ -153,7 +153,7 @@ void Game::processCreatureMove(const CreaturePtr& creature, const Position& oldP
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if(!m_walkFeedback && creature == m_localPlayer) {
|
if(!m_walkFeedback && creature == m_localPlayer) {
|
||||||
updatePing();
|
updateWalkPing();
|
||||||
m_walkFeedback = true;
|
m_walkFeedback = true;
|
||||||
}
|
}
|
||||||
creature->walk(newPos);
|
creature->walk(newPos);
|
||||||
|
@ -168,7 +168,7 @@ void Game::processAttackCancel()
|
||||||
void Game::processWalkCancel(Otc::Direction direction)
|
void Game::processWalkCancel(Otc::Direction direction)
|
||||||
{
|
{
|
||||||
if(!m_walkFeedback) {
|
if(!m_walkFeedback) {
|
||||||
updatePing();
|
updateWalkPing();
|
||||||
m_walkFeedback = true;
|
m_walkFeedback = true;
|
||||||
}
|
}
|
||||||
m_localPlayer->cancelWalk(direction, true);
|
m_localPlayer->cancelWalk(direction, true);
|
||||||
|
@ -280,6 +280,14 @@ void Game::useWith(const ThingPtr& fromThing, const ThingPtr& toThing)
|
||||||
m_protocolGame->sendUseItemEx(fromThing->getPos(), fromThing->getId(), fromStackpos, toThing->getPos(), toThing->getId(), toStackpos);
|
m_protocolGame->sendUseItemEx(fromThing->getPos(), fromThing->getId(), fromStackpos, toThing->getPos(), toThing->getId(), toStackpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Game::useHotkey(int itemId, const ThingPtr& toThing)
|
||||||
|
{
|
||||||
|
if(!m_online || !toThing || !checkBotProtection())
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_protocolGame->sendUseItemEx(Position(0xFFFF, 0, 0), itemId, 0, toThing->getPos(), toThing->getId(), getThingStackpos(toThing));
|
||||||
|
}
|
||||||
|
|
||||||
void Game::attack(const CreaturePtr& creature)
|
void Game::attack(const CreaturePtr& creature)
|
||||||
{
|
{
|
||||||
if(!m_online || !creature || !checkBotProtection())
|
if(!m_online || !creature || !checkBotProtection())
|
||||||
|
@ -347,7 +355,6 @@ void Game::talkChannel(const std::string& speakTypeDesc, int channelId, const st
|
||||||
{
|
{
|
||||||
if(!m_online || !checkBotProtection())
|
if(!m_online || !checkBotProtection())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_protocolGame->sendTalk(speakTypeDesc, channelId, "", message);
|
m_protocolGame->sendTalk(speakTypeDesc, channelId, "", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,15 +362,42 @@ void Game::talkPrivate(const std::string& speakTypeDesc, const std::string& rece
|
||||||
{
|
{
|
||||||
if(!m_online || !checkBotProtection())
|
if(!m_online || !checkBotProtection())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_protocolGame->sendTalk(speakTypeDesc, 0, receiver, message);
|
m_protocolGame->sendTalk(speakTypeDesc, 0, receiver, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Game::requestChannels()
|
||||||
|
{
|
||||||
|
if(!m_online || !checkBotProtection())
|
||||||
|
return;
|
||||||
|
m_protocolGame->sendGetChannels();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Game::joinChannel(int channelId)
|
||||||
|
{
|
||||||
|
if(!m_online || !checkBotProtection())
|
||||||
|
return;
|
||||||
|
m_protocolGame->sendJoinChannel(channelId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Game::leaveChannel(int channelId)
|
||||||
|
{
|
||||||
|
if(!m_online || !checkBotProtection())
|
||||||
|
return;
|
||||||
|
m_protocolGame->sendLeaveChannel(channelId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Game::closeNpcChannel()
|
||||||
|
{
|
||||||
|
if(!m_online || !checkBotProtection())
|
||||||
|
return;
|
||||||
|
m_protocolGame->sendCloseNpcChannel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Game::partyInvite(int creatureId)
|
void Game::partyInvite(int creatureId)
|
||||||
{
|
{
|
||||||
if(!m_online || !checkBotProtection())
|
if(!m_online || !checkBotProtection())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_protocolGame->sendInviteToParty(creatureId);
|
m_protocolGame->sendInviteToParty(creatureId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,7 +405,6 @@ void Game::partyJoin(int creatureId)
|
||||||
{
|
{
|
||||||
if(!m_online || !checkBotProtection())
|
if(!m_online || !checkBotProtection())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_protocolGame->sendJoinParty(creatureId);
|
m_protocolGame->sendJoinParty(creatureId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +412,6 @@ void Game::partyRevokeInvitation(int creatureId)
|
||||||
{
|
{
|
||||||
if(!m_online || !checkBotProtection())
|
if(!m_online || !checkBotProtection())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_protocolGame->sendRevokeInvitation(creatureId);
|
m_protocolGame->sendRevokeInvitation(creatureId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,7 +420,6 @@ void Game::partyPassLeadership(int creatureId)
|
||||||
{
|
{
|
||||||
if(!m_online || !checkBotProtection())
|
if(!m_online || !checkBotProtection())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_protocolGame->sendPassLeadership(creatureId);
|
m_protocolGame->sendPassLeadership(creatureId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,7 +427,6 @@ void Game::partyLeave()
|
||||||
{
|
{
|
||||||
if(!m_online || !checkBotProtection())
|
if(!m_online || !checkBotProtection())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_protocolGame->sendLeaveParty();
|
m_protocolGame->sendLeaveParty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,7 +434,6 @@ void Game::partyShareExperience(bool active)
|
||||||
{
|
{
|
||||||
if(!m_online || !checkBotProtection())
|
if(!m_online || !checkBotProtection())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_protocolGame->sendShareExperience(active, 0);
|
m_protocolGame->sendShareExperience(active, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,31 +441,13 @@ void Game::requestOutfit()
|
||||||
{
|
{
|
||||||
if(!m_online || !checkBotProtection())
|
if(!m_online || !checkBotProtection())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_protocolGame->sendGetOutfit();
|
m_protocolGame->sendGetOutfit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::requestChannels()
|
|
||||||
{
|
|
||||||
if(!m_online || !checkBotProtection())
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_protocolGame->sendGetChannels();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::openChannel(int channelId)
|
|
||||||
{
|
|
||||||
if(!m_online || !checkBotProtection())
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_protocolGame->sendOpenChannel(channelId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::setOutfit(const Outfit& outfit)
|
void Game::setOutfit(const Outfit& outfit)
|
||||||
{
|
{
|
||||||
if(!m_online || !checkBotProtection())
|
if(!m_online || !checkBotProtection())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_protocolGame->sendSetOutfit(outfit);
|
m_protocolGame->sendSetOutfit(outfit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,7 +455,6 @@ void Game::addVip(const std::string& name)
|
||||||
{
|
{
|
||||||
if(!m_online || name.empty() || !checkBotProtection())
|
if(!m_online || name.empty() || !checkBotProtection())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_protocolGame->sendAddVip(name);
|
m_protocolGame->sendAddVip(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,7 +462,6 @@ void Game::removeVip(int playerId)
|
||||||
{
|
{
|
||||||
if(!m_online || !checkBotProtection())
|
if(!m_online || !checkBotProtection())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_protocolGame->sendRemoveVip(playerId);
|
m_protocolGame->sendRemoveVip(playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,7 +476,7 @@ bool Game::checkBotProtection()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::updatePing()
|
void Game::updateWalkPing()
|
||||||
{
|
{
|
||||||
m_walkPing = m_walkPingTimer.ticksElapsed();
|
m_walkPing = m_walkPingTimer.ticksElapsed();
|
||||||
g_lua.callGlobalField("Game", "onWalkPingUpdate", m_walkPing);
|
g_lua.callGlobalField("Game", "onWalkPingUpdate", m_walkPing);
|
||||||
|
|
|
@ -54,32 +54,49 @@ public:
|
||||||
void processAttackCancel();
|
void processAttackCancel();
|
||||||
void processWalkCancel(Otc::Direction direction);
|
void processWalkCancel(Otc::Direction direction);
|
||||||
|
|
||||||
|
// walk related
|
||||||
void walk(Otc::Direction direction);
|
void walk(Otc::Direction direction);
|
||||||
void turn(Otc::Direction direction);
|
void turn(Otc::Direction direction);
|
||||||
|
|
||||||
|
// item related
|
||||||
void look(const ThingPtr& thing);
|
void look(const ThingPtr& thing);
|
||||||
void open(const ThingPtr& thing, int containerId);
|
void open(const ThingPtr& thing, int containerId);
|
||||||
void use(const ThingPtr& thing);
|
void use(const ThingPtr& thing);
|
||||||
void useWith(const ThingPtr& fromThing, const ThingPtr& toThing);
|
void useWith(const ThingPtr& fromThing, const ThingPtr& toThing);
|
||||||
|
void useHotkey(int itemId, const ThingPtr& toThing);
|
||||||
|
|
||||||
|
// attack/follow related
|
||||||
void attack(const CreaturePtr& creature);
|
void attack(const CreaturePtr& creature);
|
||||||
void cancelAttack();
|
void cancelAttack();
|
||||||
void follow(const CreaturePtr& creature);
|
void follow(const CreaturePtr& creature);
|
||||||
void cancelFollow();
|
void cancelFollow();
|
||||||
void rotate(const ThingPtr& thing);
|
void rotate(const ThingPtr& thing);
|
||||||
|
|
||||||
|
// talk related
|
||||||
void talk(const std::string& message);
|
void talk(const std::string& message);
|
||||||
void talkChannel(const std::string& speakTypeDesc, int channelId, const std::string& message);
|
void talkChannel(const std::string& speakTypeDesc, int channelId, const std::string& message);
|
||||||
void talkPrivate(const std::string& speakTypeDesc, const std::string& receiver, const std::string& message);
|
void talkPrivate(const std::string& speakTypeDesc, const std::string& receiver, const std::string& message);
|
||||||
|
void requestChannels();
|
||||||
|
void joinChannel(int channelId);
|
||||||
|
void leaveChannel(int channelId);
|
||||||
|
void closeNpcChannel();
|
||||||
|
|
||||||
|
// party related
|
||||||
void partyInvite(int creatureId);
|
void partyInvite(int creatureId);
|
||||||
void partyJoin(int creatureId);
|
void partyJoin(int creatureId);
|
||||||
void partyRevokeInvitation(int creatureId);
|
void partyRevokeInvitation(int creatureId);
|
||||||
void partyPassLeadership(int creatureId);
|
void partyPassLeadership(int creatureId);
|
||||||
void partyLeave();
|
void partyLeave();
|
||||||
void partyShareExperience(bool active);
|
void partyShareExperience(bool active);
|
||||||
|
|
||||||
|
// outfit related
|
||||||
void requestOutfit();
|
void requestOutfit();
|
||||||
void requestChannels();
|
|
||||||
void openChannel(int channelId);
|
|
||||||
void setOutfit(const Outfit& outfit);
|
void setOutfit(const Outfit& outfit);
|
||||||
|
|
||||||
|
// vip related
|
||||||
void addVip(const std::string& name);
|
void addVip(const std::string& name);
|
||||||
void removeVip(int playerId);
|
void removeVip(int playerId);
|
||||||
|
|
||||||
int getThingStackpos(const ThingPtr& thing);
|
int getThingStackpos(const ThingPtr& thing);
|
||||||
|
|
||||||
bool checkBotProtection();
|
bool checkBotProtection();
|
||||||
|
@ -99,7 +116,7 @@ public:
|
||||||
int getWalkPing() { return m_walkPing; }
|
int getWalkPing() { return m_walkPing; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updatePing();
|
void updateWalkPing();
|
||||||
|
|
||||||
LocalPlayerPtr m_localPlayer;
|
LocalPlayerPtr m_localPlayer;
|
||||||
ProtocolGamePtr m_protocolGame;
|
ProtocolGamePtr m_protocolGame;
|
||||||
|
|
|
@ -180,7 +180,7 @@ void OTClient::registerLuaFunctions()
|
||||||
g_lua.bindClassStaticFunction<Game>("isOnline", std::bind(&Game::isOnline, &g_game));
|
g_lua.bindClassStaticFunction<Game>("isOnline", std::bind(&Game::isOnline, &g_game));
|
||||||
g_lua.bindClassStaticFunction<Game>("requestOutfit", std::bind(&Game::requestOutfit, &g_game));
|
g_lua.bindClassStaticFunction<Game>("requestOutfit", std::bind(&Game::requestOutfit, &g_game));
|
||||||
g_lua.bindClassStaticFunction<Game>("requestChannels", std::bind(&Game::requestChannels, &g_game));
|
g_lua.bindClassStaticFunction<Game>("requestChannels", std::bind(&Game::requestChannels, &g_game));
|
||||||
g_lua.bindClassStaticFunction<Game>("openChannel", std::bind(&Game::openChannel, &g_game, _1));
|
g_lua.bindClassStaticFunction<Game>("joinChannel", std::bind(&Game::joinChannel, &g_game, _1));
|
||||||
g_lua.bindClassStaticFunction<Game>("setOutfit", std::bind(&Game::setOutfit, &g_game, _1));
|
g_lua.bindClassStaticFunction<Game>("setOutfit", std::bind(&Game::setOutfit, &g_game, _1));
|
||||||
g_lua.bindClassStaticFunction<Game>("look", std::bind(&Game::look, &g_game, _1));
|
g_lua.bindClassStaticFunction<Game>("look", std::bind(&Game::look, &g_game, _1));
|
||||||
g_lua.bindClassStaticFunction<Game>("open", std::bind(&Game::open, &g_game, _1, _2));
|
g_lua.bindClassStaticFunction<Game>("open", std::bind(&Game::open, &g_game, _1, _2));
|
||||||
|
|
Loading…
Reference in New Issue