File size: 2,189 Bytes
b6a38d7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
DefineClass.DeveloperOptions = {
__parents = { "PropertyObject" },
option_name = "",
}
function DeveloperOptions:GetProperty(property)
local meta = table.find_value(self.properties, "id", property)
if meta and not prop_eval(meta.dont_save, self, meta) then
return GetDeveloperOption(property, self.class, self.option_name, meta.default)
end
return PropertyObject.GetProperty(self, property)
end
function DeveloperOptions:SetProperty(property, value)
local meta = table.find_value(self.properties, "id", property)
if meta and not prop_eval(meta.dont_save, self, meta) then
return SetDeveloperOption(property, value, self.class, self.option_name)
end
return PropertyObject.SetProperty(self, property, value)
end
function GetDeveloperOption(option, storage, substorage, default)
storage = storage or "Developer"
substorage = substorage or "General"
local ds = LocalStorage and LocalStorage[storage]
return ds and ds[substorage] and ds[substorage][option] or default or false
end
function SetDeveloperOption(option, value, storage, substorage)
if not LocalStorage then
print("no local storage available!")
return
end
storage = storage or "Developer"
substorage = substorage or "General"
value = value or nil
local infos = LocalStorage[storage] or {}
local info = infos[substorage] or {}
info[option] = value
infos[substorage] = info
LocalStorage[storage] = infos
Msg("DeveloperOptionsChanged", storage, substorage, option, value)
DelayedCall(0, SaveLocalStorage)
end
function GetDeveloperHistory(class, name)
if not LocalStorage then
return {}
end
local history = LocalStorage.History or {}
LocalStorage.History = history
history[class] = history[class] or {}
local list = history[class][name] or {}
history[class][name] = list
return list
end
function AddDeveloperHistory(class, name, entry, max_size, accept_empty)
max_size = max_size or 20
if not LocalStorage or not accept_empty and (entry or "") == "" then
return
end
local history = GetDeveloperHistory(class, name)
table.remove_entry(history, entry)
table.insert(history, 1, entry)
while #history > max_size do
table.remove(history)
end
SaveLocalStorageDelayed()
end |