diff --git a/src/NexusVRCharacterModelClientLoader.client.luau b/src/NexusVRCharacterModelClientLoader.client.luau index 910aa5e..9e1bc99 100644 --- a/src/NexusVRCharacterModelClientLoader.client.luau +++ b/src/NexusVRCharacterModelClientLoader.client.luau @@ -21,6 +21,14 @@ local ReplicationReady = NexusVRCharacterModel:WaitForChild("ReplicationReady") +--Add the deprecation warning to the bundled Nexus VR Core. +local BaseScreenGui = require(ReplicatedStorage:WaitForChild("NexusVRCore"):WaitForChild("Container"):WaitForChild("BaseScreenGui")) :: any +local OriginalBaseScreenGuiConstructor = BaseScreenGui.__new +BaseScreenGui.__new = function(...) + warn("Using the bundled (automically loaded) Nexus VR Core with Nexus VR Character Model is deprecated.\nIt is recommended to move to a fixed version, which can be downloaded from GitHub.") + return OriginalBaseScreenGuiConstructor(...) +end + --Load the settings. Settings:SetDefaults(HttpService:JSONDecode((NexusVRCharacterModel:WaitForChild("Configuration") :: StringValue).Value)) diff --git a/src/UI/MainMenu.luau b/src/UI/MainMenu.luau index 7e0f493..ccdec84 100644 --- a/src/UI/MainMenu.luau +++ b/src/UI/MainMenu.luau @@ -8,37 +8,47 @@ local MENU_OPEN_TIME = 0.25 local Workspace = game:GetService("Workspace") local Players = game:GetService("Players") -local ReplicatedStorage = game:GetService("ReplicatedStorage") local GuiService = game:GetService("GuiService") local RunService = game:GetService("RunService") local TweenService = game:GetService("TweenService") local NexusVRCharacterModel = script.Parent.Parent +local ScreenGui3D = require(NexusVRCharacterModel:WaitForChild("NexusVRCore"):WaitForChild("Container"):WaitForChild("ScreenGui3D")) local Settings = require(NexusVRCharacterModel:WaitForChild("State"):WaitForChild("Settings")).GetInstance() local VRInputService = require(NexusVRCharacterModel:WaitForChild("State"):WaitForChild("VRInputService")).GetInstance() local ApiBaseView = require(NexusVRCharacterModel:WaitForChild("UI"):WaitForChild("View"):WaitForChild("ApiBaseView")) local EnigmaView = require(NexusVRCharacterModel:WaitForChild("UI"):WaitForChild("View"):WaitForChild("EnigmaView")) local SettingsView = require(NexusVRCharacterModel:WaitForChild("UI"):WaitForChild("View"):WaitForChild("SettingsView")) +local NexusButton = require(NexusVRCharacterModel:WaitForChild("NexusButton")) local TextButtonFactory = require(NexusVRCharacterModel:WaitForChild("NexusButton"):WaitForChild("Factory"):WaitForChild("TextButtonFactory")).CreateDefault(Color3.fromRGB(0, 170, 255)) TextButtonFactory:SetDefault("Theme", "RoundedCorners") -local NexusVRCore = require(ReplicatedStorage:WaitForChild("NexusVRCore")) :: any -local ScreenGui = NexusVRCore:GetResource("Container.ScreenGui") local MainMenu = {} MainMenu.__index = MainMenu local StaticInstance = nil +export type MainMenu = { + CurrentView: number, + Views: {any}, + ScreenGui: ScreenGui3D.NexusInstanceScreenGui3D, + ViewAdornFrame: Frame, + LeftButton: NexusButton.NexusButton, + RightButton: NexusButton.NexusButton, + ViewTextLabel: TextLabel, + LeftHandHintVisible: boolean, + RightHandHintVisible: boolean, +} & typeof(setmetatable({}, MainMenu)) + --[[ Creates the main menu. --]] function MainMenu.new(): any - local self = {} - setmetatable(self, MainMenu) + local self = setmetatable({}, MainMenu) :: MainMenu --Set up the ScreenGui. - local MainMenuScreenGui = ScreenGui.new() + local MainMenuScreenGui = ScreenGui3D.new() MainMenuScreenGui.ResetOnSpawn = false MainMenuScreenGui.Enabled = false MainMenuScreenGui.CanvasSize = Vector2.new(500, 605) @@ -98,8 +108,8 @@ function MainMenu.new(): any --Set up the default views. self.CurrentView = 1 self.Views = {} - (SettingsView :: any).new(self:CreateView("Settings")); - (EnigmaView :: any).new(self:CreateView("Enigma"), self); + SettingsView.new(self:CreateView("Settings")); + EnigmaView.new(self:CreateView("Enigma"), self); self:UpdateVisibleView() --Connect changing views. @@ -143,7 +153,7 @@ end --[[ Returns a singleton instance of the character service. --]] -function MainMenu.GetInstance(): any +function MainMenu.GetInstance(): MainMenu if not StaticInstance then StaticInstance = MainMenu.new() end @@ -154,7 +164,7 @@ end Sets up opening based on the controllers being rotated upwards. --]] -function MainMenu:SetUpOpening(): () +function MainMenu.SetUpOpening(self: MainMenu): () --Create the animation parts. local InitialMenuToggleGestureActive = Settings:GetSetting("Menu.MenuToggleGestureActive") if InitialMenuToggleGestureActive == nil then @@ -441,7 +451,7 @@ end --[[ Toggles the menu being open. --]] -function MainMenu:Toggle(Visible: boolean?): () +function MainMenu.Toggle(self: MainMenu, Visible: boolean?): () if self.ScreenGui.Enabled == Visible then return end --Determine the start and end values. @@ -470,7 +480,7 @@ end --[[ Registers a view. --]] -function MainMenu:RegisterView(ViewName: string, ViewInstance: any): () +function MainMenu.RegisterView(self: MainMenu, ViewName: string, ViewInstance: any): () warn("MainMenu::RegisterView is deprecated and may be removed in the future. Use MainMenu::CreateView instead.") --Set up the view instance. @@ -485,7 +495,7 @@ end --[[ Creates a menu view. --]] -function MainMenu:CreateView(InitialViewName: string): any +function MainMenu.CreateView(self: MainMenu, InitialViewName: string): any --Create and store the view. local View = ApiBaseView.new(InitialViewName) View.Frame.Parent = (self :: any).ViewAdornFrame @@ -513,7 +523,7 @@ end --[[ Updates the visible view. --]] -function MainMenu:UpdateVisibleView(NewView: string?): () +function MainMenu.UpdateVisibleView(self: MainMenu, NewView: string?): () --Update the button visibility. self.LeftButton.Visible = (#self.Views > 1) self.RightButton.Visible = (#self.Views > 1) diff --git a/src/UI/R6Message.luau b/src/UI/R6Message.luau index 719c189..32e0560 100644 --- a/src/UI/R6Message.luau +++ b/src/UI/R6Message.luau @@ -3,17 +3,13 @@ local MESSAGE_OPEN_TIME = 0.25 - - -local ReplicatedStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") local RunService = game:GetService("RunService") local NexusVRCharacterModel = script.Parent.Parent +local ScreenGui3D = require(NexusVRCharacterModel:WaitForChild("NexusVRCore"):WaitForChild("Container"):WaitForChild("ScreenGui3D")) local TextButtonFactory = require(NexusVRCharacterModel:WaitForChild("NexusButton"):WaitForChild("Factory"):WaitForChild("TextButtonFactory")).CreateDefault(Color3.fromRGB(0, 170, 255)) TextButtonFactory:SetDefault("Theme", "RoundedCorners") -local NexusVRCore = require(ReplicatedStorage:WaitForChild("NexusVRCore")) :: any -local ScreenGui = NexusVRCore:GetResource("Container.ScreenGui") local R6Message = {} R6Message.__index = R6Message @@ -29,7 +25,7 @@ Creates the R6 message. --]] function R6Message.new(): R6Message --Set up the ScreenGui. - local MessageScreenGui = ScreenGui.new() + local MessageScreenGui = ScreenGui3D.new() MessageScreenGui.ResetOnSpawn = false MessageScreenGui.Enabled = false MessageScreenGui.CanvasSize = Vector2.new(500, 500) diff --git a/src/UI/View/SettingsView.luau b/src/UI/View/SettingsView.luau index 96d250a..0ff26a6 100644 --- a/src/UI/View/SettingsView.luau +++ b/src/UI/View/SettingsView.luau @@ -188,7 +188,7 @@ function SettingsView.PopulateSettingsFrame(self: SettingsView, ContainerFrame: local InitialValueName = GetValueFunction() local CurrentValue = 1 local Options = (GetOptionsSettings :: () -> ({string}))() - for i,Option in pairs(Options) do + for i,Option in Options do if Option == InitialValueName then CurrentValue = i break diff --git a/src/init.luau b/src/init.luau index ecac29f..ce5b607 100644 --- a/src/init.luau +++ b/src/init.luau @@ -22,13 +22,15 @@ local RateLimiter = require(script:WaitForChild("State"):WaitForChild("RateLimit local NexusVRCharacterModel = {} +export type NexusVRCharacterModel = typeof(NexusVRCharacterModel) + --[[ Sets the configuration to use. Intended to be run once by the server. --]] -function NexusVRCharacterModel:SetConfiguration(Configuration: any): () +function NexusVRCharacterModel.SetConfiguration(self: NexusVRCharacterModel, Configuration: any): () --Create the value. local ConfigurationValue = script:FindFirstChild("Configuration") if not ConfigurationValue then @@ -60,7 +62,7 @@ end --[[ Loads Nexus VR Character Model. --]] -function NexusVRCharacterModel:Load(): () +function NexusVRCharacterModel.Load(self: NexusVRCharacterModel): () --Return if a version is already loaded. if ReplicatedStorage:FindFirstChild("NexusVRCharacterModel") then return @@ -68,15 +70,19 @@ function NexusVRCharacterModel:Load(): () --Rename and move the script to ReplicatedStorage. script.Name = "NexusVRCharacterModel" - script:WaitForChild("NexusVRCore").Parent = ReplicatedStorage - script.Parent = ReplicatedStorage; + script.Parent = ReplicatedStorage + + --Copy Nexus VR Core. + if not ReplicatedStorage:FindFirstChild("NexusVRCore") then + script:WaitForChild("NexusVRCore"):Clone().Parent = ReplicatedStorage + end --Output any warnings. (require(ReplicatedStorage:WaitForChild("NexusVRCharacterModel"):WaitForChild("Util"):WaitForChild("Warnings")) :: any)() --Set up the client scripts. local NexusVRCharacterModelClientLoader = script:WaitForChild("NexusVRCharacterModelClientLoader") - for _,Player in pairs(Players:GetPlayers()) do + for _, Player in Players:GetPlayers() do task.spawn(function() --Create and store a ScreenGui with the script. --This prevents the script disappearing on respawn.