Launcher sous Linux : plat.rs (processus, dossiers, dialogues, corbeille, ISO, zip), X11 et Wayland

- plat.rs regroupe ce qui dépend du système ; Windows garde son fonctionnement (cmd, PowerShell, explorer) ;
  Linux : sh avec groupe de processus (Arrêter), zenity/kdialog, xdg-open, gio trash, udisksctl, zip
- réglages dans $XDG_CONFIG_HOME/DoubleTroubleRecomp (même dossier que le jeu), TUCKER.EXE à la casse près
- prérequis Linux : zig-linux, dtr-recomp, en-têtes et libSDL2, libGL ; bouton Installer (pkexec, commande
  affichée avant) ; compilation par sh build_zig.sh ; DTR_ROOT pour l'AppImage
- Steam Deck : défauts plein écran et filtre lissé, comme le jeu ; pas de musique hors de Windows
- eframe : fonctions x11 et wayland sous Linux seulement (accord de l'utilisateur, crates MIT/Apache)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
linkatplugandClaude Opus 5.5 committed 2026-12-06 11:56:48 +01:00
1 parent 90569fdde6
commit f20f390bf1
12 files changed
+1072 -163

No files matched your search

+442 -8
View File
@@ -73,6 +73,7 @@ dependencies = [
"parking_lot",
"percent-encoding",
"windows-sys 0.61.2",
"wl-clipboard-rs",
"x11rb",
]
@@ -82,6 +83,12 @@ version = "0.7.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47a64a0fd06e123e9e3cf3ad01432af17dcab8185e8023edcf184fe696f9675d"
[[package]]
name = "as-raw-xcb-connection"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b"
[[package]]
name = "atomic-waker"
version = "1.1.2"
@@ -94,6 +101,21 @@ version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
[[package]]
name = "bit-set"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2f926cc3060f09db9ebc5b52823d85268d24bb917e472c0c4bea35780a7d"
dependencies = [
"bit-vec",
]
[[package]]
name = "bit-vec"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b71798fca2c1fe1086445a7258a4bc81e6e49dcd24c8d0dd9a1e57395b603f51"
[[package]]
name = "bitflags"
version = "1.3.2"
@@ -188,6 +210,18 @@ dependencies = [
"tracing",
]
[[package]]
name = "calloop-wayland-source"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95a66a987056935f7efce4ab5668920b5d0dac4a7c99991a67395f13702ddd20"
dependencies = [
"calloop 0.13.0",
"rustix 0.38.44",
"wayland-backend",
"wayland-client",
]
[[package]]
name = "calloop-wayland-source"
version = "0.4.1"
@@ -242,6 +276,15 @@ dependencies = [
"error-code",
]
[[package]]
name = "codespan-reporting"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681"
dependencies = [
"unicode-width",
]
[[package]]
name = "color"
version = "0.3.3"
@@ -422,6 +465,7 @@ dependencies = [
"bytemuck",
"document-features",
"egui",
"egui-wgpu",
"egui-winit",
"egui_glow",
"glow",
@@ -466,6 +510,26 @@ dependencies = [
"web-sys",
]
[[package]]
name = "egui-wgpu"
version = "0.38.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa5855839e41b3c9728fe509daa35e0c4f765216d60f93eef9c5b48290eaf63e"
dependencies = [
"ahash",
"bytemuck",
"document-features",
"egui",
"epaint",
"log",
"profiling",
"thiserror 2.0.21",
"type-map",
"web-time",
"wgpu",
"winit",
]
[[package]]
name = "egui-winit"
version = "0.38.0"
@@ -501,6 +565,7 @@ dependencies = [
"glow",
"log",
"profiling",
"winit",
]
[[package]]
@@ -619,6 +684,12 @@ version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f35b0b9b788e7109a8eb0607f5c8a13495edee3ef8e246f60f0664a7cd25b277"
[[package]]
name = "fixedbitset"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5905ec755cc8386d7928353e4d356d2be3e89e81e5ca01fe630a1ca4d08dc175"
[[package]]
name = "flate2"
version = "1.1.11"
@@ -630,6 +701,12 @@ dependencies = [
"zlib-rs",
]
[[package]]
name = "foldhash"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]]
name = "foldhash"
version = "0.2.0"
@@ -746,8 +823,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ae2e3b09ea1cc45c994a405e4d4154901d4caa867d3e1be3a02be641f62fefa"
dependencies = [
"bytemuck",
"foldhash",
"hashbrown",
"foldhash 0.2.0",
"hashbrown 0.17.2",
"log",
"peniko",
"skrifa",
@@ -778,6 +855,7 @@ dependencies = [
"cgl",
"dispatch2",
"glutin_egl_sys",
"glutin_glx_sys",
"glutin_wgl_sys",
"libloading",
"objc2 0.6.5",
@@ -786,7 +864,9 @@ dependencies = [
"objc2-foundation 0.3.2",
"once_cell",
"raw-window-handle",
"wayland-sys",
"windows-sys 0.52.0",
"x11-dl",
]
[[package]]
@@ -811,6 +891,16 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "glutin_glx_sys"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a7bb2938045a88b612499fbcba375a77198e01306f52272e692f8c1f3751185"
dependencies = [
"gl_generator",
"x11-dl",
]
[[package]]
name = "glutin_wgl_sys"
version = "0.6.1"
@@ -837,6 +927,7 @@ checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b"
dependencies = [
"cfg-if",
"crunchy",
"num-traits",
"zerocopy",
]
@@ -853,13 +944,22 @@ dependencies = [
"yoke",
]
[[package]]
name = "hashbrown"
version = "0.15.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
dependencies = [
"foldhash 0.1.5",
]
[[package]]
name = "hashbrown"
version = "0.17.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "735eaa21a6a5ffb2e84362faaeb90c05ba8e19797ca30428478cb6ea3a4921bc"
dependencies = [
"foldhash",
"foldhash 0.2.0",
]
[[package]]
@@ -993,7 +1093,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
dependencies = [
"equivalent",
"hashbrown",
"hashbrown 0.17.2",
]
[[package]]
@@ -1118,6 +1218,12 @@ dependencies = [
"windows-link 0.2.1",
]
[[package]]
name = "libm"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
[[package]]
name = "libredox"
version = "0.1.25"
@@ -1220,6 +1326,43 @@ dependencies = [
"pxfm",
]
[[package]]
name = "naga"
version = "30.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd0dd362bf26c0ffdd143df6da66a25d287e196eff482f117771010b207ad163"
dependencies = [
"arrayvec",
"bit-set",
"bitflags 2.13.2",
"cfg-if",
"cfg_aliases",
"codespan-reporting",
"half",
"hashbrown 0.17.2",
"indexmap",
"libm",
"log",
"naga-types",
"num-traits",
"once_cell",
"rustc-hash 1.1.0",
"thiserror 2.0.21",
"unicode-ident",
]
[[package]]
name = "naga-types"
version = "30.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14474170feb673cfb18b3565111a9869797cc1d290fb9ec969c53f5e1e231c6d"
dependencies = [
"hashbrown 0.17.2",
"indexmap",
"rustc-hash 1.1.0",
"thiserror 2.0.21",
]
[[package]]
name = "ndk"
version = "0.9.0"
@@ -1256,6 +1399,15 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
[[package]]
name = "nom"
version = "8.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405"
dependencies = [
"memchr",
]
[[package]]
name = "num-traits"
version = "0.2.19"
@@ -1263,6 +1415,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [
"autocfg",
"libm",
]
[[package]]
@@ -1588,6 +1741,16 @@ dependencies = [
"libredox",
]
[[package]]
name = "os_pipe"
version = "1.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54a351c59c9045dfd196da7bc84279dbe6d891c2fc0bb19b988de169dd60f1c9"
dependencies = [
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "parking_lot"
version = "0.12.5"
@@ -1630,6 +1793,17 @@ version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
[[package]]
name = "petgraph"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455"
dependencies = [
"fixedbitset",
"hashbrown 0.15.5",
"indexmap",
]
[[package]]
name = "pin-project"
version = "1.2.0"
@@ -1704,6 +1878,21 @@ dependencies = [
"arrayvec",
]
[[package]]
name = "portable-atomic"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
[[package]]
name = "portable-atomic-util"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715"
dependencies = [
"portable-atomic",
]
[[package]]
name = "potential_utf"
version = "0.1.6"
@@ -1786,7 +1975,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdaa4fffe9ff3ca2c353fa9729792805b9b3e324695ff5a081f860612e81b330"
dependencies = [
"bytemuck",
"foldhash",
"foldhash 0.2.0",
"font-types",
"once_cell",
"smallvec",
@@ -1820,6 +2009,24 @@ dependencies = [
"bitflags 2.13.2",
]
[[package]]
name = "renderdoc-sys"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832"
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustc-hash"
version = "2.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca420ddf5554e546a707e0ecb8bd311d505ee00b40982a7064b8bdc48aa59336"
[[package]]
name = "rustc_version"
version = "0.4.1"
@@ -1991,6 +2198,31 @@ version = "1.16.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3244542535d5de959d90ec55d1b5ff0fd2bb7b1310223907d5f11932847f7b59"
[[package]]
name = "smithay-client-toolkit"
version = "0.19.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016"
dependencies = [
"bitflags 2.13.2",
"calloop 0.13.0",
"calloop-wayland-source 0.3.0",
"cursor-icon",
"libc",
"log",
"memmap2",
"rustix 0.38.44",
"thiserror 1.0.69",
"wayland-backend",
"wayland-client",
"wayland-csd-frame",
"wayland-cursor",
"wayland-protocols",
"wayland-protocols-wlr",
"wayland-scanner",
"xkeysym",
]
[[package]]
name = "smithay-client-toolkit"
version = "0.20.0"
@@ -1999,7 +2231,7 @@ checksum = "0512da38f5e2b31201a93524adb8d3136276fa4fe4aafab4e1f727a82b534cc0"
dependencies = [
"bitflags 2.13.2",
"calloop 0.14.5",
"calloop-wayland-source",
"calloop-wayland-source 0.4.1",
"cursor-icon",
"libc",
"log",
@@ -2025,7 +2257,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71704c03f739f7745053bde45fa203a46c58d25bc5c4efba1d9a60e9dba81226"
dependencies = [
"libc",
"smithay-client-toolkit",
"smithay-client-toolkit 0.20.0",
"wayland-backend",
]
@@ -2203,6 +2435,26 @@ version = "0.1.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a"
[[package]]
name = "tree_magic_mini"
version = "3.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8765b90061cba6c22b5831f675da109ae5561588290f9fa2317adab2714d5a6"
dependencies = [
"memchr",
"nom",
"petgraph",
]
[[package]]
name = "type-map"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb30dbbd9036155e74adad6812e9898d03ec374946234fbcebd5dfc7b9187b90"
dependencies = [
"rustc-hash 2.1.4",
]
[[package]]
name = "unicode-general-category"
version = "1.1.0"
@@ -2227,6 +2479,12 @@ version = "1.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"
[[package]]
name = "unicode-width"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca718471876992059f251e33aafc334346ada08042b7661dd1fe313a9bced557"
[[package]]
name = "url"
version = "2.5.9"
@@ -2286,7 +2544,7 @@ dependencies = [
"fearless_simd",
"fearless_simd_macros",
"glifo",
"hashbrown",
"hashbrown 0.17.2",
"vello_common",
]
@@ -2447,6 +2705,19 @@ dependencies = [
"wayland-scanner",
]
[[package]]
name = "wayland-protocols-plasma"
version = "0.3.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b6d8cf1eb2c1c31ed1f5643c88a6e53538129d4af80030c8cabd1f9fa884d91"
dependencies = [
"bitflags 2.13.2",
"wayland-backend",
"wayland-client",
"wayland-protocols",
"wayland-scanner",
]
[[package]]
name = "wayland-protocols-wlr"
version = "0.3.12"
@@ -2525,6 +2796,125 @@ version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88"
[[package]]
name = "wgpu"
version = "30.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "146fc3d654250e6207921a66c87534c621bc886c70df83dcf466c1d66813810e"
dependencies = [
"arrayvec",
"bitflags 2.13.2",
"bytemuck",
"cfg-if",
"cfg_aliases",
"document-features",
"hashbrown 0.17.2",
"js-sys",
"log",
"portable-atomic",
"profiling",
"raw-window-handle",
"smallvec",
"static_assertions",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"wgpu-core",
"wgpu-hal",
"wgpu-types",
]
[[package]]
name = "wgpu-core"
version = "30.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad661da2ee99f208c30090b585284b2ab5b8bf2358ddf2d2215592808ec62f1a"
dependencies = [
"arrayvec",
"bit-set",
"bit-vec",
"bitflags 2.13.2",
"bytemuck",
"cfg_aliases",
"document-features",
"hashbrown 0.17.2",
"indexmap",
"log",
"naga",
"naga-types",
"once_cell",
"parking_lot",
"portable-atomic",
"profiling",
"raw-window-handle",
"rustc-hash 1.1.0",
"smallvec",
"thiserror 2.0.21",
"wgpu-core-deps-windows-linux-android",
"wgpu-hal",
"wgpu-naga-bridge",
"wgpu-types",
]
[[package]]
name = "wgpu-core-deps-windows-linux-android"
version = "30.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1331b08fa2362c5d454eccc4448e6e4f01eccfea569a00e310adbfc4415f2bdc"
dependencies = [
"wgpu-hal",
]
[[package]]
name = "wgpu-hal"
version = "30.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a57452fe453658e141aafdb09de1028afa498805fab518238ddf372a518813ff"
dependencies = [
"bitflags 2.13.2",
"cfg-if",
"cfg_aliases",
"hashbrown 0.17.2",
"libloading",
"log",
"naga",
"naga-types",
"portable-atomic",
"portable-atomic-util",
"raw-window-handle",
"renderdoc-sys",
"static_assertions",
"thiserror 2.0.21",
"wgpu-naga-bridge",
"wgpu-types",
]
[[package]]
name = "wgpu-naga-bridge"
version = "30.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44a62ead68aad7cd40ac9e2cd2b8ec64f32dfbad2765f429b9fb74b8b735869f"
dependencies = [
"naga",
"wgpu-types",
]
[[package]]
name = "wgpu-types"
version = "30.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9f6ee0bd50f5ab79fb8c25e3f33afb27126f034af4ba5909c7a0967058659e6"
dependencies = [
"bitflags 2.13.2",
"bytemuck",
"js-sys",
"log",
"naga-types",
"raw-window-handle",
"static_assertions",
"web-sys",
]
[[package]]
name = "winapi-util"
version = "0.1.11"
@@ -2652,10 +3042,12 @@ version = "0.30.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6755fa58a9f8350bd1e472d4c3fcc25f824ec358933bba33306d0b63df5978d"
dependencies = [
"ahash",
"android-activity",
"atomic-waker",
"bitflags 2.13.2",
"block2 0.5.1",
"bytemuck",
"calloop 0.13.0",
"cfg_aliases",
"concurrent-queue",
@@ -2665,24 +3057,33 @@ dependencies = [
"dpi",
"js-sys",
"libc",
"memmap2",
"ndk",
"objc2 0.5.3",
"objc2-app-kit 0.2.2",
"objc2-foundation 0.2.2",
"objc2-ui-kit 0.2.2",
"orbclient",
"percent-encoding",
"pin-project",
"raw-window-handle",
"redox_syscall 0.4.1",
"rustix 0.38.44",
"smithay-client-toolkit 0.19.2",
"smol_str",
"tracing",
"unicode-segmentation",
"wasm-bindgen",
"wasm-bindgen-futures",
"wayland-backend",
"wayland-client",
"wayland-protocols",
"wayland-protocols-plasma",
"web-sys",
"web-time",
"windows-sys 0.52.0",
"x11-dl",
"x11rb",
"xkbcommon-dl",
]
@@ -2695,19 +3096,52 @@ dependencies = [
"memchr",
]
[[package]]
name = "wl-clipboard-rs"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "959c7ac3b8afde864f7a7448ac16f29b2b83350b7eccbf77fb781c3999aa6848"
dependencies = [
"libc",
"log",
"os_pipe",
"rustix 1.1.6",
"thiserror 2.0.21",
"tree_magic_mini",
"wayland-backend",
"wayland-client",
"wayland-protocols",
"wayland-protocols-wlr",
]
[[package]]
name = "writeable"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc"
[[package]]
name = "x11-dl"
version = "2.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f"
dependencies = [
"libc",
"once_cell",
"pkg-config",
]
[[package]]
name = "x11rb"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9993aa5be5a26815fe2c3eacfc1fde061fc1a1f094bf1ad2a18bf9c495dd7414"
dependencies = [
"as-raw-xcb-connection",
"gethostname",
"libc",
"libloading",
"once_cell",
"rustix 1.1.6",
"x11rb-protocol",
]
+3
View File
@@ -19,3 +19,6 @@ eframe = { version = "0.38", default-features = false, features = ["glow", "defa
opt-level = 3
lto = "thin"
strip = true
[target.'cfg(target_os = "linux")'.dependencies]
eframe = { version = "0.38", default-features = false, features = ["x11", "wayland"] }
+6
View File
@@ -268,3 +268,9 @@ Compilation par MSVC (build.bat). Built with MSVC (build.bat). Kompiliert mit MS
Première compilation avec zig : environ une minute (bibliothèque C préparée une fois pour toutes), ensuite moins de 10 secondes. First build with zig: about one minute (C library prepared once and for all), then under 10 seconds. Erste Kompilierung mit zig: etwa eine Minute (C-Bibliothek wird einmalig vorbereitet), danach unter 10 Sekunden. Primera compilación con zig: alrededor de un minuto (la biblioteca C se prepara una sola vez), después menos de 10 segundos. Pierwsza kompilacja przez zig: około minuty (biblioteka C przygotowywana raz na zawsze), potem poniżej 10 sekund.
Versions publiées (GitHub) Published versions (GitHub) Veröffentlichte Versionen (GitHub) Versiones publicadas (GitHub) Opublikowane wersje (GitHub)
Créer ou exporter des images demande encore Python 3, absent de ce PC. Le jeu et les packs déjà faits n'en ont pas besoin. Creating or exporting pictures still needs Python 3, which is not on this PC. The game and ready-made packs don't need it. Bilder erstellen oder exportieren erfordert noch Python 3, das auf diesem PC fehlt. Das Spiel und fertige Pakete brauchen es nicht. Crear o exportar imágenes aún requiere Python 3, que no está en este PC. El juego y los paquetes ya hechos no lo necesitan. Tworzenie lub eksport obrazów wciąż wymaga Pythona 3, którego nie ma na tym PC. Gra i gotowe paczki go nie potrzebują.
# launcher sous Linux
absente du système missing from the system fehlt im System no está en el sistema brak w systemie
Il manque SDL2 ou OpenGL. Le bouton lance cette commande, après votre mot de passe : SDL2 or OpenGL is missing. The button runs this command, after your password: SDL2 oder OpenGL fehlt. Die Schaltfläche führt diesen Befehl nach Ihrem Passwort aus: Falta SDL2 u OpenGL. El botón ejecuta este comando, tras su contraseña: Brakuje SDL2 lub OpenGL. Przycisk uruchomi to polecenie po podaniu hasła:
Installer… Install… Installieren… Instalar… Zainstaluj…
Ni zenity ni kdialog : tapez le chemin du dossier du jeu dans la case ci-dessus. Neither zenity nor kdialog: type the game folder's path in the box above. Weder zenity noch kdialog: Geben Sie den Pfad des Spielordners oben in das Feld ein. Ni zenity ni kdialog: escriba la ruta de la carpeta del juego en la casilla de arriba. Brak zenity i kdialog: wpisz ścieżkę folderu gry w polu powyżej.
Compilation par zig (build_zig.sh). Built with zig (build_zig.sh). Kompiliert mit zig (build_zig.sh). Se compila con zig (build_zig.sh). Kompilacja przez zig (build_zig.sh).
1 # Traductions du launcher : voir src/i18n.rs. Colonnes : fr (clé, comme dans le code), en, de, es, pl.
268 Première compilation avec zig : environ une minute (bibliothèque C préparée une fois pour toutes), ensuite moins de 10 secondes.
269 Versions publiées (GitHub)
270 Créer ou exporter des images demande encore Python 3, absent de ce PC. Le jeu et les packs déjà faits n'en ont pas besoin.
271 # launcher sous Linux
272 absente du système
273 Il manque SDL2 ou OpenGL. Le bouton lance cette commande, après votre mot de passe :
274 Installer…
275 Ni zenity ni kdialog : tapez le chemin du dossier du jeu dans la case ci-dessus.
276 Compilation par zig (build_zig.sh).
+178 -105
View File
@@ -15,6 +15,7 @@ mod mods;
mod i18n;
mod music;
mod parties;
mod plat;
mod preview;
mod reports;
mod saves;
@@ -24,7 +25,7 @@ mod version;
use eframe::egui::{self, Color32, CornerRadius, Rect, RichText, Stroke};
use std::io::{BufRead, BufReader, Read};
use std::os::windows::process::CommandExt;
use plat::{capture, hidden};
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::sync::mpsc::{channel, Receiver, Sender};
@@ -32,12 +33,13 @@ use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
use std::sync::Arc;
use std::thread;
const NO_WINDOW: u32 = 0x0800_0000;
const SDL_VER: &str = "2.32.10";
const SDL_URL: &str =
"https://github.com/libsdl-org/SDL/releases/download/release-2.32.10/SDL2-devel-2.32.10-VC.zip";
const VSWHERE: &str = r"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe";
const MAX_LOG: usize = 5000;
/// Python du pack HD (tools/hd_export.py)
const PY: &str = if cfg!(windows) { "python" } else { "python3" };
// ------------------------------------------------------------------ langue
@@ -136,7 +138,7 @@ impl Default for Config {
}
fn config_file() -> Option<PathBuf> {
std::env::var_os("APPDATA").map(|a| PathBuf::from(a).join("DoubleTroubleRecomp").join("launcher.ini"))
plat::config_dir().map(|d| d.join("launcher.ini"))
}
impl Config {
@@ -221,6 +223,10 @@ struct Checks {
capstone: Option<String>,
vcvars: Option<PathBuf>,
sdl: bool,
/// Linux : libGL.so.1 présente (Windows : toujours)
gl: bool,
/// Linux : commande qui installe SDL2 et libGL avec le gestionnaire de paquets (si l'une manque)
install_cmd: Option<String>,
/// dossier qui contient TUCKER.EXE et INTRO.EXE
game_dir: Option<PathBuf>,
game_error: Option<String>,
@@ -253,7 +259,7 @@ impl Checks {
/// de quoi compiler, par l'une ou l'autre voie
fn prereqs_ok(&self) -> bool {
self.sdl && (self.zig_ok() || self.msvc_ok())
self.sdl && self.gl && (self.zig_ok() || self.msvc_ok())
}
fn can_build(&self) -> bool {
@@ -271,40 +277,20 @@ impl Checks {
/// chemin de l'exécutable compilé, relatif au projet (build\tucker.exe, build_en\tucker.exe…)
fn exe_label(&self) -> String {
let d = self.build_dir.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_else(|| "build".into());
let exe = format!("{d}{}{}", plat::SEP, plat::exe("tucker"));
match &self.built_version {
Some(v) if self.built => format!("{d}\\tucker.exe · {v}"),
_ => format!("{d}\\tucker.exe"),
Some(v) if self.built => format!("{exe} · {v}"),
_ => exe,
}
}
}
fn hidden(program: &str) -> Command {
let mut c = Command::new(program);
c.creation_flags(NO_WINDOW);
c
}
/// lance une commande et renvoie sa sortie standard (sans les espaces de fin) si elle a réussi
fn capture(cmd: &mut Command) -> Option<String> {
let out = cmd.stdin(Stdio::null()).output().ok()?;
if !out.status.success() {
return None;
}
let mut s = String::from_utf8_lossy(&out.stdout).trim().to_string();
if s.is_empty() {
s = String::from_utf8_lossy(&out.stderr).trim().to_string();
}
Some(s)
}
fn powershell(script: &str) -> Option<String> {
capture(hidden("powershell").args(["-NoProfile", "-NonInteractive", "-STA", "-Command", script]))
}
fn ps_quote(s: &str) -> String {
format!("'{}'", s.replace('\'', "''"))
#[cfg(not(windows))]
fn find_vcvars() -> Option<PathBuf> {
None
}
#[cfg(windows)]
fn find_vcvars() -> Option<PathBuf> {
let rel = r"VC\Auxiliary\Build\vcvars64.bat";
if Path::new(VSWHERE).exists() {
@@ -338,26 +324,17 @@ fn is_iso(p: &str) -> bool {
p.to_ascii_lowercase().ends_with(".iso")
}
/// monte l'image (si besoin) et renvoie la lettre du lecteur
/// monte l'image (si besoin) et renvoie le dossier où elle est montée
fn mount_iso(iso: &str) -> Result<String, String> {
let script = format!(
"$ErrorActionPreference='Stop'; $p={}; $d=Get-DiskImage -ImagePath $p; \
if(-not $d.Attached){{ $d=Mount-DiskImage -ImagePath $p -PassThru }}; \
($d | Get-Volume).DriveLetter",
ps_quote(iso)
);
match powershell(&script) {
Some(l) if l.len() == 1 => Ok(format!("{l}:\\")),
Some(other) => Err(other),
None => Err("Mount-DiskImage".into()),
}
plat::mount_iso(iso)
}
/// trouve le dossier qui contient TUCKER.EXE et INTRO.EXE : le dossier lui-même ou son sous-dossier TUCKER
fn find_game_dir(dir: &Path) -> Option<PathBuf> {
[dir.to_path_buf(), dir.join("TUCKER")]
.into_iter()
.find(|d| d.join("TUCKER.EXE").is_file() && d.join("INTRO.EXE").is_file())
.filter_map(|d| if d.is_dir() { Some(d) } else { plat::find_nocase(dir, "TUCKER") })
.find(|d| plat::find_nocase(d, "TUCKER.EXE").is_some() && plat::find_nocase(d, "INTRO.EXE").is_some())
}
fn resolve_game(path: &str) -> Result<PathBuf, String> {
@@ -385,8 +362,46 @@ fn find_tool(root: &Path, var: &str, rels: &[&str]) -> Option<PathBuf> {
rels.iter().map(|r| root.join(r)).find(|p| p.is_file())
}
/// SDL2 pour compiler : Windows, l'archive -VC dans third_party ; Linux, les en-têtes livrés (ou ceux du
/// système) et la bibliothèque du système
#[cfg(windows)]
fn sdl_ok(root: &Path) -> bool {
root.join("third_party").join(format!("SDL2-{SDL_VER}")).join("include").join("SDL.h").is_file()
}
#[cfg(not(windows))]
fn sdl_ok(root: &Path) -> bool {
let headers = root.join("third_party/SDL2-linux/include/SDL2/SDL.h").is_file()
|| Path::new("/usr/include/SDL2/SDL.h").is_file();
headers && plat::has_lib("libSDL2-2.0.so.0")
}
#[cfg(windows)]
fn gl_ok() -> bool {
true
}
#[cfg(not(windows))]
fn gl_ok() -> bool {
plat::has_lib("libGL.so.1")
}
#[cfg(windows)]
fn install_cmd() -> Option<String> {
None
}
#[cfg(not(windows))]
fn install_cmd() -> Option<String> {
if plat::has_lib("libSDL2-2.0.so.0") && plat::has_lib("libGL.so.1") {
None
} else {
plat::install_command()
}
}
fn run_checks(root: &Path, cfg: &Config) -> Checks {
let py = |args: &[&str]| capture(hidden("python").args(args));
let py = |args: &[&str]| capture(hidden(PY).args(args));
let python = py(&["--version"]);
let capstone = python
.as_ref()
@@ -405,21 +420,31 @@ fn run_checks(root: &Path, cfg: &Config) -> Checks {
);
Checks {
done: true,
zig: find_tool(root, "DTR_ZIG", &[r"third_party\zig\zig.exe"]),
recomp: find_tool(root, "DTR_RECOMP", &[r"bin\dtr-recomp.exe", r"recomp\target\release\dtr-recomp.exe"]),
zig: if cfg!(windows) {
find_tool(root, "DTR_ZIG", &[r"third_party\zig\zig.exe"])
} else {
find_tool(root, "DTR_ZIG", &["third_party/zig-linux/zig"])
},
recomp: if cfg!(windows) {
find_tool(root, "DTR_RECOMP", &[r"bin\dtr-recomp.exe", r"recomp\target\release\dtr-recomp.exe"])
} else {
find_tool(root, "DTR_RECOMP", &["bin/dtr-recomp", "recomp/target/release/dtr-recomp"])
},
python,
capstone,
vcvars: find_vcvars(),
sdl: root.join("third_party").join(format!("SDL2-{SDL_VER}")).join("include").join("SDL.h").is_file(),
sdl: sdl_ok(root),
gl: gl_ok(),
install_cmd: install_cmd(),
game_dir,
game_error,
version,
built: build_dir.join("tucker.exe").is_file(),
built: build_dir.join(plat::exe("tucker")).is_file(),
built_version: std::fs::read_to_string(build_dir.join(updates::VERSION_STAMP))
.ok()
.map(|s| s.trim().to_string())
.filter(|s| !s.is_empty()),
can_load: engine_can_load(&build_dir.join("tucker.exe")),
can_load: engine_can_load(&build_dir.join(plat::exe("tucker"))),
build_dir,
}
}
@@ -469,8 +494,7 @@ static TASK_STOP: AtomicBool = AtomicBool::new(false);
/// exécute une ligne de commande cmd.exe dans `cwd` en envoyant chaque ligne de sortie au journal
fn run_streamed(ui: &Ui, cwd: &Path, line: &str) -> bool {
ui.log(format!("> {line}"));
let child = hidden("cmd")
.raw_arg(format!("/S /C \"{line} 2>&1\""))
let child = plat::shell_line(line)
.current_dir(cwd)
.env("VSLANG", "1033")
.env("PYTHONUTF8", "1")
@@ -514,20 +538,7 @@ fn stream_lines(ui: &Ui, r: impl Read) {
}
fn pick_dialog(kind: Pick, title: &str) -> Option<String> {
let owner = "(New-Object System.Windows.Forms.Form -Property @{TopMost=$true})";
let script = match kind {
Pick::GameIso => format!(
"Add-Type -AssemblyName System.Windows.Forms; $f=New-Object System.Windows.Forms.OpenFileDialog; \
$f.Title={}; $f.Filter='ISO (*.iso)|*.iso|*.*|*.*'; if($f.ShowDialog({owner}) -eq 'OK'){{$f.FileName}}",
ps_quote(title)
),
_ => format!(
"Add-Type -AssemblyName System.Windows.Forms; $f=New-Object System.Windows.Forms.FolderBrowserDialog; \
$f.Description={}; $f.ShowNewFolderButton=$false; if($f.ShowDialog({owner}) -eq 'OK'){{$f.SelectedPath}}",
ps_quote(title)
),
};
powershell(&script).filter(|s| !s.is_empty())
plat::pick_dialog(matches!(kind, Pick::GameIso), title)
}
// ------------------------------------------------------------------ thème « labo & pizza »
@@ -811,23 +822,10 @@ enum SaveAct {
CopyOther(PathBuf),
}
// heure locale : décalage du fuseau Windows (bias, en minutes, UTC = local + bias)
#[link(name = "kernel32")]
extern "system" {
fn GetTimeZoneInformation(tzi: *mut u8) -> u32;
}
fn tz_bias_minutes() -> i64 {
let mut b = [0u8; 172];
// SAFETY : tampon de la taille de TIME_ZONE_INFORMATION
let r = unsafe { GetTimeZoneInformation(b.as_mut_ptr()) };
let rd = |o: usize| i32::from_le_bytes([b[o], b[o + 1], b[o + 2], b[o + 3]]) as i64;
rd(0) + if r == 2 { rd(168) } else { rd(84) }
}
/// date locale : « 05/12/2026 14:03 », ou « 2026-12-05_14-03-27 » pour un nom de dossier
pub fn stamp(t: std::time::SystemTime, file: bool) -> String {
let secs = t.duration_since(std::time::UNIX_EPOCH).map(|d| d.as_secs() as i64).unwrap_or(0) - tz_bias_minutes() * 60;
let secs = t.duration_since(std::time::UNIX_EPOCH).map(|d| d.as_secs() as i64).unwrap_or(0) - plat::tz_bias_minutes() * 60;
let (days, rem) = (secs.div_euclid(86400), secs.rem_euclid(86400));
// jours depuis 1970 → date (algorithme de H. Hinnant)
let z = days + 719468;
@@ -1060,6 +1058,7 @@ struct Point {
y: i32,
}
#[cfg(windows)]
#[link(name = "user32")]
extern "system" {
fn MonitorFromPoint(pt: Point, flags: u32) -> isize;
@@ -1068,11 +1067,31 @@ extern "system" {
/// position enregistrée encore visible : la barre de titre tombe sur un écran branché (sinon, écran
/// débranché ou changé : position par défaut plutôt qu'une fenêtre hors de vue)
#[cfg(windows)]
fn on_screen(x: i32, y: i32) -> bool {
// SAFETY : appel Win32 sans pointeur ; 0 = MONITOR_DEFAULTTONULL
unsafe { MonitorFromPoint(Point { x: x + 60, y: y + 12 }, 0) != 0 }
}
/// hors de Windows, le gestionnaire de fenêtres place la fenêtre lui-même (Wayland ignore la position)
#[cfg(not(windows))]
fn on_screen(_x: i32, _y: i32) -> bool {
false
}
/// échelle de l'écran principal (Windows) ; 1 ailleurs
fn system_dpi_scale() -> f32 {
#[cfg(windows)]
{
// SAFETY : appel Win32 sans argument
unsafe { GetDpiForSystem() }.max(96) as f32 / 96.0
}
#[cfg(not(windows))]
{
1.0
}
}
/// tailles d'interface proposées, en % (0 = automatique)
const UI_SCALES: [u32; 9] = [0, 80, 90, 100, 110, 125, 150, 175, 200];
@@ -1118,11 +1137,20 @@ fn textures_guide(lang: Lang) -> &'static str {
}
fn find_root() -> Option<PathBuf> {
// build_zig.bat (zip de release, sans Python) ou build.bat avec son traducteur Python
// Windows : build_zig.bat (zip de release, sans Python) ou build.bat avec son traducteur Python ;
// Linux : build_zig.sh (archive de release, ou dossier préparé par l'AppImage)
let is_root = |d: &Path| {
d.join("runtime").is_dir()
&& (d.join("build_zig.bat").is_file() || (d.join("build.bat").is_file() && d.join("tools").join("recomp.py").is_file()))
&& if cfg!(windows) {
d.join("build_zig.bat").is_file() || (d.join("build.bat").is_file() && d.join("tools").join("recomp.py").is_file())
} else {
d.join("build_zig.sh").is_file()
}
};
// l'AppImage prépare le projet dans ~/.local/share/DoubleTroubleRecomp et le donne par DTR_ROOT
if let Some(r) = std::env::var_os("DTR_ROOT").map(PathBuf::from).filter(|d| is_root(d)) {
return Some(r);
}
let mut starts = Vec::new();
if let Ok(exe) = std::env::current_exe() {
starts.push(exe);
@@ -1142,7 +1170,7 @@ impl App {
setup_theme(&cc.egui_ctx);
// ancien exécutable laissé par une mise à jour du launcher
if let Ok(exe) = std::env::current_exe() {
let _ = std::fs::remove_file(exe.with_file_name("DoubleTroubleLauncher.old.exe"));
let _ = std::fs::remove_file(exe.with_file_name(plat::exe("DoubleTroubleLauncher.old")));
}
let (tx, rx) = channel();
let cfg = Config::load();
@@ -1398,7 +1426,7 @@ impl App {
let desc: Vec<String> = parts.iter().map(|(i, m)| format!("{} {m}", PACK_PARTS[*i].2)).collect();
mods::write_mod_ini_mixed(&target, &desc.join(", "), g);
}
let base = format!("python -I tools\\hd_export.py \"{}\" \"{}\"", game.display(), target.join("hd").display());
let base = format!("{PY} -I tools/hd_export.py \"{}\" \"{}\"", game.display(), target.join("hd").display());
let bin = self.upscayl.as_ref().map(|b| format!(" --upscayl-bin \"{}\"", b.display())).unwrap_or_default();
let mut steps = Vec::new();
// images fixes, regroupées par modèle
@@ -1423,7 +1451,7 @@ impl App {
fn repair_hd_pack(&mut self, target: PathBuf, model: String) {
let Some(game) = self.checks.game_dir.clone() else { return };
let mut cmd = format!(
"python -I tools\\hd_export.py \"{}\" \"{}\" --reparer --upscayl {model}",
"{PY} -I tools/hd_export.py \"{}\" \"{}\" --reparer --upscayl {model}",
game.display(),
target.join("hd").display()
);
@@ -1802,7 +1830,7 @@ impl App {
fn export_originals(&mut self) {
let (Some(game), Some(mdir)) = (self.checks.game_dir.clone(), self.mods_dir()) else { return };
let out = mdir.join(mods::export_dir(self.game_lang().code()));
let base = format!("python -I tools\\hd_export.py \"{}\" \"{}\"", game.display(), out.display());
let base = format!("{PY} -I tools/hd_export.py \"{}\" \"{}\"", game.display(), out.display());
// décors d'abord (quelques secondes), puis planches PCX et fichiers SPR (2 à 3 minutes)
let steps = vec![base.clone(), format!("{base} --sans-decors --planches --sprites")];
self.open_after = Some(out);
@@ -2629,7 +2657,7 @@ impl App {
TASK_STOP.store(true, Ordering::SeqCst);
let pid = TASK_PID.load(Ordering::SeqCst);
if pid != 0 {
let _ = hidden("taskkill").args(["/F", "/T", "/PID", &pid.to_string()]).stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null()).status();
plat::kill_tree(pid);
}
self.open_after = None;
}
@@ -2650,7 +2678,10 @@ impl App {
// build[_zig].bat DOSSIER régénère le C depuis le jeu choisi, nogen recompile seulement
// (avec nogen, la version est donnée : le script ne relit pas le jeu)
let Some(v) = self.checks.game_version() else { return };
#[cfg(windows)]
let arg = if regenerate { format!("\"{}\"", dir.display()) } else { format!("nogen {}", v.code()) };
#[cfg(not(windows))]
let arg = if regenerate { plat::sh_quote(&dir.display().to_string()) } else { format!("nogen {}", v.code()) };
// .\ : sans lui, cmd ne cherche pas dans le dossier courant si NoDefaultCurrentDirectoryInExePath est réglé
let step = if self.build_with_msvc() {
let Some(vc) = self.checks.vcvars.clone() else { return };
@@ -2661,18 +2692,27 @@ impl App {
if !self.checks.zig_ok() {
return;
}
let first = !self.root.as_ref().is_some_and(|r| r.join("build").join("zig-cache").is_dir());
let cache = if cfg!(windows) { "zig-cache" } else { "zig-cache-linux" };
let first = !self.root.as_ref().is_some_and(|r| r.join("build").join(cache).is_dir());
if first {
self.ui_handle().log(self.t(
"Première compilation avec zig : environ une minute (bibliothèque C préparée une fois pour toutes), ensuite moins de 10 secondes.",
"First build with zig: about one minute (C library prepared once and for all), then under 10 seconds.",
));
}
format!(".\\build_zig.bat {arg}")
if cfg!(windows) { format!(".\\build_zig.bat {arg}") } else { format!("sh build_zig.sh {arg}") }
};
self.start_task(if regenerate { "build" } else { "build-nogen" }, vec![step]);
}
/// Linux : installe SDL2 et libGL avec le gestionnaire de paquets ; pkexec demande le mot de passe (accord)
fn install_libs(&mut self) {
#[cfg(not(windows))]
if let Some(cmd) = self.checks.install_cmd.clone() {
self.start_task("install", vec![format!("pkexec sh -c {}", plat::sh_quote(&cmd))]);
}
}
fn download_sdl(&mut self) {
let zip = format!("third_party\\dl\\SDL2-devel-{SDL_VER}-VC.zip");
let script = format!(
@@ -2748,10 +2788,10 @@ impl App {
let hd_root = hd.parent().map(Path::to_path_buf).unwrap_or_else(|| hd.clone());
let saves = version::saves_dir(&root, self.game_lang());
let _ = std::fs::create_dir_all(&saves);
let mut cmd = hidden(&self.checks.build_dir.join("tucker.exe").to_string_lossy());
let mut cmd = hidden(&self.checks.build_dir.join(plat::exe("tucker")).to_string_lossy());
cmd.current_dir(&root)
.arg("--cd").arg(&dir)
.arg("--exe").arg(dir.join("TUCKER.EXE"))
.arg("--exe").arg(plat::find_nocase(&dir, "TUCKER.EXE").unwrap_or_else(|| dir.join("TUCKER.EXE")))
.arg("--hd").arg(&hd)
.arg("--root").arg(&hd_root)
.arg("--saves").arg(&saves);
@@ -3098,6 +3138,9 @@ impl App {
/// lecture/pause (dessiné : ▶ n'existe pas dans la police), VF / VUS, muet au prochain démarrage
fn music_controls(&mut self, ui: &mut egui::Ui) {
if cfg!(not(windows)) {
return; // pas de lecteur MP3 sans dépendance de plus (music.rs)
}
let lang = self.cfg.lang;
let playing = self.player.playing;
let (r, resp) = ui.allocate_exact_size(egui::vec2(28.0, 22.0), egui::Sense::click());
@@ -3289,19 +3332,44 @@ impl App {
status(ui, c.recomp.is_some() || c.msvc_ok(), self.t("Traducteur", "Translator"),
&shown(&c.recomp, self.t("absent (cargo build --release dans recomp)", "missing (cargo build --release in recomp)")));
ui.end_row();
status(ui, c.sdl, &format!("SDL2 {SDL_VER}"), if c.sdl { "third_party" } else { self.t("absent", "missing") });
if !c.sdl && ui.add_enabled(!busy, egui::Button::new(self.t("Télécharger", "Download"))).clicked() {
action = Some("sdl");
if cfg!(windows) {
status(ui, c.sdl, &format!("SDL2 {SDL_VER}"), if c.sdl { "third_party" } else { self.t("absent", "missing") });
if !c.sdl && ui.add_enabled(!busy, egui::Button::new(self.t("Télécharger", "Download"))).clicked() {
action = Some("sdl");
}
ui.end_row();
} else {
status(ui, c.sdl, "SDL2", if c.sdl { "libSDL2-2.0.so.0" } else { self.t("absente du système", "missing from the system") });
ui.end_row();
status(ui, c.gl, "OpenGL", if c.gl { "libGL.so.1" } else { self.t("absente du système", "missing from the system") });
ui.end_row();
}
ui.end_row();
});
// Linux : SDL2 ou libGL manquent ; installation avec le gestionnaire de paquets, après accord (pkexec
// demande le mot de passe)
if let Some(cmd) = c.install_cmd.clone() {
ui.label(RichText::new(self.t(
"Il manque SDL2 ou OpenGL. Le bouton lance cette commande, après votre mot de passe :",
"SDL2 or OpenGL is missing. The button runs this command, after your password:",
)).color(BAD));
ui.label(RichText::new(&cmd).monospace().small());
if ui.add_enabled(!busy, egui::Button::new(self.t("Installer…", "Install…"))).clicked() {
action = Some("install");
}
}
if !cfg!(windows) && !plat::has_dialogs() {
ui.label(RichText::new(self.t(
"Ni zenity ni kdialog : tapez le chemin du dossier du jeu dans la case ci-dessus.",
"Neither zenity nor kdialog: type the game folder's path in the box above.",
)).weak().small());
}
if !c.zig_ok() && !c.msvc_ok() && c.done {
ui.label(RichText::new(self.t(
"zig et le traducteur sont livrés dans le zip de release : décompressez l'archive entière.",
"zig and the translator come with the release zip: extract the whole archive.",
)).color(BAD));
}
ui.collapsing(self.t("Facultatif : compiler avec MSVC (build.bat)", "Optional: build with MSVC (build.bat)"), |ui| {
if cfg!(windows) { ui.collapsing(self.t("Facultatif : compiler avec MSVC (build.bat)", "Optional: build with MSVC (build.bat)"), |ui| {
ui.label(RichText::new(self.t(
"Pour les développeurs. Même résultat que zig ; il faut MSVC 2022, Python 3 et capstone.",
"For developers. Same result as zig; needs MSVC 2022, Python 3 and capstone.",
@@ -3318,17 +3386,23 @@ impl App {
ui.add_enabled_ui(c.msvc_ok() && c.zig_ok() && !busy, |ui| {
ui.checkbox(&mut self.cfg.use_msvc, label);
});
});
}); }
ui.label(RichText::new(if zig_way {
self.t("Compilation par zig (build_zig.bat).", "Built with zig (build_zig.bat).")
if cfg!(windows) {
self.t("Compilation par zig (build_zig.bat).", "Built with zig (build_zig.bat).")
} else {
self.t("Compilation par zig (build_zig.sh).", "Built with zig (build_zig.sh).")
}
} else if self.build_with_msvc() {
self.t("Compilation par MSVC (build.bat).", "Built with MSVC (build.bat).")
} else {
""
}).weak().small());
});
if action == Some("sdl") {
self.download_sdl();
match action {
Some("sdl") => self.download_sdl(),
Some("install") => self.install_libs(),
_ => {}
}
ui.add_space(10.0);
@@ -3408,7 +3482,7 @@ impl App {
/// le launcher qui tourne est celui que cargo compile dans le projet (sinon pas de mise à jour par lui-même)
fn self_exe(&self) -> Option<PathBuf> {
let root = self.root.as_ref()?;
let built = root.join("launcher").join("target").join("release").join("DoubleTroubleLauncher.exe");
let built = root.join("launcher").join("target").join("release").join(plat::exe("DoubleTroubleLauncher"));
let exe = std::env::current_exe().ok()?;
let same = match (std::fs::canonicalize(&exe), std::fs::canonicalize(&built)) {
(Ok(a), Ok(b)) => a == b,
@@ -3426,7 +3500,7 @@ impl App {
fn rebuild_launcher(&mut self) {
let lang = self.cfg.lang;
let Some(exe) = self.self_exe() else { return };
let old = exe.with_file_name("DoubleTroubleLauncher.old.exe");
let old = exe.with_file_name(plat::exe("DoubleTroubleLauncher.old"));
let _ = std::fs::remove_file(&old);
if let Err(e) = std::fs::rename(&exe, &old) {
self.update_msg = Some((false, format!("{} {e}", i18n::tr(lang, "Impossible de remplacer le launcher :", "Can't replace the launcher:"))));
@@ -3439,7 +3513,7 @@ impl App {
/// lance le nouveau launcher et ferme celui-ci
fn restart_launcher(&mut self) {
let Some(root) = self.root.clone() else { return };
let exe = root.join("launcher").join("target").join("release").join("DoubleTroubleLauncher.exe");
let exe = root.join("launcher").join("target").join("release").join(plat::exe("DoubleTroubleLauncher"));
self.cfg.save();
if Command::new(&exe).current_dir(root.join("launcher")).spawn().is_ok() {
std::process::exit(0);
@@ -3903,8 +3977,7 @@ fn main() -> eframe::Result {
if let (Some(x), Some(y)) = (cfg.win_x, cfg.win_y) {
if on_screen(x, y) {
// à peu près juste dès l'ouverture (échelle de l'écran principal) ; App corrige au besoin
// SAFETY : appel Win32 sans argument
let k = unsafe { GetDpiForSystem() }.max(96) as f32 / 96.0;
let k = system_dpi_scale();
viewport = viewport.with_position([x as f32 / k, y as f32 / k]);
}
}
+16 -1
View File
@@ -4,12 +4,26 @@
use std::path::PathBuf;
#[cfg(windows)]
#[link(name = "winmm")]
extern "system" {
fn mciSendStringW(command: *const u16, ret: *mut u16, ret_len: u32, hwnd: isize) -> u32;
}
/// hors de Windows : pas de lecteur MP3 du système, la musique reste muette (choix de l'utilisateur, pas de
/// dépendance de plus) ; le bouton de musique est caché
#[cfg(not(windows))]
fn mci(_cmd: &str) -> u32 {
1
}
#[cfg(not(windows))]
fn mci_query(_cmd: &str) -> String {
String::new()
}
/// envoie une commande MCI ; 0 = réussite
#[cfg(windows)]
fn mci(cmd: &str) -> u32 {
let w: Vec<u16> = cmd.encode_utf16().chain(std::iter::once(0)).collect();
// SAFETY : chaîne UTF-16 terminée par 0, pas de tampon de retour
@@ -17,6 +31,7 @@ fn mci(cmd: &str) -> u32 {
}
/// réponse texte d'une commande MCI (status…)
#[cfg(windows)]
fn mci_query(cmd: &str) -> String {
let w: Vec<u16> = cmd.encode_utf16().chain(std::iter::once(0)).collect();
let mut buf = [0u16; 64];
@@ -66,7 +81,7 @@ impl Player {
/// copie du MP3 sur le disque (MCI lit un fichier), refaite si la taille ne correspond pas
fn file(&self) -> Option<PathBuf> {
let (_, name, data) = TRACKS[self.track];
let dir = PathBuf::from(std::env::var_os("APPDATA")?).join("DoubleTroubleRecomp").join("music");
let dir = crate::plat::config_dir()?.join("music");
let path = dir.join(name);
if std::fs::metadata(&path).map(|m| m.len() as usize) .ok() != Some(data.len()) {
std::fs::create_dir_all(&dir).ok()?;
+1 -11
View File
@@ -102,17 +102,7 @@ pub fn export_state(path: &Path, dst: &Path) -> std::io::Result<()> {
/// met le fichier à la corbeille (récupérable)
pub fn trash(path: &Path) -> bool {
let p = path.display().to_string().replace('\'', "''");
let script = format!(
"Add-Type -AssemblyName Microsoft.VisualBasic; \
[Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile('{p}', 'OnlyErrorDialogs', 'SendToRecycleBin')"
);
std::process::Command::new("powershell")
.args(["-NoProfile", "-NonInteractive", "-Command", &script])
.stdin(std::process::Stdio::null())
.status()
.is_ok_and(|s| s.success())
&& !path.exists()
crate::plat::trash(path)
}
#[cfg(test)]
+400
View File
@@ -0,0 +1,400 @@
//! Ce qui dépend du système : processus, dossiers, dialogues, corbeille, image ISO, zip, heure locale.
//! Windows garde exactement le fonctionnement d'avant (PowerShell, cmd, explorer) ; Linux passe par les
//! outils du bureau (zenity ou kdialog, xdg-open, gio, udisksctl) et par sh.
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
/// extension des exécutables
pub const EXE: &str = if cfg!(windows) { ".exe" } else { "" };
/// séparateur de chemin affiché dans l'interface
pub const SEP: &str = if cfg!(windows) { "\\" } else { "/" };
/// nom de fichier d'un exécutable du projet (tucker.exe sous Windows, tucker sous Linux)
pub fn exe(name: &str) -> String {
format!("{name}{EXE}")
}
/// commande sans fenêtre de console (Windows) ; commande ordinaire ailleurs
pub fn hidden(program: &str) -> Command {
#[allow(unused_mut)]
let mut c = Command::new(program);
#[cfg(windows)]
{
use std::os::windows::process::CommandExt;
c.creation_flags(0x0800_0000); // CREATE_NO_WINDOW
}
c
}
/// lance une commande et renvoie sa sortie standard (sans les espaces de fin) si elle a réussi
pub fn capture(cmd: &mut Command) -> Option<String> {
let out = cmd.stdin(Stdio::null()).output().ok()?;
if !out.status.success() {
return None;
}
let mut s = String::from_utf8_lossy(&out.stdout).trim().to_string();
if s.is_empty() {
s = String::from_utf8_lossy(&out.stderr).trim().to_string();
}
Some(s)
}
/// le programme existe dans le PATH
#[cfg(not(windows))]
pub fn in_path(program: &str) -> bool {
std::env::var_os("PATH")
.is_some_and(|p| std::env::split_paths(&p).any(|d| d.join(program).is_file()))
}
/// argument entre apostrophes pour sh
#[cfg(not(windows))]
pub fn sh_quote(s: &str) -> String {
format!("'{}'", s.replace('\'', "'\\''"))
}
/// ligne de commande d'une étape de tâche, sortie d'erreur mêlée à la sortie standard
pub fn shell_line(line: &str) -> Command {
#[cfg(windows)]
{
use std::os::windows::process::CommandExt;
let mut c = hidden("cmd");
c.raw_arg(format!("/S /C \"{line} 2>&1\""));
c
}
#[cfg(not(windows))]
{
use std::os::unix::process::CommandExt;
let mut c = Command::new("sh");
c.arg("-c").arg(format!("{line} 2>&1"));
// groupe de processus à part : le bouton Arrêter arrête l'étape et tous ses enfants
c.process_group(0);
c
}
}
/// arrête un processus et tous ses enfants (bouton Arrêter)
pub fn kill_tree(pid: u32) {
#[cfg(windows)]
let _ = hidden("taskkill").args(["/F", "/T", "/PID", &pid.to_string()]).stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null()).status();
#[cfg(not(windows))]
let _ = Command::new("kill").args(["-TERM", "--", &format!("-{pid}")]).stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null()).status();
}
/// dossier des réglages, partagé avec le jeu (runtime/menu.c, settings_default_path) :
/// %APPDATA%\DoubleTroubleRecomp ; sous Linux $XDG_CONFIG_HOME/DoubleTroubleRecomp, sinon ~/.config/…
pub fn config_dir() -> Option<PathBuf> {
#[cfg(windows)]
let base = std::env::var_os("APPDATA").map(PathBuf::from);
#[cfg(not(windows))]
let base = std::env::var_os("XDG_CONFIG_HOME")
.filter(|v| !v.is_empty())
.map(PathBuf::from)
.or_else(|| std::env::var_os("HOME").map(|h| PathBuf::from(h).join(".config")));
base.map(|b| b.join("DoubleTroubleRecomp"))
}
/// fichier `name` dans `dir`, à la casse près sous Linux (une ISO montée montre souvent des minuscules)
pub fn find_nocase(dir: &Path, name: &str) -> Option<PathBuf> {
let p = dir.join(name);
if p.exists() {
return Some(p);
}
#[cfg(not(windows))]
{
if let Ok(rd) = std::fs::read_dir(dir) {
for e in rd.flatten() {
if e.file_name().to_string_lossy().eq_ignore_ascii_case(name) {
return Some(e.path());
}
}
}
}
None
}
/// ouvre un dossier dans le gestionnaire de fichiers
pub fn open_dir(dir: &Path) {
#[cfg(windows)]
let _ = Command::new("explorer").arg(dir).spawn();
#[cfg(not(windows))]
let _ = Command::new("xdg-open").arg(dir).stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null()).spawn();
}
/// montre un fichier : sélectionné dans l'Explorateur sous Windows ; son dossier ailleurs
pub fn reveal(file: &Path) {
#[cfg(windows)]
let _ = Command::new("explorer").arg(format!("/select,{}", file.display())).spawn();
#[cfg(not(windows))]
if let Some(d) = file.parent() {
open_dir(d);
}
}
#[cfg(windows)]
pub fn powershell(script: &str) -> Option<String> {
capture(hidden("powershell").args(["-NoProfile", "-NonInteractive", "-STA", "-Command", script]))
}
#[cfg(windows)]
pub fn ps_quote(s: &str) -> String {
format!("'{}'", s.replace('\'', "''"))
}
/// met un fichier ou un dossier à la corbeille (récupérable)
pub fn trash(path: &Path) -> bool {
#[cfg(windows)]
{
let p = path.display().to_string().replace('\'', "''");
let what = if path.is_dir() { "DeleteDirectory" } else { "DeleteFile" };
let script = format!(
"Add-Type -AssemblyName Microsoft.VisualBasic; \
[Microsoft.VisualBasic.FileIO.FileSystem]::{what}('{p}', 'OnlyErrorDialogs', 'SendToRecycleBin')"
);
let _ = Command::new("powershell")
.args(["-NoProfile", "-NonInteractive", "-Command", &script])
.stdin(Stdio::null())
.status();
}
#[cfg(not(windows))]
{
let gio = Command::new("gio")
.arg("trash")
.arg(path)
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
.is_ok_and(|s| s.success());
if !gio {
let _ = trash_freedesktop(path);
}
}
!path.exists()
}
/// corbeille du bureau (spécification freedesktop) quand gio manque : ~/.local/share/Trash/files et info
#[cfg(not(windows))]
fn trash_freedesktop(path: &Path) -> std::io::Result<()> {
let data = std::env::var_os("XDG_DATA_HOME")
.filter(|v| !v.is_empty())
.map(PathBuf::from)
.or_else(|| std::env::var_os("HOME").map(|h| PathBuf::from(h).join(".local").join("share")))
.ok_or_else(|| std::io::Error::other("HOME"))?;
let (files, info) = (data.join("Trash").join("files"), data.join("Trash").join("info"));
std::fs::create_dir_all(&files)?;
std::fs::create_dir_all(&info)?;
let name = path.file_name().ok_or_else(|| std::io::Error::other("nom"))?.to_string_lossy().to_string();
let mut n = 0;
let mut dest = name.clone();
while files.join(&dest).exists() || info.join(format!("{dest}.trashinfo")).exists() {
n += 1;
dest = format!("{name}.{n}");
}
let abs = std::fs::canonicalize(path)?;
let date = Command::new("date").arg("+%Y-%m-%dT%H:%M:%S").output().map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string()).unwrap_or_default();
std::fs::write(info.join(format!("{dest}.trashinfo")), format!("[Trash Info]\nPath={}\nDeletionDate={date}\n", abs.display()))?;
std::fs::rename(&abs, files.join(&dest))
}
/// zip du contenu de `dir` dans `out`
pub fn zip_dir(dir: &Path, out: &Path) -> bool {
let _ = std::fs::remove_file(out);
#[cfg(windows)]
{
let q = |p: &Path| format!("'{}'", p.display().to_string().replace('\'', "''"));
let script = format!("Compress-Archive -Path {} -DestinationPath {} -Force", q(&dir.join("*")), q(out));
let _ = Command::new("powershell")
.args(["-NoProfile", "-NonInteractive", "-Command", &script])
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null())
.status();
}
#[cfg(not(windows))]
{
let ok = Command::new("zip")
.arg("-r")
.arg("-q")
.arg(out)
.arg(".")
.current_dir(dir)
.stdin(Stdio::null())
.status()
.is_ok_and(|s| s.success());
if !ok {
// sans zip : le module zipfile de Python
let names: Vec<PathBuf> = std::fs::read_dir(dir).map(|rd| rd.flatten().map(|e| e.file_name().into()).collect()).unwrap_or_default();
let _ = Command::new("python3")
.args(["-m", "zipfile", "-c"])
.arg(out)
.args(&names)
.current_dir(dir)
.stdin(Stdio::null())
.status();
}
}
out.is_file()
}
/// boîte de dialogue : choisir un dossier (`iso` faux) ou une image .iso ; None si annulé
pub fn pick_dialog(iso: bool, title: &str) -> Option<String> {
#[cfg(windows)]
{
let owner = "(New-Object System.Windows.Forms.Form -Property @{TopMost=$true})";
let script = if iso {
format!(
"Add-Type -AssemblyName System.Windows.Forms; $f=New-Object System.Windows.Forms.OpenFileDialog; \
$f.Title={}; $f.Filter='ISO (*.iso)|*.iso|*.*|*.*'; if($f.ShowDialog({owner}) -eq 'OK'){{$f.FileName}}",
ps_quote(title)
)
} else {
format!(
"Add-Type -AssemblyName System.Windows.Forms; $f=New-Object System.Windows.Forms.FolderBrowserDialog; \
$f.Description={}; $f.ShowNewFolderButton=$false; if($f.ShowDialog({owner}) -eq 'OK'){{$f.SelectedPath}}",
ps_quote(title)
)
};
powershell(&script).filter(|s| !s.is_empty())
}
#[cfg(not(windows))]
{
let home = std::env::var("HOME").unwrap_or_default() + "/";
let out = if in_path("zenity") {
let mut c = Command::new("zenity");
c.args(["--file-selection", "--title", title]);
if iso {
c.args(["--file-filter", "ISO | *.iso *.ISO", "--file-filter", "* | *"]);
} else {
c.arg("--directory");
}
capture(&mut c)
} else if in_path("kdialog") {
let mut c = Command::new("kdialog");
c.args(["--title", title]);
if iso {
c.args(["--getopenfilename", &home, "*.iso *.ISO"]);
} else {
c.args(["--getexistingdirectory", &home]);
}
capture(&mut c)
} else {
None
};
out.filter(|s| !s.is_empty())
}
}
/// une fenêtre de choix existe (Windows : toujours ; Linux : zenity ou kdialog)
pub fn has_dialogs() -> bool {
#[cfg(windows)]
{
true
}
#[cfg(not(windows))]
{
in_path("zenity") || in_path("kdialog")
}
}
/// monte l'image (si besoin) et renvoie le dossier où elle est montée
pub fn mount_iso(iso: &str) -> Result<String, String> {
#[cfg(windows)]
{
let script = format!(
"$ErrorActionPreference='Stop'; $p={}; $d=Get-DiskImage -ImagePath $p; \
if(-not $d.Attached){{ $d=Mount-DiskImage -ImagePath $p -PassThru }}; \
($d | Get-Volume).DriveLetter",
ps_quote(iso)
);
match powershell(&script) {
Some(l) if l.len() == 1 => Ok(format!("{l}:\\")),
Some(other) => Err(other),
None => Err("Mount-DiskImage".into()),
}
}
#[cfg(not(windows))]
{
// déjà attachée ? (losetup -j) ; sinon udisksctl, sans droits d'administrateur sur un bureau
let iso_abs = std::fs::canonicalize(iso).map(|p| p.display().to_string()).unwrap_or_else(|_| iso.to_string());
let mut dev = capture(Command::new("losetup").args(["-j", &iso_abs]))
.and_then(|s| s.lines().next().and_then(|l| l.split(':').next()).map(str::to_string))
.filter(|d| d.starts_with("/dev/"));
if dev.is_none() {
let out = capture(Command::new("udisksctl").args(["loop-setup", "-r", "-f", &iso_abs]))
.ok_or("udisksctl loop-setup : échec / failed (décompressez l'image / extract the image)")?;
// « Mapped file X as /dev/loop7. »
dev = out.split_whitespace().find(|w| w.starts_with("/dev/")).map(|w| w.trim_end_matches('.').to_string());
}
let dev = dev.ok_or("udisksctl : périphérique inconnu / unknown device")?;
if let Some(m) = capture(Command::new("findmnt").args(["-n", "-o", "TARGET", "--source", &dev])) {
if let Some(l) = m.lines().next().filter(|l| !l.is_empty()) {
return Ok(l.to_string());
}
}
let out = capture(Command::new("udisksctl").args(["mount", "-b", &dev])).ok_or("udisksctl mount : échec / failed")?;
// « Mounted /dev/loop7 at /media/moi/TUCKER »
out.split(" at ").nth(1).map(|s| s.trim().trim_end_matches('.').to_string()).ok_or(out)
}
}
/// décalage du fuseau horaire en minutes (UTC = local + décalage), pour dater les sauvegardes
pub fn tz_bias_minutes() -> i64 {
#[cfg(windows)]
{
#[link(name = "kernel32")]
extern "system" {
fn GetTimeZoneInformation(tzi: *mut u8) -> u32;
}
let mut b = [0u8; 172];
// SAFETY : tampon de la taille de TIME_ZONE_INFORMATION
let r = unsafe { GetTimeZoneInformation(b.as_mut_ptr()) };
let rd = |o: usize| i32::from_le_bytes([b[o], b[o + 1], b[o + 2], b[o + 3]]) as i64;
rd(0) + if r == 2 { rd(168) } else { rd(84) }
}
#[cfg(not(windows))]
{
// `date +%z` : « +0100 » ; lu une fois
static BIAS: std::sync::OnceLock<i64> = std::sync::OnceLock::new();
*BIAS.get_or_init(|| {
let z = capture(&mut Command::new("date").arg("+%z")).unwrap_or_default();
let (sign, d) = match z.as_bytes().first() {
Some(b'-') => (-1, &z[1..]),
Some(b'+') => (1, &z[1..]),
_ => return 0,
};
let (h, m) = (d.get(..2).and_then(|x| x.parse::<i64>().ok()).unwrap_or(0), d.get(2..4).and_then(|x| x.parse::<i64>().ok()).unwrap_or(0));
-sign * (h * 60 + m)
})
}
}
/// bibliothèque partagée présente sur le système (Linux : libSDL2-2.0.so.0, libGL.so.1)
#[cfg(not(windows))]
pub fn has_lib(name: &str) -> bool {
let dirs = [
"/usr/lib", "/usr/lib64", "/lib", "/lib64", "/usr/lib/x86_64-linux-gnu", "/lib/x86_64-linux-gnu",
"/usr/lib/aarch64-linux-gnu", "/lib/aarch64-linux-gnu", "/usr/local/lib",
];
if dirs.iter().any(|d| Path::new(d).join(name).exists()) {
return true;
}
capture(Command::new("sh").args(["-c", "ldconfig -p 2>/dev/null || /sbin/ldconfig -p"])).is_some_and(|s| s.contains(name))
}
/// commande d'installation de SDL2 et libGL selon la distribution (la même que tools/appimage/AppRun)
#[cfg(not(windows))]
pub fn install_command() -> Option<String> {
if in_path("apt-get") {
Some("apt-get update && apt-get install -y libsdl2-2.0-0 libgl1".into())
} else if in_path("dnf") {
Some("dnf install -y 'libSDL2-2.0.so.0()(64bit)' 'libGL.so.1()(64bit)'".into())
} else if in_path("zypper") {
Some("zypper --non-interactive install 'libSDL2-2.0.so.0()(64bit)' 'libGL.so.1()(64bit)'".into())
} else if in_path("pacman") {
Some("pacman -S --needed --noconfirm sdl2 libglvnd".into())
} else {
None
}
}
+4 -23
View File
@@ -74,16 +74,7 @@ pub fn list_in(d: &Path) -> Vec<Report> {
pub fn zip(report: &Path) -> Result<PathBuf, String> {
let name = report.file_name().ok_or("dossier invalide")?.to_string_lossy().to_string();
let out = report.with_file_name(format!("{name}.zip"));
let q = |p: &Path| format!("'{}'", p.display().to_string().replace('\'', "''"));
let script = format!("Compress-Archive -Path {} -DestinationPath {} -Force", q(&report.join("*")), q(&out));
let ok = std::process::Command::new("powershell")
.args(["-NoProfile", "-NonInteractive", "-Command", &script])
.stdin(std::process::Stdio::null())
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status()
.is_ok_and(|s| s.success());
if ok && out.is_file() { Ok(out) } else { Err("Compress-Archive a échoué".into()) }
if crate::plat::zip_dir(report, &out) { Ok(out) } else { Err("zip : échec / failed".into()) }
}
/// dépôt du projet, où les bugs se signalent (issues)
@@ -120,22 +111,12 @@ pub fn issue_url(r: &Report, game: &str) -> String {
/// envoie le dossier du rapport à la corbeille (récupérable)
pub fn trash(report: &Path) -> bool {
let p = report.display().to_string().replace('\'', "''");
let script = format!(
"Add-Type -AssemblyName Microsoft.VisualBasic; \
[Microsoft.VisualBasic.FileIO.FileSystem]::DeleteDirectory('{p}', 'OnlyErrorDialogs', 'SendToRecycleBin')"
);
std::process::Command::new("powershell")
.args(["-NoProfile", "-NonInteractive", "-Command", &script])
.stdin(std::process::Stdio::null())
.status()
.is_ok_and(|s| s.success())
&& !report.exists()
crate::plat::trash(report)
}
/// montre un fichier sélectionné dans l'Explorateur
/// montre un fichier sélectionné dans l'Explorateur (sous Linux : son dossier)
pub fn reveal(file: &Path) {
let _ = std::process::Command::new("explorer").arg(format!("/select,{}", file.display())).spawn();
crate::plat::reveal(file)
}
#[cfg(test)]
+1 -1
View File
@@ -184,7 +184,7 @@ pub fn delete(dir: &Path, slot: u32) -> std::io::Result<()> {
pub fn open_folder(dir: &Path) {
let _ = std::fs::create_dir_all(dir);
let _ = std::process::Command::new("explorer").arg(dir).spawn();
crate::plat::open_dir(dir);
}
#[cfg(test)]
+15 -4
View File
@@ -45,15 +45,26 @@ pub struct GameSettings {
pub mods_disabled: Vec<String>,
}
/// Steam Deck : la variable SteamDeck=1 (posée par Steam), sinon la carte mère de Valve ; comme le jeu
/// (runtime/host_sdl.c), qui y prend d'autres défauts : plein écran et filtre « lissé »
pub fn steam_deck() -> bool {
if std::env::var("SteamDeck").is_ok_and(|v| v == "1") {
return true;
}
cfg!(target_os = "linux")
&& std::fs::read_to_string("/sys/devices/virtual/dmi/id/board_vendor").is_ok_and(|v| v.trim() == "Valve")
}
impl Default for GameSettings {
fn default() -> Self {
// mêmes défauts que le jeu (settings_defaults)
// mêmes défauts que le jeu (settings_defaults), Steam Deck compris
let deck = steam_deck();
Self {
fullscreen: false,
fullscreen: deck,
window_scale: 3,
window_width: 0,
window_height: 0,
filter: 0,
filter: if deck { 1 } else { 0 },
aspect_43: true,
vsync: false,
hd_pack: true,
@@ -75,7 +86,7 @@ impl Default for GameSettings {
}
pub fn path() -> Option<PathBuf> {
std::env::var_os("APPDATA").map(|a| PathBuf::from(a).join("DoubleTroubleRecomp").join("settings.ini"))
crate::plat::config_dir().map(|d| d.join("settings.ini"))
}
fn parse_bool(v: &str) -> Option<bool> {
+4 -8
View File
@@ -4,11 +4,8 @@
//! - le launcher connaît le commit dont il est compilé (build.rs, DTR_LAUNCHER_COMMIT) ;
//! - le jeu compilé par le launcher a son commit dans build[_xx]\commit.txt.
use std::os::windows::process::CommandExt;
use std::path::Path;
use std::process::{Command, Stdio};
const NO_WINDOW: u32 = 0x0800_0000;
use std::process::Stdio;
/// commit des sources du launcher qui tourne (vide si compilé hors d'un clone Git)
pub const LAUNCHER_COMMIT: &str = env!("DTR_LAUNCHER_COMMIT");
@@ -60,12 +57,11 @@ pub struct Info {
}
fn git(root: &Path, args: &[&str]) -> Result<String, String> {
let out = Command::new("git")
let out = crate::plat::hidden("git")
.args(args)
.current_dir(root)
.env("GIT_TERMINAL_PROMPT", "0")
.env("GCM_INTERACTIVE", "never")
.creation_flags(NO_WINDOW)
.stdin(Stdio::null())
.output()
.map_err(|e| e.to_string())?;
@@ -117,7 +113,7 @@ pub fn check(root: &Path, build_dir: &Path, fetch: bool) -> Info {
if !LAUNCHER_COMMIT.is_empty() {
i.launcher_stale = changed(root, LAUNCHER_COMMIT, "HEAD", &LAUNCHER).unwrap_or(false);
}
if let (true, Ok(stamp)) = (build_dir.join("tucker.exe").is_file(), std::fs::read_to_string(build_dir.join(STAMP))) {
if let (true, Ok(stamp)) = (build_dir.join(crate::plat::exe("tucker")).is_file(), std::fs::read_to_string(build_dir.join(STAMP))) {
i.engine_stale = changed(root, stamp.trim(), "HEAD", &ENGINE).unwrap_or(false);
}
i
@@ -174,7 +170,7 @@ mod tests {
assert!(i.engine_up && !i.launcher_up && !i.dirty);
// un jeu compilé avant la mise à jour est à recompiler une fois celle-ci récupérée
std::fs::create_dir_all(clone.join("build")).unwrap();
std::fs::write(clone.join("build").join("tucker.exe"), "").unwrap();
std::fs::write(clone.join("build").join(crate::plat::exe("tucker")), "").unwrap();
stamp_build(&clone, &clone.join("build"));
g(&clone, &["pull", "-q", "--ff-only", "origin", "main"]);
let i = check(&clone, &clone.join("build"), false);
+2 -2
View File
@@ -26,10 +26,10 @@ pub enum Detect {
}
pub fn detect(game_dir: &Path) -> Detect {
let Ok(t) = std::fs::read(game_dir.join("TUCKER.EXE")) else { return Detect::Unknown(String::new()) };
let Some(Ok(t)) = crate::plat::find_nocase(game_dir, "TUCKER.EXE").map(std::fs::read) else { return Detect::Unknown(String::new()) };
let sum = hex(&md5(&t));
let Some(&(_, v)) = TUCKER.iter().find(|(h, _)| *h == sum) else { return Detect::Unknown(sum) };
if let Ok(i) = std::fs::read(game_dir.join("INTRO.EXE")) {
if let Some(Ok(i)) = crate::plat::find_nocase(game_dir, "INTRO.EXE").map(std::fs::read) {
let want = if v == Lang::De { INTRO_DE } else { INTRO_FR };
if hex(&md5(&i)) != want {
return Detect::BadIntro(v);