local inicfg = require 'inicfg'
local imgui = require 'mimgui'
local new = imgui.new
ini = inicfg.load({
["hp"] = {
["color"] = 0xFFFF0000
}
}, "tested_ini")
imgui.OnInitialize(function()
imgui.GetIO().IniFilename = nil
local tmp = imgui.ColorConvertU32ToFloat4(ini.hp.color)
color = new.float[4](tmp.x, tmp.y, tmp.z, tmp.w)
end)
imgui.OnFrame(function() return true end, function()
imgui.Begin("test")
if imgui.ColorEdit4("HP Color", color) then
ini.hp.color = imgui.ColorConvertFloat4ToU32(
imgui.ImVec4( color[0], color[1], color[2], color[3] )
)
end
imgui.End()
end)
function main()
local font = renderCreateFont("Tahoma", 14, 0x5)
while true do wait(0)
renderFontDrawText(font, "Проверочный текст", 10, 450, argb2abgr(ini.hp.color))
end
end
function onScriptTerminate(sc, quitGame)
if sc == thisScript() then
inicfg.save({
["hp"] = {
["color"] = ini.hp.color
}
}, "tested_ini")
end
end
function argb2abgr(argb)
local abgr = bit.bor(
bit.lshift(bit.band(bit.rshift(argb, 24), 0xFF), 24),
bit.lshift(bit.band(argb, 0xFF), 16),
bit.lshift(bit.band(bit.rshift(argb, 8), 0xFF), 8),
bit.band(bit.rshift(argb, 16), 0xFF)
)
return abgr
end