vecāks
add8505a5b
revīzija
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()
|
Pirms Platums: | Augstums: | Izmērs: 518 B Pēc Platums: | Augstums: | Izmērs: 518 B |
@ -1,11 +1,10 @@
|
||||
Module
|
||||
name: terminal
|
||||
name: client_terminal
|
||||
description: Terminal for executing lua functions
|
||||
author: OTClient team
|
||||
website: https://github.com/edubart/otclient
|
||||
|
||||
autoLoad: true
|
||||
autoLoadAntecedence: 200
|
||||
autoload: true
|
||||
autoload-antecedence: 160
|
||||
|
||||
onLoad: |
|
||||
dofile 'terminal'
|
Pirms Platums: | Augstums: | Izmērs: 459 B Pēc Platums: | Augstums: | Izmērs: 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)
|
||||
if not func then return end
|
||||
eventId = eventId + 1
|
||||
local id = eventId
|
||||
local function proxyFunc()
|
||||
if eventList[id] then
|
||||
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
|
||||
local event = g_dispatcher.scheduleEvent(callback, delay)
|
||||
|
||||
-- must hold a reference to the callback, otherwise it would be collected
|
||||
event._callback = callback
|
||||
return event
|
||||
end
|
||||
|
||||
function addEvent(func)
|
||||
return scheduleEvent(func, 0)
|
||||
function addEvent(callback, front)
|
||||
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
|
||||
|
||||
function removeEvent(id)
|
||||
if id and eventList[id] then
|
||||
eventList[id].active = false
|
||||
return true
|
||||
function removeEvent(event)
|
||||
if event then
|
||||
event:cancel()
|
||||
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)
|
||||
|
||||
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()
|
||||
rootWidget:addChild(messagebox)
|
||||
|
||||
messagebox:setStyle('MessageBoxWindow')
|
||||
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()))
|
||||
window:setHeight(label:getHeight() + self:getPaddingTop() + self:getPaddingBottom())
|
||||
local messageLabel = createWidget('MessageBoxLabel', messagebox)
|
||||
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
|
||||
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
|
||||
|
||||
function UIMessageBox:setMessage(message)
|
||||
function UIMessageBox:cancel()
|
||||
signalcall(self.onCancel, self)
|
||||
self.onCancel = nil
|
||||
self:destroy()
|
||||
end
|
||||
]]--
|
Notiek ielāde…
Atsaukties uz šo jaunā problēmā