mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-10-21 23:15:54 +02:00
Updated to OTCv8 3.1 rev 112
This commit is contained in:
@@ -200,11 +200,31 @@ context.onAddItem = function(callback)
|
||||
return context.callback("onAddItem", callback)
|
||||
end
|
||||
|
||||
-- onRemoveItem - callback = function(container, slot, item)
|
||||
context.onRemoveItem = function(callback)
|
||||
return context.callback("onRemoveItem", callback)
|
||||
end
|
||||
|
||||
-- onStatesChange - callback = function(states, oldStates)
|
||||
context.onStatesChange = function(callback)
|
||||
return context.callback("onStatesChange", callback)
|
||||
end
|
||||
|
||||
-- onGameEditText - callback = function(id, itemId, maxLength, text, writer, time)
|
||||
context.onGameEditText = function(callback)
|
||||
return context.callback("onGameEditText", callback)
|
||||
end
|
||||
|
||||
-- onSpellCooldown - callback = function(iconId, duration)
|
||||
context.onSpellCooldown = function(callback)
|
||||
return context.callback("onSpellCooldown", callback)
|
||||
end
|
||||
|
||||
-- onGroupSpellCooldown - callback = function(iconId, duration)
|
||||
context.onGroupSpellCooldown = function(callback)
|
||||
return context.callback("onGroupSpellCooldown", callback)
|
||||
end
|
||||
|
||||
-- CUSTOM CALLBACKS
|
||||
|
||||
-- listen(name, callback) -- callback = function(text, channelId, pos)
|
||||
|
@@ -13,6 +13,16 @@ UI.createWidget = function(name, parent)
|
||||
return widget
|
||||
end
|
||||
|
||||
UI.createMiniWindow = function(name, parent)
|
||||
if parent == nil then
|
||||
parent = modules.game_interface.getRightPanel()
|
||||
end
|
||||
local widget = g_ui.createWidget(name, parent)
|
||||
widget:setup()
|
||||
widget.botWidget = true
|
||||
return widget
|
||||
end
|
||||
|
||||
UI.createWindow = function(name)
|
||||
local widget = g_ui.createWidget(name, g_ui.getRootWidget())
|
||||
widget.botWidget = true
|
||||
@@ -20,5 +30,4 @@ UI.createWindow = function(name)
|
||||
widget:raise()
|
||||
widget:focus()
|
||||
return widget
|
||||
end
|
||||
|
||||
end
|
@@ -271,3 +271,131 @@ UI.TwoItemsAndSlotPanel = function(params, callback, parent)
|
||||
|
||||
return widget
|
||||
end
|
||||
|
||||
UI.DualLabel = function(left, right, params, parent)
|
||||
--[[ params:
|
||||
height - int,
|
||||
maxWidth - number
|
||||
]]
|
||||
|
||||
left = left or ""
|
||||
right = right or ""
|
||||
params = params or {}
|
||||
if not type(params) == "table" then
|
||||
parent = params
|
||||
params = {}
|
||||
end
|
||||
params.height = params.height or 20
|
||||
params.maxWidth = params.maxWidth or 88
|
||||
|
||||
local widget = UI.createWidget('DualLabelPanel', parent)
|
||||
|
||||
widget.left:setText(left)
|
||||
widget.right:setText(right)
|
||||
widget:setHeight(params.height)
|
||||
if widget.left:getWidth() > params.maxWidth then
|
||||
widget.left:setWidth(params.maxWidth)
|
||||
end
|
||||
return widget
|
||||
end
|
||||
|
||||
UI.LabelAndTextEdit = function(params, callback, parent)
|
||||
--[[ params:
|
||||
left - str,
|
||||
right - str,
|
||||
height - int,
|
||||
maxWidth - int,
|
||||
]]
|
||||
|
||||
params = params or {}
|
||||
params.left = params.left or ""
|
||||
params.right = params.right or ""
|
||||
params.height = params.height or 20
|
||||
params.maxWidth = params.maxWidth or 88
|
||||
|
||||
local widget = UI.createWidget('LabelAndTextEditPanel', parent)
|
||||
|
||||
widget.left:setText(params.left)
|
||||
widget.right:setText(params.right)
|
||||
widget:setHeight(params.height)
|
||||
if widget.left:getWidth() > params.maxWidth then
|
||||
widget.left:setWidth(params.maxWidth)
|
||||
end
|
||||
|
||||
widget.right.onTextChange = function(widget, text)
|
||||
params.right = text
|
||||
if callback then
|
||||
callback(widget, params)
|
||||
end
|
||||
end
|
||||
|
||||
--[[example:
|
||||
|
||||
storage.testParams = storage.testParams or {left = "hotkey", right = "F5"}
|
||||
UI.LabelAndTextEdit(storage.testParams, function(widget, newParams)
|
||||
storage.testParams = newParams
|
||||
end)
|
||||
|
||||
]]
|
||||
return widget
|
||||
end
|
||||
|
||||
|
||||
UI.SwitchAndButton = function(params, callbackSwitch, callbackButton, callback, parent)
|
||||
--[[ params:
|
||||
on - bool,
|
||||
left - str,
|
||||
right - str,
|
||||
height - int,
|
||||
maxWidth - int,
|
||||
]]
|
||||
|
||||
params = params or {}
|
||||
params.on = params.on or false
|
||||
params.left = params.left or ""
|
||||
params.right = params.right or ""
|
||||
params.height = params.height or 20
|
||||
params.maxWidth = params.maxWidth or 88
|
||||
|
||||
local widget = UI.createWidget('SwitchAndButtonPanel', parent)
|
||||
|
||||
widget.left:setOn(params.on)
|
||||
widget.left:setText(params.left)
|
||||
widget.right:setText(params.right)
|
||||
widget:setHeight(params.height)
|
||||
if widget.right:getWidth() > params.maxWidth then
|
||||
widget.right:setWidth(params.maxWidth)
|
||||
end
|
||||
|
||||
widget.left.onClick = function()
|
||||
params.on = not params.on
|
||||
widget.left:setOn(params.on)
|
||||
if callback then
|
||||
callback(widget, params)
|
||||
end
|
||||
if callbackSwitch then
|
||||
callbackSwitch()
|
||||
else
|
||||
warn("callback not set!")
|
||||
end
|
||||
end
|
||||
|
||||
widget.right.onClick = function()
|
||||
if callbackButton then
|
||||
callbackButton()
|
||||
else
|
||||
warn("callback not set!")
|
||||
end
|
||||
end
|
||||
|
||||
--[[ params:
|
||||
if type(storage.test1) ~= "table" then
|
||||
storage.test1 = storage.test1 or {on = false, left = "new script", right = "config"}
|
||||
end
|
||||
|
||||
UI.SwitchAndButton(storage.test1, test, test, function(widget, newParams)
|
||||
storage.test1 = newParams
|
||||
end)
|
||||
]]
|
||||
return widget
|
||||
end
|
Reference in New Issue
Block a user