song select: refresh a folder's song count text when the count changes #10

Merged
Yonokid merged 1 commits from GanYiZhong/PyTaikoGreen:fix/folder-count-refresh into main 2026-10-05 13:45:22 +02:00
@@ -15,8 +15,14 @@ local function is_2p_screen()
return (tex.current_screen and tex.current_screen() or "") == "SONG_SELECT_2P"
end
local function make_count_text(count)
local count_cfg = tex.get_skin_config("song_tja_count") or { font_size = 35 }
return text.create_raw_text(base.format_song_count(count), count_cfg.font_size or 35, WHITE, BLACK, false, 5.0, 2.0, 1.0)
end
-- Folder text objects (hori_name, tja_count_text, explanation) from FolderBox::load_text,
-- cached per box on self.
-- cached per box on self. The song count is filled in by a background scan after the box is
-- first drawn, so its text is rebuilt whenever the count changes (it stayed at 0 otherwise).
local function folder_texts(self, box)
self._folder_texts = self._folder_texts or {}
local key = box:path()
@@ -27,8 +33,8 @@ local function folder_texts(self, box)
local hori_cfg = tex.get_skin_config("song_hori_name") or { font_size = 40 }
local hori_name = text.create_raw_text(name, hori_cfg.font_size or 40, WHITE, BLACK, false, 5.0, 2.0, 1.0)
local count_cfg = tex.get_skin_config("song_tja_count") or { font_size = 35 }
local tja_count_text = text.create_raw_text(base.format_song_count(box.tja_count or 0), count_cfg.font_size or 35, WHITE, BLACK, false, 5.0, 2.0, 1.0)
local count = box.tja_count or 0
local tja_count_text = make_count_text(count)
local explanation = box:explanation() or {}
local exp_cfg = tex.get_skin_config("box_folder_explanation") or { font_size = 34 }
@@ -47,8 +53,14 @@ local function folder_texts(self, box)
end
end
t = { hori_name = hori_name, tja_count_text = tja_count_text, explanation = exp_texts }
t = { hori_name = hori_name, tja_count_text = tja_count_text, count = count, explanation = exp_texts }
self._folder_texts[key] = t
else
local count = box.tja_count or 0
if count ~= t.count then
t.tja_count_text = make_count_text(count)
t.count = count
end
end
return t
end