local imgui = require 'mimgui'
local faicons = require('fAwesome6')
local encoding = require 'encoding'
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local WinState = imgui.new.bool()
local buttons = {}
local tab = 0
imgui.OnFrame(function() return WinState[0] end, function()
imgui.SetNextWindowPos(imgui.ImVec2(500,500), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(300,300), imgui.Cond.FirstUseEver)
imgui.Begin('##Window', WinState, imgui.WindowFlags.NoResize)
imgui.Separator()
for index,bName in pairs(buttons) do
if imgui.ColoredButton(string.format('%s %s', faicons('folder'), u8(bName[1])),'000000',1) then
tab = index
end
imgui.SameLine()
end
if imgui.ColoredButton(faicons('plus'),'000000',1) then
table.insert(buttons,{'Новая вкладка##'..#buttons+1})
end
if imgui.BeginChild('Name', imgui.ImVec2(200, 100), true) then
imgui.Text(u8'Сейчас открыта вкладка №'..tonumber(tab))
imgui.EndChild()
end
imgui.End()
end)
function main()
sampRegisterChatCommand('cmdd', function()
WinState[0] = not WinState[0]
end)
wait(-1)
end
imgui.OnInitialize(function()
imgui.GetIO().IniFilename = nil
local config = imgui.ImFontConfig()
config.MergeMode = true
config.PixelSnapH = true
iconRanges = imgui.new.ImWchar[3](faicons.min_range, faicons.max_range, 0)
imgui.GetIO().Fonts:AddFontFromMemoryCompressedBase85TTF(faicons.get_font_data_base85('solid'), 14, config, iconRanges) -- solid - тип иконок, так же есть thin, regular, light и duotone
end)
function imgui.ColoredButton(text,hex,trans,size)
local r,g,b = tonumber("0x"..hex:sub(1,2)), tonumber("0x"..hex:sub(3,4)), tonumber("0x"..hex:sub(5,6))
if tonumber(trans) ~= nil and tonumber(trans) < 101 and tonumber(trans) > 0 then a = trans else a = 60 end
imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(r/255, g/255, b/255, a/100))
imgui.PushStyleColor(imgui.Col.ButtonHovered, imgui.ImVec4(r/255, g/255, b/255, a/100))
imgui.PushStyleColor(imgui.Col.ButtonActive, imgui.ImVec4(r/255, g/255, b/255, a/100))
local button = imgui.Button(text, size)
imgui.PopStyleColor(3)
return button
end