133 lines
5.4 KiB
Luau
133 lines
5.4 KiB
Luau
--!strict
|
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
local UI = require(ReplicatedStorage:WaitForChild("HunterUI") :: ModuleScript)
|
|
local Rules = require(ReplicatedStorage:WaitForChild("MatchRules") :: ModuleScript)
|
|
|
|
local ModeCard = {}
|
|
local artIds: {[string]: string} = {
|
|
TeamDeathmatch = "rbxassetid://86938429785177",
|
|
HotPoint = "rbxassetid://113230020908274",
|
|
Domination = "rbxassetid://134414659800619",
|
|
CaptureFlag = "rbxassetid://133231003741034",
|
|
TrophyHunt = "rbxassetid://89901991818650",
|
|
Siege = "rbxassetid://140524141713098",
|
|
OneLife = "rbxassetid://99724219202486",
|
|
HuntLeader = "rbxassetid://104751658045911",
|
|
}
|
|
local accents: {[string]: Color3} = {
|
|
TeamDeathmatch = UI.Blue,
|
|
HotPoint = UI.Orange,
|
|
Domination = UI.Mint,
|
|
CaptureFlag = Color3.fromRGB(104, 167, 255),
|
|
TrophyHunt = UI.Gold,
|
|
Siege = Color3.fromRGB(185, 131, 255),
|
|
OneLife = Color3.fromRGB(255, 112, 119),
|
|
HuntLeader = Color3.fromRGB(169, 157, 255),
|
|
}
|
|
|
|
export type Card = {
|
|
root: GuiObject, button: TextButton?, image: ImageLabel, title: TextLabel, badge: TextLabel,
|
|
art: Frame, glow: Frame, frame: Frame?, accent: Color3,
|
|
badgePanel: Frame, shade: Frame, lockedSurface: Frame?,
|
|
}
|
|
|
|
local dark = Color3.fromRGB(13, 24, 39)
|
|
local badgeFill = Color3.fromRGB(9, 19, 34)
|
|
local shadeColor = Color3.fromRGB(6, 12, 23)
|
|
local function appearance(card: Card, id: string)
|
|
local color = accents[id] or UI.Blue
|
|
card.accent = color
|
|
card.title.Text = Rules.get(id).title
|
|
card.art.BackgroundColor3 = dark:Lerp(color, .28)
|
|
card.badge.TextColor3 = color:Lerp(UI.Ink, .28)
|
|
card.image.Image = artIds[id] or ""
|
|
card.image.Visible = card.image.Image ~= ""
|
|
local frame = card.frame
|
|
if frame then UI.tintPlate(frame, color:Lerp(UI.Panel, .24), dark) end
|
|
UI.tintPlate(card.badgePanel, color:Lerp(dark, .4), badgeFill)
|
|
end
|
|
|
|
function ModeCard.new(parent: Instance, id: string, position: UDim2, size: UDim2, interactive: boolean?): Card
|
|
local accent = accents[id] or UI.Blue
|
|
local root: GuiObject
|
|
local button: TextButton? = nil
|
|
local shell: Frame? = nil
|
|
local lockedSurface: Frame? = nil
|
|
if interactive then
|
|
local input = Instance.new("TextButton")
|
|
input.Name = id
|
|
input.Position, input.Size = position, size
|
|
input.Text, input.BorderSizePixel = "", 0
|
|
input.BackgroundColor3 = dark
|
|
input.Parent = parent
|
|
UI.bindButton(input, accent)
|
|
root, button = input, input
|
|
lockedSurface = UI.plate(input, "LockedSurface", UDim2.fromScale(0, 0), UDim2.fromScale(1, 1),
|
|
Color3.fromRGB(104, 104, 104), Color3.fromRGB(38, 38, 38))
|
|
lockedSurface.Visible = false
|
|
else
|
|
local plate = UI.plate(parent, "ModeCard", position, size, accent, dark)
|
|
root, shell = plate, plate
|
|
end
|
|
|
|
local art = UI.frame("Illustration", root, UDim2.fromOffset(6, 6), UDim2.new(1, -12, 1, -46), dark)
|
|
art.ClipsDescendants = true
|
|
local image = Instance.new("ImageLabel")
|
|
image.Name = "Artwork"
|
|
image.BackgroundTransparency = 1
|
|
image.Size = UDim2.fromScale(1, 1)
|
|
image.ScaleType = Enum.ScaleType.Crop
|
|
image.Parent = art
|
|
local shade = UI.frame("Shade", art, UDim2.new(0, 0, .66, 0), UDim2.new(1, 0, .34, 0), shadeColor)
|
|
local fade = Instance.new("UIGradient", shade)
|
|
fade.Rotation = 90
|
|
fade.Transparency = NumberSequence.new(1, .48)
|
|
local title = UI.label(root, "ModeName", "", UDim2.new(0, 8, 1, -38), UDim2.new(1, -16, 0, 32), 19, UI.Ink)
|
|
title.FontFace = UI.Display
|
|
title.TextScaled = true
|
|
Instance.new("UITextSizeConstraint", title).MaxTextSize = 19
|
|
local score = UI.plate(root, "Badge", UDim2.new(1, -12, 0, 12), UDim2.fromOffset(if interactive then 46 else 75, 30),
|
|
accent:Lerp(dark, .4), badgeFill)
|
|
score.AnchorPoint = Vector2.new(1, 0)
|
|
local badge = UI.label(score, "Value", "", UDim2.fromScale(0, 0), UDim2.fromScale(1, 1), 17, UI.Ink)
|
|
badge.FontFace = UI.Display
|
|
local glow = UI.frame("ChoiceGlow", root, UDim2.fromScale(0, 0), UDim2.fromScale(1, 1), UI.Blue)
|
|
glow.BackgroundTransparency = 1
|
|
glow.Visible = false
|
|
glow:SetAttribute("CornerCut", 8)
|
|
if interactive then
|
|
UI.edge(glow, UI.Blue, .85).Thickness = 2
|
|
UI.contour(glow, UI.Blue)
|
|
end
|
|
local result = {root = root, button = button, art = art, image = image, title = title, badge = badge,
|
|
glow = glow, frame = shell, accent = accent, badgePanel = score, shade = shade, lockedSurface = lockedSurface}
|
|
appearance(result, id)
|
|
return result
|
|
end
|
|
|
|
function ModeCard.setMode(card: Card, id: string)
|
|
appearance(card, id)
|
|
end
|
|
|
|
function ModeCard.setSelected(card: Card, selected: boolean)
|
|
card.glow.Visible = selected
|
|
card.title.TextColor3 = if selected then UI.Blue:Lerp(UI.Ink, .45) else UI.Ink
|
|
local button = card.button
|
|
if button then button.BackgroundColor3 = if selected then dark:Lerp(UI.Blue, .22) else dark end
|
|
end
|
|
|
|
function ModeCard.setMuted(card: Card, muted: boolean)
|
|
local surface = card.lockedSurface
|
|
if surface then surface.Visible = muted end
|
|
card.art.BackgroundColor3 = if muted then Color3.fromRGB(76, 76, 76) else dark:Lerp(card.accent, .28)
|
|
card.image.ImageColor3 = if muted then Color3.fromRGB(155, 155, 155) else Color3.new(1, 1, 1)
|
|
card.image.ImageTransparency = if muted then .83 else 0
|
|
card.shade.BackgroundColor3 = if muted then Color3.fromRGB(32, 32, 32) else shadeColor
|
|
card.title.TextColor3 = if muted then Color3.fromRGB(218, 218, 218) else UI.Ink
|
|
card.badge.TextColor3 = if muted then Color3.fromRGB(201, 201, 201) else card.accent:Lerp(UI.Ink, .28)
|
|
UI.tintPlate(card.badgePanel, if muted then Color3.fromRGB(113, 113, 113) else card.accent:Lerp(dark, .4),
|
|
if muted then Color3.fromRGB(39, 39, 39) else badgeFill)
|
|
end
|
|
|
|
return ModeCard
|