phigros.tools

Custom charts

chapter{} adds a chapter of new songs to the chapter screen. Its songs play like the game's own, with the game's song list, level and result screens. The game never learns about them: they stay out of its save, its records and RKS, and phigros.tools. Phigros++ keeps their records and purchases in phigros++/charts/progress.lua.

A mod describes a chapter whose files sit next to it:

chapter{
  code = "MyPack", title = "My pack", subtitle = "Songs by me", cover = "cover.jpg", blur = "blur.jpg",
  after = "Single",                                -- shown right after this chapter, else last
  songs = {
    {
      folder = "song",                             -- music.webm, cover.jpg, blur.jpg and EZ.phc... are in it
      title = "Song", artist = "Composer", illustrator = "Cover artist",
      preview = { 30, 45 },                        -- what the song list plays, in seconds
      price = 0,                                   -- in MB of data, bought like the game's songs, 0 is free
      levels = {
        EZ = { difficulty = 3.5, charter = "Me" },
        HD = { difficulty = 9, charter = "Me" },
        IN = { difficulty = 13.8, charter = "Me and a friend" },
      },
    },
  },
}

The title, the artist, the illustrator, and every level's difficulty and charter are required: a song without them is an error. So is a key the chapter doesn't take, a typo is reported at load instead of ignored.

folder gives a song's files their usual names: music.webm, cover.jpg, blur.jpg and <LEVEL>.phc. Without it, or to use another name, give music, cover, blur and each level's chart as paths. Without a folder blur is optional, the cover is used instead.

A song has any of EZ, HD, IN and AT: an AT-only song shows a single AT level.

Charts are .phc files, the lossless format the chart-codec repo encodes from the game's chart json (formatVersion 1 or 3). Phigros++ decodes them in memory when a level starts.

Music is anything Android plays. phigros.tools serves Opus in WebM, 128 kbps. Covers are jpg or png.

code must be unique: it's in the save keys Phigros++ keeps out of the save (NowSong<code>), so pick a name and not a word. Song ids are <code>_<title>_<artist>.

A priced song is bought with the game's own Unlock button. The data spent is the one thing a custom chapter changes in the save; Phigros++ keeps that the song was bought, since the game only knows its own songs' keys.

Chapters from a url

A chapter can come from anywhere instead, described by a json manifest:

chapter{ url = "https://example.com/mypack/index.json", key = "<hex ed25519 public key>", after = "Single" }

The manifest is the same table in json, with paths relative to its url and a files object: every file's SHA-512 in hex. Each download is checked against its hash and refused when it's another file.

{ "code": "MyPack", "title": "My pack", "cover": "cover.jpg", "blur": "blur.jpg",
  "songs": [{ "title": "Song", "artist": "Composer", "illustrator": "Cover artist", "music": "Song_Composer/music.webm",
    "cover": "Song_Composer/cover.jpg", "levels": { "EZ": { "difficulty": 3.5, "charter": "Me", "chart": "Song_Composer/EZ.phc" } } }],
  "files": { "cover.jpg": "<sha-512 hex>", "...": "..." } }

With a key, the manifest must be signed. <url>.sig is the 64 byte Ed25519 signature of "phigros++ charts v1\0" .. manifest, and every file the manifest uses must be hashed. A manifest that isn't signed by the key is ignored. Without a key, anyone who can change the files can change the chapter.

Files are downloaded once into phigros++/charts/<code>_<title>_<artist>/. The covers come when the song list shows them, the music and the charts when a song is picked. Play waits for them under a progress bar. The last good manifest is kept, so the chapter shows offline and as soon as the game starts.

The official charts

The built-in mod mods/charts.lua is the Phigros++ chapter, after Single. Its manifest is phigros.tools/chapters/Phigros++/index.json, and the key it trusts is phigros.tools' charts key. It is the release key's sibling: its seed is in ~/.config/phigrospp/charts.key, and it only signs chapters, so it can't sign a Phigros++ update.

A chapter is published from web/ with bun scripts/publish-charts.ts <folder>. The folder has a chapter.json in the format above, pointing at the .phc charts, any music ffmpeg reads and any cover image. The script checks the credits and decodes every chart. It encodes the music to Opus, makes the JPEG covers, hashes everything and signs the manifest, then sends it to data/chapters/<code>/ on the server, which serves it without a deploy. --local stops before sending, and --keygen makes the charts key.