mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-04-30 11:19:21 +02:00
111 lines
2.9 KiB
Lua
111 lines
2.9 KiB
Lua
local context = G.botContext
|
|
|
|
context.setupUI = function(otml, parent)
|
|
if parent == nil then
|
|
parent = context.panel
|
|
end
|
|
local widget = g_ui.loadUIFromString(otml, parent)
|
|
widget.botWidget = true
|
|
return widget
|
|
end
|
|
|
|
context.addTab = function(name)
|
|
local tab = context.tabs:getTab(name)
|
|
if tab then -- return existing tab
|
|
return tab.tabPanel.content
|
|
end
|
|
|
|
context.tabs:setOn(true)
|
|
local newTab = context.tabs:addTab(name, g_ui.createWidget('BotPanel')).tabPanel.content
|
|
print(#(context.tabs.tabs))
|
|
if #(context.tabs.tabs) > 5 then
|
|
for k,tab in pairs(context.tabs.tabs) do
|
|
tab:setPadding(3)
|
|
tab:setFont('cipsoftFont')
|
|
end
|
|
end
|
|
|
|
return newTab
|
|
end
|
|
context.getTab = context.addTab
|
|
|
|
context.addSwitch = function(id, text, onClickCallback, parent)
|
|
if not parent then
|
|
parent = context.panel
|
|
end
|
|
local switch = g_ui.createWidget('BotSwitch', parent)
|
|
switch:setId(id)
|
|
switch:setText(text)
|
|
switch.onClick = onClickCallback
|
|
return switch
|
|
end
|
|
|
|
context.addButton = function(id, text, onClickCallback, parent)
|
|
if not parent then
|
|
parent = context.panel
|
|
end
|
|
local button = g_ui.createWidget('BotButton', parent)
|
|
button:setId(id)
|
|
button:setText(text)
|
|
button.onClick = onClickCallback
|
|
return button
|
|
end
|
|
|
|
context.addLabel = function(id, text, parent)
|
|
if not parent then
|
|
parent = context.panel
|
|
end
|
|
local label = g_ui.createWidget('BotLabel', parent)
|
|
label:setId(id)
|
|
label:setText(text)
|
|
return label
|
|
end
|
|
|
|
context.addTextEdit = function(id, text, onTextChangeCallback, parent)
|
|
if not parent then
|
|
parent = context.panel
|
|
end
|
|
local widget = g_ui.createWidget('BotTextEdit', parent)
|
|
widget:setId(id)
|
|
widget.onTextChange = onTextChangeCallback
|
|
widget:setText(text)
|
|
return widget
|
|
end
|
|
|
|
context.addSeparator = function(id, parent)
|
|
if not parent then
|
|
parent = context.panel
|
|
end
|
|
local separator = g_ui.createWidget('BotSeparator', parent)
|
|
separator:setId(id)
|
|
return separator
|
|
end
|
|
|
|
context._addMacroSwitch = function(name, keys, parent)
|
|
if not parent then
|
|
parent = context.panel
|
|
end
|
|
local text = name
|
|
if keys:len() > 0 then
|
|
text = name .. " [" .. keys .. "]"
|
|
end
|
|
local switch = context.addSwitch("macro_" .. #context._macros, text, function(widget)
|
|
context.storage._macros[name] = not context.storage._macros[name]
|
|
widget:setOn(context.storage._macros[name])
|
|
end, parent)
|
|
switch:setOn(context.storage._macros[name])
|
|
return switch
|
|
end
|
|
|
|
context._addHotkeySwitch = function(name, keys, parent)
|
|
if not parent then
|
|
parent = context.panel
|
|
end
|
|
local text = name
|
|
if keys:len() > 0 then
|
|
text = name .. " [" .. keys .. "]"
|
|
end
|
|
local switch = context.addSwitch("hotkey_" .. #context._hotkeys, text, nil, parent)
|
|
switch:setOn(false)
|
|
return switch
|
|
end |