Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
3ce8c98
Copied logs hide sign-in tokens too
MrMilenko Nov 19, 2026
d22856e
Merge log-redact: copied logs hide sign-in tokens
MrMilenko Nov 19, 2026
c07af7a
Find xemu in RetroBat and the other usual places
MrMilenko Nov 19, 2026
e28f745
Songs keep their track order, and playlists keep theirs
MrMilenko Nov 19, 2026
143d188
Merge music-order: track and playlist order
MrMilenko Nov 19, 2026
a2b98ac
Added PCSX2 as a launcher
MrMilenko Nov 19, 2026
403de67
Controllers can come and go while it runs
MrMilenko Nov 19, 2026
1ae5049
Portable mode
MrMilenko Nov 19, 2026
25b6a26
Merge portable: portable mode
MrMilenko Nov 19, 2026
9f48967
Every connected pad drives the dashboard
MrMilenko Nov 19, 2026
2205c43
Icons from .ico files and Windows programs
MrMilenko Nov 19, 2026
6577846
Kept access tokens out of the log
MrMilenko Nov 19, 2026
7c391b6
Pad buzzes when the guide can't do something
MrMilenko Nov 19, 2026
5d0261f
Import Linux .desktop shortcuts
MrMilenko Nov 19, 2026
40baaf4
Guide shows PlayStation and Nintendo buttons
MrMilenko Nov 19, 2026
24ed3ce
Setting to confirm with the right face button
MrMilenko Nov 19, 2026
a3fdcec
Per-game launch options
MrMilenko Nov 19, 2026
b68a63e
Merge controllers: hot plug, multiple pads, rumble, pad glyphs, confi…
MrMilenko Nov 19, 2026
b5db651
Merge main into launcher-issues
MrMilenko Nov 19, 2026
75ac56b
Fixed Jellyfin and Plex posters that never showed
MrMilenko Nov 19, 2026
fb77600
Merge launcher-issues: xemu find, PCSX2, program icons, Linux apps, l…
MrMilenko Nov 19, 2026
9a65b88
Stopped long Jellyfin and Plex headers running into the count
MrMilenko Nov 19, 2026
3e9373e
Guide help names the buttons the way your pad does
MrMilenko Nov 19, 2026
bde9450
Merge pad-words: guide help follows the pad
MrMilenko Nov 19, 2026
21c9f6a
Moved the Y INFO button beside BACK in Jellyfin and Plex
MrMilenko Nov 19, 2026
76cd5e3
First run offers your Steam games and emulators
MrMilenko Nov 19, 2026
2a7ecf0
Merge welcome-library: first run fills the launcher
MrMilenko Nov 19, 2026
3fe3e0b
README catches up with the guide and the new launcher bits
MrMilenko Nov 19, 2026
433147b
Merge readme-guide
MrMilenko Nov 19, 2026
9e7e766
Fixed posters still going missing after a few screens
MrMilenko Nov 19, 2026
09eb99e
Gave fullscreen video the pad and fixed backing out one level too far
MrMilenko Nov 19, 2026
39a8450
Let Jellyfin and Plex open folders instead of trying to play them
MrMilenko Nov 19, 2026
caa2b64
Episode rows read S1E05 · Title in Jellyfin and Plex
MrMilenko Nov 19, 2026
5ade1b4
Filled out the Y info card in Jellyfin and Plex
MrMilenko Nov 19, 2026
f67482b
Marked watched and half watched rows in Jellyfin and Plex
MrMilenko Nov 19, 2026
8facaac
Library rows show how many items each holds
MrMilenko Nov 19, 2026
4087dd3
Jellyfin and Plex say Loading or Can't reach instead of an empty list
MrMilenko Nov 19, 2026
f6a669b
Added Continue Watching and Next Up above the Jellyfin libraries
MrMilenko Nov 19, 2026
cd57c61
Merge main into media-polish
MrMilenko Nov 19, 2026
b3fcab9
Merge media-polish: Jellyfin and Plex fixes and polish
MrMilenko Nov 19, 2026
dbaaadf
Added Import Epic Games to the guide
MrMilenko Nov 19, 2026
af1df4d
Added collections for games
MrMilenko Nov 19, 2026
6d837d6
Added Import GOG Games to the guide
MrMilenko Nov 19, 2026
e79d614
Jellyfin and Plex hear where you stopped watching
MrMilenko Nov 19, 2026
022fbe7
Game lists can be filtered by where a game comes from
MrMilenko Nov 19, 2026
066e175
Added Import Lutris Games to the guide
MrMilenko Nov 19, 2026
9371d71
Added backing up and restoring settings from the guide
MrMilenko Nov 19, 2026
7ea0337
Added Import itch.io Games to the guide
MrMilenko Nov 19, 2026
e1c9d31
Added X FROM START and pad hints to video
MrMilenko Nov 19, 2026
fe26096
All Games can sort by time played, and About shows the total
MrMilenko Nov 19, 2026
1f14b0e
Merge store-imports: Epic, GOG, Lutris and itch.io
MrMilenko Nov 19, 2026
968d520
Merge main into library-organize
MrMilenko Nov 19, 2026
5f15bc9
Game list filter knows the store imports
MrMilenko Nov 19, 2026
8454488
Merge library-organize: collections, filters, sorting, backups
MrMilenko Nov 19, 2026
94bbbcd
RB marks things watched in Jellyfin and Plex
MrMilenko Nov 19, 2026
008a8be
README covers store imports, collections, filters and backups
MrMilenko Nov 19, 2026
532f454
Merge readme2
MrMilenko Nov 19, 2026
827f279
Added Search to Jellyfin and Plex
MrMilenko Nov 19, 2026
ef3e357
Merge main into media-progress
MrMilenko Nov 19, 2026
a47247b
Merge media-progress: watch progress to Jellyfin and Plex, from start…
MrMilenko Nov 19, 2026
7b8c901
About reads as a list, not buttons
MrMilenko Nov 19, 2026
b4ecb5c
Merge about-plain
MrMilenko Nov 19, 2026
f3e5429
Guide pages read in blocks
MrMilenko Nov 19, 2026
3f8b42a
Merge guide-blocks: guide pages in blocks
MrMilenko Nov 19, 2026
ef5795d
Version 0.4.2
MrMilenko Nov 19, 2026
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
2 changes: 1 addition & 1 deletion Configs/version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[default]
version=0.4.1
version=0.4.2
Binary file modified Data/Xips/default.xip
Binary file not shown.
Binary file modified Data/Xips/jellyfin.xip
Binary file not shown.
Binary file modified Data/Xips/plex.xip
Binary file not shown.
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ On macOS, Linux and Windows it goes by **UIX Desktop**: a launcher and media cen

## What's in it

- **Games grid** for anything you can launch: native PC games, scripts, Steam, RetroArch, [ES-DE](https://es-de.org/) collections, Xbox ISOs through [xemu](https://xemu.app), and your Xbox Cloud Gaming library
- **Games grid** for anything you can launch: native PC games, scripts, Steam, RetroArch, [ES-DE](https://es-de.org/) collections, Xbox ISOs through [xemu](https://xemu.app), PS2 discs through [PCSX2](https://pcsx2.net), Linux app shortcuts, and your Xbox Cloud Gaming library. Box art, favorites, recently played, time played, and the dashboard comes back when a game closes
- **The guide**: press the Guide button, LT+B or F7 anywhere for settings, accounts, adding and finding games, logs and help, all from a controller with its own on screen keyboard
- **Title Maker** (F3) for adding and editing entries by hand, with import tabs for Steam, RetroArch and ES-DE
- **Media library** for your Movies and TV folders, with posters from [TMDB](https://www.themoviedb.org/), plus [Plex](https://www.plex.tv/) and [Jellyfin](https://jellyfin.org/) servers. Playback runs through libmpv
- **Music** from your own folders, with a [projectM](https://github.com/projectM-visualizer/projectm) (MilkDrop) visualizer
- **Xbox Cloud Gaming and remote play**: sign in with your Xbox account and your cloud games and consoles show up in the grid
- **Skins**: UIX Lite community skins drop in as is, and the Skin Editor helps you make your own
- **CRT effect** for that living room TV look: scanlines, curvature, phosphor mask, bloom, all tunable
- **Controllers**: Xbox, PlayStation and other SDL2 gamepads, plus full keyboard control
- **Controllers**: Xbox, PlayStation, Nintendo and other SDL2 gamepads, any number of them, plugged in or out while it runs, with matching button prompts, rumble, and full keyboard control
- **Xbox HDD browser** (F5) for xemu qcow2 images and their FATX partitions

## Get it
Expand Down Expand Up @@ -58,6 +59,8 @@ Launch it and you land on the dashboard. On first run UIX Desktop creates your *
| Linux | `$XDG_DATA_HOME/theseus/`, which is usually `~/.local/share/theseus/` |
| Windows | `%APPDATA%\Theseus\` |

**Portable mode:** put an empty `portable.txt` next to the app (beside `theseus.exe` on Windows, beside `theseus` in the Linux tarball) and everything lives in a `UserData` folder right there instead, handy for a USB stick or one folder per setup. An AppImage does the same with a folder named after it plus `.home` (`UIX-Desktop-v0.4.1-x86_64.AppImage.home`). Setting `THESEUS_DATA_DIR` points the user data folder anywhere you like and beats both.

**Settings (F4) > General > Open User Directory** takes you straight there. Inside:

| Path | What's there |
Expand All @@ -75,16 +78,23 @@ When an update ships new Data (scene archives, fonts, skins), it reaches your co

### Adding games and apps

Open **Title Maker** with F3 (or Tools > Title Maker).
The quickest way is the guide (Guide button, LT+B or F7) > **Games & Playlists**:

- **Add a Game** picks a program, shortcut, ROM or disc image. **Runs With** sends Xbox ISOs to xemu and PS2 discs to PCSX2 (Settings > Games has Find rows for both), and a Windows program brings its own icon along.
- **Import Steam Library**, **Import RetroArch Recent** and **Refresh ES-DE** fill the launcher in one go, and so do **Import Epic Games**, **Import GOG Games**, **Import Lutris Games** and **Import itch.io Games** when those are installed (Heroic's Epic and GOG games count too). On Linux, **Import Linux Apps** reads your app menu, Flatpak and snap shortcuts.
- **Search by Name**, **Find a Game** by letter, **Favorites**, **Recently Played** and **Hidden Games** get you to anything. In a game list, X filters by where games come from (or Most Played, Never Played) and Y sorts All Games by name, time played or last played.
- **Collections** are your own groups: add a game from its page and the collection shows up in the dashboard's launcher next to Favorites. Each game's page also has favorite and hide toggles, its time played, and **Arguments**, **Working Folder** and **Environment** for that game alone.

- **Main** lists every entry, whatever added it. Create one by hand with a name and a launch line: a path to an executable, a script, a `steam://` link, or any shell command. Quote paths with spaces. **Test Launch** tries it without leaving the dashboard. **Add ISO** turns an Xbox ISO into an xemu entry once the xemu path is set (Find checks the usual install spots).
For hand editing, **Title Maker** (F3) has every entry and the import tabs:

- **Main** lists every entry, whatever added it. Create one by hand with a name and a launch line: a path to an executable, a script, a `steam://` link, or any shell command. Quote paths with spaces. **Test Launch** tries it without leaving the dashboard. **Add ISO** turns an Xbox ISO into an xemu entry and **Add PS2 Disc** a disc into a PCSX2 one (Find checks the usual install spots, RetroBat, scoop, Flatpak and AppImages). Icons can come from images, `.ico` files or straight out of an `.exe` or `.dll`.
- **Steam** finds your Steam install, and **Import Steam Library** brings in every installed game with its icon. Add by App ID covers betas and demos.
- **RetroArch** finds your install, and **Import Recent Titles** pulls in what you've played lately with the core and box art already sorted. Or pick a ROM and a core by hand.
- **ES-DE** points at your ES-DE data folder (the one holding `gamelists/`). Your systems and games show up under an ES-DE category, read live on every launch.

Entries from Main, Steam and RetroArch are stored in **`Configs/games.ini`** inside your user data folder, with their icons in `Configs/icons/` and the icon mapping in `Configs/Icons.ini`. Back those up and you've backed up your launcher. ES-DE and Xbox Cloud Gaming entries are never written there; they're rebuilt each launch from their source.
Entries from Main, Steam and RetroArch are stored in **`Configs/games.ini`** inside your user data folder, with their icons in `Configs/icons/` and the icon mapping in `Configs/Icons.ini`. Guide > Logs & Help > **Back Up My Settings** copies those and your settings into a dated folder under `Backups`, and **Restore a Backup** puts one back. ES-DE and Xbox Cloud Gaming entries are never written there; they're rebuilt each launch from their source.

The Steam, RetroArch and ES-DE tabs can be hidden under Optional Tabs at the top of Main. Hiding a tab keeps its entries. When you launch something, the dashboard fades to black and minimizes so the game gets the screen; switch back to it when you're done. Cloud and remote play streams run inside the dashboard window instead.
The Steam, RetroArch and ES-DE tabs can be hidden under Optional Tabs at the top of Main. Hiding a tab keeps its entries. When you launch something, the dashboard fades to black and minimizes so the game gets the screen, and idles while it plays. When the game closes, its time played is added and the dashboard comes back (Settings > Games > Back to UIX When a Game Closes turns that off). Steam games count from when Steam says they're running. A launcher that starts the real game and quits right away isn't followed. Cloud and remote play streams run inside the dashboard window instead.

### Xbox Cloud Gaming

Expand All @@ -111,6 +121,9 @@ Skins live in `Data/Skins/<SkinName>/` in your user data folder. Pick one from t
- **Display**: fullscreen (F11), borderless (F12), resolution, vsync, FPS cap, MSAA, renderer, hardware video decode, and Emulate Xbox Resolution, which frames scenes in the original 720x480 design space
- **CRT Effect**: Settings > Display, or View > CRT Effect. Four presets or eight sliders
- **Audio**: master volume, mute (Ctrl+M), and the projectM visualizer. With it on, X + Y (keys or pad) opens and closes the visualizer window
- **Controller**: rumble, which buttons the prompts show (follow the pad, or force Xbox, PlayStation or Nintendo), and Confirm With the Right Button for Nintendo style A and B

Every setting lives in the guide's Settings pages, and in the Settings window (F4) for mouse and keyboard.

Command line flags: `--fullscreen`, `--4k` (fullscreen plus 2x UI scale), `--scale N`, `--no-toolbar`, `--muted`, `--minimized`, `--dashboard`, `--development`.

Expand Down Expand Up @@ -171,7 +184,7 @@ On a Mac, Cmd works in place of Ctrl.
<details>
<summary><b>Controller in the tool windows</b></summary>

**LT + B** (the same chord as the Xbox overlay) hands the pad to the tool windows. A prompt bar along the bottom shows what each button does right now.
Guide > Desktop Tools > **Use the Tools with the Pad** hands the pad to the tool windows. A prompt bar along the bottom shows what each button does right now.

| Input | Action |
|---|---|
Expand All @@ -181,7 +194,7 @@ On a Mac, Cmd works in place of Ctrl.
| Y | Open a text field with the on screen keyboard |
| Hold X | Move and resize windows |

Turn it off with `PadMode=0` in `Configs/desktop.ini`. The Skin Editor stays mouse and keyboard only.
The Skin Editor stays mouse and keyboard only.

</details>

Expand Down
16 changes: 14 additions & 2 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,13 @@ clean:
# talks to the OS by name: <windows.h> is host_win* only, the compiler's OS
# macros are platform.h and host_* only, and THESEUS_HOST_* is too, apart
# from LINT_HOST_DATA. Those files keep per-OS data, not OS calls: default
# install paths for Steam, RetroArch and xemu, and the Linux CD ioctls.
# install paths for Steam, RetroArch, xemu and PCSX2, and the Linux CD ioctls.
# Vendored headers (stb, minimp3, imfilebrowser, imgui) are left alone.
LINT_DIRS = $(THESEUS_SRC)/desktop $(THESEUS_SRC)/shared $(THESEUS_SRC)/engine \
$(THESEUS_SRC)/render $(THESEUS_SRC)/toolbox
LINT_VENDOR = --exclude-dir=third-party --exclude-dir=xdk --exclude-dir=imgui \
--exclude='stb_*.h' --exclude='minimp3.h' --exclude='imfilebrowser.h'
LINT_HOST_DATA = title_maker.cpp retroarch.cpp steam.cpp hdd_browser.cpp cdaudio.cpp
LINT_HOST_DATA = title_maker.cpp retroarch.cpp steam.cpp xemu.cpp pcsx2.cpp hdd_browser.cpp cdaudio.cpp
LINT_HOSTTEST = THESEUS_HOST_(WIN|MAC|LINUX)
.PHONY: lint-platform
lint-platform:
Expand Down Expand Up @@ -848,6 +848,7 @@ DESKTOP_SRCS_SYSTEM = \
$(THESEUS_SRC)/desktop/dashinit.cpp \
$(THESEUS_SRC)/desktop/config.cpp \
$(THESEUS_SRC)/desktop/joystick.cpp \
$(THESEUS_SRC)/desktop/pads.cpp \
$(THESEUS_SRC)/shared/keyboard_node.cpp \
$(THESEUS_SRC)/engine/locale_node.cpp \
$(THESEUS_SRC)/shared/timezone.cpp \
Expand All @@ -872,6 +873,13 @@ DESKTOP_SRCS_PLATFORM = \
$(THESEUS_SRC)/desktop/launchers/steam.cpp \
$(THESEUS_SRC)/desktop/launchers/retroarch.cpp \
$(THESEUS_SRC)/desktop/launchers/xemu.cpp \
$(THESEUS_SRC)/desktop/launchers/pcsx2.cpp \
$(THESEUS_SRC)/desktop/launchers/emu_find.cpp \
$(THESEUS_SRC)/desktop/launchers/stores.cpp \
$(THESEUS_SRC)/desktop/launchers/epic.cpp \
$(THESEUS_SRC)/desktop/launchers/gog.cpp \
$(THESEUS_SRC)/desktop/launchers/lutris.cpp \
$(THESEUS_SRC)/desktop/launchers/itch.cpp \
$(THESEUS_SRC)/desktop/title_sanitize.cpp \
$(THESEUS_SRC)/desktop/udata_synth.cpp \
$(THESEUS_SRC)/desktop/desktop_stubs.cpp \
Expand All @@ -890,6 +898,10 @@ DESKTOP_SRCS_PLATFORM = \
$(THESEUS_SRC)/desktop/esde.cpp \
$(THESEUS_SRC)/desktop/esde_vgames.cpp \
$(THESEUS_SRC)/desktop/icon_compress.cpp \
$(THESEUS_SRC)/desktop/exe_icon.cpp \
$(THESEUS_SRC)/desktop/xdg_apps.cpp \
$(THESEUS_SRC)/desktop/store_import.cpp \
$(THESEUS_SRC)/desktop/sqlite_read.cpp \
$(THESEUS_SRC)/desktop/game_art.cpp \
$(THESEUS_SRC)/desktop/playlist.cpp \
$(THESEUS_SRC)/desktop/playlist_maker.cpp \
Expand Down
39 changes: 39 additions & 0 deletions release-notes/0.4.2-testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
A testing build with a lot in it. Please kick the tires and tell us what breaks, especially on Windows, the Steam Deck and anything with a Plex server.

## Downloads
| OS | File |
|---|---|
| macOS (Apple Silicon) | `Theseus-v0.4.2-testing-macos-app.zip` (the app), or `Theseus-v0.4.2-testing-macos.zip` (bare binary, needs Homebrew libs) |
| Windows x64 | `Theseus-v0.4.2-testing-windows-x64.zip`. Unzip anywhere, run `theseus.exe` |
| Linux x64 | `UIX-Desktop-v0.4.2-testing-x86_64.AppImage` (Steam Deck too), or the tarball |
| Linux ARM64 | `UIX-Desktop-v0.4.2-testing-aarch64.AppImage`, or the tarball |

`SHA256SUMS.txt` lists a checksum for every file.

## Games
- **Time played and back to the dashboard.** Games started from the dashboard are timed, and the dashboard comes back when they close (Settings > Games to turn it off). Steam games count from when Steam says they're running.
- **More places to bring games in from:** Epic, GOG, Lutris and itch.io (Heroic's Epic and GOG games too), PS2 discs through PCSX2, Linux app shortcuts, and icons straight out of .exe, .dll and .ico files. xemu and PCSX2 get found in a lot more places, RetroBat and Flatpak included.
- **Your own collections,** shown in the launcher next to Favorites. Filter a list by where games come from (X), sort All Games by time or last played (Y), and search by name.
- **Per-game options:** arguments, working folder and environment for any game.
- First launch offers to import your Steam games and find your emulators.

## Controllers
- Any number of pads, plugged in or out while it runs.
- PlayStation and Nintendo pads get their own button prompts, and there's a setting to confirm with the right button.
- Rumble when the guide can't do something (Settings > Controller turns it off).

## Jellyfin and Plex
- Continue Watching and Next Up, resume where you stopped (X starts from the beginning), and your progress goes back to the server.
- An info card on Y with year, runtime, rating, genres and the plot. Watched marks in lists, RB to mark watched, and search.
- Folders and box sets open, episodes read "S1E05 · Title", and you see Loading or Can't reach the server instead of an empty list.
- Fixed posters that never showed up, the header running into the item count, the pad doing nothing during a video, and B backing out of the menu as well as the video.
- Sign-in tokens no longer end up in theseus.log.

## Everything else
- The guide reads better: only things you can do are buttons, information is plain text, and pages are split into sections.
- **Back Up My Settings** and **Restore a Backup** in Logs & Help.
- **Portable mode:** put a `portable.txt` next to the app and everything stays in a `UserData` folder beside it.
- Music keeps track order when files aren't tagged, and .m3u playlists keep their order (#27).
- Copy Log hides sign-ins along with your home folder and IP addresses.

Plex support is written but hasn't been tried against a real server yet. Same for the store imports on real installs. If something's off, the issue form on GitHub plus `theseus.log` (Guide > Logs & Help > Copy Log) is the fastest way to get it fixed.
30 changes: 27 additions & 3 deletions theseus/desktop/app_paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <strings.h>
#include <sys/stat.h>
#include <map>
#include <mutex>
#include <string>

#include "host.h"
Expand Down Expand Up @@ -42,6 +43,21 @@ const char* Plat_UserDataDir() {
if (s_init) return s_dir;
s_init = true;

// THESEUS_DATA_DIR wins. Then portable mode: a portable.txt beside the
// app keeps everything in UserData next to it (a USB stick, one folder
// per setup). Otherwise the OS's usual per-user folder.
const char* env = getenv("THESEUS_DATA_DIR");
if (env && *env) {
snprintf(s_dir, sizeof(s_dir), "%s", env);
return s_dir;
}
char marker[1024];
snprintf(marker, sizeof(marker), "%s/portable.txt", Plat_ExeDir());
struct stat st;
if (stat(marker, &st) == 0) {
snprintf(s_dir, sizeof(s_dir), "%s/UserData", Plat_ExeDir());
return s_dir;
}
Host_UserDataDir(s_dir, sizeof(s_dir));
return s_dir;
}
Expand Down Expand Up @@ -282,16 +298,24 @@ const char* AppPathf(const char* fmt, ...) {
}

const char* AppPath_Tree(const char* tree) {
// One slot per tree; only the drive letter roots land here.
static struct { char name[16]; char path[1024]; } s_cache[8];
// One slot per tree, kept for the whole run. Art downloads ask from their
// own threads, hence the lock.
static std::mutex s_mtx;
static struct { char name[64]; char path[1024]; } s_cache[32];
static int s_count = 0;
if (!tree || !*tree) return "";

std::lock_guard<std::mutex> lk(s_mtx);
for (int i = 0; i < s_count; i++)
if (strcasecmp(s_cache[i].name, tree) == 0) return s_cache[i].path;
if (s_count >= 8) return tree;

const char* root = IsUserOwned(tree) ? Plat_UserDataDir() : Plat_ShippedDir();
// Out of slots or too long a name: still the right folder, just not kept.
if (s_count >= 32 || strlen(tree) >= sizeof(s_cache[0].name)) {
static thread_local char t_path[1024];
snprintf(t_path, sizeof(t_path), "%s/%s", root, tree);
return t_path;
}
snprintf(s_cache[s_count].name, sizeof(s_cache[0].name), "%s", tree);
snprintf(s_cache[s_count].path, sizeof(s_cache[0].path), "%s/%s", root, tree);
return s_cache[s_count++].path;
Expand Down
37 changes: 32 additions & 5 deletions theseus/desktop/audio_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -988,15 +988,42 @@ static void SongToDB(const Song& s, DBEntry& e)
e.album = s.album;
}

// Numbers inside names compare as numbers, so "2 - Song" comes before
// "10 - Song", and case doesn't matter.
static bool NaturalLess(const std::string& a, const std::string& b)
{
size_t i = 0, j = 0;
while (i < a.size() && j < b.size()) {
unsigned char ca = (unsigned char)a[i], cb = (unsigned char)b[j];
if (isdigit(ca) && isdigit(cb)) {
size_t ie = i, je = j;
while (ie < a.size() && a[ie] == '0') ie++;
while (je < b.size() && b[je] == '0') je++;
size_t ia = ie, jb = je;
while (ia < a.size() && isdigit((unsigned char)a[ia])) ia++;
while (jb < b.size() && isdigit((unsigned char)b[jb])) jb++;
if (ia - ie != jb - je) return ia - ie < jb - je;
int c = a.compare(ie, ia - ie, b, je, jb - je);
if (c != 0) return c < 0;
i = ia; j = jb;
continue;
}
int la = tolower(ca), lb = tolower(cb);
if (la != lb) return la < lb;
i++; j++;
}
return a.size() - i < b.size() - j;
}

// Track number from the tags first. Without one, the file name decides,
// since that's where rippers and stores put the order ("01 - Intro.mp3").
static void SortSoundtrackSongs(Soundtrack& st)
{
std::sort(st.songs.begin(), st.songs.end(), [](const Song& a, const Song& b) {
std::stable_sort(st.songs.begin(), st.songs.end(), [](const Song& a, const Song& b) {
int an = a.trackNumber > 0 ? a.trackNumber : 0x7fffffff;
int bn = b.trackNumber > 0 ? b.trackNumber : 0x7fffffff;
if (an != bn) return an < bn;
const std::string& aname = !a.title.empty() ? a.title : a.name;
const std::string& bname = !b.title.empty() ? b.title : b.name;
return aname < bname;
return NaturalLess(a.name, b.name);
});
}

Expand Down Expand Up @@ -1122,7 +1149,7 @@ int DashMusic_Scan(const char* musicRoot)
const char* nm = slash ? slash + 1 : entries[i].c_str();
soundtrack.songs.push_back(BuildSong(entries[i], StripExtension(nm)));
}
SortSoundtrackSongs(soundtrack);
// A playlist file is already in the order its author wants.
s_soundtracks.push_back(soundtrack);
};

Expand Down
Loading
Loading