1
1
using System ;
2
+ using System . Collections ;
2
3
using System . Linq ;
3
4
using FMODUnity ;
4
5
using NitroxClient . MonoBehaviours . Gui . MainMenu . ServersList ;
@@ -15,6 +16,8 @@ public class MainMenuEnterPasswordPanel : MonoBehaviour, uGUI_INavigableIconGrid
15
16
{
16
17
public const string NAME = "MultiplayerEnterPassword" ;
17
18
19
+ public static MainMenuEnterPasswordPanel Instance { get ; private set ; }
20
+
18
21
private TMP_InputField passwordInput ;
19
22
private mGUI_Change_Legend_On_Select legendChange ;
20
23
@@ -27,6 +30,8 @@ public class MainMenuEnterPasswordPanel : MonoBehaviour, uGUI_INavigableIconGrid
27
30
28
31
public void Setup ( GameObject savedGamesRef )
29
32
{
33
+ Instance = this ;
34
+
30
35
GameObject multiplayerButtonRef = savedGamesRef . RequireGameObject ( "Scroll View/Viewport/SavedGameAreaContent/NewGame" ) ;
31
36
GameObject generalTextRef = multiplayerButtonRef . GetComponentInChildren < TextMeshProUGUI > ( ) . gameObject ;
32
37
GameObject inputFieldRef = GameObject . Find ( "/Menu canvas/Panel/MainMenu/RightSide/Home/EmailBox/InputField" ) ;
@@ -37,7 +42,7 @@ public void Setup(GameObject savedGamesRef)
37
42
passwordInput = passwordInputGameObject . GetComponent < TMP_InputField > ( ) ;
38
43
passwordInput . characterValidation = TMP_InputField . CharacterValidation . None ;
39
44
passwordInput . onSubmit = new TMP_InputField . SubmitEvent ( ) ;
40
- passwordInput . onSubmit . AddListener ( _ => { SelectItemInDirection ( 0 , 1 ) ; } ) ;
45
+ passwordInput . onSubmit . AddListener ( _ => OnConfirmButtonClicked ( ) ) ;
41
46
passwordInput . placeholder . GetComponent < TranslationLiveUpdate > ( ) . translationKey = Language . main . Get ( "Nitrox_JoinServerPlaceholder" ) ;
42
47
GameObject passwordInputDesc = Instantiate ( generalTextRef , passwordInputGameObject . transform , false ) ;
43
48
passwordInputDesc . transform . localPosition = new Vector3 ( - 200 , 0 , 0 ) ;
@@ -66,10 +71,24 @@ public void Setup(GameObject savedGamesRef)
66
71
legendChange . legendButtonConfiguration = confirmButtonButton . GetComponent < mGUI_Change_Legend_On_Select > ( ) . legendButtonConfiguration . Take ( 1 ) . ToArray ( ) ;
67
72
}
68
73
74
+ public void FocusPasswordField ( )
75
+ {
76
+ StartCoroutine ( Coroutine ( ) ) ;
77
+
78
+ IEnumerator Coroutine ( )
79
+ {
80
+ passwordInput . Select ( ) ;
81
+ EventSystem . current . SetSelectedGameObject ( passwordInput . gameObject ) ;
82
+ yield return null ;
83
+ passwordInput . MoveToEndOfLine ( false , true ) ;
84
+ }
85
+ }
86
+
69
87
private void OnConfirmButtonClicked ( )
70
88
{
71
89
lastEnteredPassword = passwordInput . text ;
72
90
MainMenuRightSide . main . OpenGroup ( MainMenuJoinServerPanel . NAME ) ;
91
+ MainMenuJoinServerPanel . Instance . FocusNameInputField ( ) ;
73
92
}
74
93
75
94
private static void OnCancelClick ( )
0 commit comments