local inicfg = require 'inicfg'
local directIni = ''
local ini = inicfg.load(inicfg.load({
main = {
color = 0xFFff004d,
},
}, directIni))
inicfg.save(ini, directIni)
function join_argb(a, r, g, b)
local argb = b -- b
argb = bit.bor(argb, bit.lshift(g, 8)) -- g
argb = bit.bor(argb, bit.lshift(r, 16)) -- r
argb = bit.bor(argb, bit.lshift(a, 24)) -- a
return argb
end
function explode_argb(argb)
local a = bit.band(bit.rshift(argb, 24), 0xFF)
local r = bit.band(bit.rshift(argb, 16), 0xFF)
local g = bit.band(bit.rshift(argb, 8), 0xFF)
local b = bit.band(argb, 0xFF)
return a, r, g, b
end
local color_HEX = explode_argb(ini.main.color)
local color_argb = imgui.ImFloat4(color_HEX[2], color_HEX[3], color_HEX[4], color_HEX[1])
--save
ini.main.color = join_argb(color_argb.v[4] * 255, color_argb.v[1] * 255, color_argb.v[2] * 255, color_argb.v[3] * 255)
inicfg.save(ini, directIni)