Skip to content

Commit 80db6b7

Browse files
committed
Cloud Saves - Add root path to generated config.yaml
1 parent eae1a7e commit 80db6b7

3 files changed

Lines changed: 68 additions & 58 deletions

File tree

gamevault/Helper/Integrations/SaveGameHelper.cs

Lines changed: 49 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ internal async Task<string> RestoreBackup(int gameId, string installationDir)
6565

6666
try
6767
{
68-
68+
6969
string installationId = GetGameInstallationId(installationDir);
7070
string[] auth = WebHelper.GetCredentials();
71-
72-
string url = @$"{SettingsViewModel.Instance.ServerUrl}/api/savefiles/user/{LoginManager.Instance.GetCurrentUser()!.ID}/game/{gameId}";
71+
72+
string url = @$"{SettingsViewModel.Instance.ServerUrl}/api/savefiles/user/{LoginManager.Instance.GetCurrentUser()!.ID}/game/{gameId}";
7373
using (HttpResponseMessage response = await WebHelper.GetAsync(@$"{SettingsViewModel.Instance.ServerUrl}/api/savefiles/user/{LoginManager.Instance.GetCurrentUser()!.ID}/game/{gameId}", HttpCompletionOption.ResponseHeadersRead))
7474
{
7575
response.EnsureSuccessStatusCode();
@@ -215,57 +215,64 @@ internal async Task<string> BackupSaveGame(int gameId)
215215
public void PrepareConfigFile(string installationPath, string yamlPath)
216216
{
217217
string userFolder = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
218-
var redirects = new Dictionary<string, object>
218+
219+
// Base configuration with redirects (always included)
220+
var redirects = new List<Dictionary<string, object>>
221+
{
222+
new Dictionary<string, object>
219223
{
220-
{ "redirects", new List<Dictionary<string, object>>
221-
{
222-
new Dictionary<string, object>
223-
{
224-
{ "kind", "bidirectional" },
225-
{ "source", userFolder },
226-
{ "target", "G:\\gamevault\\currentuser" }
227-
},
228-
new Dictionary<string, object>
229-
{
230-
{ "kind", "bidirectional" },
231-
{ "source", installationPath },
232-
{ "target", "G:\\gamevault\\installation" }
233-
}
234-
}
224+
{ "kind", "bidirectional" },
225+
{ "source", userFolder },
226+
{ "target", "G:\\gamevault\\currentuser" }
227+
},
228+
new Dictionary<string, object>
229+
{
230+
{ "kind", "bidirectional" },
231+
{ "source", installationPath },
232+
{ "target", "G:\\gamevault\\installation" }
233+
}
234+
};
235+
236+
237+
238+
var roots = new List<Dictionary<string, object>>();
239+
foreach (DirectoryEntry rootPath in SettingsViewModel.Instance.RootDirectories)
240+
{
241+
roots.Add(new Dictionary<string, object>
242+
{
243+
{ "store", "other" },
244+
{ "path", Path.Combine(rootPath.Uri,"GameVault","Installations") }
245+
});
235246
}
236-
};
237247

238-
// Simulating SettingsViewModel.Instance.CustomCloudSaveManifests
239-
var customLudusaviManifests = SettingsViewModel.Instance.CustomCloudSaveManifests.Where(m => !string.IsNullOrWhiteSpace(m.Uri));
248+
// Start with base configuration (redirects and roots always included)
249+
var yamlData = new Dictionary<string, object>
250+
{
251+
{ "redirects", redirects },
252+
{ "roots", roots }
253+
};
240254

241-
Dictionary<string, object> yamlData;
255+
// Add manifest section if custom manifests exist (optional)
256+
var customLudusaviManifests = SettingsViewModel.Instance.CustomCloudSaveManifests.Where(m => !string.IsNullOrWhiteSpace(m.Uri));
242257

243-
if (customLudusaviManifests.Any()) // If manifests exist, merge with redirects
258+
if (customLudusaviManifests.Any())
244259
{
245260
var manifest = new Dictionary<string, object>
246-
{
247-
{ "enable", SettingsViewModel.Instance.UsePrimaryCloudSaveManifest },
248-
{ "secondary", new List<Dictionary<string, object>>() }
249-
};
261+
{
262+
{ "enable", SettingsViewModel.Instance.UsePrimaryCloudSaveManifest },
263+
{ "secondary", new List<Dictionary<string, object>>() }
264+
};
250265

251266
foreach (DirectoryEntry entry in customLudusaviManifests)
252267
{
253268
((List<Dictionary<string, object>>)manifest["secondary"]).Add(new Dictionary<string, object>
254-
{
255-
{ Uri.IsWellFormedUriString(entry.Uri, UriKind.Absolute) ? "url" : "path", entry.Uri },
256-
{ "enable", true }
257-
});
269+
{
270+
{ Uri.IsWellFormedUriString(entry.Uri, UriKind.Absolute) ? "url" : "path", entry.Uri },
271+
{ "enable", true }
272+
});
258273
}
259274

260-
yamlData = new Dictionary<string, object>
261-
{
262-
{ "manifest", manifest },
263-
{ "redirects", redirects["redirects"] } // Merge redirects
264-
};
265-
}
266-
else
267-
{
268-
yamlData = redirects; // Only redirects if no manifests
275+
yamlData.Add("manifest", manifest);
269276
}
270277

271278
var serializer = new SerializerBuilder()
@@ -275,6 +282,7 @@ public void PrepareConfigFile(string installationPath, string yamlPath)
275282
string result = serializer.Serialize(yamlData);
276283
File.WriteAllText(yamlPath, result);
277284
}
285+
278286
internal async Task<string> SearchForLudusaviGameTitle(string title)
279287
{
280288
return await Task.Run<string>(() =>
191 KB
Binary file not shown.

gamevault/Windows/LoginWindow.xaml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,25 @@
6262
<ControlTemplate TargetType="Button">
6363
<Grid Style="{StaticResource HoverEffect}">
6464
<StackPanel Background="Transparent">
65-
<Grid Height="100" Width="100">
66-
<uc:CacheImage UseUriSource="True" ImageCacheType="UserAvatar" Data="{Binding UserCacheAvatar}" CornerRadius="5"/>
67-
<Button x:Name="DeleteUserProfile" Style="{StaticResource ButtonWrapper}" Visibility="Hidden" Margin="0,0,0,3" Click="UserProfileContextMenu_Click">
68-
<Border Style="{StaticResource HoverEffect}" Background="Transparent" HorizontalAlignment="Right" VerticalAlignment="Bottom" CornerRadius="5">
69-
<Path Data="{StaticResource IconInstalledGamesSettings}" Fill="White" Margin="0,0,5,2"/>
70-
<Border.RenderTransform>
71-
<ScaleTransform/>
72-
</Border.RenderTransform>
73-
</Border>
74-
<Button.ContextMenu>
75-
<ContextMenu>
76-
<MenuItem Header="Edit User Profile" Click="EditUserProfile_Click"/>
77-
<MenuItem Header="Delete User Profile" Click="DeleteUserProfile_Click"/>
78-
</ContextMenu>
79-
</Button.ContextMenu>
80-
</Button>
81-
</Grid>
65+
<Border Background="{DynamicResource MahApps.Brushes.ThemeBackground}" CornerRadius="5">
66+
<Grid Height="100" Width="100">
67+
<uc:CacheImage UseUriSource="True" ImageCacheType="UserAvatar" Data="{Binding UserCacheAvatar}" CornerRadius="5"/>
68+
<Button x:Name="DeleteUserProfile" Style="{StaticResource ButtonWrapper}" Visibility="Hidden" Margin="0,0,0,3" Click="UserProfileContextMenu_Click">
69+
<Border Style="{StaticResource HoverEffect}" Background="Transparent" HorizontalAlignment="Right" VerticalAlignment="Bottom" CornerRadius="5">
70+
<Path Data="{StaticResource IconInstalledGamesSettings}" Fill="White" Margin="0,0,5,2"/>
71+
<Border.RenderTransform>
72+
<ScaleTransform/>
73+
</Border.RenderTransform>
74+
</Border>
75+
<Button.ContextMenu>
76+
<ContextMenu>
77+
<MenuItem Header="Edit User Profile" Click="EditUserProfile_Click"/>
78+
<MenuItem Header="Delete User Profile" Click="DeleteUserProfile_Click"/>
79+
</ContextMenu>
80+
</Button.ContextMenu>
81+
</Button>
82+
</Grid>
83+
</Border>
8284
<StackPanel x:Name="ProfileInfo" Visibility="Hidden">
8385
<TextBlock Text="{Binding Name}" FontSize="17" HorizontalAlignment="Center" TextAlignment="Center" Width="200" TextTrimming="CharacterEllipsis" FontWeight="Bold" Margin="-100,0,-100,0"/>
8486
<TextBlock Text="{Binding ServerUrl}" TextAlignment="Center" Width="200" TextTrimming="CharacterEllipsis" Margin="-100,0,-100,0" HorizontalAlignment="Center"/>

0 commit comments

Comments
 (0)