Skip to content
Merged
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
76 changes: 72 additions & 4 deletions scenes/game.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,16 @@ font_size = 18
font_color = Color(1, 1, 1, 0.8)

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_sijr0"]
bg_color = Color(0.1072, 0.0896, 0.16, 0.25098)
bg_color = Color(0, 0, 0, 0.8784314)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color(0, 0, 0, 0.6)
corner_radius_top_left = 12
corner_radius_top_right = 12
corner_radius_bottom_right = 12
corner_radius_bottom_left = 12

[sub_resource type="LabelSettings" id="LabelSettings_a70tm"]
font_color = Color(1, 1, 1, 0.25098)
Expand Down Expand Up @@ -756,7 +765,7 @@ size = Vector2i(1280, 720)
render_target_update_mode = 0

[node name="ReplayViewer" type="Panel" parent="." unique_id=1117476839]
visible = false
self_modulate = Color(1, 1, 1, 0)
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
Expand All @@ -770,12 +779,56 @@ grow_vertical = 2
mouse_filter = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_sijr0")

[node name="Label" type="Label" parent="ReplayViewer" unique_id=919285545]
[node name="OrthogonalPanel" type="Panel" parent="ReplayViewer" unique_id=816223519]
light_mask = 512
visibility_layer = 512
z_index = -1
z_as_relative = false
layout_mode = 1
offset_left = -5.0
offset_top = -283.0
offset_right = 259.0
offset_bottom = -19.0
offset_transform_enabled = true
offset_transform_pivot_ratio = Vector2(1, 1)
offset_transform_visual_only = false
mouse_filter = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_sijr0")

[node name="OrthogonalCamera" type="SubViewportContainer" parent="ReplayViewer/OrthogonalPanel" unique_id=468959325]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -128.0
offset_top = -128.0
offset_right = 128.0
offset_bottom = 128.0
grow_horizontal = 2
grow_vertical = 2
offset_transform_enabled = true

[node name="SubViewport" type="SubViewport" parent="ReplayViewer/OrthogonalPanel/OrthogonalCamera" unique_id=559747074]
transparent_bg = true
handle_input_locally = false
scaling_3d_mode = 5
size = Vector2i(256, 256)
render_target_update_mode = 4

[node name="Camera3D" type="Camera3D" parent="ReplayViewer/OrthogonalPanel/OrthogonalCamera/SubViewport" unique_id=1970241273]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.44182658)
top_level = true
projection = 1
size = 3.1727066

[node name="Tip" type="Label" parent="ReplayViewer" unique_id=919285545]
layout_mode = 1
anchors_preset = -1
offset_right = 40.0
grow_vertical = 0
text = "Press F2 to toggle"
text = "Press F2 to hide replay UI, F3 to hide orthogonal camera"
label_settings = SubResource("LabelSettings_a70tm")

[node name="Time" type="Label" parent="ReplayViewer" unique_id=1277133470]
Expand Down Expand Up @@ -818,6 +871,21 @@ max_value = 1.0
step = 0.0
ticks_position = 3

[node name="Background" type="Panel" parent="ReplayViewer" unique_id=375982619]
light_mask = 512
visibility_layer = 512
z_index = -1
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -52.0
grow_horizontal = 2
grow_vertical = 0
mouse_filter = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_sijr0")

[node name="NotificationHolder" type="VBoxContainer" parent="." unique_id=1425635507]
anchors_preset = 3
anchor_left = 1.0
Expand Down
7 changes: 6 additions & 1 deletion scripts/PlayerInputController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Godot;

public partial class PlayerInputController : Node
Expand All @@ -18,6 +18,7 @@ public partial class PlayerInputController : Node
public event Action OnTogglePaused;
public event Action OnRestartPressed;
public event Action OnToggleReplayViewerVisibility;
public event Action OnToggleShowOrthonogalCamera;
public event Action OnPauseOrSkipPressed;
public event Action OnPauseOrSkipReleased;
public event Action OnToggleFade;
Expand All @@ -42,6 +43,7 @@ private void handleInput(InputEvent @event)
break;
case InputEventKey { PhysicalKeycode: Key.Escape }:
case InputEventKey { PhysicalKeycode: Key.F2 }:
case InputEventKey { PhysicalKeycode: Key.F3 }:
case InputEventKey { PhysicalKeycode: Key.Space }:
case InputEventKey { PhysicalKeycode: Key.F }:
case InputEventKey { PhysicalKeycode: Key.P }:
Expand Down Expand Up @@ -101,6 +103,9 @@ private void handleKeyboardInput(InputEvent @event)
case { PhysicalKeycode: Key.F2 }:
OnToggleReplayViewerVisibility?.Invoke();
break;
case { PhysicalKeycode: Key.F3 }:
OnToggleShowOrthonogalCamera?.Invoke();
break;
case { PhysicalKeycode: Key.F }:
OnToggleFade?.Invoke();
break;
Expand Down
21 changes: 20 additions & 1 deletion scripts/game/managers/ReplayManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ public enum Mode
[Export] public CursorManager CursorManager { get; private set; }

public bool ViewerVisible;
public bool CanShow;

// only public variable because of Game
public static TextureButton SeekerPause;
private static Panel orthogonalPanel;
private static Label seekerTime;
private static Label tip;
private static Panel background;
private static HSlider seekerTimeline;
private static bool seekerHovered;
public float ReplayLength;
Expand Down Expand Up @@ -148,8 +152,11 @@ public override void _Ready()
base._Ready();

// this entire code lowkey sucks, so i am just copy and pasting it because i am lazy -fog
orthogonalPanel = ReplayViewer.GetNode<Panel>("OrthogonalPanel");
SeekerPause = ReplayViewer.GetNode<TextureButton>("Pause");
seekerTime = ReplayViewer.GetNode<Label>("Time");
tip = ReplayViewer.GetNode<Label>("Tip");
background = ReplayViewer.GetNode<Panel>("Background");
seekerTimeline = ReplayViewer.GetNode<HSlider>("Seek");
CursorManager ??= GetNode<CursorManager>("CursorManager");

Expand Down Expand Up @@ -200,7 +207,11 @@ public void ShowReplayViewer(Attempt attempt, bool? show = null)
ViewerVisible = show ?? !ViewerVisible;
bool visible = ViewerVisible && attempt.IsReplay;

ReplayViewer.Visible = visible;
SeekerPause.Visible = visible;
seekerTime.Visible = visible;
seekerTimeline.Visible = visible;
tip.Visible = visible;
background.Visible = visible;

if (attempt.IsReplay)
{
Expand All @@ -210,6 +221,14 @@ public void ShowReplayViewer(Attempt attempt, bool? show = null)
}
}

public void ShowOrthonogalCamera(Attempt attempt, bool? show = null)
{
CanShow = show ?? !CanShow;
bool visible = CanShow && attempt.IsReplay;

orthogonalPanel.Visible = visible && attempt.IsReplay;
}

public void TogglePause()
{
Runner.Pause();
Expand Down
9 changes: 9 additions & 0 deletions scripts/scenes/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ public override void _Ready()
}
};

PlayerInputController.OnToggleShowOrthonogalCamera += () =>
{
if (Attempt.IsReplay)
{
ReplayManager.ShowOrthonogalCamera(Attempt);
}
};

PlayerInputController.OnPauseOrSkipPressed += () =>
{
if (Attempt.IsReplay)
Expand Down Expand Up @@ -134,6 +142,7 @@ public override void Load()
Runner.Attempt = Attempt;
ReplayManager.InitReplayLength();
ReplayManager.ShowReplayViewer(Runner.Attempt, Runner.Attempt.IsReplay);
ReplayManager.ShowOrthonogalCamera(Runner.Attempt, Runner.Attempt.IsReplay);

Menu.HideMenu(true);

Expand Down
Loading