Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local httpService = game:GetService("HttpService");
- local InterfaceManager = {};
- do
- InterfaceManager.Folder = "FluentSettings";
- InterfaceManager.Settings = {Theme="Dark",Acrylic=true,Transparency=true,MenuKeybind="LeftControl"};
- InterfaceManager.SetFolder = function(self, folder)
- self.Folder = folder;
- self:BuildFolderTree();
- end;
- InterfaceManager.SetLibrary = function(self, library)
- self.Library = library;
- end;
- InterfaceManager.BuildFolderTree = function(self)
- local paths = {};
- local parts = self.Folder:split("/");
- for idx = 1, #parts do
- paths[#paths + 1] = table.concat(parts, "/", 1, idx);
- end
- table.insert(paths, self.Folder);
- table.insert(paths, self.Folder .. "/settings");
- for i = 1, #paths do
- local str = paths[i];
- if not isfolder(str) then
- makefolder(str);
- end
- end
- end;
- InterfaceManager.SaveSettings = function(self)
- writefile(self.Folder .. "/options.json", httpService:JSONEncode(InterfaceManager.Settings));
- end;
- InterfaceManager.LoadSettings = function(self)
- local path = self.Folder .. "/options.json";
- if isfile(path) then
- local data = readfile(path);
- local success, decoded = pcall(httpService.JSONDecode, httpService, data);
- if success then
- for i, v in next, decoded do
- InterfaceManager.Settings[i] = v;
- end
- end
- end
- end;
- InterfaceManager.BuildInterfaceSection = function(self, tab)
- assert(self.Library, "Must set InterfaceManager.Library");
- local Library = self.Library;
- local Settings = InterfaceManager.Settings;
- InterfaceManager:LoadSettings();
- local section = tab:AddSection("介面管理");
- local InterfaceTheme = section:AddDropdown("InterfaceTheme", {Title="更改介面主題(顏色)",Values=Library.Themes,Default=Settings.Theme,Callback=function(Value)
- Library:SetTheme(Value);
- Settings.Theme = Value;
- InterfaceManager:SaveSettings();
- end});
- InterfaceTheme:SetValue(Settings.Theme);
- if Library.UseAcrylic then
- section:AddToggle("AcrylicToggle", {Title="UI背景模糊(使介面背景無特效)",Default=Settings.Acrylic,Callback=function(Value)
- Library:ToggleAcrylic(Value);
- Settings.Acrylic = Value;
- InterfaceManager:SaveSettings();
- end});
- end
- section:AddToggle("TransparentToggle", {Title="UI透明度(使介面透明)",Default=Settings.Transparency,Callback=function(Value)
- Library:ToggleTransparency(Value);
- Settings.Transparency = Value;
- InterfaceManager:SaveSettings();
- end});
- local MenuKeybind = section:AddKeybind("MenuKeybind", {Title="介面快捷鍵綁定",Default=Settings.MenuKeybind});
- MenuKeybind:OnChanged(function()
- Settings.MenuKeybind = MenuKeybind.Value;
- InterfaceManager:SaveSettings();
- end);
- Library.MinimizeKeybind = MenuKeybind;
- end;
- end
- return InterfaceManager;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement