local imgui = require('imgui')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local window = imgui.ImBool(false)
local items = {
{text = imgui.ImBuffer('/lock', 256), bind = imgui.ImInt(49), state = imgui.ImBool(true)}
}
local add_popup = {bind = imgui.ImInt(49), text = imgui.ImBuffer('bind #'..tostring(#items + 1)..' TEXT', 256)}
function main()
while not isSampAvailable() do wait(200) end
imgui.Process = false
window.v = true --show window
while true do
wait(0)
imgui.Process = window.v
for i = 1, #items do
if wasKeyPressed(items[i].bind.v) then
sampSendChat(items[i].text.v)
end
end
end
end
function imgui.OnDrawFrame()
if window.v then
imgui.SetNextWindowPos(imgui.ImVec2(350.0, 250.0), imgui.Cond.FirstUseEver)
imgui.SetNextWindowSize(imgui.ImVec2(280.0, 70.0), imgui.Cond.FirstUseEver)
imgui.Begin('Window Title', window)
for i = 1, #items do
if items[i] then
imgui.Checkbox('checkbox for: '..items[i].text.v, items[i].state)
imgui.SameLine()
if imgui.Button('delete') then
table.remove(items, i)
end
end
end
if imgui.Button('Add new') then
imgui.OpenPopup('Add new item')
end
if imgui.BeginPopupModal('Add new item', true, imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoResize) then
imgui.SetWindowSize(imgui.ImVec2(300, 200))
imgui.InputInt('New bind KEY ID', add_popup.bind)
imgui.InputText('New bind TEXT', add_popup.text)
if imgui.Button('ADD!') then
table.insert(items, {text = imgui.ImBuffer(add_popup.text.v, 256), bind = imgui.ImInt(add_popup.bind.v), state = imgui.ImBool(true)})
imgui.CloseCurrentPopup()
end
if imgui.Button('CLOSE') then
imgui.CloseCurrentPopup()
end
imgui.EndPopup()
end
imgui.End()
end
end