├── .gitattributes
├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ ├── feature_request.md
│ └── question.md
└── workflows
│ ├── deployment-develop.yml
│ └── deployment-master.yml
├── .gitignore
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── SECURITY.md
├── gamevault.sln
└── gamevault
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── Converter
├── ContainsCurrentUserConverter.cs
├── DownloadLimitConverter.cs
├── EnumDescriptionConverter.cs
├── GameSettingsTabVisibilityConverter.cs
├── GameSizeConverter.cs
├── GameStateColorConverter.cs
├── GameStateDescriptionConverter.cs
├── GameTimeConverter.cs
├── GameViewSettingsPermissionRoleToVisibilityConverter.cs
├── GreaterThanConverter.cs
├── InverseBoolConverter.cs
├── InverseEmptyStringConverter.cs
├── InverseNullConverter.cs
├── InverseVisibilityConverter.cs
├── IsGameDownloadedConverter.cs
├── IsGameMappedConverter.cs
├── LibraryPermissionRoleToVisibilityConverter.cs
├── LicenseConverter.cs
├── PermissionRoleConverter.cs
├── PermissionRoleToVisibilityConverter.cs
├── ShowMappedTitleConverter.cs
├── StringToArrayConverter.cs
├── StringToColorConverter.cs
├── UTCtoLocalTimeConverter.cs
└── UrlImageConverter.cs
├── Helper
├── AnalyticsHelper.cs
├── CommandHelper.cs
├── CrashReportHelper.cs
├── DownloadSpeedCalculator.cs
├── GameTimeTracker.cs
├── InputTimer.cs
├── Integrations
│ ├── AutostartHelper.cs
│ ├── DesktopHelper.cs
│ ├── DiscordHelper.cs
│ ├── SaveGameHelper.cs
│ ├── SevenZipHelper.cs
│ ├── SteamHelper.cs
│ ├── StoreHelper.cs
│ └── ToastMessageHelper.cs
├── LoginManager.cs
├── Media
│ ├── BitmapHelper.cs
│ ├── CacheHelper.cs
│ ├── GifHelper.cs
│ └── MimeTypeHelper.cs
├── ProcessHelper.cs
├── ScrollViewerHelper.cs
├── StringCompressor.cs
├── TaskQueue.cs
├── VisualHelper.cs
└── Web
│ ├── HttpClientDownloadWithProgress.cs
│ ├── WebExceptionHelper.cs
│ ├── WebHelper.cs
│ └── WpfEmbeddedBrowser.cs
├── Lib
├── 7z
│ ├── 7z.dll
│ ├── 7z.exe
│ └── LICENSE
├── Preferences.dll
└── savegame
│ ├── LICENSE
│ └── ludusavi.exe
├── Models
├── AppInfo.cs
├── CommandOptions.cs
├── Game.cs
├── ImageCache.cs
├── Mapping
│ ├── MapGameDto.cs
│ ├── MetadataProviderDto.cs
│ ├── UpdateGameDto.cs
│ └── UpdateUserDto.cs
├── Media.cs
├── Metadata
│ ├── DeveloperMetadata.cs
│ ├── GameMetadata.cs
│ ├── GenreMetadata.cs
│ ├── PublisherMetadata.cs
│ ├── TagMetadata.cs
│ └── UpdateGameUserMetadataDto.cs
├── MinimalGame.cs
├── PaginatedGame.cs
├── PhalcodeProduct.cs
├── Pill.cs
├── Progress.cs
├── ServerInfo.cs
└── User.cs
├── PipeServiceHandler.cs
├── Program.cs
├── Properties
└── launchSettings.json
├── Resources
├── Assets
│ ├── Base.xaml
│ ├── Colors.xaml
│ ├── Icons.xaml
│ ├── MarkdownStyles.xaml
│ ├── Styles.xaml
│ └── Themes
│ │ ├── ThemeChristmasDark.xaml
│ │ ├── ThemeClassicDark.xaml
│ │ ├── ThemeDefaultDark.xaml
│ │ ├── ThemeDefaultLight.xaml
│ │ ├── ThemeHalloweenDark.xaml
│ │ ├── ThemePhalcodeDark.xaml
│ │ └── ThemePhalcodeLight.xaml
└── Images
│ ├── ContextMenuIcon_Community.png
│ ├── ContextMenuIcon_Downloads.png
│ ├── ContextMenuIcon_Exit.png
│ ├── ContextMenuIcon_Library.png
│ ├── ContextMenuIcon_Settings.png
│ ├── com_NoUserAvatar.png
│ ├── gameView_NoBackground.jpg
│ ├── glyph_premium.png
│ ├── icon.ico
│ ├── install_NoGameFound.png
│ ├── library_NoGameCover.png
│ └── library_NoGameFound.png
├── Scripts
└── GenerateClient.ps1
├── UserControls
├── AdminConsoleUserControl.xaml
├── AdminConsoleUserControl.xaml.cs
├── CommunityUserControl.xaml
├── CommunityUserControl.xaml.cs
├── DownloadsUserControl.xaml
├── DownloadsUserControl.xaml.cs
├── GameDownloadUserControl.xaml
├── GameDownloadUserControl.xaml.cs
├── GameSettingsUserControl.xaml
├── GameSettingsUserControl.xaml.cs
├── GameViewUserControl.xaml
├── GameViewUserControl.xaml.cs
├── GeneralControls
│ ├── CacheImage.xaml
│ ├── CacheImage.xaml.cs
│ ├── DateRangeSelector.xaml
│ ├── DateRangeSelector.xaml.cs
│ ├── IconButton.cs
│ ├── MediaSlider.xaml
│ ├── MediaSlider.xaml.cs
│ ├── NewsPopup.xaml
│ ├── NewsPopup.xaml.cs
│ ├── PillSelector.xaml
│ ├── PillSelector.xaml.cs
│ └── TransitioningContentControlEx.cs
├── InstallUserControl.xaml
├── InstallUserControl.xaml.cs
├── LibraryUserControl.xaml
├── LibraryUserControl.xaml.cs
├── SettingsComponents
│ ├── BackupRestoreUserControl.xaml
│ ├── BackupRestoreUserControl.xaml.cs
│ ├── LoginUserControl.xaml
│ ├── LoginUserControl.xaml.cs
│ ├── RegisterUserControl.xaml
│ ├── RegisterUserControl.xaml.cs
│ ├── RootPathUserControl.xaml
│ ├── RootPathUserControl.xaml.cs
│ ├── ServerUrlUserControl.xaml
│ └── ServerUrlUserControl.xaml.cs
├── SettingsUserControl.xaml
├── SettingsUserControl.xaml.cs
├── UserSettingsUserControl.xaml
├── UserSettingsUserControl.xaml.cs
├── Wizard.xaml
└── Wizard.xaml.cs
├── ViewModels
├── AdminConsoleViewModel.cs
├── CommunityViewModel.cs
├── DownloadsViewModel.cs
├── GameDownloadViewModel.cs
├── GameSettingsViewModel.cs
├── GameViewViewModel.cs
├── InstallViewModel.cs
├── LibraryViewModel.cs
├── MainWindowViewModel.cs
├── SettingsViewModel.cs
├── UserSettingsViewModel.cs
└── ViewModelBase.cs
├── Windows
├── ExceptionWindow.xaml
├── ExceptionWindow.xaml.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── UpdateWindow.xaml
└── UpdateWindow.xaml.cs
├── app.manifest
└── gamevault.csproj
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 | github: phalcode
3 | ko_fi: phalcode
4 | liberapay: phalcode
5 | custom: "https://paypal.me/phalcode"
6 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 🪲 Report a Bug
3 | about: Does something not work correctly?
4 | labels: ["💻 client", "🪲 bug"]
5 | projects: "Phalcode/4"
6 | ---
7 |
8 | **Describe the bug**
9 | A clear and concise description of what the bug is.
10 |
11 | **To Reproduce**
12 | Steps to reproduce the behavior:
13 | 1. Go to '...'
14 | 2. Click on '....'
15 | 3. Scroll down to '....'
16 | 4. See error
17 |
18 | **Expected behavior**
19 | A clear and concise description of what you expected to happen.
20 |
21 | **Screenshots**
22 | If applicable, add screenshots to help explain your problem.
23 |
24 | **Desktop (please complete the following information):**
25 | - OS: [e.g. iOS]
26 | - Browser [e.g. chrome, safari]
27 | - Version [e.g. 22]
28 |
29 | **Smartphone (please complete the following information):**
30 | - Device: [e.g. iPhone6]
31 | - OS: [e.g. iOS8.1]
32 | - Browser [e.g. stock browser, safari]
33 | - Version [e.g. 22]
34 |
35 | **Additional context**
36 | Add any other context about the problem here.
37 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 🔧 Request a Feature
3 | about: Do you have a Feature Request?
4 | labels: ["💻 client", "🔧 feature"]
5 | projects: "Phalcode/4"
6 | ---
7 |
8 | **Is your feature request related to a problem? Please describe.**
9 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
10 |
11 | **Describe the solution you'd like**
12 | A clear and concise description of what you want to happen.
13 |
14 | **Describe alternatives you've considered**
15 | A clear and concise description of any alternative solutions or features you've considered.
16 |
17 | **Additional context**
18 | Add any other context or screenshots about the feature request here.
19 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/question.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: ❓ Question
3 | about: Do you have a Question?
4 | labels: ["💻 client","❓ question"]
5 | projects: "Phalcode/4"
6 | ---
7 |
8 | **Your Question**
9 |
10 | Ask your question or seek clarification here.
11 |
12 | **Additional Context**
13 |
14 | Add any additional context or information that may be helpful.
15 |
--------------------------------------------------------------------------------
/.github/workflows/deployment-develop.yml:
--------------------------------------------------------------------------------
1 | name: Deployment Pipeline for develop branch
2 | on:
3 | push:
4 | branches:
5 | - develop
6 | jobs:
7 | deploy:
8 | permissions: write-all
9 | runs-on: windows-latest
10 | outputs:
11 | version: ${{ steps.release.outputs.version }}
12 |
13 | steps:
14 | - name: Checkout repository
15 | id: checkout
16 | uses: actions/checkout@v2
17 |
18 | - name: Set up .NET
19 | id: setup
20 | uses: actions/setup-dotnet@v3.2.0
21 | with:
22 | dotnet-version: '8.x'
23 |
24 | - name: Build .NET solution
25 | id: build
26 | run: |
27 | dotnet build gamevault.sln --configuration Release
28 | 7z a GameVault.zip gamevault/bin
29 |
30 | - name: Upload binaries to release
31 | uses: svenstaro/upload-release-action@v2
32 | with:
33 | repo_token: ${{ secrets.GITHUB_TOKEN }}
34 | file: GameVault.zip
35 | asset_name: GameVault.zip
36 | tag: unstable
37 | overwrite: true
38 | prerelease: true
39 |
--------------------------------------------------------------------------------
/.github/workflows/deployment-master.yml:
--------------------------------------------------------------------------------
1 | name: Deployment Pipeline for master branch
2 | on:
3 | push:
4 | branches:
5 | - master
6 | jobs:
7 | deploy:
8 | permissions: write-all
9 | runs-on: windows-latest
10 | outputs:
11 | version: ${{ steps.release.outputs.version }}
12 |
13 | steps:
14 | - name: Checkout repository
15 | id: checkout
16 | uses: actions/checkout@v2
17 |
18 | - name: Set up .NET
19 | id: setup
20 | uses: actions/setup-dotnet@v3.2.0
21 | with:
22 | dotnet-version: '8.x'
23 |
24 | - name: Build .NET solution
25 | id: build
26 | run: |
27 | dotnet build gamevault.sln --configuration Release
28 | 7z a GameVault.zip gamevault/bin
29 |
30 | - name: Create Github Tag & Release
31 | id: release
32 | uses: CupOfTea696/gh-action-auto-release@v1.0.2
33 | env:
34 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35 | with:
36 | tag: "$semver.0"
37 |
38 | - name: Upload Release Artifact
39 | id: upload
40 | uses: actions/upload-release-asset@v1
41 | with:
42 | asset_path: GameVault.zip
43 | asset_name: GameVault.zip
44 | asset_content_type: application/zip
45 | upload_url: ${{steps.release.outputs.upload_url}}
46 | env:
47 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48 |
49 | notify_discord:
50 | needs: deploy
51 | runs-on: ubuntu-latest
52 | steps:
53 | - name: Send Discord Notification
54 | id: discord
55 | uses: Ilshidur/action-discord@master
56 | env:
57 | DISCORD_WEBHOOK: ${{ secrets.DISCORD_RELEASE_BOT_WEBHOOK }}
58 | with:
59 | args: '<@&1128857090090340382> New Release: ${{ github.event.repository.full_name }} v${{ needs.deploy.outputs.version }}.0 has been deployed. Here are the changes: https://github.com/${{ github.event.repository.full_name }}/releases/tag/${{ needs.deploy.outputs.version }}.0'
60 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://gamevau.lt)
2 |
3 | # GameVault Application
4 |
5 | ## Introduction
6 |
7 | **What is GameVault?**
8 | GameVault is an innovative gaming platform providing a self-hosted, source-available alternative to popular gaming platforms. It lets you and your friends enjoy DRM-free games stored on your file server in an organized way. Think of it as a self-hosted Steam. The project you are looking at right now is the client application.
9 |
10 | **Learn More & Get Started**
11 | [You can learn more about the project and find useful guides and information on the official Website.](https://gamevau.lt)
12 |
13 | ## Support 🤝
14 |
15 | We're working hard in our free time to provide you, your friends, and families with the best self-hosted gaming experience.
16 | It would mean a lot to us if you could support us developers by [getting GameVault+](https://gamevau.lt/gamevault-plus).
17 |
18 | Alternatively, you can support us by donating us some spare dollars on any of these platforms:
19 |
20 | - [Ko-Fi](https://ko-fi.com/phalcode)
21 | - [Liberapay](https://liberapay.com/Phalcode)
22 | - [GitHub Sponsors](https://github.com/sponsors/Phalcode)
23 | - [PayPal](https://paypal.me/phalcode)
24 |
25 | **TIP FOR DONATORS:**
26 | If you connect your Discord account to Ko-Fi, you'll automatically receive the "@Supporters" role and permanently stand out in our Discord members list. If you donate through a different platform and want to obtain the role, simply send us a message with your receipt as proof that you're truly a Supporter. 🌟
27 |
28 | ## License 📜
29 |
30 | **[CC BY-NC-SA 4.0](http://creativecommons.org/licenses/by-nc-sa/4.0/)**
31 |
32 | This work is licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-nc-sa/4.0/).
33 |
34 | This project is not and never was open-source. [Click here to learn why.](https://gamevau.lt/blog/2023/07/13/)
35 |
36 | ## Legal Disclaimer ⚖️
37 |
38 | GameVault manages DRM-free games and is solely a tool to address this need. We are not responsible for the content or files users store or share.
39 |
40 | When we say DRM-free games, we only mean games obtained legally. While GameVault can theoretically be used with illegally obtained games, we do not endorse or support piracy.
41 |
42 | Users must be aware of and comply with copyright laws in their respective jurisdictions. We encourage responsible and legal use of GameVault. Unlawful use is strictly improper and unauthorized.
43 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Supported Versions
4 |
5 | The following Application Versions are supported by Phalcode and get regular security updates.
6 |
7 | | Version | Regular Updates | Supported |
8 | | ------- | --------------- |---------- |
9 | | ``Latest Minor Version`` | :white_check_mark: | :white_check_mark: |
10 | | ``Early Access Version`` | :white_check_mark: | :white_check_mark: |
11 | | ``Older Versions`` | :x: | :x: |
12 |
13 | ## Reporting a Vulnerability
14 | Please report any vulnerabilities to Phalcode [via Email](mailto:contact@phalco.de).
15 |
--------------------------------------------------------------------------------
/gamevault/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/gamevault/AssemblyInfo.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Phalcode/gamevault-app/b3061169bf2e18150397ccef40989dff93309ba9/gamevault/AssemblyInfo.cs
--------------------------------------------------------------------------------
/gamevault/Converter/ContainsCurrentUserConverter.cs:
--------------------------------------------------------------------------------
1 | using gamevault.Helper;
2 | using gamevault.Models;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Globalization;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Data;
10 |
11 | namespace gamevault.Converter
12 | {
13 | internal class ContainsCurrentUserConverter : IValueConverter
14 | {
15 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16 | {
17 | try
18 | {
19 | if (value.GetType() == typeof(List))
20 | {
21 | return ((List)value).Any(u => u.ID == LoginManager.Instance.GetCurrentUser().ID);
22 | }
23 | }
24 | catch { }
25 | return false;
26 | }
27 |
28 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
29 | {
30 | return false;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/gamevault/Converter/DownloadLimitConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Data;
8 |
9 | namespace gamevault.Converter
10 | {
11 | internal class DownloadLimitConverter : IValueConverter
12 | {
13 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
14 | {
15 | try
16 | {
17 | double size = double.Parse(value.ToString());
18 | if (size == 0)
19 | {
20 | return "Unlimited";
21 | }
22 |
23 | if (size >= 1000000)
24 | {
25 | size /= 1000000;
26 | size = Math.Round(size, 2);
27 | return $"{size} GB/s";
28 | }
29 | else if (size >= 1000)
30 | {
31 | size /= 1000;
32 | size = Math.Round(size, 2);
33 | return $"{size} MB/s";
34 | }
35 | else
36 | {
37 | size = Math.Round(size, 2);
38 | return $"{size} KB/s";
39 | }
40 | }
41 | catch
42 | {
43 | return "Calc error";
44 | }
45 | }
46 |
47 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
48 | {
49 | return "";
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/gamevault/Converter/EnumDescriptionConverter.cs:
--------------------------------------------------------------------------------
1 | using gamevault.Models;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.ComponentModel;
5 | using System.Globalization;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Data;
10 |
11 | namespace gamevault.Converter
12 | {
13 | internal class EnumDescriptionConverter : IValueConverter
14 | {
15 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16 | {
17 | if (value is GameType && (GameType)value != GameType.UNDETECTABLE)
18 | {
19 | string result = ((DescriptionAttribute[])typeof(GameType).GetField(((GameType)value).ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false))[0].Description.ToString();
20 | return result;
21 | }
22 | else if (value is State)
23 | {
24 | string result = ((DescriptionAttribute[])typeof(State).GetField(((State)value).ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false))[0].Description.ToString();
25 | return result;
26 | }
27 | return string.Empty;
28 | }
29 |
30 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
31 | {
32 | return string.Empty;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/gamevault/Converter/GameSettingsTabVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | using gamevault.Helper;
2 | using gamevault.Models;
3 | using gamevault.ViewModels;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Globalization;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows;
11 | using System.Windows.Data;
12 |
13 | namespace gamevault.Converter
14 | {
15 | internal class GameSettingsTabVisibilityConverter : IValueConverter
16 | {
17 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
18 | {
19 | if (((Game)value) == null)
20 | return Visibility.Collapsed;
21 | if (parameter.ToString() == "local")
22 | {
23 | if (InstallViewModel.Instance.InstalledGames.Where(g => g.Key.ID == ((Game)value).ID).Count() > 0)
24 | {
25 | return Visibility.Visible;
26 | }
27 | }
28 | else if (parameter.ToString() == "server")
29 | {
30 | if (LoginManager.Instance.IsLoggedIn() && (LoginManager.Instance.GetCurrentUser() != null && LoginManager.Instance.GetCurrentUser().Role >= PERMISSION_ROLE.EDITOR))
31 | {
32 | return Visibility.Visible;
33 | }
34 | }
35 | return Visibility.Collapsed;
36 | }
37 |
38 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
39 | {
40 | return false;
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/gamevault/Converter/GameSizeConverter.cs:
--------------------------------------------------------------------------------
1 | using gamevault.Models;
2 | using System;
3 | using System.Globalization;
4 | using System.Windows.Data;
5 | using System.Windows.Media.Imaging;
6 |
7 | namespace gamevault.Converter
8 | {
9 | internal class GameSizeConverter : IValueConverter
10 | {
11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
12 | {
13 | try
14 | {
15 | if (value == null)
16 | {
17 | throw new ArgumentException("Invalid input value");
18 | }
19 |
20 | double size = double.Parse(value.ToString());
21 |
22 | // DEFAULTS TO IEC (1024) used for storage capacity etc.
23 | int baseValue = 1024;
24 | if (parameter != null && parameter is int)
25 | {
26 | // Other Standard could be SI (1000) used for download speeds etc.
27 | baseValue = (int)parameter;
28 | }
29 |
30 | string[] sizeSuffixes = { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
31 |
32 | int suffixIndex = 0;
33 | while (size >= baseValue && suffixIndex < sizeSuffixes.Length - 1)
34 | {
35 | size /= baseValue;
36 | suffixIndex++;
37 | }
38 |
39 | size = Math.Round(size, 2);
40 | return $"{size} {sizeSuffixes[suffixIndex]}";
41 | }
42 | catch (Exception ex)
43 | {
44 | return "ERR";
45 | }
46 | }
47 |
48 |
49 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
50 | {
51 | return "";
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/gamevault/Converter/GameStateColorConverter.cs:
--------------------------------------------------------------------------------
1 | using gamevault.Models;
2 | using System;
3 | using System.Globalization;
4 | using System.Windows.Data;
5 | using System.Windows.Media;
6 |
7 | namespace gamevault.Converter
8 | {
9 | class GameStateColorConverter : IValueConverter
10 | {
11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
12 | {
13 | try
14 | {
15 | State state = (State)Enum.Parse(typeof(State), value.ToString());
16 | switch(state)
17 | {
18 | case State.UNPLAYED:
19 | return Brushes.DarkGray;
20 | case State.INFINITE:
21 | return Brushes.Yellow;
22 | case State.PLAYING:
23 | return Brushes.Green;
24 | case State.COMPLETED:
25 | return Brushes.Violet;
26 | case State.ABORTED_TEMPORARY:
27 | return Brushes.Orange;
28 | case State.ABORTED_PERMANENT:
29 | return Brushes.Red;
30 | default:
31 | return null;
32 | }
33 |
34 | }
35 | catch (Exception ex)
36 | {
37 | return null;
38 | }
39 | }
40 |
41 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
42 | {
43 | return null;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/gamevault/Converter/GameStateDescriptionConverter.cs:
--------------------------------------------------------------------------------
1 | using gamevault.Models;
2 | using System;
3 | using System.ComponentModel;
4 | using System.Globalization;
5 | using System.Windows.Data;
6 |
7 | namespace gamevault.Converter
8 | {
9 | internal class GameStateDescriptionConverter : IValueConverter
10 | {
11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
12 | {
13 | State enumValue = (State)Enum.Parse(typeof(State), value as string);
14 | string result = ((DescriptionAttribute[])typeof(State).GetField(((State)enumValue).ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false))[0].Description.ToString();
15 | return result;
16 | }
17 |
18 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
19 | {
20 | return string.Empty;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/gamevault/Converter/GameTimeConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Data;
8 |
9 | namespace gamevault.Converter
10 | {
11 | internal class GameTimeConverter : IValueConverter
12 | {
13 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
14 | {
15 | try
16 | {
17 | if (value != null)
18 | {
19 | int minutes = (int)value;
20 | if (minutes < 60)
21 | {
22 | return $"{minutes} min";
23 | }
24 | double hours = (double)minutes / 60;
25 | hours = Math.Round(hours, 1);
26 | return $"{hours} h";
27 | }
28 | return "?";
29 | }
30 | catch (Exception ex)
31 | {
32 | return "?";
33 | }
34 | }
35 |
36 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
37 | {
38 | return "";
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/gamevault/Converter/GameViewSettingsPermissionRoleToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | using gamevault.Helper;
2 | using gamevault.Models;
3 | using System;
4 | using System.Globalization;
5 | using System.Windows;
6 | using System.Windows.Data;
7 |
8 | namespace gamevault.Converter
9 | {
10 | internal class GameViewSettingsPermissionRoleToVisibilityConverter : IValueConverter
11 | {
12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
13 | {
14 | bool isInstalled = (bool)value;
15 | if (isInstalled || ((LoginManager.Instance.GetCurrentUser() != null && LoginManager.Instance.GetCurrentUser().Role >= PERMISSION_ROLE.EDITOR)))
16 | {
17 | return Visibility.Visible;
18 | }
19 | return Visibility.Collapsed;
20 | }
21 |
22 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
23 | {
24 | return false;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/gamevault/Converter/GreaterThanConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Data;
8 |
9 | namespace gamevault.Converter
10 | {
11 | internal class GreaterThanConverter : IValueConverter
12 | {
13 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
14 | {
15 | return ((int)value > int.Parse((string)parameter));
16 | }
17 |
18 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
19 | {
20 | return null;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/gamevault/Converter/InverseBoolConverter.cs:
--------------------------------------------------------------------------------
1 | using gamevault.Models;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows.Data;
9 | using System.Windows.Media.Imaging;
10 |
11 | namespace gamevault.Converter
12 | {
13 | internal class InverseBoolConverter : IValueConverter
14 | {
15 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16 | {
17 | return !((bool)value);
18 | }
19 |
20 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
21 | {
22 | return null;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/gamevault/Converter/InverseEmptyStringConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Data;
8 |
9 | namespace gamevault.Converter
10 | {
11 | internal class InverseEmptyStringConverter : IValueConverter
12 | {
13 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
14 | {
15 | return (value == null || value.ToString() == string.Empty);
16 | }
17 |
18 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
19 | {
20 | return null;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/gamevault/Converter/InverseNullConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Data;
8 |
9 | namespace gamevault.Converter
10 | {
11 | internal class InverseNullConverter : IValueConverter
12 | {
13 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
14 | {
15 | return (value == null);
16 | }
17 |
18 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
19 | {
20 | return null;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/gamevault/Converter/InverseVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Data;
9 |
10 | namespace gamevault.Converter
11 | {
12 | internal class InverseVisibilityConverter : IValueConverter
13 | {
14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15 | {
16 | Visibility visibility = (Visibility)value;
17 | if(visibility == Visibility.Visible)
18 | {
19 | return Visibility.Hidden;
20 | }
21 | else
22 | {
23 | return Visibility.Visible;
24 | }
25 | }
26 |
27 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
28 | {
29 | return null;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/gamevault/Converter/IsGameDownloadedConverter.cs:
--------------------------------------------------------------------------------
1 | using gamevault.Models;
2 | using gamevault.ViewModels;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Diagnostics;
6 | using System.Globalization;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows.Data;
11 |
12 | namespace gamevault.Converter
13 | {
14 | internal class IsGameDownloadedConverter : IValueConverter
15 | {
16 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
17 | {
18 | //Debug.WriteLine("IsDownloaded");
19 | if (value == null)
20 | return false;
21 | return DownloadsViewModel.Instance.DownloadedGames.Where(gameUC => gameUC.GetGameId() == (int)value).Count() > 0;
22 | }
23 |
24 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
25 | {
26 | return false;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/gamevault/Converter/IsGameMappedConverter.cs:
--------------------------------------------------------------------------------
1 | using gamevault.Models;
2 | using gamevault.Models.Mapping;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Globalization;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Data;
10 |
11 | namespace gamevault.Converter
12 | {
13 | internal class IsGameMappedConverter : IMultiValueConverter
14 | {
15 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
16 | {
17 | try
18 | {
19 | if (values[1].GetType() == typeof(GameMetadata))
20 | {
21 | return ((List)values[0]).Any(entry => entry.ProviderSlug == ((GameMetadata)values[1]).ProviderSlug);
22 | }
23 | else if(values[1].GetType() == typeof(MetadataProviderDto))
24 | {
25 | return ((List)values[0]).Any(entry => entry.ProviderSlug == ((MetadataProviderDto)values[1]).Slug);
26 | }
27 | else
28 | {
29 | return false;
30 | }
31 | }
32 | catch { return false; }
33 | }
34 |
35 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
36 | {
37 | return null;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/gamevault/Converter/LibraryPermissionRoleToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | using gamevault.Helper;
2 | using gamevault.Models;
3 | using System;
4 | using System.Diagnostics;
5 | using System.Globalization;
6 | using System.Windows;
7 | using System.Windows.Data;
8 |
9 | namespace gamevault.Converter
10 | {
11 | internal class LibraryPermissionRoleToVisibilityConverter : IValueConverter
12 | {
13 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
14 | {
15 | //Debug.WriteLine("PermRoleVis");
16 | if ((LoginManager.Instance.GetCurrentUser() != null && LoginManager.Instance.GetCurrentUser().Role >= PERMISSION_ROLE.EDITOR))
17 | {
18 | return Visibility.Visible;
19 | }
20 | return Visibility.Hidden;
21 | }
22 |
23 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
24 | {
25 | return false;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/gamevault/Converter/LicenseConverter.cs:
--------------------------------------------------------------------------------
1 | using gamevault.ViewModels;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows.Data;
9 |
10 | namespace gamevault.Converter
11 | {
12 | public class LicenseConverter : IValueConverter
13 | {
14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15 | {
16 | return SettingsViewModel.Instance.License.IsActive();
17 | }
18 |
19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
20 | {
21 | return null;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/gamevault/Converter/PermissionRoleConverter.cs:
--------------------------------------------------------------------------------
1 | using gamevault.Models;
2 | using gamevault.UserControls;
3 | using gamevault.ViewModels;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Globalization;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows.Data;
11 |
12 | namespace gamevault.Converter
13 | {
14 | internal class PermissionRoleConverter : IValueConverter
15 | {
16 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
17 | {
18 | if ((User)value != null && ((User)value).Role == PERMISSION_ROLE.ADMIN)
19 | {
20 | return true;
21 | }
22 | return false;
23 | }
24 |
25 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
26 | {
27 | return false;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/gamevault/Converter/PermissionRoleToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | using gamevault.Helper;
2 | using gamevault.Models;
3 | using MahApps.Metro.Controls;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Globalization;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows;
11 | using System.Windows.Data;
12 |
13 | namespace gamevault.Converter
14 | {
15 | internal class PermissionRoleToVisibilityConverter : IValueConverter
16 | {
17 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
18 | {
19 | if ((int)value == 0 || (LoginManager.Instance.GetCurrentUser() != null && LoginManager.Instance.GetCurrentUser().Role == PERMISSION_ROLE.ADMIN))
20 | {
21 | return Visibility.Visible;
22 | }
23 | return Visibility.Hidden;
24 | }
25 |
26 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
27 | {
28 | return false;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/gamevault/Converter/ShowMappedTitleConverter.cs:
--------------------------------------------------------------------------------
1 | using gamevault.Models;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows.Data;
9 |
10 | namespace gamevault.Converter
11 | {
12 | public class ShowMappedTitleConverter : IValueConverter
13 | {
14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15 | {
16 |
17 | bool showMappedTitle = Preferences.Get(AppConfigKey.ShowMappedTitle, AppFilePath.UserFile) == "1";
18 | if (showMappedTitle && value is Game game && !string.IsNullOrWhiteSpace(game?.Metadata?.Title))
19 | {
20 | return true;
21 | }
22 | return false;
23 |
24 | }
25 |
26 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
27 | {
28 | throw new NotImplementedException();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/gamevault/Converter/StringToArrayConverter.cs:
--------------------------------------------------------------------------------
1 | using ImageMagick;
2 | using System;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Windows.Data;
6 |
7 | namespace gamevault.Converter
8 | {
9 | internal class StringToArrayConverter : IValueConverter
10 | {
11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
12 | {
13 | try
14 | {
15 | if (value == null)
16 | return new string[] { };
17 |
18 | if (value.GetType().IsArray)//If its array, then the viewmodel was set insted of the UI
19 | {
20 | var joined = string.Join(",", (string[])value);
21 | return joined;
22 | }
23 | else
24 | {
25 | return value.ToString().Split(new[] { parameter.ToString() }, StringSplitOptions.RemoveEmptyEntries)
26 | .Select(s => s.Trim())
27 | .ToArray();
28 | }
29 | }
30 | catch { return new string[] { }; }
31 | }
32 |
33 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
34 | {
35 | try
36 | {
37 | return value.ToString().Split(new[] { parameter.ToString() }, StringSplitOptions.None)
38 | .Select(s => s.Trim())
39 | .ToArray();
40 | }
41 | catch { return null; }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/gamevault/Converter/StringToColorConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 | using System.Windows.Media;
5 |
6 | namespace gamevault.Converter
7 | {
8 | internal class StringToColorConverter : IValueConverter
9 | {
10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11 | {
12 | if (value is string stringValue)
13 | {
14 | int hashCode = stringValue.GetHashCode();
15 | Color generatedColor = GenerateColor(hashCode);
16 | SolidColorBrush brush = new SolidColorBrush(generatedColor);
17 | brush.Freeze();
18 | return brush;
19 | }
20 | return Brushes.Black;
21 | }
22 | private Color GenerateColor(int numericValue)
23 | {
24 | byte red = (byte)((numericValue >> 16) & 0xFF);
25 | byte green = (byte)((numericValue >> 8) & 0xFF);
26 | byte blue = (byte)(numericValue & 0xFF);
27 |
28 | // Ensure the color is saturated by setting the maximum component to 255
29 | byte maxComponent = Math.Max(red, Math.Max(green, blue));
30 | if (maxComponent > 0)
31 | {
32 | float scale = 200f / maxComponent;
33 | red = (byte)(red * scale);
34 | green = (byte)(green * scale);
35 | blue = (byte)(blue * scale);
36 | }
37 |
38 | return Color.FromRgb(red, green, blue);
39 | }
40 |
41 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
42 | {
43 | return Colors.White;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/gamevault/Converter/UTCtoLocalTimeConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Data;
8 |
9 | namespace gamevault.Converter
10 | {
11 | internal class UTCtoLocalTimeConverter : IValueConverter
12 | {
13 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
14 | {
15 | if (value != null)
16 | {
17 | return ((DateTime)value).ToLocalTime();
18 | }
19 | return null;
20 | }
21 |
22 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
23 | {
24 | if (value != null)
25 | {
26 | return ((DateTime)value).ToUniversalTime().ToString();
27 | }
28 | return null;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/gamevault/Converter/UrlImageConverter.cs:
--------------------------------------------------------------------------------
1 | using gamevault.Models;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows.Data;
9 | using System.Windows.Media.Imaging;
10 |
11 | namespace gamevault.Converter
12 | {
13 | internal class UrlImageConverter : IValueConverter
14 | {
15 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16 | {
17 | try
18 | {
19 | return new BitmapImage(new Uri((string)value)) { CacheOption = BitmapCacheOption.OnLoad };
20 | }
21 | catch (Exception ex)
22 | {
23 | return null;
24 | }
25 | }
26 |
27 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
28 | {
29 | return null;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/gamevault/Helper/CommandHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Input;
7 |
8 | namespace gamevault.Helper
9 | {
10 | internal class CommandHelper : ICommand
11 | {
12 | public event EventHandler