forked from Macro-Deck-App/Macro-Deck
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added code for the new extension store
- Loading branch information
1 parent
c37e756
commit 7525dfa
Showing
55 changed files
with
2,191 additions
and
557 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using SuchByte.MacroDeck.ExtensionStore; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace SuchByte.MacroDeck.Extension | ||
{ | ||
public interface IMacroDeckExtension | ||
{ | ||
public ExtensionType ExtensionType { get; } | ||
public string ExtensionTypeDisplayName { get; } | ||
public object ExtensionObject { get; } | ||
public bool Configurable { get; } | ||
public void Uninstall(); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using SuchByte.MacroDeck.ExtensionStore; | ||
using SuchByte.MacroDeck.Icons; | ||
using SuchByte.MacroDeck.Language; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace SuchByte.MacroDeck.Extension | ||
{ | ||
public class IconPackExtension : IMacroDeckExtension | ||
{ | ||
public ExtensionType ExtensionType => ExtensionType.IconPack; | ||
public string ExtensionTypeDisplayName => LanguageManager.Strings.IconPack; | ||
public object ExtensionObject { get; set; } | ||
public bool Configurable => false; | ||
|
||
public IconPackExtension(IconPack iconPack) | ||
{ | ||
this.ExtensionObject = iconPack; | ||
} | ||
|
||
public void Uninstall() | ||
{ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using SuchByte.MacroDeck.ExtensionStore; | ||
using SuchByte.MacroDeck.Language; | ||
using SuchByte.MacroDeck.Plugins; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace SuchByte.MacroDeck.Extension | ||
{ | ||
public class PluginExtension : IMacroDeckExtension | ||
{ | ||
public ExtensionType ExtensionType => ExtensionType.Plugin; | ||
public string ExtensionTypeDisplayName => LanguageManager.Strings.Plugin; | ||
public object ExtensionObject { get; set; } | ||
|
||
public bool Configurable => this.ExtensionObject != null && (this.ExtensionObject as MacroDeckPlugin).CanConfigure; | ||
|
||
public PluginExtension(MacroDeckPlugin macroDeckPlugin) | ||
{ | ||
this.ExtensionObject = macroDeckPlugin; | ||
} | ||
|
||
public void Uninstall() | ||
{ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
using SuchByte.MacroDeck.GUI.Dialogs; | ||
using SuchByte.MacroDeck.Icons; | ||
using SuchByte.MacroDeck.Model; | ||
using SuchByte.MacroDeck.Plugins; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SuchByte.MacroDeck.ExtensionStore | ||
{ | ||
public class ExtensionStoreHelper | ||
{ | ||
public static event EventHandler OnUpdateCheckFinished; | ||
|
||
private static ExtensionStoreDownloader extensionStoreDownloader; | ||
|
||
public static void InstallPluginById(string packageId) | ||
{ | ||
InstallPackages(new List<ExtensionStoreDownloaderPackageInfoModel> { new ExtensionStoreDownloaderPackageInfoModel() { PackageId = packageId, ExtensionType = ExtensionType.Plugin } }); | ||
} | ||
|
||
public static void InstallIconPackById(string packageId) | ||
{ | ||
InstallPackages(new List<ExtensionStoreDownloaderPackageInfoModel> { new ExtensionStoreDownloaderPackageInfoModel() { PackageId = packageId, ExtensionType = ExtensionType.IconPack } }); | ||
} | ||
|
||
public static void InstallPackages(List<ExtensionStoreDownloaderPackageInfoModel> packages) | ||
{ | ||
extensionStoreDownloader = new ExtensionStoreDownloader(packages) | ||
{ | ||
Owner = MacroDeck.MainWindow, | ||
}; | ||
extensionStoreDownloader.Show(); | ||
} | ||
|
||
public static string GetPackageId(IconPack iconPack) | ||
{ | ||
return $"{iconPack.Author.Replace(" ", "")}.{iconPack.Name.Replace(" ", "")}"; | ||
} | ||
|
||
public static string GetPackageId(MacroDeckPlugin macroDeckPlugin) | ||
{ | ||
return new DirectoryInfo(PluginManager.PluginDirectories[macroDeckPlugin]).Name; | ||
} | ||
|
||
public static void SearchUpdatesAsync() | ||
{ | ||
PluginManager.PluginsUpdateAvailable.Clear(); | ||
IconManager.IconPacksUpdateAvailable.Clear(); | ||
Task.Run(() => | ||
{ | ||
foreach (MacroDeckPlugin plugin in PluginManager.Plugins.Values) | ||
{ | ||
PluginManager.SearchUpdate(plugin); | ||
} | ||
foreach (MacroDeckPlugin plugin in PluginManager.PluginsNotLoaded.Values) | ||
{ | ||
PluginManager.SearchUpdate(plugin); | ||
} | ||
foreach (IconPack iconPack in IconManager.IconPacks.FindAll(iP => iP.PackageManagerManaged && !iP.Hidden)) | ||
{ | ||
IconManager.SearchUpdate(iconPack); | ||
} | ||
|
||
if (OnUpdateCheckFinished != null) | ||
{ | ||
OnUpdateCheckFinished(null, EventArgs.Empty); | ||
} | ||
}); | ||
} | ||
|
||
public static string InstalledIconPacksAsString | ||
{ | ||
get | ||
{ | ||
string installedPlugins = ""; | ||
foreach (var iconPack in IconManager.IconPacks.FindAll(x => x.PackageManagerManaged)) | ||
{ | ||
installedPlugins += $"{GetPackageId(iconPack).ToLower()}%20"; | ||
} | ||
|
||
return installedPlugins; | ||
} | ||
} | ||
|
||
public static string InstalledPluginsAsString | ||
{ | ||
get | ||
{ | ||
string installedPlugins = ""; | ||
foreach (var path in PluginManager.PluginDirectories.Values) | ||
{ | ||
installedPlugins += $"{new DirectoryInfo(path).Name.ToLower()}%20"; | ||
} | ||
|
||
return installedPlugins; | ||
} | ||
} | ||
} | ||
|
||
public enum ExtensionType | ||
{ | ||
Plugin, | ||
IconPack, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.