55using Intersect . Client . Interface . Shared ;
66using Intersect . Framework . Core ;
77using Intersect . Network ;
8- using Intersect . Utilities ;
98
109namespace Intersect . Client . Interface . Menu ;
1110
1211public partial class MainMenu : MutableInterface
1312{
1413 private readonly Canvas _menuCanvas ;
1514 private readonly MainMenuWindow _mainMenuWindow ;
16- private readonly LoginWindow _loginWindow ;
17- private readonly RegistrationWindow _registerWindow ;
18- private readonly ForgotPasswordWindow _forgotPasswordWindow ;
19- private readonly ResetPasswordWindow _resetPasswordWindow ;
20- private readonly CharacterCreationWindow _characterCreationWindow ;
21- private readonly CreditsWindow _creditsWindow ;
22-
23- public readonly SelectCharacterWindow SelectCharacterWindow ;
24-
25- //Character creation feild check
26- private bool mShouldOpenCharacterCreation ;
27- private bool mShouldOpenCharacterSelection ;
15+
16+ private bool _shouldOpenCharacterCreation ;
17+ private bool _shouldOpenCharacterSelection ;
2818 private bool _forceCharacterCreation ;
2919
3020 // Network status
3121 public static NetworkStatus ActiveNetworkStatus ;
22+
3223 public delegate void NetworkStatusHandler ( ) ;
33- public static NetworkStatusHandler ? NetworkStatusChanged ;
24+
25+ public static event NetworkStatusHandler ? NetworkStatusChanged ;
3426 internal static event EventHandler ? ReceivedConfiguration ;
3527
3628 public static long LastNetworkStatusChangeTime { get ; private set ; }
3729
38- private SettingsWindow ? _settingsWindow ;
39- private SettingsWindow SettingsWindow => _settingsWindow ??= new SettingsWindow ( _menuCanvas )
30+ private LoginWindow ? _loginWindow ;
31+
32+ private LoginWindow LoginWindow => _loginWindow ??= new LoginWindow ( _menuCanvas , this )
4033 {
4134 Alignment = [ Alignments . CenterH ] ,
4235 Y = 480 ,
4336 IsVisibleInTree = false ,
4437 } ;
4538
46- public MainMenu ( Canvas menuCanvas ) : base ( menuCanvas )
39+ private RegistrationWindow ? _registrationWindow ;
40+
41+ private RegistrationWindow RegistrationWindow => _registrationWindow ??= new RegistrationWindow ( _menuCanvas , this )
4742 {
48- _menuCanvas = menuCanvas ;
49- _mainMenuWindow = new MainMenuWindow ( _menuCanvas , this )
50- {
51- Alignment = [ Alignments . CenterH ] ,
52- Y = 480 ,
53- IsVisibleInTree = true ,
54- } ;
43+ Alignment = [ Alignments . CenterH ] ,
44+ Y = 480 ,
45+ IsVisibleInTree = false ,
46+ } ;
5547
56- var logo = new ImagePanel ( menuCanvas , "Logo" ) ;
57- logo . LoadJsonUi ( GameContentManager . UI . Menu , Graphics . Renderer ? . GetResolutionString ( ) ) ;
48+ private ForgotPasswordWindow ? _forgotPasswordWindow ;
5849
59- NetworkStatusChanged += HandleNetworkStatusChanged ;
50+ private ForgotPasswordWindow ForgotPasswordWindow => _forgotPasswordWindow ??= new ForgotPasswordWindow ( _menuCanvas , this )
51+ {
52+ // Alignment = [Alignments.CenterH],
53+ // Y = 480,
54+ // IsVisible = false,
55+ } ;
6056
61- _loginWindow = new LoginWindow ( _menuCanvas , this )
62- {
63- Alignment = [ Alignments . CenterH ] ,
64- Y = 480 ,
65- IsVisibleInTree = false ,
66- } ;
57+ private ResetPasswordWindow ? _resetPasswordWindow ;
6758
68- _registerWindow = new RegistrationWindow ( _menuCanvas , this )
69- {
70- Alignment = [ Alignments . CenterH ] ,
71- Y = 480 ,
72- IsVisibleInTree = false ,
73- } ;
59+ private ResetPasswordWindow ResetPasswordWindow => _resetPasswordWindow ?? = new ResetPasswordWindow ( _menuCanvas , this )
60+ {
61+ // Alignment = [Alignments.CenterH],
62+ // Y = 480,
63+ // IsVisible = false,
64+ } ;
7465
75- _creditsWindow = new CreditsWindow ( _menuCanvas , this )
76- {
77- Alignment = [ Alignments . CenterH ] ,
78- Y = 480 ,
79- IsVisibleInTree = false ,
80- } ;
66+ private CharacterCreationWindow ? _characterCreationWindow ;
8167
82- _forgotPasswordWindow = new ForgotPasswordWindow ( _menuCanvas , this )
83- {
84- // Alignment = [Alignments.CenterH],
85- // Y = 480,
86- // IsVisible = false,
87- } ;
68+ private CharacterCreationWindow CharacterCreationWindow => _characterCreationWindow ?? = new CharacterCreationWindow ( _menuCanvas , this , SelectCharacterWindow )
69+ {
70+ Alignment = [ Alignments . CenterH ] ,
71+ Y = 480 ,
72+ IsVisibleInTree = false ,
73+ } ;
8874
89- _resetPasswordWindow = new ResetPasswordWindow ( _menuCanvas , this )
90- {
91- // Alignment = [Alignments.CenterH],
92- // Y = 480,
93- // IsVisible = false,
94- } ;
75+ private CreditsWindow ? _creditsWindow ;
9576
96- SelectCharacterWindow = new SelectCharacterWindow ( _menuCanvas , this )
77+ private CreditsWindow CreditsWindow => _creditsWindow ??= new CreditsWindow ( _menuCanvas , this )
78+ {
79+ Alignment = [ Alignments . CenterH ] ,
80+ Y = 480 ,
81+ IsVisibleInTree = false ,
82+ } ;
83+
84+ private SelectCharacterWindow ? _selectCharacterWindow ;
85+
86+ public SelectCharacterWindow SelectCharacterWindow => _selectCharacterWindow ??=
87+ new SelectCharacterWindow ( _menuCanvas , this )
9788 {
9889 Alignment = [ Alignments . CenterH ] ,
9990 Y = 480 ,
10091 IsVisibleInTree = false ,
10192 } ;
10293
103- _characterCreationWindow = new CharacterCreationWindow ( _menuCanvas , this , SelectCharacterWindow )
94+ private SettingsWindow ? _settingsWindow ;
95+
96+ private SettingsWindow SettingsWindow => _settingsWindow ??= new SettingsWindow ( _menuCanvas )
97+ {
98+ Alignment = [ Alignments . CenterH ] ,
99+ Y = 480 ,
100+ IsVisibleInTree = false ,
101+ } ;
102+
103+ public MainMenu ( Canvas menuCanvas ) : base ( menuCanvas )
104+ {
105+ _menuCanvas = menuCanvas ;
106+ _mainMenuWindow = new MainMenuWindow ( _menuCanvas , this )
104107 {
105108 Alignment = [ Alignments . CenterH ] ,
106109 Y = 480 ,
107- IsVisibleInTree = false ,
110+ IsVisibleInTree = true ,
108111 } ;
112+
113+ var logo = new ImagePanel ( menuCanvas , "Logo" ) ;
114+ logo . LoadJsonUi ( GameContentManager . UI . Menu , Graphics . Renderer . GetResolutionString ( ) ) ;
115+
116+ NetworkStatusChanged += HandleNetworkStatusChanged ;
109117 }
110118
111119 ~ MainMenu ( )
@@ -127,29 +135,29 @@ public void Update(TimeSpan elapsed, TimeSpan total)
127135 _mainMenuWindow . Update ( ) ;
128136 }
129137
130- if ( mShouldOpenCharacterSelection )
138+ if ( _shouldOpenCharacterSelection )
131139 {
132140 CreateCharacterSelection ( ) ;
133141 }
134142
135- if ( mShouldOpenCharacterCreation )
143+ if ( _shouldOpenCharacterCreation )
136144 {
137145 CreateCharacterCreation ( ) ;
138146 }
139147
140- if ( ! _loginWindow . IsHidden )
148+ if ( ! LoginWindow . IsHidden )
141149 {
142- _loginWindow . Update ( ) ;
150+ LoginWindow . Update ( ) ;
143151 }
144152
145- if ( ! _characterCreationWindow . IsHidden )
153+ if ( ! CharacterCreationWindow . IsHidden )
146154 {
147- _characterCreationWindow . Update ( ) ;
155+ CharacterCreationWindow . Update ( ) ;
148156 }
149157
150- if ( ! _registerWindow . IsHidden )
158+ if ( ! RegistrationWindow . IsHidden )
151159 {
152- _registerWindow . Update ( ) ;
160+ RegistrationWindow . Update ( ) ;
153161 }
154162
155163 if ( ! SelectCharacterWindow . IsHidden )
@@ -164,91 +172,91 @@ public void Reset()
164172 {
165173 _settingsWindow = null ;
166174
167- _loginWindow . Hide ( ) ;
168- _registerWindow . Hide ( ) ;
169- _creditsWindow . Hide ( ) ;
170- _forgotPasswordWindow . Hide ( ) ;
171- _resetPasswordWindow . Hide ( ) ;
172- _characterCreationWindow . Hide ( ) ;
175+ LoginWindow . Hide ( ) ;
176+ RegistrationWindow . Hide ( ) ;
177+ CreditsWindow . Hide ( ) ;
178+ ForgotPasswordWindow . Hide ( ) ;
179+ ResetPasswordWindow . Hide ( ) ;
180+ CharacterCreationWindow . Hide ( ) ;
173181 SelectCharacterWindow . Hide ( ) ;
174182 _mainMenuWindow . Show ( ) ;
175183 _mainMenuWindow . Reset ( ) ;
176184 }
177185
178186 public void Show ( ) => _mainMenuWindow . Show ( ) ;
179187
180- public void Hide ( ) => _mainMenuWindow . Hide ( ) ;
188+ private void Hide ( ) => _mainMenuWindow . Hide ( ) ;
181189
182190 public void NotifyOpenCharacterSelection ( List < CharacterSelectionPreviewMetadata > characterSelectionPreviews )
183191 {
184- mShouldOpenCharacterSelection = true ;
192+ _shouldOpenCharacterSelection = true ;
185193 SelectCharacterWindow . CharacterSelectionPreviews = [ ..characterSelectionPreviews ] ;
186194 }
187195
188196 public void NotifyOpenForgotPassword ( )
189197 {
190198 Reset ( ) ;
191199 Hide ( ) ;
192- _forgotPasswordWindow . Show ( ) ;
200+ ForgotPasswordWindow . Show ( ) ;
193201 }
194202
195203 public void NotifyOpenLogin ( )
196204 {
197205 Reset ( ) ;
198206 Hide ( ) ;
199- _loginWindow . Show ( ) ;
207+ LoginWindow . Show ( ) ;
200208 }
201209
202210 public void OpenResetPassword ( string nameEmail )
203211 {
204212 Reset ( ) ;
205213 Hide ( ) ;
206- _resetPasswordWindow . Target = nameEmail ;
207- _resetPasswordWindow . Show ( ) ;
214+ ResetPasswordWindow . Target = nameEmail ;
215+ ResetPasswordWindow . Show ( ) ;
208216 }
209217
210- public void CreateCharacterSelection ( )
218+ private void CreateCharacterSelection ( )
211219 {
212220 Hide ( ) ;
213- _loginWindow . Hide ( ) ;
214- _registerWindow . Hide ( ) ;
221+ LoginWindow . Hide ( ) ;
222+ RegistrationWindow . Hide ( ) ;
215223 SettingsWindow . Hide ( ) ;
216- _characterCreationWindow . Hide ( ) ;
224+ CharacterCreationWindow . Hide ( ) ;
217225 SelectCharacterWindow . Show ( ) ;
218- mShouldOpenCharacterSelection = false ;
226+ _shouldOpenCharacterSelection = false ;
219227 }
220228
221229 public void NotifyOpenCharacterCreation ( bool force = false )
222230 {
223231 _forceCharacterCreation = force ;
224- mShouldOpenCharacterCreation = true ;
232+ _shouldOpenCharacterCreation = true ;
225233 }
226234
227- public void CreateCharacterCreation ( )
235+ private void CreateCharacterCreation ( )
228236 {
229237 Hide ( ) ;
230- _loginWindow . Hide ( ) ;
231- _registerWindow . Hide ( ) ;
238+ LoginWindow . Hide ( ) ;
239+ RegistrationWindow . Hide ( ) ;
232240 SettingsWindow . Hide ( ) ;
233241 SelectCharacterWindow . Hide ( ) ;
234- _characterCreationWindow . Show ( force : _forceCharacterCreation ) ;
235- mShouldOpenCharacterCreation = false ;
242+ CharacterCreationWindow . Show ( force : _forceCharacterCreation ) ;
243+ _shouldOpenCharacterCreation = false ;
236244 }
237245
238246 internal void SwitchToWindow < TMainMenuWindow > ( ) where TMainMenuWindow : IMainMenuWindow
239247 {
240248 _mainMenuWindow . Hide ( ) ;
241249 if ( typeof ( TMainMenuWindow ) == typeof ( LoginWindow ) )
242250 {
243- _loginWindow . Show ( ) ;
251+ LoginWindow . Show ( ) ;
244252 }
245253 else if ( typeof ( TMainMenuWindow ) == typeof ( RegistrationWindow ) )
246254 {
247- _registerWindow . Show ( ) ;
255+ RegistrationWindow . Show ( ) ;
248256 }
249257 else if ( typeof ( TMainMenuWindow ) == typeof ( CreditsWindow ) )
250258 {
251- _creditsWindow . Show ( ) ;
259+ CreditsWindow . Show ( ) ;
252260 }
253261 }
254262
0 commit comments