Skip to content

Commit

Permalink
v.1.1
Browse files Browse the repository at this point in the history
think i corrected the folder strcture
  • Loading branch information
Ghost-Miner committed Dec 19, 2024
1 parent 221c3b8 commit 54c7500
Show file tree
Hide file tree
Showing 24 changed files with 629 additions and 0 deletions.
158 changes: 158 additions & 0 deletions Flow.Launcher.Plugin.UnityLauncherPlugin/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Threading;

namespace Flow.Launcher.Plugin.UnityLauncherPlugin
{
public class UnityLauncherPlugin : IAsyncPlugin
{
private PluginInitContext _context;

public async Task InitAsync(PluginInitContext context)
{
_context = context;

await LoadHubAmdProjectData();
}

public async Task<List<Result>> QueryAsync (Query query, CancellationToken cancellationToken)
{
return await Task.Run(() =>
{
string userQuery = query.Search.ToString().Trim();

if (userQuery.ToLower() == "/dc")
{
Parts.editor.DeleteCacheFile();
}

Parts.projects.projectsMatchingQuery = Parts.projects.GetProjectsMatchingQuery(userQuery);

List<Result> results = CreateListOfResults(Parts.projects.projectsMatchingQuery);

return results;
}, cancellationToken );
}

public async Task LoadHubAmdProjectData ()
{
// Get Unity Hub's location
Parts.hub.unityHubInstallPath = Parts.hub.GetUnityHubLocation();

bool versionCacheExists = Parts.editor.VersionCacheFileExists();

// Get location of all installed editor versions
switch (versionCacheExists)
{
case false:
Parts.hub.FindInstalledEditors();
Parts.editor.SaveUnityVersopns();
break;

case true:
Parts.editor.LoadUnityVersions();
break;
}

// Find all projects listed in Unity Hub
Parts.projects.FindUnityProjects();
}

private List<Result> CreateListOfResults (List<ProjectInfoModel> projects)
{
List<Result> results = new();
string projectDetails = "";

foreach (ProjectInfoModel project in projects)
{
string editorVersion = project.editorVersion;
bool editorVersionIsInstalled = Parts.editor.DoesEditorVersionExist(project.editorVersion);

string isProjectStarred = project.isFavourite;
string resultIconPath = @"Images\logo.png";
string detailSplitter = " | ";

// Project is starred
if (isProjectStarred.ToLower() == "true")
{
resultIconPath = @"Images\fav.png";
}

// Editor version is installed
if (editorVersionIsInstalled)
{
projectDetails = project.path + detailSplitter + "Modified: " + project.lastModified + detailSplitter + "Version: " + editorVersion;
}
// Editor version is missing
else
{
resultIconPath = @"Images\warning.png";
projectDetails = "Missing version " + editorVersion + "!" + detailSplitter + project.path +
detailSplitter + "Modified: " + project.lastModified;
}

// Editor version is NOT installed
if (!editorVersionIsInstalled)
{

results.Add(new Result
{
Title = project.title,
SubTitle = projectDetails,
IcoPath = resultIconPath,
Action = _ =>
{
_context.API.ShowMsgError("Version was not found!",
"Please install Unity " + editorVersion + " to open this project " +
"or use Uity Hub to open the project in a different version");
return true;
}
});
}
// Editor version is installed
else
{
results.Add(new Result
{
Title = project.title,
SubTitle = projectDetails,
IcoPath = resultIconPath,
Action = _ =>
{
string editorPath = Parts.editor.GetMatchingEditorVersionForProject(project.editorVersion);
Parts.editor.OpenProjectIneditor(editorPath, project.path);

return true;
}
});
}
}

// Replace list of results with "No results" message
if (projects.Count < 1)
{
results = NoResultsMessage();
}

return results;
}

private static List<Result> NoResultsMessage ()
{
List<Result> results = new()
{
new Result
{
Title = "No results",
SubTitle = "",
IcoPath = @"Images\logo.png",
Action = _ =>
{
return true;
}
}
};
return results;
}
} // main class end
} // namespace end
Binary file not shown.
Binary file not shown.
12 changes: 12 additions & 0 deletions Flow.Launcher.Plugin.UnityLauncherPlugin/bin/x64/Debug/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"ID": "8de584c0-f855-4825-8886-65e670ebe441",
"ActionKeyword": "u",
"Name": "UnityLauncherPlugin",
"Description": "adds an option to launch Unity projects from Flow Launcher",
"Author": "Ghost-Miner",
"Version": "1.1.0",
"Language": "csharp",
"Website": "https://github.com/Ghost-Miner/Unity-project-launcher-plugin",
"IcoPath": "Images\\logo.png",
"ExecuteFileName": "Flow.Launcher.Plugin.UnityLauncherPlugin.dll"
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"ID": "8de584c0-f855-4825-8886-65e670ebe441",
"ActionKeyword": "u",
"Name": "UnityLauncherPlugin",
"Description": "adds an option to launch Unity projects from Flow Launcher",
"Author": "Ghost-Miner",
"Version": "1.1.0",
"Language": "csharp",
"Website": "https://github.com/Ghost-Miner/Unity-project-launcher-plugin",
"IcoPath": "Images\\logo.png",
"ExecuteFileName": "Flow.Launcher.Plugin.UnityLauncherPlugin.dll"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("Ghost-Miner")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Flow.Launcher.Plugin.UnityLauncherPlugin")]
[assembly: System.Reflection.AssemblyTitleAttribute("Flow.Launcher.Plugin.UnityLauncherPlugin")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyMetadataAttribute("RepositoryUrl", "https://github.com/Ghost-Miner/Flow.Launcher.Plugin.UnityLauncherPlugin")]
[assembly: System.Runtime.Versioning.TargetPlatformAttribute("Windows7.0")]
[assembly: System.Runtime.Versioning.SupportedOSPlatformAttribute("Windows7.0")]

// Vygenerované třídou WriteCodeFragment nástroje MSBuild

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e92dfd832dcc9ac966b62ab52dafc193fc15ceb62d3e0f8af67fd8a269d7d5e3
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
is_global = true
build_property.TargetFramework = net7.0-windows
build_property.TargetPlatformMinVersion = 7.0
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Flow.Launcher.Plugin.UnityLauncherPlugin
build_property.ProjectDir = D:\Uzivatel\Admin\Dokumenty\Flow launcher plugins\UnityLauncherPlugin\UnityLauncherPlugin\Flow.Launcher.Plugin.UnityLauncherPlugin\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.CsWinRTUseWindowsUIXamlProjections = false
build_property.EffectiveAnalysisLevelStyle = 7.0
build_property.EnableCodeStyleSeverity =
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"format": 1,
"restore": {
"D:\\Uzivatel\\Admin\\Dokumenty\\Flow launcher plugins\\UnityLauncherPlugin\\UnityLauncherPlugin\\Flow.Launcher.Plugin.UnityLauncherPlugin\\Flow.Launcher.Plugin.UnityLauncherPlugin.csproj": {}
},
"projects": {
"D:\\Uzivatel\\Admin\\Dokumenty\\Flow launcher plugins\\UnityLauncherPlugin\\UnityLauncherPlugin\\Flow.Launcher.Plugin.UnityLauncherPlugin\\Flow.Launcher.Plugin.UnityLauncherPlugin.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "D:\\Uzivatel\\Admin\\Dokumenty\\Flow launcher plugins\\UnityLauncherPlugin\\UnityLauncherPlugin\\Flow.Launcher.Plugin.UnityLauncherPlugin\\Flow.Launcher.Plugin.UnityLauncherPlugin.csproj",
"projectName": "Flow.Launcher.Plugin.UnityLauncherPlugin",
"projectPath": "D:\\Uzivatel\\Admin\\Dokumenty\\Flow launcher plugins\\UnityLauncherPlugin\\UnityLauncherPlugin\\Flow.Launcher.Plugin.UnityLauncherPlugin\\Flow.Launcher.Plugin.UnityLauncherPlugin.csproj",
"packagesPath": "C:\\Users\\Admin\\.nuget\\packages\\",
"outputPath": "D:\\Uzivatel\\Admin\\Dokumenty\\Flow launcher plugins\\UnityLauncherPlugin\\UnityLauncherPlugin\\Flow.Launcher.Plugin.UnityLauncherPlugin\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\Admin\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net7.0-windows"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net7.0-windows7.0": {
"targetAlias": "net7.0-windows",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.100"
},
"frameworks": {
"net7.0-windows7.0": {
"targetAlias": "net7.0-windows",
"dependencies": {
"Flow.Launcher.Plugin": {
"target": "Package",
"version": "[4.4.0, )"
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[7.0.20, 7.0.20]"
},
{
"name": "Microsoft.NETCore.App.Ref",
"version": "[7.0.20, 7.0.20]"
},
{
"name": "Microsoft.WindowsDesktop.App.Ref",
"version": "[7.0.20, 7.0.20]"
}
],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.101\\RuntimeIdentifierGraph.json"
}
}
}
}
}
Loading

0 comments on commit 54c7500

Please sign in to comment.