local menu = ui.create("Main")
local switch = menu:switch("1")
local base64 = require("neverlose/base64")
local clipboard = require("neverlose/clipboard")
sidebar_selection = ui.get_style("Switch Active")
sidebar_color = sidebar_selection:to_hex()
copy = ui.get_icon("copy")
paste = ui.get_icon("paste")
globe = ui.get_icon("globe")
local andr = {}
local andr = {
functions = {},
globals = {},
}
configs_list = menu:list("Currently loaded:")
andr.functions.get_config_from_elements = {
----------------------------
switch,
}
configname = menu:input("Name","Write cfg name here!")
function get_neverlose_path()
return common.get_game_directory():sub(1, -5) .. "nl\\"
end
files.create_folder("nl\\MyConfigsTest")
files.default_path = get_neverlose_path().."MyConfigsTest\\"
files.configs_path = files.default_path.. "\\presets.json"
presets = {
names = {},
values = {}
}
local configs = {main = {names = presets.names, values = presets.values}}
on_load = function()
if files.read(files.configs_path) == nil then
files.write(files.configs_path, json.stringify(configs.main))
end
end
on_load()
parse = function()
local list = json.parse(files.read(files.configs_path))
local addition_item = configname:get();
presets.names = list.names
presets.values = list.values
if presets.names == addition_item then
return
print_raw("sdfgnikhsdbfg")
elseif #presets.names ~= 0 then
configs_list:update(presets.names)
end
end
parse()
config_update = function()
configs.main.names = presets.names;
configs.main.values = presets.values;
files.write(files.configs_path, (json.stringify(configs.main)))
end
config_update()
create = function()
local config = configs_list:get()
local cur_list = configs_list:list();
local addition_item = configname:get();
andr.config = {}
for i = 1, #andr.config do
print(andr.config[i])
andr.config[i] = nil
end
for i = 1, #andr.functions.get_config_from_elements do
andr.config[i] = andr.functions.get_config_from_elements[i]:get()
end
cur_list[#cur_list+1] = addition_item;
local json_config = json.stringify(andr.config)
local encoded_config = base64.encode(json_config)
parse()
table.insert(presets.names, addition_item)
table.insert(presets.values, encoded_config)
config_update()
configs_list:update(cur_list);
end
savebutton = menu:button("\a".. sidebar_color ..""..ui.get_icon("plus") .."\aFFFFFFFF Create", create, true)
save = function()
local config = configs_list:get()
local cur_list = configs_list:list();
local addition_item = configname:get();
local deletion_item = configs_list:get();
andr.config = {}
for i = 1, #andr.config do
print(andr.config[i])
andr.config[i] = nil
end
for i = 1, #andr.functions.get_config_from_elements do
andr.config[i] = andr.functions.get_config_from_elements[i]:get()
end
local json_config = json.stringify(andr.config)
local encoded_config = base64.encode(json_config)
config = encoded_config
addition_item = encoded_config
local to_parse = json.parse(files.read(files.configs_path))
parse()
table.remove(presets.values, deletion_item)
table.insert(presets.values, config)
config_update()
end
savebutton = menu:button("\a".. sidebar_color ..""..ui.get_icon("floppy-disk") .."\aFFFFFFFF Save", save, true)
load = function()
local config = configs_list:get()
local config_writed = files.read(files.configs_path)
-- presets.values
local to_parse = json.parse(files.read(files.configs_path))
for _, value in ipairs(to_parse.values) do
local jsob
end
andr.globals.status, andr.globals.config = pcall(function() return json.parse(base64.decode(jsob)) end)
if not andr.globals.status then return end
if not andr.globals.config then
utils.console_exec(string.format("playvol buttons/bell1.wav 1"))
print("Failed to import default config")
return end
for i = 1, #andr.globals.config do
andr.functions.get_config_from_elements[i]:set(andr.globals.config[i])
end
end
loadbutton = menu:button("\a".. sidebar_color ..""..ui.get_icon("check") .."\aFFFFFFFF Load", load, true)
local function delete_function()
local cur_list = configs_list:list();
local deletion_item = configs_list:get();
parse()
table.remove(cur_list, deletion_item);
table.remove(presets.names, deletion_item);
table.remove(presets.values);
config_update()
configs_list:update(cur_list);
end
deletebutton = menu:button("\a".. sidebar_color ..""..ui.get_icon("trash") .."\aFFFFFFFF Delete", delete_function, true)