Some fixes for class names and queue (added base class).
This commit is contained in:
parent
00253e46b3
commit
c083d02bef
|
@ -0,0 +1,44 @@
|
|||
--[[
|
||||
@Authors: Ben Dol (BeniS)
|
||||
@Details: CallbackEvent class shell for callback events
|
||||
]]
|
||||
|
||||
CallbackEvent = newclass("CallbackEvent")
|
||||
|
||||
CallbackEvent.create = function(id, callback)
|
||||
local event = CallbackEvent.internalCreate()
|
||||
|
||||
event.id = id
|
||||
event.callback = callback
|
||||
|
||||
return event
|
||||
end
|
||||
|
||||
-- gets/sets
|
||||
|
||||
--@RequiredBy:Queue
|
||||
function CallbackEvent:getId()
|
||||
return self.id
|
||||
end
|
||||
|
||||
--@RequiredBy:Queue
|
||||
function CallbackEvent:setId(id)
|
||||
self.id = id
|
||||
end
|
||||
|
||||
--@RequiredBy:Queue
|
||||
function CallbackEvent:getCallback()
|
||||
return self.callback
|
||||
end
|
||||
|
||||
--@RequiredBy:Queue
|
||||
function CallbackEvent:setCallback(callback)
|
||||
self.callback = callback
|
||||
end
|
||||
|
||||
-- logic
|
||||
|
||||
--@RequiredBy:Queue
|
||||
function CallbackEvent:start()
|
||||
-- Do nothing by default
|
||||
end
|
|
@ -3,21 +3,15 @@
|
|||
@Details: Queue class for event queuing.
|
||||
]]
|
||||
|
||||
Queue = {}
|
||||
Queue.__index = Queue
|
||||
Queue = newclass("Queue")
|
||||
|
||||
Queue.__class = "Queue"
|
||||
Queue.create = function(callback)
|
||||
local obj = Queue.internalCreate()
|
||||
|
||||
Queue.new = function(callback)
|
||||
que = {
|
||||
queue = {},
|
||||
callback = nil
|
||||
}
|
||||
obj.queue = {}
|
||||
obj.callback = callback
|
||||
|
||||
que.callback = callback
|
||||
|
||||
setmetatable(que, Queue)
|
||||
return que
|
||||
return obj
|
||||
end
|
||||
|
||||
-- gets/sets
|
||||
|
|
|
@ -6,8 +6,6 @@ Module
|
|||
reloadable: false
|
||||
|
||||
@onLoad: |
|
||||
dofiles 'classes'
|
||||
|
||||
dofile 'math'
|
||||
dofile 'string'
|
||||
dofile 'table'
|
||||
|
@ -22,6 +20,7 @@ Module
|
|||
dofile 'mouse'
|
||||
dofile 'net'
|
||||
|
||||
dofiles 'classes'
|
||||
dofiles 'ui'
|
||||
|
||||
dofile 'inputmessage'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- @docclass
|
||||
UIButton = extends(UIWidget)
|
||||
UIButton = extends(UIWidget, "UIButton")
|
||||
|
||||
function UIButton.create()
|
||||
local button = UIButton.internalCreate()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- @docclass
|
||||
UICheckBox = extends(UIWidget)
|
||||
UICheckBox = extends(UIWidget, "UICheckBox")
|
||||
|
||||
function UICheckBox.create()
|
||||
local checkbox = UICheckBox.internalCreate()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- @docclass
|
||||
UIComboBox = extends(UIWidget)
|
||||
UIComboBox = extends(UIWidget, "UIComboBox")
|
||||
|
||||
function UIComboBox.create()
|
||||
local combobox = UIComboBox.internalCreate()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- @docclass
|
||||
UIImageView = extends(UIWidget)
|
||||
UIImageView = extends(UIWidget, "UIImageView")
|
||||
|
||||
function UIImageView.create()
|
||||
local imageView = UIImageView.internalCreate()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
if not UIWindow then dofile 'uiwindow' end
|
||||
|
||||
-- @docclass
|
||||
UIInputBox = extends(UIWindow)
|
||||
UIInputBox = extends(UIWindow, "UIInputBox")
|
||||
|
||||
function UIInputBox.create(title, okCallback, cancelCallback)
|
||||
local inputBox = UIInputBox.internalCreate()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- @docclass
|
||||
UILabel = extends(UIWidget)
|
||||
UILabel = extends(UIWidget, "UILabel")
|
||||
|
||||
function UILabel.create()
|
||||
local label = UILabel.internalCreate()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
if not UIWindow then dofile 'uiwindow' end
|
||||
|
||||
-- @docclass
|
||||
UIMessageBox = extends(UIWindow)
|
||||
UIMessageBox = extends(UIWindow, "UIMessageBox")
|
||||
|
||||
-- messagebox cannot be created from otui files
|
||||
UIMessageBox.create = nil
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
-- @docclass
|
||||
UIMiniWindow = extends(UIWindow)
|
||||
UIMiniWindow = extends(UIWindow, "UIMiniWindow")
|
||||
|
||||
function UIMiniWindow.create()
|
||||
local miniwindow = UIMiniWindow.internalCreate()
|
||||
return miniwindow
|
||||
end
|
||||
|
||||
function UIMiniWindow:getClassName()
|
||||
return 'UIMiniWindow'
|
||||
end
|
||||
|
||||
function UIMiniWindow:open(dontSave)
|
||||
self:setVisible(true)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- @docclass
|
||||
UIMiniWindowContainer = extends(UIWidget)
|
||||
UIMiniWindowContainer = extends(UIWidget, "UIMiniWindowContainer")
|
||||
|
||||
function UIMiniWindowContainer.create()
|
||||
local container = UIMiniWindowContainer.internalCreate()
|
||||
|
@ -9,10 +9,6 @@ function UIMiniWindowContainer.create()
|
|||
return container
|
||||
end
|
||||
|
||||
function UIMiniWindowContainer:getClassName()
|
||||
return 'UIMiniWindowContainer'
|
||||
end
|
||||
|
||||
-- TODO: connect to window onResize event
|
||||
-- TODO: try to resize another widget?
|
||||
-- TODO: try to find another panel?
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- @docclass
|
||||
UIMoveableTabBar = extends(UIWidget)
|
||||
UIMoveableTabBar = extends(UIWidget, "UIMoveableTabBar")
|
||||
|
||||
-- private functions
|
||||
local function onTabClick(tab)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- @docclass
|
||||
UIPopupMenu = extends(UIWidget)
|
||||
UIPopupMenu = extends(UIWidget, "UIPopupMenu")
|
||||
|
||||
local currentMenu
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- @docclass
|
||||
UIProgressBar = extends(UIWidget)
|
||||
UIProgressBar = extends(UIWidget, "UIProgressBar")
|
||||
|
||||
function UIProgressBar.create()
|
||||
local progressbar = UIProgressBar.internalCreate()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- @docclass
|
||||
UIRadioGroup = newclass()
|
||||
UIRadioGroup = newclass("UIRadioGroup")
|
||||
|
||||
function UIRadioGroup.create()
|
||||
local radiogroup = UIRadioGroup.internalCreate()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- @docclass
|
||||
UIResizeBorder = extends(UIWidget)
|
||||
UIResizeBorder = extends(UIWidget, "UIResizeBorder")
|
||||
|
||||
function UIResizeBorder.create()
|
||||
local resizeborder = UIResizeBorder.internalCreate()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- @docclass
|
||||
UIScrollArea = extends(UIWidget)
|
||||
UIScrollArea = extends(UIWidget, "UIScrollArea")
|
||||
|
||||
-- public functions
|
||||
function UIScrollArea.create()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- @docclass
|
||||
UIScrollBar = extends(UIWidget)
|
||||
UIScrollBar = extends(UIWidget, "UIScrollBar")
|
||||
|
||||
-- private functions
|
||||
local function calcValues(self)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- @docclass
|
||||
UISpinBox = extends(UITextEdit)
|
||||
UISpinBox = extends(UITextEdit, "UISpinBox")
|
||||
|
||||
function UISpinBox.create()
|
||||
local spinbox = UISpinBox.internalCreate()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- @docclass
|
||||
UISplitter = extends(UIWidget)
|
||||
UISplitter = extends(UIWidget, "UISplitter")
|
||||
|
||||
function UISplitter.create()
|
||||
local splitter = UISplitter.internalCreate()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- @docclass
|
||||
UITabBar = extends(UIWidget)
|
||||
UITabBar = extends(UIWidget, "UITabBar")
|
||||
|
||||
-- private functions
|
||||
local function onTabClick(tab)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Get dynamic row heights working with text wrapping.
|
||||
* Every second row different background color applied.
|
||||
]]
|
||||
UITable = extends(UIWidget)
|
||||
UITable = extends(UIWidget, "UITable")
|
||||
|
||||
local HEADER_ID = 'row0'
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- @docclass
|
||||
UIWindow = extends(UIWidget)
|
||||
UIWindow = extends(UIWidget, "UIWindow")
|
||||
|
||||
function UIWindow.create()
|
||||
local window = UIWindow.internalCreate()
|
||||
|
@ -9,10 +9,6 @@ function UIWindow.create()
|
|||
return window
|
||||
end
|
||||
|
||||
function UIWindow:getClassName()
|
||||
return 'UIWindow'
|
||||
end
|
||||
|
||||
function UIWindow:onKeyDown(keyCode, keyboardModifiers)
|
||||
if keyboardModifiers == KeyboardNoModifier then
|
||||
if keyCode == KeyEnter then
|
||||
|
|
|
@ -117,7 +117,11 @@ function disconnect(object, arg1, arg2)
|
|||
end
|
||||
end
|
||||
|
||||
function newclass()
|
||||
function newclass(name)
|
||||
if not name then
|
||||
perror(debug.traceback('new class has no name.'))
|
||||
end
|
||||
|
||||
local class = {}
|
||||
function class.internalCreate()
|
||||
local instance = {}
|
||||
|
@ -127,10 +131,16 @@ function newclass()
|
|||
return instance
|
||||
end
|
||||
class.create = class.internalCreate
|
||||
class.__class = name
|
||||
class.getClassName = function() return name end
|
||||
return class
|
||||
end
|
||||
|
||||
function extends(base)
|
||||
function extends(base, name)
|
||||
if not name then
|
||||
perror(debug.traceback('extended class has no name.'))
|
||||
end
|
||||
|
||||
local derived = {}
|
||||
function derived.internalCreate()
|
||||
local instance = base.create()
|
||||
|
@ -140,6 +150,9 @@ function extends(base)
|
|||
return instance
|
||||
end
|
||||
derived.create = derived.internalCreate
|
||||
derived.__class = name
|
||||
derived.getClassName = function() return name end
|
||||
derived.super = base
|
||||
return derived
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
UIGameMap = extends(UIMap)
|
||||
UIGameMap = extends(UIMap, "UIGameMap")
|
||||
|
||||
function UIGameMap.create()
|
||||
local gameMap = UIGameMap.internalCreate()
|
||||
|
|
|
@ -52,9 +52,10 @@ function g_game.getSupportedClients()
|
|||
792, 800, 810, 811, 840, 842, 850,
|
||||
853, 854, 860, 861, 862, 870, 910,
|
||||
940, 944, 953, 954, 960, 961, 963,
|
||||
970, 980, 981, 982, 983, 984, 985,
|
||||
986, 1001, 1002, 1010, 1020, 1021,
|
||||
1022, 1031, 1034, 1035, 1036, 1037
|
||||
970, 972, 973, 980, 981, 982, 983,
|
||||
984, 985, 986, 1001, 1002, 1010,
|
||||
1020, 1021, 1022, 1031, 1034, 1035,
|
||||
1036, 1037
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- @docclass
|
||||
ProtocolLogin = extends(Protocol)
|
||||
ProtocolLogin = extends(Protocol, "ProtocolLogin")
|
||||
|
||||
LoginServerError = 10
|
||||
LoginServerUpdate = 17
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- @docclass
|
||||
UICreatureButton = extends(UIWidget)
|
||||
UICreatureButton = extends(UIWidget, "UICreatureButton")
|
||||
|
||||
local CreatureButtonColors = {
|
||||
onIdle = {notHovered = '#888888', hovered = '#FFFFFF' },
|
||||
|
@ -25,10 +25,6 @@ function UICreatureButton.create()
|
|||
return button
|
||||
end
|
||||
|
||||
function UICreatureButton:getClassName()
|
||||
return 'UICreatureButton'
|
||||
end
|
||||
|
||||
function UICreatureButton:setCreature(creature)
|
||||
self.creature = creature
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue