Skip to content

Commit 691402d

Browse files
committed
Build temporary offline cache if not exists
1 parent 9d6ce99 commit 691402d

7 files changed

Lines changed: 65 additions & 32 deletions

File tree

CHANGELOG.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,25 @@
44
Recommended Gamevault Server Version: `v15.0.0`
55
###Changes
66

7-
- Removed the setup wizard and introduced a new login window
8-
- Added multi-profile support: if no user profile is configured, the demo user will be used by default.
9-
- Upgraded all connections to use the OAuth 2.0 authentication flow
10-
- Login and registration via configured identity providers are now supported
11-
- Added support for multiple root directories, including selection during download
7+
- Replaced setup wizard with a new login window
8+
- Introduced multi-profile support: if no user profile is configured, the demo user is used by default
9+
- Login window now dynamically adapts to the server configuration
10+
- Upgraded all connections to use OAuth 2.0 authentication flow
11+
- Added support for login and registration via configured identity providers (SSO)
12+
- Implemented pending activation state in the login process
13+
- Added options for logout from this device and logout from all devices
14+
- Introduced support for multiple root directories, including selection during download
1215
- Improved image cache performance
13-
- Added skeleton loading animations to the community tab to better indicate loading states
16+
- Added support for additional request headers
17+
- New game settings: default parameters for Un/Installer
18+
- Cloud Saves: root path is now included in the generated config.yaml
19+
- Offline cache now auto-renews when outdated
20+
- Added visual indicator on the install game card when an update is available
21+
- Implemented skeleton loading animations in the community tab to better indicate loading states
22+
- Added "Go to Game" button after installation is complete
23+
- Pressing F5 in the Library now also refreshes the list of installed games
24+
- Build temporary offline cache if not exists
25+
- Bug fix: extraction time remaining now displays correctly
1426

1527
## 1.16.1
1628
Recommended Gamevault Server Version: `v14.1.0`

gamevault/Helper/LoginManager.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public string GetServerLoginResponseMessage()
7272
public void SwitchToOfflineMode()
7373
{
7474
MainWindowViewModel.Instance.OnlineState = System.Windows.Visibility.Visible;
75-
m_User = null;
75+
m_User = null;
7676
}
7777
public UserProfile GetUserProfile()
7878
{
@@ -434,6 +434,11 @@ public void InitOnlineTimer()
434434
onlineTimer.Elapsed += CheckOnlineStatus;
435435
}
436436
onlineTimer.Start();
437+
if (!IsLoggedIn())
438+
{
439+
SwitchToOfflineMode();
440+
MainWindowViewModel.Instance.AppBarText = "No connection to the server. You are now in offline mode.";
441+
}
437442
}
438443
public void StopOnlineTimer()
439444
{
@@ -452,15 +457,18 @@ private async void CheckOnlineStatus(object sender, EventArgs e)
452457
if (!isLoggedInWithSSO)
453458
{
454459
string[] credencials = WebHelper.GetCredentials();
455-
await Login(GetUserProfile(), credencials[0], credencials[1]);
460+
if (await Login(GetUserProfile(), credencials[0], credencials[1]) != LoginState.Success)
461+
SwitchToOfflineMode();
456462
}
457463
else
458464
{
459-
//To Do: Login by Provider but make sure, the Auth window will not be opened twice
465+
if (await SSOLogin(GetUserProfile()) != LoginState.Success)
466+
SwitchToOfflineMode();
460467
}
461468
if (IsLoggedIn())
462469
{
463470
MainWindowViewModel.Instance.OnlineState = System.Windows.Visibility.Collapsed;
471+
MainWindowViewModel.Instance.AppBarText = "Connected to the server. You’re back online.";
464472
}
465473
}
466474
else

gamevault/UserControls/InstallUserControl.xaml.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,28 +86,18 @@ public async Task RestoreInstalledGames(bool fromCLI = false)
8686
{
8787
if (foundGames.Count > 0)
8888
{
89-
string gameIds = string.Empty;
90-
foreach (KeyValuePair<int, string> kv in foundGames)
91-
{
92-
if (gameIds == string.Empty)
93-
{
94-
gameIds += kv.Key;
95-
continue;
96-
}
97-
gameIds += "," + kv.Key;
98-
}
89+
string gameIds = string.Join(",", foundGames.Keys.Where(key => !string.IsNullOrEmpty(foundGames[key])));
9990
if (LoginManager.Instance.IsLoggedIn())
10091
{
10192
string gameList = await WebHelper.GetAsync(@$"{SettingsViewModel.Instance.ServerUrl}/api/games?filter.id=$in:{gameIds}");
10293
return JsonSerializer.Deserialize<PaginatedData<Game>>(gameList).Data;
10394
}
10495
else
10596
{
106-
string[] seperatedIds = gameIds.Split(',');
10797
List<Game> offlineCacheGames = new List<Game>();
108-
foreach (string id in seperatedIds)
98+
foreach (KeyValuePair<int, string> entry in foundGames)
10999
{
110-
string objectFromFile = Preferences.Get(id, LoginManager.Instance.GetUserProfile().OfflineCache);
100+
string objectFromFile = Preferences.Get(entry.Key.ToString(), LoginManager.Instance.GetUserProfile().OfflineCache);
111101
if (objectFromFile != string.Empty)
112102
{
113103
try
@@ -121,6 +111,11 @@ public async Task RestoreInstalledGames(bool fromCLI = false)
121111
}
122112
catch (FormatException exFormat) { }
123113
}
114+
else
115+
{
116+
string gameTitle = Path.GetFileName(entry.Value);
117+
offlineCacheGames.Add(new Game() { ID = entry.Key, Title = gameTitle.Substring(gameTitle.IndexOf(')') + 1) });
118+
}
124119
}
125120
return offlineCacheGames.ToArray();
126121
}

gamevault/UserControls/SettingsComponents/InstallLocationUserControl.xaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@
5858
</ScrollViewer>
5959
</StackPanel>
6060
<StackPanel VerticalAlignment="Bottom" Margin="0,0,0,10" Orientation="Horizontal" HorizontalAlignment="Center">
61-
<local:IconButton Text="Install" Height="25" Width="100" Click="Install_Click"/>
61+
<local:IconButton Text="Proceed" Height="25" Width="100" Click="Install_Click"/>
6262
<local:IconButton Text="Cancel" Kind="Skeleton" BorderThickness="1" Height="25" Width="100" Margin="10,0,0,0" Click="Close_Click"/>
6363
</StackPanel>
64-
6564
</Grid>
6665
</Border>
6766
</UserControl>

gamevault/ViewModels/SettingsViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ public string Version
449449
{
450450
get
451451
{
452-
return Assembly.GetExecutingAssembly().GetName().Version.ToString() + "EA";
452+
return Assembly.GetExecutingAssembly().GetName().Version.ToString() + "EA1";
453453
}
454454
}
455455
//DevMode

gamevault/Windows/LoginWindow.xaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,11 @@
377377
</TabItem>
378378
<TabItem>
379379
<Grid>
380-
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
381-
<TextBlock Text="Additional Request Headers" FontSize="20" FontWeight="Bold" HorizontalAlignment="Center"/>
382-
<ScrollViewer MaxHeight="100" VerticalScrollBarVisibility="Auto" Width="550" HorizontalAlignment="Center" Margin="50,10,0,0">
380+
<TextBlock Text="Client Settings" FontSize="20" FontWeight="Bold" HorizontalAlignment="Center" Margin="0,10,0,0"/>
381+
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,40,0,0">
382+
<TextBlock Text="Advanced" FontSize="16" FontWeight="Bold" HorizontalAlignment="Left"/>
383+
<TextBlock Text="Additional Request Headers" FontSize="15" HorizontalAlignment="Left" Margin="10,10,0,0"/>
384+
<ScrollViewer MaxHeight="250" VerticalScrollBarVisibility="Auto" Width="550" HorizontalAlignment="Left" Margin="10,10,0,0">
383385
<ItemsControl ItemsSource="{Binding AdditionalRequestHeaders}">
384386
<ItemsControl.ItemsPanel>
385387
<ItemsPanelTemplate>
@@ -410,7 +412,7 @@
410412
</ItemsControl.ItemTemplate>
411413
</ItemsControl>
412414
</ScrollViewer>
413-
<StackPanel Orientation="Horizontal" Margin="0,5,0,0" HorizontalAlignment="Center">
415+
<StackPanel Orientation="Horizontal" Margin="10,5,0,0" HorizontalAlignment="Left">
414416
<uc:IconButton Icon="{StaticResource IconAddTag}" Text="Add" FontSize="15" IconMargin="0,0,5,2" Width="100" Height="30" Margin="0,0,10,0" Click="AddAdditionalRequestHeader_Click"/>
415417
<uc:IconButton Icon="{StaticResource IconGameSettingsSave}" Text="Save" FontSize="15" IconMargin="0,0,5,2" Width="100" Height="30" Click="SaveAdditionalHeaders_Click"/>
416418
</StackPanel>

gamevault/Windows/LoginWindow.xaml.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ private async Task Login(UserProfile profile, bool firstTimeLogin = false, bool
263263
}
264264
if (state == LoginState.Success)
265265
{
266+
Preferences.Set(AppConfigKey.UserID, LoginManager.Instance.GetCurrentUser()?.ID, profile.UserConfigFile);
266267
await LoadMainWindow(profile);
267268
}
268269
else if (state == LoginState.NotActivated)
@@ -275,15 +276,31 @@ private async Task Login(UserProfile profile, bool firstTimeLogin = false, bool
275276
}
276277
else
277278
{
278-
ViewModel.LoginStepIndex = (int)LoginStep.ChooseProfile;
279-
ViewModel.AppBarText = LoginManager.Instance.GetServerLoginResponseMessage();
279+
if (firstTimeLogin)
280+
{
281+
ViewModel.LoginStepIndex = (int)LoginStep.ChooseProfile;
282+
ViewModel.AppBarText = LoginManager.Instance.GetServerLoginResponseMessage();
283+
}
284+
else
285+
{
286+
try
287+
{//Check if the user was ever connected and is properly set up
288+
string result = Preferences.Get(AppConfigKey.UserID, profile.UserConfigFile);
289+
if (string.IsNullOrWhiteSpace(result))
290+
{
291+
throw new Exception("User ID is not set");
292+
}
293+
await LoadMainWindow(profile);
294+
}
295+
catch { ViewModel.AppBarText = "Can not load user profile in offline mode"; ViewModel.LoginStepIndex = (int)LoginStep.ChooseProfile; }
296+
}
280297
}
281298
}
282299
private async Task LoadMainWindow(UserProfile profile)
283300
{
284301
LoginManager.Instance.SetUserProfile(profile);
285302
SettingsViewModel.Instance.Init();
286-
Preferences.Set(AppConfigKey.UserID, LoginManager.Instance.GetCurrentUser()!.ID, profile.UserConfigFile);
303+
287304
ViewModel.StatusText = "Optimizing Cache...";
288305
await CacheHelper.OptimizeCache();
289306
if (ViewModel.RememberMe)

0 commit comments

Comments
 (0)