Skip to content

Commit

Permalink
Add deprecation warning to bundled Nexus VR Core version.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNexusAvenger committed Nov 23, 2024
1 parent 302d287 commit 27a19c9
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 26 deletions.
8 changes: 8 additions & 0 deletions src/NexusVRCharacterModelClientLoader.client.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
38 changes: 24 additions & 14 deletions src/UI/MainMenu.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 2 additions & 6 deletions src/UI/R6Message.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/UI/View/SettingsView.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 11 additions & 5 deletions src/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -60,23 +62,27 @@ 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
end

--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.
Expand Down

0 comments on commit 27a19c9

Please sign in to comment.