Skip to content
Closed
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion scenes/game.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
1 change: 1 addition & 0 deletions scripts/Rhythia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public static void RegisterModifiers()
new EarthquakeModifier(),
new HorizontalFlipModifier(),
new VerticalFlipModifier(),
new HardrockModifier(),
];
}

Expand Down
14 changes: 14 additions & 0 deletions scripts/database/settings/SettingsProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@ public partial class SettingsProfile
[Order]
public SettingsItem<bool> MissPopups { get; private set; }

/// <summary>
/// Expand hud elements when hardrock mod is enabled
/// </summary>
[Order]
public SettingsItem<bool> ExpandHudOnHr { get; private set; }

#endregion

#region Video
Expand Down Expand Up @@ -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
Expand Down
67 changes: 65 additions & 2 deletions scripts/game/Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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;

Expand All @@ -65,8 +78,14 @@ public override void _Ready()
Camera ??= GetNode<Camera3D>("Camera3D");
Renderers ??= GetNode<Godot.Collections.Array<Renderer>>("Renderers");
Grid ??= HudManager.GetNode<MeshInstance3D>("Grid");
GridGuides ??= Grid.GetNode<MeshInstance3D>("GridGuides");
PanelLeft ??= HudManager.GetNode<MeshInstance3D>("PanelLeft");
PanelRight ??= HudManager.GetNode<MeshInstance3D>("PanelRight");
Cursor ??= GetNode<MeshInstance3D>("Cursor");
// VideoStreamPlayer ??= GetNode<VideoStreamPlayer>("Video/VideoViewport/VideoStreamPlayer");

gridMesh = (QuadMesh)Grid.Mesh;
gridGuidesMesh = (QuadMesh)GridGuides.Mesh;
}

public override void _Process(double delta)
Expand Down Expand Up @@ -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<Note>)
if (mod is IMapModifier || mod is IObjectRenderModifier<Note> || mod is IHudObjectModifier)
{
mod.Activate(Attempt);
HudManager.DisplayModifier(mod);
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -467,6 +515,8 @@ public void Stop(bool results = true)
StopQueued = false;
Attempt.Stopped = true;

resetHudItems();

if (eventsConnected)
{
eventsConnected = false;
Expand Down Expand Up @@ -619,6 +669,8 @@ private void onHitResultChanged(int noteIndex, HitResult hitResult)
Attempt.Alive = false;
Attempt.Qualifies = false;

resetHudItems();

Results.Replay();
}
else
Expand Down Expand Up @@ -706,4 +758,15 @@ private void syncSongPosition()
// VideoStreamPlayer.StreamPosition = (float)Attempt.Progress / 1000;
}
}

/// <summary>
/// Resets grid size and panels positions
/// </summary>
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;
}
}
9 changes: 6 additions & 3 deletions scripts/game/camera/CameraLock.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using Godot;

public class CameraLock : CameraMode
Expand All @@ -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;
}

Expand Down
40 changes: 40 additions & 0 deletions scripts/game/modifiers/HardrockModifier.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
1 change: 1 addition & 0 deletions scripts/game/modifiers/HardrockModifier.cs.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://cqphlig8g13kk
14 changes: 14 additions & 0 deletions scripts/game/modifiers/IHudObjectModifier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Godot;

public interface IHudObjectModifier : IModifier
{
void ModifyGrid(MeshInstance3D grid)
{
return;
}

void ModifyGridGuides(MeshInstance3D gridGuides)
{
return;
}
}
1 change: 1 addition & 0 deletions scripts/game/modifiers/IHudObjectModifier.cs.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://cmlnyd212mn6v
21 changes: 21 additions & 0 deletions scripts/game/ui/MeshUIComponent3D.cs
Original file line number Diff line number Diff line change
@@ -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) { }
}
1 change: 1 addition & 0 deletions scripts/game/ui/MeshUIComponent3D.cs.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://dgd8qi40pq3n4
2 changes: 1 addition & 1 deletion scripts/game/ui/PanelLeft.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Godot;

public partial class PanelLeft : UIComponent
public partial class PanelLeft : MeshUIComponent3D
{
private SubViewport viewport;
private ShaderMaterial multiplierProgressMaterial;
Expand Down
2 changes: 1 addition & 1 deletion scripts/game/ui/PanelRight.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Godot;

public partial class PanelRight : UIComponent
public partial class PanelRight : MeshUIComponent3D
{
private SubViewport viewport;
private Label accuracy,
Expand Down
4 changes: 4 additions & 0 deletions scripts/map/Replay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public Replay(string path)
foreach (string modName in rawMods)
{
// i hate this
// this should be centralized
switch (modName)
{
case "NoFail":
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions scripts/skinning/SkinManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions scripts/skinning/SkinProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions scripts/util/Misc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Binary file added user/skins/default/modifiers/hardrock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading