diff --git a/scenes/game.tscn b/scenes/game.tscn index 97ec2a45..04f37758 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -305,12 +305,15 @@ Runner = NodePath("../Runner") ReplayViewer = NodePath("../ReplayViewer") CursorManager = NodePath("../CursorManager") -[node name="Runner" type="Node3D" parent="." unique_id=580620214 node_paths=PackedStringArray("HudManager", "Camera", "Renderers", "Grid", "Cursor")] +[node name="Runner" type="Node3D" parent="." unique_id=580620214 node_paths=PackedStringArray("HudManager", "Camera", "Renderers", "Grid", "GridGuides", "PanelLeft", "PanelRight", "Cursor")] script = ExtResource("2_qnb83") HudManager = NodePath("HUD") Camera = NodePath("Camera3D") Renderers = [NodePath("Renderers/Notes")] Grid = NodePath("HUD/Grid") +GridGuides = NodePath("HUD/Grid/GridGuides") +PanelLeft = NodePath("HUD/PanelLeft") +PanelRight = NodePath("HUD/PanelRight") Cursor = NodePath("HUD/Grid/Cursor") [node name="HUD" type="Node3D" parent="Runner" unique_id=1234434255 node_paths=PackedStringArray("Runner")] diff --git a/scripts/Rhythia.cs b/scripts/Rhythia.cs index 15e26357..05230596 100644 --- a/scripts/Rhythia.cs +++ b/scripts/Rhythia.cs @@ -203,6 +203,7 @@ public static void RegisterModifiers() new EarthquakeModifier(), new HorizontalFlipModifier(), new VerticalFlipModifier(), + new HardrockModifier(), ]; } diff --git a/scripts/database/settings/SettingsProfile.cs b/scripts/database/settings/SettingsProfile.cs index 0f364d8c..7710eb98 100644 --- a/scripts/database/settings/SettingsProfile.cs +++ b/scripts/database/settings/SettingsProfile.cs @@ -287,6 +287,12 @@ public partial class SettingsProfile [Order] public SettingsItem MissPopups { get; private set; } + /// + /// Expand hud elements when hardrock mod is enabled + /// + [Order] + public SettingsItem ExpandHudOnHr { get; private set; } + #endregion #region Video @@ -1067,6 +1073,14 @@ public SettingsProfile() Section = SettingsSection.HUD, }; + ExpandHudOnHr = new(true) + { + Id = "ExpandHudOnHr", + Title = "Expand HUD On HR", + Description = "Expand HUD elements when hardrock modifier is enabled", + Section = SettingsSection.HUD, + }; + #endregion #region Video diff --git a/scripts/game/Runner.cs b/scripts/game/Runner.cs index 1fde3d1e..69f1ed96 100644 --- a/scripts/game/Runner.cs +++ b/scripts/game/Runner.cs @@ -37,6 +37,10 @@ public partial class Runner : Node3D private bool autoplayEnabled = false; private double? hitResultProgressOverride = null; private double[] noteTimestamps; + private double panelOffset = 0; + private Vector2 gridOriginalSize; + private QuadMesh gridMesh; + private QuadMesh gridGuidesMesh; [ExportCategory("Settings")] [Export] @@ -52,6 +56,15 @@ public partial class Runner : Node3D [Export] public MeshInstance3D Grid; + [Export] + public MeshInstance3D GridGuides; + + [Export] + public MeshInstance3D PanelLeft; + + [Export] + public MeshInstance3D PanelRight; + [Export] public MeshInstance3D Cursor; @@ -65,8 +78,14 @@ public override void _Ready() Camera ??= GetNode("Camera3D"); Renderers ??= GetNode>("Renderers"); Grid ??= HudManager.GetNode("Grid"); + GridGuides ??= Grid.GetNode("GridGuides"); + PanelLeft ??= HudManager.GetNode("PanelLeft"); + PanelRight ??= HudManager.GetNode("PanelRight"); Cursor ??= GetNode("Cursor"); // VideoStreamPlayer ??= GetNode("Video/VideoViewport/VideoStreamPlayer"); + + gridMesh = (QuadMesh)Grid.Mesh; + gridGuidesMesh = (QuadMesh)GridGuides.Mesh; } public override void _Process(double delta) @@ -294,11 +313,27 @@ public void Play() EmitSignal(SignalName.AttemptStatsUpdated, Attempt); } + settings = Attempt.IsReplay ? Attempt.Replays[0].Settings : SettingsManager.Instance.Settings; + + QuadMesh leftPanelMesh = (QuadMesh)PanelLeft.Mesh; + gridOriginalSize = gridMesh.Size; + + var windowSize = DisplayServer.WindowGetSize(); + + double panelSectionHeight = 2 * (PanelLeft.Position.Z - Camera.Position.Z) * Math.Tan((double)settings.FoV * Math.PI / 180 / 2); + double panelSectionWidth = windowSize.X / windowSize.Y * panelSectionHeight; + + double gridSectionHeight = 2 * (Grid.Position.Z - Camera.Position.Z) * Math.Tan((double)settings.FoV * Math.PI / 180 / 2); + double gridSectionWidth = windowSize.X / windowSize.Y * gridSectionHeight; + + double panelOffsetPerc = + (PanelLeft.Position.X + leftPanelMesh.Size.X / 2) / panelSectionWidth - (Grid.Position.X - gridMesh.Size.X / 2) / gridSectionWidth; + foreach (var mod in Attempt.Modifiers) { mod.Active = false; - if (mod is IMapModifier || mod is IObjectRenderModifier) + if (mod is IMapModifier || mod is IObjectRenderModifier || mod is IHudObjectModifier) { mod.Activate(Attempt); HudManager.DisplayModifier(mod); @@ -307,9 +342,23 @@ public void Play() { mapMod.ModifyMap(Attempt.Map, Attempt); } + + if (mod is IHudObjectModifier meshMod) + { + meshMod.ModifyGrid(Grid); + meshMod.ModifyGridGuides(GridGuides); + } } } + double offsetPerc = + (PanelLeft.Position.X + leftPanelMesh.Size.X / 2) / panelSectionWidth - (Grid.Position.X - gridMesh.Size.X / 2) / gridSectionWidth; + panelOffset = (panelOffsetPerc - offsetPerc) * panelSectionWidth; + + // this assumes right panel has the same gap as the left just in the opposite direction + PanelLeft.Translate(new Vector3((float)panelOffset, 0, 0)); + PanelRight.Translate(new Vector3(-(float)panelOffset, 0, 0)); + autoplayEnabled = Attempt.Modifiers.Any(mod => mod is AutoplayModifier) && !Attempt.IsReplay; if (autoplayEnabled) @@ -330,7 +379,6 @@ public void Play() { autoplayHandler = null; } - settings = Attempt.IsReplay ? Attempt.Replays[0].Settings : SettingsManager.Instance.Settings; Camera.Fov = (float)(double)settings.FoV; // temp until skinning support @@ -467,6 +515,8 @@ public void Stop(bool results = true) StopQueued = false; Attempt.Stopped = true; + resetHudItems(); + if (eventsConnected) { eventsConnected = false; @@ -619,6 +669,8 @@ private void onHitResultChanged(int noteIndex, HitResult hitResult) Attempt.Alive = false; Attempt.Qualifies = false; + resetHudItems(); + Results.Replay(); } else @@ -706,4 +758,15 @@ private void syncSongPosition() // VideoStreamPlayer.StreamPosition = (float)Attempt.Progress / 1000; } } + + /// + /// Resets grid size and panels positions + /// + private void resetHudItems() + { + PanelLeft.Translate(new Vector3(-(float)panelOffset, 0, 0)); + PanelRight.Translate(new Vector3((float)panelOffset, 0, 0)); + gridMesh.Size = gridOriginalSize; + gridGuidesMesh.Size = gridOriginalSize; + } } diff --git a/scripts/game/camera/CameraLock.cs b/scripts/game/camera/CameraLock.cs index 6dcbf5d6..0431ece6 100644 --- a/scripts/game/camera/CameraLock.cs +++ b/scripts/game/camera/CameraLock.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Godot; public class CameraLock : CameraMode @@ -19,17 +20,19 @@ float sensitivity { var settings = attempt.Settings; var delta = new Vector2(1, -1) * (mouseDelta * sensitivity / 120f); + float hardrockMult = attempt.Modifiers.Any(mod => mod is HardrockModifier) ? 1.35f : 1f; + Vector2 bounds = new Vector2(Constants.BOUNDS.X * hardrockMult, Constants.BOUNDS.Y * hardrockMult); if (settings.CursorDrift) { attempt.CursorPosition = attempt.IsReplay - ? replayManager.CursorPosition.Clamp(-Constants.BOUNDS, Constants.BOUNDS) - : (attempt.CursorPosition + delta).Clamp(-Constants.BOUNDS, Constants.BOUNDS); + ? replayManager.CursorPosition.Clamp(-bounds, bounds) + : (attempt.CursorPosition + delta).Clamp(-bounds, bounds); } else { attempt.RawCursorPosition = attempt.IsReplay ? replayManager.CursorPosition : attempt.RawCursorPosition + delta; - attempt.CursorPosition = attempt.RawCursorPosition.Clamp(-Constants.BOUNDS, Constants.BOUNDS); + attempt.CursorPosition = attempt.RawCursorPosition.Clamp(-bounds, bounds); attempt.BufferCursorPosition = attempt.IsReplay ? replayManager.CursorPosition : attempt.BufferCursorPosition + delta; } diff --git a/scripts/game/modifiers/HardrockModifier.cs b/scripts/game/modifiers/HardrockModifier.cs new file mode 100644 index 00000000..61188dde --- /dev/null +++ b/scripts/game/modifiers/HardrockModifier.cs @@ -0,0 +1,40 @@ +using Godot; + +public class HardrockModifier : Modifier, IHudObjectModifier, IMapModifier +{ + public override string Name => "Hardrock"; + + public override Color Color => new(0x8000ffff); + + public override bool Rankable => true; + + public override double ScoreMultiplier => 1.08; + + public void ModifyGrid(MeshInstance3D grid) + { + if (SettingsManager.Instance.Settings.ExpandHudOnHr) + { + QuadMesh mesh = (QuadMesh)grid.Mesh; + mesh.Size = new Vector2(mesh.Size.X * 1.35f, mesh.Size.Y * 1.35f); + } + } + + public void ModifyGridGuides(MeshInstance3D gridGuides) + { + if (SettingsManager.Instance.Settings.ExpandHudOnHr) + { + QuadMesh mesh = (QuadMesh)gridGuides.Mesh; + mesh.Size = new Vector2(mesh.Size.X * 1.35f, mesh.Size.Y * 1.35f); + } + } + + public void ModifyMap(Map map, Attempt attempt) + { + foreach (Note note in map.Notes) + { + note.HitWindow = 31; + note.X *= 1.35f; + note.Y *= 1.35f; + } + } +} diff --git a/scripts/game/modifiers/HardrockModifier.cs.uid b/scripts/game/modifiers/HardrockModifier.cs.uid new file mode 100644 index 00000000..c93ea034 --- /dev/null +++ b/scripts/game/modifiers/HardrockModifier.cs.uid @@ -0,0 +1 @@ +uid://cqphlig8g13kk diff --git a/scripts/game/modifiers/IHudObjectModifier.cs b/scripts/game/modifiers/IHudObjectModifier.cs new file mode 100644 index 00000000..825b4531 --- /dev/null +++ b/scripts/game/modifiers/IHudObjectModifier.cs @@ -0,0 +1,14 @@ +using Godot; + +public interface IHudObjectModifier : IModifier +{ + void ModifyGrid(MeshInstance3D grid) + { + return; + } + + void ModifyGridGuides(MeshInstance3D gridGuides) + { + return; + } +} diff --git a/scripts/game/modifiers/IHudObjectModifier.cs.uid b/scripts/game/modifiers/IHudObjectModifier.cs.uid new file mode 100644 index 00000000..e60e01e4 --- /dev/null +++ b/scripts/game/modifiers/IHudObjectModifier.cs.uid @@ -0,0 +1 @@ +uid://cmlnyd212mn6v diff --git a/scripts/game/ui/MeshUIComponent3D.cs b/scripts/game/ui/MeshUIComponent3D.cs new file mode 100644 index 00000000..2b65f992 --- /dev/null +++ b/scripts/game/ui/MeshUIComponent3D.cs @@ -0,0 +1,21 @@ +using System; +using Godot; + +public abstract partial class MeshUIComponent3D : MeshInstance3D, IUIComponent +{ + public Runner Runner { get; set; } + + public virtual void Init() { } + + public virtual void OnExitTree() { } + + public override void _ExitTree() + { + OnExitTree(); + // QueueFree(); + } + + public virtual void Process(double delta, Attempt attempt) { } + + public virtual void ApplySettings(SettingsProfile settings) { } +} diff --git a/scripts/game/ui/MeshUIComponent3D.cs.uid b/scripts/game/ui/MeshUIComponent3D.cs.uid new file mode 100644 index 00000000..8eef1c90 --- /dev/null +++ b/scripts/game/ui/MeshUIComponent3D.cs.uid @@ -0,0 +1 @@ +uid://dgd8qi40pq3n4 diff --git a/scripts/game/ui/PanelLeft.cs b/scripts/game/ui/PanelLeft.cs index e7c229a9..35d2a196 100644 --- a/scripts/game/ui/PanelLeft.cs +++ b/scripts/game/ui/PanelLeft.cs @@ -1,7 +1,7 @@ using System; using Godot; -public partial class PanelLeft : UIComponent +public partial class PanelLeft : MeshUIComponent3D { private SubViewport viewport; private ShaderMaterial multiplierProgressMaterial; diff --git a/scripts/game/ui/PanelRight.cs b/scripts/game/ui/PanelRight.cs index 25f9e637..28d07692 100644 --- a/scripts/game/ui/PanelRight.cs +++ b/scripts/game/ui/PanelRight.cs @@ -1,7 +1,7 @@ using System; using Godot; -public partial class PanelRight : UIComponent +public partial class PanelRight : MeshUIComponent3D { private SubViewport viewport; private Label accuracy, diff --git a/scripts/map/Replay.cs b/scripts/map/Replay.cs index e0504d8c..ce9765ac 100644 --- a/scripts/map/Replay.cs +++ b/scripts/map/Replay.cs @@ -127,6 +127,7 @@ public Replay(string path) foreach (string modName in rawMods) { // i hate this + // this should be centralized switch (modName) { case "NoFail": @@ -153,6 +154,9 @@ public Replay(string path) case "HFlip": Modifiers.Add(new HorizontalFlipModifier()); break; + case "Hardrock": + Modifiers.Add(new HardrockModifier()); + break; case "Spin": CameraMode = new CameraSpin(); break; diff --git a/scripts/skinning/SkinManager.cs b/scripts/skinning/SkinManager.cs index 487cc636..51f4c007 100644 --- a/scripts/skinning/SkinManager.cs +++ b/scripts/skinning/SkinManager.cs @@ -128,6 +128,7 @@ public static void Load() skin.ModEarthquakeImage = loadTexture("modifiers/earthquake.png"); skin.ModHFlipImage = loadTexture("modifiers/hflip.png"); skin.ModVFlipImage = loadTexture("modifiers/vflip.png"); + skin.ModHardrockImage = loadTexture("modifiers/hardrock.png"); // Shaders diff --git a/scripts/skinning/SkinProfile.cs b/scripts/skinning/SkinProfile.cs index 751f9cfb..8a7f92e2 100644 --- a/scripts/skinning/SkinProfile.cs +++ b/scripts/skinning/SkinProfile.cs @@ -129,6 +129,8 @@ public partial class SkinProfile : RefCounted public ImageTexture ModVFlipImage { get; set; } = new(); + public ImageTexture ModHardrockImage { get; set; } = new(); + public ImageTexture BackgroundTileImage { get; set; } = new(); public Shader BackgroundTileShader { get; set; } = new(); diff --git a/scripts/util/Misc.cs b/scripts/util/Misc.cs index 530596cf..9b41b4fe 100644 --- a/scripts/util/Misc.cs +++ b/scripts/util/Misc.cs @@ -45,6 +45,9 @@ public static Texture2D GetModIcon(string mod) case "VFlip": tex = skin.ModVFlipImage; break; + case "Hardrock": + tex = skin.ModHardrockImage; + break; default: tex = new PlaceholderTexture2D() { Size = Vector2.One * 32 }; break; diff --git a/user/skins/default/modifiers/hardrock.png b/user/skins/default/modifiers/hardrock.png new file mode 100644 index 00000000..adea0412 Binary files /dev/null and b/user/skins/default/modifiers/hardrock.png differ diff --git a/user/skins/default/modifiers/hardrock.png.import b/user/skins/default/modifiers/hardrock.png.import new file mode 100644 index 00000000..061d0bf7 --- /dev/null +++ b/user/skins/default/modifiers/hardrock.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://df84taw8ufx60" +path="res://.godot/imported/hardrock.png-7b8c5a9bdf533f38e7d5adbc54317f1e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://user/skins/default/modifiers/hardrock.png" +dest_files=["res://.godot/imported/hardrock.png-7b8c5a9bdf533f38e7d5adbc54317f1e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1