Skip to content

Commit

Permalink
added auto updating, metadata override and game name matching
Browse files Browse the repository at this point in the history
  • Loading branch information
Melodi17 committed May 12, 2024
1 parent 5d07b48 commit ef7411e
Show file tree
Hide file tree
Showing 17 changed files with 454 additions and 243 deletions.
2 changes: 1 addition & 1 deletion GameLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<Compile Update="UI\Forms\IGDBDetailsForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="UI\Forms\Form1.cs">
<Compile Update="UI\Forms\MainForm.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Management.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal static class Management

public static readonly Version Version = Assembly.GetEntryAssembly()!.GetName().Version!;
public static readonly string VersionString = Version.ToString(3);
public static readonly string ExecutablePath = Assembly.GetEntryAssembly()!.Location;
public static readonly string ExecutablePath = Environment.ProcessPath!;
public static Config Config;
public static bool IGDBViable => !string.IsNullOrEmpty(Config.IGDBId) && !string.IsNullOrEmpty(Config.IGDBSecret);
public static event Action<LauncherTheme> ThemeChange;
Expand Down
12 changes: 2 additions & 10 deletions Models/LocalGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public string GamePath
private string launchPath;

public string? CoverPath => this.coverPath;
public string GameMetadataPath => this.gameMetadataPath;
public bool HasCover => this.CoverPath != null && File.Exists(this.CoverPath);

public LocalGame(string filePath)
Expand Down Expand Up @@ -151,18 +152,9 @@ public void LoadOrDownloadResources()
if (game == null)
{
MessageBox.Show("Game not found on IGDB", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
IGDBSearchResultsForm form = new(Path.GetFileName(this.GamePath));
DialogResult result = form.ShowDialog();

if (result == DialogResult.OK && form.SelectedGame != null)
{
string newPath = $"{this.GamePath.TrimEnd('\\', '/')} [{form.SelectedGame.Id}]";
Directory.Move(this.GamePath, newPath);
this.GamePath = newPath;

if (MetadataOverrideForm.OverrideMetadata(this))
game = Management.IGDBObj.Search(Path.GetFileName(this.GamePath))
.FirstOrDefault();
}
else
return;
}
Expand Down
2 changes: 1 addition & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static void Main()

//splashForm.Invoke(splashForm.Close);

Application.Run(new Form1());
Application.Run(new MainForm());
}

private static void UnhandledException(object sender, UnhandledExceptionEventArgs e)
Expand Down
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,19 @@
## To-do
- [ ] Improve game automatic detection for launch.dat
- [ ] Play time counter
- [ ] Make uninstall work
- [ ] Save file management and quick swapping
- [ ] Add auto-updating
- [ ] Possibly add game source providing
- [ ] Fix dir names feature
- [ ] Note unrecognized games
- [ ] Add splash screen
- [ ] Custom metadata override


- [ ] Fix dark mode

## Versions

### Beta 1.5.0

- [ ] Added auto-updating
- [ ] Added custom metadata override
- [ ] Fixed dark theme
- [ ] Added game name cleanup
- [ ] Added game name matching

### Beta 1.4.8

Expand Down
4 changes: 2 additions & 2 deletions UI/Controls/GamePanelControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ namespace GameLauncher
public partial class GamePanelControl : UserControl, ITick
{
public LocalGame Game;
private Form1 originForm;
private MainForm originForm;
private bool stillLoading = true;
public GamePanelControl(Form1 originForm, LocalGame game)
public GamePanelControl(MainForm originForm, LocalGame game)
{
this.originForm = originForm;
this.Game = game;
Expand Down
118 changes: 0 additions & 118 deletions UI/Forms/IGDBSearchResultsForm.Designer.cs

This file was deleted.

77 changes: 0 additions & 77 deletions UI/Forms/IGDBSearchResultsForm.cs

This file was deleted.

6 changes: 3 additions & 3 deletions UI/Forms/Form1.Designer.cs → UI/Forms/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 15 additions & 5 deletions UI/Forms/Form1.cs → UI/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

namespace GameLauncher
{
public partial class Form1 : Form
public partial class MainForm : Form
{
private static LocalGame[]? Games;

private static Thread? ProcessMonitorThread;
private static Thread? RichPresenceThread;

public Form1()
public MainForm()
{
this.InitializeComponent();
}
Expand Down Expand Up @@ -183,9 +183,19 @@ public void CheckForUpdates(Action callback)
Version newVer = GitHub.GetLatestVersion();
if (newVer > Management.Version)
{
DialogResult result = MessageBox.Show($"New version available: {newVer}", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (result == DialogResult.Yes)
GitHub.UpdateToVersion(newVer);
DialogResult result = MessageBox.Show($"New version is available: {newVer}\nWould you like to update?", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
try
{
if (result == DialogResult.Yes)
GitHub.UpdateToVersion(newVer);
}
catch (Exception ex)
{
string backupFile = Path.Combine(Path.GetDirectoryName(Management.ExecutablePath), "GameLauncher.exe.bak");
if (File.Exists(backupFile))
File.Move(backupFile, Management.ExecutablePath);
MessageBox.Show($"Failed to update: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
callback();
}
else
Expand Down
File renamed without changes.
Loading

0 comments on commit ef7411e

Please sign in to comment.