Skip to content

Commit

Permalink
Merge pull request #47 from KrystianLesniak/develop
Browse files Browse the repository at this point in the history
Release: 1.7.2
  • Loading branch information
KrystianLesniak committed Dec 13, 2023
2 parents abe2e4f + c643e6e commit f76b1ed
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
12 changes: 11 additions & 1 deletion src/GamesLauncher.Platforms/PlatformsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,17 @@ public async Task SynchronizeGames(MainSettings settings)
Engines = InitializeEngines(settings);
await Parallel.ForEachAsync(Engines, async (engine, ct) =>
{
await engine.SynchronizeGames();
try
{
await engine.SynchronizeGames();
}
catch(Exception ex)
{
//TODO: Think about shortening an overly long error message title
publicApi.ShowMsgError($"GamesLauncher: {engine.PlatformName} failed to synchronize", "Please submit your issue with logs at plugin GitHub page.");
publicApi.LogWarn(engine.GetType().Name, @"If you see this, something bad has happened. Please report your problem using the logs you see below at: https://github.com/KrystianLesniak/Flow.Launcher.Plugin.GamesLauncher/issues");
publicApi.LogException(engine.GetType().Name, ex.Message, ex);
}
});

#if DEBUG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ private Func<Task> GetGameRunTask(string fullPath)
{
return async () =>
{
publicApi.ShellRun($"start \"\" \"{fullPath}\"");
var directory = Path.GetDirectoryName(fullPath);
var fileShortcut = Path.GetFileName(fullPath);
publicApi.ShellRun($"cd /d \"{directory}\" && start \"\" \"{fileShortcut}\"");
await Task.CompletedTask;
};
}
Expand Down
20 changes: 15 additions & 5 deletions src/GamesLauncher/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ public Task<List<Result>> QueryAsync(Query query, CancellationToken token)
var games = _platformsManager.AllSynchronizedGames;

var search = query.Search.Trim();
var isGlobalKeyword = string.IsNullOrEmpty(query.ActionKeyword);

return Task.FromResult(
games
.Where(x => _hiddenGames.IsHidden(x.InternalGameId) == false)
.Select(x => EnrichGameWithQueryAndAction(x, search))
.Select(EnrichGameWithActions)
.Select(x => EnrichGameWithResultScore(x, search, isGlobalKeyword))
.Where(x => x is not null).Select(x => x!)
.ToList());
}

Expand Down Expand Up @@ -98,7 +101,7 @@ public Control CreateSettingPanel()
return new SettingsView(_settings, _hiddenGames, _publicApi);
}

private Result EnrichGameWithQueryAndAction(Game game, string search)
private Game EnrichGameWithActions(Game game)
{
game.AsyncAction ??= async (context) =>
{
Expand All @@ -107,8 +110,12 @@ private Result EnrichGameWithQueryAndAction(Game game, string search)
return true;
};

//Get score
if (string.IsNullOrWhiteSpace(search)) //When there is no search query display 10 last played games
return game;
}

private Result? EnrichGameWithResultScore(Game game, string search, bool isGlobalKeyword)
{
if (!isGlobalKeyword && string.IsNullOrWhiteSpace(search)) //When there is no global keyword set and no search query typed prioritze last played games.
{
game.Score = _lastPlayedGames.GetResultScoreByOrder(game.InternalGameId);
game.TitleHighlightData = Array.Empty<int>();
Expand All @@ -120,7 +127,10 @@ private Result EnrichGameWithQueryAndAction(Game game, string search)
game.TitleHighlightData = fuzzySearch.MatchData;
}

return game;
if (isGlobalKeyword)
return game.Score > 0 ? game : null;
else
return game;
}
}
}
2 changes: 1 addition & 1 deletion src/GamesLauncher/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Name": "GamesLauncher",
"Description": "Search and launch games from multiple platforms like Steam, Epic Games, Xbox etc.",
"Author": "KrystianLesniak",
"Version": "1.7.1",
"Version": "1.7.2",
"Language": "csharp",
"Website": "https://github.com/KrystianLesniak/Flow.Launcher.Plugin.GamesLauncher",
"IcoPath": "icon.png",
Expand Down

0 comments on commit f76b1ed

Please sign in to comment.