From 08bdbec52f8cbdc82de663b93805facd2ef0a2d5 Mon Sep 17 00:00:00 2001 From: Leonardo Emanuele Date: Mon, 30 Sep 2024 17:34:04 +0200 Subject: [PATCH] Pause/Lobby fix mouse handling logic --- .../Elements/Columns/MissionsListColumn.cs | 2 +- .../Elements/Columns/PlayerListColumn.cs | 6 +-- .../Elements/Columns/SettingsListColumn.cs | 6 +-- .../Elements/Columns/StoreListColumn.cs | 2 +- .../Menus/Pause Menus/LobbyMenu/MainView.cs | 36 ++++++++-------- .../Menus/Pause Menus/PauseMenu/TabView.cs | 42 +++++++++++-------- 6 files changed, 49 insertions(+), 45 deletions(-) diff --git a/ScaleformUI_Csharp/Menus/Pause Menus/Elements/Columns/MissionsListColumn.cs b/ScaleformUI_Csharp/Menus/Pause Menus/Elements/Columns/MissionsListColumn.cs index 6d90dce8..73152f1c 100644 --- a/ScaleformUI_Csharp/Menus/Pause Menus/Elements/Columns/MissionsListColumn.cs +++ b/ScaleformUI_Csharp/Menus/Pause Menus/Elements/Columns/MissionsListColumn.cs @@ -233,7 +233,7 @@ public int CurrentSelection get { return Items.Count == 0 ? 0 : Pagination.CurrentMenuIndex; } set { - if (value == CurrentSelection) return; + if (value == Pagination.CurrentMenuIndex) return; if (value < 0) { Pagination.CurrentMenuIndex = 0; diff --git a/ScaleformUI_Csharp/Menus/Pause Menus/Elements/Columns/PlayerListColumn.cs b/ScaleformUI_Csharp/Menus/Pause Menus/Elements/Columns/PlayerListColumn.cs index 0d03b493..2d53a506 100644 --- a/ScaleformUI_Csharp/Menus/Pause Menus/Elements/Columns/PlayerListColumn.cs +++ b/ScaleformUI_Csharp/Menus/Pause Menus/Elements/Columns/PlayerListColumn.cs @@ -240,7 +240,7 @@ public int CurrentSelection get { return Items.Count == 0 ? 0 : Pagination.CurrentMenuIndex; } set { - if (value == CurrentSelection) return; + if (value == Pagination.CurrentMenuIndex) return; API.ClearPedInPauseMenu(); if (value < 0) { @@ -268,9 +268,9 @@ public int CurrentSelection { lobby._pause._lobby.CallFunction("SET_PLAYERS_SELECTION", Pagination.GetScaleformIndex(Pagination.CurrentMenuIndex)); lobby._pause._lobby.CallFunction("SET_PLAYERS_QTTY", CurrentSelection + 1, Items.Count); - Items[CurrentSelection].Selected = true; - if (lobby.listCol[0].Type == "players" || (lobby.listCol.Any(x => x.Type == "players") && Items.Count > 0 && Items[0].KeepPanelVisible)) + if (lobby.listCol[lobby.FocusLevel].Type == "players") { + Items[CurrentSelection].Selected = true; if (Items[CurrentSelection].ClonePed != null) Items[CurrentSelection].CreateClonedPed(); } diff --git a/ScaleformUI_Csharp/Menus/Pause Menus/Elements/Columns/SettingsListColumn.cs b/ScaleformUI_Csharp/Menus/Pause Menus/Elements/Columns/SettingsListColumn.cs index 65eb4e1d..2ca4bcac 100644 --- a/ScaleformUI_Csharp/Menus/Pause Menus/Elements/Columns/SettingsListColumn.cs +++ b/ScaleformUI_Csharp/Menus/Pause Menus/Elements/Columns/SettingsListColumn.cs @@ -95,7 +95,7 @@ internal void _itemCreation(int page, int pageIndex, bool before, bool isOverflo AddTextEntry($"menu_lobby_desc_{menuIndex}", item.Description); BeginScaleformMovieMethod(lobby._pause._lobby.Handle, "ADD_LEFT_ITEM"); PushScaleformMovieFunctionParameterBool(before); - PushScaleformMovieFunctionParameterInt(menuIndex); + PushScaleformMovieFunctionParameterInt(scaleformIndex); PushScaleformMovieFunctionParameterInt(item._itemId); PushScaleformMovieMethodParameterString(item._formatLeftLabel); if (item.DescriptionHash != 0 && string.IsNullOrWhiteSpace(item.Description)) @@ -195,7 +195,7 @@ internal void _itemCreation(int page, int pageIndex, bool before, bool isOverflo AddTextEntry($"menu_pause_playerTab[{pause.Index}]_desc_{menuIndex}", item.Description); BeginScaleformMovieMethod(pause._pause._pause.Handle, "ADD_PLAYERS_TAB_SETTINGS_ITEM"); PushScaleformMovieFunctionParameterBool(before); - PushScaleformMovieFunctionParameterInt(menuIndex); + PushScaleformMovieFunctionParameterInt(scaleformIndex); PushScaleformMovieFunctionParameterInt(item._itemId); PushScaleformMovieMethodParameterString(item._formatLeftLabel); if (item.DescriptionHash != 0 && string.IsNullOrWhiteSpace(item.Description)) @@ -415,7 +415,7 @@ public int CurrentSelection get { return Items.Count == 0 ? 0 : Pagination.CurrentMenuIndex; } set { - if (value == CurrentSelection) + if (value == Pagination.CurrentMenuIndex) { if (Parent != null && Parent.Visible) { diff --git a/ScaleformUI_Csharp/Menus/Pause Menus/Elements/Columns/StoreListColumn.cs b/ScaleformUI_Csharp/Menus/Pause Menus/Elements/Columns/StoreListColumn.cs index eeef2416..ef9bb2fc 100644 --- a/ScaleformUI_Csharp/Menus/Pause Menus/Elements/Columns/StoreListColumn.cs +++ b/ScaleformUI_Csharp/Menus/Pause Menus/Elements/Columns/StoreListColumn.cs @@ -223,7 +223,7 @@ public int CurrentSelection get { return Items.Count == 0 ? 0 : Pagination.CurrentMenuIndex; } set { - if (value == CurrentSelection) return; + if (value == Pagination.CurrentMenuIndex) return; if (value < 0) { Pagination.CurrentMenuIndex = 0; diff --git a/ScaleformUI_Csharp/Menus/Pause Menus/LobbyMenu/MainView.cs b/ScaleformUI_Csharp/Menus/Pause Menus/LobbyMenu/MainView.cs index b33b44e7..85b8e345 100644 --- a/ScaleformUI_Csharp/Menus/Pause Menus/LobbyMenu/MainView.cs +++ b/ScaleformUI_Csharp/Menus/Pause Menus/LobbyMenu/MainView.cs @@ -520,27 +520,28 @@ public override async void ProcessMouse() { int foc = FocusLevel; int curSel = 0; - if (_newStyle) + switch (listCol[foc].Type) { - switch (listCol[foc].Type) - { - case "settings": - curSel = SettingsColumn.CurrentSelection; + case "settings": + curSel = SettingsColumn.CurrentSelection; + if (_newStyle) SettingsColumn.Items[SettingsColumn.CurrentSelection].Selected = false; - break; - case "players": - curSel = PlayersColumn.CurrentSelection; + break; + case "players": + curSel = PlayersColumn.CurrentSelection; + if (_newStyle) PlayersColumn.Items[PlayersColumn.CurrentSelection].Selected = false; - break; - case "missions": - curSel = MissionsColumn.CurrentSelection; + break; + case "missions": + curSel = MissionsColumn.CurrentSelection; + if (_newStyle) MissionsColumn.Items[MissionsColumn.CurrentSelection].Selected = false; - break; - case "store": - curSel = StoreColumn.CurrentSelection; + break; + case "store": + curSel = StoreColumn.CurrentSelection; + if (_newStyle) StoreColumn.Items[StoreColumn.CurrentSelection].Selected = false; - break; - } + break; } updateFocus(context, true); int index = listCol[FocusLevel].Pagination.GetMenuIndexFromScaleformIndex(itemId); @@ -675,9 +676,6 @@ public override async void ProcessControls() public async void Select() { - string result = await _pause._lobby.CallFunctionReturnValueString("SET_INPUT_EVENT", 16); - - int[] split = result.Split(',').Select(int.Parse).ToArray(); switch (listCol[FocusLevel].Type) { case "settings": diff --git a/ScaleformUI_Csharp/Menus/Pause Menus/PauseMenu/TabView.cs b/ScaleformUI_Csharp/Menus/Pause Menus/PauseMenu/TabView.cs index ecb632c9..5094db71 100644 --- a/ScaleformUI_Csharp/Menus/Pause Menus/PauseMenu/TabView.cs +++ b/ScaleformUI_Csharp/Menus/Pause Menus/PauseMenu/TabView.cs @@ -1718,8 +1718,13 @@ public override async void ProcessMouse() FocusLevel = 1; if (Tabs[Index] is PlayerListTab tab) { - if (tab.PlayersColumn.Items[tab.PlayersColumn.CurrentSelection].ClonePed != null) - tab.PlayersColumn.Items[tab.PlayersColumn.CurrentSelection].CreateClonedPed(); + if (tab.listCol.Any(x => x.Type == "players")) + { + if (tab.PlayersColumn.Items[tab.PlayersColumn.CurrentSelection].ClonePed != null) + tab.PlayersColumn.Items[tab.PlayersColumn.CurrentSelection].CreateClonedPed(); + else + ClearPedInPauseMenu(); + } else ClearPedInPauseMenu(); } @@ -1845,27 +1850,28 @@ public override async void ProcessMouse() { int foc = tab.Focus; int curSel = 0; - if (tab._newStyle) + switch (tab.listCol[foc].Type) { - switch (tab.listCol[foc].Type) - { - case "settings": - curSel = tab.SettingsColumn.CurrentSelection; + case "settings": + curSel = tab.SettingsColumn.CurrentSelection; + if (tab._newStyle) tab.SettingsColumn.Items[tab.SettingsColumn.CurrentSelection].Selected = false; - break; - case "players": - curSel = tab.PlayersColumn.CurrentSelection; + break; + case "players": + curSel = tab.PlayersColumn.CurrentSelection; + if (tab._newStyle) tab.PlayersColumn.Items[tab.PlayersColumn.CurrentSelection].Selected = false; - break; - case "missions": - curSel = tab.MissionsColumn.CurrentSelection; + break; + case "missions": + curSel = tab.MissionsColumn.CurrentSelection; + if (tab._newStyle) tab.MissionsColumn.Items[tab.MissionsColumn.CurrentSelection].Selected = false; - break; - case "store": - curSel = tab.StoreColumn.CurrentSelection; + break; + case "store": + curSel = tab.StoreColumn.CurrentSelection; + if (tab._newStyle) tab.StoreColumn.Items[tab.StoreColumn.CurrentSelection].Selected = false; - break; - } + break; } tab.updateFocus(context, true); int index = tab.listCol[tab.Focus].Pagination.GetMenuIndexFromScaleformIndex(itemId);