Changed how DLCs are referred as.

Optional DLC settings can now be shown (loading and saving is not implemented yet)
This commit is contained in:
Jeddunk 2021-04-28 13:33:04 +02:00
parent adc067d8a2
commit e17b0a18ca
5 changed files with 30 additions and 39 deletions

View File

@ -32,13 +32,13 @@ namespace GoldbergGUI.Core.Models
/// <summary> /// <summary>
/// List of DLC /// List of DLC
/// </summary> /// </summary>
public List<SteamApp> DlcList { get; set; } public List<DlcApp> DlcList { get; set; }
public List<Depot> Depots { get; set; } //public List<Depot> Depots { get; set; }
public List<Group> SubscribedGroups { get; set; } public List<Group> SubscribedGroups { get; set; }
public List<AppPath> AppPaths { get; set; } //public List<AppPath> AppPaths { get; set; }
public List<Achievement> Achievements { get; set; } public List<Achievement> Achievements { get; set; }
@ -65,20 +65,11 @@ namespace GoldbergGUI.Core.Models
public GoldbergGlobalConfiguration OverwrittenGlobalConfiguration { get; set; } public GoldbergGlobalConfiguration OverwrittenGlobalConfiguration { get; set; }
} }
public class Depot public class DlcApp : SteamApp
{ {
/// <summary> public int? DepotId { get; set; }
/// ID of Depot. public string DepotName { get; set; }
/// </summary> public string AppPath { get; set; }
public int DepotId { get; set; }
/// <summary>
/// Name of Depot.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Associated DLC App ID, can be null (e.g. if Depot is for base game).
/// </summary>
public int DlcAppId { get; set; }
} }
public class Group public class Group
@ -97,12 +88,6 @@ namespace GoldbergGUI.Core.Models
public int AppId { get; set; } public int AppId { get; set; }
} }
public class AppPath
{
public int AppId { get; set; }
public string Path { get; set; }
}
public class Achievement public class Achievement
{ {
/// <summary> /// <summary>

View File

@ -207,7 +207,7 @@ namespace GoldbergGUI.Core.Services
{ {
_log.Info("Reading configuration..."); _log.Info("Reading configuration...");
var appId = -1; var appId = -1;
var dlcList = new List<SteamApp>(); var dlcList = new List<DlcApp>();
var steamAppidTxt = Path.Combine(path, "steam_appid.txt"); var steamAppidTxt = Path.Combine(path, "steam_appid.txt");
if (File.Exists(steamAppidTxt)) if (File.Exists(steamAppidTxt))
{ {
@ -235,7 +235,7 @@ namespace GoldbergGUI.Core.Services
{ {
AppId = Convert.ToInt32(match.Groups["id"].Value), AppId = Convert.ToInt32(match.Groups["id"].Value),
Name = match.Groups["name"].Value Name = match.Groups["name"].Value
}); } as DlcApp);
} }
} }
else else

View File

@ -23,7 +23,7 @@ namespace GoldbergGUI.Core.Services
public Task<IEnumerable<SteamApp>> GetListOfAppsByName(string name); public Task<IEnumerable<SteamApp>> GetListOfAppsByName(string name);
public Task<SteamApp> GetAppByName(string name); public Task<SteamApp> GetAppByName(string name);
public Task<SteamApp> GetAppById(int appid); public Task<SteamApp> GetAppById(int appid);
public Task<List<SteamApp>> GetListOfDlc(SteamApp steamApp, bool useSteamDb); public Task<List<DlcApp>> GetListOfDlc(SteamApp steamApp, bool useSteamDb);
} }
class SteamCache class SteamCache
@ -168,9 +168,9 @@ namespace GoldbergGUI.Core.Services
return app; return app;
} }
public async Task<List<SteamApp>> GetListOfDlc(SteamApp steamApp, bool useSteamDb) public async Task<List<DlcApp>> GetListOfDlc(SteamApp steamApp, bool useSteamDb)
{ {
var dlcList = new List<SteamApp>(); var dlcList = new List<DlcApp>();
if (steamApp != null) if (steamApp != null)
{ {
_log.Info($"Get DLC for App {steamApp}"); _log.Info($"Get DLC for App {steamApp}");
@ -183,7 +183,7 @@ namespace GoldbergGUI.Core.Services
var result = await _db.Table<SteamApp>().Where(z => z.type == AppTypeDlc) var result = await _db.Table<SteamApp>().Where(z => z.type == AppTypeDlc)
.FirstOrDefaultAsync(y => y.AppId.Equals(x)).ConfigureAwait(true) .FirstOrDefaultAsync(y => y.AppId.Equals(x)).ConfigureAwait(true)
?? new SteamApp {AppId = x, Name = $"Unknown DLC {x}"}; ?? new SteamApp {AppId = x, Name = $"Unknown DLC {x}"};
dlcList.Add(result); dlcList.Add(result as DlcApp);
_log.Debug($"{result.AppId}={result.Name}"); _log.Debug($"{result.AppId}={result.Name}");
}); });
@ -233,11 +233,11 @@ namespace GoldbergGUI.Core.Services
var i = dlcList.FindIndex(x => x.AppId.Equals(dlcApp.AppId)); var i = dlcList.FindIndex(x => x.AppId.Equals(dlcApp.AppId));
if (i > -1) if (i > -1)
{ {
if (dlcList[i].Name.Contains("Unknown DLC")) dlcList[i] = dlcApp; if (dlcList[i].Name.Contains("Unknown DLC")) dlcList[i] = dlcApp as DlcApp;
} }
else else
{ {
dlcList.Add(dlcApp); dlcList.Add(dlcApp as DlcApp);
} }
} }

View File

@ -30,7 +30,7 @@ namespace GoldbergGUI.Core.ViewModels
private int _appId; private int _appId;
//private SteamApp _currentGame; //private SteamApp _currentGame;
private ObservableCollection<SteamApp> _dlcs; private ObservableCollection<DlcApp> _dlcs;
private string _accountName; private string _accountName;
private long _steamId; private long _steamId;
private bool _offline; private bool _offline;
@ -130,7 +130,7 @@ namespace GoldbergGUI.Core.ViewModels
} }
// ReSharper disable once InconsistentNaming // ReSharper disable once InconsistentNaming
public ObservableCollection<SteamApp> DLCs public ObservableCollection<DlcApp> DLCs
{ {
get => _dlcs; get => _dlcs;
set set
@ -382,7 +382,7 @@ namespace GoldbergGUI.Core.ViewModels
StatusText = "Trying to get list of DLCs..."; StatusText = "Trying to get list of DLCs...";
var listOfDlc = await _steam.GetListOfDlc(new SteamApp {AppId = AppId, Name = GameName}, true) var listOfDlc = await _steam.GetListOfDlc(new SteamApp {AppId = AppId, Name = GameName}, true)
.ConfigureAwait(false); .ConfigureAwait(false);
DLCs = new MvxObservableCollection<SteamApp>(listOfDlc); DLCs = new MvxObservableCollection<DlcApp>(listOfDlc);
MainWindowEnabled = true; MainWindowEnabled = true;
if (DLCs.Count > 0) if (DLCs.Count > 0)
{ {
@ -480,7 +480,7 @@ namespace GoldbergGUI.Core.ViewModels
var expression = new Regex(@"(?<id>.*) *= *(?<name>.*)"); var expression = new Regex(@"(?<id>.*) *= *(?<name>.*)");
var pastedDlc = (from line in result.Split(new[] {"\n", "\r\n"}, var pastedDlc = (from line in result.Split(new[] {"\n", "\r\n"},
StringSplitOptions.RemoveEmptyEntries) select expression.Match(line) into match StringSplitOptions.RemoveEmptyEntries) select expression.Match(line) into match
where match.Success select new SteamApp where match.Success select new DlcApp
{ {
AppId = Convert.ToInt32(match.Groups["id"].Value), AppId = Convert.ToInt32(match.Groups["id"].Value),
Name = match.Groups["name"].Value Name = match.Groups["name"].Value
@ -488,7 +488,7 @@ namespace GoldbergGUI.Core.ViewModels
if (pastedDlc.Count > 0) if (pastedDlc.Count > 0)
{ {
DLCs.Clear(); DLCs.Clear();
DLCs = new ObservableCollection<SteamApp>(pastedDlc); DLCs = new ObservableCollection<DlcApp>(pastedDlc);
//var empty = DLCs.Count == 1 ? "" : "s"; //var empty = DLCs.Count == 1 ? "" : "s";
//StatusText = $"Successfully got {DLCs.Count} DLC{empty} from clipboard! Ready."; //StatusText = $"Successfully got {DLCs.Count} DLC{empty} from clipboard! Ready.";
var statusTextCount = DLCs.Count == 1 ? "one DLC" : $"{DLCs.Count} DLCs"; var statusTextCount = DLCs.Count == 1 ? "one DLC" : $"{DLCs.Count} DLCs";
@ -524,7 +524,7 @@ namespace GoldbergGUI.Core.ViewModels
DllPath = "Path to game's steam_api(64).dll..."; DllPath = "Path to game's steam_api(64).dll...";
GameName = "Game name..."; GameName = "Game name...";
AppId = -1; AppId = -1;
DLCs = new ObservableCollection<SteamApp>(); DLCs = new ObservableCollection<DlcApp>();
AccountName = "Account name..."; AccountName = "Account name...";
SteamId = -1; SteamId = -1;
Offline = false; Offline = false;
@ -544,7 +544,7 @@ namespace GoldbergGUI.Core.ViewModels
private void SetFormFromConfig(GoldbergConfiguration config) private void SetFormFromConfig(GoldbergConfiguration config)
{ {
AppId = config.AppId; AppId = config.AppId;
DLCs = new ObservableCollection<SteamApp>(config.DlcList); DLCs = new ObservableCollection<DlcApp>(config.DlcList);
Offline = config.Offline; Offline = config.Offline;
DisableNetworking = config.DisableNetworking; DisableNetworking = config.DisableNetworking;
DisableOverlay = config.DisableOverlay; DisableOverlay = config.DisableOverlay;

View File

@ -7,6 +7,9 @@
xmlns:viewmodel="clr-namespace:GoldbergGUI.Core.ViewModels;assembly=GoldbergGUI.Core" xmlns:viewmodel="clr-namespace:GoldbergGUI.Core.ViewModels;assembly=GoldbergGUI.Core"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="500" d:DesignWidth="400" d:DataContext="{d:DesignInstance Type=viewmodel:MainViewModel }"> d:DesignHeight="500" d:DesignWidth="400" d:DataContext="{d:DesignInstance Type=viewmodel:MainViewModel }">
<views:MvxWpfView.Resources>
<BooleanToVisibilityConverter x:Key="B2V" />
</views:MvxWpfView.Resources>
<Grid Margin="0,0,0,0"> <Grid Margin="0,0,0,0">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
@ -53,10 +56,13 @@
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="App ID" Binding="{Binding AppId}" Width="80" /> <DataGridTextColumn Header="App ID" Binding="{Binding AppId}" Width="80" />
<DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="*" /> <DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="*" />
<DataGridTextColumn Header="Depot ID" Binding="{Binding DepotId}" Width="80" Visibility="{Binding Source={x:Reference showOptionalDlcSettings}, Path=IsChecked, Converter={StaticResource B2V}}"/>
<DataGridTextColumn Header="Depot Name" Binding="{Binding DepotName}" Width="*" Visibility="{Binding Source={x:Reference showOptionalDlcSettings}, Path=IsChecked, Converter={StaticResource B2V}}" />
<DataGridTextColumn Header="App Path" Binding="{Binding AppPath}" Width="*" Visibility="{Binding Source={x:Reference showOptionalDlcSettings}, Path=IsChecked, Converter={StaticResource B2V}}" />
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
<Button Content="Get _DLCs for AppID" Command="{Binding GetListOfDlcCommand}" Grid.Row="1" Width="120" HorizontalAlignment="Right" Margin="0,5,125,0" Height="20"/> <CheckBox Grid.Row="1" x:Name="showOptionalDlcSettings" Margin="0,5,0,0" Content="Show optional settings"/>
<Button Content="_Advanced Settings..." Grid.Row="1" Width="120" HorizontalAlignment="Right" Margin="0,5,0,0" Height="20" IsEnabled="False" ToolTip="Work in progress..."/> <Button Content="Get _DLCs for AppID" Command="{Binding GetListOfDlcCommand}" Grid.Row="1" Width="120" HorizontalAlignment="Right" Margin="0,5,0,0" Height="20"/>
</Grid> </Grid>
</GroupBox> </GroupBox>
</Grid> </Grid>