diff --git a/BeatSaviorData/BeatSaviorData.csproj b/BeatSaviorData/BeatSaviorData.csproj
index c733038..9201f13 100644
--- a/BeatSaviorData/BeatSaviorData.csproj
+++ b/BeatSaviorData/BeatSaviorData.csproj
@@ -33,11 +33,14 @@
4
+
+ ..\..\..\..\..\..\Games\steamapps\common\Beat Saber\Plugins\BSML.dll
+
- D:\Logiciels\Steam\steamapps\common\Beat Saber\Plugins\BS_Utils.dll
+ ..\..\..\..\..\..\Games\steamapps\common\Beat Saber\Plugins\BS_Utils.dll
- D:\Logiciels\Steam\steamapps\common\Beat Saber\IPA\Libs\Newtonsoft.Json.12.0.0.0.dll
+ ..\..\..\..\..\..\Games\steamapps\common\Beat Saber\Libs\Newtonsoft.Json.12.0.0.0.dll
..\..\..\..\..\..\Games\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Oculus.VR.dll
@@ -106,6 +109,7 @@
+
@@ -119,6 +123,7 @@
+
diff --git a/BeatSaviorData/HTTPManager.cs b/BeatSaviorData/HTTPManager.cs
index 17ea564..6d1d33d 100644
--- a/BeatSaviorData/HTTPManager.cs
+++ b/BeatSaviorData/HTTPManager.cs
@@ -1,10 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http;
-using System.Net.Http.Headers;
+using System.Net.Http;
using System.Text;
-using System.Threading.Tasks;
namespace BeatSaviorData
{
@@ -12,15 +7,17 @@ class HTTPManager
{
public static readonly HttpClient client = new HttpClient();
- public static bool uploadJson(string json)
+ public async static void uploadJson(string json)
{
//client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
StringContent content = new StringContent(json, Encoding.UTF8, "application/json");
+ HttpResponseMessage success = await client.PostAsync(PrivateKeys.BeatSaviorUploadUrl, content);
- if (client.PostAsync(PrivateKeys.BeatSaviorUploadUrl, content).Result.IsSuccessStatusCode)
- return true;
- return false;
+ if (success.IsSuccessStatusCode)
+ Logger.log.Info("BSD : Upload succeeded !");
+ else
+ Logger.log.Info("BSD : Upload failed.");
}
}
}
diff --git a/BeatSaviorData/Plugin.cs b/BeatSaviorData/Plugin.cs
index 40f3136..e1031a0 100644
--- a/BeatSaviorData/Plugin.cs
+++ b/BeatSaviorData/Plugin.cs
@@ -1,16 +1,8 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using IPA;
-using IPA.Config;
-using IPA.Utilities;
+using IPA;
using UnityEngine.SceneManagement;
-using UnityEngine;
using IPALogger = IPA.Logging.Logger;
-using BS_Utils.Gameplay;
using BS_Utils.Utilities;
-using Newtonsoft.Json;
+using BeatSaberMarkupLanguage.Settings;
namespace BeatSaviorData
{
@@ -25,6 +17,9 @@ public class Plugin : IBeatSaberPlugin
public void OnApplicationStart()
{
+ bool a = SettingsMenu.instance.DisableFails;
+ a = SettingsMenu.instance.DisablePass;
+
if (!init)
{
BSEvents.levelCleared += UploadData;
@@ -33,6 +28,8 @@ public void OnApplicationStart()
BSEvents.levelRestarted += OnLevelRestarted;*/
init = true;
}
+
+ BSMLSettings.instance.AddSettingsMenu("BeatSaviorData", "BeatSaviorData.UI.Views.SettingsView.bsml", SettingsMenu.instance);
}
private void UploadData(StandardLevelScenesTransitionSetupDataSO data, LevelCompletionResults results)
@@ -42,11 +39,13 @@ private void UploadData(StandardLevelScenesTransitionSetupDataSO data, LevelComp
if (!songData.IsAReplay() && !songData.IsPraticeMode()) {
string json = songData.FinalizeData(results);
ShowData(json);
- // upload
- if (HTTPManager.uploadJson(json))
- Logger.log.Info("BSD : Upload succeeded !");
+
+ if (results.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared && SettingsMenu.instance.DisablePass)
+ Logger.log.Info("Pass upload is disabled.");
+ else if (results.levelEndStateType == LevelCompletionResults.LevelEndStateType.Failed && SettingsMenu.instance.DisableFails)
+ Logger.log.Info("Fail upload is disabled.");
else
- Logger.log.Info("BSD : Upload failed.");
+ HTTPManager.uploadJson(json);
}
else if (songData.IsAReplay()) {
Logger.log.Info("BSD : That was a replay you cheater (╯°□°)╯︵ ┻━┻");
@@ -61,8 +60,9 @@ private void UploadData(StandardLevelScenesTransitionSetupDataSO data, LevelComp
public void OnActiveSceneChanged(Scene prevScene, Scene nextScene)
{
- if (nextScene.name == "GameCore")
- songData = new SongData();
+ if(!SettingsMenu.instance.DisableFails || !SettingsMenu.instance.DisablePass)
+ if (nextScene.name == "GameCore")
+ songData = new SongData();
}
#region InterfaceImplementation
diff --git a/BeatSaviorData/SettingsMenu.cs b/BeatSaviorData/SettingsMenu.cs
new file mode 100644
index 0000000..9e0a687
--- /dev/null
+++ b/BeatSaviorData/SettingsMenu.cs
@@ -0,0 +1,24 @@
+using BeatSaberMarkupLanguage.Attributes;
+using BS_Utils.Utilities;
+
+namespace BeatSaviorData
+{
+ class SettingsMenu : PersistentSingleton
+ {
+ private static readonly Config config = new Config("BeatSaviorData");
+
+ [UIValue("DisablePass")]
+ public bool DisablePass
+ {
+ get => config.GetBool("BeatSaviorData", "DisablePass", false, true);
+ set => config.SetBool("BeatSaviorData", "DisablePass", value);
+ }
+
+ [UIValue("DisableFail")]
+ public bool DisableFails
+ {
+ get => config.GetBool("BeatSaviorData", "DisableFails", false, true);
+ set => config.SetBool("BeatSaviorData", "DisableFails", value);
+ }
+ }
+}
diff --git a/BeatSaviorData/SongData.cs b/BeatSaviorData/SongData.cs
index b032d42..c549aab 100644
--- a/BeatSaviorData/SongData.cs
+++ b/BeatSaviorData/SongData.cs
@@ -1,9 +1,6 @@
using BS_Utils.Gameplay;
-using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using UnityEngine;
using BeatSaviorData.Trackers;
using Newtonsoft.Json;
diff --git a/BeatSaviorData/Trackers/AccuracyTracker.cs b/BeatSaviorData/Trackers/AccuracyTracker.cs
index f28e722..081d6c9 100644
--- a/BeatSaviorData/Trackers/AccuracyTracker.cs
+++ b/BeatSaviorData/Trackers/AccuracyTracker.cs
@@ -1,15 +1,11 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Collections.Generic;
namespace BeatSaviorData.Trackers
{
class AccuracyTracker : ITracker
{
public float accRight, accLeft, averageAcc;
- public float[] gridAcc = new float[12];
+ public float[] gridAcc = new float[12], leftAverageCut = new float[3], rightAverageCut = new float[3], averageCut = new float[3];
private int cutRight, cutLeft;
private int[] gridCut = new int[12];
@@ -21,10 +17,18 @@ public void EndOfSong(LevelCompletionResults results)
{
accRight = Utils.SafeDivide(accRight, cutRight);
accLeft = Utils.SafeDivide(accLeft, cutLeft);
+
for (int i = 0; i < 12; i++)
gridAcc[i] = Utils.SafeDivide(gridAcc[i], gridCut[i]);
- // This doesn't take into account the number of note hit by each hand, gotta change that
- averageAcc = (accRight + accLeft) / 2;
+
+ for (int i = 0; i < 3; i++) {
+ leftAverageCut[i] = Utils.SafeDivide(leftAverageCut[i], cutLeft);
+ rightAverageCut[i] = Utils.SafeDivide(rightAverageCut[i], cutRight);
+ averageCut[i] = (rightAverageCut[i] * cutRight + leftAverageCut[i] * cutLeft) / (cutRight + cutLeft);
+ averageCut[i] = Utils.SafeAverage(rightAverageCut[i], cutRight, leftAverageCut[i], cutLeft);
+ }
+
+ averageAcc = Utils.SafeAverage(accRight, cutRight, accLeft, cutLeft);
}
public void OnNoteCut(BeatmapObjectSpawnController bosc, INoteController data, NoteCutInfo info)
@@ -53,11 +57,17 @@ private void WaitForSwing(SaberSwingRatingCounter s)
{
cutLeft++;
accLeft += before + acc + after;
+ leftAverageCut[0] += before;
+ leftAverageCut[1] += acc;
+ leftAverageCut[2] += after;
}
else if (type == Saber.SaberType.SaberB)
{
cutRight++;
accRight += before + acc + after;
+ rightAverageCut[0] += before;
+ rightAverageCut[1] += acc;
+ rightAverageCut[2] += after;
}
gridCut[thisIsBullshit[s].Value]++;
diff --git a/BeatSaviorData/Trackers/HitTracker.cs b/BeatSaviorData/Trackers/HitTracker.cs
index 21c82fa..7a5359d 100644
--- a/BeatSaviorData/Trackers/HitTracker.cs
+++ b/BeatSaviorData/Trackers/HitTracker.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BeatSaviorData.Trackers
+namespace BeatSaviorData.Trackers
{
class HitTracker : ITracker
{
@@ -30,26 +24,27 @@ public void OnNoteCut(BeatmapObjectSpawnController bosc, INoteController data, N
case NoteType.NoteB:
rightNoteHit++;
break;
- case NoteType.Bomb:
- bombHit++;
- break;
}
} else
{
- miss++;
- if (combo > maxCombo)
- maxCombo = combo;
- combo = 0;
+ if (data.noteData.noteType == NoteType.Bomb)
+ bombHit++;
+ else
+ miss++;
}
}
+ private void BreakComboWall()
+ {
+ if (combo > maxCombo)
+ maxCombo = combo;
+ combo = 0;
+ }
+
public void OnNoteMissed(BeatmapObjectSpawnController bosc, INoteController data)
{
if (data.noteData.noteType != NoteType.Bomb)
{
- if (combo > maxCombo)
- maxCombo = combo;
- combo = 0;
miss++;
}
}
@@ -58,6 +53,7 @@ public void RegisterTracker(SongData data)
{
data.GetBOSC().noteWasCutEvent += OnNoteCut;
data.GetBOSC().noteWasMissedEvent += OnNoteMissed;
+ data.GetScoreController().comboBreakingEventHappenedEvent += BreakComboWall;
}
}
}
diff --git a/BeatSaviorData/Trackers/WinTracker.cs b/BeatSaviorData/Trackers/WinTracker.cs
index 3c37417..a60d24a 100644
--- a/BeatSaviorData/Trackers/WinTracker.cs
+++ b/BeatSaviorData/Trackers/WinTracker.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BeatSaviorData.Trackers
+namespace BeatSaviorData.Trackers
{
class WinTracker : ITracker
{
diff --git a/BeatSaviorData/UI/Views/SettingsView.bsml b/BeatSaviorData/UI/Views/SettingsView.bsml
new file mode 100644
index 0000000..580c1e6
--- /dev/null
+++ b/BeatSaviorData/UI/Views/SettingsView.bsml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BeatSaviorData/Utils.cs b/BeatSaviorData/Utils.cs
index 462db34..7ab3f47 100644
--- a/BeatSaviorData/Utils.cs
+++ b/BeatSaviorData/Utils.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BeatSaviorData
+namespace BeatSaviorData
{
class Utils
{
@@ -19,5 +13,15 @@ public static float SafeDivide(float a, float b)
return 0;
}
}
+
+ public static float SafeAverage(float a, float nbA, float b, float nbB)
+ {
+ if (!float.IsNaN(a) && !float.IsNaN(b))
+ return (a * nbA + b * nbB) / (nbA + nbB);
+ else if (float.IsNaN(b))
+ return a;
+ else
+ return b;
+ }
}
}
diff --git a/BeatSaviorData/manifest.json b/BeatSaviorData/manifest.json
index 09a5bb5..3bd8937 100644
--- a/BeatSaviorData/manifest.json
+++ b/BeatSaviorData/manifest.json
@@ -1,17 +1,21 @@
{
"$schema": "https://raw.githubusercontent.com/nike4613/ModSaber-MetadataFileSchema/master/Schema.json",
- "id": null,
+ "id": "BeatSaviorData",
"name": "BeatSaviorData",
"author": "Mystogan",
- "version": "0.0.1",
- "description": "Streams data such as map completion to Beat Savior",
+ "version": "1.0.0",
+ "description": "Uploads data on map completion, such as per saber accuracy, to Beat Savior",
"gameVersion": "1.7.0",
"dependsOn": {
"BS Utils": "^1.3.5",
+ "BeatSaberMarkupLanguage": "^1.1.5"
},
- "loadAfter": [ "BS Utils" ],
+ "loadAfter": [ "BS Utils", "BeatSaberMarkupLanguage" ],
"features": [],
"misc": {
"plugin-hint": "BeatSaviorData.Plugin"
- }
+ },
+ "links": {
+ "project-home": "https://github.com/Mystogan98/BeatSaviorData"
+ }
}
\ No newline at end of file