script_author('cort_quwin')
script_version('1.0')
require "lib.moonloader" -- подключение библиотеки
local imgui = require 'imgui'
local fa = require 'faIcons'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local window = imgui.ImBool(false)
local type = imgui.ImInt(0)
local text = imgui.ImBuffer('Toast text', 256)
local time = imgui.ImInt(1000)
local tnotf = import('lib/toast_notf.lua')
local fa_font = nil
local fa_glyph_ranges = imgui.ImGlyphRanges({ fa.min_range, fa.max_range })
function imgui.BeforeDrawFrame()
if fa_font == nil then
local font_config = imgui.ImFontConfig() -- to use 'imgui.ImFontConfig.new()' on error
font_config.MergeMode = true
fa_font = imgui.GetIO().Fonts:AddFontFromFileTTF('moonloader/resource/fonts/fontawesome-webfont.ttf', 14.0, font_config, fa_glyph_ranges)
end
end
function imgui.VerticalSeparator()
local p = imgui.GetCursorScreenPos()
imgui.GetWindowDrawList():AddLine(imgui.ImVec2(p.x, p.y), imgui.ImVec2(p.x, p.y + imgui.GetContentRegionMax().y), imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.Separator]))
end
function imgui.TextColoredRGB(text, render_text)
local max_float = imgui.GetWindowWidth()
local style = imgui.GetStyle()
local colors = style.Colors
local ImVec4 = imgui.ImVec4
local explode_argb = function(argb)
local a = bit.band(bit.rshift(argb, 24), 0xFF)
local r = bit.band(bit.rshift(argb, 16), 0xFF)
local g = bit.band(bit.rshift(argb, 8), 0xFF)
local b = bit.band(argb, 0xFF)
return a, r, g, b
end
local getcolor = function(color)
if color:sub(1, 6):upper() == 'SSSSSS' then
local r, g, b = colors[1].x, colors[1].y, colors[1].z
local a = tonumber(color:sub(7, 8), 16) or colors[1].w * 255
return ImVec4(r, g, b, a / 255)
end
local color = type(color) == 'string' and tonumber(color, 16) or color
if type(color) ~= 'number' then return end
local r, g, b, a = explode_argb(color)
return imgui.ImColor(r, g, b, a):GetVec4()
end
local render_text = function(text_)
for w in text_:gmatch('[^\r\n]+') do
local text, colors_, m = {}, {}, 1
w = w:gsub('{(......)}', '{%1FF}')
while w:find('{........}') do
local n, k = w:find('{........}')
local color = getcolor(w:sub(n + 1, k - 1))
if color then
text[#text], text[#text + 1] = w:sub(m, n - 1), w:sub(k + 1, #w)
colors_[#colors_ + 1] = color
m = n
end
w = w:sub(1, n - 1) .. w:sub(k + 1, #w)
end
local length = imgui.CalcTextSize(w)
if render_text == 2 then
imgui.NewLine()
imgui.SameLine(max_float / 2 - ( length.x / 2 ))
elseif render_text == 3 then
imgui.NewLine()
imgui.SameLine(max_float - length.x - 5 )
end
if text[0] then
for i = 0, #text do
imgui.TextColored(colors_[i] or colors[1], text[i])
imgui.SameLine(nil, 0)
end
imgui.NewLine()
else imgui.Text(w) end
end
end
render_text(text)
end
local main_window_state = imgui.ImBool(false)
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampAddChatMessage(u8'{ffffff}[{2a5f99}TC Manager{ffffff}]{ffffff}: {2a5f99}}Успешно загрузился.', -1)
sampAddChatMessage(u8'{ffffff}[{2a5f99}TC Manager{ffffff}]{ffffff}: {2a5f99}Автор: {2e4fe1}cort_quwin.', -1)
tnotf.toast('Скрипт говно загружен!\nМеню настроек: /tc.menu', 3500, tnotf.type.INFO)
sampRegisterChatCommand('tc.menu', cmd_menu)
imgui.Process = false
while true do
wait(0)
end
end
function cmd_menu(arg)
main_window_state.v = not main_window_state.v
imgui.Process = main_window_state.v
end
function imgui.OnDrawFrame()
if not main_window_state.v then
imgui.Process = false
end
if main_window_state.v then
local sw, sh = getScreenResolution()
imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(350, 104), imgui.Cond.FirstUseEver)
imgui.Begin('##window', _, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoScrollbar)
imgui.BeginChild('##main', imgui.ImVec2(342, 95), true)
imgui.TextColoredRGB('{feb7ff}TC Manager', 2);
imgui.Separator()
imgui.BeginChild('##main', imgui.ImVec2(334, 65), true)
imgui.EndChild()
imgui.EndChild()
imgui.End()
end
end
function imgui.Selector(labels, size, selected, pos, speed)
local rBool = false
if not speed then speed = 10 end
if (pos.v < (selected.v * size.y)) then
pos.v = pos.v + speed
elseif (pos.v > (selected.v * size.y)) then
pos.v = pos.v - speed
end
imgui.SetCursorPos(imgui.ImVec2(0.00, pos.v))
local draw_list = imgui.GetWindowDrawList()
local p = imgui.GetCursorScreenPos()
local radius = size.y * 0.50
draw_list:AddRectFilled(imgui.ImVec2(p.x-size.x/2, p.y), imgui.ImVec2(p.x + radius + 1 * (size.x - radius * 2.0), p.y + radius*2), imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.ButtonActive]))
draw_list:AddRectFilled(imgui.ImVec2(p.x-size.x/2, p.y), imgui.ImVec2(p.x + 5, p.y + size.y), imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.Button]), 0)
draw_list:AddCircleFilled(imgui.ImVec2(p.x + radius + 1 * (size.x - radius * 2.0), p.y + radius), radius, imgui.GetColorU32(imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.ButtonActive])), radius/10*12)
for i = 1, #labels do
imgui.SetCursorPos(imgui.ImVec2(0, (i * size.y)))
local p = imgui.GetCursorScreenPos()
if imgui.InvisibleButton(labels[i], size) then selected.v = i rBool = true end
if imgui.IsItemHovered() then
draw_list:AddRectFilled(imgui.ImVec2(p.x-size.x/2, p.y), imgui.ImVec2(p.x + size.x, p.y + size.y), imgui.GetColorU32(imgui.ImVec4(0.58, 0.34, 0.46, 0.20)), radius/10*12)
end
imgui.SetCursorPos(imgui.ImVec2(20, (i * size.y + (size.y-imgui.CalcTextSize(labels[i]).y)/2)))
imgui.Text(labels[i])
end
return rBool
end