Skip to content

Commit

Permalink
Merge pull request #5 from skedgyedgy/fnf
Browse files Browse the repository at this point in the history
fixed a bunch of annoying shit
  • Loading branch information
skedgyedgy authored Jan 2, 2022
2 parents df14447 + 392150c commit 1532885
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Artemis.Plugins.Module.FNF/Artemis.Plugins.Module.FNF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
<Reference Include="Artemis.Storage">
<HintPath>..\..\Artemis\src\Artemis.Storage\bin\x64\Debug\net5.0\Artemis.Storage.dll</HintPath>
</Reference>
<Reference Include="Artemis.UI">
<HintPath>..\..\Artemis\src\Artemis.UI\bin\net5.0-windows\Artemis.UI.dll</HintPath>
</Reference>
<Reference Include="Artemis.UI.Shared">
<HintPath>..\..\..\..\..\..\Program%20Files\Artemis\Artemis.UI.Shared.dll</HintPath>
<Private>false</Private>
Expand Down
22 changes: 16 additions & 6 deletions Artemis.Plugins.Module.FNF/FnfModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
using Artemis.Core.Modules;
using Artemis.Core.Services;
using Artemis.Plugins.Module.FNF.DataModels;
using Artemis.UI.Events;
using SkiaSharp;
using Stylet;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand All @@ -13,24 +15,28 @@ namespace Artemis.Plugins.Module.FNF {
public class FnfModule : Module<FnfDataModel> {
private readonly IWebServerService webServerService;
private readonly IProfileService profileService;
private readonly IEventAggregator eventAggregator;

private ProfileCategory fnfCategory;

public override List<IModuleActivationRequirement> ActivationRequirements => null; // might add this, probably won't just to be on the safe side when it comes to mods

public FnfModule (IWebServerService webServerService, IProfileService profileService, PluginSettings settings) {
public FnfModule (IWebServerService webServerService, IProfileService profileService, IEventAggregator eventAggregator, PluginSettings settings) {
this.webServerService = webServerService;
this.profileService = profileService;
this.eventAggregator = eventAggregator;
}

public override void Enable () {
if (profileService.ProfileCategories.Any (cat => cat.Name == "Friday Night Funkin'")) {
fnfCategory = profileService.ProfileCategories.First (cat => cat.Name == "Friday Night Funkin'");
// } else if (settings.GetSetting ("AllowAutomaticProfiles", true).Value) { TODO: add this eventually
// } else if (settings.GetSetting ("AllowAutomaticProfiles", true).Value) { TODO: add this eventually
} else {
fnfCategory = profileService.CreateProfileCategory ("Friday Night Funkin'");
fnfCategory.Load ();
fnfCategory.Order = -10;
}
}

public override void Enable () {
webServerService.AddStringEndPoint (this, "SetGameState", h => {
DataModel.GameState.GameState = h;
if (h == "dead") DataModel.GameState.OnBlueBalled.Trigger ();
Expand Down Expand Up @@ -136,8 +142,12 @@ public override void Enable () {
if (File.Exists (h)) {
ProfileConfigurationExportModel exportModel = JsonConvert.DeserializeObject<ProfileConfigurationExportModel> (File.ReadAllText (h), IProfileService.ExportSettings);
if (exportModel != null) {
if (profileService.ProfileConfigurations.Any (p => p.Entity.ProfileId == exportModel.ProfileEntity.Id))
profileService.RemoveProfileConfiguration (fnfCategory.ProfileConfigurations.First (p => p.Entity.ProfileId == exportModel.ProfileEntity.Id));
if (profileService.ProfileConfigurations.Any (p => p.Entity.ProfileId == exportModel.ProfileEntity.Id)) {
ProfileConfiguration oldConfig = fnfCategory.ProfileConfigurations.First (p => p.Entity.ProfileId == exportModel.ProfileEntity.Id);
if (oldConfig.IsBeingEdited) eventAggregator.Publish (new RequestSelectSidebarItemEvent ("Home"));

profileService.RemoveProfileConfiguration (oldConfig);
}
profileService.ImportProfile (fnfCategory, exportModel, false, true, "auto-added");
} else {
throw new System.Exception ();
Expand Down
2 changes: 1 addition & 1 deletion Artemis.Plugins.Module.FNF/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"Author": "skedgyedgy",
"Website": null,
"Repository": "https://github.com/skedgyedgy/Artemis.Plugins",
"Version": "1.1",
"Version": "1.1.1",
"Main": "Artemis.Plugins.Module.FNF.dll"
}

0 comments on commit 1532885

Please sign in to comment.