Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Added the ability to fine-tune notification position #27

Merged
merged 4 commits into from
Jun 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion Notification/NotificationSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public class NotificationSystem
public static Color DefaultColour = new Color(0.1764f, 0.2549f, .3333f, 1f);
public static MelonPreferences_Entry<float> NotificationAlpha;
public static MelonPreferences_Entry<string> NotificationAlignment;
public static MelonPreferences_Entry<bool> NotificationCoordinateAlignment;
public static MelonPreferences_Entry<float> NotificationX;
public static MelonPreferences_Entry<float> NotificationY;
public static bool UseVRChatNotificationSystem;

//AssetBundle Parts
Expand Down Expand Up @@ -48,8 +51,14 @@ public static void SetupNotifications()
MelonPreferences.CreateCategory("ReModCore", "ReMod.Core");
NotificationAlpha = MelonPreferences.CreateEntry("ReModCore", "NotificationAlpha", .7f, "Notification Alpha", "Controls transparency of the notification system.");
NotificationAlignment = MelonPreferences.CreateEntry("ReModCore", "NotificationAlignment", "centerMiddle", "Notification Alignment");
NotificationCoordinateAlignment = MelonPreferences.CreateEntry("ReModCore", "NotificationCoordinateAlignment", false, "Use Coordinate Alignment");
NotificationX = MelonPreferences.CreateEntry("ReModCore", "NotificationX", .5f, "Notification X", "Controls the X position of the notification system.");
NotificationY = MelonPreferences.CreateEntry("ReModCore", "NotificationY", .5f, "Notification Y", "Controls the Y position of the notification system.");

NotificationAlignment.OnValueChanged += UpdateNotificationAlignment;
NotificationCoordinateAlignment.OnValueChanged += (_, _) => UpdateNotificationAlignment(null, null);
NotificationX.OnValueChanged += (_, _) => UpdateNotificationAlignment(null, null);
NotificationY.OnValueChanged += (_, _) => UpdateNotificationAlignment(null, null);

//Create UIX settings enum
RegSettingsEnum("ReModCore", "NotificationAlignment", new[] {("centerMiddle", "Middle Centered"), ("topCenter", "Top Centered"), ("topLeft", "Top Left"), ("topRight", "Top Right"), ("bottomCenter", "Bottom Centered"), ("bottomLeft", "Bottom Left"), ("bottomRight", "Bottom Right")});
Expand Down Expand Up @@ -116,6 +125,14 @@ public static void CloseNotification()
private static void UpdateNotificationAlignment(string sender, string args)
{
if (_notificationRect == null) return;

if (NotificationCoordinateAlignment.Value)
{
_notificationRect.anchorMin = new Vector2(NotificationX.Value, NotificationY.Value);
_notificationRect.anchorMax = new Vector2(NotificationX.Value, NotificationY.Value);
_notificationRect.pivot = new Vector2(NotificationX.Value, NotificationY.Value);
return;
}

switch (NotificationAlignment.Value)
{
Expand Down Expand Up @@ -222,4 +239,4 @@ private static bool RegSettingsEnum(string settingsCat, string settingsName, ILi

#endregion
}
}
}