Skip to content

Commit

Permalink
Lua: Sync with C# side
Browse files Browse the repository at this point in the history
  • Loading branch information
manups4e committed Mar 3, 2024
1 parent caf3360 commit 4a8a5b8
Show file tree
Hide file tree
Showing 19 changed files with 581 additions and 81 deletions.
1 change: 1 addition & 0 deletions ScaleformUI_Lua/src/Menus/MenuHandler.lua
Expand Up @@ -51,6 +51,7 @@ function MenuHandler:SwitchTo(currentMenu, newMenu, newMenuCurrentSelection, inh
newMenu:MouseSettings(currentMenu:MouseControlsEnabled(), currentMenu:MouseEdgeEnabled(), currentMenu:MouseWheelControlEnabled(), currentMenu.Settings.ResetCursorOnOpen, currentMenu.leftClickEnabled)
newMenu.enabled3DAnimations = currentMenu.enabled3DAnimations
newMenu.fadingTime = currentMenu.fadingTime
newMenu.SubtitleColor = currentMenu.SubtitleColor
--[[
newMenu.Settings.MouseControlsEnabled = currentMenu.Settings.MouseControlsEnabled
newMenu.Settings.MouseEdgeEnabled = currentMenu.Settings.MouseEdgeEnabled
Expand Down
Expand Up @@ -21,9 +21,9 @@ end
---@param label string
---@param color SColor
---@return table
function MissionListColumn.New(label, color, scrollType)
function MissionListColumn.New(label, color, scrollType, _maxItems)
local handler = PaginationHandler.New()
handler:ItemsPerPage(12)
handler:ItemsPerPage(_maxItems or 16)
handler.scrollType = scrollType or MenuScrollingType.CLASSIC
local _data = {
_isBuilding = false,
Expand Down
Expand Up @@ -21,9 +21,9 @@ end
---@param label string
---@param color number|SColor
---@return table
function PlayerListColumn.New(label, color, scrollType)
function PlayerListColumn.New(label, color, scrollType,_maxItems)
local handler = PaginationHandler.New()
handler:ItemsPerPage(12)
handler:ItemsPerPage(_maxItems or 16)
handler.scrollType = scrollType or MenuScrollingType.CLASSIC
local _data = {
_isBuilding = false,
Expand Down
Expand Up @@ -18,9 +18,9 @@ end
---@field public OnIndexChanged fun(index: number)
---@field public AddSettings fun(self: SettingsListColumn, item: SettingsListItem)

function SettingsListColumn.New(label, color, scrollType)
function SettingsListColumn.New(label, color, scrollType,_maxItems)
local handler = PaginationHandler.New()
handler:ItemsPerPage(12)
handler:ItemsPerPage(_maxItems or 16)
handler.scrollType = scrollType or MenuScrollingType.CLASSIC
local _data = {
_isBuilding = false,
Expand Down
18 changes: 18 additions & 0 deletions ScaleformUI_Lua/src/Menus/PauseMenus/LobbyMenu/Items/FakeBlip.lua
@@ -0,0 +1,18 @@
FakeBlip = setmetatable({}, FakeBlip)
FakeBlip.__index = FakeBlip
FakeBlip.__call = function()
return "LobbyItem", "FakeBlip"
end

---@class FakeBlip
---@field private New fun(sprite:number, position:vector3)
---@field public Sprite number
---@field public Position vector3

function FakeBlip.New(sprite, position)
local _data = {
Sprite = sprite,
Position = position
}
return setmetatable(_data, FakeBlip)
end
@@ -0,0 +1,18 @@
MinimapRaceCheckpoint = setmetatable({}, MinimapRaceCheckpoint)
MinimapRaceCheckpoint.__index = MinimapRaceCheckpoint
MinimapRaceCheckpoint.__call = function()
return "LobbyItem", "MinimapRaceCheckpoint"
end

---@class MinimapRaceCheckpoint
---@field private New fun(sprite:number, position:vector3)
---@field public Sprite number
---@field public Position vector3

function MinimapRaceCheckpoint.New(sprite, position)
local _data = {
Sprite = sprite,
Position = position
}
return setmetatable(_data, MinimapRaceCheckpoint)
end
@@ -0,0 +1,53 @@
MinimapRoute = setmetatable({}, MinimapRoute)
MinimapRoute.__index = MinimapRoute
MinimapRoute.__call = function()
return "LobbyComponent", "MinimapRoute"
end

---@class MinimapRoute
---@field private New fun()
---@field public StartPoint MinimapRaceCheckpoint
---@field public EndPoint MinimapRaceCheckpoint
---@field public CheckPoints MinimapRaceCheckpoint[]
---@field public RadarThickness number
---@field public MapThickness number
---@field public RouteColor HudColours
---@field private SetupCustomRoute fun()

function MinimapRoute.New()
local _data = {
StartPoint = MinimapRaceCheckpoint.New(0, vector3(0,0,0)),
EndPoint = MinimapRaceCheckpoint.New(0, vector3(0,0,0)),
CheckPoints = {},
RadarThickness = 18,
MapThickness = 30,
RouteColor = HudColours.HUD_COLOUR_FREEMODE
}
return setmetatable(_data, MinimapRoute)
end

function MinimapRoute:SetupCustomRoute()
if self.StartPoint == nil or self.StartPoint.Position.x == 0 or self.StartPoint.Position.y == 0 or self.StartPoint.Position.z == 0 then
return
end

StartGpsCustomRoute(self.RouteColor, true, true)

RaceGalleryNextBlipSprite(self.StartPoint.Sprite)
RaceGalleryAddBlip(self.StartPoint.Position.x, self.StartPoint.Position.y, self.StartPoint.Position.z)

AddPointToGpsCustomRoute(self.StartPoint.Position.x, self.StartPoint.Position.y, self.StartPoint.Position.z)

for i=1,#self.CheckPoints, 1 do
local checkPoint = self.CheckPoints[i]
RaceGalleryNextBlipSprite(checkPoint.Sprite)
RaceGalleryAddBlip(checkPoint.Position.x, checkPoint.Position.y, checkPoint.Position.z)
AddPointToGpsCustomRoute(checkPoint.Position.x, checkPoint.Position.y, checkPoint.Position.z)
end

RaceGalleryNextBlipSprite(self.EndPoint.Sprite)
RaceGalleryAddBlip(self.EndPoint.Position.x, self.EndPoint.Position.y, self.EndPoint.Position.z)
AddPointToGpsCustomRoute(self.EndPoint.Position.x, self.EndPoint.Position.y, self.EndPoint.Position.z)

SetGpsCustomRouteRender(true, self.RadarThickness * 10, self.MapThickness * 10)
end
42 changes: 27 additions & 15 deletions ScaleformUI_Lua/src/Menus/PauseMenus/LobbyMenu/MainView.lua
Expand Up @@ -38,6 +38,8 @@ function MainView.New(title, subtitle, sideTop, sideMid, sideBot, newStyle)
MissionsColumn = nil --[[@type MissionListColumn]],
StoreColumn = nil --[[@type StoreListColumn]],
MissionPanel = nil --[[@type MissionDetailsPanel]],
Minimap = MinimapPanel.New(nil), --[[@type MinimapPanel]]
timer = 100,
_showStoreBG = false,
_storeBGSpeed = 240,
_focus = 1,
Expand Down Expand Up @@ -71,7 +73,9 @@ function MainView.New(title, subtitle, sideTop, sideMid, sideBot, newStyle)
end
]]
}
return setmetatable(_data, MainView)
local meta = setmetatable(_data, MainView)
meta.Minimap.Parent = meta
return meta
end

function MainView:Focus()
Expand Down Expand Up @@ -110,18 +114,19 @@ function MainView:Visible(visible)
if not IsPauseMenuActive() then
self._focus = 1
PlaySoundFrontend(self.SoundId, "Hit_In", "PLAYER_SWITCH_CUSTOM_SOUNDSET", true)
ActivateFrontendMenu(`FE_MENU_VERSION_EMPTY_NO_BACKGROUND`, true, -1)
ActivateFrontendMenu(`FE_MENU_VERSION_CORONA`, true, 0)
self:BuildPauseMenu()
self.OnLobbyMenuOpen(self)
AnimpostfxPlay("PauseMenuIn", 800, true)
ScaleformUI.Scaleforms.InstructionalButtons:SetInstructionalButtons(self.InstructionalButtons)
SetPlayerControl(PlayerId(), false, 0)
self._firstTick = true
MenuHandler._currentPauseMenu = self
MenuHandler.ableToDraw = true;
MenuHandler.ableToDraw = true
end
else
MenuHandler.ableToDraw = false;
self.Minimap:Dispose()
MenuHandler.ableToDraw = false
MenuHandler._currentPauseMenu = nil
ScaleformUI.Scaleforms._pauseMenu:Dispose()
ScaleformUI.Scaleforms.InstructionalButtons:ClearButtonList()
Expand All @@ -131,7 +136,7 @@ function MainView:Visible(visible)
SetPlayerControl(PlayerId(), true, 0)
if IsPauseMenuActive() then
PlaySoundFrontend(self.SoundId, "Hit_Out", "PLAYER_SWITCH_CUSTOM_SOUNDSET", true)
ActivateFrontendMenu(`FE_MENU_VERSION_EMPTY_NO_BACKGROUND`, false, -1)
ActivateFrontendMenu(`FE_MENU_VERSION_CORONA`, false, 0)
end
SetFrontendActive(false)
end
Expand Down Expand Up @@ -259,8 +264,8 @@ function MainView:ShowHeader()
ScaleformUI.Scaleforms._pauseMenu:AddLobbyMenuTab(self.listCol[1]._label, 2, self.listCol[1]._color)
ScaleformUI.Scaleforms._pauseMenu:AddLobbyMenuTab(self.listCol[2]._label, 2, self.listCol[2]._color)
ScaleformUI.Scaleforms._pauseMenu:AddLobbyMenuTab(self.listCol[3]._label, 2, self.listCol[3]._color)
ScaleformUI.Scaleforms._pauseMenu._header:CallFunction("SET_ALL_HIGHLIGHTS", true, 117);
ScaleformUI.Scaleforms._pauseMenu._header:CallFunction("ENABLE_DYNAMIC_WIDTH", false);
ScaleformUI.Scaleforms._pauseMenu._header:CallFunction("SET_ALL_HIGHLIGHTS", true, 117)
ScaleformUI.Scaleforms._pauseMenu._header:CallFunction("ENABLE_DYNAMIC_WIDTH", false)
self._loaded = true
end

Expand All @@ -271,10 +276,16 @@ function MainView:BuildPauseMenu()
ScaleformUI.Scaleforms._pauseMenu._pauseBG:CallFunction("ANIMATE_BACKGROUND", self:StoreBackgroundAnimationSpeed())
if #self.listCol == 1 then
ScaleformUI.Scaleforms._pauseMenu._lobby:CallFunction("CREATE_MENU", self.listCol[1].Type)
ScaleformUI.Scaleforms._pauseMenu._lobby:CallFunction("SET_COLUMN_MAXITEMS", 0, self.listCol[1].Pagination:ItemsPerPage())
elseif #self.listCol == 2 then
ScaleformUI.Scaleforms._pauseMenu._lobby:CallFunction("CREATE_MENU", self.listCol[1].Type, self.listCol[2].Type)
ScaleformUI.Scaleforms._pauseMenu._lobby:CallFunction("SET_COLUMN_MAXITEMS", 0, self.listCol[1].Pagination:ItemsPerPage())
ScaleformUI.Scaleforms._pauseMenu._lobby:CallFunction("SET_COLUMN_MAXITEMS", 1, self.listCol[2].Pagination:ItemsPerPage())
elseif #self.listCol == 3 then
ScaleformUI.Scaleforms._pauseMenu._lobby:CallFunction("CREATE_MENU", self.listCol[1].Type, self.listCol[2].Type, self.listCol[3].Type)
ScaleformUI.Scaleforms._pauseMenu._lobby:CallFunction("SET_COLUMN_MAXITEMS", 0, self.listCol[1].Pagination:ItemsPerPage())
ScaleformUI.Scaleforms._pauseMenu._lobby:CallFunction("SET_COLUMN_MAXITEMS", 1, self.listCol[2].Pagination:ItemsPerPage())
ScaleformUI.Scaleforms._pauseMenu._lobby:CallFunction("SET_COLUMN_MAXITEMS", 2, self.listCol[3].Pagination:ItemsPerPage())
end
ScaleformUI.Scaleforms._pauseMenu._lobby:CallFunction("SET_NEWSTYLE", self._newStyle)

Expand All @@ -289,8 +300,8 @@ function MainView:BuildPauseMenu()
elseif col.Type == "store" then
self:buildStore()
elseif col.Type == "panel" then
ScaleformUI.Scaleforms._pauseMenu._lobby:CallFunction("ADD_MISSION_PANEL_PICTURE", self.MissionPanel.TextureDict, self.MissionPanel.TextureName);
ScaleformUI.Scaleforms._pauseMenu._lobby:CallFunction("SET_MISSION_PANEL_TITLE", self.MissionPanel:Title());
ScaleformUI.Scaleforms._pauseMenu._lobby:CallFunction("ADD_MISSION_PANEL_PICTURE", self.MissionPanel.TextureDict, self.MissionPanel.TextureName)
ScaleformUI.Scaleforms._pauseMenu._lobby:CallFunction("SET_MISSION_PANEL_TITLE", self.MissionPanel:Title())
for k, item in pairs(self.MissionPanel.Items) do
ScaleformUI.Scaleforms._pauseMenu._lobby:CallFunction("ADD_MISSION_PANEL_ITEM", item.Type, item.TextLeft,
item.TextRight, item.Icon or 0, item.IconColor or SColor.HUD_Pure_white, item.Tick, item._labelFont.FontName, item._labelFont.FontID, item._rightLabelFont.FontName, item._rightLabelFont.FontID)
Expand Down Expand Up @@ -485,6 +496,7 @@ function MainView:Draw()
if not self:Visible() or self.TemporarilyHidden or self._isBuilding then
return
end
self.Minimap:MaintainMap();
DisableControlAction(0, 199, true)
DisableControlAction(0, 200, true)
DisableControlAction(1, 199, true)
Expand All @@ -494,6 +506,7 @@ function MainView:Draw()
ScaleformUI.Scaleforms._pauseMenu:Draw(true)
if self._firstTick then
ScaleformUI.Scaleforms._pauseMenu._lobby:CallFunction("FADE_IN")
self.timer = GetNetworkTime()
self._firstTick = false
end
end
Expand All @@ -510,8 +523,7 @@ function MainView:ProcessMouse()
SetInputExclusive(2, 237)
SetInputExclusive(2, 238)

success, event_type, context, item_id = GetScaleformMovieCursorSelection(ScaleformUI.Scaleforms._pauseMenu._lobby
.handle)
success, event_type, context, item_id = GetScaleformMovieCursorSelection(ScaleformUI.Scaleforms._pauseMenu._lobby.handle)
if success then
if event_type == 5 then
local foc = self:Focus()
Expand Down Expand Up @@ -738,8 +750,8 @@ function MainView:GoLeft()
end

if self.listCol[self._focus].Type == "settings" then
ClearPedInPauseMenu();
local item = self.SettingsColumn.Items[self.SettingsColumn:CurrentSelection()];
ClearPedInPauseMenu()
local item = self.SettingsColumn.Items[self.SettingsColumn:CurrentSelection()]
if not item:Enabled() then
if self._newStyle then
item:Selected(false)
Expand Down Expand Up @@ -824,8 +836,8 @@ function MainView:GoRight()
end

if self.listCol[self._focus].Type == "settings" then
ClearPedInPauseMenu();
local item = self.SettingsColumn.Items[self.SettingsColumn:CurrentSelection()];
ClearPedInPauseMenu()
local item = self.SettingsColumn.Items[self.SettingsColumn:CurrentSelection()]
if not item:Enabled() then
if self._newStyle then
item:Selected(false)
Expand Down

0 comments on commit 4a8a5b8

Please sign in to comment.