Skip to content

Commit

Permalink
Added the toggle button
Browse files Browse the repository at this point in the history
  • Loading branch information
Asgragrt committed Feb 23, 2024
1 parent 4bd4078 commit 5f33d8c
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 6 deletions.
11 changes: 9 additions & 2 deletions Managers/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,24 @@ internal class SettingsManager
// Main Category
//--------------------------------------------------------------------+
public static bool DisableAllEffects => MainCategory._disableAllEffects.Value;
public static bool Enabled
{
get => MainCategory._enabled.Value;
set => MainCategory._enabled.Value = value;
}

internal class MainCategory
{
public static MelonPreferences_Entry<bool> _disableAllEffects;
public static MelonPreferences_Entry<bool> _enabled;

public static void Init()
{
MelonPreferences_Category mainCategory = MelonPreferences.CreateCategory("Main");
mainCategory.SetFilePath(SettingsPath);

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

}
Expand Down Expand Up @@ -111,7 +118,7 @@ public static void Init()

_disableBossFx = miscCategory.CreateEntry<bool>("DisableBossFx", false);
_disableDustFx = miscCategory.CreateEntry<bool>("DisableDustFx", false);
_disableHurtFx = miscCategory.CreateEntry<bool>("DisableHurtFx", false, description: "Disable hp loss text-");
_disableHurtFx = miscCategory.CreateEntry<bool>("DisableHurtFx", false, description: "Disable hp loss text.");
}
}

Expand Down
Binary file added Media/MenuToggle.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion Patches/DisappearAnimationPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ internal static class DisappearAnimationPatch
[HarmonyPatch(nameof(BaseEnemyObjectController.OnControllerAttacked))]
public static void Postfix(BaseEnemyObjectController __instance)
{
if (!SettingsManager.Enabled) return;

if (SettingsManager.DisableAllEffects || SettingsManager.DisableHitEnemy)
{
Expand All @@ -21,7 +22,7 @@ public static void Postfix(BaseEnemyObjectController __instance)
if (SettingsManager.DisableHitEffects)
{
GameObject out_fx = __instance.transform.FindChild("out_fx")?.gameObject;
if (out_fx) out_fx.SetActive(false);
if (out_fx) UnityEngine.Object.Destroy(out_fx);
}

if (!SettingsManager.DisableHitDissapearAnimations) return;
Expand Down
2 changes: 2 additions & 0 deletions Patches/HitEffectPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ internal static class HitEffectPatch
{
public static void Postfix(AttackEffectManager __instance)
{
if (!SettingsManager.Enabled) return;

if (!SettingsManager.DisableHitEffects) return;
__instance.m_PlayResult.SetActive(false);
}
Expand Down
2 changes: 2 additions & 0 deletions Patches/JudgementPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal static class JudgementPatch
{
public static void Postfix()
{
if (!SettingsManager.Enabled) return;

if (!SettingsManager.DisableJudgement && !SettingsManager.MakeJudgementSmaller) return;
Transform effectsTransform = GameObject.Find("Effects").transform;

Expand Down
4 changes: 4 additions & 0 deletions Patches/MainEffectsPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ internal class MainEffectsPatch

public static bool Prefix(ref GameObject __result)
{
if (!SettingsManager.Enabled) return true;

__result = EmptyObject;
return !SettingsManager.DisableAllEffects;
}

public static void Postfix(Effect __instance, ref GameObject __result)
{
if (!SettingsManager.Enabled) return;

if (SettingsManager.DisableAllEffects || !EffectsDisablerManager.AnyEffect) return;

string fxName = __instance.uid;
Expand Down
57 changes: 57 additions & 0 deletions Patches/TogglePatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using HarmonyLib;
using Il2CppAssets.Scripts.PeroTools.Nice.Events;
using Il2CppAssets.Scripts.UI.Panels;
using SelectiveEffects.Managers;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

namespace SelectiveEffects.Patches
{
[HarmonyPatch(typeof(PnlMenu), nameof(PnlMenu.Awake))]
internal class TogglePatch
{
internal static GameObject EffectsToggle;
public static void Postfix(PnlMenu __instance)
{
if (EffectsToggle) return;

EffectsToggle = UnityEngine.Object.Instantiate(
GameObject.Find("Forward").transform.Find("PnlVolume").Find("LogoSetting").Find("Toggles").Find("TglOn").gameObject,
__instance.transform
);


Toggle toggleComp = EffectsToggle.GetComponent<Toggle>();
toggleComp.onValueChanged.AddListener((UnityAction<bool>)
((bool val) => { SettingsManager.Enabled = val; })
);
toggleComp.group = null;
toggleComp.SetIsOnWithoutNotify(SettingsManager.Enabled);

EffectsToggle.name = "EffectsToggleObject";

Text txt = EffectsToggle.transform.Find("Txt").GetComponent<Text>();
txt.text = "Disable Effects";
txt.fontSize = 40;
txt.color = new Color(1, 1, 1, 76 / 255f);
RectTransform rect = txt.transform.Cast<RectTransform>();
Vector2 vect = rect.offsetMax;
rect.offsetMax = new Vector2(txt.text.Length * 25, vect.y);


Image checkBox = EffectsToggle.transform.Find("Background").GetComponent<Image>();
checkBox.color = new(60 / 255f, 40 / 255f, 111 / 255f);

Image checkMark = EffectsToggle.transform.Find("Background").GetChild(0).GetComponent<Image>();
checkMark.color = new(103 / 255f, 93 / 255f, 130 / 255f);

EffectsToggle.transform.position = new Vector3(-6.8f, -4.95f, 100f);
EffectsToggle.GetComponent<OnToggle>().enabled = false;
EffectsToggle.GetComponent<OnToggleOn>().enabled = false;
EffectsToggle.GetComponent<OnActivate>().enabled = false;

EffectsToggle.transform.SetParent(__instance.transform.Find("Panels").Find("PnlOption").Find("TxtVersion"));
}
}
}
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
# SelectiveEffects
Mod that allows disabling battle effects.

## Features
* Individual config options for several effects.
* Enable/disable toggle at the menu.

## Settings
The config file can be found at `${Your muse dash folder}/UserData/SelectiveEffects.cfg`
### Main
* `Enabled` stores the last status of the toggle.
* `DisableAllEfects` uses a general method to disable all effects in battle.
### Judgement
* `DisableJudgement` disables the judgements (including early/late).
* `MakeJudgementSmaller` if the judgements are available, it makes them 25%~ smaller.
### Hit
* `DisableHitDissapearAnimation` disables the enemies animation when they have been hit and makes them disappear inmmeadiatly.
* `DisableHitEffects` disables the hit effects and particles.
* `DisableGirlHitFx` the same as `DisableHitEffects` but doesn't disappear the out_fx of some enemies.
* `DisablePressFx` disables some particles when pressing the holds.
### MusicHearts
* `DisableMusicNotesFx` disables the particles and text that appear when you touch a music note.
* `DisableHeartsFx` disables the particles and text that appear when you touch a heart.
### Misc
* `DisableBossFx` disables some effects the boss has when deploying enemies.
* `DisableDustFx` disables the dust effect when the character falls to the ground.
* `DisableHurtFx` disables the text that appear when the character is hurt.

It is prefered to use the `DisableAllEfects` option instead of the individual options.

Config file at `${Your muse dash folder}/UserData/SelectiveEffects.cfg`
## In-game screenshots
### Menu Toggle
![MenuToggle](Media/MenuToggle.jpg)
4 changes: 2 additions & 2 deletions SelectiveEffects.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
<Reference Include="Il2Cppspine-unity">
<HintPath>$(MD_NET6_DIRECTORY)\MelonLoader\Il2CppAssemblies\Il2Cppspine-unity.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ParticleSystemModule">
<HintPath>$(MD_NET6_DIRECTORY)\MelonLoader\Il2CppAssemblies\UnityEngine.ParticleSystemModule.dll</HintPath>
<Reference Include="UnityEngine.UI">
<HintPath>$(MD_NET6_DIRECTORY)\MelonLoader\Il2CppAssemblies\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>

Expand Down

0 comments on commit 5f33d8c

Please sign in to comment.