diff --git a/installer/gui.py b/installer/gui.py index ac031400..217c681d 100644 --- a/installer/gui.py +++ b/installer/gui.py @@ -56,6 +56,9 @@ class App: self.screen = None root.title(self.cat('ui.title')) + icon = layout.runtime / 'totk.ico' + if os.name == 'nt' and icon.is_file(): + root.iconbitmap(default=str(icon)) root.minsize(680, 560) root.protocol('WM_DELETE_WINDOW', self.on_close) style = ttk.Style(root) diff --git a/installer/launcher/launcher.c b/installer/launcher/launcher.c index 0644234b..11994cd9 100644 --- a/installer/launcher/launcher.c +++ b/installer/launcher/launcher.c @@ -2,7 +2,8 @@ No console window. The two message strings come from the catalog (installer/text/.json, ids launcher.title and launcher.python_missing); tools/make_release.py writes them into launcher_text.h before it compiles this file. - Build: llvm/bin/clang -O2 -mwindows launcher.c -o TotK-Setup.exe */ + Build: llvm/bin/llvm-windres -I runtime -O coff launcher.rc -o launcher_rc.o, then + llvm/bin/clang -O2 -mwindows launcher.c launcher_rc.o -o TotK-Setup.exe */ #include #include diff --git a/installer/launcher/launcher.rc b/installer/launcher/launcher.rc new file mode 100644 index 00000000..f5288b09 --- /dev/null +++ b/installer/launcher/launcher.rc @@ -0,0 +1,3 @@ +/* The icon of TotK-Setup.exe: runtime/totk.ico, the icon of totk.exe. tools/make_release.py compiles this file with + llvm-windres -I runtime and links it with launcher.c. */ +1 ICON "totk.ico" diff --git a/installer/layout.py b/installer/layout.py index 42bb2544..80a5877b 100644 --- a/installer/layout.py +++ b/installer/layout.py @@ -6,7 +6,7 @@ Release (docs/installer.md "Release layout"), root = the unpacked folder: and ../recomp on sys.path, so `python -m installer` imports from the release folder recomp/, tools/ the lifter and the scripts; recomp/patches-v121.txt, tools/data/expected-v1.2.1.json llvm/ llvm-mingw (bin/clang.exe) - runtime/ libtotkrt.a, the headers and install-side sources (romfs.c); runtime/deps/ holds + runtime/ libtotkrt.a, the headers, install-side sources (romfs.c) and totk.ico; runtime/deps/ holds include/ + lib/ of Vulkan, SDL3, Opus, libvpx and VMA (build_game.py --deps) bin/ totk_xlate.exe (+ totk_xlate.id), hactool.exe, ninja.exe, SDL3.dll, libopus-0.dll data/shader_list.tsv the MacNativeGames shader list diff --git a/runtime/gfx_window.c b/runtime/gfx_window.c index c95fba94..9dfe8cab 100644 --- a/runtime/gfx_window.c +++ b/runtime/gfx_window.c @@ -340,7 +340,12 @@ static LRESULT CALLBACK wnd_proc(HWND h, UINT m, WPARAM w, LPARAM l) { static DWORD WINAPI window_main(void *arg) { (void)arg; HINSTANCE inst = GetModuleHandleW(NULL); + // Icon resource 1 of totk.rc (runtime/totk.ico): the title bar, the taskbar button and Alt+Tab. WNDCLASSEXW wc = {.cbSize = sizeof wc, .lpfnWndProc = wnd_proc, .hInstance = inst, + .hIcon = LoadImageW(inst, MAKEINTRESOURCEW(1), IMAGE_ICON, GetSystemMetrics(SM_CXICON), + GetSystemMetrics(SM_CYICON), LR_SHARED), + .hIconSm = LoadImageW(inst, MAKEINTRESOURCEW(1), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), + GetSystemMetrics(SM_CYSMICON), LR_SHARED), .hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW), .lpszClassName = L"TotKRecompWindow"}; RegisterClassExW(&wc); int cw, ch; diff --git a/runtime/totk.ico b/runtime/totk.ico new file mode 100644 index 00000000..610eec95 Binary files /dev/null and b/runtime/totk.ico differ diff --git a/runtime/totk.rc b/runtime/totk.rc index b26fe565..5739d292 100644 --- a/runtime/totk.rc +++ b/runtime/totk.rc @@ -1,3 +1,5 @@ -/* The application manifest of totk.exe (totk.manifest). tools/build_game.py compiles it with the runtime objects, so it - is also a member of libtotkrt.a, which the release links with --whole-archive. */ +/* The application manifest of totk.exe (totk.manifest) and its icon (totk.ico, also the icon of TotK-Setup.exe and of + the installer window). tools/build_game.py compiles it with the runtime objects, so it is also a member of + libtotkrt.a, which the release links with --whole-archive. */ 1 24 "totk.manifest" +1 ICON "totk.ico" diff --git a/tools/build_game.py b/tools/build_game.py index 107722fb..0b564e1d 100644 --- a/tools/build_game.py +++ b/tools/build_game.py @@ -281,7 +281,11 @@ def ninja_file(gen, out, mods, pool_depth, skip=(), prebuilt=False, runtime_lib= sources += [out / 'modules.c'] for src in sources: o = runtime_object(out, src) - lines.append(f'build {ninja_path(o)}: {"rc" if src.suffix == ".rc" else "cc_rt"} {ninja_path(src)}') + if src.suffix == '.rc': # windres writes no depfile: the files totk.rc embeds are listed by hand + lines.append(f'build {ninja_path(o)}: rc {ninja_path(src)} | {ninja_path(RUNTIME / "totk.manifest")} ' + f'{ninja_path(RUNTIME / "totk.ico")}') + else: + lines.append(f'build {ninja_path(o)}: cc_rt {ninja_path(src)}') rt.append(o) objs['runtime'] = rt every = [o for v in objs.values() for o in v] diff --git a/tools/make_release.py b/tools/make_release.py index c15f7a15..0f945379 100644 --- a/tools/make_release.py +++ b/tools/make_release.py @@ -97,7 +97,7 @@ LLVM_SKIP_SUFFIXES = {'.idl', '.tlb'} TOOLS_FILES = ['build_game.py', 'check_content.py', 'extract.py', 'make_romfs_patches.py', 'prepare_shaders.py', 'romfs_index.py', 'shader_census.py'] TOOLS_DIRS = ['vendor/macnativegames', 'data'] # data/: expected hashes -RUNTIME_SUFFIXES = {'.h', '.inc'} +RUNTIME_SUFFIXES = {'.h', '.inc', '.ico'} # .ico: the installer window icon PROBES = ['--probe-kernel', '--probe-vkexec', '--probe-nvn-tex', '--probe-shader'] @@ -393,8 +393,12 @@ def launcher_header(path): def build_launcher(out, llvm): work = MAIN_ROOT / 'build' / 'release-check' / 'launcher' launcher_header(work / 'launcher_text.h') + env = clean_env(llvm / 'bin') + res = work / 'launcher_rc.o' + run([llvm / 'bin' / 'llvm-windres.exe', '-I', ROOT / 'runtime', '-O', 'coff', + ROOT / 'installer' / 'launcher' / 'launcher.rc', '-o', res], env=env) run([llvm / 'bin' / 'clang.exe', '-O2', '-mwindows', '-Wall', '-Wl,-s', '-I', work, - ROOT / 'installer' / 'launcher' / 'launcher.c', '-o', out / 'TotK-Setup.exe'], env=clean_env(llvm / 'bin')) + ROOT / 'installer' / 'launcher' / 'launcher.c', res, '-o', out / 'TotK-Setup.exe'], env=env) # ---- checks ----------------------------------------------------------------------------------------------------------