mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
add chat panel, send text messages, guard forbidden functions with an ifdef
This commit is contained in:
19
modules/chat/chat.lua
Normal file
19
modules/chat/chat.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
Chat = {}
|
||||
|
||||
-- private variables
|
||||
local chatPanel
|
||||
|
||||
-- public functions
|
||||
function Chat.create()
|
||||
chatPanel = loadUI("/chat/chat.otui", Game.gameBottomPanel)
|
||||
end
|
||||
|
||||
function Chat.destroy()
|
||||
chatPanel:destroy()
|
||||
chatPanel = nil
|
||||
end
|
||||
|
||||
-- hooked events
|
||||
|
||||
connect(Game, { onLogin = Chat.create,
|
||||
onLogout = Chat.destroy })
|
14
modules/chat/chat.otmod
Normal file
14
modules/chat/chat.otmod
Normal file
@@ -0,0 +1,14 @@
|
||||
Module
|
||||
name: chat
|
||||
description: Manage chat window
|
||||
author: OTClient team
|
||||
website: https://github.com/edubart/otclient
|
||||
autoLoad: true
|
||||
dependencies:
|
||||
- game
|
||||
|
||||
onLoad: |
|
||||
require 'chat'
|
||||
return true
|
||||
|
||||
|
30
modules/chat/chat.otui
Normal file
30
modules/chat/chat.otui
Normal file
@@ -0,0 +1,30 @@
|
||||
ChatLabel < UILabel
|
||||
font: verdana-11px-monochrome
|
||||
height: 16
|
||||
|
||||
Panel
|
||||
id: chatPanel
|
||||
anchors.fill: parent
|
||||
|
||||
Panel
|
||||
id: chatBuffer
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: next.top
|
||||
margin.right: 6
|
||||
margin.left: 6
|
||||
margin.bottom: 2
|
||||
margin.top: 6
|
||||
layout: verticalBox
|
||||
focusable: false
|
||||
|
||||
LineEdit
|
||||
id: chatLineEdit
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin.right: 6
|
||||
margin.left: 6
|
||||
margin.bottom: 6
|
||||
always focused: true
|
@@ -8,7 +8,7 @@ RectPanel
|
||||
opacity: 216
|
||||
anchors.fill: parent
|
||||
|
||||
UIWidget
|
||||
Panel
|
||||
id: consoleBuffer
|
||||
layout: verticalBox
|
||||
focusable: false
|
||||
|
@@ -18,9 +18,8 @@ function connect(object, signalsAndSlots)
|
||||
object[signal] = slot
|
||||
elseif type(object[signal]) == 'function' then
|
||||
object[signal] = { object[signal], slot }
|
||||
elseif type(signal) == 'table' then
|
||||
table.insert(object[signal], slot)
|
||||
else
|
||||
elseif type(object[signal]) == 'table' then
|
||||
table.insert(object[signal], #object[signal]+1, slot)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -15,20 +15,23 @@ local function onGameKeyPress(self, keyCode, keyChar, keyboardModifiers)
|
||||
end
|
||||
|
||||
-- public functions
|
||||
function Game.create()
|
||||
function Game.createInterface()
|
||||
Background.hide()
|
||||
CharacterList.destroyLoadBox()
|
||||
Game.gameUi = loadUI('/game/ui/gameinterface.otui', UI.root)
|
||||
Game.gameMapPanel = Game.gameUi:getChildById('mapPanel')
|
||||
Game.gameRightPanel = Game.gameUi:getChildById('rightPanel')
|
||||
Game.gameBottomPanel = Game.gameUi:getChildById('bottomPanel')
|
||||
Game.gameUi.onKeyPress = onGameKeyPress
|
||||
|
||||
TextMessage.create()
|
||||
end
|
||||
|
||||
function Game.destroy()
|
||||
function Game.destroyInterface()
|
||||
if Game.gameUi then
|
||||
Game.gameUi:destroy()
|
||||
Game.gameUi = nil
|
||||
end
|
||||
Background.show()
|
||||
CharacterList.show()
|
||||
end
|
||||
|
||||
function Game.show()
|
||||
@@ -42,12 +45,6 @@ function Game.hide()
|
||||
end
|
||||
|
||||
-- hooked events
|
||||
function Game.onLogin()
|
||||
Background.hide()
|
||||
CharacterList.destroyLoadBox()
|
||||
Game.show()
|
||||
end
|
||||
|
||||
function Game.onLoginError(message)
|
||||
CharacterList.destroyLoadBox()
|
||||
local errorBox = displayErrorBox("Login Error", "Login error: " .. message)
|
||||
@@ -60,8 +57,5 @@ function Game.onConnectionError(message)
|
||||
errorBox.onOk = CharacterList.show
|
||||
end
|
||||
|
||||
function Game.onLogout()
|
||||
Game.hide()
|
||||
Background.show()
|
||||
CharacterList.show()
|
||||
end
|
||||
connect(Game, { onLogin = Game.createInterface,
|
||||
onLogout = Game.destroyInterface })
|
||||
|
@@ -13,7 +13,4 @@ Module
|
||||
|
||||
onLoad: |
|
||||
require 'game'
|
||||
require 'textmessage'
|
||||
Game.create()
|
||||
Game.hide()
|
||||
return true
|
||||
|
@@ -43,4 +43,7 @@ end
|
||||
function Game.setSkill(id, level, percent)
|
||||
local skillPanel = skillWindow:getChildById('skillPanel')
|
||||
local levelLabel = skillPanel:getChildById('skillLevel' .. id)
|
||||
end
|
||||
end
|
||||
|
||||
connect(Game, { onLogin = Skills.create,
|
||||
onLogout = Skills.destroy })
|
@@ -9,10 +9,6 @@ Module
|
||||
|
||||
onLoad: |
|
||||
require 'skills'
|
||||
Skills.create()
|
||||
return true
|
||||
|
||||
onUnload:
|
||||
Skills.destroy()
|
||||
|
||||
|
||||
|
@@ -44,3 +44,6 @@ function Game.onVipStateChange(id, online)
|
||||
|
||||
label.vipOnline = online
|
||||
end
|
||||
|
||||
connect(Game, { onLogin = VipList.create,
|
||||
onLogout = VipList.destroy })
|
||||
|
@@ -9,10 +9,6 @@ Module
|
||||
|
||||
onLoad: |
|
||||
require 'viplist'
|
||||
VipList.create()
|
||||
return true
|
||||
|
||||
onUnload:
|
||||
VipList.destroy()
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user