Skip to content

Commit 6f1a3d4

Browse files
committed
Cleaned dev branch history
1 parent 82187fe commit 6f1a3d4

9 files changed

+224
-13
lines changed

.config/dotnet-tools.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"cake.tool": {
6+
"version": "5.0.0",
7+
"commands": [
8+
"dotnet-cake"
9+
],
10+
"rollForward": false
11+
}
12+
}
13+
}

.github/workflows/build-and-pack.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build & Pack Extension
2+
3+
on:
4+
push:
5+
branches: [main, dev]
6+
workflow_dispatch: {}
7+
8+
jobs:
9+
build-and-pack:
10+
runs-on: windows-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Setup MSBuild
16+
uses: microsoft/setup-msbuild@v2
17+
18+
- name: Setup NuGet
19+
uses: NuGet/setup-nuget@v2
20+
21+
- name: Setup .NET Core
22+
uses: actions/setup-dotnet@v4
23+
with:
24+
dotnet-version: "8.0.x"
25+
26+
- name: Run the Cake script
27+
uses: cake-build/cake-action@v3
28+
with:
29+
script-path: ./build.cake
30+
target: Pack

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -360,4 +360,6 @@ MigrationBackup/
360360
.ionide/
361361

362362
# Fody - auto-generated XML schema
363-
FodyWeavers.xsd
363+
FodyWeavers.xsd
364+
.vscode/settings.json
365+
tools/Addins/*

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This plugin periodically checks the Epic Games Store for free games and gives yo
66
Clicking the notification brings you to the game page so you can claim it.
77

88
## Todo
9-
Eventually I would like to support checking other game stores
9+
Eventually I would like to support checking other game stores.
1010

1111
## Screenshots
1212

build.cake

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
var target = Argument("target", "Pack");
2+
var configuration = Argument("configuration", "Release");
3+
4+
var assemblyName = "FreeGameNotifications";
5+
var solution = "./source/FreeGameNotifications.sln";
6+
var output = $"./source/bin/{configuration}";
7+
8+
// List of files to pack, everything else is ignored
9+
List<string> filesToPack = [
10+
"extension.yaml",
11+
$"{assemblyName}.dll",
12+
$"{assemblyName}.pdb",
13+
"icon.png",
14+
"en_US.xaml"
15+
];
16+
17+
private (string id, string version) ReadExtensionManifest()
18+
{
19+
var manifestPath = $"{output}/extension.yaml";
20+
var manifestLines = System.IO.File.ReadAllLines(manifestPath);
21+
22+
var id = manifestLines
23+
.FirstOrDefault(line => line.StartsWith("Id:"))
24+
?.Replace("Id: ", string.Empty);
25+
26+
var version = manifestLines
27+
.FirstOrDefault(line => line.StartsWith("Version:"))
28+
?.Replace("Version: ", string.Empty)
29+
?.Replace(".", "_");
30+
31+
Information("Reading extension.yaml: Id: {0}, Version: {1}", id, version);
32+
33+
return (id, version);
34+
}
35+
36+
string PackExtension()
37+
{
38+
// remove all files from output folder except the ones in filesToPack
39+
var files = System.IO.Directory.GetFiles(output, "*.*", System.IO.SearchOption.AllDirectories);
40+
41+
Information("Preparing to pack files");
42+
foreach (var file in files)
43+
{
44+
var name = System.IO.Path.GetFileName(file);
45+
if (!filesToPack.Contains(name))
46+
{
47+
Information("File not in filesToPack, removing: {0}", name);
48+
System.IO.File.Delete(file);
49+
}
50+
}
51+
52+
// Read extension manifest
53+
(var id, var version) = ReadExtensionManifest();
54+
var packedExtension = $"{output}/{id}_{version}.pext";
55+
56+
// Zip contents of output
57+
Zip(output, packedExtension);
58+
59+
return packedExtension;
60+
}
61+
62+
Task("Clean")
63+
.Does(() =>
64+
{
65+
CleanDirectory(output);
66+
});
67+
68+
Task("Restore")
69+
.Does(() =>
70+
{
71+
// Restore NuGet packages
72+
Information("Restoring NuGet packages...");
73+
NuGetRestore(solution);
74+
});
75+
76+
Task("Build")
77+
.IsDependentOn("Clean")
78+
.IsDependentOn("Restore")
79+
.Does(() =>
80+
{
81+
// Build the solution
82+
MSBuild(solution, settings =>
83+
{
84+
settings.SetConfiguration(configuration);
85+
});
86+
});
87+
88+
Task("Pack")
89+
.IsDependentOn("Build")
90+
.Does(async () =>
91+
{
92+
var packedExtension = PackExtension();
93+
var artifactName = System.IO.Path.GetFileName(packedExtension);
94+
95+
// upload packedExtension artifact to github
96+
Information("Packed extension: {0}", artifactName);
97+
98+
await GitHubActions.Commands.UploadArtifact(new FilePath(packedExtension), assemblyName);
99+
});
100+
101+
RunTarget(target);

source/EpicGamesWebApi.cs

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ namespace FreeGameNotifications
1515
{
1616
public class EpicGamesWebApi
1717
{
18+
private static readonly ILogger logger = LogManager.GetLogger();
19+
1820
public static async Task<List<Notification>> GetGames()
1921
{
2022
using (var client = new HttpClient())
@@ -38,6 +40,7 @@ public static async Task<List<Notification>> GetGames()
3840
// skipping code redemption only
3941
if (isCodeRedemptionOnly)
4042
{
43+
logger.Info($"Game {gameTitle} is marked as Code Redemption Only, skipping.");
4144
continue;
4245
}
4346

source/FreeGameNotifications.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
<Compile Include="Properties\AssemblyInfo.cs" />
6363
</ItemGroup>
6464
<ItemGroup>
65+
<None Include="..\manifest\installer.yaml">
66+
<Link>installer.yaml</Link>
67+
</None>
6568
<None Include="extension.yaml">
6669
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
6770
</None>

source/FreeGameNotifications.sln

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ VisualStudioVersion = 17.6.33829.357
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeGameNotifications", "FreeGameNotifications.csproj", "{4FDF1E89-5BC3-4C72-8FDA-0D580E7A5D5F}"
77
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "manifest", "manifest", "{E642C328-CB6B-471F-8435-C58AF26AB904}"
9+
ProjectSection(SolutionItems) = preProject
10+
extension.yaml = extension.yaml
11+
..\manifest\installer.yaml = ..\manifest\installer.yaml
12+
EndProjectSection
13+
EndProject
814
Global
915
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1016
Debug|Any CPU = Debug|Any CPU

source/FreeGameNotificationsSettingsView.xaml

+64-11
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,76 @@
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
mc:Ignorable="d"
77
d:DesignHeight="400" d:DesignWidth="600">
8-
<StackPanel>
9-
<TextBlock Text="Show notifications for games already collected:" ToolTip="Check this if you'd like to see notifications for games you already have" TextWrapping="Wrap" Margin="0,10,0,0"/>
10-
<CheckBox IsChecked="{Binding Settings.AlwaysShowNotifications}" ToolTip="Check this if you'd like to see notifications for games you already have" HorizontalAlignment="Left" Margin="10,0,0,0"/>
11-
<TextBlock TextWrapping="Wrap" Margin="0,10,0,0" Text="Check Interval (in hours ; minimum value: 1, maximum value: 24)"/>
12-
<TextBox Text="{Binding Settings.CheckInterval}" InputScope="Number" Width="252" HorizontalAlignment="Left" Margin="10,0,0,0"/>
13-
<TextBlock Text="Save shown notifications in a local history and do not show them again:" ToolTip="Check this if you'd like to not see notifications you've already seen" TextWrapping="Wrap" Margin="0,10,0,0"/>
14-
<CheckBox IsChecked="{Binding Settings.UseNotificationHistory}" ToolTip="Check this if you'd like to not see notifications you've already seen" Margin="10,0,0,0"/>
15-
<TextBlock Margin="0,10,0,0" Text="Local History (read-only, copiable):"/>
16-
<ListBox Margin="20" ItemsSource="{Binding Settings.History}">
8+
<Grid Margin="5">
9+
<Grid.RowDefinitions>
10+
<!-- These only take up needed space -->
11+
<RowDefinition Height="Auto"/>
12+
<RowDefinition Height="Auto"/>
13+
<RowDefinition Height="Auto"/>
14+
<RowDefinition Height="Auto"/>
15+
<RowDefinition Height="Auto"/>
16+
<RowDefinition Height="Auto"/>
17+
<RowDefinition Height="Auto"/>
18+
<RowDefinition Height="*"/>
19+
<!-- The last item takes remaining space -->
20+
</Grid.RowDefinitions>
21+
22+
<TextBlock Grid.Row="0"
23+
Margin="5"
24+
Text="Show notifications for games already collected:"
25+
ToolTip="Check this if you'd like to see notifications for games you already have"
26+
TextWrapping="Wrap" />
27+
28+
<CheckBox Grid.Row="1"
29+
Margin="5"
30+
IsChecked="{Binding Settings.AlwaysShowNotifications}"
31+
ToolTip="Check this if you'd like to see notifications for games you already have"
32+
HorizontalAlignment="Left" />
33+
34+
<TextBlock Grid.Row="2"
35+
Margin="5"
36+
TextWrapping="Wrap"
37+
Text="Check Interval (in hours ; minimum value: 1, maximum value: 24)" />
38+
39+
<TextBox Grid.Row="3"
40+
Margin="5"
41+
Text="{Binding Settings.CheckInterval}"
42+
InputScope="Number"
43+
Width="50"
44+
HorizontalAlignment="Left" />
45+
46+
<TextBlock Grid.Row="4"
47+
Margin="5"
48+
Text="Save shown notifications in a local history and do not show them again:"
49+
ToolTip="Check this if you'd like to not see notifications you've already seen"
50+
TextWrapping="Wrap" />
51+
52+
<CheckBox Grid.Row="5"
53+
Margin="5"
54+
IsChecked="{Binding Settings.UseNotificationHistory}"
55+
ToolTip="Check this if you'd like to not see notifications you've already seen" />
56+
57+
<TextBlock Grid.Row="6"
58+
Margin="5"
59+
Text="Local History (read-only, copiable):" />
60+
61+
<ListBox Grid.Row="7"
62+
Margin="5"
63+
ItemsSource="{Binding Settings.History}">
64+
1765
<ListBox.ItemTemplate>
1866
<DataTemplate>
1967
<StackPanel Orientation="Horizontal">
20-
<TextBox Background="Transparent" BorderThickness="0" Text="{Binding Path=., Mode=OneWay}" IsReadOnly="True" TextWrapping="Wrap" />
68+
<TextBox Background="Transparent"
69+
BorderThickness="0"
70+
Text="{Binding Path=., Mode=OneWay}"
71+
IsReadOnly="True"
72+
TextWrapping="Wrap" />
2173
</StackPanel>
2274
</DataTemplate>
2375
</ListBox.ItemTemplate>
2476
</ListBox>
77+
</Grid>
78+
2579

26-
</StackPanel>
2780
</UserControl>

0 commit comments

Comments
 (0)