Hades126

ROBLOX2

Dec 8th, 2024
1,057
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. local httpService = game:GetService("HttpService")
  2.  
  3. local InterfaceManager = {} do
  4. InterfaceManager.Folder = "FluentSettings"
  5. InterfaceManager.Settings = {
  6. Theme = "Dark",
  7. Acrylic = true,
  8. Transparency = true,
  9. MenuKeybind = "LeftControl"
  10. }
  11.  
  12. function InterfaceManager:SetFolder(folder)
  13. self.Folder = folder;
  14. self:BuildFolderTree()
  15. end
  16.  
  17. function InterfaceManager:SetLibrary(library)
  18. self.Library = library
  19. end
  20.  
  21. function InterfaceManager:BuildFolderTree()
  22. local paths = {}
  23.  
  24. local parts = self.Folder:split("/")
  25. for idx = 1, #parts do
  26. paths[#paths + 1] = table.concat(parts, "/", 1, idx)
  27. end
  28.  
  29. table.insert(paths, self.Folder)
  30. table.insert(paths, self.Folder .. "/settings")
  31.  
  32. for i = 1, #paths do
  33. local str = paths[i]
  34. if not isfolder(str) then
  35. makefolder(str)
  36. end
  37. end
  38. end
  39.  
  40. function InterfaceManager:SaveSettings()
  41. writefile(self.Folder .. "/options.json", httpService:JSONEncode(InterfaceManager.Settings))
  42. end
  43.  
  44. function InterfaceManager:LoadSettings()
  45. local path = self.Folder .. "/options.json"
  46. if isfile(path) then
  47. local data = readfile(path)
  48. local success, decoded = pcall(httpService.JSONDecode, httpService, data)
  49.  
  50. if success then
  51. for i, v in next, decoded do
  52. InterfaceManager.Settings[i] = v
  53. end
  54. end
  55. end
  56. end
  57.  
  58. function InterfaceManager:BuildInterfaceSection(tab)
  59. assert(self.Library, "Must set InterfaceManager.Library")
  60. local Library = self.Library
  61. local Settings = InterfaceManager.Settings
  62.  
  63. InterfaceManager:LoadSettings()
  64.  
  65. local section = tab:AddSection("Interface")
  66.  
  67. local InterfaceTheme = section:AddDropdown("InterfaceTheme", {
  68. Title = "Theme",
  69. Description = "Changes the interface theme.",
  70. Values = Library.Themes,
  71. Default = Settings.Theme,
  72. Callback = function(Value)
  73. Library:SetTheme(Value)
  74. Settings.Theme = Value
  75. InterfaceManager:SaveSettings()
  76. end
  77. })
  78.  
  79. InterfaceTheme:SetValue(Settings.Theme)
  80.  
  81. if Library.UseAcrylic then
  82. section:AddToggle("AcrylicToggle", {
  83. Title = "Acrylic",
  84. Description = "The blurred background requires graphic quality 8+",
  85. Default = Settings.Acrylic,
  86. Callback = function(Value)
  87. Library:ToggleAcrylic(Value)
  88. Settings.Acrylic = Value
  89. InterfaceManager:SaveSettings()
  90. end
  91. })
  92. end
  93.  
  94. section:AddToggle("TransparentToggle", {
  95. Title = "Transparency",
  96. Description = "Makes the interface transparent.",
  97. Default = Settings.Transparency,
  98. Callback = function(Value)
  99. Library:ToggleTransparency(Value)
  100. Settings.Transparency = Value
  101. InterfaceManager:SaveSettings()
  102. end
  103. })
  104.  
  105. local MenuKeybind = section:AddKeybind("MenuKeybind", { Title = "Minimize Bind", Default = Settings.MenuKeybind })
  106. MenuKeybind:OnChanged(function()
  107. Settings.MenuKeybind = MenuKeybind.Value
  108. InterfaceManager:SaveSettings()
  109. end)
  110. Library.MinimizeKeybind = MenuKeybind
  111. end
  112. end
  113.  
  114. return InterfaceManager
Add Comment
Please, Sign In to add comment