-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using settings manager and fixing some issues
- Loading branch information
Showing
5 changed files
with
129 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
using MelonLoader; | ||
using FadeIn.Managers; | ||
using MelonLoader; | ||
|
||
namespace FadeIn | ||
{ | ||
public class Main : MelonMod | ||
{ | ||
|
||
public override void OnInitializeMelon() | ||
{ | ||
base.OnInitializeMelon(); | ||
SettingsManager.Load(); | ||
LoggerInstance.Msg("FadeIn has loaded correctly!"); | ||
} | ||
|
||
public override void OnSceneWasLoaded(int buildIndex, string sceneName) | ||
{ | ||
base.OnSceneWasLoaded(buildIndex, sceneName); | ||
if (sceneName.Equals("GameMain")) return; | ||
ModManager.ClearCoroutines(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using MelonLoader; | ||
|
||
namespace FadeIn.Managers | ||
{ | ||
public enum Difficulties | ||
{ | ||
Easy, | ||
Medium, | ||
Hard, | ||
} | ||
|
||
internal class SettingsManager | ||
{ | ||
private static MelonPreferences_Entry<bool> _isEnabled; | ||
|
||
internal static bool IsEnabled | ||
{ | ||
get { return _isEnabled.Value; } | ||
set { _isEnabled.Value = value; } | ||
} | ||
|
||
private static MelonPreferences_Entry<string> _difficulty; | ||
internal static Difficulties Difficulty | ||
{ | ||
get | ||
{ | ||
return _difficulty.Value switch | ||
{ | ||
"Easy" => Difficulties.Easy, | ||
"Hard" => Difficulties.Hard, | ||
_ => Difficulties.Medium, | ||
}; | ||
} | ||
} | ||
public static float DissapearPositionX { get; set; } | ||
public static float DissapearPositionR { get; set; } | ||
public static float MinimalDistanceX { get; set; } | ||
public static float MinimalDistanceR { get; set; } | ||
|
||
internal static void InitValues() | ||
{ | ||
switch (Difficulty) | ||
{ | ||
case Difficulties.Easy: | ||
DissapearPositionX = -1.8f; | ||
DissapearPositionR = 8f; | ||
break; | ||
|
||
case Difficulties.Medium: | ||
DissapearPositionX = -0.9f; | ||
DissapearPositionR = 20f; | ||
break; | ||
|
||
case Difficulties.Hard: | ||
DissapearPositionX = 0f; | ||
DissapearPositionR = 35f; | ||
break; | ||
} | ||
MinimalDistanceX = 5.8f; | ||
MinimalDistanceR = 70f; | ||
|
||
} | ||
|
||
public static void Load() | ||
{ | ||
MelonPreferences_Category settings = MelonPreferences.CreateCategory("FadeIn"); | ||
_isEnabled = settings.CreateEntry<bool>(nameof(IsEnabled), false); | ||
_difficulty = settings.CreateEntry<string>(nameof(Difficulty), "Medium", description: "Options:\nEasy\nMedium\nHard"); | ||
|
||
InitValues(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters