Rebuild the game as a single code-driven scene with a package-folder pack source

- One empty scene; App builds the canvas, safe-area layout and a shared 5x6
  Grid in code. Pages (Intro, Main, Choose, Play, Account, Settings) replace
  5 scenes, 5 prefabs and the per-cell spawner/display components.
- Packs: the game reads Rhyculator/package/ (with All files access) or the
  app folder, like a plugged-in USB stick. Zips stay where they are and are
  extracted to a cache keyed by name/size/mtime; folders are read directly.
  Scans run every second on a background thread. Old songs/ imports and inbox
  zips are migrated automatically.
- Download packs by 8-char code from the new pack website, or via
  rhyculator://pack/<code> links; opened/shared zips go into the package folder.
- Play: pause/resume/retry, auto-pause on background, combo and progress bar;
  judging and scoring unchanged. Choose page fits 9:16 screens; empty state,
  pack delete. Android back key handled everywhere.
- Slimming: removed TextMesh Pro, unused 2D/Timeline/VisualScripting/etc.
  packages and modules, scene template, unused sprites; menu theme wav (20MB)
  -> ogg (2.3MB). Build profile replaced by explicit settings in BuildAndroid.
- Tests: PackLibrary/PackReader/migration/serializer tests (39 passing).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
SahikandClaude Opus 5.5 committed 2026-10-24 14:18:54 +08:00
1 parent 6d5f66ac6a
commit ddd5fdc28b
295 files changed
+3854 -82126

No files matched your search

-102
View File
@@ -117,105 +117,3 @@ public class SongInfoTests
}
}
public class PackImporterTests
{
const string Config = "{\"id\":\"test-song\",\"name\":\"Test\",\"artist\":\"A\",\"bpm\":120,\"normal_num\":5}";
private string tempRoot;
[SetUp]
public void SetUp()
{
tempRoot = Path.Combine(Path.GetTempPath(), "rhyculator-test-" + Path.GetRandomFileName());
Directory.CreateDirectory(tempRoot);
SongLibrary.rootOverride = tempRoot;
}
[TearDown]
public void TearDown()
{
SongLibrary.rootOverride = null;
SongLibrary.Reload();
if (Directory.Exists(tempRoot)) Directory.Delete(tempRoot, true);
}
static MemoryStream MakeZip(string prefix, params (string name, string content)[] files)
{
var ms = new MemoryStream();
using (var zip = new ZipArchive(ms, ZipArchiveMode.Create, true))
{
foreach (var (name, content) in files)
{
var entry = zip.CreateEntry(prefix + name);
using var w = new StreamWriter(entry.Open(), new UTF8Encoding(false));
w.Write(content);
}
}
ms.Position = 0;
return ms;
}
[Test]
public void Imports_pack_into_library_and_ignores_other_entries()
{
var zip = MakeZip("",
("config.json", Config), ("normal.json", "{\"format\":1,\"notes\":[]}"),
("music.ogg", "x"), ("image.png", "x"),
("README.txt", "ignored"), ("../evil.txt", "ignored"), ("sub/easy.json", "ignored"));
var info = PackImporter.Import(zip);
Assert.AreEqual("test-song", info.id);
string dir = Path.Combine(tempRoot, "test-song");
Assert.IsTrue(File.Exists(Path.Combine(dir, "normal.json")));
Assert.IsFalse(File.Exists(Path.Combine(dir, "README.txt")));
Assert.IsFalse(File.Exists(Path.Combine(dir, "easy.json")));
Assert.IsFalse(File.Exists(Path.Combine(tempRoot, "evil.txt")));
Assert.IsTrue(info.HasLevel(2));
Assert.IsFalse(info.HasLevel(1));
Assert.AreEqual(2, info.FirstLevel());
Assert.AreEqual(5, info.levelNum[2]);
SongLibrary.Reload();
Assert.AreEqual(1, SongLibrary.Songs.Count);
Assert.AreEqual("test-song", SongLibrary.Find("test-song").id);
}
[Test]
public void Accepts_folder_prefix_and_reimport_replaces_old_files()
{
PackImporter.Import(MakeZip("test-song/", ("config.json", Config), ("easy.json", "{\"notes\":[]}"), ("music.wav", "x"), ("image.png", "x")));
PackImporter.Import(MakeZip("", ("config.json", Config), ("hard.json", "{\"notes\":[]}"), ("music.ogg", "x"), ("image.png", "x")));
string dir = Path.Combine(tempRoot, "test-song");
Assert.IsTrue(File.Exists(Path.Combine(dir, "hard.json")));
Assert.IsFalse(File.Exists(Path.Combine(dir, "easy.json")), "重新匯入要整個取代舊資料夾");
Assert.IsFalse(File.Exists(Path.Combine(dir, "music.wav")));
}
[Test]
public void Rejects_incomplete_packs_without_leaving_files()
{
Assert.Throws<PackImporter.ImportException>(() => PackImporter.Import(MakeZip("", ("easy.json", "{}"))));
Assert.Throws<PackImporter.ImportException>(() => PackImporter.Import(MakeZip("", ("config.json", Config), ("music.ogg", "x"), ("image.png", "x"))));
Assert.Throws<PackImporter.ImportException>(() => PackImporter.Import(MakeZip("", ("config.json", Config), ("easy.json", "{}"), ("image.png", "x"))));
Assert.Throws<PackImporter.ImportException>(() => PackImporter.Import(MakeZip("", ("config.json", Config), ("easy.json", "{}"), ("music.ogg", "x"))));
Assert.Throws<PackImporter.ImportException>(() => PackImporter.Import(MakeZip("", ("config.json", "{\"id\":\"BAD\",\"name\":\"n\"}"), ("easy.json", "{}"), ("music.ogg", "x"), ("image.png", "x"))));
Assert.IsFalse(Directory.Exists(Path.Combine(tempRoot, "test-song")));
}
[Test]
public void Inbox_imports_and_deletes_zips()
{
string inbox = SongLibrary.InboxDir;
Directory.CreateDirectory(inbox);
File.WriteAllBytes(Path.Combine(inbox, "a.zip"),
MakeZip("", ("config.json", Config), ("easy.json", "{\"notes\":[]}"), ("music.ogg", "x"), ("image.png", "x")).ToArray());
File.WriteAllText(Path.Combine(inbox, "bad.zip"), "not a zip");
var errors = new List<string>();
var imported = PackImporter.ImportInbox(errors);
Assert.AreEqual(1, imported.Count);
Assert.AreEqual(1, errors.Count);
Assert.AreEqual(0, Directory.GetFiles(inbox, "*.zip").Length);
}
}