help for imgui

Kegwineye.

Участник
Автор темы
478
20
Версия MoonLoader
.026-beta
@chapo help me :> Тут крч при выборе менющки 1 не отображаются слайды для влючения/выключения. А при открытии 2 менющки ваще 0


Lua:
local key = require 'vkeys'
local wm = require 'lib.windows.message'
local imgui = require 'imgui'
local SE = require 'lib.samp.events'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local main_window_state = imgui.ImBool(false)

function main()
   if not isSampLoaded() then
      return
   end
   while not isSampAvailable() do
      wait(0)
    end
    sampRegisterChatCommand("hhl", function ()
        main_window_state.v = not main_window_state.v
    end)
    while true do
        wait(0)
        imgui.Process = main_window_state.v
    end
end

function apply_custom_style()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    style.WindowRounding = 1.5
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    style.ChildWindowRounding = 1.5
    style.FrameRounding = 1.0
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0
    -- style.Alpha =
    style.WindowPadding = imgui.ImVec2(4.0, 4.0)
    -- style.WindowMinSize =
    style.FramePadding = imgui.ImVec2(2.5, 3.5)
    -- style.ItemInnerSpacing =
    -- style.TouchExtraPadding =
    -- style.IndentSpacing =
    -- style.ColumnsMinSpacing = ?
    style.ButtonTextAlign = imgui.ImVec2(0.02, 0.4)
    -- style.DisplayWindowPadding =
    -- style.DisplaySafeAreaPadding =
    -- style.AntiAliasedLines =
    -- style.AntiAliasedShapes =
    -- style.CurveTessellationTol =
colors[clr.Text] = ImVec4(0.80, 0.80, 0.83, 1.00)
  colors[clr.TextDisabled] = ImVec4(0.24, 0.23, 0.29, 1.00)
  colors[clr.WindowBg] = ImVec4(0.06, 0.05, 0.07, 1.00)
  colors[clr.ChildWindowBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
  colors[clr.PopupBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
  colors[clr.Border] = ImVec4(0.80, 0.80, 0.83, 0.88)
  colors[clr.BorderShadow] = ImVec4(0.92, 0.91, 0.88, 0.00)
  colors[clr.FrameBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
  colors[clr.FrameBgHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
  colors[clr.FrameBgActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
  colors[clr.TitleBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
  colors[clr.TitleBgCollapsed] = ImVec4(1.00, 0.98, 0.95, 0.75)
  colors[clr.TitleBgActive] = ImVec4(0.07, 0.07, 0.09, 1.00)
  colors[clr.MenuBarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
  colors[clr.ScrollbarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
  colors[clr.ScrollbarGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
  colors[clr.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
  colors[clr.ScrollbarGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
  colors[clr.ComboBg] = ImVec4(0.19, 0.18, 0.21, 1.00)
  colors[clr.CheckMark] = ImVec4(0.80, 0.80, 0.83, 0.31)
  colors[clr.SliderGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
  colors[clr.SliderGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
  colors[clr.Button] = ImVec4(0.10, 0.09, 0.12, 1.00)
  colors[clr.ButtonHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
  colors[clr.ButtonActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
  colors[clr.Header] = ImVec4(0.10, 0.09, 0.12, 1.00)
  colors[clr.HeaderHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
  colors[clr.HeaderActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
  colors[clr.ResizeGrip] = ImVec4(0.00, 0.00, 0.00, 0.00)
  colors[clr.ResizeGripHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
  colors[clr.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
  colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
  colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
  colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00)
  colors[clr.PlotLines] = ImVec4(0.40, 0.39, 0.38, 0.63)
  colors[clr.PlotLinesHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
  colors[clr.PlotHistogram] = ImVec4(0.40, 0.39, 0.38, 0.63)
  colors[clr.PlotHistogramHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
  colors[clr.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
  colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
end
apply_custom_style()

local imBool = imgui.ImBool(false)
local imBool2 = imgui.ImBool(false)
local imBool3 = imgui.ImBool(false)
local imBool4 = imgui.ImBool(false)
local sw, sh = 200, 200


function imgui.OnDrawFrame()
    local iScreenWidth, iScreenHeight = getScreenResolution()
  
   imgui.SetNextWindowPos(imgui.ImVec2(iScreenWidth / 2, iScreenHeight / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
   imgui.SetNextWindowSize(imgui.ImVec2(500, 390), imgui.Cond.FirstUseEver)
  
   imgui.Begin("Helper from Han | v 0.0.1", main_window_state, imgui.WindowFlags.NoResize)
   imgui.BeginChild('tabs', imgui.ImVec2(sw-80, sh-90), true)
       if imgui.Button('Tab 1') then
        tab = 1
    end
    if imgui.Button('Tab 2') then
        tab = 2
    end
    imgui.EndChild()
    imgui.SameLine()
    if tab == 1 then
        imgui.BeginChild('tabs2', imgui.ImVec2(sw-200, sh-200), true)
    imgui.AlignTextToFramePadding()
    imgui.Text("Тупить сильнее когда говорят не тупи")
    imgui.SameLine(365)
    if imgui.ToggleButton("Test##1", imBool) then
        sampAddChatMessage("You change status, new status: " .. tostring(imBool.v), -1)
    end
    imgui.AlignTextToFramePadding()
    imgui.Text(u8("Press Me2"))
    imgui.SameLine(365)
    if imgui.ToggleButton("Test2##2", imBool2) then
      
    end
    imgui.AlignTextToFramePadding()
    imgui.Text(u8("Press Me3"))
    imgui.SameLine(365)
    if imgui.ToggleButton("Test2##3", imBool3) then
      
    end
    imgui.AlignTextToFramePadding()
    imgui.Text(u8("Press Me4"))
    imgui.SameLine(365)
    if imgui.ToggleButton("Test2##4", imBool4) then

    end
    imgui.Separator()
    imgui.EndChild()
    if tab == 2 then
        imgui.BeginChild('tabs3', imgui.ImVec2(sw-90, sh-60), true)
        imgui.Text('Tab 3')
        imgui.Checkbox('Tab 3', checkbox)
        imgui.Checkbox('Tab 3##2', checkbox)
        imgui.EndChild()
    end
end

   imgui.End()
end

function imgui.ToggleButton(str_id, bool)

    local rBool = false

    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
    
    local p = imgui.GetCursorScreenPos()
    local draw_list = imgui.GetWindowDrawList()

    local height = imgui.GetTextLineHeightWithSpacing() + (imgui.GetStyle().FramePadding.y / 2)
    local width = height * 1.55
    local radius = height * 0.50
    local ANIM_SPEED = 0.15

    if imgui.InvisibleButton(str_id, imgui.ImVec2(width, height)) then
        bool.v = not bool.v
        rBool = true
        LastActiveTime[tostring(str_id)] = os.clock()
        LastActive[str_id] = true
    end

    local t = bool.v and 1.0 or 0.0

    if LastActive[str_id] then
        local time = os.clock() - LastActiveTime[tostring(str_id)]
        if time <= ANIM_SPEED then
            local t_anim = ImSaturate(time / ANIM_SPEED)
            t = bool.v and t_anim or 1.0 - t_anim
        else
            LastActive[str_id] = false
        end
    end

    local col_bg
    if imgui.IsItemHovered() then
        col_bg = imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.FrameBgHovered])
    else
        col_bg = imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.FrameBg])
    end

    draw_list:AddRectFilled(p, imgui.ImVec2(p.x + width, p.y + height), col_bg, height * 0.5)
    draw_list:AddCircleFilled(imgui.ImVec2(p.x + radius + t * (width - radius * 2.0), p.y + radius), radius - 1.5, imgui.GetColorU32(bool.v and imgui.GetStyle().Colors[imgui.Col.ButtonActive] or imgui.GetStyle().Colors[imgui.Col.Button]))

    return rBool
end


function onWindowMessage(msg, wparam, lparam)
    if msg == 0x100 or msg == 0x101 then
        if (wparam == key.VK_ESCAPE and main_window_state.v) and not isPauseMenuActive() then
            consumeWindowMessage(true, false)
            if msg == 0x101 then
                main_window_state.v = false
            end
        end
    end
end
 

chapo

чопа сребдс // @moujeek
Модератор
8,931
11,695
научись ставить табуляцию. У тебя тут "противоречие"
1639155962464.png
 
  • Нравится
Реакции: Kegwineye.