сохранение стиля в кфг

linmsqn

Участник
Автор темы
337
9
Версия MoonLoader
.026-beta
нужно чтобы стиль выбранный человеком сохранялся в кфг, как можно сделать такое?
сразу говорю то, что я с кфг никогда не имел дела, поэтому тут уточняю

Lua:
local imgui = require 'imgui'
local key = require 'vkeys'
local fa = require 'fAwesome5'



--local themes = import "resource/imgui_themes.lua"
--local checked_radio = imgui.ImInt(1)



local theme = imgui.ImInt(1)

-- одно из основных отличий от оригинального апи
-- все переменные, значения которых записываются в ImGui по указателю, могут использоваться только через специальные типы
local main_window_state = imgui.ImBool(false)
local main_window_state2 = imgui.ImBool(false)
function imgui.OnDrawFrame()


  if theme.v == 0 then theme0() end -- красный стиль
  if theme.v == 1 then theme1() end -- синий стиль
  if theme.v == 2 then theme2() end -- коричневый стиль
  if theme.v == 3 then theme3() end -- голубой стиль
  if theme.v == 4 then theme4() end -- тёмно-салатовый стиль
  if theme.v == 5 then theme5() end -- фиолетовый стиль   


  if main_window_state.v then -- чтение и запись значения такой переменной осуществляется через поле v (или Value)
    imgui.SetNextWindowSize(imgui.ImVec2(970, 365), imgui.Cond.FirstUseEver) -- меняем размер
    -- но для передачи значения по указателю - обязательно напрямую
    -- тут main_window_state передаётся функции imgui.Begin, чтобы можно было отследить закрытие окна нажатием на крестик
    imgui.Begin('Window1', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
    imgui.Spacing()
    imgui.Separator()
    imgui.Spacing()
    imgui.TextQuestion("( UPDATE )", "УПДАТЕ")
    imgui.SetCursorPosX((imgui.GetWindowWidth() - imgui.CalcTextSize(" Темы").x) / 2)
    if imgui.Button(fa.ICON_PAINT_BRUSH .. " Темы") then -- а вот и кнопка с действием
      -- условие будет выполнено при нажатии на неё
    main_window_state2.v = not main_window_state2.v
    end
    imgui.SetCursorPosX((imgui.GetWindowWidth() - imgui.CalcTextSize(" Test2").x) / 2)
    if imgui.Button(fa.ICON_VIAL .. " Тест") then
    end
    imgui.End()
  end
  if main_window_state2.v then
    imgui.SetNextWindowSize(imgui.ImVec2(210, 220), imgui.Cond.FirstUseEver)
    imgui.Begin('Window2', main_window_state2, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
    imgui.Spacing()
    imgui.Separator()
    imgui.Spacing()
 --   if imgui.Button('Красная') then     кнопка + функция для неё
 --       themes.SwitchColorTheme(2)
 --     end     

  if imgui.Button('Красный стиль') then -- При нажатие на кнопку будем менять стиль на красный
  theme.v = 0
end
  if imgui.Button('Синий стиль') then -- При нажатие на кнопку будем менять стиль на синий
  theme.v = 1
end
  if imgui.Button('Коричневый стиль') then -- При нажатие на кнопку будем менять стиль на коричневый
  theme.v = 2
end
  if imgui.Button('Голубой стиль') then -- При нажатие на кнопку будем менять стиль на голубой
  theme.v = 3
end
  if imgui.Button('Тёмно-салатовый стиль') then -- При нажатие на кнопку будем менять стиль на тёмно-салатовый
  theme.v = 4
end
  if imgui.Button('Фиолетовый стиль') then -- При нажатие на кнопку будем менять стиль на фиолетовый
  theme.v = 5
end

                
    imgui.End()
  end
end

function main()
    imgui.Process = false
    sampRegisterChatCommand("testike", function() main_window_state.v = not main_window_state.v end) -- Команда /test
  while true do
    wait(0)
    imgui.Process = main_window_state.v or main_window_state2.v -- теперь значение imgui.Process всегда будет задаваться в зависимости от активности основного окна
  end
  imgui.Process = show_main_window.v

  themes.SwitchColorTheme(tonumber(arg))

  --imgui.SwitchContext()
  --themes.SwitchColorTheme()

    end

    show_main_window = imgui.ImBool(false)

    local fa_font = nil
    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() -- to use 'imgui.ImFontConfig.new()' on error
        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
    
    function imgui.TextQuestion(label, description)
        imgui.TextDisabled(label)
    
        if imgui.IsItemHovered() then
            imgui.BeginTooltip()
                imgui.PushTextWrapPos(600)
                    imgui.TextUnformatted(description)
                imgui.PopTextWrapPos()
            imgui.EndTooltip()
        end
    end

    function theme0() -- красный стиль
      imgui.SwitchContext()
      local style = imgui.GetStyle()
      local colors = style.Colors
      local clr = imgui.Col
      local ImVec4 = imgui.ImVec4
 
      style.WindowRounding = 2.0
      style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
      style.ChildWindowRounding = 2.0
      style.FrameRounding = 2.0
      style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
      style.ScrollbarSize = 13.0
      style.ScrollbarRounding = 0
      style.GrabMinSize = 8.0
      style.GrabRounding = 1.0
 
      colors[clr.FrameBg]                = ImVec4(0.48, 0.16, 0.16, 0.54)
      colors[clr.FrameBgHovered]         = ImVec4(0.98, 0.26, 0.26, 0.40)
      colors[clr.FrameBgActive]          = ImVec4(0.98, 0.26, 0.26, 0.67)
      colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
      colors[clr.TitleBgActive]          = ImVec4(0.48, 0.16, 0.16, 1.00)
      colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
      colors[clr.CheckMark]              = ImVec4(0.98, 0.26, 0.26, 1.00)
      colors[clr.SliderGrab]             = ImVec4(0.88, 0.26, 0.24, 1.00)
      colors[clr.SliderGrabActive]       = ImVec4(0.98, 0.26, 0.26, 1.00)
      colors[clr.Button]                 = ImVec4(0.98, 0.26, 0.26, 0.40)
      colors[clr.ButtonHovered]          = ImVec4(0.98, 0.26, 0.26, 1.00)
      colors[clr.ButtonActive]           = ImVec4(0.98, 0.06, 0.06, 1.00)
      colors[clr.Header]                 = ImVec4(0.98, 0.26, 0.26, 0.31)
      colors[clr.HeaderHovered]          = ImVec4(0.98, 0.26, 0.26, 0.80)
      colors[clr.HeaderActive]           = ImVec4(0.98, 0.26, 0.26, 1.00)
      colors[clr.Separator]              = colors[clr.Border]
      colors[clr.SeparatorHovered]       = ImVec4(0.75, 0.10, 0.10, 0.78)
      colors[clr.SeparatorActive]        = ImVec4(0.75, 0.10, 0.10, 1.00)
      colors[clr.ResizeGrip]             = ImVec4(0.98, 0.26, 0.26, 0.25)
      colors[clr.ResizeGripHovered]      = ImVec4(0.98, 0.26, 0.26, 0.67)
      colors[clr.ResizeGripActive]       = ImVec4(0.98, 0.26, 0.26, 0.95)
      colors[clr.TextSelectedBg]         = ImVec4(0.98, 0.26, 0.26, 0.35)
      colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
      colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 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]                = colors[clr.PopupBg]
      colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
      colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
      colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 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.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
      colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00)
      colors[clr.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
      colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
      colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
  end
 
  function theme1() -- синий стиль
      imgui.SwitchContext()
      local style = imgui.GetStyle()
      local colors = style.Colors
      local clr = imgui.Col
      local ImVec4 = imgui.ImVec4
 
      style.WindowRounding = 2.0
      style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
      style.ChildWindowRounding = 2.0
      style.FrameRounding = 2.0
      style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
      style.ScrollbarSize = 13.0
      style.ScrollbarRounding = 0
      style.GrabMinSize = 8.0
      style.GrabRounding = 1.0
 
      colors[clr.FrameBg]                = ImVec4(0.16, 0.29, 0.48, 0.54)
      colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.59, 0.98, 0.40)
      colors[clr.FrameBgActive]          = ImVec4(0.26, 0.59, 0.98, 0.67)
      colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
      colors[clr.TitleBgActive]          = ImVec4(0.16, 0.29, 0.48, 1.00)
      colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
      colors[clr.CheckMark]              = ImVec4(0.26, 0.59, 0.98, 1.00)
      colors[clr.SliderGrab]             = ImVec4(0.24, 0.52, 0.88, 1.00)
      colors[clr.SliderGrabActive]       = ImVec4(0.26, 0.59, 0.98, 1.00)
      colors[clr.Button]                 = ImVec4(0.26, 0.59, 0.98, 0.40)
      colors[clr.ButtonHovered]          = ImVec4(0.26, 0.59, 0.98, 1.00)
      colors[clr.ButtonActive]           = ImVec4(0.06, 0.53, 0.98, 1.00)
      colors[clr.Header]                 = ImVec4(0.26, 0.59, 0.98, 0.31)
      colors[clr.HeaderHovered]          = ImVec4(0.26, 0.59, 0.98, 0.80)
      colors[clr.HeaderActive]           = ImVec4(0.26, 0.59, 0.98, 1.00)
      colors[clr.Separator]              = colors[clr.Border]
      colors[clr.SeparatorHovered]       = ImVec4(0.26, 0.59, 0.98, 0.78)
      colors[clr.SeparatorActive]        = ImVec4(0.26, 0.59, 0.98, 1.00)
      colors[clr.ResizeGrip]             = ImVec4(0.26, 0.59, 0.98, 0.25)
      colors[clr.ResizeGripHovered]      = ImVec4(0.26, 0.59, 0.98, 0.67)
      colors[clr.ResizeGripActive]       = ImVec4(0.26, 0.59, 0.98, 0.95)
      colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.59, 0.98, 0.35)
      colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
      colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 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]                = colors[clr.PopupBg]
      colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
      colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
      colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 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.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
      colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00)
      colors[clr.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
      colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
      colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
  end

  function theme2() -- коричневый стиль
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 2.0
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0

    colors[clr.FrameBg]                = ImVec4(0.48, 0.23, 0.16, 0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.98, 0.43, 0.26, 0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.98, 0.43, 0.26, 0.67)
    colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.48, 0.23, 0.16, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.CheckMark]              = ImVec4(0.98, 0.43, 0.26, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.88, 0.39, 0.24, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.98, 0.43, 0.26, 1.00)
    colors[clr.Button]                 = ImVec4(0.98, 0.43, 0.26, 0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.98, 0.43, 0.26, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.98, 0.28, 0.06, 1.00)
    colors[clr.Header]                 = ImVec4(0.98, 0.43, 0.26, 0.31)
    colors[clr.HeaderHovered]          = ImVec4(0.98, 0.43, 0.26, 0.80)
    colors[clr.HeaderActive]           = ImVec4(0.98, 0.43, 0.26, 1.00)
    colors[clr.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.75, 0.25, 0.10, 0.78)
    colors[clr.SeparatorActive]        = ImVec4(0.75, 0.25, 0.10, 1.00)
    colors[clr.ResizeGrip]             = ImVec4(0.98, 0.43, 0.26, 0.25)
    colors[clr.ResizeGripHovered]      = ImVec4(0.98, 0.43, 0.26, 0.67)
    colors[clr.ResizeGripActive]       = ImVec4(0.98, 0.43, 0.26, 0.95)
    colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.50, 0.35, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.98, 0.43, 0.26, 0.35)
    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 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]                = colors[clr.PopupBg]
    colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
    colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 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.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
end

function theme3() -- голубой стиль
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 2.0
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0

    colors[clr.FrameBg]                = ImVec4(0.16, 0.48, 0.42, 0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.98, 0.85, 0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.26, 0.98, 0.85, 0.67)
    colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.16, 0.48, 0.42, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.CheckMark]              = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.24, 0.88, 0.77, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.Button]                 = ImVec4(0.26, 0.98, 0.85, 0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.06, 0.98, 0.82, 1.00)
    colors[clr.Header]                 = ImVec4(0.26, 0.98, 0.85, 0.31)
    colors[clr.HeaderHovered]          = ImVec4(0.26, 0.98, 0.85, 0.80)
    colors[clr.HeaderActive]           = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.10, 0.75, 0.63, 0.78)
    colors[clr.SeparatorActive]        = ImVec4(0.10, 0.75, 0.63, 1.00)
    colors[clr.ResizeGrip]             = ImVec4(0.26, 0.98, 0.85, 0.25)
    colors[clr.ResizeGripHovered]      = ImVec4(0.26, 0.98, 0.85, 0.67)
    colors[clr.ResizeGripActive]       = ImVec4(0.26, 0.98, 0.85, 0.95)
    colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.81, 0.35, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.98, 0.85, 0.35)
    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 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]                = colors[clr.PopupBg]
    colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
    colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 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.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
end

function theme4() -- тёмно-салатовый стиль
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 2.0
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0

    colors[clr.FrameBg]                = ImVec4(0.42, 0.48, 0.16, 0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.85, 0.98, 0.26, 0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.85, 0.98, 0.26, 0.67)
    colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.42, 0.48, 0.16, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.CheckMark]              = ImVec4(0.85, 0.98, 0.26, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.77, 0.88, 0.24, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.85, 0.98, 0.26, 1.00)
    colors[clr.Button]                 = ImVec4(0.85, 0.98, 0.26, 0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.85, 0.98, 0.26, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.82, 0.98, 0.06, 1.00)
    colors[clr.Header]                 = ImVec4(0.85, 0.98, 0.26, 0.31)
    colors[clr.HeaderHovered]          = ImVec4(0.85, 0.98, 0.26, 0.80)
    colors[clr.HeaderActive]           = ImVec4(0.85, 0.98, 0.26, 1.00)
    colors[clr.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.63, 0.75, 0.10, 0.78)
    colors[clr.SeparatorActive]        = ImVec4(0.63, 0.75, 0.10, 1.00)
    colors[clr.ResizeGrip]             = ImVec4(0.85, 0.98, 0.26, 0.25)
    colors[clr.ResizeGripHovered]      = ImVec4(0.85, 0.98, 0.26, 0.67)
    colors[clr.ResizeGripActive]       = ImVec4(0.85, 0.98, 0.26, 0.95)
    colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.81, 0.35, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.85, 0.98, 0.26, 0.35)
    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 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]                = colors[clr.PopupBg]
    colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
    colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 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.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
end

function theme5() -- фиолетовый стиль
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    style.WindowRounding = 2
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 3
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0
    style.WindowPadding = imgui.ImVec2(4.0, 4.0)
    style.FramePadding = imgui.ImVec2(3.5, 3.5)
    style.ButtonTextAlign = imgui.ImVec2(0.0, 0.5)
    colors[clr.WindowBg]              = ImVec4(0.14, 0.12, 0.16, 1.00);
    colors[clr.ChildWindowBg]         = ImVec4(0.30, 0.20, 0.39, 0.00);
    colors[clr.PopupBg]               = ImVec4(0.05, 0.05, 0.10, 0.90);
    colors[clr.Border]                = ImVec4(0.89, 0.85, 0.92, 0.30);
    colors[clr.BorderShadow]          = ImVec4(0.00, 0.00, 0.00, 0.00);
    colors[clr.FrameBg]               = ImVec4(0.30, 0.20, 0.39, 1.00);
    colors[clr.FrameBgHovered]        = ImVec4(0.41, 0.19, 0.63, 0.68);
    colors[clr.FrameBgActive]         = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.TitleBg]               = ImVec4(0.41, 0.19, 0.63, 0.45);
    colors[clr.TitleBgCollapsed]      = ImVec4(0.41, 0.19, 0.63, 0.35);
    colors[clr.TitleBgActive]         = ImVec4(0.41, 0.19, 0.63, 0.78);
    colors[clr.MenuBarBg]             = ImVec4(0.30, 0.20, 0.39, 0.57);
    colors[clr.ScrollbarBg]           = ImVec4(0.30, 0.20, 0.39, 1.00);
    colors[clr.ScrollbarGrab]         = ImVec4(0.41, 0.19, 0.63, 0.31);
    colors[clr.ScrollbarGrabHovered]  = ImVec4(0.41, 0.19, 0.63, 0.78);
    colors[clr.ScrollbarGrabActive]   = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.ComboBg]               = ImVec4(0.30, 0.20, 0.39, 1.00);
    colors[clr.CheckMark]             = ImVec4(0.56, 0.61, 1.00, 1.00);
    colors[clr.SliderGrab]            = ImVec4(0.41, 0.19, 0.63, 0.24);
    colors[clr.SliderGrabActive]      = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.Button]                = ImVec4(0.41, 0.19, 0.63, 0.44);
    colors[clr.ButtonHovered]         = ImVec4(0.41, 0.19, 0.63, 0.86);
    colors[clr.ButtonActive]          = ImVec4(0.64, 0.33, 0.94, 1.00);
    colors[clr.Header]                = ImVec4(0.41, 0.19, 0.63, 0.76);
    colors[clr.HeaderHovered]         = ImVec4(0.41, 0.19, 0.63, 0.86);
    colors[clr.HeaderActive]          = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.ResizeGrip]            = ImVec4(0.41, 0.19, 0.63, 0.20);
    colors[clr.ResizeGripHovered]     = ImVec4(0.41, 0.19, 0.63, 0.78);
    colors[clr.ResizeGripActive]      = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.CloseButton]           = ImVec4(1.00, 1.00, 1.00, 0.75);
    colors[clr.CloseButtonHovered]    = ImVec4(0.88, 0.74, 1.00, 0.59);
    colors[clr.CloseButtonActive]     = ImVec4(0.88, 0.85, 0.92, 1.00);
    colors[clr.PlotLines]             = ImVec4(0.89, 0.85, 0.92, 0.63);
    colors[clr.PlotLinesHovered]      = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.PlotHistogram]         = ImVec4(0.89, 0.85, 0.92, 0.63);
    colors[clr.PlotHistogramHovered]  = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.TextSelectedBg]        = ImVec4(0.41, 0.19, 0.63, 0.43);
    colors[clr.ModalWindowDarkening]  = ImVec4(0.20, 0.20, 0.20, 0.35);
end
apply_custom_style()
 

A S K I T

Активный
200
69
Попробуй

Lua:
-- К библиотекам.
local inicfg = require 'inicfg'
local cfg = inicfg.load({
    settings = {
        theme = 0,
    },
})
inicfg.save(cfg)

-- В OnDrawFrame()
if imgui.Button('Синяя тема') then cfg.settings.theme = 0 inicfg.save(cfg) end
if imgui.Button('Красная тема') then cfg.settings.theme = 1 inicfg.save(cfg) end

-- Применение темы.
if cfg.settings.theme == 0 then applyBlueTheme()
elseif cfg.settings.theme == 1 then applyRedTheme() end

-- Сохранение конфига.
function saveData()
    inicfg.save({
        settings =
        {
            theme = cfg.settings.theme
        },
    })
end
 
  • Нравится
Реакции: Shepi

jayden_daskadsasdasd

Новичок
11
1
Попробуй

Lua:
-- К библиотекам.
local inicfg = require 'inicfg'
local cfg = inicfg.load({
    settings = {
        theme = 0,
    },
})
inicfg.save(cfg)

-- В OnDrawFrame()
if imgui.Button('Синяя тема') then cfg.settings.theme = 0 inicfg.save(cfg) end
if imgui.Button('Красная тема') then cfg.settings.theme = 1 inicfg.save(cfg) end

-- Применение темы.
if cfg.settings.theme == 0 then applyBlueTheme()
elseif cfg.settings.theme == 1 then applyRedTheme() end

-- Сохранение конфига.
function saveData()
    inicfg.save({
        settings =
        {
            theme = cfg.settings.theme
        },
    })
end
а где тут можно название самого кфг файла отредачить?
 

A S K I T

Активный
200
69
а где тут можно название самого кфг файла отредачить?
Используй:
local direct_cfg = '../papka/script.ini'
local cfg = inicfg.load(inicfg.load({
    settings = {
        -- ASD
    },
}, direct_cfg))
inicfg.save(cfg, direct_cfg)
И в место:
inicfg.save(cfg)
Это:
inicfg.save(cfg, direct_cfg)
 

linmsqn

Участник
Автор темы
337
9
Используй:
local direct_cfg = '../papka/script.ini'
local cfg = inicfg.load(inicfg.load({
    settings = {
        -- ASD
    },
}, direct_cfg))
inicfg.save(cfg, direct_cfg)
И в место:
inicfg.save(cfg)
Это:
inicfg.save(cfg, direct_cfg)
Сохранение в конфиге работает, но у меня теперь не работает переключение стилей из-за кфг. Типо он сохраняет тему и новую включить уже нельзя
Lua:
local imgui = require 'imgui'
local key = require 'vkeys'
local fa = require 'fAwesome5'

local inicfg = require 'inicfg'
local cfg = inicfg.load({
    settings = {
        theme = 0,
    },
})
inicfg.save(cfg, direct_cfg)


--local themes = import "resource/imgui_themes.lua"
--local checked_radio = imgui.ImInt(1)



local theme = imgui.ImInt(1)

-- одно из основных отличий от оригинального апи
-- все переменные, значения которых записываются в ImGui по указателю, могут использоваться только через специальные типы
local main_window_state = imgui.ImBool(false)
local main_window_state2 = imgui.ImBool(false)
function imgui.OnDrawFrame()


  if theme.v == 0 then theme0() end -- красный стиль
  if theme.v == 1 then theme1() end -- синий стиль
  if theme.v == 2 then theme2() end -- коричневый стиль
  if theme.v == 3 then theme3() end -- голубой стиль
  if theme.v == 4 then theme4() end -- тёмно-салатовый стиль
  if theme.v == 5 then theme5() end -- фиолетовый стиль   


  if main_window_state.v then -- чтение и запись значения такой переменной осуществляется через поле v (или Value)
    imgui.SetNextWindowSize(imgui.ImVec2(970, 365), imgui.Cond.FirstUseEver) -- меняем размер
    -- но для передачи значения по указателю - обязательно напрямую
    -- тут main_window_state передаётся функции imgui.Begin, чтобы можно было отследить закрытие окна нажатием на крестик
    imgui.Begin('Window1', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
    imgui.Spacing()
    imgui.Separator()
    imgui.Spacing() 
    imgui.TextQuestion("( UPDATE )", "УПДАТЕ")
    --imgui.SetCursorPosX((imgui.GetWindowWidth() - imgui.CalcTextSize(" Темы").x) / 2)
    if imgui.Button(fa.ICON_PAINT_BRUSH .. " Темы") then -- а вот и кнопка с действием
      -- условие будет выполнено при нажатии на неё
    main_window_state2.v = not main_window_state2.v
    end
    --imgui.SetCursorPosX((imgui.GetWindowWidth() - imgui.CalcTextSize(" Test2").x) / 2)
    if imgui.Button(fa.ICON_VIAL .. " Тест") then
    end
    imgui.End()
  end
  if main_window_state2.v then
    imgui.SetNextWindowSize(imgui.ImVec2(210, 220), imgui.Cond.FirstUseEver)
    imgui.Begin('Window2', main_window_state2, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
    imgui.Spacing()
    imgui.Separator()
    imgui.Spacing()
 --   if imgui.Button('Красная') then     кнопка + функция для неё
 --       themes.SwitchColorTheme(2)
 --     end     

  if imgui.Button('Красный стиль') then cfg.settings.theme = 0 inicfg.save(cfg) end -- При нажатие на кнопку будем менять стиль на красный
  theme.v = 0

  if imgui.Button('Синий стиль') then cfg.settings.theme = 1 inicfg.save(cfg) end -- При нажатие на кнопку будем менять стиль на синий
  theme.v = 1

  if imgui.Button('Коричневый стиль') then cfg.settings.theme = 2 inicfg.save(cfg) end -- При нажатие на кнопку будем менять стиль на коричневый
  theme.v = 2
 
  if imgui.Button('Голубой стиль') then cfg.settings.theme = 3 inicfg.save(cfg) end -- При нажатие на кнопку будем менять стиль на голубой
  theme.v = 3

  if imgui.Button('Тёмно-салатовый стиль') then cfg.settings.theme = 4 inicfg.save(cfg) end -- При нажатие на кнопку будем менять стиль на тёмно-салатовый
  theme.v = 4

  if imgui.Button('Фиолетовый стиль') then cfg.settings.theme = 5 inicfg.save(cfg) end -- При нажатие на кнопку будем менять стиль на фиолетовый
  theme.v = 5


                
    imgui.End()
  end
end

function main()
    imgui.Process = false
    sampRegisterChatCommand("testike", function() main_window_state.v = not main_window_state.v end) -- Команда /test
  while true do
    wait(0)
    imgui.Process = main_window_state.v or main_window_state2.v -- теперь значение imgui.Process всегда будет задаваться в зависимости от активности основного окна
  end
  imgui.Process = show_main_window.v

  themes.SwitchColorTheme(tonumber(arg))

  --imgui.SwitchContext()
  --themes.SwitchColorTheme()

    end

    show_main_window = imgui.ImBool(false)

    local fa_font = nil
    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() -- to use 'imgui.ImFontConfig.new()' on error
        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
    
    function imgui.TextQuestion(label, description)
        imgui.TextDisabled(label)
    
        if imgui.IsItemHovered() then
            imgui.BeginTooltip()
                imgui.PushTextWrapPos(600)
                    imgui.TextUnformatted(description)
                imgui.PopTextWrapPos()
            imgui.EndTooltip()
        end
    end

    function theme0() -- красный стиль
      imgui.SwitchContext()
      local style = imgui.GetStyle()
      local colors = style.Colors
      local clr = imgui.Col
      local ImVec4 = imgui.ImVec4
 
      style.WindowRounding = 2.0
      style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
      style.ChildWindowRounding = 2.0
      style.FrameRounding = 2.0
      style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
      style.ScrollbarSize = 13.0
      style.ScrollbarRounding = 0
      style.GrabMinSize = 8.0
      style.GrabRounding = 1.0
 
      colors[clr.FrameBg]                = ImVec4(0.48, 0.16, 0.16, 0.54)
      colors[clr.FrameBgHovered]         = ImVec4(0.98, 0.26, 0.26, 0.40)
      colors[clr.FrameBgActive]          = ImVec4(0.98, 0.26, 0.26, 0.67)
      colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
      colors[clr.TitleBgActive]          = ImVec4(0.48, 0.16, 0.16, 1.00)
      colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
      colors[clr.CheckMark]              = ImVec4(0.98, 0.26, 0.26, 1.00)
      colors[clr.SliderGrab]             = ImVec4(0.88, 0.26, 0.24, 1.00)
      colors[clr.SliderGrabActive]       = ImVec4(0.98, 0.26, 0.26, 1.00)
      colors[clr.Button]                 = ImVec4(0.98, 0.26, 0.26, 0.40)
      colors[clr.ButtonHovered]          = ImVec4(0.98, 0.26, 0.26, 1.00)
      colors[clr.ButtonActive]           = ImVec4(0.98, 0.06, 0.06, 1.00)
      colors[clr.Header]                 = ImVec4(0.98, 0.26, 0.26, 0.31)
      colors[clr.HeaderHovered]          = ImVec4(0.98, 0.26, 0.26, 0.80)
      colors[clr.HeaderActive]           = ImVec4(0.98, 0.26, 0.26, 1.00)
      colors[clr.Separator]              = colors[clr.Border]
      colors[clr.SeparatorHovered]       = ImVec4(0.75, 0.10, 0.10, 0.78)
      colors[clr.SeparatorActive]        = ImVec4(0.75, 0.10, 0.10, 1.00)
      colors[clr.ResizeGrip]             = ImVec4(0.98, 0.26, 0.26, 0.25)
      colors[clr.ResizeGripHovered]      = ImVec4(0.98, 0.26, 0.26, 0.67)
      colors[clr.ResizeGripActive]       = ImVec4(0.98, 0.26, 0.26, 0.95)
      colors[clr.TextSelectedBg]         = ImVec4(0.98, 0.26, 0.26, 0.35)
      colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
      colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 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]                = colors[clr.PopupBg]
      colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
      colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
      colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 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.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
      colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00)
      colors[clr.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
      colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
      colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
  end
 
  function theme1() -- синий стиль
      imgui.SwitchContext()
      local style = imgui.GetStyle()
      local colors = style.Colors
      local clr = imgui.Col
      local ImVec4 = imgui.ImVec4
 
      style.WindowRounding = 2.0
      style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
      style.ChildWindowRounding = 2.0
      style.FrameRounding = 2.0
      style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
      style.ScrollbarSize = 13.0
      style.ScrollbarRounding = 0
      style.GrabMinSize = 8.0
      style.GrabRounding = 1.0
 
      colors[clr.FrameBg]                = ImVec4(0.16, 0.29, 0.48, 0.54)
      colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.59, 0.98, 0.40)
      colors[clr.FrameBgActive]          = ImVec4(0.26, 0.59, 0.98, 0.67)
      colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
      colors[clr.TitleBgActive]          = ImVec4(0.16, 0.29, 0.48, 1.00)
      colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
      colors[clr.CheckMark]              = ImVec4(0.26, 0.59, 0.98, 1.00)
      colors[clr.SliderGrab]             = ImVec4(0.24, 0.52, 0.88, 1.00)
      colors[clr.SliderGrabActive]       = ImVec4(0.26, 0.59, 0.98, 1.00)
      colors[clr.Button]                 = ImVec4(0.26, 0.59, 0.98, 0.40)
      colors[clr.ButtonHovered]          = ImVec4(0.26, 0.59, 0.98, 1.00)
      colors[clr.ButtonActive]           = ImVec4(0.06, 0.53, 0.98, 1.00)
      colors[clr.Header]                 = ImVec4(0.26, 0.59, 0.98, 0.31)
      colors[clr.HeaderHovered]          = ImVec4(0.26, 0.59, 0.98, 0.80)
      colors[clr.HeaderActive]           = ImVec4(0.26, 0.59, 0.98, 1.00)
      colors[clr.Separator]              = colors[clr.Border]
      colors[clr.SeparatorHovered]       = ImVec4(0.26, 0.59, 0.98, 0.78)
      colors[clr.SeparatorActive]        = ImVec4(0.26, 0.59, 0.98, 1.00)
      colors[clr.ResizeGrip]             = ImVec4(0.26, 0.59, 0.98, 0.25)
      colors[clr.ResizeGripHovered]      = ImVec4(0.26, 0.59, 0.98, 0.67)
      colors[clr.ResizeGripActive]       = ImVec4(0.26, 0.59, 0.98, 0.95)
      colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.59, 0.98, 0.35)
      colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
      colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 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]                = colors[clr.PopupBg]
      colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
      colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
      colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 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.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
      colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00)
      colors[clr.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
      colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
      colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
  end

  function theme2() -- коричневый стиль
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 2.0
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0

    colors[clr.FrameBg]                = ImVec4(0.48, 0.23, 0.16, 0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.98, 0.43, 0.26, 0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.98, 0.43, 0.26, 0.67)
    colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.48, 0.23, 0.16, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.CheckMark]              = ImVec4(0.98, 0.43, 0.26, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.88, 0.39, 0.24, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.98, 0.43, 0.26, 1.00)
    colors[clr.Button]                 = ImVec4(0.98, 0.43, 0.26, 0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.98, 0.43, 0.26, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.98, 0.28, 0.06, 1.00)
    colors[clr.Header]                 = ImVec4(0.98, 0.43, 0.26, 0.31)
    colors[clr.HeaderHovered]          = ImVec4(0.98, 0.43, 0.26, 0.80)
    colors[clr.HeaderActive]           = ImVec4(0.98, 0.43, 0.26, 1.00)
    colors[clr.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.75, 0.25, 0.10, 0.78)
    colors[clr.SeparatorActive]        = ImVec4(0.75, 0.25, 0.10, 1.00)
    colors[clr.ResizeGrip]             = ImVec4(0.98, 0.43, 0.26, 0.25)
    colors[clr.ResizeGripHovered]      = ImVec4(0.98, 0.43, 0.26, 0.67)
    colors[clr.ResizeGripActive]       = ImVec4(0.98, 0.43, 0.26, 0.95)
    colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.50, 0.35, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.98, 0.43, 0.26, 0.35)
    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 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]                = colors[clr.PopupBg]
    colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
    colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 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.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
end

function theme3() -- голубой стиль
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 2.0
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0

    colors[clr.FrameBg]                = ImVec4(0.16, 0.48, 0.42, 0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.98, 0.85, 0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.26, 0.98, 0.85, 0.67)
    colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.16, 0.48, 0.42, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.CheckMark]              = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.24, 0.88, 0.77, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.Button]                 = ImVec4(0.26, 0.98, 0.85, 0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.06, 0.98, 0.82, 1.00)
    colors[clr.Header]                 = ImVec4(0.26, 0.98, 0.85, 0.31)
    colors[clr.HeaderHovered]          = ImVec4(0.26, 0.98, 0.85, 0.80)
    colors[clr.HeaderActive]           = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.10, 0.75, 0.63, 0.78)
    colors[clr.SeparatorActive]        = ImVec4(0.10, 0.75, 0.63, 1.00)
    colors[clr.ResizeGrip]             = ImVec4(0.26, 0.98, 0.85, 0.25)
    colors[clr.ResizeGripHovered]      = ImVec4(0.26, 0.98, 0.85, 0.67)
    colors[clr.ResizeGripActive]       = ImVec4(0.26, 0.98, 0.85, 0.95)
    colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.81, 0.35, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.98, 0.85, 0.35)
    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 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]                = colors[clr.PopupBg]
    colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
    colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 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.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
end

function theme4() -- тёмно-салатовый стиль
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 2.0
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0

    colors[clr.FrameBg]                = ImVec4(0.42, 0.48, 0.16, 0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.85, 0.98, 0.26, 0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.85, 0.98, 0.26, 0.67)
    colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.42, 0.48, 0.16, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.CheckMark]              = ImVec4(0.85, 0.98, 0.26, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.77, 0.88, 0.24, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.85, 0.98, 0.26, 1.00)
    colors[clr.Button]                 = ImVec4(0.85, 0.98, 0.26, 0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.85, 0.98, 0.26, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.82, 0.98, 0.06, 1.00)
    colors[clr.Header]                 = ImVec4(0.85, 0.98, 0.26, 0.31)
    colors[clr.HeaderHovered]          = ImVec4(0.85, 0.98, 0.26, 0.80)
    colors[clr.HeaderActive]           = ImVec4(0.85, 0.98, 0.26, 1.00)
    colors[clr.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.63, 0.75, 0.10, 0.78)
    colors[clr.SeparatorActive]        = ImVec4(0.63, 0.75, 0.10, 1.00)
    colors[clr.ResizeGrip]             = ImVec4(0.85, 0.98, 0.26, 0.25)
    colors[clr.ResizeGripHovered]      = ImVec4(0.85, 0.98, 0.26, 0.67)
    colors[clr.ResizeGripActive]       = ImVec4(0.85, 0.98, 0.26, 0.95)
    colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.81, 0.35, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.85, 0.98, 0.26, 0.35)
    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 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]                = colors[clr.PopupBg]
    colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
    colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 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.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
end

function theme5() -- фиолетовый стиль
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    style.WindowRounding = 2
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 3
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0
    style.WindowPadding = imgui.ImVec2(4.0, 4.0)
    style.FramePadding = imgui.ImVec2(3.5, 3.5)
    style.ButtonTextAlign = imgui.ImVec2(0.0, 0.5)
    colors[clr.WindowBg]              = ImVec4(0.14, 0.12, 0.16, 1.00);
    colors[clr.ChildWindowBg]         = ImVec4(0.30, 0.20, 0.39, 0.00);
    colors[clr.PopupBg]               = ImVec4(0.05, 0.05, 0.10, 0.90);
    colors[clr.Border]                = ImVec4(0.89, 0.85, 0.92, 0.30);
    colors[clr.BorderShadow]          = ImVec4(0.00, 0.00, 0.00, 0.00);
    colors[clr.FrameBg]               = ImVec4(0.30, 0.20, 0.39, 1.00);
    colors[clr.FrameBgHovered]        = ImVec4(0.41, 0.19, 0.63, 0.68);
    colors[clr.FrameBgActive]         = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.TitleBg]               = ImVec4(0.41, 0.19, 0.63, 0.45);
    colors[clr.TitleBgCollapsed]      = ImVec4(0.41, 0.19, 0.63, 0.35);
    colors[clr.TitleBgActive]         = ImVec4(0.41, 0.19, 0.63, 0.78);
    colors[clr.MenuBarBg]             = ImVec4(0.30, 0.20, 0.39, 0.57);
    colors[clr.ScrollbarBg]           = ImVec4(0.30, 0.20, 0.39, 1.00);
    colors[clr.ScrollbarGrab]         = ImVec4(0.41, 0.19, 0.63, 0.31);
    colors[clr.ScrollbarGrabHovered]  = ImVec4(0.41, 0.19, 0.63, 0.78);
    colors[clr.ScrollbarGrabActive]   = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.ComboBg]               = ImVec4(0.30, 0.20, 0.39, 1.00);
    colors[clr.CheckMark]             = ImVec4(0.56, 0.61, 1.00, 1.00);
    colors[clr.SliderGrab]            = ImVec4(0.41, 0.19, 0.63, 0.24);
    colors[clr.SliderGrabActive]      = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.Button]                = ImVec4(0.41, 0.19, 0.63, 0.44);
    colors[clr.ButtonHovered]         = ImVec4(0.41, 0.19, 0.63, 0.86);
    colors[clr.ButtonActive]          = ImVec4(0.64, 0.33, 0.94, 1.00);
    colors[clr.Header]                = ImVec4(0.41, 0.19, 0.63, 0.76);
    colors[clr.HeaderHovered]         = ImVec4(0.41, 0.19, 0.63, 0.86);
    colors[clr.HeaderActive]          = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.ResizeGrip]            = ImVec4(0.41, 0.19, 0.63, 0.20);
    colors[clr.ResizeGripHovered]     = ImVec4(0.41, 0.19, 0.63, 0.78);
    colors[clr.ResizeGripActive]      = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.CloseButton]           = ImVec4(1.00, 1.00, 1.00, 0.75);
    colors[clr.CloseButtonHovered]    = ImVec4(0.88, 0.74, 1.00, 0.59);
    colors[clr.CloseButtonActive]     = ImVec4(0.88, 0.85, 0.92, 1.00);
    colors[clr.PlotLines]             = ImVec4(0.89, 0.85, 0.92, 0.63);
    colors[clr.PlotLinesHovered]      = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.PlotHistogram]         = ImVec4(0.89, 0.85, 0.92, 0.63);
    colors[clr.PlotHistogramHovered]  = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.TextSelectedBg]        = ImVec4(0.41, 0.19, 0.63, 0.43);
    colors[clr.ModalWindowDarkening]  = ImVec4(0.20, 0.20, 0.20, 0.35);
end

function saveData()
  inicfg.save({
      settings =
      {
          theme = cfg.settings.theme
      },
  })
end
 

A S K I T

Активный
200
69
В конце кода убери.

Сделай функцию:
Lua:
function swith_theme()
    lua_thread.create(function()
        while true do wait(0)
            if cfg.settings.theme.v == 0 then
                applyBlueTheme()
            elseif cfg.settings.theme.v == 1 then
                applyRedTheme()
            end
        end
    end)
end

И вставь её в main()
 

linmsqn

Участник
Автор темы
337
9
Lua:
            if cfg.settings.theme.v == 0 then
                applyBlueTheme()
            elseif cfg.settings.theme.v == 1 then
                applyRedTheme()
у меня больше стилей, а не красный и синий, как добавить остальные?

[22:34:46.761540] (error) testnovoe.lua: D:\Сборки\GTA SA by gashcontrol\moonloader\testnovoe.lua:130: unexpected symbol near ')'
[22:34:46.761540] (error) testnovoe.lua: Script died due to an error. (230986BC)

Lua:
local imgui = require 'imgui'
local key = require 'vkeys'
local fa = require 'fAwesome5'
local sw, sh = getScreenResolution()

--сохранение темы, не работаэ щас

local inicfg = require 'inicfg'
local direct_cfg = '../papka/script.ini'
local cfg = inicfg.load({
    settings = {
        theme = 0,
    },
})
inicfg.save(cfg, direct_cfg)

if cfg.settings.theme == 0 then applyRedTheme()
elseif cfg.settings.theme == 1 then applyBlueTheme() end
if cfg.settings.theme == 2 then applyBrownTheme()
elseif cfg.settings.theme == 3 then applyLightBlueTheme() end
if cfg.settings.theme == 4 then applyLightGreenTheme()
elseif cfg.settings.theme == 5 then applyPurpleTheme() end

--сохранение темы, не работаэ щас


--local themes = import "resource/imgui_themes.lua"
--local checked_radio = imgui.ImInt(1)





local theme = imgui.ImInt(1)

-- одно из основных отличий от оригинального апи
-- все переменные, значения которых записываются в ImGui по указателю, могут использоваться только через специальные типы
local main_window_state = imgui.ImBool(false)
local main_window_state2 = imgui.ImBool(false)
function imgui.OnDrawFrame()


  if theme.v == 0 then theme0() end -- красный стиль
  if theme.v == 1 then theme1() end -- синий стиль
  if theme.v == 2 then theme2() end -- коричневый стиль
  if theme.v == 3 then theme3() end -- голубой стиль
  if theme.v == 4 then theme4() end -- тёмно-салатовый стиль
  if theme.v == 5 then theme5() end -- фиолетовый стиль   


  if main_window_state.v then -- чтение и запись значения такой переменной осуществляется через поле v (или Value)
    imgui.SetNextWindowSize(imgui.ImVec2(665, 600), imgui.Cond.FirstUseEver) -- меняем размер
    imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

    -- но для передачи значения по указателю - обязательно напрямую
    -- тут main_window_state передаётся функции imgui.Begin, чтобы можно было отследить закрытие окна нажатием на крестик
    imgui.Begin('Window1', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
    imgui.Spacing()
    imgui.Separator()
    imgui.Spacing() 
    imgui.TextQuestion("( UPDATE )", "УПДАТЕ")
    --imgui.SetCursorPosX((imgui.GetWindowWidth() - imgui.CalcTextSize(" Темы").x) / 2)
    if imgui.Button(fa.ICON_PAINT_BRUSH .. " Темы") then -- а вот и кнопка с действием
      -- условие будет выполнено при нажатии на неё
    main_window_state2.v = not main_window_state2.v
    end
    --imgui.SetCursorPosX((imgui.GetWindowWidth() - imgui.CalcTextSize(" Test2").x) / 2)
    if imgui.Button(fa.ICON_VIAL .. " Тест") then
    end
    imgui.End()
  end
  if main_window_state2.v then
    imgui.SetNextWindowSize(imgui.ImVec2(210, 220), imgui.Cond.FirstUseEver)
    imgui.Begin('Window2', main_window_state2, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
    imgui.Spacing()
    imgui.Separator()
    imgui.Spacing()
 --   if imgui.Button('Красная') then     кнопка + функция для неё
 --       themes.SwitchColorTheme(2)
 --     end     

  if imgui.Button('Красный стиль') then cfg.settings.theme = 1 inicfg.save(cfg) end -- При нажатие на кнопку будем менять стиль на красный
  --theme.v = 0


  if imgui.Button('Синий стиль') then  cfg.settings.theme = 2 inicfg.save(cfg) end -- При нажатие на кнопку будем менять стиль на синий
  --theme.v = 1


  if imgui.Button('Коричневый стиль') then  cfg.settings.theme = 3 inicfg.save(cfg) end -- При нажатие на кнопку будем менять стиль на коричневый
  --theme.v = 2


  if imgui.Button('Голубой стиль') then  cfg.settings.theme = 4 inicfg.save(cfg) end -- При нажатие на кнопку будем менять стиль на голубой
  --theme.v = 3


  if imgui.Button('Тёмно-салатовый стиль') then  cfg.settings.theme = 5 inicfg.save(cfg) end -- При нажатие на кнопку будем менять стиль на тёмно-салатовый
  --theme.v = 4


  if imgui.Button('Фиолетовый стиль') then cfg.settings.theme = 6 inicfg.save(cfg) end -- При нажатие на кнопку будем менять стиль на фиолетовый
  --theme.v = 5



                
    imgui.End()
  end
end

function main()
  function swith_theme()
    lua_thread.create(function()
        while true do wait(0)
            if cfg.settings.theme.v == 0 then
                applyRedTheme()
            elseif cfg.settings.theme.v == 1 then
                applyBlueTheme()
            if cfg.settings.theme.v == 2 then
                applyBrownTheme()
            elseif cfg.settings.theme.v == 3 then
                applyLightBlueTheme()
            if cfg.settings.theme.v == 4 then
                applyLightGreenTheme()
            elseif cfg.settings.theme.v == 5 then
                applyPurpleTheme()
          end
        end
      end)
    end

    imgui.Process = false
    sampRegisterChatCommand("testik", function() main_window_state.v = not main_window_state.v end) -- Команда /testik           

  while true do
    wait(0)
    imgui.Process = main_window_state.v or main_window_state2.v -- теперь значение imgui.Process всегда будет задаваться в зависимости от активности основного окна
  end
  imgui.Process = show_main_window.v

  themes.SwitchColorTheme(tonumber(arg))

  --imgui.SwitchContext()
  --themes.SwitchColorTheme()

    end

    show_main_window = imgui.ImBool(false)

    local fa_font = nil
    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() -- to use 'imgui.ImFontConfig.new()' on error
        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
    
    function imgui.TextQuestion(label, description)
        imgui.TextDisabled(label)
    
        if imgui.IsItemHovered() then
            imgui.BeginTooltip()
                imgui.PushTextWrapPos(600)
                    imgui.TextUnformatted(description)
                imgui.PopTextWrapPos()
            imgui.EndTooltip()
        end
    end

    function saveData()
      inicfg.save({
           settings =
           {
               theme = cfg.settings.theme
           },
       })
     end

    function theme0() -- красный стиль
      imgui.SwitchContext()
      local style = imgui.GetStyle()
      local colors = style.Colors
      local clr = imgui.Col
      local ImVec4 = imgui.ImVec4
 
      style.WindowRounding = 2.0
      style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
      style.ChildWindowRounding = 2.0
      style.FrameRounding = 2.0
      style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
      style.ScrollbarSize = 13.0
      style.ScrollbarRounding = 0
      style.GrabMinSize = 8.0
      style.GrabRounding = 1.0
 
      colors[clr.FrameBg]                = ImVec4(0.48, 0.16, 0.16, 0.54)
      colors[clr.FrameBgHovered]         = ImVec4(0.98, 0.26, 0.26, 0.40)
      colors[clr.FrameBgActive]          = ImVec4(0.98, 0.26, 0.26, 0.67)
      colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
      colors[clr.TitleBgActive]          = ImVec4(0.48, 0.16, 0.16, 1.00)
      colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
      colors[clr.CheckMark]              = ImVec4(0.98, 0.26, 0.26, 1.00)
      colors[clr.SliderGrab]             = ImVec4(0.88, 0.26, 0.24, 1.00)
      colors[clr.SliderGrabActive]       = ImVec4(0.98, 0.26, 0.26, 1.00)
      colors[clr.Button]                 = ImVec4(0.98, 0.26, 0.26, 0.40)
      colors[clr.ButtonHovered]          = ImVec4(0.98, 0.26, 0.26, 1.00)
      colors[clr.ButtonActive]           = ImVec4(0.98, 0.06, 0.06, 1.00)
      colors[clr.Header]                 = ImVec4(0.98, 0.26, 0.26, 0.31)
      colors[clr.HeaderHovered]          = ImVec4(0.98, 0.26, 0.26, 0.80)
      colors[clr.HeaderActive]           = ImVec4(0.98, 0.26, 0.26, 1.00)
      colors[clr.Separator]              = colors[clr.Border]
      colors[clr.SeparatorHovered]       = ImVec4(0.75, 0.10, 0.10, 0.78)
      colors[clr.SeparatorActive]        = ImVec4(0.75, 0.10, 0.10, 1.00)
      colors[clr.ResizeGrip]             = ImVec4(0.98, 0.26, 0.26, 0.25)
      colors[clr.ResizeGripHovered]      = ImVec4(0.98, 0.26, 0.26, 0.67)
      colors[clr.ResizeGripActive]       = ImVec4(0.98, 0.26, 0.26, 0.95)
      colors[clr.TextSelectedBg]         = ImVec4(0.98, 0.26, 0.26, 0.35)
      colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
      colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 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]                = colors[clr.PopupBg]
      colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
      colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
      colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 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.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
      colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00)
      colors[clr.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
      colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
      colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
  end
 
  function theme1() -- синий стиль
      imgui.SwitchContext()
      local style = imgui.GetStyle()
      local colors = style.Colors
      local clr = imgui.Col
      local ImVec4 = imgui.ImVec4
 
      style.WindowRounding = 2.0
      style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
      style.ChildWindowRounding = 2.0
      style.FrameRounding = 2.0
      style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
      style.ScrollbarSize = 13.0
      style.ScrollbarRounding = 0
      style.GrabMinSize = 8.0
      style.GrabRounding = 1.0
 
      colors[clr.FrameBg]                = ImVec4(0.16, 0.29, 0.48, 0.54)
      colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.59, 0.98, 0.40)
      colors[clr.FrameBgActive]          = ImVec4(0.26, 0.59, 0.98, 0.67)
      colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
      colors[clr.TitleBgActive]          = ImVec4(0.16, 0.29, 0.48, 1.00)
      colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
      colors[clr.CheckMark]              = ImVec4(0.26, 0.59, 0.98, 1.00)
      colors[clr.SliderGrab]             = ImVec4(0.24, 0.52, 0.88, 1.00)
      colors[clr.SliderGrabActive]       = ImVec4(0.26, 0.59, 0.98, 1.00)
      colors[clr.Button]                 = ImVec4(0.26, 0.59, 0.98, 0.40)
      colors[clr.ButtonHovered]          = ImVec4(0.26, 0.59, 0.98, 1.00)
      colors[clr.ButtonActive]           = ImVec4(0.06, 0.53, 0.98, 1.00)
      colors[clr.Header]                 = ImVec4(0.26, 0.59, 0.98, 0.31)
      colors[clr.HeaderHovered]          = ImVec4(0.26, 0.59, 0.98, 0.80)
      colors[clr.HeaderActive]           = ImVec4(0.26, 0.59, 0.98, 1.00)
      colors[clr.Separator]              = colors[clr.Border]
      colors[clr.SeparatorHovered]       = ImVec4(0.26, 0.59, 0.98, 0.78)
      colors[clr.SeparatorActive]        = ImVec4(0.26, 0.59, 0.98, 1.00)
      colors[clr.ResizeGrip]             = ImVec4(0.26, 0.59, 0.98, 0.25)
      colors[clr.ResizeGripHovered]      = ImVec4(0.26, 0.59, 0.98, 0.67)
      colors[clr.ResizeGripActive]       = ImVec4(0.26, 0.59, 0.98, 0.95)
      colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.59, 0.98, 0.35)
      colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
      colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 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]                = colors[clr.PopupBg]
      colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
      colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
      colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 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.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
      colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00)
      colors[clr.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
      colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
      colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
  end

  function theme2() -- коричневый стиль
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 2.0
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0

    colors[clr.FrameBg]                = ImVec4(0.48, 0.23, 0.16, 0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.98, 0.43, 0.26, 0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.98, 0.43, 0.26, 0.67)
    colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.48, 0.23, 0.16, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.CheckMark]              = ImVec4(0.98, 0.43, 0.26, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.88, 0.39, 0.24, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.98, 0.43, 0.26, 1.00)
    colors[clr.Button]                 = ImVec4(0.98, 0.43, 0.26, 0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.98, 0.43, 0.26, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.98, 0.28, 0.06, 1.00)
    colors[clr.Header]                 = ImVec4(0.98, 0.43, 0.26, 0.31)
    colors[clr.HeaderHovered]          = ImVec4(0.98, 0.43, 0.26, 0.80)
    colors[clr.HeaderActive]           = ImVec4(0.98, 0.43, 0.26, 1.00)
    colors[clr.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.75, 0.25, 0.10, 0.78)
    colors[clr.SeparatorActive]        = ImVec4(0.75, 0.25, 0.10, 1.00)
    colors[clr.ResizeGrip]             = ImVec4(0.98, 0.43, 0.26, 0.25)
    colors[clr.ResizeGripHovered]      = ImVec4(0.98, 0.43, 0.26, 0.67)
    colors[clr.ResizeGripActive]       = ImVec4(0.98, 0.43, 0.26, 0.95)
    colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.50, 0.35, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.98, 0.43, 0.26, 0.35)
    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 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]                = colors[clr.PopupBg]
    colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
    colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 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.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
end

function theme3() -- голубой стиль
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 2.0
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0

    colors[clr.FrameBg]                = ImVec4(0.16, 0.48, 0.42, 0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.98, 0.85, 0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.26, 0.98, 0.85, 0.67)
    colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.16, 0.48, 0.42, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.CheckMark]              = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.24, 0.88, 0.77, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.Button]                 = ImVec4(0.26, 0.98, 0.85, 0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.06, 0.98, 0.82, 1.00)
    colors[clr.Header]                 = ImVec4(0.26, 0.98, 0.85, 0.31)
    colors[clr.HeaderHovered]          = ImVec4(0.26, 0.98, 0.85, 0.80)
    colors[clr.HeaderActive]           = ImVec4(0.26, 0.98, 0.85, 1.00)
    colors[clr.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.10, 0.75, 0.63, 0.78)
    colors[clr.SeparatorActive]        = ImVec4(0.10, 0.75, 0.63, 1.00)
    colors[clr.ResizeGrip]             = ImVec4(0.26, 0.98, 0.85, 0.25)
    colors[clr.ResizeGripHovered]      = ImVec4(0.26, 0.98, 0.85, 0.67)
    colors[clr.ResizeGripActive]       = ImVec4(0.26, 0.98, 0.85, 0.95)
    colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.81, 0.35, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.98, 0.85, 0.35)
    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 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]                = colors[clr.PopupBg]
    colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
    colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 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.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
end

function theme4() -- тёмно-салатовый стиль
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 2.0
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0

    colors[clr.FrameBg]                = ImVec4(0.42, 0.48, 0.16, 0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.85, 0.98, 0.26, 0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.85, 0.98, 0.26, 0.67)
    colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.42, 0.48, 0.16, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.CheckMark]              = ImVec4(0.85, 0.98, 0.26, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.77, 0.88, 0.24, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.85, 0.98, 0.26, 1.00)
    colors[clr.Button]                 = ImVec4(0.85, 0.98, 0.26, 0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.85, 0.98, 0.26, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.82, 0.98, 0.06, 1.00)
    colors[clr.Header]                 = ImVec4(0.85, 0.98, 0.26, 0.31)
    colors[clr.HeaderHovered]          = ImVec4(0.85, 0.98, 0.26, 0.80)
    colors[clr.HeaderActive]           = ImVec4(0.85, 0.98, 0.26, 1.00)
    colors[clr.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.63, 0.75, 0.10, 0.78)
    colors[clr.SeparatorActive]        = ImVec4(0.63, 0.75, 0.10, 1.00)
    colors[clr.ResizeGrip]             = ImVec4(0.85, 0.98, 0.26, 0.25)
    colors[clr.ResizeGripHovered]      = ImVec4(0.85, 0.98, 0.26, 0.67)
    colors[clr.ResizeGripActive]       = ImVec4(0.85, 0.98, 0.26, 0.95)
    colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.81, 0.35, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.85, 0.98, 0.26, 0.35)
    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 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]                = colors[clr.PopupBg]
    colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
    colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 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.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
end

function theme5() -- фиолетовый стиль
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    style.WindowRounding = 2
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 3
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0
    style.WindowPadding = imgui.ImVec2(4.0, 4.0)
    style.FramePadding = imgui.ImVec2(3.5, 3.5)
    style.ButtonTextAlign = imgui.ImVec2(0.0, 0.5)
    colors[clr.WindowBg]              = ImVec4(0.14, 0.12, 0.16, 1.00);
    colors[clr.ChildWindowBg]         = ImVec4(0.30, 0.20, 0.39, 0.00);
    colors[clr.PopupBg]               = ImVec4(0.05, 0.05, 0.10, 0.90);
    colors[clr.Border]                = ImVec4(0.89, 0.85, 0.92, 0.30);
    colors[clr.BorderShadow]          = ImVec4(0.00, 0.00, 0.00, 0.00);
    colors[clr.FrameBg]               = ImVec4(0.30, 0.20, 0.39, 1.00);
    colors[clr.FrameBgHovered]        = ImVec4(0.41, 0.19, 0.63, 0.68);
    colors[clr.FrameBgActive]         = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.TitleBg]               = ImVec4(0.41, 0.19, 0.63, 0.45);
    colors[clr.TitleBgCollapsed]      = ImVec4(0.41, 0.19, 0.63, 0.35);
    colors[clr.TitleBgActive]         = ImVec4(0.41, 0.19, 0.63, 0.78);
    colors[clr.MenuBarBg]             = ImVec4(0.30, 0.20, 0.39, 0.57);
    colors[clr.ScrollbarBg]           = ImVec4(0.30, 0.20, 0.39, 1.00);
    colors[clr.ScrollbarGrab]         = ImVec4(0.41, 0.19, 0.63, 0.31);
    colors[clr.ScrollbarGrabHovered]  = ImVec4(0.41, 0.19, 0.63, 0.78);
    colors[clr.ScrollbarGrabActive]   = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.ComboBg]               = ImVec4(0.30, 0.20, 0.39, 1.00);
    colors[clr.CheckMark]             = ImVec4(0.56, 0.61, 1.00, 1.00);
    colors[clr.SliderGrab]            = ImVec4(0.41, 0.19, 0.63, 0.24);
    colors[clr.SliderGrabActive]      = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.Button]                = ImVec4(0.41, 0.19, 0.63, 0.44);
    colors[clr.ButtonHovered]         = ImVec4(0.41, 0.19, 0.63, 0.86);
    colors[clr.ButtonActive]          = ImVec4(0.64, 0.33, 0.94, 1.00);
    colors[clr.Header]                = ImVec4(0.41, 0.19, 0.63, 0.76);
    colors[clr.HeaderHovered]         = ImVec4(0.41, 0.19, 0.63, 0.86);
    colors[clr.HeaderActive]          = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.ResizeGrip]            = ImVec4(0.41, 0.19, 0.63, 0.20);
    colors[clr.ResizeGripHovered]     = ImVec4(0.41, 0.19, 0.63, 0.78);
    colors[clr.ResizeGripActive]      = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.CloseButton]           = ImVec4(1.00, 1.00, 1.00, 0.75);
    colors[clr.CloseButtonHovered]    = ImVec4(0.88, 0.74, 1.00, 0.59);
    colors[clr.CloseButtonActive]     = ImVec4(0.88, 0.85, 0.92, 1.00);
    colors[clr.PlotLines]             = ImVec4(0.89, 0.85, 0.92, 0.63);
    colors[clr.PlotLinesHovered]      = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.PlotHistogram]         = ImVec4(0.89, 0.85, 0.92, 0.63);
    colors[clr.PlotHistogramHovered]  = ImVec4(0.41, 0.19, 0.63, 1.00);
    colors[clr.TextSelectedBg]        = ImVec4(0.41, 0.19, 0.63, 0.43);
    colors[clr.ModalWindowDarkening]  = ImVec4(0.20, 0.20, 0.20, 0.35);
end
 
Последнее редактирование:

A S K I T

Активный
200
69
Эту функцию не нужно полностью вставлять в main(). Её вставь в тело скрипта, т.е. в пустое место, а в main() вставь swith_theme()
Lua:
function swith_theme()
    lua_thread.create(function()
        while true do wait(0)
            if cfg.settings.theme.v == 0 then
                applyBlueTheme()
            elseif cfg.settings.theme.v == 1 then
                applyRedTheme()
            end
        end
    end)
end

у меня больше стилей, а не красный и синий, как добавить остальные?
Просто копируй кнопки и изменяй названия тем на свои.
Потом делай проверки функцией выше, добавляя новые темы с помощью проверки "elseif cfg.settings.theme.v == [номер_темы] then".

[22:34:46.761540] (error) testnovoe.lua: D:\Сборки\GTA SA by gashcontrol\moonloader\testnovoe.lua:130: unexpected symbol near ')'
[22:34:46.761540] (error) testnovoe.lua: Script died due to an error. (230986BC)
У тебя if не закрыто. Добавь "end" перед "end)"