- 19
- 1
- Версия MoonLoader
- .026-beta
Помогите перенести слайдер с imgui на mimgui
Lua:
function imgui.CustomSlider(str_id, min, max, width, int) -- by aurora
local p = imgui.GetCursorScreenPos()
local draw_list = imgui.GetWindowDrawList()
local pos = imgui.GetWindowPos()
local posx,posy = getCursorPos()
local n = max - min
if int.v == 0 then
int.v = min
end
local col_bg_active = imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.ButtonActive])
local col_bg_notactive = imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.ModalWindowDarkening])
draw_list:AddRectFilled(imgui.ImVec2(p.x + 7, p.y + 12), imgui.ImVec2(p.x + (width/n)*(int.v-min), p.y + 12), col_bg_active, 5.0)
draw_list:AddRectFilled(imgui.ImVec2(p.x + (width/n)*(int.v-min), p.y + 12), imgui.ImVec2(p.x + width, p.y + 12), col_bg_notactive, 5.0)
for i = 0, n do
if posx > (p.x + i*width/(max+1) ) and posx < (p.x + (i+1)*width/(max+1)) and posy > p.y + 2 and posy < p.y + 22 and imgui.IsMouseDown(0) then
int.v = i + min
draw_list:AddCircleFilled(imgui.ImVec2(p.x + (width/n)*(int.v-min) + 4, p.y + 7*2 - 2), 7+2, col_bg_active)
end
end
imgui.SetCursorPos(imgui.ImVec2(p.x + width + 6 - pos.x, p.y - 8 - pos.y))
imgui.Text(tostring(int.v))
draw_list:AddCircleFilled(imgui.ImVec2(p.x + (width/n)*(int.v-min) + 4, p.y + 7*2 - 2), 7, col_bg_active)
imgui.NewLine()
return int
end