Skip to content

Commit 855dccf

Browse files
committed
Update v1.1.1
1 parent 0dec703 commit 855dccf

File tree

9 files changed

+172
-105
lines changed

9 files changed

+172
-105
lines changed

MGSVST_Core/MGSVST_Core.csproj

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
7-
</PropertyGroup>
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<AssemblyVersion>1.1.1.0</AssemblyVersion>
8+
<FileVersion>$(AssemblyVersion)</FileVersion>
9+
<Version>$(AssemblyVersion)</Version>
10+
<Authors>Mi5hmasH</Authors>
11+
</PropertyGroup>
812

9-
</Project>
13+
</Project>

MGSVST_Core/Models/MGSVSaveData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ private bool DecryptLite(uint key)
277277
{
278278
var bytes = Data;
279279
uint batchUInt32 = 0;
280-
for (int i = 0; i < 20; i += 4)
280+
for (var i = 0; i < 20; i += 4)
281281
{
282282
// take 4 bytes
283283
var batch = bytes.Skip(i).Take(4).ToArray();
Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using System;
2+
using System.IO;
3+
using System.Reflection;
24

35
namespace MGSV_SaveTranslator.Helpers;
46

@@ -7,24 +9,85 @@ namespace MGSV_SaveTranslator.Helpers;
79
/// </summary>
810
public static class AppInfo
911
{
12+
public static string RootPath => AppDomain.CurrentDomain.BaseDirectory;
13+
1014
#region APP INFO
1115

12-
public static string Name => "MGSV - SaveData Translator";
16+
public static string Title => "MGSV - SaveData Translator";
1317

14-
public static string RootPath => AppDomain.CurrentDomain.BaseDirectory;
18+
public static string Version => GetAssemblyVersion();
1519

16-
#endregion
20+
public static string Author => GetCompany();
1721

22+
public static string ProductTitle => GetProductTitle();
23+
24+
public static string Description => GetDescription();
25+
26+
public static string Copyright => GetCopyright();
27+
28+
#endregion
1829

1930
#region OTHER INFO
2031

21-
public static string BackupFolder => "backup";
32+
public static string BackupFolder => "_BACKUP";
33+
public static string BackupPath => Path.Combine(RootPath, BackupFolder);
2234

23-
public static string UnpackedFilesFolder => "unpacked";
35+
public static string UnpackedFilesFolder => "_UNPACKED";
36+
public static string UnpackedFilesPath => Path.Combine(RootPath, UnpackedFilesFolder);
2437

25-
public static string PackedFilesFolder => "packed";
38+
public static string PackedFilesFolder => "_PACKED";
39+
public static string PackedFilesPath => Path.Combine(RootPath, PackedFilesFolder);
2640

2741
public static string ProfilesFolder => "profiles";
42+
public static string ProfilesPath => Path.Combine(RootPath, ProfilesFolder);
43+
44+
#endregion
45+
46+
#region METHODS
47+
48+
/// <summary>
49+
/// Gets the attribute value of the assembly.
50+
/// </summary>
51+
/// <typeparam name="TAttr"></typeparam>
52+
/// <param name="resolveFunc"></param>
53+
/// <param name="defaultResult"></param>
54+
/// <returns></returns>
55+
private static string GetAttributeValue<TAttr>(Func<TAttr, string> resolveFunc, string defaultResult = "") where TAttr : Attribute
56+
{
57+
// Source: https://www.codeproject.com/Tips/353819/Get-all-Assembly-Information
58+
var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(TAttr), false);
59+
return attributes.Length > 0 ? resolveFunc((TAttr)attributes[0]) : defaultResult;
60+
}
61+
62+
/// <summary>
63+
/// Gets the application version.
64+
/// </summary>
65+
/// <returns></returns>
66+
private static string GetAssemblyVersion() => Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "1.0.0.0";
67+
68+
/// <summary>
69+
/// Gets the product title.
70+
/// </summary>
71+
/// <returns></returns>
72+
private static string GetProductTitle() => GetAttributeValue<AssemblyTitleAttribute>(a => a.Title, Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName));
73+
74+
/// <summary>
75+
/// Gets the description about the application.
76+
/// </summary>
77+
/// <returns></returns>
78+
private static string GetDescription() => GetAttributeValue<AssemblyDescriptionAttribute>(a => a.Description);
79+
80+
/// <summary>
81+
/// Gets the copyright information for the product.
82+
/// </summary>
83+
/// <returns></returns>
84+
private static string GetCopyright() => GetAttributeValue<AssemblyCopyrightAttribute>(a => a.Copyright);
2885

86+
/// <summary>
87+
/// Gets the company information for the product.
88+
/// </summary>
89+
/// <returns></returns>
90+
private static string GetCompany() => GetAttributeValue<AssemblyCompanyAttribute>(a => a.Company);
91+
2992
#endregion
3093
}
Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,50 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<OutputType>WinExe</OutputType>
5-
<TargetFramework>net7.0-windows</TargetFramework>
6-
<Nullable>enable</Nullable>
7-
<LangVersion>10.0</LangVersion>
8-
<UseWPF>true</UseWPF>
9-
<ApplicationManifest>app.manifest</ApplicationManifest>
10-
<ApplicationIcon>applicationIcon.ico</ApplicationIcon>
11-
<StartupObject>MGSV_SaveTranslator.App</StartupObject>
12-
<Authors>Mi5hmasH</Authors>
13-
<Title>MGSV_SaveTranslator</Title>
14-
<Version>1.1.0</Version>
15-
</PropertyGroup>
16-
17-
<ItemGroup>
18-
<Content Include="applicationIcon.ico" />
19-
</ItemGroup>
20-
21-
<ItemGroup>
22-
<PackageReference Include="WPF-UI" Version="2.0.3" />
23-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
24-
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
25-
</ItemGroup>
26-
27-
<ItemGroup>
28-
<None Remove="Assets\applicationIcon-1024.png" />
29-
<None Remove="Assets\applicationIcon-256.png" />
30-
<None Remove="Assets\staticLogo.png" />
31-
</ItemGroup>
32-
33-
<ItemGroup>
34-
<ProjectReference Include="..\MGSVST_Core\MGSVST_Core.csproj" />
35-
</ItemGroup>
36-
37-
<ItemGroup>
38-
<Resource Include="Assets\applicationIcon-1024.png" />
39-
<Resource Include="Assets\applicationIcon-256.png" />
40-
<Resource Include="Assets\staticLogo.png" />
41-
</ItemGroup>
42-
43-
<ItemGroup>
44-
<Page Update="Views\Pages\TranslatorPage.xaml">
45-
<SubType>Designer</SubType>
46-
</Page>
47-
</ItemGroup>
48-
49-
</Project>
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net7.0-windows</TargetFramework>
6+
<Nullable>enable</Nullable>
7+
<UseWPF>true</UseWPF>
8+
<ApplicationManifest>app.manifest</ApplicationManifest>
9+
<ApplicationIcon>applicationIcon.ico</ApplicationIcon>
10+
<StartupObject>MGSV_SaveTranslator.App</StartupObject>
11+
<Authors>Mi5hmasH</Authors>
12+
<Title>$(AssemblyName)</Title>
13+
<AssemblyVersion>1.1.1.0</AssemblyVersion>
14+
<FileVersion>$(AssemblyVersion)</FileVersion>
15+
<Version>$(AssemblyVersion)</Version>
16+
</PropertyGroup>
17+
18+
<ItemGroup>
19+
<Content Include="applicationIcon.ico" />
20+
</ItemGroup>
21+
22+
<ItemGroup>
23+
<PackageReference Include="WPF-UI" Version="2.1.0" />
24+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
25+
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
26+
</ItemGroup>
27+
28+
<ItemGroup>
29+
<None Remove="Assets\applicationIcon-1024.png" />
30+
<None Remove="Assets\applicationIcon-256.png" />
31+
<None Remove="Assets\staticLogo.png" />
32+
</ItemGroup>
33+
34+
<ItemGroup>
35+
<ProjectReference Include="..\MGSVST_Core\MGSVST_Core.csproj" />
36+
</ItemGroup>
37+
38+
<ItemGroup>
39+
<Resource Include="Assets\applicationIcon-1024.png" />
40+
<Resource Include="Assets\applicationIcon-256.png" />
41+
<Resource Include="Assets\staticLogo.png" />
42+
</ItemGroup>
43+
44+
<ItemGroup>
45+
<Page Update="Views\Pages\TranslatorPage.xaml">
46+
<SubType>Designer</SubType>
47+
</Page>
48+
</ItemGroup>
49+
50+
</Project>

MGSV_SaveTranslator/ViewModels/AboutViewModel.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using CommunityToolkit.Mvvm.ComponentModel;
2+
using MGSV_SaveTranslator.Helpers;
23
using Wpf.Ui.Common.Interfaces;
34

45
namespace MGSV_SaveTranslator.ViewModels;
@@ -10,6 +11,9 @@ public partial class AboutViewModel : ObservableObject, INavigationAware
1011
[ObservableProperty]
1112
private string _appVersion = string.Empty;
1213

14+
[ObservableProperty]
15+
private string _appAuthor = string.Empty;
16+
1317
public void OnNavigatedTo()
1418
{
1519
if (!_isInitialized)
@@ -22,13 +26,8 @@ public void OnNavigatedFrom()
2226

2327
private void InitializeViewModel()
2428
{
25-
AppVersion = $"{GetAssemblyVersion()}";
29+
AppVersion = AppInfo.Version;
30+
AppAuthor = AppInfo.Author;
2631
_isInitialized = true;
2732
}
28-
29-
/// <summary>
30-
/// Gets application version.
31-
/// </summary>
32-
/// <returns></returns>
33-
private static string GetAssemblyVersion() => System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? string.Empty;
3433
}

MGSV_SaveTranslator/ViewModels/MainWindowViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ public partial class MainWindowViewModel : ObservableObject
2424
[ObservableProperty]
2525
private ObservableCollection<MenuItem> _trayMenuItems = new();
2626

27-
public MainWindowViewModel(INavigationService navigationService)
27+
public MainWindowViewModel()
2828
{
2929
if (!_isInitialized) InitializeViewModel();
3030
}
3131

3232
private void InitializeViewModel()
3333
{
34-
ApplicationTitle = AppInfo.Name;
34+
ApplicationTitle = AppInfo.Title;
3535

3636
NavigationItems = new ObservableCollection<INavigationControl>
3737
{

MGSV_SaveTranslator/ViewModels/ResearchViewModel.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ public partial class ResearchViewModel : ObservableObject, INavigationAware
4040

4141
// Dependencies
4242
[ObservableProperty] private ProgressService _progressService;
43-
private MGSVProfilesService _mgsvProfilesService;
43+
private readonly MGSVProfilesService _mgsvProfilesService;
4444

4545
/// <summary>
4646
/// Constructor with dependency injection
4747
/// </summary>
4848
/// <param name="mgsvProfilesService"></param>
4949
/// <param name="progressService"></param>
50-
public ResearchViewModel(MGSVProfilesService mgsvProfilesService, ProgressService progressService, MainWindowViewModel mainWindowViewModel)
50+
public ResearchViewModel(MGSVProfilesService mgsvProfilesService, ProgressService progressService)
5151
{
5252
_mgsvProfilesService = mgsvProfilesService;
5353
_progressService = progressService;
@@ -79,11 +79,11 @@ private void GuessKeyUsingFileType()
7979
InfoBarFeederConsume(_mgsvProfilesService.Reporter);
8080

8181
MGSVSaveData mgsvst = new();
82-
mgsvst.Load(_saveFilePath);
83-
var ft = _profileName;
82+
mgsvst.Load(SaveFilePath);
83+
var ft = ProfileName;
8484
try
8585
{
86-
ft = _profileName.Split("] ")[1];
86+
ft = ProfileName.Split("] ")[1];
8787
}
8888
catch
8989
{
@@ -105,11 +105,11 @@ private async Task BruteforceKeyAsync()
105105

106106
_cts = new CancellationTokenSource();
107107
MGSVSaveData mgsvst = new();
108-
mgsvst.Load(_saveFilePath);
108+
mgsvst.Load(SaveFilePath);
109109

110110
try
111111
{
112-
// progress bar update hack
112+
// progress bar update hack (DO NOT AWAIT OR IT WILL BREAK!)
113113
Task.Run(async () => {
114114
while (!_cts.Token.IsCancellationRequested)
115115
{
@@ -166,8 +166,8 @@ private void RepopulateCollections()
166166
{
167167
var rProfileName = ProfileName;
168168
var profileNames = _mgsvProfilesService.GameProfilesJson.Profiles.Select(x => x.Name);
169-
_profileNames.Clear();
170-
foreach (var item in profileNames) _profileNames.Add(item);
169+
ProfileNames.Clear();
170+
foreach (var item in profileNames) ProfileNames.Add(item);
171171
SelectedProfileName = ProfileNames.IndexOf(rProfileName);
172172
}
173173

@@ -185,12 +185,12 @@ private void AddProfile()
185185
MGSVProfile profile = new()
186186
{
187187
Name = ProfileName,
188-
Key = _key
188+
Key = Key
189189
};
190190
var result = _mgsvProfilesService.Add(profile);
191191
if (result)
192192
{
193-
if (!_profileNames.Contains(profile.Name)) _profileNames.Add(profile.Name);
193+
if (!ProfileNames.Contains(profile.Name)) ProfileNames.Add(profile.Name);
194194
}
195195
InfoBarFeederConsume(_mgsvProfilesService.Reporter);
196196
}
@@ -201,7 +201,7 @@ private void RemoveProfile()
201201
MGSVProfile profile = new()
202202
{
203203
Name = ProfileName,
204-
Key = _key
204+
Key = Key
205205
};
206206
_mgsvProfilesService.Remove(profile);
207207
InfoBarFeederConsume(_mgsvProfilesService.Reporter);

0 commit comments

Comments
 (0)