Skip to content

Commit 5f33d8c

Browse files
committed
Added the toggle button
1 parent 4bd4078 commit 5f33d8c

9 files changed

Lines changed: 106 additions & 6 deletions

Managers/SettingsManager.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,24 @@ internal class SettingsManager
1010
// Main Category
1111
//--------------------------------------------------------------------+
1212
public static bool DisableAllEffects => MainCategory._disableAllEffects.Value;
13+
public static bool Enabled
14+
{
15+
get => MainCategory._enabled.Value;
16+
set => MainCategory._enabled.Value = value;
17+
}
1318

1419
internal class MainCategory
1520
{
1621
public static MelonPreferences_Entry<bool> _disableAllEffects;
22+
public static MelonPreferences_Entry<bool> _enabled;
1723

1824
public static void Init()
1925
{
2026
MelonPreferences_Category mainCategory = MelonPreferences.CreateCategory("Main");
2127
mainCategory.SetFilePath(SettingsPath);
2228

23-
_disableAllEffects = mainCategory.CreateEntry<bool>("DisableAllEfects", true, description: "Takes precedence to the following options");
29+
_enabled = mainCategory.CreateEntry<bool>("Enabled", true, description: "Enable or disable the mod!");
30+
_disableAllEffects = mainCategory.CreateEntry<bool>("DisableAllEfects", true, description: "Takes precedence to the following options.");
2431
}
2532

2633
}
@@ -111,7 +118,7 @@ public static void Init()
111118

112119
_disableBossFx = miscCategory.CreateEntry<bool>("DisableBossFx", false);
113120
_disableDustFx = miscCategory.CreateEntry<bool>("DisableDustFx", false);
114-
_disableHurtFx = miscCategory.CreateEntry<bool>("DisableHurtFx", false, description: "Disable hp loss text-");
121+
_disableHurtFx = miscCategory.CreateEntry<bool>("DisableHurtFx", false, description: "Disable hp loss text.");
115122
}
116123
}
117124

Media/MenuToggle.jpg

125 KB
Loading

Patches/DisappearAnimationPatch.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ internal static class DisappearAnimationPatch
1111
[HarmonyPatch(nameof(BaseEnemyObjectController.OnControllerAttacked))]
1212
public static void Postfix(BaseEnemyObjectController __instance)
1313
{
14+
if (!SettingsManager.Enabled) return;
1415

1516
if (SettingsManager.DisableAllEffects || SettingsManager.DisableHitEnemy)
1617
{
@@ -21,7 +22,7 @@ public static void Postfix(BaseEnemyObjectController __instance)
2122
if (SettingsManager.DisableHitEffects)
2223
{
2324
GameObject out_fx = __instance.transform.FindChild("out_fx")?.gameObject;
24-
if (out_fx) out_fx.SetActive(false);
25+
if (out_fx) UnityEngine.Object.Destroy(out_fx);
2526
}
2627

2728
if (!SettingsManager.DisableHitDissapearAnimations) return;

Patches/HitEffectPatch.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ internal static class HitEffectPatch
99
{
1010
public static void Postfix(AttackEffectManager __instance)
1111
{
12+
if (!SettingsManager.Enabled) return;
13+
1214
if (!SettingsManager.DisableHitEffects) return;
1315
__instance.m_PlayResult.SetActive(false);
1416
}

Patches/JudgementPatch.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ internal static class JudgementPatch
1010
{
1111
public static void Postfix()
1212
{
13+
if (!SettingsManager.Enabled) return;
14+
1315
if (!SettingsManager.DisableJudgement && !SettingsManager.MakeJudgementSmaller) return;
1416
Transform effectsTransform = GameObject.Find("Effects").transform;
1517

Patches/MainEffectsPatch.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ internal class MainEffectsPatch
1212

1313
public static bool Prefix(ref GameObject __result)
1414
{
15+
if (!SettingsManager.Enabled) return true;
16+
1517
__result = EmptyObject;
1618
return !SettingsManager.DisableAllEffects;
1719
}
1820

1921
public static void Postfix(Effect __instance, ref GameObject __result)
2022
{
23+
if (!SettingsManager.Enabled) return;
24+
2125
if (SettingsManager.DisableAllEffects || !EffectsDisablerManager.AnyEffect) return;
2226

2327
string fxName = __instance.uid;

Patches/TogglePatch.cs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using HarmonyLib;
2+
using Il2CppAssets.Scripts.PeroTools.Nice.Events;
3+
using Il2CppAssets.Scripts.UI.Panels;
4+
using SelectiveEffects.Managers;
5+
using UnityEngine;
6+
using UnityEngine.Events;
7+
using UnityEngine.UI;
8+
9+
namespace SelectiveEffects.Patches
10+
{
11+
[HarmonyPatch(typeof(PnlMenu), nameof(PnlMenu.Awake))]
12+
internal class TogglePatch
13+
{
14+
internal static GameObject EffectsToggle;
15+
public static void Postfix(PnlMenu __instance)
16+
{
17+
if (EffectsToggle) return;
18+
19+
EffectsToggle = UnityEngine.Object.Instantiate(
20+
GameObject.Find("Forward").transform.Find("PnlVolume").Find("LogoSetting").Find("Toggles").Find("TglOn").gameObject,
21+
__instance.transform
22+
);
23+
24+
25+
Toggle toggleComp = EffectsToggle.GetComponent<Toggle>();
26+
toggleComp.onValueChanged.AddListener((UnityAction<bool>)
27+
((bool val) => { SettingsManager.Enabled = val; })
28+
);
29+
toggleComp.group = null;
30+
toggleComp.SetIsOnWithoutNotify(SettingsManager.Enabled);
31+
32+
EffectsToggle.name = "EffectsToggleObject";
33+
34+
Text txt = EffectsToggle.transform.Find("Txt").GetComponent<Text>();
35+
txt.text = "Disable Effects";
36+
txt.fontSize = 40;
37+
txt.color = new Color(1, 1, 1, 76 / 255f);
38+
RectTransform rect = txt.transform.Cast<RectTransform>();
39+
Vector2 vect = rect.offsetMax;
40+
rect.offsetMax = new Vector2(txt.text.Length * 25, vect.y);
41+
42+
43+
Image checkBox = EffectsToggle.transform.Find("Background").GetComponent<Image>();
44+
checkBox.color = new(60 / 255f, 40 / 255f, 111 / 255f);
45+
46+
Image checkMark = EffectsToggle.transform.Find("Background").GetChild(0).GetComponent<Image>();
47+
checkMark.color = new(103 / 255f, 93 / 255f, 130 / 255f);
48+
49+
EffectsToggle.transform.position = new Vector3(-6.8f, -4.95f, 100f);
50+
EffectsToggle.GetComponent<OnToggle>().enabled = false;
51+
EffectsToggle.GetComponent<OnToggleOn>().enabled = false;
52+
EffectsToggle.GetComponent<OnActivate>().enabled = false;
53+
54+
EffectsToggle.transform.SetParent(__instance.transform.Find("Panels").Find("PnlOption").Find("TxtVersion"));
55+
}
56+
}
57+
}

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
11
# SelectiveEffects
22
Mod that allows disabling battle effects.
33

4+
## Features
5+
* Individual config options for several effects.
6+
* Enable/disable toggle at the menu.
7+
8+
## Settings
9+
The config file can be found at `${Your muse dash folder}/UserData/SelectiveEffects.cfg`
10+
### Main
11+
* `Enabled` stores the last status of the toggle.
12+
* `DisableAllEfects` uses a general method to disable all effects in battle.
13+
### Judgement
14+
* `DisableJudgement` disables the judgements (including early/late).
15+
* `MakeJudgementSmaller` if the judgements are available, it makes them 25%~ smaller.
16+
### Hit
17+
* `DisableHitDissapearAnimation` disables the enemies animation when they have been hit and makes them disappear inmmeadiatly.
18+
* `DisableHitEffects` disables the hit effects and particles.
19+
* `DisableGirlHitFx` the same as `DisableHitEffects` but doesn't disappear the out_fx of some enemies.
20+
* `DisablePressFx` disables some particles when pressing the holds.
21+
### MusicHearts
22+
* `DisableMusicNotesFx` disables the particles and text that appear when you touch a music note.
23+
* `DisableHeartsFx` disables the particles and text that appear when you touch a heart.
24+
### Misc
25+
* `DisableBossFx` disables some effects the boss has when deploying enemies.
26+
* `DisableDustFx` disables the dust effect when the character falls to the ground.
27+
* `DisableHurtFx` disables the text that appear when the character is hurt.
28+
429
It is prefered to use the `DisableAllEfects` option instead of the individual options.
530

6-
Config file at `${Your muse dash folder}/UserData/SelectiveEffects.cfg`
31+
## In-game screenshots
32+
### Menu Toggle
33+
![MenuToggle](Media/MenuToggle.jpg)

SelectiveEffects.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
<Reference Include="Il2Cppspine-unity">
4141
<HintPath>$(MD_NET6_DIRECTORY)\MelonLoader\Il2CppAssemblies\Il2Cppspine-unity.dll</HintPath>
4242
</Reference>
43-
<Reference Include="UnityEngine.ParticleSystemModule">
44-
<HintPath>$(MD_NET6_DIRECTORY)\MelonLoader\Il2CppAssemblies\UnityEngine.ParticleSystemModule.dll</HintPath>
43+
<Reference Include="UnityEngine.UI">
44+
<HintPath>$(MD_NET6_DIRECTORY)\MelonLoader\Il2CppAssemblies\UnityEngine.UI.dll</HintPath>
4545
</Reference>
4646
</ItemGroup>
4747

0 commit comments

Comments
 (0)