Skip to content

Commit

Permalink
woag lots of updates
Browse files Browse the repository at this point in the history
  • Loading branch information
skedgyedgy committed Dec 31, 2021
1 parent 4554f92 commit c15b318
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 173 deletions.
25 changes: 25 additions & 0 deletions Artemis.Plugins.Module.FNF/DataModels/FNFColors.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Artemis.Core;
using Artemis.Core.Modules;
using SkiaSharp;

namespace Artemis.Plugins.Module.FNF.DataModels {
public class FNFColors {
public SKColor DadHealthColor { get; set; } = new SKColor (0xB7, 0xD8, 0x55, 0xFF);
public SKColor BfHealthColor { get; set; } = new SKColor (0x31, 0xB0, 0xD1, 0xFF);

[DataModelProperty(Name = "Background color", Description = "The background color on main menus, also used for unconfigured songs.")]
public SKColor BackgroundColor { get; set; } = SKColor.Empty;
public SKColor AccentColor1 { get; set; } = SKColor.Empty;
public SKColor AccentColor2 { get; set; } = SKColor.Empty;
public SKColor AccentColor3 { get; set; } = SKColor.Empty;
public SKColor AccentColor4 { get; set; } = SKColor.Empty;
[DataModelProperty(Name = "Blammed lights", Description = "The color fade during Blammed and all other stages that use it.")]
public SKColor BlammedLights { get; set; } = SKColor.Empty;
public SKColor FlashColor { get; set; } = SKColor.Empty;
public SKColor FadeColor { get; set; } = new SKColor (0x00, 0x00, 0x00, 0xFF);
public bool Fade { get; set; } = false;

public DataModelEvent OnBlammedLights { get; } = new DataModelEvent();
public DataModelEvent OnFlash { get; } = new DataModelEvent();
}
}
26 changes: 26 additions & 0 deletions Artemis.Plugins.Module.FNF/DataModels/FNFGameState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Artemis.Core;
using Artemis.Core.Modules;
using SkiaSharp;

namespace Artemis.Plugins.Module.FNF.DataModels {
public class FNFGameState {
[DataModelProperty (Name = "Game state", Description = "The current state of the game: title, menu, in-game freeplay, in-game story, cutscene, dead, closed")]
public string GameState { get; set; } = "closed";
[DataModelProperty (Name = "In-game", Description = "Whether a game is currently active")]
public bool InGame => GameState == "in-game story" || GameState == "in-game freeplay" || GameState == "dead";

[DataModelProperty (Name = "Mod name", Description = "The name of the current mod")]
public string ModName { get; set; } = "vanilla";

public DataModelEvent OnSongStarted { get; } = new DataModelEvent ();
// public DataModelEvent<SongStartedEventArguments> OnSongStarted { get; } = new DataModelEvent<SongStartedEventArguments> ();
public DataModelEvent OnBlueBalled { get; } = new DataModelEvent ();
}

// yes there will be things here eventually
/* public class SongStartedEventArguments : DataModelEventArgs {
public SongStartedEventArguments () {
}
} */
}
71 changes: 3 additions & 68 deletions Artemis.Plugins.Module.FNF/DataModels/FnfDataModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,75 +5,10 @@
namespace Artemis.Plugins.Module.FNF.DataModels {
public class FnfDataModel : DataModel {
public FnfDataModel () {
//PluginSubDataModel = new FnfSubDataModel ();
}

[DataModelProperty (Name = "Game state", Description = "The current state of the game: title, menu, in-game freeplay, in-game story, cutscene, dead")]
public string GameState { get; set; } = "title";
[DataModelProperty (Name = "In-game", Description = "Whether a game is currently active.")]
public bool InGame => GameState == "in-game story" || GameState == "in-game freeplay";

[DataModelProperty (Name = "Mod name", Description = "The name of the current mod")]
public string ModName { get; set; } = "vanilla";
[DataModelProperty (Name = "Stage name", Description = "The name of the current song's stage")]
public string StageName { get; set; } = "stage";

public FnfSongData SongData { get; set; }
[DataModelProperty (Name = "Beat number", Description = "The current beat of the song.")]
public int BeatNumber { get; set; }
[DataModelProperty (Name = "Measure number", Description = "The current measure of the song.")]
public int MeasureNumber { get; set; }

[DataModelProperty (Name = "Player health", Description = "How much health boyfriend has.")]
public float BoyfriendHealth { get; set; }
[DataModelProperty (Name = "Current combo", Description = "How big your current combo is.")]
public int CurrentCombo { get; set; }
[DataModelProperty (Name = "Rating", Description = "Your rating percentage")]
public float RatingPercentage { get; set; }
[DataModelProperty (Name = "Full combo", Description = "Whether you are currently in a full combo")]
public bool FullCombo { get; set; }

[DataModelProperty (Name = "Background color", Description = "The background color on main menus, also used for unconfigured songs.")]
public SKColor BackgroundColor { get; set; } = SKColor.Empty;
[DataModelProperty (Name = "Accent color 1 ")]
public SKColor AccentColor1 { get; set; } = SKColor.Empty;
[DataModelProperty (Name = "Accent color 2")]
public SKColor AccentColor2 { get; set; } = SKColor.Empty;
[DataModelProperty (Name = "Blammed lights", Description = "The color fade during Blammed and all other stages that use it.")]
public SKColor BlammedLights { get; set; } = SKColor.Empty;
[DataModelProperty (Name = "Flash color")]
public SKColor FlashColor { get; set; } = SKColor.Empty;
[DataModelProperty (Name = "Fade to black")]
public bool FadeToBlack { get; set; } = false;

[DataModelProperty (Name = "On beat")]
public DataModelEvent OnBeat { get; } = new DataModelEvent ();
[DataModelProperty (Name = "On measure")]
public DataModelEvent OnMeasure { get; } = new DataModelEvent ();
[DataModelProperty (Name = "On blammed light")]
public DataModelEvent OnBlammedLights { get; } = new DataModelEvent ();
[DataModelProperty (Name = "On flash")]
public DataModelEvent OnFlash { get; } = new DataModelEvent ();

/*
// You can even have classes in your datamodel, just don't forget to instantiate them ;)
[DataModelProperty (Name = "A class within the datamodel")]
public FnfSubDataModel PluginSubDataModel { get; set; }*/
public FNFGameState GameState { get; set; } = new FNFGameState ();
public FNFSongData SongData { get; set; } = new FNFSongData ();
public FNFColors Colors { get; set; } = new FNFColors ();
}

/*public class FnfSubDataModel {
public FnfSubDataModel () {
ListOfInts = new List<int> { 1, 2, 3, 4, 5 };
}
// You don't need to annotate properties, they will still show up
public float FloatyFloat { get; set; }
// You can even have a list!
public List<int> ListOfInts { get; set; }
// If you don't want a property to show up in the datamodel, annotate it with DataModelIgnore
[DataModelIgnore]
public string MyDarkestSecret { get; set; }
}*/
}
99 changes: 37 additions & 62 deletions Artemis.Plugins.Module.FNF/DataModels/FnfSongData.cs
Original file line number Diff line number Diff line change
@@ -1,69 +1,44 @@
using Artemis.Core.Modules;
using Artemis.Core;
using Artemis.Core.Modules;
using SkiaSharp;

namespace Artemis.Plugins.Module.FNF.DataModels {
public class FnfSongData {
public SKColor DadHealthColor { get; set; } = new SKColor (0xB7, 0xD8, 0x55, 0xFF);
[DataModelIgnore]
public string DadHealthHex {
get => DadHealthColor.ToString ();
set {
SKColor val = DadHealthColor;
SKColor.TryParse (value, out val);
DadHealthColor = val;
}
}
public class FNFSongData {
[DataModelProperty (Name = "Stage name", Description = "The name of the current song's stage")]
public string StageName { get; set; } = "stage";
[DataModelProperty (Name = "Is pixel stage", Description = "Whether the stage is a pixel stage or not")]
public bool IsPixelStage { get; set; } = false;

public SKColor BfHealthColor { get; set; } = new SKColor (0x31, 0xB0, 0xD1, 0xFF);
[DataModelIgnore]
public string BfHealthHex {
get => BfHealthColor.ToString ();
set {
SKColor val = BfHealthColor;
SKColor.TryParse (value, out val);
BfHealthColor = val;
}
}
[DataModelProperty (Name = "Beat number", Description = "The current beat of the song.")]
public int BeatNumber { get; set; }
[DataModelProperty (Name = "Measure number", Description = "The current measure of the song (assuming it is 4/4 time).")]
public int MeasureNumber => BeatNumber / 4;

public SKColor LeftNoteColor { get; set; } = new SKColor (0xC2, 0x4B, 0x99, 0xFF);
[DataModelIgnore]
public string LeftNoteHex {
get => LeftNoteColor.ToString ();
set {
SKColor val = LeftNoteColor;
SKColor.TryParse (value, out val);
LeftNoteColor = val;
}
}
public SKColor DownNoteColor { get; set; } = new SKColor (0x00, 0xFF, 0xFF, 0xFF);
[DataModelIgnore]
public string NoteHex {
get => DownNoteColor.ToString ();
set {
SKColor val = DownNoteColor;
SKColor.TryParse (value, out val);
DownNoteColor = val;
}
}
public SKColor UpNoteColor { get; set; } = new SKColor (0x12, 0xFA, 0x05, 0xFF);
[DataModelIgnore]
public string UpNoteHex {
get => UpNoteColor.ToString ();
set {
SKColor val = UpNoteColor;
SKColor.TryParse (value, out val);
UpNoteColor = val;
}
}
public SKColor RightNoteColor { get; set; } = new SKColor (0xF9, 0x39, 0x3F, 0xFF);
[DataModelIgnore]
public string RightNoteHex {
get => RightNoteColor.ToString ();
set {
SKColor val = RightNoteColor;
SKColor.TryParse (value, out val);
RightNoteColor = val;
}
[DataModelProperty (Name = "Player health", Description = "How much health boyfriend has")]
public float BoyfriendHealth { get; set; }
[DataModelProperty (Name = "Current combo", Description = "How big your current combo is")]
public int CurrentCombo { get; set; }
[DataModelProperty (Name = "Rating", Description = "Your rating percentage")]
public float RatingPercentage { get; set; }
[DataModelProperty (Name = "Full combo", Description = "Whether you are currently in a full combo")]
public bool FullCombo { get; set; }


[DataModelProperty (Name = "On beat")]
public DataModelEvent OnBeat { get; } = new DataModelEvent ();
[DataModelProperty (Name = "On measure")]
public DataModelEvent OnMeasure { get; } = new DataModelEvent ();
[DataModelProperty (Name = "On combo broken")]
public DataModelEvent<ComboBreakEventArgs> OnComboBroken { get; } = new DataModelEvent<ComboBreakEventArgs> ();
}

public class ComboBreakEventArgs : DataModelEventArgs {
public int BrokenComboValue { get; set; }
public bool WasFullCombo { get; set; }

public ComboBreakEventArgs (int brokenComboValue, bool wasFullCombo) {
BrokenComboValue = brokenComboValue;
WasFullCombo = wasFullCombo;
}
}
}
}
120 changes: 78 additions & 42 deletions Artemis.Plugins.Module.FNF/FnfModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,77 +17,113 @@ public FnfModule (IWebServerService webServerService) {
}

public override void Enable () {
webServerService.AddStringEndPoint (this, "SetGameState", h => DataModel.GameState = h);
webServerService.AddStringEndPoint (this, "SetStageName", h => DataModel.StageName = h);
webServerService.AddStringEndPoint (this, "SetModName", h => DataModel.ModName = h);
webServerService.AddStringEndPoint (this, "SetGameState", h => {
DataModel.GameState.GameState = h;
if (h == "dead") DataModel.GameState.OnBlueBalled.Trigger ();
});
webServerService.AddStringEndPoint (this, "SetModName", h => DataModel.GameState.ModName = h);

JsonPluginEndPoint<FnfSongData> songDataEndpoint = webServerService.AddJsonEndPoint<FnfSongData> (this, "SetSongData", d => DataModel.SongData = d);
songDataEndpoint.RequestException += JsonPluginEndPointOnRequestException;
webServerService.AddStringEndPoint (this, "SetBeat", h => {
int val = DataModel.BeatNumber;
int.TryParse (h, out val);
DataModel.BeatNumber = val;
DataModel.OnBeat.Trigger ();
webServerService.AddStringEndPoint (this, "SetStageName", h => DataModel.SongData.StageName = h);
webServerService.AddStringEndPoint (this, "SetIsPixelStage", h => {
bool val = DataModel.SongData.IsPixelStage;
bool.TryParse (h, out val);
DataModel.SongData.IsPixelStage = val;
});
webServerService.AddStringEndPoint (this, "SetMeasure", h => {
int val = DataModel.MeasureNumber;

webServerService.AddStringEndPoint (this, "SetBeat", h => {
int val = DataModel.SongData.BeatNumber;
int.TryParse (h, out val);
DataModel.MeasureNumber = val;
DataModel.OnMeasure.Trigger ();
});

if (val > DataModel.SongData.BeatNumber) {
DataModel.SongData.OnBeat.Trigger ();
if (val % 4 == 0) DataModel.SongData.OnMeasure.Trigger ();
}

DataModel.SongData.BeatNumber = val;
});
webServerService.AddStringEndPoint (this, "SetHealth", h => {
float val = DataModel.BoyfriendHealth;
float val = DataModel.SongData.BoyfriendHealth;
float.TryParse (h, out val);
DataModel.SongData.BoyfriendHealth = val;
});
webServerService.AddStringEndPoint (this, "SetRating", h => {
float val = DataModel.SongData.RatingPercentage;
float.TryParse (h, out val);
DataModel.BoyfriendHealth = val;
DataModel.SongData.RatingPercentage = val;
});
webServerService.AddStringEndPoint (this, "SetCombo", h => {
int val = DataModel.CurrentCombo;
int val = DataModel.SongData.CurrentCombo;
int.TryParse (h, out val);
DataModel.CurrentCombo = val;
DataModel.SongData.CurrentCombo = val;
});
webServerService.AddStringEndPoint (this, "SetRating", h => {
float val = DataModel.RatingPercentage;
float.TryParse (h, out val);
DataModel.RatingPercentage = val;
webServerService.AddStringEndPoint (this, "StartSong", h => {
DataModel.SongData.FullCombo = true;
DataModel.SongData.CurrentCombo = 0;
DataModel.GameState.OnSongStarted.Trigger ();
// DataModel.GameState.OnSongStarted.Trigger (new SongStartedEventArguments ());
});
webServerService.AddStringEndPoint (this, "SetFullCombo", h => {
bool val = DataModel.FullCombo;
bool.TryParse (h, out val);
DataModel.FullCombo = val;
webServerService.AddStringEndPoint (this, "BreakCombo", h => {
DataModel.SongData.OnComboBroken.Trigger (new ComboBreakEventArgs (DataModel.SongData.CurrentCombo, DataModel.SongData.FullCombo));
DataModel.SongData.FullCombo = false;
DataModel.SongData.CurrentCombo = 0;
});

webServerService.AddStringEndPoint (this, "SetDadHex", h => {
SKColor val = DataModel.Colors.DadHealthColor;
SKColor.TryParse (h, out val);
DataModel.Colors.DadHealthColor = val;
});
webServerService.AddStringEndPoint (this, "SetBFHex", h => {
SKColor val = DataModel.Colors.BfHealthColor;
SKColor.TryParse (h, out val);
DataModel.Colors.BfHealthColor = val;
});
webServerService.AddStringEndPoint (this, "SetBackgroundHex", h => {
SKColor val = DataModel.BackgroundColor;
SKColor val = DataModel.Colors.BackgroundColor;
SKColor.TryParse (h, out val);
DataModel.BackgroundColor = val;
DataModel.Colors.BackgroundColor = val;
});
webServerService.AddStringEndPoint (this, "SetAccent1Hex", h => {
SKColor val = DataModel.AccentColor1;
SKColor val = DataModel.Colors.AccentColor1;
SKColor.TryParse (h, out val);
DataModel.AccentColor1 = val;
DataModel.Colors.AccentColor1 = val;
});
webServerService.AddStringEndPoint (this, "SetAccent2Hex", h => {
SKColor val = DataModel.AccentColor2;
SKColor val = DataModel.Colors.AccentColor2;
SKColor.TryParse (h, out val);
DataModel.AccentColor2 = val;
DataModel.Colors.AccentColor2 = val;
});
webServerService.AddStringEndPoint (this, "SetAccent3Hex", h => {
SKColor val = DataModel.Colors.AccentColor3;
SKColor.TryParse (h, out val);
DataModel.Colors.AccentColor3 = val;
});
webServerService.AddStringEndPoint (this, "SetAccent4Hex", h => {
SKColor val = DataModel.Colors.AccentColor4;
SKColor.TryParse (h, out val);
DataModel.Colors.AccentColor4 = val;
});
webServerService.AddStringEndPoint (this, "SetBlammedHex", h => {
SKColor val = DataModel.BlammedLights;
SKColor val = DataModel.Colors.BlammedLights;
SKColor.TryParse (h, out val);
DataModel.BlammedLights = val;
DataModel.OnBlammedLights.Trigger ();
DataModel.Colors.BlammedLights = val;
DataModel.Colors.OnBlammedLights.Trigger ();
});
webServerService.AddStringEndPoint (this, "FlashColorHex", h => {
SKColor val = DataModel.FlashColor;
SKColor val = DataModel.Colors.FlashColor;
SKColor.TryParse (h, out val);
DataModel.Colors.FlashColor = val;
DataModel.Colors.OnFlash.Trigger ();
});
webServerService.AddStringEndPoint (this, "SetFadeHex", h => {
SKColor val = DataModel.Colors.FadeColor;
SKColor.TryParse (h, out val);
DataModel.FlashColor = val;
DataModel.OnFlash.Trigger ();
DataModel.Colors.FadeColor = val;
});
webServerService.AddStringEndPoint (this, "FadeToBlack", h => {
bool val = DataModel.FadeToBlack;
webServerService.AddStringEndPoint (this, "ToggleFade", h => {
bool val = DataModel.Colors.Fade;
bool.TryParse (h, out val);
DataModel.FadeToBlack = val;
DataModel.Colors.Fade = val;
});
}

Expand Down
Loading

0 comments on commit c15b318

Please sign in to comment.