diff --git a/packages/ludic.update/latest.ludic b/packages/ludic.update/latest.ludic index bd7b0415..23d2ee28 100644 --- a/packages/ludic.update/latest.ludic +++ b/packages/ludic.update/latest.ludic @@ -37,8 +37,12 @@ export function update_latest(update_st: UpdateState) -> string { return update_ export function update_shown(update_st: UpdateState) -> bool { return update_st.update__ask == UPDATE_NEWER or update_st.update__ask == UPDATE_CURRENT } export function update_fresh(update_st: UpdateState) -> bool { return update_st.update__ask == UPDATE_NEWER } -# the notes in the language the game asked for (update_notes_for), else English, else none -export function update_notes(update_st: UpdateState, lang: string) -> []string { return update_st.update__notes_list } +# the notes update_notes_for last kept, for that language (else English); none for a language it was +# not asked for - a question makes nothing, so it cannot fill them itself +export function update_notes(update_st: UpdateState, lang: string) -> []string { + if lang != update_st.update__notes_lang { return update_st.update__notes_none } + return update_st.update__notes_list +} # the notes kept for this language: filled when the version or the language changes, so the panel # reading them every frame makes nothing diff --git a/packages/ludic.update/state.ludic b/packages/ludic.update/state.ludic index e425d4b9..86fbe25c 100644 --- a/packages/ludic.update/state.ludic +++ b/packages/ludic.update/state.ludic @@ -59,6 +59,7 @@ export state UpdateState { update__installed: bool = false # worked out when configured: the panel asks every frame @max(256) update__notes_list: []string = new []string # the notes in the language last asked, kept update__notes_lang: string = "" + update__notes_none: []string = new []string # update_notes for a language not kept: always empty, never pushed to update__notes_of: string = "" # ... for this version update__cfg: UpdateConfig = new UpdateConfig update__state: int = 0 diff --git a/packages/ludic.update/tests/update_test.ludic b/packages/ludic.update/tests/update_test.ludic index 2dfa30b4..d5b82137 100644 --- a/packages/ludic.update/tests/update_test.ludic +++ b/packages/ludic.update/tests/update_test.ludic @@ -63,6 +63,12 @@ program UpdateTest { System.run("rm -rf '" + dir() + "'") Fs.mkdir(dir()) Fs.mkdir(pkgs()) + configure(update_st, root) + update_reset(update_st) + } + # whether this copy was installed is worked out when the updater is configured, so a test that + # changes the disk or the executable's place configures again + function configure(update_st: mut UpdateState, root: bool) -> void { let c = new UpdateConfig c.feed = "http://feed" c.app_id = "Game" @@ -71,7 +77,6 @@ program UpdateTest { c.packages = pkgs() c.scratch = hashf() update_config(update_st, c) - update_reset(update_st) } function asset(ty: string, ver: string, size: int) -> string { @@ -116,8 +121,11 @@ program UpdateTest { update_check_tick(update_st, false) expect(update_fresh(update_st)) expect(update_latest(update_st) == "1.2.0") + update_notes_for(update_st, "tr") # the game's tick keeps them for its language expect_eq(len(update_notes(update_st, "tr")), 1) - expect_eq(len(update_notes(update_st, "de")), 2) + expect_eq(len(update_notes(update_st, "de")), 0) # not kept for German yet + update_notes_for(update_st, "de") + expect_eq(len(update_notes(update_st, "de")), 2) # no German: English } test "the version being played is shown only when asked" (update_st: mut UpdateState, update_test_st: mut UpdateTestState) { @@ -175,8 +183,10 @@ program UpdateTest { Fs.mkdir(dir() + "/Game.app/Contents") Fs.mkdir(dir() + "/Game.app/Contents/MacOS") Fs.write_text(dir() + "/Game.app/Contents/MacOS/UpdateMac", "x") + configure(update_st, false) expect(update_installed(update_st)) update_test_st.exe = "/private/var/folders/x/AppTranslocation/y/Game.app/Contents/MacOS/Game" + configure(update_st, false) expect(not update_installed(update_st)) }