Skip to content

Commit eec4140

Browse files
committed
Moved server outdated check to ogin window + added enter key to login and registration text boxes
1 parent fe1fabc commit eec4140

3 files changed

Lines changed: 87 additions & 50 deletions

File tree

gamevault/Windows/LoginWindow.xaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185
<TextBlock Text="Sign In" FontSize="30" HorizontalAlignment="Center"/>
186186
<TextBlock Text="Specify Your Server URL" TextDecorations="Underline" Margin="0,15,0,5"/>
187187
<StackPanel Orientation="Horizontal" Margin="0,0,0,0">
188-
<TextBox Text="{Binding LoginUser.ServerUrl}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2" Width="400" TextChanged="ServerUrlInput_TextChanged"/>
188+
<TextBox Text="{Binding LoginUser.ServerUrl}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2" Width="400" TextChanged="ServerUrlInput_TextChanged" KeyDown="UserLoginTextBox_KeyDown"/>
189189
<Path Data="{StaticResource IconCheck}" Fill="Green" Margin="2,1,-25,0">
190190
<Path.Style>
191191
<Style TargetType="Path">
@@ -211,10 +211,10 @@
211211
</Style>
212212
</StackPanel.Style>
213213
<TextBlock Text="Username or Email" TextDecorations="Underline" Margin="0,15,0,5"/>
214-
<TextBox Text="{Binding LoginUser.Username}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2"/>
214+
<TextBox Text="{Binding LoginUser.Username}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2" KeyDown="UserLoginTextBox_KeyDown"/>
215215

216216
<TextBlock Text="Password" TextDecorations="Underline" Margin="0,15,0,5"/>
217-
<TextBox helper:PasswordBoxAttachedProperties.IsPassword="True" helper:PasswordBoxAttachedProperties.ActualPassword="{Binding LoginUser.Password}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2"/>
217+
<TextBox helper:PasswordBoxAttachedProperties.IsPassword="True" helper:PasswordBoxAttachedProperties.ActualPassword="{Binding LoginUser.Password}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2" KeyDown="UserLoginTextBox_KeyDown"/>
218218
</StackPanel>
219219
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,15,0,0">
220220
<Rectangle Fill="{DynamicResource MahApps.Brushes.ThemeForeground}" Width="70" Height="2"/>
@@ -244,7 +244,7 @@
244244
<TextBlock Text="Sign Up" FontSize="30" HorizontalAlignment="Center"/>
245245
<TextBlock Text="Specify Your Server URL" TextDecorations="Underline" Margin="0,15,0,5"/>
246246
<StackPanel Orientation="Horizontal">
247-
<TextBox Text="{Binding SignupUser.ServerUrl}" mah:ControlsHelper.CornerRadius="5" Width="400" BorderThickness="2" TextChanged="ServerUrlInput_TextChanged"/>
247+
<TextBox Text="{Binding SignupUser.ServerUrl}" mah:ControlsHelper.CornerRadius="5" Width="400" BorderThickness="2" TextChanged="ServerUrlInput_TextChanged" KeyDown="UserRegistrationTextBox_KeyDown"/>
248248
<Path Data="{StaticResource IconCheck}" Fill="Green" Margin="2,1,-25,0">
249249
<Path.Style>
250250
<Style TargetType="Path">
@@ -277,21 +277,21 @@
277277
</Grid.ColumnDefinitions>
278278
<StackPanel Width="195" Grid.Column="0">
279279
<TextBlock Text="Username" TextDecorations="Underline" Margin="0,15,0,5"/>
280-
<TextBox Text="{Binding SignupUser.Username}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2"/>
280+
<TextBox Text="{Binding SignupUser.Username}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2" KeyDown="UserRegistrationTextBox_KeyDown"/>
281281
</StackPanel>
282282
<StackPanel Width="195" Grid.Column="2">
283283
<StackPanel Orientation="Horizontal" Margin="0,15,0,5">
284284
<TextBlock Text="Birth Date" TextDecorations="Underline"/>
285285
<TextBlock Text="(Mandatory)" Visibility="{Binding SignUpServerInfo.IsBirthDateMandatory,Converter={StaticResource boolToVisConv}}" VerticalAlignment="Center" Margin="5,0,0,0"/>
286286
</StackPanel>
287-
<DatePicker SelectedDate="{Binding SignupUser.BirthDate}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2"/>
287+
<DatePicker SelectedDate="{Binding SignupUser.BirthDate}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2" KeyDown="UserRegistrationTextBox_KeyDown"/>
288288
</StackPanel>
289289
</Grid>
290290
<StackPanel Orientation="Horizontal" Margin="0,15,0,5">
291291
<TextBlock Text="E-Mail" TextDecorations="Underline"/>
292292
<TextBlock Text="(Mandatory)" Visibility="{Binding SignUpServerInfo.IsEMailMandatory,Converter={StaticResource boolToVisConv}}" VerticalAlignment="Center" Margin="5,0,0,0"/>
293293
</StackPanel>
294-
<TextBox Text="{Binding SignupUser.EMail}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2"/>
294+
<TextBox Text="{Binding SignupUser.EMail}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2" KeyDown="UserRegistrationTextBox_KeyDown"/>
295295
<Grid>
296296
<Grid.ColumnDefinitions>
297297
<ColumnDefinition Width="Auto"/>
@@ -303,14 +303,14 @@
303303
<TextBlock Text="First Name" TextDecorations="Underline"/>
304304
<TextBlock Text="(Mandatory)" Visibility="{Binding SignUpServerInfo.IsFirstNameMandatory,Converter={StaticResource boolToVisConv}}" VerticalAlignment="Center" Margin="5,0,0,0"/>
305305
</StackPanel>
306-
<TextBox Text="{Binding SignupUser.FirstName}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2"/>
306+
<TextBox Text="{Binding SignupUser.FirstName}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2" KeyDown="UserRegistrationTextBox_KeyDown"/>
307307
</StackPanel>
308308
<StackPanel Width="195" Grid.Column="2">
309309
<StackPanel Orientation="Horizontal" Margin="0,15,0,5">
310310
<TextBlock Text="Last Name" TextDecorations="Underline"/>
311311
<TextBlock Text="(Mandatory)" Visibility="{Binding SignUpServerInfo.IsLastNameMandatory,Converter={StaticResource boolToVisConv}}" VerticalAlignment="Center" Margin="5,0,0,0"/>
312312
</StackPanel>
313-
<TextBox Text="{Binding SignupUser.LastName}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2"/>
313+
<TextBox Text="{Binding SignupUser.LastName}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2" KeyDown="UserRegistrationTextBox_KeyDown"/>
314314
</StackPanel>
315315
</Grid>
316316
<Grid>
@@ -321,11 +321,11 @@
321321
</Grid.ColumnDefinitions>
322322
<StackPanel Width="195" Grid.Column="0">
323323
<TextBlock Text="Password" TextDecorations="Underline" Margin="0,15,0,5"/>
324-
<TextBox helper:PasswordBoxAttachedProperties.IsPassword="True" helper:PasswordBoxAttachedProperties.ActualPassword="{Binding SignupUser.Password}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2"/>
324+
<TextBox helper:PasswordBoxAttachedProperties.IsPassword="True" helper:PasswordBoxAttachedProperties.ActualPassword="{Binding SignupUser.Password}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2" KeyDown="UserRegistrationTextBox_KeyDown"/>
325325
</StackPanel>
326326
<StackPanel Width="195" Grid.Column="2">
327327
<TextBlock Text="Repeat Password" TextDecorations="Underline" Margin="0,15,0,5"/>
328-
<TextBox helper:PasswordBoxAttachedProperties.IsPassword="True" helper:PasswordBoxAttachedProperties.ActualPassword="{Binding SignupUser.RepeatPassword}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2"/>
328+
<TextBox helper:PasswordBoxAttachedProperties.IsPassword="True" helper:PasswordBoxAttachedProperties.ActualPassword="{Binding SignupUser.RepeatPassword}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2" KeyDown="UserRegistrationTextBox_KeyDown"/>
329329
</StackPanel>
330330
</Grid>
331331
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,15,0,0">

gamevault/Windows/LoginWindow.xaml.cs

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ private UserProfile SetupUserProfile(LoginUser user)
171171
return profile;
172172
}
173173
private async void SaveAndLogin_Click(object sender, RoutedEventArgs e)
174+
{
175+
await SaveAndLogin();
176+
}
177+
private async Task SaveAndLogin()
174178
{
175179
try
176180
{
@@ -225,13 +229,20 @@ private void ValidateSignInData(LoginUser loginUser, bool isLogin)
225229
}
226230
}
227231

228-
private async Task Login(UserProfile profile, bool firstTimeLogin = false, bool activationCall = false)
232+
private async Task Login(UserProfile profile, bool firstTimeLogin = false, bool calledByActivationLoop = false)
229233
{
230-
if (!activationCall)
234+
if (!calledByActivationLoop)
231235
{
232236
ViewModel.StatusText = "Logging in...";
233237
ViewModel.LoginStepIndex = (int)LoginStep.LoadingAction;
238+
239+
if (await CheckIfServerIsOutdated(profile.ServerUrl))
240+
{
241+
ViewModel.LoginStepIndex = (int)LoginStep.ChooseProfile;
242+
return;
243+
}
234244
}
245+
235246
bool isLoggedInWithSSO = Preferences.Get(AppConfigKey.IsLoggedInWithSSO, profile.UserConfigFile) == "1";
236247
LoginState state = LoginState.Success;
237248
if (!isLoggedInWithSSO)
@@ -321,6 +332,10 @@ private async Task LoadMainWindow(UserProfile profile)
321332
this.Close();
322333
}
323334
private async void SaveAndSignUp_Click(object sender, RoutedEventArgs e)
335+
{
336+
await SaveAndSignUp();
337+
}
338+
private async Task SaveAndSignUp()
324339
{
325340
try
326341
{
@@ -548,6 +563,49 @@ public async Task CheckForUpdates(Window root)
548563
catch { }
549564
}
550565

566+
private async Task<bool> CheckIfServerIsOutdated(string serverUrl)
567+
{
568+
//User Notification for major client/server update
569+
bool isServerOutdated = false;
570+
try
571+
{
572+
string serverResonse = await WebHelper.BaseGetAsync(@$"{serverUrl}/api/status");
573+
string currentServerVersion = System.Text.Json.JsonSerializer.Deserialize<ServerInfo>(serverResonse).Version;
574+
if (currentServerVersion == null || currentServerVersion == "")
575+
{
576+
isServerOutdated = true;
577+
}
578+
isServerOutdated = new Version(currentServerVersion) < new Version("15.0.0");
579+
}
580+
catch { }
581+
if (isServerOutdated)
582+
{
583+
try
584+
{
585+
MessageDialogResult result = await ((MetroWindow)App.Current.MainWindow).ShowMessageAsync("CLIENT-SERVER-INCOMPABILITY DETECTED",
586+
$"Your GameVault Client is not compatible with the GameVault Server you are using (<15.0.0). This server is too old for your client.\r\n\r\nYou have the following options:\r\n",
587+
MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings()
588+
{
589+
AffirmativeButtonText = "Get older client version from GitHub",
590+
NegativeButtonText = "Update the server",
591+
AnimateHide = false,
592+
DialogMessageFontSize = 20,
593+
DialogTitleFontSize = 25
594+
});
595+
if (result == MessageDialogResult.Affirmative)
596+
{
597+
Process.Start(new ProcessStartInfo("https://github.com/Phalcode/gamevault-app/releases") { UseShellExecute = true });
598+
}
599+
else
600+
{
601+
Process.Start(new ProcessStartInfo("https://github.com/Phalcode/gamevault-backend/releases/tag/12.2.0") { UseShellExecute = true });
602+
}
603+
}
604+
catch { }
605+
}
606+
return isServerOutdated;
607+
}
608+
551609
private void MetroWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
552610
{
553611
if (!App.HideToSystemTray)
@@ -584,5 +642,20 @@ private void LoginWindowSettings_Click(object sender, RoutedEventArgs e)
584642
{
585643
ViewModel.LoginStepIndex = (int)LoginStep.Settings;
586644
}
645+
646+
private async void UserLoginTextBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
647+
{
648+
if (e.Key == System.Windows.Input.Key.Enter)
649+
{
650+
await SaveAndLogin();
651+
}
652+
}
653+
private async void UserRegistrationTextBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
654+
{
655+
if (e.Key == System.Windows.Input.Key.Enter)
656+
{
657+
await SaveAndSignUp();
658+
}
659+
}
587660
}
588661
}

gamevault/Windows/MainWindow.xaml.cs

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -111,44 +111,8 @@ private async void MetroWindow_Loaded(object sender, System.Windows.RoutedEventA
111111

112112
uiNewsBadge.Badge = await CheckForNews() ? "!" : "";
113113
InitNewsTimer();
114-
115-
if (await IsServerTooOutdated())
116-
{
117-
try
118-
{
119-
MessageDialogResult result = await ((MetroWindow)App.Current.MainWindow).ShowMessageAsync("CLIENT-SERVER-INCOMPABILITY DETECTED",
120-
$"Your GameVault Client is not compatible with the GameVault Server you are using (<15.0.0). This server is too old for your client.\r\n\r\nYou have the following options:\r\n",
121-
MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings() { AffirmativeButtonText = "Install the older version of the client from GitHub", NegativeButtonText = "Update the server", AnimateHide = false, DialogMessageFontSize = 25, DialogTitleFontSize = 30 });
122-
if (result == MessageDialogResult.Affirmative)
123-
{
124-
Process.Start(new ProcessStartInfo("https://github.com/Phalcode/gamevault-app/releases") { UseShellExecute = true });
125-
}
126-
else
127-
{
128-
Process.Start(new ProcessStartInfo("https://github.com/Phalcode/gamevault-backend/releases/tag/12.2.0") { UseShellExecute = true });
129-
}
130-
}
131-
catch { }
132-
}
133-
}
134-
//User Notification for major client/server update
135-
private async Task<bool> IsServerTooOutdated()
136-
{
137-
try
138-
{
139-
string serverResonse = await WebHelper.BaseGetAsync(@$"{SettingsViewModel.Instance.ServerUrl}/api/status");
140-
string currentServerVersion = System.Text.Json.JsonSerializer.Deserialize<ServerInfo>(serverResonse).Version;
141-
if (currentServerVersion == null || currentServerVersion == "")
142-
{
143-
return true;
144-
}
145-
return new Version(currentServerVersion) < new Version("15.0.0");
146-
}
147-
catch { }
148-
return false;
114+
149115
}
150-
//######
151-
152116
private void MetroWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
153117
{
154118
if (App.HideToSystemTray)

0 commit comments

Comments
 (0)