Commit Graph
7 Commits
Author SHA1 Message Date
McSchneidar 61b2677f16 Redesign highscore screen (#908)
- Places 1-3 are shown on a podium with profile avatars and a crown for the winner
- Players without an avatar get a placeholder silhouette (new skin texture NoAvatar)
- Places 4-10 are listed below with a score bar for each entry
- The podium only appears once there is at least one highscore
- New entries are shown in gold with a slight pulse and gold sparkles
2026-10-17 04:23:07 +02:00
McSchneidarandFlorian Ostertag e69f62809a Improve gamepad input handling (#901)
Co-authored-by: Florian Ostertag <flokuep@users.noreply.github.com>
2026-10-16 07:54:44 +02:00
McSchneidarandFlorian Ostertag 611591be1d Fix overlapping EHeaderFlags values (#902)
Instrumental (5) and Vocals (6) overlapped with Title|MP3 and
Artist|MP3 in the [Flags] enum. A song file with #INSTRUMENTAL or
#VOCALS therefore passed the mandatory-tag checks even when #TITLE,
#ARTIST or #MP3 were missing, leaving Audio empty.

Give each flag its own bit (Instrumental = 64, Vocals = 128).

Co-authored-by: Florian Ostertag <flokuep@users.noreply.github.com>
2026-10-16 07:33:40 +02:00
McSchneidarandFlorian Ostertag 8f916aaf65 Allow the last entry to be picked in random song/category selection (#903)
Random.Next(min, max) excludes max, so Next(0, Count - 1) never returned
the last index. The last song or category in the list was only picked
once it was the only one left, so it always came last.

Use Next(0, Count) instead.

Co-authored-by: Florian Ostertag <flokuep@users.noreply.github.com>
2026-10-16 06:40:24 +02:00
McSchneidarandFlorian Ostertag df412b6d33 Two small fixes (#904)
* Fix index check in CSelectSlide.RenameValue

The check used && instead of ||. An index cannot be negative and out
of range at the same time, so the check never returned early and an
invalid index caused an ArgumentOutOfRangeException.

* Allow textures to be disposed more than once

CTextureBase.Dispose threw ObjectDisposedException on a second call.
Dispose must be safe to call multiple times, otherwise freeing a
texture twice crashes the game.

Return early instead. CD3DTexture and COGLTexture also check
IsDisposed first, so a second call does not free the GPU texture
again. This matters for OpenGL, where the texture name may already
belong to another texture.

---------

Co-authored-by: Florian Ostertag <flokuep@users.noreply.github.com>
2026-10-16 05:53:10 +02:00
McSchneidar 2a6be1b3fe Speed up cover loading and keep the cover DB up to date (#905)
* Recreate cover DB on version mismatch instead of throwing

CCoverDB.Init threw NotImplementedException whenever the stored
version was older than CSettings.DatabaseCoverVersion, so any future
schema change would crash the game on start.

The cover DB is only a cache. On any version mismatch, drop all
tables and create an empty DB with the current layout instead.
Covers are rebuilt on the next load.

* Add indexes to cover DB and guard against duplicate entries

Cover.Path and CoverData.CoverId had no index, so every cover lookup
scanned the whole table. With thousands of songs this makes loading
quadratic. Add unique indexes on both columns.

Use INSERT OR IGNORE plus last_insert_rowid() when storing a cover.
This prepares for loading covers outside the lock, where two threads
may store the same cover concurrently.

Bump DatabaseCoverVersion to 2 so existing cover DBs are recreated
with the indexes.

* Decode and resize covers outside of the cover DB lock

The comment in GetCover claimed the lock was released before loading
the bitmap, but the whole method ran inside lock(_Mutex). All cover
tasks started by CSongs._LoadCovers therefore decoded and resized
one after another, and the remaining thread pool threads just waited.

Split GetCover into three steps:
- _ReadCachedCover: DB lookup (locked)
- decoding and resizing (not locked, runs in parallel)
- _StoreCover: DB insert (locked)

The duplicated resize code moves into _FitToMaxSize.

If the DB connection has been closed in the meantime, GetCover now
still returns true, because the texture has already been created.
Before, it returned false, and the caller generated a second cover
while the first texture was still queued.

* Store resized covers and detect changed cover files

The cover DB stored the original cover file. Every later load still
had to decode the full-size image (often 1000-3000 px) and scale it
down to CoverSize, so the cache only saved reading the file from disk.

- Store the cover already scaled to CoverSize: JPEG (quality 90), or
  PNG if the original has transparency. Covers that are already small
  enough are stored unchanged to avoid recompressing them.
- Entries were only keyed by path, so a replaced cover file with the
  same name was never picked up. Also store file size, last write
  time and CoverSize, and drop outdated entries on lookup.
- _FitToMaxSize throws if Resize fails instead of passing null on.
2026-10-16 05:22:44 +02:00
McSchneidar d48426b04d Fixes for progress bar and applause sounds (#906)
* Control score sounds from UpdateGame instead of the thread pool

_PlayProgressBarSound started a Task that waited for the progress bar
duration and then closed whatever stream was stored in
_ProgressBarSoundStream. When switching rounds on the score screen
before that time had passed, an old task closed the progress bar
sound of the new round too early and played the applause of the
previous round, while the applause of the new round never played.

Remember when the progress bar sound was started and check it in
UpdateGame on the main thread instead. Starting a new progress bar
sound and leaving the screen now also stop a running applause.

* Sync progress bar sound with the score bar animation

The sound duration was computed from the points (10,000 points =
5 seconds), while the bar animation duration depends on the bar size
in the theme and only starts when the bar is first drawn. Both only
matched approximately and drifted apart with other themes.

Add CProgressBar.AnimatesMovement and CProgressBar.IsAnimating. The
score screen now stops the progress bar sound and starts the applause
as soon as no visible score bar is animating anymore. If the theme
has no movement animation, the previous duration is used.

* Make stream id allocation in CPlaybackBase thread-safe

Load assigned stream ids with _NextId++ outside of the lock. Load is
also called from other threads, so two streams could get the same id
and a later Close or Play could hit the wrong stream.

Use Interlocked.Increment instead. Ids still start at 0.

* Do not play the progress bar sound for 0 points

With 0 points the score bars do not move, so the progress bar sound
started and stopped again right away, which could be heard as a short
click. Do not start it at all if the highest score is 0.
2026-10-16 05:21:34 +02:00