local ui, Clipboard, ffi_handler = {}, {}, {}
ffi.cdef[[
typedef int(__thiscall* get_clipboard_text_length)(void*);
typedef void(__thiscall* set_clipboard_text)(void*, const char*, int);
typedef void(__thiscall* get_clipboard_text)(void*, int, const char*, int);
]]
ffi_handler.VGUI_System = ffi.cast(ffi.typeof("void***"), Utils.CreateInterface("vgui2.dll", "VGUI_System010"))
ffi_handler.get_clipboard_text_length = ffi.cast("get_clipboard_text_length", ffi_handler.VGUI_System[0][7])
ffi_handler.get_clipboard_text = ffi.cast("get_clipboard_text", ffi_handler.VGUI_System[0][11])
ffi_handler.set_clipboard_text = ffi.cast("set_clipboard_text", ffi_handler.VGUI_System[0][9])
function Clipboard.Get()
local clipboard_text_length = ffi_handler.get_clipboard_text_length(ffi_handler.VGUI_System)
if (clipboard_text_length > 0) then
local buffer = ffi.new("char[?]", clipboard_text_length)
ffi_handler.get_clipboard_text(ffi_handler.VGUI_System, 0, buffer, clipboard_text_length * ffi.sizeof("char[?]", clipboard_text_length))
return ffi.string(buffer, clipboard_text_length - 1)
end
return ""
end
function Clipboard.Set(text)
ffi_handler.set_clipboard_text(ffi_handler.VGUI_System, text, #text)
end
local JSON = Panorama.LoadString([[
return {
stringify: JSON.stringify,
parse: JSON.parse
};
]])()
ui.my_switch = Menu.Switch("NL", "my switch", false)
ui.my_color_switch = Menu.SwitchColor("NL", "my color switch", false, Color.new(1, 1, 1))
ui.my_color_edit = Menu.ColorEdit("NL", "my color edit", Color.new(1, 1, 1))
ui.my_sliderint = Menu.SliderInt("NL", "my sliderint", 0, -180, 180)
ui.my_sliderfloat = Menu.SliderFloat("NL", "my slider float", 60, 0, 60)
ui.my_combo = Menu.Combo("NL", "my combo", {"W", "A", "S", "D"}, 0)
ui.my_multicombo = Menu.MultiCombo("NL", "my multicombo", {"W", "A", "S", "D"}, 0)
ui.my_textbox = Menu.TextBox("NL", "my textbox", 64, "My text...")
local cfg_data = {
bools = {
ui.my_switch,
ui.my_color_switch
},
ints = {
ui.my_sliderint,
ui.my_combo,
ui.my_multicombo
},
floats = {
ui.my_sliderfloat
},
strings = {
ui.my_textbox
},
colors = {
ui.my_color_switch,
ui.my_color_edit
}
}
Menu.Button("Config System", "Export Config", "", function()
local Code = {{}, {}, {}, {}, {}}
for _, bools in pairs(cfg_data.bools) do
table.insert(Code[1], bools:GetBool())
end
for _, ints in pairs(cfg_data.ints) do
table.insert(Code[2], ints:GetInt())
end
for _, floats in pairs(cfg_data.floats) do
table.insert(Code[3], floats:GetFloat())
end
for _, strings in pairs(cfg_data.strings) do
table.insert(Code[4], strings:GetString())
end
for _, colors in pairs(cfg_data.colors) do
local clr = colors:GetColor()
table.insert(Code[5], string.format("%02X%02X%02X%02X", math.floor(clr.r * 255), math.floor(clr.g * 255), math.floor(clr.b * 255), math.floor(clr.a * 255)))
end
Clipboard.Set(JSON.stringify(Code))
end)
Menu.Button("Config System", "Import Config", "", function()
for k, v in pairs(JSON.parse(Clipboard.Get())) do
k = ({[1] = "bools", [2] = "ints", [3] = "floats", [4] = "strings", [5] = "colors"})[k]
for k2, v2 in pairs(v) do
if (k == "bools") then
cfg_data[k][k2]:SetBool(v2)
end
if (k == "ints") then
cfg_data[k][k2]:SetInt(v2)
end
if (k == "floats") then
cfg_data[k][k2]:SetFloat(v2)
end
if (k == "strings") then
cfg_data[k][k2]:SetString(v2)
end
if (k == "colors") then
cfg_data[k][k2]:SetColor(Color.new(tonumber("0x"..v2:sub(1, 2))/255, tonumber("0x"..v2:sub(3, 4))/255, tonumber("0x"..v2:sub(5, 6))/255, tonumber("0x"..v2:sub(7, 8))/255))
end
end
end
end)