- Версия MoonLoader
- Другое
Как на mimgui сделать примерно такое окно? чтоб все функции(button, text, SliderIntи т.д) находились во второй части экрана.
Help please.
Версия на imgui:
Help please.
Версия на imgui:
imgui:
require 'moonloader'
local imgui = require('imgui')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local AI_PAGE = {}
local ToU32 = imgui.ColorConvertFloat4ToU32
local page = 1
local window = imgui.ImBool(false)
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampRegisterChatCommand('123123', function()
window.v = not window.v
imgui.Process = window.v
end)
while true do
wait(0)
end
end
function imgui.OnDrawFrame()
if not window.v then
imgui.Process = false
end
if window.v then
local resX, resY = getScreenResolution()
local sizeX, sizeY = 600, 600 -- 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.BeginChild('tabs', imgui.ImVec2(200, -1), true)
if imgui.PageButton(page == 1, '#', 'Page one') then
page = 1
end
if imgui.PageButton(page == 2, '#', 'Page two') then
page = 2
end
imgui.EndChild()
imgui.SameLine()
imgui.BeginChild('workspace', imgui.ImVec2(-1, -1), true)
if page == 1 then
imgui.Text('One Page')
elseif page == 2 then
imgui.Text('Two Page')
end
imgui.EndChild()
imgui.End()
end
end
imgui.PageButton = function(bool, icon, name, but_wide)
but_wide = but_wide or 190
local duration = 0.25
local DL = imgui.GetWindowDrawList()
local p1 = imgui.GetCursorScreenPos()
local p2 = imgui.GetCursorPos()
local col = imgui.GetStyle().Colors[imgui.Col.ButtonActive]
if not AI_PAGE[name] then
AI_PAGE[name] = { clock = nil }
end
local pool = AI_PAGE[name]
imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(0.00, 0.00, 0.00, 0.00))
imgui.PushStyleColor(imgui.Col.ButtonHovered, imgui.ImVec4(0.00, 0.00, 0.00, 0.00))
imgui.PushStyleColor(imgui.Col.ButtonActive, imgui.ImVec4(0.00, 0.00, 0.00, 0.00))
local result = imgui.InvisibleButton(name, imgui.ImVec2(but_wide, 35))
if result and not bool then
pool.clock = os.clock()
end
local pressed = imgui.IsItemActive()
imgui.PopStyleColor(3)
if bool then
if pool.clock and (os.clock() - pool.clock) < duration then
local wide = (os.clock() - pool.clock) * (but_wide / duration)
DL:AddRectFilled(imgui.ImVec2(p1.x, p1.y), imgui.ImVec2((p1.x + 190) - wide, p1.y + 35), 0x10FFFFFF, 15, 10)
DL:AddRectFilled(imgui.ImVec2(p1.x, p1.y), imgui.ImVec2(p1.x + 5, p1.y + 35), ToU32(col))
DL:AddRectFilled(imgui.ImVec2(p1.x, p1.y), imgui.ImVec2(p1.x + wide, p1.y + 35), ToU32(imgui.ImVec4(col.x, col.y, col.z, 0.6)), 15, 10)
else
DL:AddRectFilled(imgui.ImVec2(p1.x, (pressed and p1.y + 3 or p1.y)), imgui.ImVec2(p1.x + 5, (pressed and p1.y + 32 or p1.y + 35)), ToU32(col))
DL:AddRectFilled(imgui.ImVec2(p1.x, p1.y), imgui.ImVec2(p1.x + 190, p1.y + 35), ToU32(imgui.ImVec4(col.x, col.y, col.z, 0.6)), 15, 10)
end
else
if imgui.IsItemHovered() then
DL:AddRectFilled(imgui.ImVec2(p1.x, p1.y), imgui.ImVec2(p1.x + 190, p1.y + 35), 0x10FFFFFF, 15, 10)
end
end
imgui.SameLine(10); imgui.SetCursorPosY(p2.y + 8)
if bool then
imgui.Text((' '):rep(3) .. icon)
imgui.SameLine(60)
imgui.Text(name)
else
imgui.TextColored(imgui.ImVec4(0.60, 0.60, 0.60, 1.00), (' '):rep(3) .. icon)
imgui.SameLine(60)
imgui.TextColored(imgui.ImVec4(0.60, 0.60, 0.60, 1.00), name)
end
imgui.SetCursorPosY(p2.y + 40)
return result
end
function dark_theme()
imgui.SwitchContext()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
local ImVec2 = imgui.ImVec2
style.WindowPadding = imgui.ImVec2(8, 8)
style.WindowRounding = 6
style.ChildWindowRounding = 5
style.FramePadding = imgui.ImVec2(5, 3)
style.FrameRounding = 3.0
style.ItemSpacing = imgui.ImVec2(5, 4)
style.ItemInnerSpacing = imgui.ImVec2(4, 4)
style.IndentSpacing = 21
style.ScrollbarSize = 10.0
style.ScrollbarRounding = 13
style.GrabMinSize = 8
style.GrabRounding = 1
style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)
colors[clr.FrameBg] = ImVec4(0.46, 0.11, 0.29, 1.00)
colors[clr.FrameBgHovered] = ImVec4(0.69, 0.16, 0.43, 1.00)
colors[clr.FrameBgActive] = ImVec4(0.58, 0.10, 0.35, 1.00)
colors[clr.TitleBg] = ImVec4(0.00, 0.00, 0.00, 1.00)
colors[clr.TitleBgActive] = ImVec4(0.61, 0.16, 0.39, 1.00)
colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.00, 0.00, 0.51)
colors[clr.CheckMark] = ImVec4(0.94, 0.30, 0.63, 1.00)
colors[clr.SliderGrab] = ImVec4(0.85, 0.11, 0.49, 1.00)
colors[clr.SliderGrabActive] = ImVec4(0.89, 0.24, 0.58, 1.00)
colors[clr.Button] = ImVec4(0.46, 0.11, 0.29, 1.00)
colors[clr.ButtonHovered] = ImVec4(0.69, 0.17, 0.43, 1.00)
colors[clr.ButtonActive] = ImVec4(0.59, 0.10, 0.35, 1.00)
colors[clr.Header] = ImVec4(0.46, 0.11, 0.29, 1.00)
colors[clr.HeaderHovered] = ImVec4(0.69, 0.16, 0.43, 1.00)
colors[clr.HeaderActive] = ImVec4(0.58, 0.10, 0.35, 1.00)
colors[clr.Separator] = ImVec4(0.69, 0.16, 0.43, 1.00)
colors[clr.SeparatorHovered] = ImVec4(0.58, 0.10, 0.35, 1.00)
colors[clr.SeparatorActive] = ImVec4(0.58, 0.10, 0.35, 1.00)
colors[clr.ResizeGrip] = ImVec4(0.46, 0.11, 0.29, 0.70)
colors[clr.ResizeGripHovered] = ImVec4(0.69, 0.16, 0.43, 0.67)
colors[clr.ResizeGripActive] = ImVec4(0.70, 0.13, 0.42, 1.00)
colors[clr.TextSelectedBg] = ImVec4(1.00, 0.78, 0.90, 0.35)
colors[clr.Text] = ImVec4(1.00, 1.00, 1.00, 1.00)
colors[clr.TextDisabled] = ImVec4(0.60, 0.19, 0.40, 1.00)
colors[clr.WindowBg] = ImVec4(0.06, 0.06, 0.06, 0.94)
colors[clr.ChildWindowBg] = ImVec4(1.00, 1.00, 1.00, 0.00)
colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 0.94)
colors[clr.ComboBg] = ImVec4(0.08, 0.08, 0.08, 0.94)
colors[clr.Border] = ImVec4(0.49, 0.14, 0.31, 1.00)
colors[clr.BorderShadow] = ImVec4(0.49, 0.14, 0.31, 0.00)
colors[clr.MenuBarBg] = ImVec4(0.15, 0.15, 0.15, 1.00)
colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 0.53)
colors[clr.ScrollbarGrab] = ImVec4(0.31, 0.31, 0.31, 1.00)
colors[clr.ScrollbarGrabHovered] = ImVec4(0.41, 0.41, 0.41, 1.00)
colors[clr.ScrollbarGrabActive] = ImVec4(0.51, 0.51, 0.51, 1.00)
colors[clr.CloseButton] = ImVec4(0.41, 0.41, 0.41, 0.50)
colors[clr.CloseButtonHovered] = ImVec4(0.98, 0.39, 0.36, 1.00)
colors[clr.CloseButtonActive] = ImVec4(0.98, 0.39, 0.36, 1.00)
colors[clr.ModalWindowDarkening] = ImVec4(0.80, 0.80, 0.80, 0.35)
end
dark_theme()