parent
add8505a5b
commit
88301c329a
@ -0,0 +1,3 @@
|
|||||||
|
*
|
||||||
|
!/README.txt
|
||||||
|
!.gitignore
|
@ -0,0 +1 @@
|
|||||||
|
You can plance any personal addons here.
|
@ -1,24 +0,0 @@
|
|||||||
Module
|
|
||||||
name: client
|
|
||||||
description: Load all other otclient dependecies
|
|
||||||
author: OTClient team
|
|
||||||
website: https://github.com/edubart/otclient
|
|
||||||
canUnload: false
|
|
||||||
|
|
||||||
// NOTE: order does matter
|
|
||||||
dependencies:
|
|
||||||
- client_background
|
|
||||||
- client_topmenu
|
|
||||||
- client_tibiafiles
|
|
||||||
- client_about
|
|
||||||
- client_options
|
|
||||||
- client_entergame
|
|
||||||
- client_modulemanager
|
|
||||||
- game
|
|
||||||
|
|
||||||
onLoad: |
|
|
||||||
dofile 'client'
|
|
||||||
Client.init()
|
|
||||||
|
|
||||||
onUnload: |
|
|
||||||
Client.terminate()
|
|
@ -0,0 +1,14 @@
|
|||||||
|
Module
|
||||||
|
name: client_main
|
||||||
|
description: Initialize the client and setups its main window
|
||||||
|
author: OTClient team
|
||||||
|
website: https://github.com/edubart/otclient
|
||||||
|
autoload: true
|
||||||
|
autoload-antecedence: 100
|
||||||
|
|
||||||
|
onLoad: |
|
||||||
|
dofile 'client'
|
||||||
|
Client.init()
|
||||||
|
|
||||||
|
onUnload: |
|
||||||
|
Client.terminate()
|
Before Width: | Height: | Size: 518 B After Width: | Height: | Size: 518 B |
@ -1,11 +1,10 @@
|
|||||||
Module
|
Module
|
||||||
name: terminal
|
name: client_terminal
|
||||||
description: Terminal for executing lua functions
|
description: Terminal for executing lua functions
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
|
autoload: true
|
||||||
autoLoad: true
|
autoload-antecedence: 160
|
||||||
autoLoadAntecedence: 200
|
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
dofile 'terminal'
|
dofile 'terminal'
|
Before Width: | Height: | Size: 459 B After Width: | Height: | Size: 459 B |
@ -1,17 +0,0 @@
|
|||||||
Module
|
|
||||||
name: core
|
|
||||||
description: Contains lua classes, functions and constants used by other modules
|
|
||||||
author: OTClient team
|
|
||||||
website: https://github.com/edubart/otclient
|
|
||||||
|
|
||||||
// core must be loaded before other modules
|
|
||||||
autoLoad: true
|
|
||||||
autoLoadAntecedence: 10
|
|
||||||
|
|
||||||
// NOTE: order does matter
|
|
||||||
dependencies:
|
|
||||||
- core_lib
|
|
||||||
- core_fonts
|
|
||||||
- core_styles
|
|
||||||
- core_widgets
|
|
||||||
|
|
@ -1,34 +1,20 @@
|
|||||||
local eventId = 0
|
|
||||||
local eventList = {}
|
|
||||||
|
|
||||||
function scheduleEvent(func, delay)
|
function scheduleEvent(func, delay)
|
||||||
if not func then return end
|
local event = g_dispatcher.scheduleEvent(callback, delay)
|
||||||
eventId = eventId + 1
|
|
||||||
local id = eventId
|
-- must hold a reference to the callback, otherwise it would be collected
|
||||||
local function proxyFunc()
|
event._callback = callback
|
||||||
if eventList[id] then
|
return event
|
||||||
if eventList[id].active then
|
|
||||||
func()
|
|
||||||
end
|
|
||||||
eventList[id] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
eventList[id] = { func = proxyFunc, active = true }
|
|
||||||
if delay and delay > 0 then
|
|
||||||
g_dispatcher.scheduleEvent(proxyFunc, delay)
|
|
||||||
else
|
|
||||||
g_dispatcher.addEvent(proxyFunc, false)
|
|
||||||
end
|
|
||||||
return id
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function addEvent(func)
|
function addEvent(callback, front)
|
||||||
return scheduleEvent(func, 0)
|
local event = g_dispatcher.addEvent(callback, front)
|
||||||
|
-- must hold a reference to the callback, otherwise it would be collected
|
||||||
|
event._callback = callback
|
||||||
|
return event
|
||||||
end
|
end
|
||||||
|
|
||||||
function removeEvent(id)
|
function removeEvent(event)
|
||||||
if id and eventList[id] then
|
if event then
|
||||||
eventList[id].active = false
|
event:cancel()
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
MessageBoxWindow < MainWindow
|
||||||
|
id: messageBoxWindow
|
||||||
|
anchors.centerIn: parent
|
||||||
|
height: 60
|
||||||
|
width: 80
|
||||||
|
padding-bottom: 10
|
||||||
|
padding-right: 10
|
||||||
|
|
||||||
|
MessageBoxLabel < Label
|
||||||
|
id: messageBoxLabel
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
anchors.top: parent.top
|
||||||
|
|
||||||
|
MessageBoxRightButton < Button
|
||||||
|
id: messageBoxRightButton
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.right: parent.right
|
||||||
|
width: 64
|
||||||
|
visible: true
|
@ -1,81 +0,0 @@
|
|||||||
MessageBox = {}
|
|
||||||
MessageBox.__index = MessageBox
|
|
||||||
|
|
||||||
-- messagebox flags
|
|
||||||
MessageBoxOk = 1
|
|
||||||
MessageBoxCancel = 2
|
|
||||||
|
|
||||||
function MessageBox.create(title, text, flags)
|
|
||||||
local box = {}
|
|
||||||
setmetatable(box, MessageBox)
|
|
||||||
|
|
||||||
-- create messagebox window
|
|
||||||
local window = displayUI('messagebox.otui')
|
|
||||||
window:lock()
|
|
||||||
window:setText(title)
|
|
||||||
|
|
||||||
local label = window:getChildById('messageBoxLabel')
|
|
||||||
label:setText(text)
|
|
||||||
label:resizeToText()
|
|
||||||
|
|
||||||
-- set window size based on label size
|
|
||||||
window:setWidth(math.max(label:getWidth() + 48, 120))
|
|
||||||
window:setHeight(label:getHeight() + 64)
|
|
||||||
|
|
||||||
-- setup messagebox first button
|
|
||||||
local buttonRight = window:getChildById('messageBoxRightButton')
|
|
||||||
|
|
||||||
if flags == MessageBoxOk then
|
|
||||||
buttonRight:setText("Ok")
|
|
||||||
box.onOk = function() end
|
|
||||||
buttonRight.onClick = function()
|
|
||||||
box.onOk()
|
|
||||||
box:destroy()
|
|
||||||
end
|
|
||||||
window.onEnter = buttonRight.onClick
|
|
||||||
window.onEscape = buttonRight.onClick
|
|
||||||
elseif flags == MessageBoxCancel then
|
|
||||||
buttonRight:setText("Cancel")
|
|
||||||
box.onCancel = function() end
|
|
||||||
buttonRight.onClick = function()
|
|
||||||
box.onCancel()
|
|
||||||
box:destroy()
|
|
||||||
end
|
|
||||||
window.onEnter = buttonRight.onClick
|
|
||||||
window.onEscape = buttonRight.onClick
|
|
||||||
end
|
|
||||||
|
|
||||||
box.window = window
|
|
||||||
return box
|
|
||||||
end
|
|
||||||
|
|
||||||
function MessageBox:destroy()
|
|
||||||
if self.onDestroy then
|
|
||||||
self.onDestroy()
|
|
||||||
self.onDestroy = nil
|
|
||||||
end
|
|
||||||
if self.window then
|
|
||||||
self.window:destroy()
|
|
||||||
self.window = nil
|
|
||||||
end
|
|
||||||
self.onOk = nil
|
|
||||||
self.onCancel = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
-- shortcuts for creating message boxes
|
|
||||||
function displayMessageBox(title, text, flags)
|
|
||||||
return MessageBox.create(title, text, flags)
|
|
||||||
end
|
|
||||||
|
|
||||||
function displayErrorBox(title, text)
|
|
||||||
return MessageBox.create(title, text, MessageBoxOk)
|
|
||||||
end
|
|
||||||
|
|
||||||
function displayInfoBox(title, text)
|
|
||||||
return MessageBox.create(title, text, MessageBoxOk)
|
|
||||||
end
|
|
||||||
|
|
||||||
function displayCancelBox(title, text)
|
|
||||||
return MessageBox.create(title, text, MessageBoxCancel)
|
|
||||||
end
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
|||||||
Window
|
|
||||||
id: messageBoxWindow
|
|
||||||
anchors.centerIn: parent
|
|
||||||
height: 80
|
|
||||||
width: 120
|
|
||||||
|
|
||||||
Label
|
|
||||||
id: messageBoxLabel
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
anchors.top: parent.top
|
|
||||||
margin-top: 27
|
|
||||||
margin-bottom : 27
|
|
||||||
|
|
||||||
Button
|
|
||||||
id: messageBoxRightButton
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
anchors.right: parent.right
|
|
||||||
margin-right: 10
|
|
||||||
margin-bottom: 10
|
|
||||||
width: 64
|
|
||||||
visible: true
|
|
@ -1,7 +0,0 @@
|
|||||||
Label
|
|
||||||
id: toolTipText
|
|
||||||
background-color: #111111bb
|
|
||||||
size: 200 200
|
|
||||||
id: toolTip
|
|
||||||
focusable: false
|
|
||||||
anchors.centerIn: parent
|
|
@ -1,23 +1,64 @@
|
|||||||
--[[
|
|
||||||
UIMessageBox = extends(UIWindow)
|
UIMessageBox = extends(UIWindow)
|
||||||
|
|
||||||
function UIMessageBox.create(title, message)
|
MessageBoxOk = 1
|
||||||
|
MessageBoxCancel = 2
|
||||||
|
|
||||||
|
-- messagebox cannot be created from otui files
|
||||||
|
UIMessageBox.create = nil
|
||||||
|
|
||||||
|
function UIMessageBox.display(title, message, flags)
|
||||||
local messagebox = UIMessageBox.internalCreate()
|
local messagebox = UIMessageBox.internalCreate()
|
||||||
|
rootWidget:addChild(messagebox)
|
||||||
|
|
||||||
|
messagebox:setStyle('MessageBoxWindow')
|
||||||
messagebox:setText(title)
|
messagebox:setText(title)
|
||||||
local messageLabel = self:getChildById('messageLabel')
|
|
||||||
label:setText(message)
|
|
||||||
label:resizeToText()
|
|
||||||
|
|
||||||
window:setWidth(math.max(label:getWidth() + self:getPaddingLeft() + self:getPaddingRight(), self:getWidth()))
|
local messageLabel = createWidget('MessageBoxLabel', messagebox)
|
||||||
window:setHeight(label:getHeight() + self:getPaddingTop() + self:getPaddingBottom())
|
messageLabel:setText(message)
|
||||||
|
messageLabel:resizeToText()
|
||||||
|
|
||||||
|
messagebox:setWidth(math.max(messageLabel:getWidth() + 48, messagebox:getWidth()))
|
||||||
|
messagebox:setHeight(math.max(messageLabel:getHeight() + 64, messagebox:getHeight()))
|
||||||
|
|
||||||
|
-- setup messagebox first button
|
||||||
|
local buttonRight = createWidget('MessageBoxRightButton', messagebox)
|
||||||
|
|
||||||
|
if flags == MessageBoxOk then
|
||||||
|
buttonRight:setText('Ok')
|
||||||
|
connect(buttonRight, { onClick = function(self) self:getParent():ok() end })
|
||||||
|
elseif flags == MessageBoxCancel then
|
||||||
|
buttonRight:setText('Cancel')
|
||||||
|
connect(buttonRight, { onClick = function(self) self:getParent():cancel() end })
|
||||||
|
end
|
||||||
|
|
||||||
|
connect(messagebox, { onEnter = function(self) self:destroy() end })
|
||||||
|
connect(messagebox, { onEscape = function(self) self:destroy() end })
|
||||||
|
|
||||||
|
messagebox:lock()
|
||||||
|
|
||||||
return messagebox
|
return messagebox
|
||||||
end
|
end
|
||||||
|
|
||||||
function UIMessageBox:setTitle(title)
|
function displayInfoBox(title, message)
|
||||||
|
return UIMessageBox.display(title, message, MessageBoxOk)
|
||||||
|
end
|
||||||
|
|
||||||
|
function displayErrorBox(title, message)
|
||||||
|
return UIMessageBox.display(title, message, MessageBoxOk)
|
||||||
|
end
|
||||||
|
|
||||||
|
function displayCancelBox(title, message)
|
||||||
|
return UIMessageBox.display(title, message, MessageBoxCancel)
|
||||||
|
end
|
||||||
|
|
||||||
|
function UIMessageBox:ok()
|
||||||
|
signalcall(self.onOk, self)
|
||||||
|
self.onOk = nil
|
||||||
|
self:destroy()
|
||||||
end
|
end
|
||||||
|
|
||||||
function UIMessageBox:setMessage(message)
|
function UIMessageBox:cancel()
|
||||||
|
signalcall(self.onCancel, self)
|
||||||
|
self.onCancel = nil
|
||||||
|
self:destroy()
|
||||||
end
|
end
|
||||||
]]--
|
|
Loading…
Reference in new issue