- 1,298
- 618
--где то сверху
local AI_PAGE = {}
--где то внизу
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
Что нужно вписать в ondrawframe, чтобы появилась вкладка?Вкладки слева:
Lua:--где то сверху local AI_PAGE = {} --где то внизу 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
как сделать текст кину в луа файле ибо код не влазит
imgui.PageButton(tab=1, '#', 'Name')Что нужно вписать в ondrawframe, чтобы появилась вкладка?
')' expected near '='.
imgui.PageButton(tab=1, '#', 'Name')
Надеюсь ты же знаешь как делать вкладки? да?
')' expected near '='
чтобы сделать вкладку нужно сделать проверку на неё, и потом пихать внутрь что-либо?
local page = 1
if imgui.PageButton(page == 1, '#', 'Page one') then
page = 1
end
attempt to call global 'ToU32' (a nil value)Тупанул немногоLua:local page = 1 if imgui.PageButton(page == 1, '#', 'Page one') then page = 1 end
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))
local ToU32 = imgui.ColorConvertFloat4ToU32attempt to call global 'ToU32' (a nil value)
Lua: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))
как создать вторую вкладку? не получается никакlocal ToU32 = imgui.ColorConvertFloat4ToU32
после local AI_PAGE = {}
нажимаю на вкладку и ничего не происходит, ошибок в консоли нетуLua:if imgui.PageButton(page == 2, '#', 'Page Two') then page = 2 end
Так блять, ниже вкладок сделай проверку на pageнажимаю на вкладку и ничего не происходит, ошибок в консоли нету
if page == 1 then
imgui.Text(u8'Первая вкладка')
elseif page == 2 then
imgui.Text(u8'Вторая вкладка')
end
не нажимается всё равноТак блять, ниже вкладок сделай проверку на page
Lua:if page == 1 then imgui.Text(u8'Первая вкладка') elseif page == 2 then imgui.Text(u8'Вторая вкладка') end