forked from aya/aya
Initial commit
This commit is contained in:
1566
client/common/content/scripts/Modules/BackpackScript.lua
Normal file
1566
client/common/content/scripts/Modules/BackpackScript.lua
Normal file
File diff suppressed because it is too large
Load Diff
2665
client/common/content/scripts/Modules/Chat.lua
Normal file
2665
client/common/content/scripts/Modules/Chat.lua
Normal file
File diff suppressed because it is too large
Load Diff
2973
client/common/content/scripts/Modules/DeveloperConsoleModule.lua
Normal file
2973
client/common/content/scripts/Modules/DeveloperConsoleModule.lua
Normal file
File diff suppressed because it is too large
Load Diff
765
client/common/content/scripts/Modules/GameSettings.lua
Normal file
765
client/common/content/scripts/Modules/GameSettings.lua
Normal file
@@ -0,0 +1,765 @@
|
||||
--[[
|
||||
Filename: GameSettings.lua
|
||||
Written by: jeditkacheff
|
||||
Version 1.0
|
||||
Description: Takes care of the Game Settings Tab in Settings Menu
|
||||
--]]
|
||||
|
||||
-------------- SERVICES --------------
|
||||
local CoreGui = game:GetService("CoreGui")
|
||||
local RobloxGui = CoreGui:WaitForChild("RobloxGui")
|
||||
local GuiService = game:GetService("GuiService")
|
||||
local UserInputService = game:GetService("UserInputService")
|
||||
local PlatformService = nil
|
||||
pcall(function() PlatformService = game:GetService("PlatformService") end)
|
||||
local ContextActionService = game:GetService("ContextActionService")
|
||||
local Settings = UserSettings()
|
||||
local GameSettings = Settings.GameSettings
|
||||
local StarterPlayer = game:GetService("StarterPlayer")
|
||||
-- from loadingscript.lua
|
||||
local PLACEID = game.PlaceId
|
||||
|
||||
function GetGameName()
|
||||
if GameAssetInfo ~= nil then
|
||||
if IsConvertMyPlaceNameInXboxAppEnabled() then
|
||||
return GetFilteredGameName(GameAssetInfo.Name, self:GetCreatorName())
|
||||
else
|
||||
return GameAssetInfo.Name
|
||||
end
|
||||
else
|
||||
return ''
|
||||
end
|
||||
end
|
||||
|
||||
function GetCreatorName()
|
||||
if GameAssetInfo ~= nil then
|
||||
return GameAssetInfo.Creator.Name
|
||||
else
|
||||
return ''
|
||||
end
|
||||
end
|
||||
|
||||
-------------- CONSTANTS --------------
|
||||
local GRAPHICS_QUALITY_LEVELS = 10
|
||||
local GRAPHICS_QUALITY_TO_INT = {
|
||||
["Enum.SavedQualitySetting.Automatic"] = 0,
|
||||
["Enum.SavedQualitySetting.QualityLevel1"] = 1,
|
||||
["Enum.SavedQualitySetting.QualityLevel2"] = 2,
|
||||
["Enum.SavedQualitySetting.QualityLevel3"] = 3,
|
||||
["Enum.SavedQualitySetting.QualityLevel4"] = 4,
|
||||
["Enum.SavedQualitySetting.QualityLevel5"] = 5,
|
||||
["Enum.SavedQualitySetting.QualityLevel6"] = 6,
|
||||
["Enum.SavedQualitySetting.QualityLevel7"] = 7,
|
||||
["Enum.SavedQualitySetting.QualityLevel8"] = 8,
|
||||
["Enum.SavedQualitySetting.QualityLevel9"] = 9,
|
||||
["Enum.SavedQualitySetting.QualityLevel10"] = 10,
|
||||
}
|
||||
local PC_CHANGED_PROPS = {
|
||||
DevComputerMovementMode = true,
|
||||
DevComputerCameraMode = true,
|
||||
DevEnableMouseLock = true,
|
||||
}
|
||||
local TOUCH_CHANGED_PROPS = {
|
||||
DevTouchMovementMode = true,
|
||||
DevTouchCameraMode = true,
|
||||
}
|
||||
local CAMERA_MODE_DEFAULT_STRING = UserInputService.TouchEnabled and "Default (Follow)" or "Default (Classic)"
|
||||
|
||||
local MOVEMENT_MODE_DEFAULT_STRING = UserInputService.TouchEnabled and "Default (Thumbstick)" or "Default (Keyboard)"
|
||||
local MOVEMENT_MODE_KEYBOARDMOUSE_STRING = "Keyboard + Mouse"
|
||||
local MOVEMENT_MODE_CLICKTOMOVE_STRING = UserInputService.TouchEnabled and "Tap to Move" or "Click to Move"
|
||||
|
||||
----------- UTILITIES --------------
|
||||
local utility = require(RobloxGui.Modules.Utility)
|
||||
|
||||
------------ Variables -------------------
|
||||
RobloxGui:WaitForChild("Modules"):WaitForChild("TenFootInterface")
|
||||
RobloxGui:WaitForChild("Modules"):WaitForChild("SettingsHub")
|
||||
local isTenFootInterface = require(RobloxGui.Modules.TenFootInterface):IsEnabled()
|
||||
local PageInstance = nil
|
||||
local LocalPlayer = game.Players.LocalPlayer
|
||||
local platform = UserInputService:GetPlatform()
|
||||
local overscanScreen = nil
|
||||
|
||||
----------- CLASS DECLARATION --------------
|
||||
local function Initialize()
|
||||
local settingsPageFactory = require(RobloxGui.Modules.SettingsPageFactory)
|
||||
local this = settingsPageFactory:CreateNewPage()
|
||||
|
||||
----------- FUNCTIONS ---------------
|
||||
local function createGraphicsOptions()
|
||||
|
||||
------------------ Fullscreen Selection GUI Setup ------------------
|
||||
local fullScreenInit = 1
|
||||
if not GameSettings:InFullScreen() then
|
||||
fullScreenInit = 2
|
||||
end
|
||||
|
||||
this.FullscreenFrame,
|
||||
this.FullscreenLabel,
|
||||
this.FullscreenEnabler = utility:AddNewRow(this, "Fullscreen", "Selector", {"On", "Off"}, fullScreenInit)
|
||||
|
||||
local fullScreenSelectionFrame = this.FullscreenEnabler.SliderFrame and this.FullscreenEnabler.SliderFrame or this.FullscreenEnabler.SelectorFrame
|
||||
|
||||
this.FullscreenEnabler.IndexChanged:connect(function(newIndex)
|
||||
GuiService:ToggleFullscreen()
|
||||
end)
|
||||
|
||||
|
||||
------------------ Gfx Enabler Selection GUI Setup ------------------
|
||||
this.GraphicsEnablerFrame,
|
||||
this.GraphicsEnablerLabel,
|
||||
this.GraphicsQualityEnabler = utility:AddNewRow(this, "Graphics Mode", "Selector", {"Automatic", "Manual"}, 1)
|
||||
|
||||
------------------ Gfx Slider GUI Setup ------------------
|
||||
this.GraphicsQualityFrame,
|
||||
this.GraphicsQualityLabel,
|
||||
this.GraphicsQualitySlider = utility:AddNewRow(this, "Graphics Quality", "Slider", GRAPHICS_QUALITY_LEVELS, 1)
|
||||
this.GraphicsQualitySlider:SetMinStep(1)
|
||||
|
||||
------------------ Discord Rich Presence Selection GUI Setup ------------------
|
||||
this.DiscordRichPresenceFrame,
|
||||
this.DiscordRichPresenceLabel,
|
||||
this.DiscordRichPresenceEnabler = utility:AddNewRow(this, "Discord Rich Presence", "Selector", {"On", "Off"}, GameSettings.DiscordRichPresenceEnabled and 1 or 2)
|
||||
|
||||
|
||||
------------------ Micro Profiler Selection GUI Setup ------------------
|
||||
this.MicroProfilerFrame,
|
||||
this.MicroProfilerLabel,
|
||||
this.MicroProfilerEnabler = utility:AddNewRow(this, "Micro Profiler", "Selector", {"On", "Off"}, GameSettings.MicroProfilerEnabled and 1 or 2)
|
||||
|
||||
this.MicroProfilerEnabler.IndexChanged:connect(function(newIndex)
|
||||
GameSettings.MicroProfilerEnabled = newIndex == 1
|
||||
end)
|
||||
------------------ Max Framerate Selection GUI Setup ------------------
|
||||
local maxFramerateEnumItems = Enum.MaxFramerate:GetEnumItems()
|
||||
local startingFrameRateEnumItem = 2
|
||||
|
||||
for i = 1, #maxFramerateEnumItems do
|
||||
if GameSettings.MaxFramerate == maxFramerateEnumItems[i] then
|
||||
startingFrameRateEnumItem = i
|
||||
end
|
||||
end
|
||||
|
||||
this.MaxFramerateFrame,
|
||||
this.MaxFramerateLabel,
|
||||
this.MaxFramerateEnabler = utility:AddNewRow(this, "Max Framerate", "Selector", {"30 FPS", "60 FPS", "75 FPS", "120 FPS", "144 FPS", "200 FPS", "240 FPS", "360 FPS", "Uncapped"}, startingFrameRateEnumItem)
|
||||
------------------ Virtual Version Selection GUI Setup ------------------
|
||||
local virtualVersionEnumItems = Enum.VirtualVersion:GetEnumItems()
|
||||
local startingVirtualVersionEnumItem = 1
|
||||
|
||||
local minVersion = StarterPlayer.MinVirtualVersion
|
||||
local maxVersion = StarterPlayer.MaxVirtualVersion
|
||||
|
||||
local options = {}
|
||||
local filteredEnumItems = {}
|
||||
|
||||
for i = 1, #virtualVersionEnumItems do
|
||||
local enumItem = virtualVersionEnumItems[i]
|
||||
|
||||
if enumItem.Value >= minVersion.Value and enumItem.Value <= maxVersion.Value then
|
||||
table.insert(options, enumItem.Name)
|
||||
table.insert(filteredEnumItems, enumItem)
|
||||
|
||||
if GameSettings.VirtualVersion == enumItem then
|
||||
startingVirtualVersionEnumItem = #options
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
virtualVersionEnumItems = filteredEnumItems
|
||||
|
||||
this.VirtualVersionFrame,
|
||||
this.VirtualVersionLabel,
|
||||
this.VirtualVersionEnabler = utility:AddNewRow(this, "Virtual Version", "DropDown", options, startingVirtualVersionEnumItem)
|
||||
|
||||
------------------ Freaky Mode Selection GUI Setup ------------------
|
||||
if settings():GetFFlag("FreakyModeEnabled") and GameSettings.VirtualVersion == Enum.VirtualVersion['2016'] then
|
||||
this.FreakyModeFrame,
|
||||
this.FreakyModeLabel,
|
||||
this.FreakyModeEnabler = utility:AddNewRow(this, "Freaky Mode", "Selector", {"On", "Off"}, GameSettings.FreakyModeEnabled and 1 or 2)
|
||||
|
||||
this.FreakyModeEnabler.IndexChanged:connect(function(newIndex)
|
||||
GameSettings.FreakyModeEnabled = newIndex == 1
|
||||
end)
|
||||
|
||||
spawn(function()
|
||||
-- when switching virtualversion, this will erorr
|
||||
pcall(function ()
|
||||
this.Page["Freaky ModeFrame"]["Freaky ModeLabel"].Font = Enum.Font.LuckiestGuy
|
||||
this.Page["Freaky ModeFrame"]["Freaky ModeLabel"].TextStrokeTransparency = 0.6
|
||||
|
||||
local hue = 0
|
||||
while wait() do
|
||||
hue = (hue + (0.005))
|
||||
if hue > 1 then
|
||||
hue = hue - 1
|
||||
end
|
||||
|
||||
pcall(function ()
|
||||
this.Page["Freaky ModeFrame"]["Freaky ModeLabel"].TextColor3 = Color3.fromHSV(hue, 1, 1)
|
||||
this.Page["Freaky ModeFrame"]["Freaky ModeLabel"].TextStrokeColor3 = Color3.fromHSV(hue, 1, 0.6)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
------------------------- Connection Setup ----------------------------
|
||||
settings().Rendering.EnableFRM = true
|
||||
|
||||
function SetGraphicsQuality(newValue, automaticSettingAllowed)
|
||||
local percentage = newValue/GRAPHICS_QUALITY_LEVELS
|
||||
local newQualityLevel = math.floor((settings().Rendering:GetMaxQualityLevel() - 1) * percentage)
|
||||
if newQualityLevel == 20 then
|
||||
newQualityLevel = 21
|
||||
elseif newValue == 1 then
|
||||
newQualityLevel = 1
|
||||
elseif newValue < 1 and not automaticSettingAllowed then
|
||||
newValue = 1
|
||||
newQualityLevel = 1
|
||||
elseif newQualityLevel > settings().Rendering:GetMaxQualityLevel() then
|
||||
newQualityLevel = settings().Rendering:GetMaxQualityLevel() - 1
|
||||
end
|
||||
|
||||
GameSettings.SavedQualityLevel = newValue
|
||||
settings().Rendering.QualityLevel = newQualityLevel
|
||||
end
|
||||
|
||||
local function setGraphicsToAuto()
|
||||
this.GraphicsQualitySlider:SetZIndex(1)
|
||||
this.GraphicsQualityLabel.ZIndex = 1
|
||||
this.GraphicsQualitySlider:SetInteractable(false)
|
||||
|
||||
SetGraphicsQuality(Enum.QualityLevel.Automatic.Value, true)
|
||||
end
|
||||
local function setGraphicsToManual(level)
|
||||
this.GraphicsQualitySlider:SetZIndex(2)
|
||||
this.GraphicsQualityLabel.ZIndex = 2
|
||||
this.GraphicsQualitySlider:SetInteractable(true)
|
||||
|
||||
-- need to force the quality change if slider is already at this position
|
||||
if this.GraphicsQualitySlider:GetValue() == level then
|
||||
SetGraphicsQuality(level)
|
||||
else
|
||||
this.GraphicsQualitySlider:SetValue(level)
|
||||
end
|
||||
end
|
||||
|
||||
game.GraphicsQualityChangeRequest:connect(function(isIncrease)
|
||||
if settings().Rendering.QualityLevel == Enum.QualityLevel.Automatic then return end
|
||||
--
|
||||
local currentGraphicsSliderValue = this.GraphicsQualitySlider:GetValue()
|
||||
if isIncrease then
|
||||
currentGraphicsSliderValue = currentGraphicsSliderValue + 1
|
||||
else
|
||||
currentGraphicsSliderValue = currentGraphicsSliderValue - 1
|
||||
end
|
||||
|
||||
this.GraphicsQualitySlider:SetValue(currentGraphicsSliderValue)
|
||||
end)
|
||||
|
||||
this.GraphicsQualitySlider.ValueChanged:connect(function(newValue)
|
||||
SetGraphicsQuality(newValue)
|
||||
end)
|
||||
|
||||
this.GraphicsQualityEnabler.IndexChanged:connect(function(newIndex)
|
||||
if newIndex == 1 then
|
||||
setGraphicsToAuto()
|
||||
elseif newIndex == 2 then
|
||||
setGraphicsToManual( this.GraphicsQualitySlider:GetValue() )
|
||||
end
|
||||
end)
|
||||
|
||||
this.DiscordRichPresenceEnabler.IndexChanged:connect(function(newIndex)
|
||||
GameSettings.DiscordRichPresenceEnabled = newIndex == 1
|
||||
end)
|
||||
|
||||
this.VirtualVersionEnabler.IndexChanged:connect(function(newIndex)
|
||||
Spawn(function()
|
||||
local function easeInOutQuad(t, b, c, d)
|
||||
t = t / (d / 2)
|
||||
if t < 1 then
|
||||
return c / 2 * t * t + b
|
||||
end
|
||||
t = t - 1
|
||||
return -c / 2 * (t * (t - 2) - 1) + b
|
||||
end
|
||||
|
||||
local function fadeIn(blurEffect, duration)
|
||||
local startTime = tick()
|
||||
local connection
|
||||
connection = game:GetService("RunService").RenderStepped:Connect(function()
|
||||
local elapsedTime = tick() - startTime
|
||||
if elapsedTime < duration then
|
||||
blurEffect.Size = easeInOutQuad(elapsedTime, 0, 9, duration)
|
||||
else
|
||||
blurEffect.Size = 9
|
||||
connection:disconnect()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local function fadeOut(blurEffect, duration)
|
||||
local startTime = tick()
|
||||
local connection
|
||||
connection = game:GetService("RunService").RenderStepped:Connect(function()
|
||||
local elapsedTime = tick() - startTime
|
||||
if elapsedTime < duration then
|
||||
blurEffect.Size = easeInOutQuad(elapsedTime, 9, -9, duration)
|
||||
else
|
||||
blurEffect.Size = 0
|
||||
connection:disconnect()
|
||||
blurEffect:Destroy()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local blurEffect = Instance.new("BlurEffect")
|
||||
blurEffect.Size = 0
|
||||
blurEffect.Parent = workspace.CurrentCamera
|
||||
blurEffect.Name = "VirtualVersionBlurEffect"
|
||||
blurEffect.RobloxLocked = true
|
||||
|
||||
fadeIn(blurEffect, 0.2)
|
||||
GameSettings.VirtualVersion = virtualVersionEnumItems[newIndex]
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
this.MaxFramerateEnabler.IndexChanged:connect(function(newIndex)
|
||||
GameSettings.MaxFramerate = maxFramerateEnumItems[newIndex]
|
||||
end)
|
||||
|
||||
if GameSettings.SavedQualityLevel == Enum.SavedQualitySetting.Automatic then
|
||||
this.GraphicsQualitySlider:SetValue(5)
|
||||
this.GraphicsQualityEnabler:SetSelectionIndex(1)
|
||||
else
|
||||
local graphicsLevel = tostring(GameSettings.SavedQualityLevel)
|
||||
if GRAPHICS_QUALITY_TO_INT[graphicsLevel] then
|
||||
graphicsLevel = GRAPHICS_QUALITY_TO_INT[graphicsLevel]
|
||||
else
|
||||
graphicsLevel = GRAPHICS_QUALITY_LEVELS
|
||||
end
|
||||
|
||||
spawn(function()
|
||||
this.GraphicsQualitySlider:SetValue(graphicsLevel)
|
||||
this.GraphicsQualityEnabler:SetSelectionIndex(2)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
local function createCameraModeOptions(movementModeEnabled)
|
||||
------------------------------------------------------
|
||||
------------------
|
||||
------------------ Shift Lock Switch -----------------
|
||||
if UserInputService.MouseEnabled then
|
||||
this.ShiftLockFrame,
|
||||
this.ShiftLockLabel,
|
||||
this.ShiftLockMode,
|
||||
this.ShiftLockOverrideText = nil
|
||||
|
||||
if UserInputService.MouseEnabled and UserInputService.KeyboardEnabled then
|
||||
local startIndex = 2
|
||||
if GameSettings.ControlMode == Enum.ControlMode.MouseLockSwitch then
|
||||
startIndex = 1
|
||||
end
|
||||
|
||||
this.ShiftLockFrame,
|
||||
this.ShiftLockLabel,
|
||||
this.ShiftLockMode = utility:AddNewRow(this, "Shift Lock Switch", "Selector", {"On", "Off"}, startIndex)
|
||||
|
||||
this.ShiftLockOverrideText = utility:Create'TextLabel'
|
||||
{
|
||||
Name = "ShiftLockOverrideLabel",
|
||||
Text = "Set by Developer",
|
||||
TextColor3 = Color3.new(1,1,1),
|
||||
Font = Enum.Font.SourceSans,
|
||||
FontSize = Enum.FontSize.Size24,
|
||||
BackgroundTransparency = 1,
|
||||
Size = UDim2.new(0,200,1,0),
|
||||
Position = UDim2.new(1,-350,0,0),
|
||||
Visible = false,
|
||||
ZIndex = 2,
|
||||
Parent = this.ShiftLockFrame
|
||||
};
|
||||
|
||||
this.ShiftLockMode.IndexChanged:connect(function(newIndex)
|
||||
if newIndex == 1 then
|
||||
GameSettings.ControlMode = Enum.ControlMode.MouseLockSwitch
|
||||
else
|
||||
GameSettings.ControlMode = Enum.ControlMode.Classic
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------
|
||||
------------------
|
||||
------------------ Camera Mode -----------------------
|
||||
do
|
||||
local enumItems = nil
|
||||
local startingCameraEnumItem = 1
|
||||
if UserInputService.TouchEnabled then
|
||||
enumItems = Enum.TouchCameraMovementMode:GetEnumItems()
|
||||
else
|
||||
enumItems = Enum.ComputerCameraMovementMode:GetEnumItems()
|
||||
end
|
||||
|
||||
local cameraEnumNames = {}
|
||||
local cameraEnumNameToItem = {}
|
||||
for i = 1, #enumItems do
|
||||
local displayName = enumItems[i].Name
|
||||
if displayName == 'Default' then
|
||||
displayName = CAMERA_MODE_DEFAULT_STRING
|
||||
end
|
||||
|
||||
if UserInputService.TouchEnabled then
|
||||
if GameSettings.TouchCameraMovementMode == enumItems[i] then
|
||||
startingCameraEnumItem = i
|
||||
end
|
||||
else
|
||||
if GameSettings.ComputerCameraMovementMode == enumItems[i] then
|
||||
startingCameraEnumItem = i
|
||||
end
|
||||
end
|
||||
|
||||
cameraEnumNames[i] = displayName
|
||||
cameraEnumNameToItem[displayName] = enumItems[i].Value
|
||||
end
|
||||
|
||||
this.CameraModeFrame,
|
||||
this.CameraModeLabel,
|
||||
this.CameraMode = utility:AddNewRow(this, "Camera Mode", "Selector", cameraEnumNames, startingCameraEnumItem)
|
||||
|
||||
this.CameraModeOverrideText = utility:Create'TextLabel'
|
||||
{
|
||||
Name = "CameraDevOverrideLabel",
|
||||
Text = "Set by Developer",
|
||||
TextColor3 = Color3.new(1,1,1),
|
||||
Font = Enum.Font.SourceSans,
|
||||
FontSize = Enum.FontSize.Size24,
|
||||
BackgroundTransparency = 1,
|
||||
Size = UDim2.new(0,200,1,0),
|
||||
Position = UDim2.new(1,-350,0,0),
|
||||
Visible = false,
|
||||
ZIndex = 2,
|
||||
Parent = this.CameraModeFrame
|
||||
};
|
||||
|
||||
this.CameraMode.IndexChanged:connect(function(newIndex)
|
||||
local newEnumSetting = cameraEnumNameToItem[cameraEnumNames[newIndex]]
|
||||
|
||||
if UserInputService.TouchEnabled then
|
||||
GameSettings.TouchCameraMovementMode = newEnumSetting
|
||||
else
|
||||
GameSettings.ComputerCameraMovementMode = newEnumSetting
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
------------------------------------------------------
|
||||
------------------
|
||||
------------------ Movement Mode ---------------------
|
||||
if movementModeEnabled then
|
||||
local movementEnumItems = nil
|
||||
local startingMovementEnumItem = 1
|
||||
if UserInputService.TouchEnabled then
|
||||
movementEnumItems = Enum.TouchMovementMode:GetEnumItems()
|
||||
else
|
||||
movementEnumItems = Enum.ComputerMovementMode:GetEnumItems()
|
||||
end
|
||||
|
||||
local movementEnumNames = {}
|
||||
local movementEnumNameToItem = {}
|
||||
for i = 1, #movementEnumItems do
|
||||
local displayName = movementEnumItems[i].Name
|
||||
if displayName == "Default" then
|
||||
displayName = MOVEMENT_MODE_DEFAULT_STRING
|
||||
elseif displayName == "KeyboardMouse" then
|
||||
displayName = MOVEMENT_MODE_KEYBOARDMOUSE_STRING
|
||||
elseif displayName == "ClickToMove" then
|
||||
displayName = MOVEMENT_MODE_CLICKTOMOVE_STRING
|
||||
end
|
||||
|
||||
if UserInputService.TouchEnabled then
|
||||
if GameSettings.TouchMovementMode == movementEnumItems[i] then
|
||||
startingMovementEnumItem = i
|
||||
end
|
||||
else
|
||||
if GameSettings.ComputerMovementMode == movementEnumItems[i] then
|
||||
startingMovementEnumItem = i
|
||||
end
|
||||
end
|
||||
|
||||
movementEnumNames[i] = displayName
|
||||
movementEnumNameToItem[displayName] = movementEnumItems[i]
|
||||
end
|
||||
|
||||
this.MovementModeFrame,
|
||||
this.MovementModeLabel,
|
||||
this.MovementMode = utility:AddNewRow(this, "Movement Mode", "Selector", movementEnumNames, startingMovementEnumItem)
|
||||
|
||||
this.MovementModeOverrideText = utility:Create'TextLabel'
|
||||
{
|
||||
Name = "MovementDevOverrideLabel",
|
||||
Text = "Set by Developer",
|
||||
TextColor3 = Color3.new(1,1,1),
|
||||
Font = Enum.Font.SourceSans,
|
||||
FontSize = Enum.FontSize.Size24,
|
||||
BackgroundTransparency = 1,
|
||||
Size = UDim2.new(0,200,1,0),
|
||||
Position = UDim2.new(1,-350,0,0),
|
||||
Visible = false,
|
||||
ZIndex = 2,
|
||||
Parent = this.MovementModeFrame
|
||||
};
|
||||
|
||||
this.MovementMode.IndexChanged:connect(function(newIndex)
|
||||
local newEnumSetting = movementEnumNameToItem[movementEnumNames[newIndex]]
|
||||
|
||||
if UserInputService.TouchEnabled then
|
||||
GameSettings.TouchMovementMode = newEnumSetting
|
||||
else
|
||||
GameSettings.ComputerMovementMode = newEnumSetting
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------
|
||||
------------------
|
||||
------------------------- Connection Setup -----------
|
||||
function setCameraModeVisible(visible)
|
||||
if this.CameraMode then
|
||||
this.CameraMode.SelectorFrame.Visible = visible
|
||||
this.CameraMode:SetInteractable(visible)
|
||||
end
|
||||
end
|
||||
|
||||
function setMovementModeVisible(visible)
|
||||
if this.MovementMode then
|
||||
this.MovementMode.SelectorFrame.Visible = visible
|
||||
this.MovementMode:SetInteractable(visible)
|
||||
end
|
||||
end
|
||||
|
||||
function setShiftLockVisible(visible)
|
||||
if this.ShiftLockMode then
|
||||
this.ShiftLockMode.SelectorFrame.Visible = visible
|
||||
this.ShiftLockMode:SetInteractable(visible)
|
||||
end
|
||||
end
|
||||
|
||||
do -- initial set of dev vs user choice for guis
|
||||
local isUserChoiceCamera = false
|
||||
if UserInputService.TouchEnabled then
|
||||
isUserChoiceCamera = LocalPlayer.DevTouchCameraMode == Enum.DevTouchCameraMovementMode.UserChoice
|
||||
else
|
||||
isUserChoiceCamera = LocalPlayer.DevComputerCameraMode == Enum.DevComputerCameraMovementMode.UserChoice
|
||||
end
|
||||
|
||||
if not isUserChoiceCamera then
|
||||
this.CameraModeOverrideText.Visible = true
|
||||
setCameraModeVisible(false)
|
||||
else
|
||||
this.CameraModeOverrideText.Visible = false
|
||||
setCameraModeVisible(true)
|
||||
end
|
||||
|
||||
|
||||
local isUserChoiceMovement = false
|
||||
if UserInputService.TouchEnabled then
|
||||
isUserChoiceMovement = LocalPlayer.DevTouchMovementMode == Enum.DevTouchMovementMode.UserChoice
|
||||
else
|
||||
isUserChoiceMovement = LocalPlayer.DevComputerMovementMode == Enum.DevComputerMovementMode.UserChoice
|
||||
end
|
||||
|
||||
if this.MovementModeOverrideText then
|
||||
if not isUserChoiceMovement then
|
||||
this.MovementModeOverrideText.Visible = true
|
||||
setMovementModeVisible(false)
|
||||
else
|
||||
this.MovementModeOverrideText.Visible = false
|
||||
setMovementModeVisible(true)
|
||||
end
|
||||
end
|
||||
|
||||
if this.ShiftLockOverrideText then
|
||||
this.ShiftLockOverrideText.Visible = not LocalPlayer.DevEnableMouseLock
|
||||
setShiftLockVisible(LocalPlayer.DevEnableMouseLock)
|
||||
end
|
||||
end
|
||||
|
||||
local function updateUserSettingsMenu(property)
|
||||
if this.ShiftLockOverrideText and property == "DevEnableMouseLock" then
|
||||
this.ShiftLockOverrideText.Visible = not LocalPlayer.DevEnableMouseLock
|
||||
setShiftLockVisible(LocalPlayer.DevEnableMouseLock)
|
||||
elseif property == "DevComputerCameraMode" then
|
||||
local isUserChoice = LocalPlayer.DevComputerCameraMode == Enum.DevComputerCameraMovementMode.UserChoice
|
||||
setCameraModeVisible(isUserChoice)
|
||||
this.CameraModeOverrideText.Visible = not isUserChoice
|
||||
elseif property == "DevComputerMovementMode" then
|
||||
local isUserChoice = LocalPlayer.DevComputerMovementMode == Enum.DevComputerMovementMode.UserChoice
|
||||
setMovementModeVisible(isUserChoice)
|
||||
if this.MovementModeOverrideText then
|
||||
this.MovementModeOverrideText.Visible = not isUserChoice
|
||||
end
|
||||
-- TOUCH
|
||||
elseif property == "DevTouchMovementMode" then
|
||||
local isUserChoice = LocalPlayer.DevTouchMovementMode == Enum.DevTouchMovementMode.UserChoice
|
||||
setMovementModeVisible(isUserChoice)
|
||||
if this.MovementModeOverrideText then
|
||||
this.MovementModeOverrideText.Visible = not isUserChoice
|
||||
end
|
||||
elseif property == "DevTouchCameraMode" then
|
||||
local isUserChoice = LocalPlayer.DevTouchCameraMode == Enum.DevTouchCameraMovementMode.UserChoice
|
||||
setCameraModeVisible(isUserChoice)
|
||||
this.CameraModeOverrideText.Visible = not isUserChoice
|
||||
end
|
||||
end
|
||||
|
||||
LocalPlayer.Changed:connect(function(property)
|
||||
if IsTouchClient then
|
||||
if TOUCH_CHANGED_PROPS[property] then
|
||||
updateUserSettingsMenu(property)
|
||||
end
|
||||
else
|
||||
if PC_CHANGED_PROPS[property] then
|
||||
updateUserSettingsMenu(property)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local function createVolumeOptions()
|
||||
local startVolumeLevel = math.floor(GameSettings.MasterVolume * 10)
|
||||
this.VolumeFrame,
|
||||
this.VolumeLabel,
|
||||
this.VolumeSlider = utility:AddNewRow(this, "Volume", "Slider", 10, startVolumeLevel)
|
||||
|
||||
local volumeSound = Instance.new("Sound", game.CoreGui.RobloxGui:WaitForChild("Sounds"))
|
||||
volumeSound.Name = "VolumeChangeSound"
|
||||
volumeSound.SoundId = "ayaasset://sounds/uuhhh.mp3"
|
||||
|
||||
this.VolumeSlider.ValueChanged:connect(function(newValue)
|
||||
local soundPercent = newValue/10
|
||||
volumeSound.Volume = soundPercent
|
||||
volumeSound:Play()
|
||||
GameSettings.MasterVolume = soundPercent
|
||||
end)
|
||||
end
|
||||
|
||||
local function createMouseOptions()
|
||||
local MouseSteps = 10
|
||||
local MinMouseSensitivity = 0.2
|
||||
|
||||
-- equations below map a function to include points (0, 0.2) (5, 1) (10, 4)
|
||||
-- where x is the slider position, y is the mouse sensitivity
|
||||
local function translateEngineMouseSensitivityToGui(engineSensitivity)
|
||||
return math.floor((2.0/3.0) * (math.sqrt(75.0 * engineSensitivity - 11.0) - 2))
|
||||
end
|
||||
|
||||
local function translateGuiMouseSensitivityToEngine(guiSensitivity)
|
||||
return 0.03 * math.pow(guiSensitivity,2) + (0.08 * guiSensitivity) + MinMouseSensitivity
|
||||
end
|
||||
|
||||
local startMouseLevel = translateEngineMouseSensitivityToGui(GameSettings.MouseSensitivity)
|
||||
|
||||
this.MouseSensitivityFrame,
|
||||
this.MouseSensitivityLabel,
|
||||
this.MouseSensitivitySlider = utility:AddNewRow(this, "Mouse Sensitivity", "Slider", MouseSteps, startMouseLevel)
|
||||
this.MouseSensitivitySlider:SetMinStep(1)
|
||||
|
||||
this.MouseSensitivitySlider.ValueChanged:connect(function(newValue)
|
||||
GameSettings.MouseSensitivity = translateGuiMouseSensitivityToEngine(newValue)
|
||||
end)
|
||||
end
|
||||
|
||||
local function createOverscanOption()
|
||||
local showOverscanScreen = function()
|
||||
|
||||
if not overscanScreen then
|
||||
local createOverscanFunc = require(RobloxGui.Modules.OverscanScreen)
|
||||
overscanScreen = createOverscanFunc(RobloxGui)
|
||||
overscanScreen:SetStyleForInGame()
|
||||
end
|
||||
|
||||
local MenuModule = require(RobloxGui.Modules.SettingsHub)
|
||||
MenuModule:SetVisibility(false, true)
|
||||
|
||||
local closedCon = nil
|
||||
closedCon = overscanScreen.Closed:connect(function()
|
||||
closedCon:disconnect()
|
||||
pcall(function() PlatformService.BlurIntensity = 0 end)
|
||||
ContextActionService:UnbindCoreAction("RbxStopOverscanMovement")
|
||||
MenuModule:SetVisibility(true, true)
|
||||
end)
|
||||
|
||||
pcall(function() PlatformService.BlurIntensity = 10 end)
|
||||
|
||||
local noOpFunc = function() end
|
||||
ContextActionService:BindCoreAction("RbxStopOverscanMovement", noOpFunc, false,
|
||||
Enum.UserInputType.Gamepad1, Enum.UserInputType.Gamepad2,
|
||||
Enum.UserInputType.Gamepad3, Enum.UserInputType.Gamepad4)
|
||||
|
||||
local ScreenManager = require(RobloxGui.Modules.ScreenManager)
|
||||
ScreenManager:OpenScreen(overscanScreen)
|
||||
|
||||
end
|
||||
|
||||
local adjustButton, adjustText, setButtonRowRef = utility:MakeStyledButton("AdjustButton", "Adjust", UDim2.new(0,300,1,-20), showOverscanScreen, this)
|
||||
adjustText.Font = Enum.Font.SourceSans
|
||||
adjustButton.Position = UDim2.new(1,-400,0,12)
|
||||
|
||||
local row = utility:AddNewRowObject(this, "Safe Zone", adjustButton)
|
||||
setButtonRowRef(row)
|
||||
end
|
||||
|
||||
createCameraModeOptions(not isTenFootInterface and
|
||||
(UserInputService.TouchEnabled or UserInputService.MouseEnabled or UserInputService.KeyboardEnabled))
|
||||
|
||||
if UserInputService.MouseEnabled then
|
||||
createMouseOptions()
|
||||
end
|
||||
|
||||
createVolumeOptions()
|
||||
createGraphicsOptions()
|
||||
|
||||
if isTenFootInterface then
|
||||
createOverscanOption()
|
||||
end
|
||||
|
||||
------ TAB CUSTOMIZATION -------
|
||||
this.TabHeader.Name = "GameSettingsTab"
|
||||
|
||||
this.TabHeader.Icon.Image = "ayaasset://textures/ui/Settings/MenuBarIcons/GameSettingsTab.png"
|
||||
if utility:IsSmallTouchScreen() then
|
||||
this.TabHeader.Icon.Size = UDim2.new(0,34,0,34)
|
||||
this.TabHeader.Icon.Position = UDim2.new(this.TabHeader.Icon.Position.X.Scale,this.TabHeader.Icon.Position.X.Offset,0.5,-17)
|
||||
this.TabHeader.Size = UDim2.new(0,125,1,0)
|
||||
elseif isTenFootInterface then
|
||||
this.TabHeader.Icon.Image = "ayaasset://textures/ui/Settings/MenuBarIcons/GameSettingsTab@2x.png"
|
||||
this.TabHeader.Icon.Size = UDim2.new(0,90,0,90)
|
||||
this.TabHeader.Icon.Position = UDim2.new(0,0,0.5,-43)
|
||||
this.TabHeader.Size = UDim2.new(0,280,1,0)
|
||||
else
|
||||
this.TabHeader.Icon.Size = UDim2.new(0,45,0,45)
|
||||
this.TabHeader.Icon.Position = UDim2.new(0,15,0.5,-22)
|
||||
end
|
||||
|
||||
|
||||
this.TabHeader.Icon.Title.Text = "Settings"
|
||||
|
||||
------ PAGE CUSTOMIZATION -------
|
||||
this.Page.ZIndex = 5
|
||||
|
||||
return this
|
||||
end
|
||||
|
||||
|
||||
----------- Page Instantiation --------------
|
||||
|
||||
PageInstance = Initialize()
|
||||
return PageInstance
|
||||
480
client/common/content/scripts/Modules/Help.lua
Normal file
480
client/common/content/scripts/Modules/Help.lua
Normal file
@@ -0,0 +1,480 @@
|
||||
--[[
|
||||
Filename: Help.lua
|
||||
Written by: jeditkacheff
|
||||
Version 1.0
|
||||
Description: Takes care of the help page in Settings Menu
|
||||
--]]
|
||||
-------------- CONSTANTS --------------
|
||||
local KEYBOARD_MOUSE_TAG = "KeyboardMouse"
|
||||
local TOUCH_TAG = "Touch"
|
||||
local GAMEPAD_TAG = "Gamepad"
|
||||
local PC_TABLE_SPACING = 4
|
||||
|
||||
-------------- SERVICES --------------
|
||||
local CoreGui = game:GetService("CoreGui")
|
||||
local RobloxGui = CoreGui:WaitForChild("RobloxGui")
|
||||
local UserInputService = game:GetService("UserInputService")
|
||||
local GuiService = game:GetService("GuiService")
|
||||
|
||||
----------- UTILITIES --------------
|
||||
local utility = require(RobloxGui.Modules.Utility)
|
||||
|
||||
------------ Variables -------------------
|
||||
local PageInstance = nil
|
||||
RobloxGui:WaitForChild("Modules"):WaitForChild("TenFootInterface")
|
||||
local isTenFootInterface = require(RobloxGui.Modules.TenFootInterface):IsEnabled()
|
||||
|
||||
----------- CLASS DECLARATION --------------
|
||||
|
||||
local function Initialize()
|
||||
local settingsPageFactory = require(RobloxGui.Modules.SettingsPageFactory)
|
||||
local this = settingsPageFactory:CreateNewPage()
|
||||
this.HelpPages = {}
|
||||
|
||||
-- TODO: Change dev console script to parent this to somewhere other than an engine created gui
|
||||
local ControlFrame = RobloxGui:WaitForChild('ControlFrame')
|
||||
local ToggleDevConsoleBindableFunc = ControlFrame:WaitForChild('ToggleDevConsole')
|
||||
local lastInputType = nil
|
||||
|
||||
function this:GetCurrentInputType()
|
||||
if lastInputType == nil then -- we don't know what controls the user has, just use reasonable defaults
|
||||
local platform = UserInputService:GetPlatform()
|
||||
if platform == Enum.Platform.XBoxOne or platform == Enum.Platform.WiiU then
|
||||
|
||||
return GAMEPAD_TAG
|
||||
elseif platform == Enum.Platform.Windows or platform == Enum.Platform.OSX then
|
||||
return KEYBOARD_MOUSE_TAG
|
||||
else
|
||||
return TOUCH_TAG
|
||||
end
|
||||
end
|
||||
|
||||
if lastInputType == Enum.UserInputType.Keyboard or lastInputType == Enum.UserInputType.MouseMovement or
|
||||
lastInputType == Enum.UserInputType.MouseButton1 or lastInputType == Enum.UserInputType.MouseButton2 or
|
||||
lastInputType == Enum.UserInputType.MouseButton3 or lastInputType == Enum.UserInputType.MouseWheel then
|
||||
return KEYBOARD_MOUSE_TAG
|
||||
elseif lastInputType == Enum.UserInputType.Touch then
|
||||
return TOUCH_TAG
|
||||
elseif lastInputType == Enum.UserInputType.Gamepad1 or lastInputType == Enum.UserInputType.Gamepad2 or
|
||||
inputType == Enum.UserInputType.Gamepad3 or lastInputType == Enum.UserInputType.Gamepad4 then
|
||||
return GAMEPAD_TAG
|
||||
end
|
||||
|
||||
return KEYBOARD_MOUSE_TAG
|
||||
end
|
||||
|
||||
|
||||
local function createPCHelp(parentFrame)
|
||||
local function createPCGroup(title, actionInputBindings)
|
||||
local textIndent = 9
|
||||
|
||||
local pcGroupFrame = utility:Create'Frame'
|
||||
{
|
||||
Size = UDim2.new(1/3,-PC_TABLE_SPACING,1,0),
|
||||
BackgroundTransparency = 1,
|
||||
Name = "PCGroupFrame" .. tostring(title)
|
||||
};
|
||||
local pcGroupTitle = utility:Create'TextLabel'
|
||||
{
|
||||
Position = UDim2.new(0,textIndent,0,0),
|
||||
Size = UDim2.new(1,-textIndent,0,30),
|
||||
BackgroundTransparency = 1,
|
||||
Text = title,
|
||||
Font = Enum.Font.SourceSansBold,
|
||||
FontSize = Enum.FontSize.Size18,
|
||||
TextColor3 = Color3.new(1,1,1),
|
||||
TextXAlignment = Enum.TextXAlignment.Left,
|
||||
Name = "PCGroupTitle" .. tostring(title),
|
||||
ZIndex = 2,
|
||||
Parent = pcGroupFrame
|
||||
};
|
||||
|
||||
local count = 0
|
||||
local frameHeight = 42
|
||||
local spacing = 2
|
||||
local offset = pcGroupTitle.Size.Y.Offset
|
||||
for i = 1, #actionInputBindings do
|
||||
for actionName, inputName in pairs(actionInputBindings[i]) do
|
||||
local actionInputFrame = utility:Create'Frame'
|
||||
{
|
||||
Size = UDim2.new(1,0,0,frameHeight),
|
||||
Position = UDim2.new(0,0,0, offset + ((frameHeight + spacing) * count)),
|
||||
BackgroundTransparency = 0.65,
|
||||
BorderSizePixel = 0,
|
||||
ZIndex = 2,
|
||||
Name = "ActionInputBinding" .. tostring(actionName),
|
||||
Parent = pcGroupFrame
|
||||
};
|
||||
|
||||
local nameLabel = utility:Create'TextLabel'
|
||||
{
|
||||
Size = UDim2.new(0.4,-textIndent,0,frameHeight),
|
||||
Position = UDim2.new(0,textIndent,0,0),
|
||||
BackgroundTransparency = 1,
|
||||
Text = actionName,
|
||||
Font = Enum.Font.SourceSansBold,
|
||||
FontSize = Enum.FontSize.Size18,
|
||||
TextColor3 = Color3.new(1,1,1),
|
||||
TextXAlignment = Enum.TextXAlignment.Left,
|
||||
Name = actionName .. "Label",
|
||||
ZIndex = 2,
|
||||
Parent = actionInputFrame
|
||||
};
|
||||
|
||||
local inputLabel = utility:Create'TextLabel'
|
||||
{
|
||||
Size = UDim2.new(0.6,0,0,frameHeight),
|
||||
Position = UDim2.new(0.5,-4,0,0),
|
||||
BackgroundTransparency = 1,
|
||||
Text = inputName,
|
||||
Font = Enum.Font.SourceSans,
|
||||
FontSize = Enum.FontSize.Size18,
|
||||
TextColor3 = Color3.new(1,1,1),
|
||||
TextXAlignment = Enum.TextXAlignment.Left,
|
||||
Name = inputName .. "Label",
|
||||
ZIndex = 2,
|
||||
Parent = actionInputFrame
|
||||
};
|
||||
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
|
||||
pcGroupFrame.Size = UDim2.new(pcGroupFrame.Size.X.Scale,pcGroupFrame.Size.X.Offset,
|
||||
0, offset + ((frameHeight + spacing) * count))
|
||||
|
||||
return pcGroupFrame
|
||||
end
|
||||
|
||||
local rowOffset = 50
|
||||
local isOSX = UserInputService:GetPlatform() == Enum.Platform.OSX
|
||||
|
||||
local charMoveFrame = createPCGroup( "Character Movement", {[1] = {["Move Forward"] = "W/Up Arrow"},
|
||||
[2] = {["Move Backward"] = "S/Down Arrow"},
|
||||
[3] = {["Move Left"] = "A/Left Arrow"},
|
||||
[4] = {["Move Right"] = "D/Right Arrow"},
|
||||
[5] = {["Jump"] = "Space"}} )
|
||||
charMoveFrame.Parent = parentFrame
|
||||
|
||||
local accessoriesFrame = createPCGroup("Accessories", { [1] = {["Equip Tools"] = "1,2,3..."},
|
||||
[2] = {["Unequip Tools"] = "1,2,3..."},
|
||||
[3] = {["Drop Tool"] = "Backspace"},
|
||||
[4] = {["Use Tool"] = "Left Mouse Button"},
|
||||
[5] = {["Drop Hats"] = "+"} })
|
||||
accessoriesFrame.Position = UDim2.new(1/3,PC_TABLE_SPACING,0,0)
|
||||
accessoriesFrame.Parent = parentFrame
|
||||
|
||||
local miscFrame = nil
|
||||
local hideHudSuccess, hideHudFlagValue = pcall(function() return settings():GetFFlag("AllowHideHudShortcut") end)
|
||||
if (hideHudSuccess and hideHudFlagValue) then
|
||||
miscFrame = createPCGroup("Misc", { [1] = {["Hide HUD"] = isOSX and "F7/fn + F7" or "F7"},
|
||||
[2] = {["Dev Console"] = isOSX and "F9/fn + F9" or "F9"},
|
||||
[3] = {["Mouselock"] = "Shift"},
|
||||
[4] = {["Graphics Level"] = isOSX and "F10/fn + F10" or "F10"},
|
||||
[5] = {["Fullscreen"] = isOSX and "F11/fn + F11" or "F11"} })
|
||||
else
|
||||
miscFrame = createPCGroup("Misc", { [1] = {["Dev Console"] = isOSX and "F9/fn + F9" or "F9"},
|
||||
[2] = {["Mouselock"] = "Shift"},
|
||||
[3] = {["Graphics Level"] = isOSX and "F10/fn + F10" or "F10"},
|
||||
[4] = {["Fullscreen"] = isOSX and "F11/fn + F11" or "F11"} })
|
||||
end
|
||||
miscFrame.Position = UDim2.new(2/3,PC_TABLE_SPACING * 2,0,0)
|
||||
miscFrame.Parent = parentFrame
|
||||
|
||||
local camFrame = createPCGroup("Camera Movement", { [1] = {["Rotate"] = "Right Mouse Button"},
|
||||
[2] = {["Zoom In/Out"] = "Mouse Wheel"},
|
||||
[3] = {["Zoom In"] = "I"},
|
||||
[4] = {["Zoom Out"] = "O"} })
|
||||
camFrame.Position = UDim2.new(0,0,charMoveFrame.Size.Y.Scale,charMoveFrame.Size.Y.Offset + rowOffset)
|
||||
camFrame.Parent = parentFrame
|
||||
|
||||
local menuFrame = createPCGroup("Menu Items", { [1] = {["Kiseki Menu"] = "ESC"},
|
||||
[2] = {["Backpack"] = "~"},
|
||||
[3] = {["Playerlist"] = "TAB"},
|
||||
[4] = {["Chat"] = "/"} })
|
||||
menuFrame.Position = UDim2.new(1/3,PC_TABLE_SPACING,charMoveFrame.Size.Y.Scale,charMoveFrame.Size.Y.Offset + rowOffset)
|
||||
menuFrame.Parent = parentFrame
|
||||
|
||||
parentFrame.Size = UDim2.new(parentFrame.Size.X.Scale, parentFrame.Size.X.Offset, 0,
|
||||
menuFrame.Size.Y.Offset + menuFrame.Position.Y.Offset)
|
||||
end
|
||||
|
||||
local function createGamepadHelp(parentFrame)
|
||||
local gamepadImage = "ayaasset://textures/ui/Settings/Help/GenericController.png"
|
||||
local imageSize = UDim2.new(0,650,0,239)
|
||||
local imagePosition = UDim2.new(0.5,-imageSize.X.Offset/2,0.5,-imageSize.Y.Offset/2)
|
||||
if UserInputService:GetPlatform() == Enum.Platform.XBoxOne or UserInputService:GetPlatform() == Enum.Platform.XBox360 then
|
||||
gamepadImage = "ayaasset://textures/ui/Settings/Help/XboxController.png"
|
||||
imageSize = UDim2.new(0,1334,0,570)
|
||||
imagePosition = UDim2.new(0.5, (-imageSize.X.Offset/2) - 50, 0.5, -imageSize.Y.Offset/2)
|
||||
elseif UserInputService:GetPlatform() == Enum.Platform.PS4 or UserInputService:GetPlatform() == Enum.Platform.PS3 then
|
||||
gamepadImage = "ayaasset://textures/ui/Settings/Help/PSController.png"
|
||||
end
|
||||
|
||||
local gamepadImageLabel = utility:Create'ImageLabel'
|
||||
{
|
||||
Name = "GamepadImage",
|
||||
Size = imageSize,
|
||||
Position = imagePosition,
|
||||
Image = gamepadImage,
|
||||
BackgroundTransparency = 1,
|
||||
ZIndex = 2,
|
||||
Parent = parentFrame
|
||||
};
|
||||
parentFrame.Size = UDim2.new(parentFrame.Size.X.Scale, parentFrame.Size.X.Offset, 0, gamepadImageLabel.Size.Y.Offset + 100)
|
||||
|
||||
local gamepadFontSize = isTenFootInterface and Enum.FontSize.Size36 or Enum.FontSize.Size24
|
||||
local function createGamepadLabel(text, position, size)
|
||||
local nameLabel = utility:Create'TextLabel'
|
||||
{
|
||||
Position = position,
|
||||
Size = size,
|
||||
BackgroundTransparency = 1,
|
||||
Text = text,
|
||||
TextXAlignment = Enum.TextXAlignment.Left,
|
||||
Font = Enum.Font.SourceSansBold,
|
||||
FontSize = gamepadFontSize,
|
||||
TextColor3 = Color3.new(1,1,1),
|
||||
Name = text .. "Label",
|
||||
ZIndex = 2,
|
||||
Parent = gamepadImageLabel
|
||||
};
|
||||
end
|
||||
|
||||
local textVerticalSize = (gamepadFontSize == Enum.FontSize.Size36) and 36 or 24
|
||||
|
||||
if gamepadImage == "ayaasset://textures/ui/Settings/Help/XboxController.png" then
|
||||
createGamepadLabel("Switch Tool", UDim2.new(0,50,0,-textVerticalSize/2), UDim2.new(0,100,0,textVerticalSize))
|
||||
createGamepadLabel("Game Menu Toggle", UDim2.new(0,-38,0.15,-textVerticalSize/2), UDim2.new(0,164,0,textVerticalSize))
|
||||
createGamepadLabel("Move", UDim2.new(0,-80,0.31,-textVerticalSize/2), UDim2.new(0,46,0,textVerticalSize))
|
||||
createGamepadLabel("Menu Navigation", UDim2.new(0,-50,0.46,-textVerticalSize/2), UDim2.new(0,164,0,textVerticalSize))
|
||||
createGamepadLabel("Use Tool", UDim2.new(0.96,0,0,-textVerticalSize/2), UDim2.new(0,73,0,textVerticalSize))
|
||||
createGamepadLabel("Kiseki Menu", UDim2.new(0.96,0,0.15,-textVerticalSize/2), UDim2.new(0,122,0,textVerticalSize))
|
||||
createGamepadLabel("Back", UDim2.new(0.96,0,0.31,-textVerticalSize/2), UDim2.new(0,43,0,textVerticalSize))
|
||||
createGamepadLabel("Jump", UDim2.new(0.96,0,0.46,-textVerticalSize/2), UDim2.new(0,49,0,textVerticalSize))
|
||||
createGamepadLabel("Rotate Camera", UDim2.new(1,0,0.62,-textVerticalSize/2), UDim2.new(0,132,0,textVerticalSize))
|
||||
createGamepadLabel("Camera Zoom", UDim2.new(1,0,0.77,-textVerticalSize/2), UDim2.new(0,122,0,textVerticalSize))
|
||||
else
|
||||
createGamepadLabel("Switch Tool", UDim2.new(-0.01,0,0,-textVerticalSize/2), UDim2.new(0,100,0,textVerticalSize))
|
||||
createGamepadLabel("Game Menu Toggle", UDim2.new(-0.11,0,0.15,-textVerticalSize/2), UDim2.new(0,164,0,textVerticalSize))
|
||||
createGamepadLabel("Move", UDim2.new(-0.08,0,0.31,-textVerticalSize/2), UDim2.new(0,46,0,textVerticalSize))
|
||||
createGamepadLabel("Menu Navigation", UDim2.new(-0.125,0,0.46,-textVerticalSize/2), UDim2.new(0,164,0,textVerticalSize))
|
||||
createGamepadLabel("Use Tool", UDim2.new(0.96,0,0,-textVerticalSize/2), UDim2.new(0,73,0,textVerticalSize))
|
||||
createGamepadLabel("Kiseki Menu", UDim2.new(0.9,0,0.15,-textVerticalSize/2), UDim2.new(0,122,0,textVerticalSize))
|
||||
createGamepadLabel("Back", UDim2.new(1.01,0,0.31,-textVerticalSize/2), UDim2.new(0,43,0,textVerticalSize))
|
||||
createGamepadLabel("Jump", UDim2.new(0.91,0,0.46,-textVerticalSize/2), UDim2.new(0,49,0,textVerticalSize))
|
||||
createGamepadLabel("Rotate Camera", UDim2.new(0.91,0,0.62,-textVerticalSize/2), UDim2.new(0,132,0,textVerticalSize))
|
||||
createGamepadLabel("Camera Zoom", UDim2.new(0.91,0,0.77,-textVerticalSize/2), UDim2.new(0,122,0,textVerticalSize))
|
||||
end
|
||||
|
||||
|
||||
-- todo: turn on dev console button when dev console is ready
|
||||
--[[local openDevConsoleFunc = function()
|
||||
this.HubRef:SetVisibility(false)
|
||||
ToggleDevConsoleBindableFunc:Invoke()
|
||||
end
|
||||
local devConsoleButton = utility:MakeStyledButton("ConsoleButton", " Toggle Dev Console", UDim2.new(0,300,0,44), openDevConsoleFunc)
|
||||
devConsoleButton.Size = UDim2.new(devConsoleButton.Size.X.Scale, devConsoleButton.Size.X.Offset, 0, 60)
|
||||
devConsoleButton.Position = UDim2.new(1,-300,1,30)
|
||||
if UserInputService.GamepadEnabled and not UserInputService.TouchEnabled and not UserInputService.MouseEnabled and not UserInputService.KeyboardEnabled then
|
||||
devConsoleButton.ImageTransparency = 1
|
||||
end
|
||||
devConsoleButton.Parent = gamepadImageLabel
|
||||
local aButtonImage = utility:Create'ImageLabel'
|
||||
{
|
||||
Name = "AButtonImage",
|
||||
Size = UDim2.new(0,55,0,55),
|
||||
Position = UDim2.new(0,5,0.5,-28),
|
||||
Image = "ayaasset://textures/ui/Settings/Help/AButtonDark.png",
|
||||
BackgroundTransparency = 1,
|
||||
ZIndex = 2,
|
||||
Parent = devConsoleButton
|
||||
};
|
||||
|
||||
this:AddRow(nil, nil, devConsoleButton, 340)]]
|
||||
end
|
||||
|
||||
local function createTouchHelp(parentFrame)
|
||||
local smallScreen = utility:IsSmallTouchScreen()
|
||||
local ySize = GuiService:GetScreenResolution().y - 350
|
||||
if smallScreen then
|
||||
ySize = GuiService:GetScreenResolution().y - 100
|
||||
end
|
||||
parentFrame.Size = UDim2.new(1,0,0,ySize)
|
||||
|
||||
local function createTouchLabel(text, position, size, parent)
|
||||
local nameLabel = utility:Create'TextLabel'
|
||||
{
|
||||
Position = position,
|
||||
Size = size,
|
||||
BackgroundTransparency = 1,
|
||||
Text = text,
|
||||
Font = Enum.Font.SourceSansBold,
|
||||
FontSize = Enum.FontSize.Size14,
|
||||
TextColor3 = Color3.new(1,1,1),
|
||||
Name = text .. "Label",
|
||||
ZIndex = 2,
|
||||
Parent = parent
|
||||
};
|
||||
if not smallScreen then
|
||||
nameLabel.FontSize = Enum.FontSize.Size18
|
||||
nameLabel.Size = UDim2.new(nameLabel.Size.X.Scale, nameLabel.Size.X.Offset, nameLabel.Size.Y.Scale, nameLabel.Size.Y.Offset + 4)
|
||||
end
|
||||
local nameBackgroundImage = utility:Create'ImageLabel'
|
||||
{
|
||||
Name = text .. "BackgroundImage",
|
||||
Size = UDim2.new(1,0,1,0),
|
||||
Position = UDim2.new(0,0,0,2),
|
||||
BackgroundTransparency = 1,
|
||||
Image = "ayaasset://textures/ui/Settings/Radial/RadialLabel.png",
|
||||
ScaleType = Enum.ScaleType.Slice,
|
||||
SliceCenter = Rect.new(12,2,65,21),
|
||||
ZIndex = 2,
|
||||
Parent = nameLabel
|
||||
};
|
||||
|
||||
return nameLabel
|
||||
end
|
||||
|
||||
local function createTouchGestureImage(name, image, position, size, parent)
|
||||
local gestureImage = utility:Create'ImageLabel'
|
||||
{
|
||||
Name = name,
|
||||
Size = size,
|
||||
Position = position,
|
||||
BackgroundTransparency = 1,
|
||||
Image = image,
|
||||
ZIndex = 2,
|
||||
Parent = parent
|
||||
};
|
||||
|
||||
return gestureImage
|
||||
end
|
||||
|
||||
local xSizeOffset = 30
|
||||
local ySize = 25
|
||||
if smallScreen then xSizeOffset = 0 end
|
||||
|
||||
local moveLabel = createTouchLabel("Move", UDim2.new(0.06,0,0.58,0), UDim2.new(0,77 + xSizeOffset,0,ySize), parentFrame)
|
||||
if not smallScreen then moveLabel.Position = UDim2.new(-0.03,0,0.7,0) end
|
||||
local jumpLabel = createTouchLabel("Jump", UDim2.new(0.8,0,0.58,0), UDim2.new(0,77 + xSizeOffset,0,ySize), parentFrame)
|
||||
if not smallScreen then jumpLabel.Position = UDim2.new(0.85,0,0.7,0) end
|
||||
local equipLabel = createTouchLabel("Equip/Unequip Tools", UDim2.new(0.5,-60,0.64,0), UDim2.new(0,120 + xSizeOffset,0,ySize), parentFrame)
|
||||
if not smallScreen then equipLabel.Position = UDim2.new(0.5,-60,0.95,0) end
|
||||
|
||||
local zoomLabel = createTouchLabel("Zoom In/Out", UDim2.new(0.15,-60,0.02,0), UDim2.new(0,120,0,ySize), parentFrame)
|
||||
createTouchGestureImage("ZoomImage", "ayaasset://textures/ui/Settings/Help/ZoomGesture.png", UDim2.new(0.5,-26,1,3), UDim2.new(0,53,0,59), zoomLabel)
|
||||
local rotateLabel = createTouchLabel("Rotate Camera", UDim2.new(0.5,-60,0.02,0), UDim2.new(0,120,0,ySize), parentFrame)
|
||||
createTouchGestureImage("RotateImage", "ayaasset://textures/ui/Settings/Help/RotateCameraGesture.png", UDim2.new(0.5,-32,1,3), UDim2.new(0,65,0,48), rotateLabel)
|
||||
local useToolLabel = createTouchLabel("Use Tool", UDim2.new(0.85,-60,0.02,0), UDim2.new(0,120,0,ySize), parentFrame)
|
||||
createTouchGestureImage("ToolImage", "ayaasset://textures/ui/Settings/Help/UseToolGesture.png", UDim2.new(0.5,-19,1,3), UDim2.new(0,38,0,52), useToolLabel)
|
||||
|
||||
end
|
||||
|
||||
local function createHelpDisplay(typeOfHelp)
|
||||
local helpFrame = utility:Create'Frame'
|
||||
{
|
||||
Size = UDim2.new(1,0,1,0),
|
||||
BackgroundTransparency = 1,
|
||||
Name = "HelpFrame" .. tostring(typeOfHelp)
|
||||
};
|
||||
|
||||
if typeOfHelp == KEYBOARD_MOUSE_TAG then
|
||||
createPCHelp(helpFrame)
|
||||
elseif typeOfHelp == GAMEPAD_TAG then
|
||||
createGamepadHelp(helpFrame)
|
||||
elseif typeOfHelp == TOUCH_TAG then
|
||||
createTouchHelp(helpFrame)
|
||||
end
|
||||
|
||||
return helpFrame
|
||||
end
|
||||
|
||||
local function displayHelp(currentPage)
|
||||
for i, helpPage in pairs(this.HelpPages) do
|
||||
if helpPage == currentPage then
|
||||
helpPage.Parent = this.Page
|
||||
this.Page.Size = helpPage.Size
|
||||
else
|
||||
helpPage.Parent = nil
|
||||
end
|
||||
end
|
||||
if UserInputService:GetPlatform() == Enum.Platform.XBoxOne then
|
||||
this.HubRef.PageViewClipper.ClipsDescendants = false
|
||||
this.HubRef.PageView.ClipsDescendants = false
|
||||
end
|
||||
end
|
||||
|
||||
local function switchToHelp(typeOfHelp)
|
||||
local helpPage = this.HelpPages[typeOfHelp]
|
||||
if helpPage then
|
||||
displayHelp(helpPage)
|
||||
else
|
||||
this.HelpPages[typeOfHelp] = createHelpDisplay(typeOfHelp)
|
||||
switchToHelp(typeOfHelp)
|
||||
end
|
||||
end
|
||||
|
||||
local function showTypeOfHelp()
|
||||
switchToHelp(this:GetCurrentInputType())
|
||||
end
|
||||
|
||||
------ TAB CUSTOMIZATION -------
|
||||
this.TabHeader.Name = "HelpTab"
|
||||
|
||||
this.TabHeader.Icon.Image = "ayaasset://textures/ui/Settings/MenuBarIcons/HelpTab.png"
|
||||
|
||||
if utility:IsSmallTouchScreen() then
|
||||
this.TabHeader.Icon.Size = UDim2.new(0,33,0,33)
|
||||
this.TabHeader.Icon.Position = UDim2.new(this.TabHeader.Icon.Position.X.Scale,this.TabHeader.Icon.Position.X.Offset,0.5,-16)
|
||||
this.TabHeader.Size = UDim2.new(0,100,1,0)
|
||||
elseif isTenFootInterface then
|
||||
this.TabHeader.Icon.Image = "ayaasset://textures/ui/Settings/MenuBarIcons/HelpTab@2x.png"
|
||||
this.TabHeader.Icon.Size = UDim2.new(0,90,0,90)
|
||||
this.TabHeader.Icon.Position = UDim2.new(0,0,0.5,-43)
|
||||
this.TabHeader.Size = UDim2.new(0,210,1,0)
|
||||
else
|
||||
this.TabHeader.Icon.Size = UDim2.new(0,44,0,44)
|
||||
this.TabHeader.Icon.Position = UDim2.new(this.TabHeader.Icon.Position.X.Scale,this.TabHeader.Icon.Position.X.Offset,0.5,-22)
|
||||
this.TabHeader.Size = UDim2.new(0,130,1,0)
|
||||
end
|
||||
|
||||
this.TabHeader.Icon.Title.Text = "Help"
|
||||
|
||||
|
||||
------ PAGE CUSTOMIZATION -------
|
||||
this.Page.Name = "Help"
|
||||
|
||||
UserInputService.InputBegan:connect(function(inputObject)
|
||||
local inputType = inputObject.UserInputType
|
||||
if inputType ~= Enum.UserInputType.Focus and inputType ~= Enum.UserInputType.None then
|
||||
lastInputType = inputObject.UserInputType
|
||||
showTypeOfHelp()
|
||||
end
|
||||
end)
|
||||
|
||||
return this
|
||||
end
|
||||
|
||||
|
||||
----------- Public Facing API Additions --------------
|
||||
do
|
||||
PageInstance = Initialize()
|
||||
PageInstance.Displayed.Event:connect(function()
|
||||
if PageInstance:GetCurrentInputType() == TOUCH_TAG then
|
||||
if PageInstance.HubRef.BottomButtonFrame and not utility:IsSmallTouchScreen() then
|
||||
PageInstance.HubRef.BottomButtonFrame.Visible = false
|
||||
end
|
||||
end
|
||||
end)
|
||||
PageInstance.Hidden.Event:connect(function()
|
||||
PageInstance.HubRef.PageViewClipper.ClipsDescendants = true
|
||||
PageInstance.HubRef.PageView.ClipsDescendants = true
|
||||
PageInstance.HubRef:ShowShield()
|
||||
|
||||
if PageInstance:GetCurrentInputType() == TOUCH_TAG then
|
||||
PageInstance.HubRef.BottomButtonFrame.Visible = true
|
||||
end
|
||||
end)
|
||||
end
|
||||
return PageInstance
|
||||
79
client/common/content/scripts/Modules/Home.lua
Normal file
79
client/common/content/scripts/Modules/Home.lua
Normal file
@@ -0,0 +1,79 @@
|
||||
--[[
|
||||
Filename: Home.lua
|
||||
Written by: jeditkacheff
|
||||
Version 1.0
|
||||
Description: Takes care of the home page in Settings Menu
|
||||
--]]
|
||||
|
||||
local BUTTON_OFFSET = 20
|
||||
local BUTTON_SPACING = 10
|
||||
|
||||
-------------- SERVICES --------------
|
||||
local CoreGui = game:GetService("CoreGui")
|
||||
local RobloxGui = CoreGui:WaitForChild("RobloxGui")
|
||||
local GuiService = game:GetService("GuiService")
|
||||
|
||||
----------- UTILITIES --------------
|
||||
local utility = require(RobloxGui.Modules.Utility)
|
||||
|
||||
------------ Variables -------------------
|
||||
local PageInstance = nil
|
||||
|
||||
----------- CLASS DECLARATION --------------
|
||||
|
||||
local function Initialize()
|
||||
local settingsPageFactory = require(RobloxGui.Modules.SettingsPageFactory)
|
||||
local this = settingsPageFactory:CreateNewPage()
|
||||
|
||||
------ TAB CUSTOMIZATION -------
|
||||
this.TabHeader.Name = "HomeTab"
|
||||
|
||||
this.TabHeader.Icon.Image = "ayaasset://textures/ui/Settings/MenuBarIcons/HomeTab.png"
|
||||
this.TabHeader.Icon.Size = UDim2.new(0,32,0,30)
|
||||
this.TabHeader.Icon.Position = UDim2.new(0,5,0.5,-15)
|
||||
|
||||
this.TabHeader.Icon.Title.Text = "Home"
|
||||
|
||||
this.TabHeader.Size = UDim2.new(0,100,1,0)
|
||||
|
||||
------ PAGE CUSTOMIZATION -------
|
||||
this.Page.Name = "Home"
|
||||
local resumeGameFunc = function()
|
||||
this.HubRef:SetVisibility(false)
|
||||
end
|
||||
|
||||
this.ResumeButton = utility:MakeStyledButton("ResumeButton", "Resume Game", UDim2.new(0, 200, 0, 50), resumeGameFunc)
|
||||
this.ResumeButton.Position = UDim2.new(0.5,-100,0,BUTTON_OFFSET)
|
||||
this.ResumeButton.Parent = this.Page
|
||||
|
||||
local resetFunc = function()
|
||||
this.HubRef:SwitchToPage(this.HubRef.ResetCharacterPage, false, 1)
|
||||
end
|
||||
|
||||
local resetButton = utility:MakeStyledButton("ResetButton", "Reset Character", UDim2.new(0, 200, 0, 50), resetFunc)
|
||||
resetButton.Position = UDim2.new(0.5,-100,0,this.ResumeButton.AbsolutePosition.Y + this.ResumeButton.AbsoluteSize.Y + BUTTON_SPACING)
|
||||
resetButton.Parent = this.Page
|
||||
|
||||
local leaveGameFunc = function()
|
||||
this.HubRef:SwitchToPage(this.HubRef.LeaveGamePage, false, 1)
|
||||
end
|
||||
|
||||
local leaveButton = utility:MakeStyledButton("LeaveButton", "Leave Game", UDim2.new(0, 200, 0, 50), leaveGameFunc)
|
||||
leaveButton.Position = UDim2.new(0.5,-100,0,resetButton.AbsolutePosition.Y + resetButton.AbsoluteSize.Y + BUTTON_SPACING)
|
||||
leaveButton.Parent = this.Page
|
||||
|
||||
this.Page.Size = UDim2.new(1,0,0,leaveButton.AbsolutePosition.Y + leaveButton.AbsoluteSize.Y)
|
||||
|
||||
return this
|
||||
end
|
||||
|
||||
|
||||
----------- Public Facing API Additions --------------
|
||||
do
|
||||
PageInstance = Initialize()
|
||||
PageInstance.Displayed.Event:connect(function()
|
||||
if not utility:UsesSelectedObject() then return end
|
||||
GuiService.SelectedCoreObject = PageInstance.ResumeButton
|
||||
end)
|
||||
end
|
||||
return PageInstance
|
||||
120
client/common/content/scripts/Modules/LeaveGame.lua
Normal file
120
client/common/content/scripts/Modules/LeaveGame.lua
Normal file
@@ -0,0 +1,120 @@
|
||||
--[[
|
||||
Filename: LeaveGame.lua
|
||||
Written by: jeditkacheff
|
||||
Version 1.0
|
||||
Description: Takes care of the leave game in Settings Menu
|
||||
--]]
|
||||
|
||||
|
||||
-------------- CONSTANTS -------------
|
||||
local LEAVE_GAME_ACTION = "LeaveGameCancelAction"
|
||||
|
||||
-------------- SERVICES --------------
|
||||
local CoreGui = game:GetService("CoreGui")
|
||||
local ContextActionService = game:GetService("ContextActionService")
|
||||
local RobloxGui = CoreGui:WaitForChild("RobloxGui")
|
||||
local GuiService = game:GetService("GuiService")
|
||||
|
||||
----------- UTILITIES --------------
|
||||
local utility = require(RobloxGui.Modules.Utility)
|
||||
|
||||
------------ Variables -------------------
|
||||
local PageInstance = nil
|
||||
RobloxGui:WaitForChild("Modules"):WaitForChild("TenFootInterface")
|
||||
local isTenFootInterface = require(RobloxGui.Modules.TenFootInterface):IsEnabled()
|
||||
|
||||
|
||||
----------- CLASS DECLARATION --------------
|
||||
|
||||
local function Initialize()
|
||||
local settingsPageFactory = require(RobloxGui.Modules.SettingsPageFactory)
|
||||
local this = settingsPageFactory:CreateNewPage()
|
||||
|
||||
this.DontLeaveFunc = function(isUsingGamepad)
|
||||
if this.HubRef then
|
||||
this.HubRef:PopMenu(isUsingGamepad, true)
|
||||
end
|
||||
end
|
||||
this.DontLeaveFromHotkey = function(name, state, input)
|
||||
if state == Enum.UserInputState.Begin then
|
||||
local isUsingGamepad = input.UserInputType == Enum.UserInputType.Gamepad1 or input.UserInputType == Enum.UserInputType.Gamepad2
|
||||
or input.UserInputType == Enum.UserInputType.Gamepad3 or input.UserInputType == Enum.UserInputType.Gamepad4
|
||||
|
||||
this.DontLeaveFunc(isUsingGamepad)
|
||||
end
|
||||
end
|
||||
this.DontLeaveFromButton = function(isUsingGamepad)
|
||||
this.DontLeaveFunc(isUsingGamepad)
|
||||
end
|
||||
|
||||
------ TAB CUSTOMIZATION -------
|
||||
this.TabHeader = nil -- no tab for this page
|
||||
|
||||
------ PAGE CUSTOMIZATION -------
|
||||
this.Page.Name = "LeaveGamePage"
|
||||
|
||||
local leaveGameText = utility:Create'TextLabel'
|
||||
{
|
||||
Name = "LeaveGameText",
|
||||
Text = "Are you sure you want to leave the game?",
|
||||
Font = Enum.Font.SourceSansBold,
|
||||
FontSize = Enum.FontSize.Size36,
|
||||
TextColor3 = Color3.new(1,1,1),
|
||||
BackgroundTransparency = 1,
|
||||
Size = UDim2.new(1,0,0,200),
|
||||
TextWrapped = true,
|
||||
ZIndex = 2,
|
||||
Parent = this.Page
|
||||
};
|
||||
if utility:IsSmallTouchScreen() then
|
||||
leaveGameText.FontSize = Enum.FontSize.Size24
|
||||
leaveGameText.Size = UDim2.new(1,0,0,100)
|
||||
elseif isTenFootInterface then
|
||||
leaveGameText.FontSize = Enum.FontSize.Size48
|
||||
end
|
||||
|
||||
local buttonSpacing = 20
|
||||
local buttonSize = UDim2.new(0, 200, 0, 50)
|
||||
if isTenFootInterface then
|
||||
leaveGameText.Position = UDim2.new(0,0,0,100)
|
||||
buttonSize = UDim2.new(0, 300, 0, 80)
|
||||
end
|
||||
|
||||
this.LeaveGameButton = utility:MakeStyledButton("LeaveGame", "Leave", buttonSize)
|
||||
this.LeaveGameButton.NextSelectionRight = nil
|
||||
this.LeaveGameButton:SetVerb("Exit")
|
||||
if utility:IsSmallTouchScreen() then
|
||||
this.LeaveGameButton.Position = UDim2.new(0.5, -buttonSize.X.Offset - buttonSpacing, 1, 0)
|
||||
else
|
||||
this.LeaveGameButton.Position = UDim2.new(0.5, -buttonSize.X.Offset - buttonSpacing, 1, -30)
|
||||
end
|
||||
this.LeaveGameButton.Parent = leaveGameText
|
||||
|
||||
|
||||
------------- Init ----------------------------------
|
||||
|
||||
local dontleaveGameButton = utility:MakeStyledButton("DontLeaveGame", "Don't Leave", buttonSize, this.DontLeaveFromButton)
|
||||
dontleaveGameButton.NextSelectionLeft = nil
|
||||
if utility:IsSmallTouchScreen() then
|
||||
dontleaveGameButton.Position = UDim2.new(0.5, buttonSpacing, 1, 0)
|
||||
else
|
||||
dontleaveGameButton.Position = UDim2.new(0.5, buttonSpacing, 1, -30)
|
||||
end
|
||||
dontleaveGameButton.Parent = leaveGameText
|
||||
|
||||
this.Page.Size = UDim2.new(1,0,0,dontleaveGameButton.AbsolutePosition.Y + dontleaveGameButton.AbsoluteSize.Y)
|
||||
|
||||
return this
|
||||
end
|
||||
|
||||
|
||||
----------- Public Facing API Additions --------------
|
||||
PageInstance = Initialize()
|
||||
PageInstance.Displayed.Event:connect(function()
|
||||
GuiService.SelectedCoreObject = PageInstance.LeaveGameButton
|
||||
ContextActionService:BindCoreAction(LEAVE_GAME_ACTION, PageInstance.DontLeaveFromHotkey, false, Enum.KeyCode.ButtonB)
|
||||
end)
|
||||
PageInstance.Hidden.Event:connect(function()
|
||||
ContextActionService:UnbindCoreAction(LEAVE_GAME_ACTION)
|
||||
end)
|
||||
return PageInstance
|
||||
632
client/common/content/scripts/Modules/PlayerDropDown.lua
Normal file
632
client/common/content/scripts/Modules/PlayerDropDown.lua
Normal file
@@ -0,0 +1,632 @@
|
||||
--[[
|
||||
// FileName: PlayerDropDown.lua
|
||||
// Written by: TheGamer101
|
||||
// Description: Code for the player drop down in the PlayerList and Chat
|
||||
]]
|
||||
local moduleApiTable = {}
|
||||
|
||||
--[[ Services ]]--
|
||||
local CoreGui = game:GetService('CoreGui')
|
||||
local HttpService = game:GetService('HttpService')
|
||||
local HttpRbxApiService = game:GetService('HttpRbxApiService')
|
||||
local PlayersService = game:GetService('Players')
|
||||
|
||||
--[[ Script Variables ]]--
|
||||
local LocalPlayer = PlayersService.LocalPlayer
|
||||
|
||||
--[[ Constants ]]--
|
||||
local POPUP_ENTRY_SIZE_Y = 24
|
||||
local ENTRY_PAD = 2
|
||||
local BG_TRANSPARENCY = 0.5
|
||||
local BG_COLOR = Color3.new(31/255, 31/255, 31/255)
|
||||
local TEXT_STROKE_TRANSPARENCY = 0.75
|
||||
local TEXT_COLOR = Color3.new(1, 1, 243/255)
|
||||
local TEXT_STROKE_COLOR = Color3.new(34/255, 34/255, 34/255)
|
||||
local MAX_FRIEND_COUNT = 200
|
||||
local FRIEND_IMAGE = 'http://www.roblox.com/thumbs/avatar.ashx?userId='
|
||||
|
||||
--[[ Fast Flags ]]--
|
||||
local followerSuccess, isFollowersEnabled = pcall(function() return settings():GetFFlag("EnableLuaFollowers") end)
|
||||
local IsFollowersEnabled = followerSuccess and isFollowersEnabled
|
||||
|
||||
local serverFollowersSuccess, serverFollowersEnabled = pcall(function() return settings():GetFFlag("UserServerFollowers") end)
|
||||
local IsServerFollowers = serverFollowersSuccess and serverFollowersEnabled
|
||||
|
||||
--[[ Modules ]]--
|
||||
local RobloxGui = CoreGui:WaitForChild('RobloxGui')
|
||||
local settingsHub = nil
|
||||
|
||||
spawn(function()
|
||||
settingsHub = require(RobloxGui:WaitForChild("Modules"):WaitForChild("SettingsHub"))
|
||||
end)
|
||||
|
||||
--[[ Bindables ]]--
|
||||
local BinbableFunction_SendNotification = nil
|
||||
spawn(function()
|
||||
BinbableFunction_SendNotification = RobloxGui:WaitForChild("SendNotification")
|
||||
end)
|
||||
|
||||
--[[ Remotes ]]--
|
||||
local RemoteEvent_NewFollower = nil
|
||||
|
||||
spawn(function()
|
||||
local RobloxReplicatedStorage = game:GetService('RobloxReplicatedStorage')
|
||||
RemoteEvent_NewFollower = RobloxReplicatedStorage:WaitForChild('NewFollower')
|
||||
end)
|
||||
|
||||
--[[ Utility Functions ]]--
|
||||
local function createSignal()
|
||||
local sig = {}
|
||||
|
||||
local mSignaler = Instance.new('BindableEvent')
|
||||
|
||||
local mArgData = nil
|
||||
local mArgDataCount = nil
|
||||
|
||||
function sig:fire(...)
|
||||
mArgData = {...}
|
||||
mArgDataCount = select('#', ...)
|
||||
mSignaler:Fire()
|
||||
end
|
||||
|
||||
function sig:connect(f)
|
||||
if not f then error("connect(nil)", 2) end
|
||||
return mSignaler.Event:connect(function()
|
||||
f(unpack(mArgData, 1, mArgDataCount))
|
||||
end)
|
||||
end
|
||||
|
||||
function sig:wait()
|
||||
mSignaler.Event:wait()
|
||||
assert(mArgData, "Missing arg data, likely due to :TweenSize/Position corrupting threadrefs.")
|
||||
return unpack(mArgData, 1, mArgDataCount)
|
||||
end
|
||||
|
||||
return sig
|
||||
end
|
||||
|
||||
--[[ Events ]]--
|
||||
local BlockStatusChanged = createSignal()
|
||||
|
||||
--[[ Personal Server Stuff ]]--
|
||||
local IsPersonalServer = false
|
||||
local PersonalServerService = nil
|
||||
if game.Workspace:FindFirstChild('PSVariable') then
|
||||
IsPersonalServer = true
|
||||
PersonalServerService = game:GetService('PersonalServerService')
|
||||
end
|
||||
game.Workspace.ChildAdded:connect(function(child)
|
||||
if child.Name == 'PSVariable' and child:IsA('BoolValue') then
|
||||
IsPersonalServer = true
|
||||
PersonalServerService = game:GetService('PersonalServerService')
|
||||
end
|
||||
end)
|
||||
|
||||
local PRIVILEGE_LEVEL = {
|
||||
OWNER = 255,
|
||||
ADMIN = 240,
|
||||
MEMBER = 128,
|
||||
VISITOR = 10,
|
||||
BANNED = 0,
|
||||
}
|
||||
|
||||
local function onPrivilegeLevelSelect(player, rank)
|
||||
while player.PersonalServerRank < rank do
|
||||
PersonalServerService:Promote(player)
|
||||
end
|
||||
while player.PersonalServerRank > rank do
|
||||
PersonalServerService:Demote(player)
|
||||
end
|
||||
end
|
||||
|
||||
--[[ Follower Notifications ]]--
|
||||
local function sendNotification(title, text, image, duration, callback)
|
||||
if BinbableFunction_SendNotification then
|
||||
BinbableFunction_SendNotification:Invoke(title, text, image, duration, callback)
|
||||
end
|
||||
end
|
||||
|
||||
--[[ Friend Functions ]]--
|
||||
local function getFriendStatus(selectedPlayer)
|
||||
if selectedPlayer == LocalPlayer then
|
||||
return Enum.FriendStatus.NotFriend
|
||||
else
|
||||
local success, result = pcall(function()
|
||||
-- NOTE: Core script only
|
||||
return LocalPlayer:GetFriendStatus(selectedPlayer)
|
||||
end)
|
||||
if success then
|
||||
return result
|
||||
else
|
||||
return Enum.FriendStatus.NotFriend
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- if userId = nil, then it will get count for local player
|
||||
local function getFriendCountAsync(userId)
|
||||
local friendCount = nil
|
||||
local wasSuccess, result = pcall(function()
|
||||
local str = 'user/get-friendship-count'
|
||||
if userId then
|
||||
str = str..'?userId='..tostring(userId)
|
||||
end
|
||||
return HttpRbxApiService:GetAsync(str, true)
|
||||
end)
|
||||
if not wasSuccess then
|
||||
print("getFriendCountAsync() failed because", result)
|
||||
return nil
|
||||
end
|
||||
result = HttpService:JSONDecode(result)
|
||||
|
||||
if result["success"] and result["count"] then
|
||||
friendCount = result["count"]
|
||||
end
|
||||
|
||||
return friendCount
|
||||
end
|
||||
|
||||
-- checks if we can send a friend request. Right now the only way we
|
||||
-- can't is if one of the players is at the max friend limit
|
||||
local function canSendFriendRequestAsync(otherPlayer)
|
||||
local theirFriendCount = getFriendCountAsync(otherPlayer.userId)
|
||||
local myFriendCount = getFriendCountAsync()
|
||||
|
||||
-- assume max friends if web call fails
|
||||
if not myFriendCount or not theirFriendCount then
|
||||
return false
|
||||
end
|
||||
if myFriendCount < MAX_FRIEND_COUNT and theirFriendCount < MAX_FRIEND_COUNT then
|
||||
return true
|
||||
elseif myFriendCount >= MAX_FRIEND_COUNT then
|
||||
sendNotification("Cannot send friend request", "You are at the max friends limit.", "", 5, function() end)
|
||||
return false
|
||||
elseif theirFriendCount >= MAX_FRIEND_COUNT then
|
||||
sendNotification("Cannot send friend request", otherPlayer.Name.." is at the max friends limit.", "", 5, function() end)
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
--[[ Follower Functions ]]--
|
||||
|
||||
-- Returns whether followerUserId is following userId
|
||||
local function isFollowing(userId, followerUserId)
|
||||
local apiPath = "user/following-exists?userId="
|
||||
local params = userId.."&followerUserId="..followerUserId
|
||||
local success, result = pcall(function()
|
||||
return HttpRbxApiService:GetAsync(apiPath..params, true)
|
||||
end)
|
||||
if not success then
|
||||
print("isFollowing() failed because", result)
|
||||
return false
|
||||
end
|
||||
|
||||
-- can now parse web response
|
||||
result = HttpService:JSONDecode(result)
|
||||
return result["success"] and result["isFollowing"]
|
||||
end
|
||||
|
||||
--[[ Functions for Blocking users ]]--
|
||||
local BlockedList = {}
|
||||
local MutedList = {}
|
||||
|
||||
local function GetBlockedPlayersAsync()
|
||||
local userId = LocalPlayer.userId
|
||||
local apiPath = "userblock/getblockedusers" .. "?" .. "userId=" .. tostring(userId) .. "&" .. "page=" .. "1"
|
||||
if userId > 0 then
|
||||
local blockList = nil
|
||||
local success, msg = pcall(function()
|
||||
local request = HttpRbxApiService:GetAsync(apiPath)
|
||||
blockList = request and game:GetService('HttpService'):JSONDecode(request)
|
||||
end)
|
||||
if blockList and blockList['success'] == true and blockList['userList'] then
|
||||
return blockList['userList']
|
||||
end
|
||||
end
|
||||
return {}
|
||||
end
|
||||
|
||||
spawn(function()
|
||||
BlockedList = GetBlockedPlayersAsync()
|
||||
end)
|
||||
|
||||
local function isBlocked(userId)
|
||||
if (BlockedList[userId] ~= nil and BlockedList[userId] == true) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function isMuted(userId)
|
||||
if (MutedList[userId] ~= nil and MutedList[userId] == true) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function BlockPlayerAsync(playerToBlock)
|
||||
if playerToBlock and LocalPlayer ~= playerToBlock then
|
||||
local blockUserId = playerToBlock.UserId
|
||||
if blockUserId > 0 then
|
||||
if not isBlocked(blockUserId) then
|
||||
BlockedList[blockUserId] = true
|
||||
BlockStatusChanged:fire(blockUserId, true)
|
||||
pcall(function()
|
||||
local success = PlayersService:BlockUser(LocalPlayer.userId, blockUserId)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function UnblockPlayerAsync(playerToUnblock)
|
||||
if playerToUnblock then
|
||||
local unblockUserId = playerToUnblock.userId
|
||||
|
||||
if isBlocked(unblockUserId) then
|
||||
BlockedList[unblockUserId] = nil
|
||||
BlockStatusChanged:fire(unblockUserId, false)
|
||||
pcall(function()
|
||||
local success = PlayersService:UnblockUser(LocalPlayer.userId, unblockUserId)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function MutePlayer(playerToMute)
|
||||
if playerToMute and LocalPlayer ~= playerToMute then
|
||||
local muteUserId = playerToMute.UserId
|
||||
if muteUserId > 0 then
|
||||
if not isMuted(muteUserId) then
|
||||
MutedList[muteUserId] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function UnmutePlayer(playerToUnmute)
|
||||
if playerToUnmute then
|
||||
local unmuteUserId = playerToUnmute.UserId
|
||||
MutedList[unmuteUserId] = nil
|
||||
end
|
||||
end
|
||||
|
||||
--[[ Function to create DropDown class ]]--
|
||||
function createPlayerDropDown()
|
||||
local playerDropDown = {}
|
||||
playerDropDown.Player = nil
|
||||
playerDropDown.PopupFrame = nil
|
||||
playerDropDown.HidePopupImmediately = false
|
||||
playerDropDown.PopupFrameOffScreenPosition = nil -- if this is set the popup frame tweens to a different offscreen position than the default
|
||||
|
||||
playerDropDown.HiddenSignal = createSignal()
|
||||
|
||||
--[[ Functions for when options in the dropdown are pressed ]]--
|
||||
local function onFriendButtonPressed()
|
||||
if playerDropDown.Player then
|
||||
local status = getFriendStatus(playerDropDown.Player)
|
||||
if status == Enum.FriendStatus.Friend then
|
||||
LocalPlayer:RevokeFriendship(playerDropDown.Player)
|
||||
elseif status == Enum.FriendStatus.Unknown or status == Enum.FriendStatus.NotFriend then
|
||||
-- cache and spawn
|
||||
local cachedLastSelectedPlayer = playerDropDown.Player
|
||||
spawn(function()
|
||||
-- check for max friends before letting them send the request
|
||||
if canSendFriendRequestAsync(cachedLastSelectedPlayer) then -- Yields
|
||||
if cachedLastSelectedPlayer and cachedLastSelectedPlayer.Parent == PlayersService then
|
||||
LocalPlayer:RequestFriendship(cachedLastSelectedPlayer)
|
||||
end
|
||||
end
|
||||
end)
|
||||
elseif status == Enum.FriendStatus.FriendRequestSent then
|
||||
LocalPlayer:RevokeFriendship(playerDropDown.Player)
|
||||
elseif status == Enum.FriendStatus.FriendRequestReceived then
|
||||
LocalPlayer:RequestFriendship(playerDropDown.Player)
|
||||
end
|
||||
|
||||
playerDropDown:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
local function onDeclineFriendButonPressed()
|
||||
if playerDropDown.Player then
|
||||
LocalPlayer:RevokeFriendship(playerDropDown.Player)
|
||||
playerDropDown:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
-- Client unfollows followedUserId
|
||||
local function onUnfollowButtonPressed()
|
||||
if not playerDropDown.Player then return end
|
||||
--
|
||||
local apiPath = "user/unfollow"
|
||||
local params = "followedUserId="..tostring(playerDropDown.Player.userId)
|
||||
local success, result = pcall(function()
|
||||
return HttpRbxApiService:PostAsync(apiPath, params, true, Enum.ThrottlingPriority.Default, Enum.HttpContentType.ApplicationUrlEncoded)
|
||||
end)
|
||||
if not success then
|
||||
print("unfollowPlayer() failed because", result)
|
||||
playerDropDown:Hide()
|
||||
return
|
||||
end
|
||||
|
||||
result = HttpService:JSONDecode(result)
|
||||
if result["success"] then
|
||||
if RemoteEvent_NewFollower then
|
||||
RemoteEvent_NewFollower:FireServer(playerDropDown.Player, false)
|
||||
end
|
||||
moduleApiTable.FollowerStatusChanged:fire()
|
||||
end
|
||||
|
||||
playerDropDown:Hide()
|
||||
-- no need to send notification when someone unfollows
|
||||
end
|
||||
|
||||
local function onBlockButtonPressed()
|
||||
if playerDropDown.Player then
|
||||
local cachedPlayer = playerDropDown.Player
|
||||
spawn(function()
|
||||
BlockPlayerAsync(cachedPlayer)
|
||||
end)
|
||||
playerDropDown:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
local function onUnblockButtonPressed()
|
||||
if playerDropDown.Player then
|
||||
local cachedPlayer = playerDropDown.Player
|
||||
spawn(function()
|
||||
UnblockPlayerAsync(cachedPlayer)
|
||||
end)
|
||||
playerDropDown:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
local function onReportButtonPressed()
|
||||
if playerDropDown.Player then
|
||||
settingsHub:ReportPlayer(playerDropDown.Player)
|
||||
playerDropDown:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
-- Client follows followedUserId
|
||||
local function onFollowButtonPressed()
|
||||
if not playerDropDown.Player then return end
|
||||
--
|
||||
local followedUserId = tostring(playerDropDown.Player.userId)
|
||||
local apiPath = "user/follow"
|
||||
local params = "followedUserId="..followedUserId
|
||||
local success, result = pcall(function()
|
||||
return HttpRbxApiService:PostAsync(apiPath, params, true, Enum.ThrottlingPriority.Default, Enum.HttpContentType.ApplicationUrlEncoded)
|
||||
end)
|
||||
if not success then
|
||||
print("followPlayer() failed because", result)
|
||||
playerDropDown:Hide()
|
||||
return
|
||||
end
|
||||
|
||||
result = HttpService:JSONDecode(result)
|
||||
if result["success"] then
|
||||
sendNotification("You are", "now following "..playerDropDown.Player.Name, FRIEND_IMAGE..followedUserId.."&x=48&y=48", 5, function() end)
|
||||
if RemoteEvent_NewFollower then
|
||||
RemoteEvent_NewFollower:FireServer(playerDropDown.Player, true)
|
||||
end
|
||||
moduleApiTable.FollowerStatusChanged:fire()
|
||||
end
|
||||
|
||||
playerDropDown:Hide()
|
||||
end
|
||||
|
||||
--[[ GUI Creation Functions ]]--
|
||||
local function createPersonalServerDialog(buttons, selectedPlayer)
|
||||
local showPersonalServerRanks = IsPersonalServer and LocalPlayer.PersonalServerRank >= PRIVILEGE_LEVEL.ADMIN and LocalPlayer.PersonalServerRank > selectedPlayer.PersonalServerRank
|
||||
if showPersonalServerRanks then
|
||||
table.insert(buttons, {
|
||||
Name = "BanButton",
|
||||
Text = "Ban",
|
||||
OnPress = function()
|
||||
playerDropDown:Hide()
|
||||
onPrivilegeLevelSelect(selectedPlayer, PRIVILEGE_LEVEL.BANNED)
|
||||
end,
|
||||
})
|
||||
table.insert(buttons, {
|
||||
Name = "VistorButton",
|
||||
Text = "Visitor",
|
||||
OnPress = function()
|
||||
onPrivilegeLevelSelect(selectedPlayer, PRIVILEGE_LEVEL.VISITOR)
|
||||
end,
|
||||
})
|
||||
table.insert(buttons, {
|
||||
Name = "MemberButton",
|
||||
Text = "Member",
|
||||
OnPress = function()
|
||||
onPrivilegeLevelSelect(selectedPlayer, PRIVILEGE_LEVEL.MEMBER)
|
||||
end,
|
||||
})
|
||||
table.insert(buttons, {
|
||||
Name = "AdminButton",
|
||||
Text = "Admin",
|
||||
OnPress = function()
|
||||
onPrivilegeLevelSelect(selectedPlayer, PRIVILEGE_LEVEL.ADMIN)
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
local function createPopupFrame(buttons)
|
||||
local frame = Instance.new('Frame')
|
||||
frame.Name = "PopupFrame"
|
||||
frame.Size = UDim2.new(1, 0, 0, (POPUP_ENTRY_SIZE_Y * #buttons) + (#buttons - ENTRY_PAD))
|
||||
frame.Position = UDim2.new(1, 1, 0, 0)
|
||||
frame.BackgroundTransparency = 1
|
||||
|
||||
for i,button in ipairs(buttons) do
|
||||
local btn = Instance.new('TextButton')
|
||||
btn.Name = button.Name
|
||||
btn.Size = UDim2.new(1, 0, 0, POPUP_ENTRY_SIZE_Y)
|
||||
btn.Position = UDim2.new(0, 0, 0, POPUP_ENTRY_SIZE_Y * (i - 1) + ((i - 1) * ENTRY_PAD))
|
||||
btn.BackgroundTransparency = BG_TRANSPARENCY
|
||||
btn.BackgroundColor3 = BG_COLOR
|
||||
btn.BorderSizePixel = 0
|
||||
btn.Text = button.Text
|
||||
btn.Font = Enum.Font.SourceSans
|
||||
btn.FontSize = Enum.FontSize.Size14
|
||||
btn.TextColor3 = TEXT_COLOR
|
||||
btn.TextStrokeTransparency = TEXT_STROKE_TRANSPARENCY
|
||||
btn.TextStrokeColor3 = TEXT_STROKE_COLOR
|
||||
btn.AutoButtonColor = true
|
||||
btn.Parent = frame
|
||||
|
||||
btn.MouseButton1Click:connect(button.OnPress)
|
||||
end
|
||||
|
||||
return frame
|
||||
end
|
||||
|
||||
--[[ PlayerDropDown Functions ]]--
|
||||
function playerDropDown:Hide()
|
||||
if playerDropDown.PopupFrame then
|
||||
local offscreenPosition = (playerDropDown.PopupFrameOffScreenPosition ~= nil and playerDropDown.PopupFrameOffScreenPosition or UDim2.new(1, 1, 0, playerDropDown.PopupFrame.Position.Y.Offset))
|
||||
if not playerDropDown.HidePopupImmediately then
|
||||
playerDropDown.PopupFrame:TweenPosition(offscreenPosition, Enum.EasingDirection.InOut,
|
||||
Enum.EasingStyle.Quad, TWEEN_TIME, true, function()
|
||||
if playerDropDown.PopupFrame then
|
||||
playerDropDown.PopupFrame:Destroy()
|
||||
playerDropDown.PopupFrame = nil
|
||||
end
|
||||
end)
|
||||
else
|
||||
playerDropDown.PopupFrame:Destroy()
|
||||
playerDropDown.PopupFrame = nil
|
||||
end
|
||||
end
|
||||
if playerDropDown.Player then
|
||||
playerDropDown.Player = nil
|
||||
end
|
||||
playerDropDown.HiddenSignal:fire()
|
||||
end
|
||||
|
||||
function playerDropDown:CreatePopup(Player)
|
||||
playerDropDown.Player = Player
|
||||
|
||||
local buttons = {}
|
||||
|
||||
local status = getFriendStatus(playerDropDown.Player)
|
||||
local friendText = ""
|
||||
local canDeclineFriend = false
|
||||
if status == Enum.FriendStatus.Friend then
|
||||
friendText = "Unfriend Player"
|
||||
elseif status == Enum.FriendStatus.Unknown or status == Enum.FriendStatus.NotFriend then
|
||||
friendText = "Send Friend Request"
|
||||
elseif status == Enum.FriendStatus.FriendRequestSent then
|
||||
friendText = "Revoke Friend Request"
|
||||
elseif status == Enum.FriendStatus.FriendRequestReceived then
|
||||
friendText = "Accept Friend Request"
|
||||
canDeclineFriend = true
|
||||
end
|
||||
|
||||
local blocked = isBlocked(playerDropDown.Player.userId)
|
||||
|
||||
if not blocked then
|
||||
table.insert(buttons, {
|
||||
Name = "FriendButton",
|
||||
Text = friendText,
|
||||
OnPress = onFriendButtonPressed,
|
||||
})
|
||||
end
|
||||
|
||||
if canDeclineFriend and not blocked then
|
||||
table.insert(buttons, {
|
||||
Name = "DeclineFriend",
|
||||
Text = "Decline Friend Request",
|
||||
OnPress = onDeclineFriendButonPressed,
|
||||
})
|
||||
end
|
||||
-- following status
|
||||
if IsServerFollowers or IsFollowersEnabled then
|
||||
local following = isFollowing(playerDropDown.Player.userId, LocalPlayer.userId)
|
||||
local followerText = following and "Unfollow Player" or "Follow Player"
|
||||
|
||||
if not blocked then
|
||||
table.insert(buttons, {
|
||||
Name = "FollowerButton",
|
||||
Text = followerText,
|
||||
OnPress = following and onUnfollowButtonPressed or onFollowButtonPressed,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
local blockedText = blocked and "Unblock Player" or "Block Player"
|
||||
table.insert(buttons, {
|
||||
Name = "BlockButton",
|
||||
Text = blockedText,
|
||||
OnPress = blocked and onUnblockButtonPressed or onBlockButtonPressed,
|
||||
})
|
||||
table.insert(buttons, {
|
||||
Name = "ReportButton",
|
||||
Text = "Report Abuse",
|
||||
OnPress = onReportButtonPressed,
|
||||
})
|
||||
|
||||
createPersonalServerDialog(buttons, playerDropDown.Player)
|
||||
if playerDropDown.PopupFrame then
|
||||
playerDropDown.PopupFrame:Destroy()
|
||||
end
|
||||
playerDropDown.PopupFrame = createPopupFrame(buttons)
|
||||
return playerDropDown.PopupFrame
|
||||
end
|
||||
|
||||
--[[ PlayerRemoving Connection ]]--
|
||||
PlayersService.PlayerRemoving:connect(function(leavingPlayer)
|
||||
if playerDropDown.Player == leavingPlayer then
|
||||
playerDropDown:Hide()
|
||||
end
|
||||
end)
|
||||
|
||||
return playerDropDown
|
||||
end
|
||||
|
||||
|
||||
do
|
||||
moduleApiTable.FollowerStatusChanged = createSignal()
|
||||
|
||||
function moduleApiTable:CreatePlayerDropDown()
|
||||
return createPlayerDropDown()
|
||||
end
|
||||
|
||||
function moduleApiTable:CreateBlockingUtility()
|
||||
local blockingUtility = {}
|
||||
|
||||
function blockingUtility:BlockPlayerAsync(player)
|
||||
return BlockPlayerAsync(player)
|
||||
end
|
||||
|
||||
function blockingUtility:UnblockPlayerAsync(player)
|
||||
return UnblockPlayerAsync(player)
|
||||
end
|
||||
|
||||
function blockingUtility:MutePlayer(player)
|
||||
return MutePlayer(player)
|
||||
end
|
||||
|
||||
function blockingUtility:UnmutePlayer(player)
|
||||
return UnmutePlayer(player)
|
||||
end
|
||||
|
||||
function blockingUtility:IsPlayerBlockedByUserId(userId)
|
||||
return isBlocked(userId)
|
||||
end
|
||||
|
||||
function blockingUtility:GetBlockedStatusChangedEvent()
|
||||
return BlockStatusChanged
|
||||
end
|
||||
|
||||
function blockingUtility:IsPlayerMutedByUserId(userId)
|
||||
return isMuted(userId)
|
||||
end
|
||||
|
||||
return blockingUtility
|
||||
end
|
||||
end
|
||||
|
||||
return moduleApiTable
|
||||
1764
client/common/content/scripts/Modules/PlayerlistModule.lua
Normal file
1764
client/common/content/scripts/Modules/PlayerlistModule.lua
Normal file
File diff suppressed because it is too large
Load Diff
304
client/common/content/scripts/Modules/Players.lua
Normal file
304
client/common/content/scripts/Modules/Players.lua
Normal file
@@ -0,0 +1,304 @@
|
||||
--[[
|
||||
Filename: Players.lua
|
||||
Written by: Stickmasterluke
|
||||
Version 1.0
|
||||
Description: Player list inside escape menu, with friend adding functionality.
|
||||
--]]
|
||||
-------------- SERVICES --------------
|
||||
local CoreGui = game:GetService("CoreGui")
|
||||
local RobloxGui = CoreGui:WaitForChild("RobloxGui")
|
||||
local GuiService = game:GetService("GuiService")
|
||||
local PlayersService = game:GetService('Players')
|
||||
local HttpService = game:GetService('HttpService')
|
||||
local HttpRbxApiService = game:GetService('HttpRbxApiService')
|
||||
local UserInputService = game:GetService('UserInputService')
|
||||
local Settings = UserSettings()
|
||||
local GameSettings = Settings.GameSettings
|
||||
|
||||
----------- UTILITIES --------------
|
||||
RobloxGui:WaitForChild("Modules"):WaitForChild("TenFootInterface")
|
||||
local utility = require(RobloxGui.Modules.Utility)
|
||||
local isTenFootInterface = require(RobloxGui.Modules.TenFootInterface):IsEnabled()
|
||||
|
||||
------------ Constants -------------------
|
||||
local frameDefaultTransparency = .85
|
||||
local frameSelectedTransparency = .65
|
||||
|
||||
------------ Variables -------------------
|
||||
local PageInstance = nil
|
||||
local localPlayer = PlayersService.LocalPlayer
|
||||
|
||||
----------- CLASS DECLARATION --------------
|
||||
local function Initialize()
|
||||
local settingsPageFactory = require(RobloxGui.Modules.SettingsPageFactory)
|
||||
local this = settingsPageFactory:CreateNewPage()
|
||||
|
||||
local playerLabelFakeSelection = Instance.new('ImageLabel')
|
||||
playerLabelFakeSelection.BackgroundTransparency = 1
|
||||
--[[playerLabelFakeSelection.Image = 'ayaasset://textures/ui/SelectionBox.png'
|
||||
playerLabelFakeSelection.ScaleType = 'Slice'
|
||||
playerLabelFakeSelection.SliceCenter = Rect.new(31,31,31,31)]]
|
||||
playerLabelFakeSelection.Image = ''
|
||||
playerLabelFakeSelection.Size = UDim2.new(0,0,0,0)
|
||||
|
||||
------ TAB CUSTOMIZATION -------
|
||||
this.TabHeader.Name = "PlayersTab"
|
||||
|
||||
this.TabHeader.Icon.Image = "ayaasset://textures/ui/Settings/MenuBarIcons/PlayersTabIcon.png"
|
||||
if utility:IsSmallTouchScreen() then
|
||||
this.TabHeader.Icon.Size = UDim2.new(0,34,0,28)
|
||||
this.TabHeader.Icon.Position = UDim2.new(this.TabHeader.Icon.Position.X.Scale,this.TabHeader.Icon.Position.X.Offset,0.5,-14)
|
||||
this.TabHeader.Size = UDim2.new(0,115,1,0)
|
||||
elseif isTenFootInterface then
|
||||
this.TabHeader.Icon.Image = "ayaasset://textures/ui/Settings/MenuBarIcons/PlayersTabIcon@2x.png"
|
||||
this.TabHeader.Icon.Size = UDim2.new(0,88,0,74)
|
||||
this.TabHeader.Icon.Position = UDim2.new(0,0,0.5,-43)
|
||||
this.TabHeader.Size = UDim2.new(0,280,1,0)
|
||||
else
|
||||
this.TabHeader.Icon.Size = UDim2.new(0,44,0,37)
|
||||
this.TabHeader.Icon.Position = UDim2.new(0,15,0.5,-18) -- -22
|
||||
this.TabHeader.Size = UDim2.new(0,150,1,0)
|
||||
end
|
||||
|
||||
this.TabHeader.Icon.Title.Text = "Players"
|
||||
|
||||
----- FRIENDSHIP FUNCTIONS ------
|
||||
local function getFriendStatus(selectedPlayer)
|
||||
if selectedPlayer == localPlayer then
|
||||
return Enum.FriendStatus.NotFriend
|
||||
else
|
||||
local success, result = pcall(function()
|
||||
-- NOTE: Core script only
|
||||
return localPlayer:GetFriendStatus(selectedPlayer)
|
||||
end)
|
||||
if success then
|
||||
return result
|
||||
else
|
||||
return Enum.FriendStatus.NotFriend
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
------ PAGE CUSTOMIZATION -------
|
||||
this.Page.Name = "Players"
|
||||
|
||||
local selectionFound = nil
|
||||
local function friendStatusCreate(playerLabel, player)
|
||||
if playerLabel then
|
||||
-- remove any previous friend status labels
|
||||
for _, item in pairs(playerLabel:GetChildren()) do
|
||||
if item and item.Name == 'FriendStatus' then
|
||||
if GuiService.SelectedCoreObject == item then
|
||||
selectionFound = nil
|
||||
GuiService.SelectedCoreObject = nil
|
||||
end
|
||||
item:Destroy()
|
||||
end
|
||||
end
|
||||
|
||||
-- create new friend status label
|
||||
local status = nil
|
||||
if player and player ~= localPlayer and player.userId > 1 and localPlayer.userId > 1 then
|
||||
status = getFriendStatus(player)
|
||||
end
|
||||
|
||||
local friendLabel = nil
|
||||
local friendLabelText = nil
|
||||
if not status then
|
||||
friendLabel = Instance.new('TextButton')
|
||||
friendLabel.Text = ''
|
||||
friendLabel.BackgroundTransparency = 1
|
||||
friendLabel.Position = UDim2.new(1,-198,0,7)
|
||||
elseif status == Enum.FriendStatus.Friend then
|
||||
friendLabel = Instance.new('TextButton')
|
||||
friendLabel.Text = 'Friend'
|
||||
friendLabel.BackgroundTransparency = 1
|
||||
friendLabel.FontSize = 'Size24'
|
||||
friendLabel.Font = 'SourceSans'
|
||||
friendLabel.TextColor3 = Color3.new(1,1,1)
|
||||
friendLabel.Position = UDim2.new(1,-198,0,7)
|
||||
elseif status == Enum.FriendStatus.Unknown or status == Enum.FriendStatus.NotFriend or status == Enum.FriendStatus.FriendRequestReceived then
|
||||
local addFriendFunc = function()
|
||||
if friendLabel and friendLabelText and friendLabelText.Text ~= '' then
|
||||
friendLabel.ImageTransparency = 1
|
||||
friendLabelText.Text = ''
|
||||
if localPlayer and player then
|
||||
localPlayer:RequestFriendship(player)
|
||||
end
|
||||
end
|
||||
end
|
||||
local friendLabel2, friendLabelText2 = utility:MakeStyledButton("FriendStatus", "Add Friend", UDim2.new(0, 182, 0, 46), addFriendFunc)
|
||||
friendLabel = friendLabel2
|
||||
friendLabelText = friendLabelText2
|
||||
friendLabelText.ZIndex = 3
|
||||
friendLabelText.Position = friendLabelText.Position + UDim2.new(0,0,0,1)
|
||||
friendLabel.Position = UDim2.new(1,-198,0,7)
|
||||
elseif status == Enum.FriendStatus.FriendRequestSent then
|
||||
friendLabel = Instance.new('TextButton')
|
||||
friendLabel.Text = 'Request Sent'
|
||||
friendLabel.BackgroundTransparency = 1
|
||||
friendLabel.FontSize = 'Size24'
|
||||
friendLabel.Font = 'SourceSans'
|
||||
friendLabel.TextColor3 = Color3.new(1,1,1)
|
||||
friendLabel.Position = UDim2.new(1,-198,0,7)
|
||||
end
|
||||
|
||||
if friendLabel then
|
||||
friendLabel.Name = 'FriendStatus'
|
||||
friendLabel.Size = UDim2.new(0,182,0,46)
|
||||
friendLabel.ZIndex = 3
|
||||
friendLabel.Parent = playerLabel
|
||||
friendLabel.SelectionImageObject = playerLabelFakeSelection
|
||||
|
||||
local updateHighlight = function()
|
||||
if playerLabel then
|
||||
playerLabel.ImageTransparency = friendLabel and GuiService.SelectedCoreObject == friendLabel and frameSelectedTransparency or frameDefaultTransparency
|
||||
end
|
||||
end
|
||||
friendLabel.SelectionGained:connect(updateHighlight)
|
||||
friendLabel.SelectionLost:connect(updateHighlight)
|
||||
|
||||
if UserInputService.GamepadEnabled and not selectionFound then
|
||||
selectionFound = true
|
||||
local fakeSize = 20
|
||||
playerLabelFakeSelection.Size = UDim2.new(0,playerLabel.AbsoluteSize.X+fakeSize,0,playerLabel.AbsoluteSize.Y+fakeSize)
|
||||
playerLabelFakeSelection.Position = UDim2.new(0, -(playerLabel.AbsoluteSize.X-198)-fakeSize*.5, 0, -8-fakeSize*.5)
|
||||
GuiService.SelectedCoreObject = friendLabel
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
localPlayer.FriendStatusChanged:connect(function(player, friendStatus)
|
||||
if player then
|
||||
local playerLabel = this.Page:FindFirstChild('PlayerLabel'..player.Name)
|
||||
if playerLabel then
|
||||
friendStatusCreate(playerLabel, player)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
if utility:IsSmallTouchScreen() then
|
||||
local spaceFor3Buttons = RobloxGui.AbsoluteSize.x >= 720 -- else there is only space for 2
|
||||
|
||||
local resetFunc = function()
|
||||
this.HubRef:SwitchToPage(this.HubRef.ResetCharacterPage, false, 1)
|
||||
end
|
||||
local resetButton, resetLabel = utility:MakeStyledButton("ResetButton", "Reset Character", UDim2.new(0, 200, 0, 62), resetFunc)
|
||||
resetLabel.Size = UDim2.new(1, 0, 1, -6)
|
||||
resetLabel.FontSize = Enum.FontSize.Size24
|
||||
resetButton.Position = UDim2.new(0.5,spaceFor3Buttons and -340 or -220,0,14)
|
||||
resetButton.Parent = this.Page
|
||||
|
||||
local leaveGameFunc = function()
|
||||
this.HubRef:SwitchToPage(this.HubRef.LeaveGamePage, false, 1)
|
||||
end
|
||||
local leaveButton, leaveLabel = utility:MakeStyledButton("LeaveButton", "Leave Game", UDim2.new(0, 200, 0, 62), leaveGameFunc)
|
||||
leaveLabel.Size = UDim2.new(1, 0, 1, -6)
|
||||
leaveLabel.FontSize = Enum.FontSize.Size24
|
||||
leaveButton.Position = UDim2.new(0.5,spaceFor3Buttons and -100 or 20,0,14)
|
||||
leaveButton.Parent = this.Page
|
||||
|
||||
if spaceFor3Buttons then
|
||||
local resumeGameFunc = function()
|
||||
this.HubRef:SetVisibility(false)
|
||||
end
|
||||
resumeButton, resumeLabel = utility:MakeStyledButton("ResumeButton", "Resume Game", UDim2.new(0, 200, 0, 62), resumeGameFunc)
|
||||
resumeLabel.Size = UDim2.new(1, 0, 1, -6)
|
||||
resumeLabel.FontSize = Enum.FontSize.Size24
|
||||
resumeButton.Position = UDim2.new(0.5,140,0,14)
|
||||
resumeButton.Parent = this.Page
|
||||
end
|
||||
end
|
||||
|
||||
local existingPlayerLabels = {}
|
||||
this.Displayed.Event:connect(function(switchedFromGamepadInput)
|
||||
local sortedPlayers = PlayersService:GetPlayers()
|
||||
table.sort(sortedPlayers,function(item1,item2)
|
||||
return item1.Name < item2.Name
|
||||
end)
|
||||
|
||||
local extraOffset = 20
|
||||
if utility:IsSmallTouchScreen() then
|
||||
extraOffset = 85
|
||||
end
|
||||
|
||||
selectionFound = nil
|
||||
|
||||
|
||||
-- iterate through players to reuse or create labels for players
|
||||
for index=1, #sortedPlayers do
|
||||
local player = sortedPlayers[index]
|
||||
local frame = existingPlayerLabels[index]
|
||||
if player then
|
||||
-- create label (frame) for this player index if one does not exist
|
||||
if not frame or not frame.Parent then
|
||||
frame = Instance.new('ImageLabel')
|
||||
frame.Image = "ayaasset://textures/ui/dialog_white.png"
|
||||
frame.ScaleType = 'Slice'
|
||||
frame.SliceCenter = Rect.new(10,10,10,10)
|
||||
frame.Size = UDim2.new(1,0,0,60)
|
||||
frame.Position = UDim2.new(0,0,0,(index-1)*80 + extraOffset)
|
||||
frame.BackgroundTransparency = 1
|
||||
frame.ZIndex = 2
|
||||
|
||||
local icon = Instance.new('ImageLabel')
|
||||
icon.Name = 'Icon'
|
||||
icon.BackgroundTransparency = 1
|
||||
icon.Size = UDim2.new(0,36,0,36)
|
||||
icon.Position = UDim2.new(0,12,0,12)
|
||||
icon.ZIndex = 3
|
||||
icon.Parent = frame
|
||||
|
||||
local nameLabel = Instance.new('TextLabel')
|
||||
nameLabel.Name = 'NameLabel'
|
||||
nameLabel.TextXAlignment = Enum.TextXAlignment.Left
|
||||
nameLabel.Font = 'SourceSans'
|
||||
nameLabel.FontSize = 'Size24'
|
||||
nameLabel.TextColor3 = Color3.new(1,1,1)
|
||||
nameLabel.BackgroundTransparency = 1
|
||||
nameLabel.Position = UDim2.new(0,60,.5,0)
|
||||
nameLabel.Size = UDim2.new(0,0,0,0)
|
||||
nameLabel.ZIndex = 3
|
||||
nameLabel.Parent = frame
|
||||
|
||||
frame.MouseEnter:connect(function()
|
||||
frame.ImageTransparency = frameSelectedTransparency
|
||||
end)
|
||||
frame.MouseLeave:connect(function()
|
||||
frame.ImageTransparency = frameDefaultTransparency
|
||||
end)
|
||||
|
||||
frame.Parent = this.Page
|
||||
table.insert(existingPlayerLabels, index, frame)
|
||||
end
|
||||
frame.Name = 'PlayerLabel'..player.Name
|
||||
frame.Icon.Image = 'http://www.kiseki.lol/Thumbs/Avatar.ashx?x=100&y=100&userId='..math.max(1, player.userId)
|
||||
frame.NameLabel.Text = player.Name
|
||||
frame.ImageTransparency = frameDefaultTransparency
|
||||
|
||||
friendStatusCreate(frame, player)
|
||||
end
|
||||
end
|
||||
|
||||
-- iterate through existing labels in reverse to destroy and remove unused labels
|
||||
for index=#existingPlayerLabels, 1, -1 do
|
||||
local player = sortedPlayers[index]
|
||||
local frame = existingPlayerLabels[index]
|
||||
if frame and not player then
|
||||
table.remove(existingPlayerLabels, i)
|
||||
frame:Destroy()
|
||||
end
|
||||
end
|
||||
|
||||
this.Page.Size = UDim2.new(1,0,0, extraOffset + 80 * #sortedPlayers - 5)
|
||||
end)
|
||||
|
||||
return this
|
||||
end
|
||||
|
||||
|
||||
----------- Public Facing API Additions --------------
|
||||
PageInstance = Initialize()
|
||||
return PageInstance
|
||||
281
client/common/content/scripts/Modules/ReportAbuseMenu.lua
Normal file
281
client/common/content/scripts/Modules/ReportAbuseMenu.lua
Normal file
@@ -0,0 +1,281 @@
|
||||
--[[
|
||||
Filename: ReportAbuseMenu.lua
|
||||
Written by: jeditkacheff
|
||||
Version 1.0
|
||||
Description: Takes care of the report abuse page in Settings Menu
|
||||
--]]
|
||||
|
||||
-------------- SERVICES --------------
|
||||
local CoreGui = game:GetService("CoreGui")
|
||||
local RobloxGui = CoreGui:WaitForChild("RobloxGui")
|
||||
local GuiService = game:GetService("GuiService")
|
||||
local PlayersService = game:GetService("Players")
|
||||
|
||||
----------- UTILITIES --------------
|
||||
local utility = require(RobloxGui.Modules.Utility)
|
||||
|
||||
------------ CONSTANTS -------------------
|
||||
local ABUSE_TYPES_PLAYER = {
|
||||
"Swearing",
|
||||
"Inappropriate Username",
|
||||
"Bullying",
|
||||
"Scamming",
|
||||
"Dating",
|
||||
"Cheating/Exploiting",
|
||||
"Personal Question",
|
||||
"Offsite Links",
|
||||
}
|
||||
|
||||
local ABUSE_TYPES_GAME = {
|
||||
"Inappropriate Content",
|
||||
"Bad Model or Script",
|
||||
"Offsite Link",
|
||||
}
|
||||
local DEFAULT_ABUSE_DESC_TEXT = " Short Description (Optional)"
|
||||
if utility:IsSmallTouchScreen() then
|
||||
DEFAULT_ABUSE_DESC_TEXT = " (Optional)"
|
||||
end
|
||||
|
||||
------------ VARIABLES -------------------
|
||||
local PageInstance = nil
|
||||
|
||||
----------- CLASS DECLARATION --------------
|
||||
local function Initialize()
|
||||
local settingsPageFactory = require(RobloxGui.Modules.SettingsPageFactory)
|
||||
local this = settingsPageFactory:CreateNewPage()
|
||||
|
||||
local playerNames = {}
|
||||
local nameToRbxPlayer = {}
|
||||
|
||||
function this:GetPlayerFromIndex(index)
|
||||
local playerName = playerNames[index]
|
||||
if playerName then
|
||||
return nameToRbxPlayer[nameToRbxPlayer]
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
function this:UpdatePlayerDropDown()
|
||||
playerNames = {}
|
||||
nameToRbxPlayer = {}
|
||||
|
||||
local players = PlayersService:GetPlayers()
|
||||
local index = 1
|
||||
for i = 1, #players do
|
||||
local player = players[i]
|
||||
if player ~= PlayersService.LocalPlayer and player.UserId > 0 then
|
||||
playerNames[index] = player.Name
|
||||
nameToRbxPlayer[player.Name] = player
|
||||
index = index + 1
|
||||
end
|
||||
end
|
||||
|
||||
this.WhichPlayerMode:UpdateDropDownList(playerNames)
|
||||
|
||||
if index == 1 then
|
||||
this.GameOrPlayerMode:SetSelectionIndex(1)
|
||||
this.TypeOfAbuseMode:UpdateDropDownList(ABUSE_TYPES_GAME)
|
||||
end
|
||||
|
||||
this.WhichPlayerMode:SetInteractable(index > 1 and this.GameOrPlayerMode.CurrentIndex ~= 1)
|
||||
this.GameOrPlayerMode:SetInteractable(index > 1)
|
||||
end
|
||||
|
||||
------ TAB CUSTOMIZATION -------
|
||||
this.TabHeader.Name = "ReportAbuseTab"
|
||||
|
||||
this.TabHeader.Icon.Image = "ayaasset://textures/ui/Settings/MenuBarIcons/ReportAbuseTab.png"
|
||||
if utility:IsSmallTouchScreen() then
|
||||
this.TabHeader.Icon.Size = UDim2.new(0,27,0,32)
|
||||
this.TabHeader.Size = UDim2.new(0,120,1,0)
|
||||
else
|
||||
this.TabHeader.Size = UDim2.new(0,150,1,0)
|
||||
this.TabHeader.Icon.Size = UDim2.new(0,36,0,43)
|
||||
end
|
||||
this.TabHeader.Icon.Position = UDim2.new(this.TabHeader.Icon.Position.X.Scale, this.TabHeader.Icon.Position.X.Offset + 10, 0.5,-this.TabHeader.Icon.Size.Y.Offset/2)
|
||||
|
||||
this.TabHeader.Icon.Title.Text = "Report"
|
||||
|
||||
------ PAGE CUSTOMIZATION -------
|
||||
this.Page.Name = "ReportAbusePage"
|
||||
|
||||
-- need to override this function from SettingsPageFactory
|
||||
-- DropDown menus require hub to to be set when they are initialized
|
||||
function this:SetHub(newHubRef)
|
||||
this.HubRef = newHubRef
|
||||
|
||||
if utility:IsSmallTouchScreen() then
|
||||
this.GameOrPlayerFrame,
|
||||
this.GameOrPlayerLabel,
|
||||
this.GameOrPlayerMode = utility:AddNewRow(this, "Game or Player?", "Selector", {"Game", "Player"}, 1)
|
||||
else
|
||||
this.GameOrPlayerFrame,
|
||||
this.GameOrPlayerLabel,
|
||||
this.GameOrPlayerMode = utility:AddNewRow(this, "Game or Player?", "Selector", {"Game", "Player"}, 1, 3)
|
||||
end
|
||||
|
||||
this.WhichPlayerFrame,
|
||||
this.WhichPlayerLabel,
|
||||
this.WhichPlayerMode = utility:AddNewRow(this, "Which Player?", "DropDown", {"update me"})
|
||||
this.WhichPlayerMode:SetInteractable(false)
|
||||
this.WhichPlayerLabel.ZIndex = 1
|
||||
|
||||
this.TypeOfAbuseFrame,
|
||||
this.TypeOfAbuseLabel,
|
||||
this.TypeOfAbuseMode = utility:AddNewRow(this, "Type Of Abuse", "DropDown", ABUSE_TYPES_GAME)
|
||||
|
||||
if utility:IsSmallTouchScreen() then
|
||||
this.AbuseDescriptionFrame,
|
||||
this.AbuseDescriptionLabel,
|
||||
this.AbuseDescription = utility:AddNewRow(this, DEFAULT_ABUSE_DESC_TEXT, "TextBox", nil, nil)
|
||||
else
|
||||
this.AbuseDescriptionFrame,
|
||||
this.AbuseDescriptionLabel,
|
||||
this.AbuseDescription = utility:AddNewRow(this, DEFAULT_ABUSE_DESC_TEXT, "TextBox", nil, nil, 5)
|
||||
end
|
||||
|
||||
if utility:IsSmallTouchScreen() then
|
||||
this.AbuseDescription.Selection.Size = UDim2.new(0, 290, 0, 30)
|
||||
this.AbuseDescription.Selection.Position = UDim2.new(1,-345,this.AbuseDescription.Selection.Position.Y.Scale, this.AbuseDescription.Selection.Position.Y.Offset)
|
||||
|
||||
this.AbuseDescriptionLabel = this.TypeOfAbuseLabel:clone()
|
||||
this.AbuseDescriptionLabel.Text = "Abuse Description"
|
||||
this.AbuseDescriptionLabel.Position = UDim2.new(this.AbuseDescriptionLabel.Position.X.Scale, this.AbuseDescriptionLabel.Position.X.Offset,
|
||||
0,50)
|
||||
this.AbuseDescriptionLabel.Parent = this.Page
|
||||
end
|
||||
|
||||
local SelectionOverrideObject = utility:Create'ImageLabel'
|
||||
{
|
||||
Image = "",
|
||||
BackgroundTransparency = 1
|
||||
};
|
||||
|
||||
local submitButton, submitText = nil, nil
|
||||
|
||||
local function makeSubmitButtonActive()
|
||||
submitButton.ZIndex = 2
|
||||
submitButton.Selectable = true
|
||||
submitText.ZIndex = 2
|
||||
end
|
||||
|
||||
local function makeSubmitButtonInactive()
|
||||
submitButton.ZIndex = 1
|
||||
submitButton.Selectable = false
|
||||
submitText.ZIndex = 1
|
||||
end
|
||||
|
||||
local function updateAbuseDropDown()
|
||||
this.WhichPlayerMode:ResetSelectionIndex()
|
||||
this.TypeOfAbuseMode:ResetSelectionIndex()
|
||||
|
||||
if this.GameOrPlayerMode.CurrentIndex == 1 then
|
||||
this.TypeOfAbuseMode:UpdateDropDownList(ABUSE_TYPES_GAME)
|
||||
this.WhichPlayerMode:SetInteractable(false)
|
||||
this.WhichPlayerLabel.ZIndex = 1
|
||||
this.GameOrPlayerMode.SelectorFrame.NextSelectionDown = this.TypeOfAbuseMode.DropDownFrame
|
||||
else
|
||||
this.TypeOfAbuseMode:UpdateDropDownList(ABUSE_TYPES_PLAYER)
|
||||
this.WhichPlayerMode:SetInteractable(true)
|
||||
this.WhichPlayerLabel.ZIndex = 2
|
||||
this.GameOrPlayerMode.SelectorFrame.NextSelectionDown = this.WhichPlayerMode.DropDownFrame
|
||||
end
|
||||
makeSubmitButtonInactive()
|
||||
end
|
||||
|
||||
local function cleanupReportAbuseMenu()
|
||||
updateAbuseDropDown()
|
||||
this.AbuseDescription.Selection.Text = DEFAULT_ABUSE_DESC_TEXT
|
||||
this.HubRef:SetVisibility(false, true)
|
||||
end
|
||||
|
||||
local function onReportSubmitted()
|
||||
local abuseReason = nil
|
||||
if this.GameOrPlayerMode.CurrentIndex == 2 then
|
||||
abuseReason = ABUSE_TYPES_PLAYER[this.TypeOfAbuseMode.CurrentIndex]
|
||||
|
||||
local currentAbusingPlayer = this:GetPlayerFromIndex(this.WhichPlayerMode.CurrentIndex)
|
||||
if currentAbusingPlayer and abuseReason then
|
||||
spawn(function()
|
||||
game.Players:ReportAbuse(currentAbusingPlayer, abuseReason, this.AbuseDescription.Selection.Text)
|
||||
end)
|
||||
end
|
||||
else
|
||||
abuseReason = ABUSE_TYPES_GAME[this.TypeOfAbuseMode.CurrentIndex]
|
||||
if abuseReason then
|
||||
spawn(function()
|
||||
game.Players:ReportAbuse(nil, abuseReason, this.AbuseDescription.Selection.Text)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
if abuseReason then
|
||||
local alertText = "Thanks for your report! Our moderators will review the chat logs and evaluate what happened."
|
||||
|
||||
if abuseReason == 'Cheating/Exploiting' then
|
||||
alertText = "Thanks for your report! We've recorded your report for evaluation."
|
||||
elseif abuseReason == 'Inappropriate Username' then
|
||||
alertText = "Thanks for your report! Our moderators will evaluate the username."
|
||||
elseif abuseReason == "Bad Model or Script" or abuseReason == "Inappropriate Content" or abuseReason == "Offsite Link" or abuseReason == "Offsite Links" then
|
||||
alertText = "Thanks for your report! Our moderators will review the place and make a determination."
|
||||
end
|
||||
|
||||
utility:ShowAlert(alertText, "Ok", this.HubRef, cleanupReportAbuseMenu)
|
||||
|
||||
this.LastSelectedObject = nil
|
||||
end
|
||||
end
|
||||
|
||||
submitButton, submitText = utility:MakeStyledButton("SubmitButton", "Submit", UDim2.new(0,198,0,50), onReportSubmitted, this)
|
||||
if utility:IsSmallTouchScreen() then
|
||||
submitButton.Position = UDim2.new(1,-220,1,5)
|
||||
else
|
||||
submitButton.Position = UDim2.new(1,-194,1,5)
|
||||
end
|
||||
submitButton.Selectable = false
|
||||
submitButton.ZIndex = 1
|
||||
submitText.ZIndex = 1
|
||||
submitButton.Parent = this.AbuseDescription.Selection
|
||||
|
||||
local function playerSelectionChanged(newIndex)
|
||||
if newIndex ~= nil and this.TypeOfAbuseMode:GetSelectedIndex() ~= nil then
|
||||
makeSubmitButtonActive()
|
||||
else
|
||||
makeSubmitButtonInactive()
|
||||
end
|
||||
end
|
||||
this.WhichPlayerMode.IndexChanged:connect(playerSelectionChanged)
|
||||
|
||||
local function typeOfAbuseChanged(newIndex)
|
||||
if newIndex ~= nil then
|
||||
if this.GameOrPlayerMode.CurrentIndex == 1 or this.WhichPlayerMode:GetSelectedIndex() ~= nil then
|
||||
makeSubmitButtonActive()
|
||||
else
|
||||
makeSubmitButtonInactive()
|
||||
end
|
||||
else
|
||||
makeSubmitButtonInactive()
|
||||
end
|
||||
end
|
||||
this.TypeOfAbuseMode.IndexChanged:connect(typeOfAbuseChanged)
|
||||
|
||||
this.GameOrPlayerMode.IndexChanged:connect(updateAbuseDropDown)
|
||||
|
||||
this:AddRow(nil, nil, this.AbuseDescription)
|
||||
|
||||
this.Page.Size = UDim2.new(1,0,0,submitButton.AbsolutePosition.Y + submitButton.AbsoluteSize.Y)
|
||||
end
|
||||
|
||||
return this
|
||||
end
|
||||
|
||||
|
||||
----------- Public Facing API Additions --------------
|
||||
do
|
||||
PageInstance = Initialize()
|
||||
PageInstance.Displayed.Event:connect(function()
|
||||
PageInstance:UpdatePlayerDropDown()
|
||||
end)
|
||||
end
|
||||
return PageInstance
|
||||
134
client/common/content/scripts/Modules/ResetCharacter.lua
Normal file
134
client/common/content/scripts/Modules/ResetCharacter.lua
Normal file
@@ -0,0 +1,134 @@
|
||||
--[[
|
||||
Filename: ResetCharacter.lua
|
||||
Written by: jeditkacheff
|
||||
Version 1.0
|
||||
Description: Takes care of the reseting the character in Settings Menu
|
||||
--]]
|
||||
|
||||
-------------- CONSTANTS -------------
|
||||
local RESET_CHARACTER_GAME_ACTION = "ResetCharacterAction"
|
||||
|
||||
-------------- SERVICES --------------
|
||||
local CoreGui = game:GetService("CoreGui")
|
||||
local ContextActionService = game:GetService("ContextActionService")
|
||||
local RobloxGui = CoreGui:WaitForChild("RobloxGui")
|
||||
local GuiService = game:GetService("GuiService")
|
||||
local PlayersService = game:GetService("Players")
|
||||
|
||||
----------- UTILITIES --------------
|
||||
local utility = require(RobloxGui.Modules.Utility)
|
||||
|
||||
------------ Variables -------------------
|
||||
local PageInstance = nil
|
||||
RobloxGui:WaitForChild("Modules"):WaitForChild("TenFootInterface")
|
||||
local isTenFootInterface = require(RobloxGui.Modules.TenFootInterface):IsEnabled()
|
||||
|
||||
----------- CLASS DECLARATION --------------
|
||||
|
||||
local function Initialize()
|
||||
local settingsPageFactory = require(RobloxGui.Modules.SettingsPageFactory)
|
||||
local this = settingsPageFactory:CreateNewPage()
|
||||
|
||||
this.DontResetCharFunc = function(isUsingGamepad)
|
||||
if this.HubRef then
|
||||
this.HubRef:PopMenu(isUsingGamepad, true)
|
||||
end
|
||||
end
|
||||
this.DontResetCharFromHotkey = function(name, state, input)
|
||||
if state == Enum.UserInputState.Begin then
|
||||
local isUsingGamepad = input.UserInputType == Enum.UserInputType.Gamepad1 or input.UserInputType == Enum.UserInputType.Gamepad2
|
||||
or input.UserInputType == Enum.UserInputType.Gamepad3 or input.UserInputType == Enum.UserInputType.Gamepad4
|
||||
|
||||
this.DontResetCharFunc(isUsingGamepad)
|
||||
end
|
||||
end
|
||||
this.DontResetCharFromButton = function(isUsingGamepad)
|
||||
this.DontResetCharFunc(isUsingGamepad)
|
||||
end
|
||||
|
||||
------ TAB CUSTOMIZATION -------
|
||||
this.TabHeader = nil -- no tab for this page
|
||||
|
||||
------ PAGE CUSTOMIZATION -------
|
||||
this.Page.Name = "ResetCharacter"
|
||||
|
||||
local resetCharacterText = utility:Create'TextLabel'
|
||||
{
|
||||
Name = "ResetCharacterText",
|
||||
Text = "Are you sure you want to reset your character?",
|
||||
Font = Enum.Font.SourceSansBold,
|
||||
FontSize = Enum.FontSize.Size36,
|
||||
TextColor3 = Color3.new(1,1,1),
|
||||
BackgroundTransparency = 1,
|
||||
Size = UDim2.new(1,0,0,200),
|
||||
TextWrapped = true,
|
||||
ZIndex = 2,
|
||||
Parent = this.Page
|
||||
};
|
||||
if utility:IsSmallTouchScreen() then
|
||||
resetCharacterText.FontSize = Enum.FontSize.Size24
|
||||
resetCharacterText.Size = UDim2.new(1,0,0,100)
|
||||
elseif isTenFootInterface then
|
||||
resetCharacterText.FontSize = Enum.FontSize.Size48
|
||||
end
|
||||
|
||||
------ Init -------
|
||||
local resetCharFunc = function()
|
||||
local player = PlayersService.LocalPlayer
|
||||
if player then
|
||||
local character = player.Character
|
||||
if character then
|
||||
local humanoid = character:FindFirstChild('Humanoid')
|
||||
if humanoid then
|
||||
humanoid.Health = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if this.HubRef then
|
||||
this.HubRef:SetVisibility(false, true)
|
||||
end
|
||||
end
|
||||
|
||||
local buttonSpacing = 20
|
||||
local buttonSize = UDim2.new(0, 200, 0, 50)
|
||||
if isTenFootInterface then
|
||||
resetCharacterText.Position = UDim2.new(0,0,0,100)
|
||||
buttonSize = UDim2.new(0, 300, 0, 80)
|
||||
end
|
||||
|
||||
this.ResetCharacterButton = utility:MakeStyledButton("ResetCharacter", "Reset", buttonSize, resetCharFunc)
|
||||
this.ResetCharacterButton.NextSelectionRight = nil
|
||||
if utility:IsSmallTouchScreen() then
|
||||
this.ResetCharacterButton.Position = UDim2.new(0.5, -buttonSize.X.Offset - buttonSpacing, 1, 0)
|
||||
else
|
||||
this.ResetCharacterButton.Position = UDim2.new(0.5, -buttonSize.X.Offset - buttonSpacing, 1, -30)
|
||||
end
|
||||
this.ResetCharacterButton.Parent = resetCharacterText
|
||||
|
||||
|
||||
local dontResetCharacterButton = utility:MakeStyledButton("DontResetCharacter", "Don't Reset", buttonSize, this.DontResetCharFromButton)
|
||||
dontResetCharacterButton.NextSelectionLeft = nil
|
||||
if utility:IsSmallTouchScreen() then
|
||||
dontResetCharacterButton.Position = UDim2.new(0.5, buttonSpacing, 1, 0)
|
||||
else
|
||||
dontResetCharacterButton.Position = UDim2.new(0.5, buttonSpacing, 1, -30)
|
||||
end
|
||||
dontResetCharacterButton.Parent = resetCharacterText
|
||||
|
||||
this.Page.Size = UDim2.new(1,0,0,dontResetCharacterButton.AbsolutePosition.Y + dontResetCharacterButton.AbsoluteSize.Y)
|
||||
|
||||
return this
|
||||
end
|
||||
|
||||
|
||||
----------- Public Facing API Additions --------------
|
||||
PageInstance = Initialize()
|
||||
PageInstance.Displayed.Event:connect(function()
|
||||
GuiService.SelectedCoreObject = PageInstance.ResetCharacterButton
|
||||
ContextActionService:BindCoreAction(RESET_CHARACTER_GAME_ACTION, PageInstance.DontResetCharFromHotkey, false, Enum.KeyCode.ButtonB)
|
||||
end)
|
||||
PageInstance.Hidden.Event:connect(function()
|
||||
ContextActionService:UnbindCoreAction(RESET_CHARACTER_GAME_ACTION)
|
||||
end)
|
||||
return PageInstance
|
||||
1115
client/common/content/scripts/Modules/SettingsHub.lua
Normal file
1115
client/common/content/scripts/Modules/SettingsHub.lua
Normal file
File diff suppressed because it is too large
Load Diff
277
client/common/content/scripts/Modules/SettingsPageFactory.lua
Normal file
277
client/common/content/scripts/Modules/SettingsPageFactory.lua
Normal file
@@ -0,0 +1,277 @@
|
||||
--[[
|
||||
Filename: SettingsPageFactory.lua
|
||||
Written by: jeditkacheff
|
||||
Version 1.0
|
||||
Description: Base Page Functionality for all Settings Pages
|
||||
--]]
|
||||
----------------- SERVICES ------------------------------
|
||||
local GuiService = game:GetService("GuiService")
|
||||
local HttpService = game:GetService("HttpService")
|
||||
local UserInputService = game:GetService("UserInputService")
|
||||
|
||||
local CoreGui = game:GetService("CoreGui")
|
||||
local RobloxGui = CoreGui:WaitForChild("RobloxGui")
|
||||
|
||||
----------- UTILITIES --------------
|
||||
local utility = require(RobloxGui.Modules.Utility)
|
||||
|
||||
|
||||
----------- VARIABLES --------------
|
||||
RobloxGui:WaitForChild("Modules"):WaitForChild("TenFootInterface")
|
||||
local isTenFootInterface = require(RobloxGui.Modules.TenFootInterface):IsEnabled()
|
||||
|
||||
----------- CONSTANTS --------------
|
||||
local HEADER_SPACING = 5
|
||||
if utility:IsSmallTouchScreen() then
|
||||
HEADER_SPACING = 0
|
||||
end
|
||||
|
||||
----------- CLASS DECLARATION --------------
|
||||
local function Initialize()
|
||||
local this = {}
|
||||
this.HubRef = nil
|
||||
this.LastSelectedObject = nil
|
||||
this.TabPosition = 0
|
||||
this.Active = false
|
||||
this.OpenStateChangedCount = 0
|
||||
local rows = {}
|
||||
local displayed = false
|
||||
|
||||
------ TAB CREATION -------
|
||||
this.TabHeader = utility:Create'TextButton'
|
||||
{
|
||||
Name = "Header",
|
||||
Text = "",
|
||||
BackgroundTransparency = 1,
|
||||
Size = UDim2.new(0,169,1,0),
|
||||
Position = UDim2.new(0.5,0,0,0)
|
||||
};
|
||||
if utility:IsSmallTouchScreen() then
|
||||
this.TabHeader.Size = UDim2.new(0,84,1,0)
|
||||
elseif isTenFootInterface then
|
||||
this.TabHeader.Size = UDim2.new(0,220,1,0)
|
||||
end
|
||||
this.TabHeader.MouseButton1Click:connect(function()
|
||||
if this.HubRef then
|
||||
this.HubRef:SwitchToPage(this, true)
|
||||
end
|
||||
end)
|
||||
|
||||
local icon = utility:Create'ImageLabel'
|
||||
{
|
||||
Name = "Icon",
|
||||
BackgroundTransparency = 1,
|
||||
Size = UDim2.new(0,44,0,37),
|
||||
Position = UDim2.new(0,10,0.5,-18),
|
||||
Image = "",
|
||||
ImageTransparency = 0.5,
|
||||
Parent = this.TabHeader
|
||||
};
|
||||
|
||||
local title = utility:Create'TextLabel'
|
||||
{
|
||||
Name = "Title",
|
||||
Text = "Change Me",
|
||||
Font = Enum.Font.SourceSansBold,
|
||||
FontSize = Enum.FontSize.Size24,
|
||||
TextColor3 = Color3.new(1,1,1),
|
||||
BackgroundTransparency = 1,
|
||||
Size = UDim2.new(1.05,0,1,0),
|
||||
Position = UDim2.new(1.2,0,0,0),
|
||||
TextXAlignment = Enum.TextXAlignment.Left,
|
||||
TextTransparency = 0.5,
|
||||
Parent = icon
|
||||
};
|
||||
if utility:IsSmallTouchScreen() then
|
||||
title.FontSize = Enum.FontSize.Size18
|
||||
elseif isTenFootInterface then
|
||||
title.FontSize = Enum.FontSize.Size48
|
||||
end
|
||||
|
||||
local tabSelection = utility:Create'ImageLabel'
|
||||
{
|
||||
Name = "TabSelection",
|
||||
Image = "ayaasset://textures/ui/Settings/MenuBarAssets/MenuSelection.png",
|
||||
ScaleType = Enum.ScaleType.Slice,
|
||||
SliceCenter = Rect.new(3,1,4,5),
|
||||
Visible = false,
|
||||
BackgroundTransparency = 1,
|
||||
Size = UDim2.new(1,0,0,6),
|
||||
Position = UDim2.new(0,0,1,-6),
|
||||
Parent = this.TabHeader
|
||||
};
|
||||
|
||||
------ PAGE CREATION -------
|
||||
this.Page = utility:Create'Frame'
|
||||
{
|
||||
Name = "Page",
|
||||
BackgroundTransparency = 1,
|
||||
Size = UDim2.new(1,0,1,0)
|
||||
};
|
||||
|
||||
-- make sure each page has a unique selection group (for gamepad selection)
|
||||
GuiService:AddSelectionParent(HttpService:GenerateGUID(false), this.Page)
|
||||
|
||||
----------------- Events ------------------------
|
||||
|
||||
this.Displayed = Instance.new("BindableEvent")
|
||||
this.Displayed.Name = "Displayed"
|
||||
|
||||
this.Displayed.Event:connect(function()
|
||||
if not this.HubRef.Shield.Visible then return end
|
||||
|
||||
this:SelectARow()
|
||||
end)
|
||||
|
||||
this.Hidden = Instance.new("BindableEvent")
|
||||
this.Hidden.Event:connect(function()
|
||||
if GuiService.SelectedCoreObject and GuiService.SelectedCoreObject:IsDescendantOf(this.Page) then
|
||||
GuiService.SelectedCoreObject = nil
|
||||
end
|
||||
end)
|
||||
this.Hidden.Name = "Hidden"
|
||||
|
||||
----------------- FUNCTIONS ------------------------
|
||||
function this:SelectARow(forced) -- Selects the first row or the most recently selected row
|
||||
if forced or not GuiService.SelectedCoreObject or not GuiService.SelectedCoreObject:IsDescendantOf(this.Page) then
|
||||
if this.LastSelectedObject then
|
||||
GuiService.SelectedCoreObject = this.LastSelectedObject
|
||||
else
|
||||
if rows and #rows > 0 then
|
||||
local valueChangerFrame = nil
|
||||
|
||||
if type(rows[1].ValueChanger) ~= "table" then
|
||||
valueChangerFrame = rows[1].ValueChanger
|
||||
else
|
||||
valueChangerFrame = rows[1].ValueChanger.SliderFrame and
|
||||
rows[1].ValueChanger.SliderFrame or rows[1].ValueChanger.SelectorFrame
|
||||
end
|
||||
GuiService.SelectedCoreObject = valueChangerFrame
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function this:Display(pageParent, skipAnimation)
|
||||
this.OpenStateChangedCount = this.OpenStateChangedCount + 1
|
||||
|
||||
if this.TabHeader then
|
||||
this.TabHeader.TabSelection.Visible = true
|
||||
this.TabHeader.Icon.ImageTransparency = 0
|
||||
this.TabHeader.Icon.Title.TextTransparency = 0
|
||||
end
|
||||
|
||||
this.Page.Parent = pageParent
|
||||
this.Page.Visible = true
|
||||
|
||||
local endPos = UDim2.new(0,0,0,0)
|
||||
local animationComplete = function()
|
||||
this.Page.Visible = true
|
||||
displayed = true
|
||||
this.Displayed:Fire()
|
||||
end
|
||||
if skipAnimation then
|
||||
this.Page.Position = endPos
|
||||
animationComplete()
|
||||
else
|
||||
this.Page:TweenPosition(endPos, Enum.EasingDirection.In, Enum.EasingStyle.Quad, 0.1, true, animationComplete)
|
||||
end
|
||||
end
|
||||
function this:Hide(direction, newPagePos, skipAnimation, delayBeforeHiding)
|
||||
this.OpenStateChangedCount = this.OpenStateChangedCount + 1
|
||||
|
||||
if this.TabHeader then
|
||||
this.TabHeader.TabSelection.Visible = false
|
||||
this.TabHeader.Icon.ImageTransparency = 0.5
|
||||
this.TabHeader.Icon.Title.TextTransparency = 0.5
|
||||
end
|
||||
|
||||
if this.Page.Parent then
|
||||
local endPos = UDim2.new(1 * direction,0,0,0)
|
||||
local animationComplete = function()
|
||||
this.Page.Visible = false
|
||||
this.Page.Position = UDim2.new(this.TabPosition - newPagePos,0,0,0)
|
||||
displayed = false
|
||||
this.Hidden:Fire()
|
||||
end
|
||||
|
||||
local remove = function()
|
||||
if skipAnimation then
|
||||
this.Page.Position = endPos
|
||||
animationComplete()
|
||||
else
|
||||
this.Page:TweenPosition(endPos, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.1, true, animationComplete)
|
||||
end
|
||||
end
|
||||
|
||||
if delayBeforeHiding then
|
||||
local myOpenStateChangedCount = this.OpenStateChangedCount
|
||||
delay(delayBeforeHiding, function()
|
||||
if myOpenStateChangedCount == this.OpenStateChangedCount then
|
||||
remove()
|
||||
end
|
||||
end)
|
||||
else
|
||||
remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function this:GetDisplayed()
|
||||
return displayed
|
||||
end
|
||||
|
||||
function this:GetVisibility()
|
||||
return this.Page.Parent
|
||||
end
|
||||
|
||||
function this:GetTabHeader()
|
||||
return this.TabHeader
|
||||
end
|
||||
|
||||
function this:SetHub(hubRef)
|
||||
this.HubRef = hubRef
|
||||
|
||||
for i, row in next, rows do
|
||||
if type(row.ValueChanger) == 'table' then
|
||||
row.ValueChanger.HubRef = this.HubRef
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function this:GetSize()
|
||||
return this.Page.AbsoluteSize
|
||||
end
|
||||
|
||||
function this:AddRow(RowFrame, RowLabel, ValueChangerInstance, ExtraRowSpacing)
|
||||
rows[#rows + 1] = {SelectionFrame = RowFrame, Label = RowLabel, ValueChanger = ValueChangerInstance}
|
||||
|
||||
local rowFrameYSize = 0
|
||||
if RowFrame then
|
||||
rowFrameYSize = RowFrame.Size.Y.Offset
|
||||
end
|
||||
|
||||
if ExtraRowSpacing then
|
||||
this.Page.Size = UDim2.new(1, 0, 0, this.Page.Size.Y.Offset + rowFrameYSize + ExtraRowSpacing)
|
||||
else
|
||||
this.Page.Size = UDim2.new(1, 0, 0, this.Page.Size.Y.Offset + rowFrameYSize)
|
||||
end
|
||||
|
||||
if this.HubRef and type(ValueChangerInstance) == 'table' then
|
||||
ValueChangerInstance.HubRef = this.HubRef
|
||||
end
|
||||
end
|
||||
|
||||
return this
|
||||
end
|
||||
|
||||
|
||||
-------- public facing API ----------------
|
||||
local moduleApiTable = {}
|
||||
|
||||
function moduleApiTable:CreateNewPage()
|
||||
return Initialize()
|
||||
end
|
||||
|
||||
|
||||
return moduleApiTable
|
||||
343
client/common/content/scripts/Modules/TenFootInterface.lua
Normal file
343
client/common/content/scripts/Modules/TenFootInterface.lua
Normal file
@@ -0,0 +1,343 @@
|
||||
--[[
|
||||
Filename: TenFootInterface.lua
|
||||
Written by: jeditkacheff
|
||||
Version 1.0
|
||||
Description: Setups up some special UI for ROBLOX TV gaming
|
||||
--]]
|
||||
-------------- CONSTANTS --------------
|
||||
local HEALTH_GREEN_COLOR = Color3.new(27/255, 252/255, 107/255)
|
||||
local DISPLAY_POS_INIT_INSET = 0
|
||||
local DISPLAY_ITEM_OFFSET = 4
|
||||
local FORCE_TEN_FOOT_INTERFACE = false
|
||||
|
||||
-------------- SERVICES --------------
|
||||
local CoreGui = game:GetService("CoreGui")
|
||||
local RobloxGui = CoreGui:WaitForChild("RobloxGui")
|
||||
local UserInputService = game:GetService("UserInputService")
|
||||
local GuiService = game:GetService("GuiService")
|
||||
|
||||
------------------ VARIABLES --------------------
|
||||
local tenFootInterfaceEnabled = false
|
||||
do
|
||||
local platform = UserInputService:GetPlatform()
|
||||
|
||||
tenFootInterfaceEnabled = false
|
||||
end
|
||||
|
||||
if FORCE_TEN_FOOT_INTERFACE then
|
||||
tenFootInterfaceEnabled = true
|
||||
end
|
||||
|
||||
local Util = {}
|
||||
do
|
||||
function Util.Create(instanceType)
|
||||
return function(data)
|
||||
local obj = Instance.new(instanceType)
|
||||
for k, v in pairs(data) do
|
||||
if type(k) == 'number' then
|
||||
v.Parent = obj
|
||||
else
|
||||
obj[k] = v
|
||||
end
|
||||
end
|
||||
return obj
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function CreateModule()
|
||||
local this = {}
|
||||
local nextObjectDisplayYPos = DISPLAY_POS_INIT_INSET
|
||||
local displayStack = {}
|
||||
|
||||
-- setup base gui
|
||||
local function createContainer()
|
||||
if not this.Container then
|
||||
this.Container = Util.Create'ImageButton'
|
||||
{
|
||||
Name = "TopRightContainer";
|
||||
Size = UDim2.new(0, 350, 0, 100);
|
||||
Position = UDim2.new(1,-360,0,10);
|
||||
AutoButtonColor = false;
|
||||
Image = "";
|
||||
Active = false;
|
||||
BackgroundTransparency = 1;
|
||||
Parent = RobloxGui;
|
||||
};
|
||||
end
|
||||
end
|
||||
|
||||
function removeFromDisplayStack(displayObject)
|
||||
local moveUpFromHere = nil
|
||||
|
||||
for i = 1, #displayStack do
|
||||
if displayStack[i] == displayObject then
|
||||
moveUpFromHere = i + 1
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local prevObject = displayObject
|
||||
for i = moveUpFromHere, #displayStack do
|
||||
local objectToMoveUp = displayStack[i]
|
||||
objectToMoveUp.Position = UDim2.new(objectToMoveUp.Position.X.Scale, objectToMoveUp.Position.X.Offset,
|
||||
objectToMoveUp.Position.Y.Scale, prevObject.AbsolutePosition.Y)
|
||||
prevObject = objectToMoveUp
|
||||
end
|
||||
end
|
||||
|
||||
function addBackToDisplayStack(displayObject)
|
||||
for i = 1, #displayStack do
|
||||
if displayStack[i] == displayObject then
|
||||
moveDownFromHere = i + 1
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local prevObject = displayObject
|
||||
for i = moveDownFromHere, #displayStack do
|
||||
local objectToMoveDown = displayStack[i]
|
||||
local nextDisplayPos = prevObject.AbsolutePosition.Y + prevObject.AbsoluteSize.Y + DISPLAY_ITEM_OFFSET
|
||||
objectToMoveDown.Position = UDim2.new(objectToMoveDown.Position.X.Scale, objectToMoveDown.Position.X.Offset,
|
||||
objectToMoveDown.Position.Y.Scale, nextDisplayPos)
|
||||
prevObject = objectToMoveDown
|
||||
end
|
||||
end
|
||||
|
||||
function addToDisplayStack(displayObject)
|
||||
local lastDisplayed = nil
|
||||
if #displayStack > 0 then
|
||||
lastDisplayed = displayStack[#displayStack]
|
||||
end
|
||||
displayStack[#displayStack + 1] = displayObject
|
||||
|
||||
local nextDisplayPos = DISPLAY_POS_INIT_INSET
|
||||
if lastDisplayed then
|
||||
nextDisplayPos = lastDisplayed.AbsolutePosition.Y + lastDisplayed.AbsoluteSize.Y + DISPLAY_ITEM_OFFSET
|
||||
end
|
||||
|
||||
displayObject.Position = UDim2.new(displayObject.Position.X.Scale, displayObject.Position.X.Offset,
|
||||
displayObject.Position.Y.Scale, nextDisplayPos)
|
||||
|
||||
createContainer()
|
||||
displayObject.Parent = this.Container
|
||||
|
||||
displayObject.Changed:connect(function(prop)
|
||||
if prop == "Visible" then
|
||||
if not displayObject.Visible then
|
||||
removeFromDisplayStack(displayObject)
|
||||
else
|
||||
addBackToDisplayStack(displayObject)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function this:CreateHealthBar()
|
||||
this.HealthContainer = Util.Create'Frame'{
|
||||
Name = "HealthContainer";
|
||||
Size = UDim2.new(1, -86, 0, 50);
|
||||
Position = UDim2.new(0, 92, 0, 0);
|
||||
BorderSizePixel = 0;
|
||||
BackgroundColor3 = Color3.new(0,0,0);
|
||||
BackgroundTransparency = 0.5;
|
||||
};
|
||||
|
||||
local healthFillHolder = Util.Create'Frame'{
|
||||
Name = "HealthFillHolder";
|
||||
Size = UDim2.new(1, -10, 1, -10);
|
||||
Position = UDim2.new(0, 5, 0, 5);
|
||||
BorderSizePixel = 0;
|
||||
BackgroundColor3 = Color3.new(1,1,1);
|
||||
BackgroundTransparency = 1.0;
|
||||
Parent = this.HealthContainer;
|
||||
};
|
||||
|
||||
local healthFill = Util.Create'Frame'{
|
||||
Name = "HealthFill";
|
||||
Size = UDim2.new(1, 0, 1, 0);
|
||||
Position = UDim2.new(0, 0, 0, 0);
|
||||
BorderSizePixel = 0;
|
||||
BackgroundTransparency = 0.0;
|
||||
BackgroundColor3 = HEALTH_GREEN_COLOR;
|
||||
Parent = healthFillHolder;
|
||||
};
|
||||
|
||||
local healthText = Util.Create'TextLabel'{
|
||||
Name = "HealthText";
|
||||
Size = UDim2.new(0, 98, 0, 50);
|
||||
Position = UDim2.new(0, -100, 0, 0);
|
||||
BackgroundTransparency = 0.5;
|
||||
BackgroundColor3 = Color3.new(0,0,0);
|
||||
Font = Enum.Font.SourceSans;
|
||||
FontSize = Enum.FontSize.Size36;
|
||||
Text = "Health";
|
||||
TextColor3 = Color3.new(1,1,1);
|
||||
BorderSizePixel = 0;
|
||||
Parent = this.HealthContainer;
|
||||
};
|
||||
|
||||
local username = Util.Create'TextLabel'{
|
||||
Visible = false
|
||||
}
|
||||
|
||||
addToDisplayStack(this.HealthContainer)
|
||||
createContainer()
|
||||
|
||||
return this.Container, username, this.HealthContainer, healthFill
|
||||
end
|
||||
|
||||
function this:SetupTopStat()
|
||||
local topStatEnabled = true
|
||||
local displayedStat = nil
|
||||
local displayedStatChangedCon = nil
|
||||
local displayedStatParentedCon = nil
|
||||
local leaderstatsChildAddedCon = nil
|
||||
local tenFootInterfaceStat = nil
|
||||
|
||||
local function makeTenFootInterfaceStat()
|
||||
if tenFootInterfaceStat then return end
|
||||
|
||||
tenFootInterfaceStat = Util.Create'Frame'{
|
||||
Name = "OneStatFrame";
|
||||
Size = UDim2.new(1, 0, 0, 36);
|
||||
Position = UDim2.new(0, 0, 0, 0);
|
||||
BorderSizePixel = 0;
|
||||
BackgroundTransparency = 1;
|
||||
};
|
||||
local statName = Util.Create'TextLabel'{
|
||||
Name = "StatName";
|
||||
Size = UDim2.new(0.5,0,0,36);
|
||||
BackgroundTransparency = 1;
|
||||
Font = Enum.Font.SourceSans;
|
||||
FontSize = Enum.FontSize.Size36;
|
||||
TextStrokeColor3 = Color3.new(104/255, 104/255, 104/255);
|
||||
TextStrokeTransparency = 0;
|
||||
Text = " StatName:";
|
||||
TextColor3 = Color3.new(1,1,1);
|
||||
TextXAlignment = Enum.TextXAlignment.Left;
|
||||
BorderSizePixel = 0;
|
||||
ClipsDescendants = true;
|
||||
Parent = tenFootInterfaceStat;
|
||||
};
|
||||
local statValue = statName:clone()
|
||||
statValue.Position = UDim2.new(0.5,0,0,0)
|
||||
statValue.Name = "StatValue"
|
||||
statValue.Text = "123,643,231"
|
||||
statValue.TextXAlignment = Enum.TextXAlignment.Right
|
||||
statValue.Parent = tenFootInterfaceStat
|
||||
|
||||
addToDisplayStack(tenFootInterfaceStat)
|
||||
end
|
||||
|
||||
local function setDisplayedStat(newStat)
|
||||
if displayedStatChangedCon then displayedStatChangedCon:disconnect() displayedStatChangedCon = nil end
|
||||
if displayedStatParentedCon then displayedStatParentedCon:disconnect() displayedStatParentedCon = nil end
|
||||
|
||||
displayedStat = newStat
|
||||
|
||||
if displayedStat then
|
||||
makeTenFootInterfaceStat()
|
||||
updateTenFootStat(displayedStat)
|
||||
displayedStatParentedCon = displayedStat.AncestryChanged:connect(function() updateTenFootStat(displayedStat, "Parent") end)
|
||||
displayedStatChangedCon = displayedStat.Changed:connect(function(prop) updateTenFootStat(displayedStat, prop) end)
|
||||
end
|
||||
end
|
||||
|
||||
function updateTenFootStat(statObj, property)
|
||||
if property and property == "Parent" then
|
||||
tenFootInterfaceStat.StatName.Text = ""
|
||||
tenFootInterfaceStat.StatValue.Text = ""
|
||||
setDisplayedStat(nil)
|
||||
|
||||
tenFootInterfaceChanged()
|
||||
else
|
||||
if topStatEnabled then
|
||||
tenFootInterfaceStat.StatName.Text = " " .. tostring(statObj.Name) .. ":"
|
||||
tenFootInterfaceStat.StatValue.Text = tostring(statObj.Value)
|
||||
else
|
||||
tenFootInterfaceStat.StatName.Text = ""
|
||||
tenFootInterfaceStat.StatValue.Text = ""
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function isValidStat(obj)
|
||||
return obj:IsA('StringValue') or obj:IsA('IntValue') or obj:IsA('BoolValue') or obj:IsA('NumberValue') or
|
||||
obj:IsA('DoubleConstrainedValue') or obj:IsA('IntConstrainedValue')
|
||||
end
|
||||
|
||||
local function tenFootInterfaceNewStat( newStat )
|
||||
if not displayedStat and isValidStat(newStat) then
|
||||
setDisplayedStat(newStat)
|
||||
end
|
||||
end
|
||||
|
||||
function tenFootInterfaceChanged()
|
||||
game:WaitForChild("Players")
|
||||
while not game.Players.LocalPlayer do
|
||||
wait()
|
||||
end
|
||||
|
||||
local leaderstats = game.Players.LocalPlayer:FindFirstChild('leaderstats')
|
||||
if leaderstats then
|
||||
local statChildren = leaderstats:GetChildren()
|
||||
for i = 1, #statChildren do
|
||||
tenFootInterfaceNewStat(statChildren[i])
|
||||
end
|
||||
if leaderstatsChildAddedCon then leaderstatsChildAddedCon:disconnect() end
|
||||
leaderstatsChildAddedCon = leaderstats.ChildAdded:connect(function(newStat)
|
||||
tenFootInterfaceNewStat(newStat)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
game:WaitForChild("Players")
|
||||
while not game.Players.LocalPlayer do
|
||||
wait()
|
||||
end
|
||||
|
||||
local leaderstats = game.Players.LocalPlayer:FindFirstChild('leaderstats')
|
||||
if leaderstats then
|
||||
tenFootInterfaceChanged()
|
||||
else
|
||||
game.Players.LocalPlayer.ChildAdded:connect(tenFootInterfaceChanged)
|
||||
end
|
||||
|
||||
--Top Stat Public API
|
||||
|
||||
local topStatApiTable = {}
|
||||
|
||||
function topStatApiTable:SetTopStatEnabled(value)
|
||||
topStatEnabled = value
|
||||
if displayedStat then
|
||||
updateTenFootStat(displayedStat, "")
|
||||
end
|
||||
end
|
||||
|
||||
return topStatApiTable
|
||||
end
|
||||
|
||||
return this
|
||||
end
|
||||
|
||||
|
||||
-- Public API
|
||||
|
||||
local moduleApiTable = {}
|
||||
|
||||
local TenFootInterfaceModule = CreateModule()
|
||||
|
||||
function moduleApiTable:IsEnabled()
|
||||
return tenFootInterfaceEnabled
|
||||
end
|
||||
|
||||
function moduleApiTable:CreateHealthBar()
|
||||
return TenFootInterfaceModule:CreateHealthBar()
|
||||
end
|
||||
|
||||
function moduleApiTable:SetupTopStat()
|
||||
return TenFootInterfaceModule:SetupTopStat()
|
||||
end
|
||||
|
||||
return moduleApiTable
|
||||
2039
client/common/content/scripts/Modules/Utility.lua
Normal file
2039
client/common/content/scripts/Modules/Utility.lua
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user