diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..6e8bf73a --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0 diff --git a/docs/installer.md b/docs/installer.md index 5b5a1ee3..bad63116 100644 --- a/docs/installer.md +++ b/docs/installer.md @@ -96,7 +96,7 @@ runtime/ libtotkrt.a and the headers the generated code and modules bin/ totk_xlate.exe, hactool.exe, SDL3.dll, libopus-0.dll, ninja.exe data/ shader_list.tsv (MacNativeGames, MIT) THIRD_PARTY_NOTICES.md -totk.ini.example, VERSION the default ini; the release string (git describe of the build) +totk.ini.example, VERSION the default ini; the release string (the repository's VERSION plus the commit) ``` - SDL3 comes from the upstream release, not MSYS2: MSYS2's DLL imports the LGPL libiconv. diff --git a/installer/gui.py b/installer/gui.py index 0d9fbd16..391918de 100644 --- a/installer/gui.py +++ b/installer/gui.py @@ -65,11 +65,15 @@ class App: style.configure('Title.TLabel', font=('Segoe UI', 15, 'bold')) style.configure('Notice.TLabel', background='#fff3cd', foreground='#664d03', padding=8) style.configure('Err.TLabel', foreground='#c01c28') + style.configure('Version.TLabel', foreground='#808080') top = ttk.Frame(root, padding=(PAD, PAD, PAD, 0)) top.pack(fill='x') self.title = self.label(top, 'ui.title', style='Title.TLabel') self.title.pack(side='left') + version = ttk.Label(top, style='Version.TLabel') + self.bind_text(version, 'text', 'ui.version', version=layout.release) + version.pack(side='left', padx=(10, 0), pady=(6, 0)) sw = ttk.Frame(top) sw.pack(side='right') self.ui_var = tk.StringVar(value=self.cat.lang) diff --git a/installer/layout.py b/installer/layout.py index c36250c0..655c7c22 100644 --- a/installer/layout.py +++ b/installer/layout.py @@ -19,7 +19,7 @@ Dev mode, root = a repository checkout (no python/python.exe): build/py314-embed Python the release ships, with the same packages), else this Python; toolchain/llvm-mingw-*/ and toolchain/deps-mingw; runtime/ as the sources with build/install-rtlib/libtotkrt.a (tools/build_game.py --make-runtime-lib --out build/install-rtlib); MSYS2 UCRT64 ninja.exe; toolchain/hactool; build/xlate/totk_xlate.exe; the shader list from -refs/MacNativeGames; build/install-temp. The version is dev-. +refs/MacNativeGames; build/install-temp. The version is VERSION with -dev and the commit: 0.1.0-dev+973c626. """ import os import subprocess @@ -105,8 +105,9 @@ def dev_layout(root): embed = root / 'build' / 'py314-embed' / 'py' / ('python' + EXE) trees = sorted(p.parent.parent for p in (root / 'toolchain').glob('llvm-mingw-*/llvm-mingw-*/bin/clang' + EXE)) deps = root / 'toolchain' / 'deps-mingw' + semver = (root / 'VERSION').read_text(encoding='utf-8').strip() return Layout( - root=root, dev=True, release=f'dev-{commit or "unknown"}', + root=root, dev=True, release=f'{semver}-dev+{commit or "unknown"}', python=embed if embed.is_file() else Path(sys.executable), tools=root / 'tools', recomp=root / 'recomp', llvm=trees[-1] if trees else root / 'toolchain' / 'llvm-mingw-missing', deps=deps, diff --git a/installer/text/en.json b/installer/text/en.json index d4a16971..92c24197 100644 --- a/installer/text/en.json +++ b/installer/text/en.json @@ -81,6 +81,7 @@ "warn.npdm_differs": "main.npdm differs from the reference {version} dump; only the code modules are used.", "ui.title": "TotK Setup", + "ui.version": "version {version}", "ui.intro": "Builds a playable Tears of the Kingdom folder from your own game files. This takes a while and runs once.", "ui.notice": "The folder this setup builds contains the game. It is for your own use only; do not share or upload it.", "ui.keys_private": "The keys file is read in place. Its contents are never shown, copied or stored.", diff --git a/installer/text/ru.json b/installer/text/ru.json index a1c5dee2..ad3e9666 100644 --- a/installer/text/ru.json +++ b/installer/text/ru.json @@ -81,6 +81,7 @@ "warn.npdm_differs": "main.npdm отличается от эталонного дампа {version}; используются только модули с кодом.", "ui.title": "Установка TotK", + "ui.version": "версия {version}", "ui.intro": "Собирает готовую к запуску папку с Tears of the Kingdom из ваших игровых файлов. Занимает много времени и выполняется один раз.", "ui.notice": "Папка, которую создаёт установка, содержит игру. Она предназначена только для личного использования: не передавайте и не выкладывайте её.", "ui.keys_private": "Файл ключей читается на месте. Его содержимое не показывается, не копируется и не сохраняется.", diff --git a/runtime/host.h b/runtime/host.h index a8919153..237c6ad0 100644 --- a/runtime/host.h +++ b/runtime/host.h @@ -171,6 +171,7 @@ extern const RtFileHash rt_exefs_sha256[]; // tools/data/expecte extern const int rt_exefs_sha256_count; extern const char rt_default_exefs[], rt_default_romfs[], rt_default_profile[]; extern const int rt_game_version; // the game build: 121 (1.2.1) or 143 (1.4.3) +extern const char rt_port_version[]; // VERSION at the build's root: 0.1.0, 0.1.0+973c626 in a release #define RT_V143 (rt_game_version >= 143) // ---- kernel (kernel.c) diff --git a/runtime/ui/menu.cpp b/runtime/ui/menu.cpp index db50bcda..2cdf8484 100644 --- a/runtime/ui/menu.cpp +++ b/runtime/ui/menu.cpp @@ -36,6 +36,8 @@ void vk_queue_lock(void); void vk_queue_unlock(void); void res_sizes(unsigned out[2], unsigned scene[2]); double frame_step_limit_hz(void); +extern const int rt_game_version; +extern const char rt_port_version[]; } // Roboto Medium (Apache-2.0, ui/fonts/LICENSE-Roboto.txt) with Latin and Cyrillic glyphs. @@ -735,6 +737,12 @@ static void layout_menu(uint32_t w, uint32_t h, float scale) { ImGui::Begin("##menu", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings); ImGui::TextColored(ImVec4(0.93f, 0.76f, 0.33f, 1), "%s", menu_text(UI_MENU_TITLE)); + // the port version and the game update, right-aligned on the title line: what a bug report needs first + char game[16], version[96]; + snprintf(game, sizeof game, "%d.%d.%d", rt_game_version / 100, rt_game_version / 10 % 10, rt_game_version % 10); + snprintf(version, sizeof version, menu_text(UI_MENU_VERSION), rt_port_version, game); + ImGui::SameLine(ImGui::GetWindowWidth() - ImGui::GetStyle().WindowPadding.x - ImGui::CalcTextSize(version).x); + ImGui::TextDisabled("%s", version); int step = g_modal ? 0 : ImGui::IsKeyPressed(ImGuiKey_GamepadR1, false) || ImGui::IsKeyPressed(ImGuiKey_E, false) ? 1 diff --git a/runtime/ui_text.c b/runtime/ui_text.c index e4bf5696..c9016606 100644 --- a/runtime/ui_text.c +++ b/runtime/ui_text.c @@ -33,6 +33,7 @@ static const char *const text_en[UI_TEXT_COUNT] = { [UI_MENU_ON] = "On", [UI_MENU_OFF] = "Off", [UI_MENU_AUTO] = "Automatic", [UI_MENU_DEFAULT_MARK] = "default", [UI_MENU_AFTER_RESTART] = "after restart", [UI_MENU_SET_BY_ENV] = "set by environment variable", [UI_MENU_SAVE_FAILED] = "could not save settings", + [UI_MENU_VERSION] = "TotK Recomp %s, game %s", [UI_MENU_FULLSCREEN] = "Fullscreen", [UI_MENU_FULLSCREEN_DESC] = "Fills the screen with the game; F11 toggles it.", [UI_MENU_WINDOW_SIZE] = "Window size", [UI_MENU_WINDOW_SIZE_DESC] = "Size of the game window when not fullscreen.", @@ -198,6 +199,7 @@ static const char *const text_ru[UI_TEXT_COUNT] = { [UI_MENU_DEFAULT_MARK] = "по умолчанию", [UI_MENU_AFTER_RESTART] = "после перезапуска", [UI_MENU_SET_BY_ENV] = "задано переменной окружения", [UI_MENU_SAVE_FAILED] = "не удалось сохранить настройки", + [UI_MENU_VERSION] = "TotK Recomp %s, игра %s", [UI_MENU_FULLSCREEN] = "Полный экран", [UI_MENU_FULLSCREEN_DESC] = "Игра на весь экран; F11 переключает режим.", [UI_MENU_WINDOW_SIZE] = "Размер окна", [UI_MENU_WINDOW_SIZE_DESC] = "Размер окна игры вне полноэкранного режима.", diff --git a/runtime/ui_text.h b/runtime/ui_text.h index 73506bec..0ec5693f 100644 --- a/runtime/ui_text.h +++ b/runtime/ui_text.h @@ -21,6 +21,7 @@ typedef enum { UI_MENU_AFTER_RESTART, // note on a setting that is read at start UI_MENU_SET_BY_ENV, // note on a setting an environment variable fixes UI_MENU_SAVE_FAILED, + UI_MENU_VERSION, // "TotK Recomp %s, game %s": the port version and the game update, beside the title // Screen UI_MENU_FULLSCREEN, UI_MENU_FULLSCREEN_DESC, diff --git a/tools/build_game.py b/tools/build_game.py index ec488c23..bf3a3d95 100644 --- a/tools/build_game.py +++ b/tools/build_game.py @@ -217,10 +217,17 @@ def module_glue(layout, linked, hashes, paths, version): for name in ('exefs', 'romfs', 'profile'): out.append(f'const char rt_default_{name}[] = {c_string(paths[name].as_posix())};') number = int(DISPLAY_VERSIONS[version].replace('.', '')) if version in DISPLAY_VERSIONS else 0 # 1.4.3 -> 143 - out += [f'const int rt_game_version = {number};', ''] + out += [f'const int rt_game_version = {number};', f'const char rt_port_version[] = {c_string(port_version())};', ''] return '\n'.join(out) +def port_version(): + """VERSION at the root: the repository's semver, or in a release folder the release string (make_release.py + version).""" + path = ROOT / 'VERSION' + return path.read_text(encoding='utf-8').strip() if path.is_file() else 'unknown' + + def ninja_file(gen, out, mods, pool_depth, skip=(), prebuilt=False, runtime_lib=None, make_lib=False): """build.ninja text, and the object lists per module. With prebuilt the generated objects already exist in out/obj and are link inputs without a compile edge. runtime_lib: a prebuilt library replaces the runtime objects diff --git a/tools/make_release.py b/tools/make_release.py index 9e8442d2..4489c8d8 100644 --- a/tools/make_release.py +++ b/tools/make_release.py @@ -14,7 +14,7 @@ cached in toolchain/release-dl/ and checked against the sha256 in PINS; a mismat ov_zstd.c (compiled per install), deps/ (headers and import libraries of SDL3, Opus, libvpx, Vulkan and VMA) bin/ totk_xlate.exe (+ .id), hactool.exe, SDL3.dll (upstream), libopus-0.dll, ninja.exe recomp/, tools/, data/, installer/, licenses/, THIRD_PARTY_NOTICES.md, totk.ini.example - VERSION git describe of the checkout (else the short hash); the installer's release string + VERSION the repository's VERSION plus the commit, 0.1.0+973c626; the installer's release string TotK-Setup.exe installer/launcher/launcher.c built with llvm/ (-mwindows): starts python/pythonw.exe -m installer.gui --prove compiles generated/v121 and links build/release-check/totk.exe with nothing but the folder's python/, llvm/, @@ -362,12 +362,12 @@ def build_sources(out): def version(): - """git describe of the checkout, else its short hash.""" - for args in (['describe', '--tags', '--always'], ['rev-parse', '--short', 'HEAD']): - r = subprocess.run(['git', '-C', ROOT, *args], capture_output=True, text=True) - if r.returncode == 0 and r.stdout.strip(): - return r.stdout.strip() - sys.exit('no git version: not a git checkout') + """The port version from VERSION with the commit as build metadata: 0.1.0+973c626. The commit keeps two releases of + one version apart, so the installer reruns the steps an earlier release made.""" + r = subprocess.run(['git', '-C', ROOT, 'rev-parse', '--short', 'HEAD'], capture_output=True, text=True) + if r.returncode or not r.stdout.strip(): + sys.exit('no git version: not a git checkout') + return (ROOT / 'VERSION').read_text(encoding='utf-8').strip() + '+' + r.stdout.strip() # ---- TotK-Setup.exe --------------------------------------------------------------------------------------------------