imgui color

Radfgh177

Участник
Автор темы
62
1
Версия MoonLoader
.026-beta
Как сделать так чтобы цвет имгуи сохранялся после перезахода?

Lua:
script_name('Imgui Script Themes') -- название скрипта
script_author('FORMYS') -- автор скрипта
script_description('Imgui') -- описание скрипта

require "lib.moonloader" -- подключение библиотеки
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local themes = import "resource/imgui_themes.lua"

main_window_state = imgui.ImBool(false)

-- for RADIO
local checked_radio = imgui.ImInt(1)
--

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand("themes", cmd_themes)

    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)

    imgui.Process = false

    imgui.SwitchContext()
    themes.SwitchColorTheme()

    --sampAddChatMessage("Скрипт imgui перезагружен", -1)


    while true do
        wait(0)

        if isKeyJustPressed(VK_F3) then
            sampAddChatMessage("Вы нажали клавишу {FFFFFF}F3." .. main_color_text .. "Ваш ник: {FFFFFF}" .. nick .. ", " .. main_color_text .. "ваш ID: {FFFFFF}" .. id, main_color)
        end

        if isKeyDown(VK_MENU) and isKeyJustPressed(VK_9) then
            sampAddChatMessage("Вы крут, вы зажали комбинацию клавиш!", main_color)
            wait(500)
            sampAddChatMessage("Прошло пол секунды", main_color)
        end
        -- Блок выполняющийся бесконечно (пока самп активен)

    end
end

function cmd_themes(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
    
    themes.SwitchColorTheme(tonumber(arg))
end

function imgui.OnDrawFrame()

    if not main_window_state.v then
        imgui.Process = false
    end

    if main_window_state.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(510, 600), imgui.Cond.FirstUseEver)

        imgui.Begin('Imgui Themes', main_window_state, imgui.WindowFlags.NoCollapse)

        if imgui.Button(u8'Кнопка') then
            themes.SwitchColorTheme(2)
        end

        imgui.BeginChild("ChildWindow2", imgui.ImVec2(200, 175), true)
            for i, value in ipairs(themes.colorThemes) do
                if imgui.RadioButton(value, checked_radio, i) then
                    themes.SwitchColorTheme(i)
                end
            end
        imgui.EndChild()


        imgui.End()
    end
end

в файле imgui_themes.lua находятся цвета для самого скрипта
 

Вложения

  • imgui_themes.lua
    23.3 KB · Просмотры: 26

Sanchez.

Известный
704
187
Как сделать так чтобы цвет имгуи сохранялся после перезахода?

Lua:
script_name('Imgui Script Themes') -- название скрипта
script_author('FORMYS') -- автор скрипта
script_description('Imgui') -- описание скрипта

require "lib.moonloader" -- подключение библиотеки
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local themes = import "resource/imgui_themes.lua"

main_window_state = imgui.ImBool(false)

-- for RADIO
local checked_radio = imgui.ImInt(1)
--

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand("themes", cmd_themes)

    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)

    imgui.Process = false

    imgui.SwitchContext()
    themes.SwitchColorTheme()

    --sampAddChatMessage("Скрипт imgui перезагружен", -1)


    while true do
        wait(0)

        if isKeyJustPressed(VK_F3) then
            sampAddChatMessage("Вы нажали клавишу {FFFFFF}F3." .. main_color_text .. "Ваш ник: {FFFFFF}" .. nick .. ", " .. main_color_text .. "ваш ID: {FFFFFF}" .. id, main_color)
        end

        if isKeyDown(VK_MENU) and isKeyJustPressed(VK_9) then
            sampAddChatMessage("Вы крут, вы зажали комбинацию клавиш!", main_color)
            wait(500)
            sampAddChatMessage("Прошло пол секунды", main_color)
        end
        -- Блок выполняющийся бесконечно (пока самп активен)

    end
end

function cmd_themes(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
   
    themes.SwitchColorTheme(tonumber(arg))
end

function imgui.OnDrawFrame()

    if not main_window_state.v then
        imgui.Process = false
    end

    if main_window_state.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(510, 600), imgui.Cond.FirstUseEver)

        imgui.Begin('Imgui Themes', main_window_state, imgui.WindowFlags.NoCollapse)

        if imgui.Button(u8'Кнопка') then
            themes.SwitchColorTheme(2)
        end

        imgui.BeginChild("ChildWindow2", imgui.ImVec2(200, 175), true)
            for i, value in ipairs(themes.colorThemes) do
                if imgui.RadioButton(value, checked_radio, i) then
                    themes.SwitchColorTheme(i)
                end
            end
        imgui.EndChild()


        imgui.End()
    end
end

в файле imgui_themes.lua находятся цвета для самого скрипта
Сделать конфиг