From 61aa710d1c037337fbfa85d75d2c9742e74d4770 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Fri, 13 Jan 2012 23:37:15 -0200 Subject: [PATCH] some chat functionality --- modules/addon_mapeffects/mapeffects.lua | 18 --- modules/addon_mapeffects/mapeffects.otmod | 16 --- modules/addon_pingbar/pingbar.otmod | 2 +- modules/addon_playground/playground.otmod | 2 +- modules/addon_terminal/terminal.otmod | 2 +- modules/client_options/options.otui | 8 +- modules/client_tibiafiles | 2 +- modules/core/core.otmod | 2 +- modules/core_styles/icons/channels.png | Bin 0 -> 245 bytes modules/core_styles/icons/closechannel.png | Bin 0 -> 300 bytes modules/core_widgets/uitabbar.lua | 86 ++++++----- modules/game/thing.lua | 2 +- modules/game_console/channelswindow.otui | 40 ++++++ modules/game_console/console.lua | 159 +++++++++++++++++---- modules/game_console/console.otui | 19 ++- modules/game_textmessage/textmessage.lua | 22 +-- src/framework/core/module.cpp | 2 +- src/framework/core/module.h | 4 +- src/framework/core/modulemanager.cpp | 6 +- src/framework/core/modulemanager.h | 2 +- src/otclient/core/game.cpp | 28 +++- src/otclient/core/game.h | 8 +- src/otclient/core/localplayer.h | 2 + src/otclient/luafunctions.cpp | 5 +- src/otclient/net/protocolcodes.h | 37 +++++ src/otclient/net/protocolgame.h | 4 +- src/otclient/net/protocolgamesend.cpp | 13 +- 27 files changed, 345 insertions(+), 146 deletions(-) delete mode 100644 modules/addon_mapeffects/mapeffects.lua delete mode 100644 modules/addon_mapeffects/mapeffects.otmod create mode 100644 modules/core_styles/icons/channels.png create mode 100644 modules/core_styles/icons/closechannel.png create mode 100644 modules/game_console/channelswindow.otui diff --git a/modules/addon_mapeffects/mapeffects.lua b/modules/addon_mapeffects/mapeffects.lua deleted file mode 100644 index 152290b6..00000000 --- a/modules/addon_mapeffects/mapeffects.lua +++ /dev/null @@ -1,18 +0,0 @@ -MapEffects = {} - -function MapEffects.init() ---[[ - local box = createWidget('ComboBox', 'leftButtonsPanel') - box:addAnchor(AnchorLeft, 'prev', AnchorRight) - box:addAnchor(AnchorTop, 'parent', AnchorTop) - box:setMargin(6, 6) - box:addOption('Normal') - box:addOption('Bloom') - box:addOption('TV') - displayUI(box) -]]-- -end - -function MapEffects.terminate() - -end diff --git a/modules/addon_mapeffects/mapeffects.otmod b/modules/addon_mapeffects/mapeffects.otmod deleted file mode 100644 index 90172be6..00000000 --- a/modules/addon_mapeffects/mapeffects.otmod +++ /dev/null @@ -1,16 +0,0 @@ -Module - name: mapeffects - description: Contains experimental shader effects for map - author: OTClient team - website: https://github.com/edubart/otclient - - // console can be loaded after core - autoLoad: true - autoLoadPriority: 1000 - - onLoad: | - require 'mapeffects' - MapEffects.init() - - onUnload: | - MapEffects.terminate() diff --git a/modules/addon_pingbar/pingbar.otmod b/modules/addon_pingbar/pingbar.otmod index ae22f279..f55172ca 100644 --- a/modules/addon_pingbar/pingbar.otmod +++ b/modules/addon_pingbar/pingbar.otmod @@ -5,7 +5,7 @@ Module website: https://github.com/edubart/otclient autoLoad: true - autoLoadPriority: 1000 + autoLoadAntecedence: 1000 onLoad: | require 'pingbar' diff --git a/modules/addon_playground/playground.otmod b/modules/addon_playground/playground.otmod index 5b0567ad..05a3d281 100644 --- a/modules/addon_playground/playground.otmod +++ b/modules/addon_playground/playground.otmod @@ -1,7 +1,7 @@ Module name: playground autoLoad: true - autoLoadPriority: 1000 + autoLoadAntecedence: 1000 onLoad: | require 'playground' diff --git a/modules/addon_terminal/terminal.otmod b/modules/addon_terminal/terminal.otmod index 7716c38c..7c3e2525 100644 --- a/modules/addon_terminal/terminal.otmod +++ b/modules/addon_terminal/terminal.otmod @@ -5,7 +5,7 @@ Module website: https://github.com/edubart/otclient autoLoad: true - autoLoadPriority: 200 + autoLoadAntecedence: 200 onLoad: | require 'terminal' diff --git a/modules/client_options/options.otui b/modules/client_options/options.otui index 8d995025..feaf0285 100644 --- a/modules/client_options/options.otui +++ b/modules/client_options/options.otui @@ -16,7 +16,7 @@ OptionCheckBox < CheckBox MainWindow id: optionsWindow text: Options - size: 286 230 + size: 286 250 @onEnter: Options.hide() @onEscape: Options.hide() @@ -58,9 +58,9 @@ MainWindow id: showLevelsInConsole text: Show levels in console - //OptionCheckBox - // id: showPrivateMessagesInConsole - // text: Show private messages in console + OptionCheckBox + id: showPrivateMessagesInConsole + text: Show private messages in console Button text: Ok diff --git a/modules/client_tibiafiles b/modules/client_tibiafiles index dd648e14..9beb17da 160000 --- a/modules/client_tibiafiles +++ b/modules/client_tibiafiles @@ -1 +1 @@ -Subproject commit dd648e1431171bffe091b748744395780df7eba1 +Subproject commit 9beb17daaeb170c127c39c5a5e4feb9d95ebed92 diff --git a/modules/core/core.otmod b/modules/core/core.otmod index 5dd9ec92..a8dcefa9 100644 --- a/modules/core/core.otmod +++ b/modules/core/core.otmod @@ -6,7 +6,7 @@ Module // core must be loaded before other modules autoLoad: true - autoLoadPriority: 10 + autoLoadAntecedence: 10 // NOTE: order does matter dependencies: diff --git a/modules/core_styles/icons/channels.png b/modules/core_styles/icons/channels.png new file mode 100644 index 0000000000000000000000000000000000000000..885ba2292c7d85c47b1858fd9c9b7f896c5b161e GIT binary patch literal 245 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6U4S$Y z{B+)352QE?JR*x37`TN&n2}-D90{Nxdx@v7EBhTrJ_aT8>=~ycfI_mFArU3c`MJ5N zc_lzD1A}u>YGO%hib8p2Nrr;Er*A-tUMf3K+{e?!F~s6@a)Lz0fsQjj|NpmN#^mNU ziRVYZKd;&02o8x~^0T=o@*YY%P|s8&;?1#>LD}ZQ-jgnwIy_Fy97nAknK!7j-YGib c^0 literal 0 HcmV?d00001 diff --git a/modules/core_styles/icons/closechannel.png b/modules/core_styles/icons/closechannel.png new file mode 100644 index 0000000000000000000000000000000000000000..0b130d45afe1279757eabcfe609a285f9e783c6c GIT binary patch literal 300 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6U4S$Y z{B+)352QE?JR*x37`TN&n2}-D90{Nxdx@v7EBhTrJ_coBzXrJzKq1-8kcblJ{M_8s zyb>Unfx)>bHL)Z$MWH;iBtya7(>EYRFO?lA-t6h(7-Dhy?4;YA2NZZ**Yhoqj`;rn z1=}UxU8mmqw`9~hXfJIPIPrMK42J!JliHSucdyZkdy=w0l!rZmU4UW6DuGAblOCJI zly8`5bL5p@-o|SjwkP&fFmx_*4L5dZbD6X}Z!gHBhA+P78 i+xAaScGOjH&p*v-sTDG%qMfG) 0 then + message = name .. ' [' .. level .. ']: ' .. message + else + message = name .. ': ' .. message + end + end + return message +end -- public functions function Console.create() consolePanel = displayUI('console.otui', { parent = Game.gameBottomPanel } ) + consoleLineEdit = consolePanel:getChildById('consoleLineEdit') consoleBuffer = consolePanel:getChildById('consoleBuffer') consoleTabBar = consolePanel:getChildById('consoleTabBar') consoleTabBar:setContentWidget(consoleBuffer) - defaultChannelTab = consoleTabBar:addTab('Default') - serverLogTab = consoleTabBar:addTab('Server Log') + channels = {} + + Console.addChannel('Default', 0) + Console.addTab('Server Log') Hotkeys.bind('Tab', function() consoleTabBar:selectNextTab() end, consolePanel) Hotkeys.bind('Shift+Tab', function() consoleTabBar:selectPrevTab() end, consolePanel) + Hotkeys.bind('Enter', Console.sendCurrentMessage, consolePanel) + Hotkeys.bind('Return', Console.sendCurrentMessage, consolePanel) end function Console.destroy() @@ -43,24 +59,84 @@ function Console.destroy() consolePanel = nil end -function Console.addText(text, color, channelTab) - color = color or 'white' +function Console.addTab(name) + local tab = consoleTabBar:addTab(name) + consoleTabBar:selectTab(tab) + return tab +end +function Console.getTab(name) + return consoleTabBar:getTab(name) +end + +function Console.getCurrentTab() + return consoleTabBar:getCurrentTab() +end + +function Console.addChannel(name, id) + channels[id] = name + local tab = Console.addTab(name) + tab.channelId = id + return tab +end + +function Console.addPrivateText(text, speaktype, name) + local privateTab = Console.getTab(name) + if privateTab == nil then + if Options.showPrivateMessagesInConsole then + privateTab = Console.getTab('Default') + else + privateTab = Console.addTab(name) + end + privateTab.npcChat = speaktype.npcChat + end + Console.addTabText(text, speaktype, privateTab) +end + +function Console.addText(text, speaktype, tabName) + local tab = Console.getTab(tabName) + Console.addTabText(text, speaktype, tab) +end + +function Console.addTabText(text, speaktype, tab) if Options.showTimestampsInConsole then text = os.date('%H:%M') .. ' ' .. text end - local label = createWidget('ConsoleLabel', consoleTabBar:getTabPanel(channelTab)) + local label = createWidget('ConsoleLabel', consoleTabBar:getTabPanel(tab)) label:setText(text) - label:setColor(color) - consoleTabBar:blinkTab(channelTab) + label:setColor(speaktype.color) + consoleTabBar:blinkTab(tab) end -function Console.addChannelMessage(text, color, channel) - if channel == 'Server Log' then - Console.addText(text, color, serverLogTab) - elseif channel == 'Default' then - Console.addText(text, color, defaultChannelTab) +function Console.sendCurrentMessage() + local message = consoleLineEdit:getText() + if #message == 0 then return end + consoleLineEdit:clearText() + + local tab = Console.getCurrentTab() + local name = tab:getText() + if name == 'Server Log' then name = 'Default' end + + local speaktypedesc = 'say' + if tab.npcChat then + speaktypedesc = 'playerToNpc' + end + + if tab.channelId then + if tab.channelId ~= 0 then + speaktypedesc = 'channelYellow' + end + + Game.talkChannel(speaktypedesc, tab.channelId, message) + return + else + local speaktype = SpeakTypes[speaktypedesc] + local player = Game.getLocalPlayer() + message = applyMessagePrefixies(player:getName(), player:getLevel(), message) + Console.addPrivateText(message, speaktype, name) + + Game.talkPrivate(speaktypedesc, name, message) end end @@ -69,17 +145,44 @@ local function onCreatureSpeak(name, level, speaktypedesc, message, channelId, c speaktype = SpeakTypes[speaktypedesc] if speaktype.hideInConsole then return end - if name then - if Options.showLevelsInConsole and level > 0 then - message = name .. ' [' .. level .. ']: ' .. message - else - message = name .. ': ' .. message - end + message = applyMessagePrefixies(name, level, message) + + if speaktype.private then + Console.addPrivateText(message, speaktype, name) + else + Console.addText(message, speaktype, channels[channelId]) end +end - Console.addText(message, speaktype.color, defaultChannelTab) +local function onOpenChannel(channelId, channelName) + Console.addChannel(channelName, channelId) +end + +local function onChannelList(channelList) + local channelsWindow = displayUI('channelswindow.otui') + local channelListPanel = channelsWindow:getChildById('channelList') + channelsWindow.onEnter = function(self) + local selectedChannelLabel = channelListPanel:getFocusedChild() + if not selectedChannelLabel then return end + --Game.joinChannel(selectedChannelLabel.channelId) + --Console.addChannel(selectedChannelLabel:getText(), selectedChannelLabel .channelId) + channelsWindow:destroy() + end + for k,v in pairs(channelList) do + local channelId = v[1] + local channelName = v[2] + + if channelId ~= 0 and #channelName > 0 then + local label = createWidget('ChannelListLabel', channelListPanel) + print(channelId, channelName) + label.channelId = channelId + label:setText(channelName) + end + end end connect(Game, { onLogin = Console.create, onLogout = Console.destroy, - onCreatureSpeak = onCreatureSpeak}) \ No newline at end of file + onCreatureSpeak = onCreatureSpeak, + onChannelList = onChannelList, + onOpenChannel = onOpenChannel}) \ No newline at end of file diff --git a/modules/game_console/console.otui b/modules/game_console/console.otui index 9afa2faa..7a04b629 100644 --- a/modules/game_console/console.otui +++ b/modules/game_console/console.otui @@ -34,12 +34,29 @@ Panel ConsoleButton id: nextChannelButton icon: /core_styles/icons/rightarrow.png - anchors.right: parent.right + anchors.right: next.left anchors.top: parent.top margin-right: 5 margin-top: 6 enabled: false + ConsoleButton + id: closeChannelButton + icon: /core_styles/icons/closechannel.png + anchors.right: next.left + anchors.top: parent.top + margin-right: 5 + margin-top: 6 + + ConsoleButton + id: channelsButton + icon: /core_styles/icons/channels.png + anchors.right: parent.right + anchors.top: parent.top + margin-right: 5 + margin-top: 6 + @onClick: Game.requestChannels() + Panel id: consoleBuffer anchors.top: prev.bottom diff --git a/modules/game_textmessage/textmessage.lua b/modules/game_textmessage/textmessage.lua index 739213b1..a79587f1 100644 --- a/modules/game_textmessage/textmessage.lua +++ b/modules/game_textmessage/textmessage.lua @@ -5,16 +5,16 @@ importStyle 'textmessage.otui' -- private variables local MessageTypes = { - consoleRed = { color = '#F55E5E', consoleChannel = 'Server Log' }, - eventOrange = { color = '#FE6500', consoleChannel = 'Default' , windowLocation = 'center', consoleOption = 'showEventMessagesInConsole' }, - consoleOrange = { color = '#FE6500', consoleChannel = 'Default' }, - warning = { color = '#F55E5E', consoleChannel = 'Server Log', windowLocation = 'center' }, - eventAdvance = { color = '#FFFFFF', consoleChannel = 'Server Log', windowLocation = 'center', consoleOption = 'showEventMessagesInConsole' }, - eventDefault = { color = '#FFFFFF', consoleChannel = 'Server Log', windowLocation = 'bottom', consoleOption = 'showEventMessagesInConsole' }, - statusDefault = { color = '#FFFFFF', consoleChannel = 'Server Log', windowLocation = 'bottom', consoleOption = 'showStatusMessagesInConsole' }, - infoDescription = { color = '#00EB00', consoleChannel = 'Server Log', windowLocation = 'center', consoleOption = 'showInfoMessagesInConsole' }, + consoleRed = { color = '#F55E5E', consoleTab = 'Server Log' }, + eventOrange = { color = '#FE6500', consoleTab = 'Default' , windowLocation = 'center', consoleOption = 'showEventMessagesInConsole' }, + consoleOrange = { color = '#FE6500', consoleTab = 'Default' }, + warning = { color = '#F55E5E', consoleTab = 'Server Log', windowLocation = 'center' }, + eventAdvance = { color = '#FFFFFF', consoleTab = 'Server Log', windowLocation = 'center', consoleOption = 'showEventMessagesInConsole' }, + eventDefault = { color = '#FFFFFF', consoleTab = 'Server Log', windowLocation = 'bottom', consoleOption = 'showEventMessagesInConsole' }, + statusDefault = { color = '#FFFFFF', consoleTab = 'Server Log', windowLocation = 'bottom', consoleOption = 'showStatusMessagesInConsole' }, + infoDescription = { color = '#00EB00', consoleTab = 'Server Log', windowLocation = 'center', consoleOption = 'showInfoMessagesInConsole' }, statusSmall = { color = '#FFFFFF', windowLocation = 'bottom' }, - consoleBlue = { color = '#9F9DFD', consoleChannel = 'Default' }, + consoleBlue = { color = '#9F9DFD', consoleTab = 'Default' }, } local bottomLabelWidget @@ -26,9 +26,9 @@ local centerLabelHideEvent local function displayMessage(msgtype, msg, time) if not Game.isOnline() then return end - if msgtype.consoleChannel ~= nil then + if msgtype.consoleTab ~= nil then if msgtype.consoleOption == nil or Options[msgtype.consoleOption] then - Console.addChannelMessage(msg, msgtype.color, msgtype.consoleChannel) + Console.addText(msg, msgtype, msgtype.consoleTab) end end diff --git a/src/framework/core/module.cpp b/src/framework/core/module.cpp index 160e3f89..7af5fc9a 100644 --- a/src/framework/core/module.cpp +++ b/src/framework/core/module.cpp @@ -39,7 +39,7 @@ void Module::discover(const OTMLNodePtr& moduleNode) m_website = moduleNode->valueAt("website", none); m_version = moduleNode->valueAt("version", none); m_autoLoad = moduleNode->valueAt("autoLoad", false); - m_autoLoadPriority = moduleNode->valueAt("autoLoadPriority", 100); + m_autoLoadAntecedence = moduleNode->valueAt("autoLoadAntecedence", 100); if(OTMLNodePtr node = moduleNode->get("dependencies")) { for(const OTMLNodePtr& tmp : node->children()) diff --git a/src/framework/core/module.h b/src/framework/core/module.h index 6a4650bc..ee43ff1f 100644 --- a/src/framework/core/module.h +++ b/src/framework/core/module.h @@ -44,12 +44,12 @@ public: std::string getWebsite() { return m_website; } std::string getVersion() { return m_version; } bool isAutoLoad() { return m_autoLoad; } - int getAutoLoadPriority() { return m_autoLoadPriority; } + int getAutoLoadAntecedence() { return m_autoLoadAntecedence; } private: Boolean m_loaded; Boolean m_autoLoad; - int m_autoLoadPriority; + int m_autoLoadAntecedence; std::string m_name; std::string m_description; std::string m_author; diff --git a/src/framework/core/modulemanager.cpp b/src/framework/core/modulemanager.cpp index 4a6b7670..6af78872 100644 --- a/src/framework/core/modulemanager.cpp +++ b/src/framework/core/modulemanager.cpp @@ -37,17 +37,17 @@ void ModuleManager::discoverModules() if(boost::ends_with(moduleFile, ".otmod")) { ModulePtr module = discoverModule("/" + moduleDir + "/" + moduleFile); if(module && module->isAutoLoad()) - m_autoLoadModules.insert(make_pair(module->getAutoLoadPriority(), module)); + m_autoLoadModules.insert(make_pair(module->getAutoLoadAntecedence(), module)); } } } } -void ModuleManager::autoLoadModules(int maxPriority) +void ModuleManager::autoLoadModules(int maxAntecedence) { for(auto& pair : m_autoLoadModules) { int priority = pair.first; - if(priority > maxPriority) + if(priority > maxAntecedence) break; ModulePtr module = pair.second; if(!module->isLoaded() && !module->load()) diff --git a/src/framework/core/modulemanager.h b/src/framework/core/modulemanager.h index ab3a26f0..2419b511 100644 --- a/src/framework/core/modulemanager.h +++ b/src/framework/core/modulemanager.h @@ -30,7 +30,7 @@ class ModuleManager public: void discoverModulesPath(); void discoverModules(); - void autoLoadModules(int maxPriority); + void autoLoadModules(int maxAntecedence); ModulePtr discoverModule(const std::string& moduleFile); void ensureModuleLoaded(const std::string& moduleName); void unloadModules(); diff --git a/src/otclient/core/game.cpp b/src/otclient/core/game.cpp index 7fce3d9e..b2b31b6b 100644 --- a/src/otclient/core/game.cpp +++ b/src/otclient/core/game.cpp @@ -340,23 +340,23 @@ int Game::getThingStackpos(const ThingPtr& thing) void Game::talk(const std::string& message) { - talkChannel(1, 0, message); + talkChannel("say", 0, message); } -void Game::talkChannel(int channelType, int channelId, const std::string& message) +void Game::talkChannel(const std::string& speakTypeDesc, int channelId, const std::string& message) { if(!m_online || !checkBotProtection()) return; - m_protocolGame->sendTalk(channelType, channelId, "", message); + m_protocolGame->sendTalk(speakTypeDesc, channelId, "", message); } -void Game::talkPrivate(int channelType, const std::string& receiver, const std::string& message) +void Game::talkPrivate(const std::string& speakTypeDesc, const std::string& receiver, const std::string& message) { if(!m_online || !checkBotProtection()) return; - m_protocolGame->sendTalk(channelType, 0, receiver, message); + m_protocolGame->sendTalk(speakTypeDesc, 0, receiver, message); } void Game::partyInvite(int creatureId) @@ -408,7 +408,7 @@ void Game::partyShareExperience(bool active) m_protocolGame->sendShareExperience(active, 0); } -void Game::openOutfitWindow() +void Game::requestOutfit() { if(!m_online || !checkBotProtection()) return; @@ -416,6 +416,22 @@ void Game::openOutfitWindow() 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) { if(!m_online || !checkBotProtection()) diff --git a/src/otclient/core/game.h b/src/otclient/core/game.h index a9334d62..cb2036e2 100644 --- a/src/otclient/core/game.h +++ b/src/otclient/core/game.h @@ -66,15 +66,17 @@ public: void cancelFollow(); void rotate(const ThingPtr& thing); void talk(const std::string& message); - void talkChannel(int channelType, int channelId, const std::string& message); - void talkPrivate(int channelType, const std::string& receiver, 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 partyInvite(int creatureId); void partyJoin(int creatureId); void partyRevokeInvitation(int creatureId); void partyPassLeadership(int creatureId); void partyLeave(); void partyShareExperience(bool active); - void openOutfitWindow(); + void requestOutfit(); + void requestChannels(); + void openChannel(int channelId); void setOutfit(const Outfit& outfit); void addVip(const std::string& name); void removeVip(int playerId); diff --git a/src/otclient/core/localplayer.h b/src/otclient/core/localplayer.h index dff399fc..a180d67f 100644 --- a/src/otclient/core/localplayer.h +++ b/src/otclient/core/localplayer.h @@ -55,6 +55,8 @@ public: LocalPlayerPtr asLocalPlayer() { return std::static_pointer_cast(shared_from_this()); } + double getLevel() { return getStatistic(Otc::Level); } + private: bool m_canReportBugs; bool m_clientWalking; diff --git a/src/otclient/luafunctions.cpp b/src/otclient/luafunctions.cpp index daf57e0e..7349c9a7 100644 --- a/src/otclient/luafunctions.cpp +++ b/src/otclient/luafunctions.cpp @@ -145,6 +145,7 @@ void OTClient::registerLuaFunctions() g_lua.registerClass(); g_lua.bindClassMemberFunction("getAttackingCreature", &LocalPlayer::getAttackingCreature); g_lua.bindClassMemberFunction("getFollowingCreature", &LocalPlayer::getFollowingCreature); + g_lua.bindClassMemberFunction("getLevel", &LocalPlayer::getLevel); g_lua.registerClass(); g_lua.bindClassMemberFunction("clean", &Tile::clean); @@ -177,7 +178,9 @@ void OTClient::registerLuaFunctions() g_lua.bindClassStaticFunction("logout", std::bind(&Game::logout, &g_game, _1)); g_lua.bindClassStaticFunction("cancelLogin", std::bind(&Game::cancelLogin, &g_game)); g_lua.bindClassStaticFunction("isOnline", std::bind(&Game::isOnline, &g_game)); - g_lua.bindClassStaticFunction("openOutfitWindow", std::bind(&Game::openOutfitWindow, &g_game)); + g_lua.bindClassStaticFunction("requestOutfit", std::bind(&Game::requestOutfit, &g_game)); + g_lua.bindClassStaticFunction("requestChannels", std::bind(&Game::requestChannels, &g_game)); + g_lua.bindClassStaticFunction("openChannel", std::bind(&Game::openChannel, &g_game, _1)); g_lua.bindClassStaticFunction("setOutfit", std::bind(&Game::setOutfit, &g_game, _1)); g_lua.bindClassStaticFunction("look", std::bind(&Game::look, &g_game, _1)); g_lua.bindClassStaticFunction("open", std::bind(&Game::open, &g_game, _1, _2)); diff --git a/src/otclient/net/protocolcodes.h b/src/otclient/net/protocolcodes.h index 399b1fd0..14100230 100644 --- a/src/otclient/net/protocolcodes.h +++ b/src/otclient/net/protocolcodes.h @@ -336,6 +336,43 @@ namespace Proto { } } + inline int translateSpeakTypeDesc(const std::string& type) { + if(type == "say") + return Proto::SpeakSay; + else if(type == "whisper") + return Proto::SpeakWhisper; + else if(type == "yell") + return Proto::SpeakYell; + else if(type == "monsterSay") + return Proto::SpeakMonsterSay; + else if(type == "monsterYell") + return Proto::SpeakMonsterYell; + else if(type == "npcToPlayer") + return Proto::SpeakPrivateNpcToPlayer; + else if(type == "channelYellow") + return Proto::SpeakChannelYellow; + else if(type == "channelWhite") + return Proto::SpeakChannelWhite; + else if(type == "channelRed") + return Proto::SpeakChannelRed; + else if(type == "channelRed") + return Proto::SpeakChannelRed2; + else if(type == "channelOrange") + return Proto::SpeakChannelOrange; + else if(type == "private") + return Proto::SpeakPrivate; + else if(type == "playerToNpc") + return Proto::SpeakPrivatePlayerToNpc; + else if(type == "broadcast") + return Proto::SpeakBroadcast; + else if(type == "privateRed") + return Proto::SpeakPrivateRed; + else { + logError("unknown protocol speak type desc ", type); + return 0; + } + } + inline std::string translateTextMessageType(int type) { switch(type) { case Proto::MessageConsoleOrange: diff --git a/src/otclient/net/protocolgame.h b/src/otclient/net/protocolgame.h index a8e15421..cd207c9f 100644 --- a/src/otclient/net/protocolgame.h +++ b/src/otclient/net/protocolgame.h @@ -73,7 +73,7 @@ public: void sendTextWindow(uint windowTextId, const std::string& text); void sendHouseWindow(int doorId, uint id, const std::string& text); void sendLookAt(const Position& position, int thingId, int stackpos); - void sendTalk(int channelType, int channelId, const std::string& receiver, const std::string& message); + void sendTalk(const std::string& speakTypeDesc, int channelId, const std::string& receiver, const std::string& message); void sendGetChannels(); void sendJoinChannel(int channelId); void sendLeaveChannel(int channelId); @@ -88,7 +88,7 @@ public: void sendPassLeadership(uint creatureId); void sendLeaveParty(); void sendShareExperience(bool active, int unknown); - void sendOpenChannel(); + void sendOpenChannel(int channelId); void sendInviteToChannel(const std::string& name); void sendExcludeFromChannel(const std::string& name); void sendCancel(); diff --git a/src/otclient/net/protocolgamesend.cpp b/src/otclient/net/protocolgamesend.cpp index 493c01ef..5c5e66f0 100644 --- a/src/otclient/net/protocolgamesend.cpp +++ b/src/otclient/net/protocolgamesend.cpp @@ -341,18 +341,18 @@ void ProtocolGame::sendLookAt(const Position& position, int thingId, int stackpo send(oMsg); } -void ProtocolGame::sendTalk(int channelType, int channelId, const std::string& receiver, const std::string& message) +void ProtocolGame::sendTalk(const std::string& speakTypeDesc, int channelId, const std::string& receiver, const std::string& message) { if(message.length() > 255 || message.length() <= 0) return; + int speakType = Proto::translateSpeakTypeDesc(speakTypeDesc); + OutputMessage oMsg; oMsg.addU8(Proto::ClientTalk); + oMsg.addU8(speakType); - assert(channelType >= 0); - oMsg.addU8(channelType); - - switch(channelType) { + switch(speakType) { case Proto::SpeakPrivate: case Proto::SpeakPrivateRed: oMsg.addString(receiver); @@ -486,10 +486,11 @@ void ProtocolGame::sendShareExperience(bool active, int unknown) send(oMsg); } -void ProtocolGame::sendOpenChannel() +void ProtocolGame::sendOpenChannel(int channelId) { OutputMessage oMsg; oMsg.addU8(Proto::ClientOpenChannel); + oMsg.addU16(channelId); send(oMsg); }