some chat functionality
This commit is contained in:
parent
aae784468b
commit
61aa710d1c
|
@ -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
|
|
@ -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()
|
|
@ -5,7 +5,7 @@ Module
|
|||
website: https://github.com/edubart/otclient
|
||||
|
||||
autoLoad: true
|
||||
autoLoadPriority: 1000
|
||||
autoLoadAntecedence: 1000
|
||||
|
||||
onLoad: |
|
||||
require 'pingbar'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
Module
|
||||
name: playground
|
||||
autoLoad: true
|
||||
autoLoadPriority: 1000
|
||||
autoLoadAntecedence: 1000
|
||||
onLoad: |
|
||||
require 'playground'
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ Module
|
|||
website: https://github.com/edubart/otclient
|
||||
|
||||
autoLoad: true
|
||||
autoLoadPriority: 200
|
||||
autoLoadAntecedence: 200
|
||||
|
||||
onLoad: |
|
||||
require 'terminal'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit dd648e1431171bffe091b748744395780df7eba1
|
||||
Subproject commit 9beb17daaeb170c127c39c5a5e4feb9d95ebed92
|
|
@ -6,7 +6,7 @@ Module
|
|||
|
||||
// core must be loaded before other modules
|
||||
autoLoad: true
|
||||
autoLoadPriority: 10
|
||||
autoLoadAntecedence: 10
|
||||
|
||||
// NOTE: order does matter
|
||||
dependencies:
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 245 B |
Binary file not shown.
After Width: | Height: | Size: 300 B |
|
@ -1,14 +1,14 @@
|
|||
UITabBar = extends(UIWidget)
|
||||
|
||||
-- private functions
|
||||
local function onTabClick(tabButton)
|
||||
tabButton.tabBar:selectTab(tabButton)
|
||||
local function onTabClick(tab)
|
||||
tab.tabBar:selectTab(tab)
|
||||
end
|
||||
|
||||
local function tabBlink(tabButton)
|
||||
if not tabButton.blinking then return end
|
||||
tabButton:setOn(not tabButton:isOn())
|
||||
scheduleEvent(function() tabBlink(tabButton) end, 500)
|
||||
local function tabBlink(tab)
|
||||
if not tab.blinking then return end
|
||||
tab:setOn(not tab:isOn())
|
||||
scheduleEvent(function() tabBlink(tab) end, 500)
|
||||
end
|
||||
|
||||
-- public functions
|
||||
|
@ -31,44 +31,52 @@ function UITabBar:addTab(text, panel)
|
|||
panel = createWidget(self:getStyleName() .. 'Panel')
|
||||
end
|
||||
|
||||
local tabButton = createWidget(self:getStyleName() .. 'Button', self)
|
||||
tabButton.tabPanel = panel
|
||||
tabButton.tabBar = self
|
||||
tabButton:setText(text)
|
||||
tabButton:setWidth(tabButton:getTextSize().width + tabButton:getPaddingLeft() + tabButton:getPaddingRight())
|
||||
connect(tabButton, { onClick = onTabClick })
|
||||
local tab = createWidget(self:getStyleName() .. 'Button', self)
|
||||
tab.tabPanel = panel
|
||||
tab.tabBar = self
|
||||
tab:setText(text)
|
||||
tab:setWidth(tab:getTextSize().width + tab:getPaddingLeft() + tab:getPaddingRight())
|
||||
connect(tab, { onClick = onTabClick })
|
||||
|
||||
table.insert(self.tabs, tabButton)
|
||||
table.insert(self.tabs, tab)
|
||||
if #self.tabs == 1 then
|
||||
self:selectTab(tabButton)
|
||||
self:selectTab(tab)
|
||||
end
|
||||
|
||||
return tabButton
|
||||
return tab
|
||||
end
|
||||
|
||||
function UITabBar:selectTab(tabButton)
|
||||
if self.currentTabButton == tabButton then return end
|
||||
function UITabBar:getTab(text)
|
||||
for k,tab in pairs(self.tabs) do
|
||||
if tab:getText() == text then
|
||||
return tab
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function UITabBar:selectTab(tab)
|
||||
if self.currentTab == tab then return end
|
||||
if self.contentWidget then
|
||||
local selectedWidget = self.contentWidget:getFirstChild()
|
||||
if selectedWidget then
|
||||
self.contentWidget:removeChild(selectedWidget)
|
||||
end
|
||||
self.contentWidget:addChild(tabButton.tabPanel)
|
||||
tabButton.tabPanel:fill('parent')
|
||||
self.contentWidget:addChild(tab.tabPanel)
|
||||
tab.tabPanel:fill('parent')
|
||||
end
|
||||
|
||||
if self.currentTabButton then
|
||||
self.currentTabButton:setChecked(false)
|
||||
if self.currentTab then
|
||||
self.currentTab:setChecked(false)
|
||||
end
|
||||
self.currentTabButton = tabButton
|
||||
tabButton:setChecked(true)
|
||||
tabButton:setOn(false)
|
||||
tabButton.blinking = false
|
||||
self.currentTab = tab
|
||||
tab:setChecked(true)
|
||||
tab:setOn(false)
|
||||
tab.blinking = false
|
||||
end
|
||||
|
||||
function UITabBar:selectNextTab()
|
||||
if self.currentTabButton == nil then return end
|
||||
local index = table.find(self.tabs, self.currentTabButton)
|
||||
if self.currentTab == nil then return end
|
||||
local index = table.find(self.tabs, self.currentTab)
|
||||
if index == nil then return end
|
||||
local nextTab = self.tabs[index + 1] or self.tabs[1]
|
||||
if not nextTab then return end
|
||||
|
@ -76,26 +84,30 @@ function UITabBar:selectNextTab()
|
|||
end
|
||||
|
||||
function UITabBar:selectPrevTab()
|
||||
if self.currentTabButton == nil then return end
|
||||
local index = table.find(self.tabs, self.currentTabButton)
|
||||
if self.currentTab == nil then return end
|
||||
local index = table.find(self.tabs, self.currentTab)
|
||||
if index == nil then return end
|
||||
local prevTab = self.tabs[index - 1] or self.tabs[#self.tabs]
|
||||
if not prevTab then return end
|
||||
self:selectTab(prevTab)
|
||||
end
|
||||
|
||||
function UITabBar:blinkTab(tabButton)
|
||||
if tabButton:isChecked() or tabButton.blinking then return end
|
||||
tabButton.blinking = true
|
||||
tabBlink(tabButton)
|
||||
function UITabBar:blinkTab(tab)
|
||||
if tab:isChecked() or tab.blinking then return end
|
||||
tab.blinking = true
|
||||
tabBlink(tab)
|
||||
end
|
||||
|
||||
function UITabBar:getTabPanel(tabButton)
|
||||
return tabButton.tabPanel
|
||||
function UITabBar:getTabPanel(tab)
|
||||
return tab.tabPanel
|
||||
end
|
||||
|
||||
function UITabBar:getCurrentTabPanel()
|
||||
if self.currentTabButton then
|
||||
return self.currentTabButton.tabPanel
|
||||
if self.currentTab then
|
||||
return self.currentTab.tabPanel
|
||||
end
|
||||
end
|
||||
|
||||
function UITabBar:getCurrentTab()
|
||||
return self.currentTab
|
||||
end
|
|
@ -133,7 +133,7 @@ function Game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
|||
menu:addSeparator()
|
||||
|
||||
if creatureThing:asLocalPlayer() then
|
||||
menu:addOption('Set Outfit', function() Game.openOutfitWindow() end)
|
||||
menu:addOption('Set Outfit', function() Game.requestOutfit() end)
|
||||
|
||||
if creatureThing:asPlayer():isPartyMember() --[[and not fighting]] then
|
||||
if creatureThing:asPlayer():isPartyLeader() then
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
ChannelListLabel < Label
|
||||
font: verdana-11px-monochrome
|
||||
background-color: alpha
|
||||
text-offset: 2 0
|
||||
focusable: true
|
||||
|
||||
$focus:
|
||||
background-color: #ffffff22
|
||||
color: #ffffff
|
||||
|
||||
MainWindow
|
||||
id: channelsWindow
|
||||
text: Channels
|
||||
size: 250 208
|
||||
@onEscape: self:destroy()
|
||||
|
||||
TextList
|
||||
id: channelList
|
||||
anchors.fill: parent
|
||||
anchors.bottom: next.top
|
||||
margin-bottom: 10
|
||||
padding: 1
|
||||
focusable: false
|
||||
|
||||
Button
|
||||
id: buttonOpen
|
||||
text: Open
|
||||
width: 64
|
||||
anchors.right: next.left
|
||||
anchors.bottom: parent.bottom
|
||||
margin-right: 10
|
||||
@onClick: self:getParent():onEnter()
|
||||
|
||||
Button
|
||||
id: buttonCancel
|
||||
text: Cancel
|
||||
width: 64
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
@onClick: self:getParent():destroy()
|
|
@ -7,35 +7,51 @@ local SpeakTypes = {
|
|||
yell = { color = '#FFFF00' },
|
||||
monsterSay = { color = '#FE6500', hideInConsole = true},
|
||||
monsterYell = { color = '#FE6500', hideInConsole = true},
|
||||
npcToPlayer = { color = '#5FF7F7' },
|
||||
npcToPlayer = { color = '#5FF7F7', private = true, npcChat = true },
|
||||
channelYellow = { color = '#FFFF00' },
|
||||
channelWhite = { color = '#FFFFFF' },
|
||||
channelRed = { color = '#F55E5E' },
|
||||
channelOrange = { color = '#FE6500' },
|
||||
private = { color = '#5FF7F7' },
|
||||
playerToNpc = { color = '#9F9DFD' },
|
||||
broadcast = { color = '#F55E5E' },
|
||||
privateRed = { color = '#F55E5E' }
|
||||
private = { color = '#5FF7F7', private = true },
|
||||
playerToNpc = { color = '#9F9DFD', private = true, npcChat = true },
|
||||
broadcast = { color = '#F55E5E', private = true },
|
||||
privateRed = { color = '#F55E5E', private = true }
|
||||
}
|
||||
|
||||
local consolePanel
|
||||
local consoleBuffer
|
||||
local consoleTabBar
|
||||
local defaultChannelTab
|
||||
local serverLogTab
|
||||
local currentTab
|
||||
local consoleLineEdit
|
||||
local channels
|
||||
|
||||
-- private functions
|
||||
function applyMessagePrefixies(name, level, message)
|
||||
if name then
|
||||
if Options.showLevelsInConsole and level > 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
|
||||
message = applyMessagePrefixies(name, level, message)
|
||||
|
||||
if speaktype.private then
|
||||
Console.addPrivateText(message, speaktype, name)
|
||||
else
|
||||
message = name .. ': ' .. message
|
||||
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})
|
||||
onCreatureSpeak = onCreatureSpeak,
|
||||
onChannelList = onChannelList,
|
||||
onOpenChannel = onOpenChannel})
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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<bool>("autoLoad", false);
|
||||
m_autoLoadPriority = moduleNode->valueAt<int>("autoLoadPriority", 100);
|
||||
m_autoLoadAntecedence = moduleNode->valueAt<int>("autoLoadAntecedence", 100);
|
||||
|
||||
if(OTMLNodePtr node = moduleNode->get("dependencies")) {
|
||||
for(const OTMLNodePtr& tmp : node->children())
|
||||
|
|
|
@ -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<false> m_loaded;
|
||||
Boolean<false> m_autoLoad;
|
||||
int m_autoLoadPriority;
|
||||
int m_autoLoadAntecedence;
|
||||
std::string m_name;
|
||||
std::string m_description;
|
||||
std::string m_author;
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -55,6 +55,8 @@ public:
|
|||
|
||||
LocalPlayerPtr asLocalPlayer() { return std::static_pointer_cast<LocalPlayer>(shared_from_this()); }
|
||||
|
||||
double getLevel() { return getStatistic(Otc::Level); }
|
||||
|
||||
private:
|
||||
bool m_canReportBugs;
|
||||
bool m_clientWalking;
|
||||
|
|
|
@ -145,6 +145,7 @@ void OTClient::registerLuaFunctions()
|
|||
g_lua.registerClass<LocalPlayer, Player>();
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("getAttackingCreature", &LocalPlayer::getAttackingCreature);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("getFollowingCreature", &LocalPlayer::getFollowingCreature);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("getLevel", &LocalPlayer::getLevel);
|
||||
|
||||
g_lua.registerClass<Tile>();
|
||||
g_lua.bindClassMemberFunction<Tile>("clean", &Tile::clean);
|
||||
|
@ -177,7 +178,9 @@ void OTClient::registerLuaFunctions()
|
|||
g_lua.bindClassStaticFunction<Game>("logout", std::bind(&Game::logout, &g_game, _1));
|
||||
g_lua.bindClassStaticFunction<Game>("cancelLogin", std::bind(&Game::cancelLogin, &g_game));
|
||||
g_lua.bindClassStaticFunction<Game>("isOnline", std::bind(&Game::isOnline, &g_game));
|
||||
g_lua.bindClassStaticFunction<Game>("openOutfitWindow", std::bind(&Game::openOutfitWindow, &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>("openChannel", std::bind(&Game::openChannel, &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>("open", std::bind(&Game::open, &g_game, _1, _2));
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue