Skip to content
Draft
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
16 changes: 15 additions & 1 deletion prefabs/map_info_container.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[ext_resource type="Theme" uid="uid://dhuhu3mmaew1a" path="res://themes/theme.tres" id="4_4d08m"]
[ext_resource type="Script" uid="uid://c1235cyjfh4rl" path="res://scripts/ui/LinkPopupButton.cs" id="4_dccrs"]
[ext_resource type="Texture2D" uid="uid://7px5v8ikildx" path="res://user/skins/default/ui/buttons/favorite.png" id="5_1m5pv"]
[ext_resource type="Texture2D" uid="uid://dkpbociv8fgfd" path="res://user/skins/default/ui/buttons/export.png" id="5_g02bu"]
[ext_resource type="Script" uid="uid://dy45uerqy0yd7" path="res://scripts/ui/FlatPreview.cs" id="5_svokg"]
[ext_resource type="Texture2D" uid="uid://degvlg4p0if70" path="res://user/skins/default/ui/buttons/add_video.png" id="6_g02bu"]
[ext_resource type="Texture2D" uid="uid://cgxbwx4f28lt2" path="res://user/skins/default/ui/buttons/copy.png" id="7_oibm8"]
Expand Down Expand Up @@ -175,7 +176,7 @@ outline_color = Color(0, 0, 0, 1)
shadow_size = 4
shadow_color = Color(0, 0, 0, 1)

[node name="MapInfoContainer" type="Panel" unique_id=150923669 node_paths=PackedStringArray("info", "dim", "coverBackground", "cover", "infoSubholder", "mainLabel", "extraLabel", "artistLink", "favoriteButton", "videoButton", "videoDialog", "copyButton", "copyDialog", "deleteButton", "actions", "preview", "speedHolder", "speedPresets", "playHolder", "startButton", "leaderboard", "lbScrollContainer", "lbContainer", "lbExpand", "lbHide")]
[node name="MapInfoContainer" type="Panel" unique_id=150923669 node_paths=PackedStringArray("info", "dim", "coverBackground", "cover", "infoSubholder", "mainLabel", "extraLabel", "artistLink", "exportButton", "favoriteButton", "videoButton", "videoDialog", "copyButton", "copyDialog", "deleteButton", "actions", "preview", "speedHolder", "speedPresets", "playHolder", "startButton", "leaderboard", "lbScrollContainer", "lbContainer", "lbExpand", "lbHide")]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
Expand All @@ -193,6 +194,7 @@ infoSubholder = NodePath("Info/ScrollContainer/HBoxContainer")
mainLabel = NodePath("Info/ScrollContainer/HBoxContainer/Subholder/Main")
extraLabel = NodePath("Info/ScrollContainer/HBoxContainer/Subholder/Extra")
artistLink = NodePath("Info/ScrollContainer/HBoxContainer/Background/ArtistLink")
exportButton = NodePath("Info/ScrollContainer/HBoxContainer/Subholder/Buttons/Export")
favoriteButton = NodePath("Info/ScrollContainer/HBoxContainer/Subholder/Buttons/Favorite")
videoButton = NodePath("Info/ScrollContainer/HBoxContainer/Subholder/Buttons/Video")
videoDialog = NodePath("Info/ScrollContainer/HBoxContainer/Subholder/Buttons/Video/VideoDialog")
Expand Down Expand Up @@ -357,6 +359,17 @@ grow_horizontal = 0
grow_vertical = 0
alignment = 2

[node name="Export" type="Button" parent="Info/ScrollContainer/HBoxContainer/Subholder/Buttons" unique_id=2033571562]
layout_mode = 2
tooltip_text = "Export (Shift+Click for .sspm export)"
focus_mode = 0
mouse_default_cursor_shape = 2
theme = ExtResource("4_4d08m")
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_constants/icon_max_width = 24
icon = ExtResource("5_g02bu")
icon_alignment = 1

[node name="Favorite" type="Button" parent="Info/ScrollContainer/HBoxContainer/Subholder/Buttons" unique_id=1022164792]
layout_mode = 2
tooltip_text = "Favorite"
Expand Down Expand Up @@ -390,6 +403,7 @@ filters = PackedStringArray("*.mp4")
use_native_dialog = true

[node name="Copy" type="Button" parent="Info/ScrollContainer/HBoxContainer/Subholder/Buttons" unique_id=2053076461]
visible = false
layout_mode = 2
tooltip_text = "Copy"
focus_mode = 0
Expand Down
4 changes: 2 additions & 2 deletions scripts/SoundManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public static void PlayJukebox(Map map, bool setRichPresence = true)

JukeboxIndex = MapManager.Maps.FindIndex(x => x.Id == map.Id);

Song.Stream = Util.Audio.LoadFromFile($"{MapUtil.MapsCacheFolder}/{map.Name}/audio.{map.AudioExt}");
Song.Stream = Util.Audio.LoadFromFile($"{MapUtil.MapsFolder}/{map.Name}/audio.{map.AudioExt}");
Song.Play();

Instance.JukeboxPlayed?.Invoke(map);
Expand Down Expand Up @@ -280,7 +280,7 @@ public static void StartMapSelectionPlayback(Map map, bool setRichPresence = tru
}
}

Song.Stream = Util.Audio.LoadFromFile($"{MapUtil.MapsCacheFolder}/{map.Name}/audio.{map.AudioExt}");
Song.Stream = Util.Audio.LoadFromFile($"{MapUtil.MapsFolder}/{map.Name}/audio.{map.AudioExt}");
Song.Play(0);

Instance.JukeboxPlayed?.Invoke(map);
Expand Down
12 changes: 8 additions & 4 deletions scripts/game/managers/ReplayManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System;
using System.IO;

// using System.IO;
using System.Linq;
using System.Security.Cryptography;
using Godot;
Expand Down Expand Up @@ -28,7 +31,7 @@ public enum Mode
public string ReplayPath;
public Vector2 CursorPosition { get; private set; }

private FileAccess file;
private Godot.FileAccess file;
private ulong statusOffset, frameCountOffset;

public void NewReplay(Attempt attempt)
Expand All @@ -39,7 +42,7 @@ public void NewReplay(Attempt attempt)

ReplayPath = $"{Constants.USER_FOLDER}/replays/{attempt.ID}.phxr";

file = FileAccess.Open(ReplayPath, FileAccess.ModeFlags.Write);
file = Godot.FileAccess.Open(ReplayPath, Godot.FileAccess.ModeFlags.Write);

file.StoreString("phxr"); // sig
file.Store8(1); // replay file version
Expand Down Expand Up @@ -69,7 +72,8 @@ public void NewReplay(Attempt attempt)
}

string serializedMods = string.Join("_", mods);
string mapName = attempt.Map.FilePath.GetFile().GetBaseName();
// string mapName = attempt.Map.FilePath.GetFile().GetBaseName();
string mapName = Path.GetFileName(attempt.Map.FolderPath);
string player = "You";

void storeSizedString(string data)
Expand Down Expand Up @@ -126,7 +130,7 @@ public void SaveReplay(Attempt attempt)
file.Close();

// open replay to store hash
file = FileAccess.Open($"{Constants.USER_FOLDER}/replays/{attempt.ID}.phxr", FileAccess.ModeFlags.ReadWrite);
file = Godot.FileAccess.Open($"{Constants.USER_FOLDER}/replays/{attempt.ID}.phxr", Godot.FileAccess.ModeFlags.ReadWrite);
ulong length = file.GetLength();
byte[] hash = SHA256.HashData(file.GetBuffer((long)length));
file.StoreBuffer(hash);
Expand Down
2 changes: 1 addition & 1 deletion scripts/game/ui/PlaytestOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void UpdatePlaytestOverlay(bool show)
speedValue = speedDouble;
}

var map = MapParser.Decode(oldAttempt.Map.FilePath, Rhythia.AudioFilePath);
var map = MapParser.Decode(oldAttempt.Map.FolderPath, Rhythia.AudioFilePath);

Game.Attempt = new(map, speedValue, GetStartFrom(startFromEdit) * 1000, Rhythia.TempCam, Rhythia.TempMods);
SceneManager.ReloadCurrentScene();
Expand Down
20 changes: 14 additions & 6 deletions scripts/map/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,20 @@ public partial class Map : RefCounted
public int Id { get; set; }

public string Name { get; set; } = string.Empty;
public string LastModifiedMetadata { get; set; }
public string LastModifiedNotes { get; set; }

public string Hash { get; set; }
/// <summary>
/// The hash of the metadata.json, then the objects.phxmo in order
/// </summary>
public string MetadataObjectHash { get; set; }

public string Collection { get; set; } = string.Empty;

[Ignore]
public MapSet MapSet { get; set; }

public string FilePath { get; set; } = string.Empty;
public string FolderPath { get; set; } = string.Empty;

public bool Favorite { get; set; }

Expand Down Expand Up @@ -86,7 +91,7 @@ public Note[] TryParseNotes()
{
try
{
notes = MapParser.DecodePHXMO($"{MapUtil.MapsCacheFolder}/{Name}/objects.phxmo");
notes = MapParser.DecodePHXMO($"{MapUtil.MapsFolder}/{Name}/objects.phxmo");
return notes;
}
catch
Expand All @@ -97,7 +102,7 @@ public Note[] TryParseNotes()

private Texture2D getCover()
{
string path = $"{MapUtil.MapsCacheFolder}/{Name}";
string path = $"{MapUtil.MapsFolder}/{Name}";

if (cover == DefaultCover && File.Exists($"{path}/cover.png"))
{
Expand All @@ -115,10 +120,13 @@ private Texture2D getCover()

public Map() { }

public Map(string filePath, Note[] data = null, string id = null, string artist = "", string title = "", float rating = 0, string[] mappers = null, int difficulty = 0, string difficultyName = null, int? length = null, byte[] audioBuffer = null, byte[] coverBuffer = null, byte[] videoBuffer = null, bool ephemeral = false, string artistLink = "", string artistPlatform = "")
public Map(string folderPath, string metadataObjHash = "", string lastModifiedMetadata = "", string lastModifiedNotes = "", Note[] data = null, string id = null, string artist = "", string title = "", float rating = 0, string[] mappers = null, int difficulty = 0, string difficultyName = null, int? length = null, byte[] audioBuffer = null, byte[] coverBuffer = null, byte[] videoBuffer = null, bool ephemeral = false, string artistLink = "", string artistPlatform = "")
{
FilePath = filePath;
FolderPath = folderPath;
Ephemeral = ephemeral;
MetadataObjectHash = metadataObjHash;
LastModifiedMetadata = lastModifiedMetadata;
LastModifiedNotes = lastModifiedNotes;
Artist = (artist ?? "").StripEscapes();
ArtistLink = artistLink;
ArtistPlatform = artistPlatform;
Expand Down
Loading