Skip to content

Commit

Permalink
add systemlink row ui_scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Joelrau committed Aug 6, 2024
1 parent 02752b7 commit 6740c9e
Show file tree
Hide file tree
Showing 4 changed files with 347 additions and 1 deletion.
1 change: 0 additions & 1 deletion data/cdata/ui_scripts/SystemLinkMenu/SysLinkBrowser.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local serverBrowserPath = "frontEnd.systemLinkMenu.serverBrowser"
local serverBrowserOffsets = {10, 240, 360, 450}

local leaveMenuHandler = function(menu, controller)
-- Engine.StopGameMode()
Expand Down
242 changes: 242 additions & 0 deletions data/cdata/ui_scripts/SystemLinkMenu/SystemLinkJoinMenuRow.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
local function PostLoadFunc(element, controllerIndex, controller)
element:addEventHandler("button_action", function(arg0, arg1)
local dataSource = element:GetDataSource()
Lobby.JoinServer(controllerIndex, dataSource.index)
end)
end

function SystemLinkJoinMenuRow(menu, controller)
local self = LUI.UIButton.new()
self:SetAnchorsAndPosition(0, 1, 0, 1, 0, 1131 * _1080p, 0, 35 * _1080p)
self.id = "SystemLinkJoinMenuRow"
self._animationSets = {}
self._sequences = {}
local controllerIndex = controller and controller.controllerIndex
if not controllerIndex and not Engine.InFrontend() then
controllerIndex = self:getRootController()
end
assert(controllerIndex)

local DropShadow = nil

DropShadow = LUI.UIImage.new()
DropShadow.id = "DropShadow"
DropShadow:SetRGBFromInt(0, 0)
DropShadow:SetAlpha(0.3, 0)
DropShadow:setImage(RegisterMaterial("widg_gradient_top_to_bottom"), 0)
DropShadow:SetAnchorsAndPosition(0, 0, 1, 0, 0, 0, 0, _1080p * 4)
self:addElement(DropShadow)
self.DropShadow = DropShadow

local RowBG = nil

RowBG = LUI.UIImage.new()
RowBG.id = "RowBG"
RowBG:SetRGBFromInt(0, 0)
RowBG:SetAlpha(0.5, 0)
self:addElement(RowBG)
self.RowBG = RowBG

local Host = nil

Host = LUI.UIStyledText.new()
Host.id = "Host"
Host:SetRGBFromInt(14277081, 0)
Host:SetFontSize(24 * _1080p)
Host:SetFont(FONTS.GetFont(FONTS.MainMedium.File))
Host:SetAlignment(LUI.Alignment.Left)
Host:SetStartupDelay(1000)
Host:SetLineHoldTime(400)
Host:SetAnimMoveTime(3000)
Host:SetEndDelay(1000)
Host:SetCrossfadeTime(400)
Host:SetAutoScrollStyle(LUI.UIStyledText.AutoScrollStyle.ScrollH)
Host:SetMaxVisibleLines(1)
Host:SetAnchorsAndPosition(0, 1, 0.5, 0.5, _1080p * 12, _1080p * 279, _1080p * -12, _1080p * 12)
Host:SubscribeToModelThroughElement(self, "host", function()
local dataSource = self:GetDataSource()
dataSource = dataSource.host:GetValue(controllerIndex)
if dataSource ~= nil then
Host:setText(dataSource, 0)
end
end)
self:addElement(Host)
self.Host = Host

local Players = nil

Players = LUI.UIText.new()
Players.id = "Players"
Players:SetRGBFromInt(14277081, 0)
Players:SetFontSize(24 * _1080p)
Players:SetFont(FONTS.GetFont(FONTS.MainMedium.File))
Players:SetAlignment(LUI.Alignment.Left)
Players:SetAnchorsAndPosition(0, 1, 0.5, 0.5, _1080p * 286, _1080p * 421, _1080p * -12, _1080p * 12)
Players:SubscribeToModelThroughElement(self, "players", function()
local dataSource = self:GetDataSource()
dataSource = dataSource.players:GetValue(controllerIndex)
if dataSource ~= nil then
Players:setText(dataSource, 0)
end
end)
self:addElement(Players)
self.Players = Players

local Status = nil

Status = LUI.UIText.new()
Status.id = "Status"
Status:SetRGBFromInt(14277081, 0)
Status:SetFontSize(24 * _1080p)
Status:SetFont(FONTS.GetFont(FONTS.MainMedium.File))
Status:SetAlignment(LUI.Alignment.Left)
Status:SetAnchorsAndPosition(0, 1, 0.5, 0.5, _1080p * 426, _1080p * 626, _1080p * -12, _1080p * 12)
Status:SubscribeToModelThroughElement(self, "status", function()
local dataSource = self:GetDataSource()
dataSource = dataSource.status:GetValue(controllerIndex)
if dataSource ~= nil then
Status:setText(ToUpperCase(dataSource), 0)
end
end)
self:addElement(Status)
self.Status = Status

local Map = nil

Map = LUI.UIStyledText.new()
Map.id = "Map"
Map:SetRGBFromInt(14277081, 0)
Map:SetFontSize(24 * _1080p)
Map:SetFont(FONTS.GetFont(FONTS.MainMedium.File))
Map:SetAlignment(LUI.Alignment.Left)
Map:SetStartupDelay(1250)
Map:SetLineHoldTime(400)
Map:SetAnimMoveTime(300)
Map:SetEndDelay(1000)
Map:SetCrossfadeTime(500)
Map:SetAutoScrollStyle(LUI.UIStyledText.AutoScrollStyle.ScrollH)
Map:SetMaxVisibleLines(1)
Map:SetAnchorsAndPosition(0, 1, 0.5, 0.5, _1080p * 627, _1080p * 853, _1080p * -12, _1080p * 12)
Map:SubscribeToModelThroughElement(self, "map", function()
local dataSource = self:GetDataSource()
dataSource = dataSource.map:GetValue(controllerIndex)
if dataSource ~= nil then
Map:setText(dataSource, 0)
end
end)
self:addElement(Map)
self.Map = Map

local Type = nil

Type = LUI.UIText.new()
Type.id = "Type"
Type:SetRGBFromInt(14277081, 0)
Type:SetFontSize(24 * _1080p)
Type:SetFont(FONTS.GetFont(FONTS.MainMedium.File))
Type:SetAlignment(LUI.Alignment.Left)
Type:SetAnchorsAndPosition(0, 1, 0.5, 0.5, _1080p * 862, _1080p * 1119, _1080p * -12, _1080p * 12)
Type:SubscribeToModelThroughElement(self, "type", function()
local dataSource = self:GetDataSource()
dataSource = dataSource.type:GetValue(controllerIndex)
if dataSource ~= nil then
Type:setText(dataSource, 0)
end
end)
self:addElement(Type)
self.Type = Type

local Cap = nil

Cap = LUI.UIImage.new()
Cap.id = "Cap"
Cap:SetRGBFromInt(14277081, 0)
Cap:SetAnchorsAndPosition(0, 1, 0, 0, 0, _1080p * 6, 0, 0)
self:addElement(Cap)
self.Cap = Cap

self._animationSets.DefaultAnimationSet = function()
self._sequences.DefaultSequence = function()

end

RowBG:RegisterAnimationSequence("ButtonOver", {{function()
return self.RowBG:SetAlpha(1, 0)
end}, {function()
return self.RowBG:SetRGBFromInt(14277081, 0)
end}})
Host:RegisterAnimationSequence("ButtonOver", {{function()
return self.Host:SetRGBFromInt(0, 0)
end}})
Players:RegisterAnimationSequence("ButtonOver", {{function()
return self.Players:SetRGBFromInt(0, 0)
end}})
Status:RegisterAnimationSequence("ButtonOver", {{function()
return self.Status:SetRGBFromInt(0, 0)
end}})
Map:RegisterAnimationSequence("ButtonOver", {{function()
return self.Map:SetRGBFromInt(0, 0)
end}})
Type:RegisterAnimationSequence("ButtonOver", {{function()
return self.Type:SetRGBFromInt(0, 0)
end}})
Cap:RegisterAnimationSequence("ButtonOver", {{function()
return self.Cap:SetRGBFromInt(0, 0)
end}})
self._sequences.ButtonOver = function()
RowBG:AnimateSequence("ButtonOver")
Host:AnimateSequence("ButtonOver")
Players:AnimateSequence("ButtonOver")
Status:AnimateSequence("ButtonOver")
Map:AnimateSequence("ButtonOver")
Type:AnimateSequence("ButtonOver")
Cap:AnimateSequence("ButtonOver")
end

RowBG:RegisterAnimationSequence("ButtonUp", {{function()
return self.RowBG:SetAlpha(0.5, 0)
end}, {function()
return self.RowBG:SetRGBFromInt(0, 0)
end}})
Host:RegisterAnimationSequence("ButtonUp", {{function()
return self.Host:SetRGBFromInt(14277081, 0)
end}})
Players:RegisterAnimationSequence("ButtonUp", {{function()
return self.Players:SetRGBFromInt(14277081, 0)
end}})
Status:RegisterAnimationSequence("ButtonUp", {{function()
return self.Status:SetRGBFromInt(14277081, 0)
end}})
Map:RegisterAnimationSequence("ButtonUp", {{function()
return self.Map:SetRGBFromInt(14277081, 0)
end}})
Type:RegisterAnimationSequence("ButtonUp", {{function()
return self.Type:SetRGBFromInt(14277081, 0)
end}})
Cap:RegisterAnimationSequence("ButtonUp", {{function()
return self.Cap:SetRGBFromInt(14277081, 0)
end}})
self._sequences.ButtonUp = function()
RowBG:AnimateSequence("ButtonUp")
Host:AnimateSequence("ButtonUp")
Players:AnimateSequence("ButtonUp")
Status:AnimateSequence("ButtonUp")
Map:AnimateSequence("ButtonUp")
Type:AnimateSequence("ButtonUp")
Cap:AnimateSequence("ButtonUp")
end

end

self._animationSets.DefaultAnimationSet()
self:addEventHandler("button_over", function(arg0, arg1)
ACTIONS.AnimateSequence(self, "ButtonOver")
end)
self:addEventHandler("button_up", function(arg0, arg1)
ACTIONS.AnimateSequence(self, "ButtonUp")
end)
PostLoadFunc(self, controllerIndex, controller)
return self
end

MenuBuilder.m_types["SystemLinkJoinMenuRow"] = SystemLinkJoinMenuRow
103 changes: 103 additions & 0 deletions data/cdata/ui_scripts/SystemLinkMenu/SystemLinkJoinMenuTitleRow.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
local function PostLoadFunc(element, controllerIndex, controller)
assert(element.Status)
assert(element.Type)
assert(element.Players)
assert(element.Map)
assert(element.Host)
if IsLanguageOversizedFont() then
element.Status:SetTop(-11 * _1080p, 0)
element.Status:SetBottom(11 * _1080p, 0)
element.Type:SetTop(-11 * _1080p, 0)
element.Type:SetBottom(11 * _1080p, 0)
element.Players:SetTop(-11 * _1080p, 0)
element.Players:SetBottom(11 * _1080p, 0)
element.Map:SetTop(-11 * _1080p, 0)
element.Map:SetBottom(11 * _1080p, 0)
element.Host:SetTop(-11 * _1080p, 0)
element.Host:SetBottom(11 * _1080p, 0)
end
end

function SystemLinkJoinMenuTitleRow(menu, controller)
local self = LUI.UIElement.new()
self:SetAnchorsAndPosition(0, 1, 0, 1, 0, 1131 * _1080p, 0, 40 * _1080p)
self.id = "SystemLinkJoinMenuTitleRow"
local controllerIndex = controller and controller.controllerIndex
if not controllerIndex and not Engine.InFrontend() then
controllerIndex = self:getRootController()
end
assert(controllerIndex)

local TitleBG = nil

TitleBG = LUI.UIImage.new()
TitleBG.id = "TitleBG"
TitleBG:SetRGBFromInt(0, 0)
self:addElement(TitleBG)
self.TitleBG = TitleBG

local Host = nil

Host = LUI.UIText.new()
Host.id = "Host"
Host:setText(Engine.Localize("MENU_HOST_NAME"), 0)
Host:SetFontSize(24 * _1080p)
Host:SetFont(FONTS.GetFont(FONTS.MainMedium.File))
Host:SetAlignment(LUI.Alignment.Left)
Host:SetAnchorsAndPosition(0, 1, 0.5, 0.5, _1080p * 9, _1080p * 275, _1080p * -12, _1080p * 12)
self:addElement(Host)
self.Host = Host

local Map = nil

Map = LUI.UIText.new()
Map.id = "Map"
Map:setText(Engine.Localize("MENU_MAP"), 0)
Map:SetFontSize(24 * _1080p)
Map:SetFont(FONTS.GetFont(FONTS.MainMedium.File))
Map:SetAlignment(LUI.Alignment.Left)
Map:SetAnchorsAndPosition(0, 1, 0.5, 0.5, _1080p * 627, _1080p * 853, _1080p * -12, _1080p * 12)
self:addElement(Map)
self.Map = Map

local Players = nil

Players = LUI.UIText.new()
Players.id = "Players"
Players:setText(Engine.Localize("MENU_NUMPLAYERS"), 0)
Players:SetFontSize(24 * _1080p)
Players:SetFont(FONTS.GetFont(FONTS.MainMedium.File))
Players:SetAlignment(LUI.Alignment.Left)
Players:SetAnchorsAndPosition(0, 1, 0.5, 0.5, _1080p * 283, _1080p * 418, _1080p * -12, _1080p * 12)
self:addElement(Players)
self.Players = Players

local Type = nil

Type = LUI.UIText.new()
Type.id = "Type"
Type:setText(Engine.Localize("MENU_TYPE1"), 0)
Type:SetFontSize(24 * _1080p)
Type:SetFont(FONTS.GetFont(FONTS.MainMedium.File))
Type:SetAlignment(LUI.Alignment.Left)
Type:SetAnchorsAndPosition(0, 1, 0.5, 0.5, _1080p * 862, _1080p * 1119, _1080p * -12, _1080p * 12)
self:addElement(Type)
self.Type = Type

local Status = nil

Status = LUI.UIText.new()
Status.id = "Status"
Status:setText(Engine.Localize("MENU_STATUS_NAME"), 0)
Status:SetFontSize(24 * _1080p)
Status:SetFont(FONTS.GetFont(FONTS.MainMedium.File))
Status:SetAlignment(LUI.Alignment.Left)
Status:SetAnchorsAndPosition(0, 1, 0.5, 0.5, _1080p * 426, _1080p * 620, _1080p * -12, _1080p * 12)
self:addElement(Status)
self.Status = Status

PostLoadFunc(self, controllerIndex, controller)
return self
end

MenuBuilder.m_types["SystemLinkJoinMenuTitleRow"] = SystemLinkJoinMenuTitleRow
2 changes: 2 additions & 0 deletions data/cdata/ui_scripts/SystemLinkMenu/__init__.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ end

require("ServerButtons")
require("SysLinkBrowser")
require("SystemLinkJoinMenuRow")
require("SystemLinkJoinMenuTitleRow")

0 comments on commit 6740c9e

Please sign in to comment.