Skip to content

Commit

Permalink
this update sucks but I did it omg!! (a programmers worst nightmare)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cosmental committed Oct 9, 2023
1 parent 66e47e6 commit e8da039
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ function DataService:Initialize(Setup : table)
else
local IsMatch : boolean = (tbl[Key] == tbl2[Key]);
if (IsMatch) then continue; end
if (Key == "ControlPanelEnabled") then continue; end
if (Key == "ModernTopbarPlusEnabled") then continue; end

table.insert(Changes, {
["Path"] = path,
Expand Down
80 changes: 52 additions & 28 deletions src/MainModule/SocialChat/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

--// Services
local CollectionService = game:GetService("CollectionService");
local ContentProvider = game:GetService("ContentProvider")
local IsServer = game:GetService("RunService"):IsServer();

--// Imports
Expand All @@ -40,27 +41,6 @@ function GetSocialChat()
local Server = ((IsServer) and (require(Environments.Server)));
local Client = ((not IsServer) and (require(Environments.Client)));

--// Module Collection
local Library = {};

local function AddToLibrary(Container : Folder) : table
for _, Module in pairs(Container:GetDescendants()) do
if (not Module:IsA("ModuleScript")) then continue; end
if (Module.Parent:IsA("ModuleScript")) then continue; end

local Success, Response = pcall(function()
return require(Module);
end);

if (Success) then
Library[Module.Name] = Response
end
end
end

AddToLibrary((IsServer and Resources.Server) or Resources.Client);
AddToLibrary(Resources.Shared);

--// Configurations
local Configurations = {};

Expand Down Expand Up @@ -92,15 +72,61 @@ function GetSocialChat()
AddToConfiguration(game.ReplicatedStorage:WaitForChild("ChatSettings"):WaitForChild("Client"), "Client");
else
AddToConfiguration(game.ReplicatedStorage:WaitForChild("ChatSettings"):WaitForChild("Client"));
end

AddToConfiguration(game.ReplicatedStorage.ChatSettings:WaitForChild("Shared"));

--// Module Collection
local Library = {};

local function AddToLibrary(Container : Folder) : table
for _, Module in pairs(Container:GetDescendants()) do
if (not Module:IsA("ModuleScript")) then continue; end
if (Module.Parent:IsA("ModuleScript")) then continue; end

--[[
TopbarPlus UI Config Controller
>> Yes this is very inefficient but its the only method I could think of for this scenario
]]--

local DoesUseModernTBP : boolean? = Configurations.Channels.ModernTopbarPlusEnabled

if (not DoesUseModernTBP and Module.Name == "ModernTBP") then
Module.Parent.LegacyTBP.Name = "TopbarPlus"

if (Library.LegacyTBP) then
Library.TopbarPlus = Library.LegacyTBP
Library.LegacyTBP = nil
end

continue;
elseif (DoesUseModernTBP and Module.Name == "LegacyTBP") then
Module.Parent.ModernTBP.Name = "TopbarPlus"

if (Library.ModernTBP) then
Library.TopbarPlus = Library.ModernTBP
Library.ModernTBP = nil
end

continue;
end

--// TopbarPlus Configuration
local DoesUseModernTBP : boolean? = Configurations.Channels.ModernTopbarPlusEnabled
--// Requiring Protocol
local Success, Response = pcall(function()
return require(Module);
end);

if (not DoesUseModernTBP) then
Library.TopbarPlus = Library.LegacyTBP
Library.LegacyTBP = nil
if (Success) then
Library[Module.Name] = Response
end
end
end

AddToLibrary((IsServer and Resources.Server) or Resources.Client);
AddToLibrary(Resources.Shared);

--// TopbarPlus Configuration
if (not IsServer) then
if (Library.TopbarPlus) then
local VoiceChatConfiguration : BoolValue? = game.ReplicatedStorage.ChatSettings.Client:WaitForChild("IsVoiceChatEnabled", 3);
local VoiceChatEnabled = ((VoiceChatConfiguration and VoiceChatConfiguration.Value) or true); -- true by default
Expand All @@ -111,8 +137,6 @@ function GetSocialChat()
end
end

AddToConfiguration(game.ReplicatedStorage.ChatSettings:WaitForChild("Shared"));

--// Initialization
if (IsServer) then
local Remotes = script.Remotes
Expand Down

0 comments on commit e8da039

Please sign in to comment.