- 138
- 17
- Версия MoonLoader
- .027.0-preview
Смотрел видео по смене темы через радио кнопку, но где-то ошибка. Можете помочь сделать, чтобы тема менялась при выборе через список
Lua:
local imgui = require('imgui')
local encoding = require 'encoding'
local vkeys = require 'vkeys'
local text = ('КЛИКНИ')
local color_tag = ('0xff00ff')
local themes = import "resource/imgui_themes.lua"
encoding.default = 'CP1251'
u8 = encoding.UTF8
local fa = require 'fAwesome5' -- ICONS LIST: https://fontawesome.com/v5.15/icons?d=gallery&s=solid&m=free
local tag = ('[Admin Tools]: ')
local fa_font = nil
local checked_radio = imgui.InInt(1)
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()
font_config.MergeMode = true
fa_font = imgui.GetIO().Fonts:AddFontFromFileTTF('moonloader/resource/fonts/fa-solid-900.ttf', 13.0, font_config, fa_glyph_ranges)
end
end
local window = imgui.ImBool(false)
function main()
while not isSampAvailable() do wait(200) end
imgui.Process = false
imgui.SwitchContext()
themes.SwitchColorTheme()
while true do
wait(0)
imgui.Process = (window.v)
if isKeyJustPressed(vkeys.VK_F2) then
window.v = not window.v
end
end
end
local tabs = {
fa.ICON_FA_COGS..(u8' Настройки'),
fa.ICON_FA_KEYBOARD..(u8' Бинды'),
fa.ICON_FA_LIST..(u8' Параметры'),
fa.ICON_FA_CROSSHAIRS..(u8' Читы'),
fa.ICON_FA_TERMINAL..(u8' Консоль'),
fa.ICON_FA_CAR..(u8' Ид машин'),
fa.ICON_FA_INFO..u8" Информация",
}
local select_menu = imgui.ImInt(1)
function imgui.CustomMenu(labels, selected, size, speed, centering)
local bool = false
speed = speed and speed or 0.2
local radius = size.y * 0.50
local draw_list = imgui.GetWindowDrawList()
if LastActiveTime == nil then LastActiveTime = {} end
if LastActive == nil then LastActive = {} end
local function ImSaturate(f)
return f < 0.0 and 0.0 or (f > 1.0 and 1.0 or f)
end
for i, v in ipairs(labels) do
local c = imgui.GetCursorPos()
local p = imgui.GetCursorScreenPos()
if imgui.InvisibleButton(v..'##'..i, size) then
selected.v = i
LastActiveTime[v] = os.clock()
LastActive[v] = true
bool = true
end
imgui.SetCursorPos(c)
local t = selected.v == i and 1.0 or 0.0
if LastActive[v] then
local time = os.clock() - LastActiveTime[v]
if time <= 0.3 then
local t_anim = ImSaturate(time / speed)
t = selected.v == i and t_anim or 1.0 - t_anim
else
LastActive[v] = false
end
end
local col_bg = imgui.GetColorU32(selected.v == i and imgui.GetStyle().Colors[imgui.Col.ButtonActive] or imgui.ImVec4(0,0,0,0))
local col_box = imgui.GetColorU32(selected.v == i and imgui.GetStyle().Colors[imgui.Col.Button] or imgui.ImVec4(0,0,0,0))
local col_hovered = imgui.GetStyle().Colors[imgui.Col.ButtonHovered]
local col_hovered = imgui.GetColorU32(imgui.ImVec4(col_hovered.x, col_hovered.y, col_hovered.z, (imgui.IsItemHovered() and 0.2 or 0)))
draw_list:AddRectFilled(imgui.ImVec2(p.x-size.x/6, p.y), imgui.ImVec2(p.x + (radius * 0.65) + t * size.x, p.y + size.y), col_bg, 10.0)
draw_list:AddRectFilled(imgui.ImVec2(p.x-size.x/6, p.y), imgui.ImVec2(p.x + (radius * 0.65) + size.x, p.y + size.y), col_hovered, 10.0)
draw_list:AddRectFilled(imgui.ImVec2(p.x, p.y), imgui.ImVec2(p.x+5, p.y + size.y), col_box)
imgui.SetCursorPos(imgui.ImVec2(c.x+(centering and (size.x-imgui.CalcTextSize(v).x)/2 or 15), c.y+(size.y-imgui.CalcTextSize(v).y)/2))
imgui.Text(v)
imgui.SetCursorPos(imgui.ImVec2(c.x, c.y+size.y))
end
return bool
end
function imgui.OnDrawFrame()
if window.v then
local resX, resY = getScreenResolution()
local sizeX, sizeY = 800, 330 -- WINDOW SIZE
imgui.SetNextWindowPos(imgui.ImVec2(resX / 2 - sizeX / 2, resY / 2 - sizeY / 2), imgui.Cond.FirstUseEver)
imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
imgui.Begin('Window Title', window)
imgui.CustomMenu(tabs, select_menu, imgui.ImVec2(123, 362 / 9.3), 0.3, true)
if select_menu == 1 then
imgui.Text('constchar*fmt,...')
elseif select_menu == 2 then
imgui.Button('constchar*fmt,...')
end
if imgui.Button(u8'Тест', imgui.ImVec2(123, 362 / 9.3)) then
themes.SwitchColorTheme(5)
end
imgui.BeginChild("ChildWindow2", imgui.ImVec2(200,175), true)
for i, value in ipairs(themes.ColorTheme) do
if imgui.radioButton(value, checked_radio, i) then
themes.SwitchColorTheme(i)
end
end
imgui.EndChild()
imgui.End()
end
end