diff --git a/betrieb/sperre.py b/betrieb/sperre.py index 2f46df6c..97fa7290 100644 --- a/betrieb/sperre.py +++ b/betrieb/sperre.py @@ -7,6 +7,7 @@ Datei atomar an (O_EXCL); lebt ihr Besitzer, startet der zweite nicht (`Belegt`) Spezifikation: tests/sperre_spec.py. """ import os +import sys from dataclasses import dataclass from typing import Optional @@ -35,7 +36,25 @@ def _zombie(pid): return aus.startswith("Z") +def _lebt_windows(pid): + """Unter Windows beendet os.kill(pid, 0) den Prozess (TerminateProcess) - hier nur fragen.""" + import ctypes + k = ctypes.windll.kernel32 + k.OpenProcess.restype = ctypes.c_void_p + k.CloseHandle.argtypes = [ctypes.c_void_p] + h = k.OpenProcess(0x1000, False, pid) # PROCESS_QUERY_LIMITED_INFORMATION + if not h: + return ctypes.GetLastError() == 5 # ERROR_ACCESS_DENIED: gibt es, gehoert anderen + try: + code = ctypes.c_ulong() + return bool(k.GetExitCodeProcess(ctypes.c_void_p(h), ctypes.byref(code))) and code.value == 259 + finally: + k.CloseHandle(h) + + def lebt(pid): + if sys.platform == "win32": + return pid > 0 and _lebt_windows(pid) try: os.kill(pid, 0) except ProcessLookupError: diff --git a/cockpit/Cargo.lock b/cockpit/Cargo.lock new file mode 100644 index 00000000..d1edbf8b --- /dev/null +++ b/cockpit/Cargo.lock @@ -0,0 +1,5720 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "ab_glyph" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01c0457472c38ea5bd1c3b5ada5e368271cb550be7a4ca4a0b4634e9913f6cc2" +dependencies = [ + "ab_glyph_rasterizer", + "owned_ttf_parser", +] + +[[package]] +name = "ab_glyph_rasterizer" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618" + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "getrandom 0.3.4", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "android-activity" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f2a1bb052857d5dd49572219344a7332b31b76405648eabac5bc68978251bcd" +dependencies = [ + "android-properties", + "bitflags 2.13.2", + "cc", + "jni", + "libc", + "log", + "ndk", + "ndk-context", + "ndk-sys", + "num_enum", + "thiserror 2.0.21", +] + +[[package]] +name = "android-properties" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" + +[[package]] +name = "android_system_properties" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" +dependencies = [ + "libc", +] + +[[package]] +name = "annotate-snippets" +version = "0.12.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a5b0a5ab8561c603f16c3b78c24a386b1f70e7fc1b1b1e8c15738828e4a176" +dependencies = [ + "anstyle", + "memchr", + "unicode-width", +] + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + +[[package]] +name = "arboard" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeb9553e62312c8756a5979254fc6d7da8bbeb5986a1e17037fab932f7037917" +dependencies = [ + "clipboard-win", + "log", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "parking_lot", + "percent-encoding", + "windows-sys 0.61.2", + "wl-clipboard-rs", + "x11rb", +] + +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + +[[package]] +name = "arrayvec" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" + +[[package]] +name = "as-raw-xcb-connection" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" + +[[package]] +name = "ash" +version = "0.38.0+1.3.281" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f" +dependencies = [ + "libloading", +] + +[[package]] +name = "async-broadcast" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532" +dependencies = [ + "event-listener", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-channel" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2" +dependencies = [ + "concurrent-queue", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f426a31126c735126297bc5ea7a521263c9faff4f63ca415267ee625651c4f37" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "pin-project-lite", + "slab", +] + +[[package]] +name = "async-io" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc" +dependencies = [ + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite", + "parking", + "polling", + "rustix 1.1.6", + "slab", + "windows-sys 0.61.2", +] + +[[package]] +name = "async-lock" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0876700b0d007ad25d5508865a4259c3af9af6d296bf663a0d586d0bc3369f6f" +dependencies = [ + "event-listener", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-process" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc50921ec0055cdd8a16de48773bfeec5c972598674347252c0399676be7da75" +dependencies = [ + "async-channel", + "async-io", + "async-lock", + "async-signal", + "async-task", + "blocking", + "cfg-if", + "event-listener", + "futures-lite", + "rustix 1.1.6", +] + +[[package]] +name = "async-recursion" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f8abc12baad266b1c8cec146854c195b5864b4221d4b2ca7296a7ae82d9e451" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "async-signal" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52b5aaafa020cf5053a01f2a60e8ff5dccf550f0f77ec54a4e47285ac2bab485" +dependencies = [ + "async-io", + "async-lock", + "atomic-waker", + "cfg-if", + "futures-core", + "futures-io", + "rustix 1.1.6", + "signal-hook-registry", + "slab", + "windows-sys 0.61.2", +] + +[[package]] +name = "async-task" +version = "4.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" + +[[package]] +name = "async-trait" +version = "0.1.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + +[[package]] +name = "bincode" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36eaf5d7b090263e8150820482d5d93cd964a81e4019913c972f4edcc6edb740" +dependencies = [ + "serde", + "unty", +] + +[[package]] +name = "bindgen" +version = "0.72.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" +dependencies = [ + "bitflags 2.13.2", + "cexpr", + "clang-sys", + "itertools 0.13.0", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash 2.1.3", + "shlex 1.3.0", + "syn 2.0.119", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" +dependencies = [ + "serde_core", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block2" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" +dependencies = [ + "objc2 0.5.3", +] + +[[package]] +name = "block2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5" +dependencies = [ + "objc2 0.6.5", +] + +[[package]] +name = "blocking" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a70e4329df6cb94385eed412ec92375c3cdd8a6e502493d1229b6414e4036dfa" +dependencies = [ + "async-channel", + "async-task", + "futures-io", + "futures-lite", + "piper", +] + +[[package]] +name = "borsh" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "553c5d846a6ba5150c65e3b1b8ec073bcf1abc20f9b7220de384a4443ea4e20a" +dependencies = [ + "bytes", + "cfg_aliases", +] + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "by_address" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64fa3c856b712db6612c019f14756e64e4bcea13337a6b33b696333a9eaa2d06" + +[[package]] +name = "bytemuck" +version = "1.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a1f896587b6f2c069c73d2f0913e2d590c3990285cd2f0b6aa02b786b4c679c" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "byteorder-lite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" + +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + +[[package]] +name = "calloop" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b99da2f8558ca23c71f4fd15dc57c906239752dd27ff3c00a1d56b685b7cbfec" +dependencies = [ + "bitflags 2.13.2", + "log", + "polling", + "rustix 0.38.44", + "slab", + "thiserror 1.0.69", +] + +[[package]] +name = "calloop" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b32313e937c8721c9d17ee9bf60699a6402b4b7c2cb6ac1bee0ffcaa4b4e5e" +dependencies = [ + "bitflags 2.13.2", + "polling", + "rustix 1.1.6", + "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 = "cc" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ff2a8126fff0f8c839080d619675a585e61720bb12d2baceae45769fd66f155" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex 2.0.1", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom 7.1.3", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "cfg_aliases" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" + +[[package]] +name = "cgl" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff" +dependencies = [ + "libc", +] + +[[package]] +name = "chrono" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "clang-sys" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "clipboard-win" +version = "5.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052af7878466feccda12ba7a6a67d019d712f296809559b47c12c8cc196d3a9a" +dependencies = [ + "error-code", +] + +[[package]] +name = "clru" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "197fd99cb113a8d5d9b6376f3aa817f32c1078f2343b714fff7d2ca44fdf67d5" +dependencies = [ + "hashbrown 0.16.1", +] + +[[package]] +name = "cockpit" +version = "0.1.0" +dependencies = [ + "png", + "serde_json", + "slint", + "slint-build", + "tungstenite", + "ureq", +] + +[[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_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + +[[package]] +name = "combine" +version = "4.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4356eba6976435498d05a311ee9fc486da3bc81c200d3f0d7dd9703b41913f92" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "const-field-offset" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d535c69e75b4e3c69e17205b5b37a91936c54086cecd339b70071500786acb9c" +dependencies = [ + "const-field-offset-macro", + "field-offset", +] + +[[package]] +name = "const-field-offset-macro" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d5848843a221ac268cfdd6bfd14e68d5d3dfa79d52c880aafab93f9517fb74" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "convert_case" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "core-graphics" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "core-graphics-types", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics-types" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "libc", +] + +[[package]] +name = "countme" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b929dd2a135771f40afabd1073f85eed59c800b7c61901e5c254270497dad64" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "critical-section" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" + +[[package]] +name = "crossbeam-channel" +version = "0.5.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98b0cc327b5bc766e7fda9c9260cc0fa81b43a8e240440422dff70788e3f9ef1" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" + +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "ctor" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83cf0d42651b16c6dfe68685716d18480d18a9c39c62d76e8cf3eb6ed5d8bcbf" +dependencies = [ + "dtor", +] + +[[package]] +name = "cursor-icon" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f" + +[[package]] +name = "data-encoding" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06" + +[[package]] +name = "data-url" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376" + +[[package]] +name = "derive_more" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.119", + "unicode-xid", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "dispatch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" + +[[package]] +name = "dispatch2" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", +] + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "dlib" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab8ecd87370524b461f8557c119c405552c396ed91fc0a8eec68679eab26f94a" +dependencies = [ + "libloading", +] + +[[package]] +name = "document-features" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" +dependencies = [ + "litrs", +] + +[[package]] +name = "downcast-rs" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" + +[[package]] +name = "dpi" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76" + +[[package]] +name = "drm" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80bc8c5c6c2941f70a55c15f8d9f00f9710ebda3ffda98075f996a0e6c92756f" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "drm-ffi", + "drm-fourcc", + "libc", + "rustix 0.38.44", +] + +[[package]] +name = "drm-ffi" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51a91c9b32ac4e8105dec255e849e0d66e27d7c34d184364fb93e469db08f690" +dependencies = [ + "drm-sys", + "rustix 1.1.6", +] + +[[package]] +name = "drm-fourcc" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aafbcdb8afc29c1a7ee5fbe53b5d62f4565b35a042a662ca9fecd0b54dae6f4" + +[[package]] +name = "drm-sys" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8e1361066d91f5ffccff060a3c3be9c3ecde15be2959c1937595f7a82a9f8" +dependencies = [ + "libc", + "linux-raw-sys 0.9.4", +] + +[[package]] +name = "dtor" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edf234dd1594d6dd434a8fb8cada51ddbbc593e40e4a01556a0b31c62da2775b" + +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" + +[[package]] +name = "endi" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66b7e2430c6dff6a955451e2cfc438f09cea1965a9d6f87f7e3b90decc014099" + +[[package]] +name = "enumflags2" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef" +dependencies = [ + "enumflags2_derive", + "serde", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "error-code" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5343afd4a8365a643ac588dab4cf234a190c7f6c88c9f6dd6ffe00837661b7" + +[[package]] +name = "euclid" +version = "0.22.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a05365e3b1c6d1650318537c7460c6923f1abdd272ad6842baa2b509957a06" +dependencies = [ + "num-traits", +] + +[[package]] +name = "event-listener" +version = "5.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2" +dependencies = [ + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" +dependencies = [ + "event-listener", + "pin-project-lite", +] + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "fdeflate" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "field-offset" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" +dependencies = [ + "memoffset", + "rustc_version", +] + +[[package]] +name = "filetime" +version = "0.2.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c287a33c7f0a620c38e641e7f60827713987b3c0f26e8ddc9462cc69cf75759" +dependencies = [ + "cfg-if", + "libc", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" + +[[package]] +name = "fixed_decimal" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2214fb00f669ee96bee5bb29dfb1ddabe058b2bc426817efc79afa03c9bc55ae" +dependencies = [ + "displaydoc", + "smallvec", + "writeable", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" +dependencies = [ + "crc32fast", + "miniz_oxide 0.9.1", + "zlib-rs", +] + +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "font-types" +version = "0.12.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835ae9d781464a79026cde387f9cbc650c9a4909d7cf7e658b127e3c35d2f35d" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "fontdb" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2660c5e9157bf76d2db1294e4a9feba604ef610819a3b591088d0d8392a3290f" +dependencies = [ + "log", + "slotmap", + "tinyvec", +] + +[[package]] +name = "fontique" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6688bc1294fe7117d788937b6c53480169b29c566954af490830d4c09da9516a" +dependencies = [ + "hashbrown 0.17.1", + "linebender_resource_handle", + "memmap2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-text", + "objc2-foundation 0.3.2", + "parlance", + "read-fonts", + "roxmltree", + "smallvec", + "windows", + "windows-core", + "yeslogic-fontconfig-sys", +] + +[[package]] +name = "foreign-types" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" +dependencies = [ + "foreign-types-macros", + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-macros" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea5190182e6915eb873ddbc16e23b711b6eb1f9c00a0d0a3a91b5f6228475225" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "foreign-types-shared" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-executor" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" + +[[package]] +name = "futures-lite" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + +[[package]] +name = "futures-macro" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "futures-sink" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "gethostname" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" +dependencies = [ + "rustix 1.1.6", + "windows-link", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", +] + +[[package]] +name = "gif" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee8cfcc411d9adbbaba82fb72661cc1bcca13e8bba98b364e62b2dba8f960159" +dependencies = [ + "color_quant", + "weezl", +] + +[[package]] +name = "gl_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + +[[package]] +name = "glob" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" + +[[package]] +name = "glow" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "263218b0ba2b0715c3370fb04674f5f8aa331594b521c94ff0a8e4a8472d1386" +dependencies = [ + "js-sys", + "slotmap", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "glutin" +version = "0.32.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12124de845cacfebedff80e877bb37b5b75c34c5a4c89e47e1cdd67fb6041325" +dependencies = [ + "bitflags 2.13.2", + "cfg_aliases", + "cgl", + "dispatch2", + "glutin_egl_sys", + "glutin_glx_sys", + "glutin_wgl_sys", + "libloading", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "once_cell", + "raw-window-handle", + "wayland-sys", + "windows-sys 0.52.0", + "x11-dl", +] + +[[package]] +name = "glutin-winit" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85edca7075f8fc728f28cb8fbb111a96c3b89e930574369e3e9c27eb75d3788f" +dependencies = [ + "cfg_aliases", + "glutin", + "raw-window-handle", + "winit", +] + +[[package]] +name = "glutin_egl_sys" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c4680ba6195f424febdc3ba46e7a42a0e58743f2edb115297b86d7f8ecc02d2" +dependencies = [ + "gl_generator", + "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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c4ee00b289aba7a9e5306d57c2d05499b2e5dc427f84ac708bd2c090212cf3e" +dependencies = [ + "gl_generator", +] + +[[package]] +name = "gpu-allocator" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51255ea7cfaadb6c5f1528d43e92a82acb2b96c43365989a28b2d44ee38f8795" +dependencies = [ + "ash", + "hashbrown 0.16.1", + "log", + "presser", + "thiserror 2.0.21", + "windows", +] + +[[package]] +name = "grid" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b40ca9252762c466af32d0b1002e91e4e1bc5398f77455e55474deb466355ff5" + +[[package]] +name = "half" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" +dependencies = [ + "cfg-if", + "crunchy", + "num-traits", + "zerocopy", +] + +[[package]] +name = "harfrust" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c03d949a14aa089bbb282f7dd76a498a7f684428e4257202efc119ec010376f9" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "read-fonts", + "smallvec", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[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.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash 0.2.0", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" +dependencies = [ + "foldhash 0.2.0", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "hermit-abi" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "htmlparser" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48ce8546b993eaf241d69ded33b1be6d205dd9857ec879d9d18bd05d3676e144" + +[[package]] +name = "http" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "i-slint-backend-linuxkms" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f519a8611a4982921e46e391015e5e40ceac5cc63813333ef91ada77df180d8" +dependencies = [ + "bytemuck", + "calloop 0.14.5", + "cfg_aliases", + "drm", + "i-slint-common", + "i-slint-core", + "i-slint-renderer-software", + "input", + "libseat", + "memmap2", + "nix", + "xkbcommon", +] + +[[package]] +name = "i-slint-backend-selector" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb974705d61ba56034f6129ff61f3e6282a2c0c07752f25e6cb417d81c0f0958" +dependencies = [ + "cfg-if", + "cfg_aliases", + "i-slint-backend-linuxkms", + "i-slint-backend-testing", + "i-slint-backend-winit", + "i-slint-common", + "i-slint-core", + "i-slint-core-macros", +] + +[[package]] +name = "i-slint-backend-testing" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01943d6c5ea5bc913d497bdaa423c309e7627afff47a6794bfd13be5c564209f" +dependencies = [ + "cfg_aliases", + "i-slint-common", + "i-slint-core", + "i-slint-renderer-software", + "vtable", +] + +[[package]] +name = "i-slint-backend-winit" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dae4fcf1b19e9cb109984d2af87d2b9485388c619265bff71dd523133888bee2" +dependencies = [ + "arboard", + "block2 0.6.2", + "bytemuck", + "cfg-if", + "cfg_aliases", + "futures", + "glutin", + "glutin-winit", + "i-slint-common", + "i-slint-core", + "i-slint-core-macros", + "i-slint-renderer-skia", + "i-slint-renderer-software", + "imgref", + "lyon_path", + "muda", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", + "objc2-ui-kit 0.3.2", + "pin-weak", + "raw-window-handle", + "rgb", + "scoped-tls-hkt", + "scopeguard", + "softbuffer", + "strum", + "vtable", + "wasm-bindgen", + "web-sys", + "webbrowser", + "windows", + "winit", + "zbus", +] + +[[package]] +name = "i-slint-common" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68a578f3e4b681b2b9cbd326d3be19716e2fac51d00a8a5b00c0ef4ae923b5e6" +dependencies = [ + "derive_more", + "fontique", + "htmlparser", + "icu_decimal", + "icu_locale_core", + "icu_provider", + "pulldown-cmark", + "resvg", + "skrifa", +] + +[[package]] +name = "i-slint-compiler" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55d48ebef05e2bf09ba5a1fc67bcb11033b9e12a2a50ed3105c7d25e2b539d0" +dependencies = [ + "annotate-snippets", + "by_address", + "data-url", + "derive_more", + "i-slint-common", + "icu_normalizer", + "icu_properties", + "image", + "indexmap", + "itertools 0.15.0", + "lyon_extra", + "lyon_path", + "num_enum", + "proc-macro2", + "quote", + "rayon", + "resvg", + "rowan", + "rspolib", + "skrifa", + "smol_str 0.3.7", + "strum", + "swash", + "typed-index-collections", + "unicode-segmentation", + "url", +] + +[[package]] +name = "i-slint-core" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2ea15059d70bc31b1a8b1eb4c34f2c5df04cb7e53f36179b43c0261231d646" +dependencies = [ + "bitflags 2.13.2", + "cfg-if", + "chrono", + "clru", + "const-field-offset", + "derive_more", + "euclid", + "i-slint-common", + "i-slint-core-macros", + "icu_normalizer", + "image", + "js-sys", + "lyon_algorithms", + "lyon_extra", + "lyon_geom", + "lyon_path", + "num-traits", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "once_cell", + "parley", + "pin-project", + "pin-weak", + "portable-atomic", + "raw-window-handle", + "resvg", + "rgb", + "scopeguard", + "skrifa", + "slab", + "strum", + "swash", + "sys-locale", + "taffy", + "unicode-linebreak", + "unicode-script", + "unicode-segmentation", + "vtable", + "wasm-bindgen", + "web-sys", + "web-time", + "wgpu", + "windows", +] + +[[package]] +name = "i-slint-core-macros" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f5a8a076de52f53be80caa826599ed2107b54c9d4a421e66dc06cf893a984c" +dependencies = [ + "quote", + "serde_json", + "syn 3.0.10", +] + +[[package]] +name = "i-slint-renderer-skia" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc9c1cf02385f1d26fc1f423544e52390a8e5c2d89420a8042aa94b4fe109d1f" +dependencies = [ + "bytemuck", + "cfg-if", + "cfg_aliases", + "clru", + "const-field-offset", + "glow", + "glutin", + "i-slint-common", + "i-slint-core", + "i-slint-core-macros", + "lyon_path", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "objc2-metal 0.3.2", + "objc2-quartz-core 0.3.2", + "pin-weak", + "raw-window-handle", + "read-fonts", + "scoped-tls-hkt", + "skia-safe", + "softbuffer", + "spin_on", + "unicode-segmentation", + "vtable", + "wgpu", + "wgpu-hal", + "windows", + "windows-core", + "write-fonts", +] + +[[package]] +name = "i-slint-renderer-software" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f8c641e138a2cc96537cac4481f5c7c8bb8dcc66d09acaed269329c8738628a" +dependencies = [ + "bytemuck", + "clru", + "derive_more", + "euclid", + "i-slint-common", + "i-slint-core", + "lyon_path", + "num-traits", + "skrifa", + "swash", + "zeno", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_decimal" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1150ad5e272740670464934ee76facda43ef2e11f85c27b7ba76ccb33edf2d05" +dependencies = [ + "displaydoc", + "fixed_decimal", + "icu_decimal_data", + "icu_locale_core", + "icu_locale_fallback", + "icu_plurals", + "icu_provider", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_decimal_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5595ab78370d48abd24a062f3db115d5108dd0b65634352036cae532aebb0df8" + +[[package]] +name = "icu_locale_core" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" +dependencies = [ + "displaydoc", + "litemap", + "serde", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locale_fallback" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "406e9ae5b95d8aa37db6293405931b766a6172d1848daee22d70eb44aa78a43c" +dependencies = [ + "icu_locale_core", + "icu_locale_fallback_data", + "icu_provider", + "potential_utf", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locale_fallback_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3632ebbd0c5c3637ba1a40bdf8288f2cb9d2268e73441a69d5fc73d7cfbaa87c" + +[[package]] +name = "icu_normalizer" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc" + +[[package]] +name = "icu_plurals" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ef046647b445acf95ce0f8083fa292467d3df649959fa9a20f3f8abfd957c5d" +dependencies = [ + "fixed_decimal", + "icu_locale_fallback", + "icu_plurals_data", + "icu_provider", + "zerovec", +] + +[[package]] +name = "icu_plurals_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d43ff7df2c1a1d41588a6ddcba354d513d4a3e10eec22c06fe56d13c12a848ea" + +[[package]] +name = "icu_properties" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf" + +[[package]] +name = "icu_provider" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" +dependencies = [ + "displaydoc", + "icu_locale_core", + "serde", + "stable_deref_trait", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_segmenter" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61b195dc605f81aa181bec9b3bd14e26cc71b903e4644f6af578ca9772c7a710" +dependencies = [ + "icu_collections", + "icu_locale_fallback", + "icu_provider", + "icu_segmenter_data", + "potential_utf", + "smallvec", + "utf8_iter", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_segmenter_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "913a7d294ad056474749152107309fdee3ec17d2482d1ab70fdc61a81c64b9a3" + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "image" +version = "0.25.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104" +dependencies = [ + "bytemuck", + "byteorder-lite", + "moxcms", + "num-traits", + "png", + "zune-core", + "zune-jpeg", +] + +[[package]] +name = "image-webp" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525e9ff3e1a4be2fbea1fdf0e98686a6d98b4d8f937e1bf7402245af1909e8c3" +dependencies = [ + "byteorder-lite", + "quick-error", +] + +[[package]] +name = "imagesize" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65b27460c2c92b037f3f94c538ed9a3342f3fdf923606781629ccb35f82d042a" + +[[package]] +name = "imgref" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e44b0a4eaa4c82f441d50a963f2d5f05a787240aeee097597033e72accfd22f" + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown 0.17.1", +] + +[[package]] +name = "input" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9793345a65d71317763a33066b5d8351f8760dde8d4930fe9e39b5f14a7959d" +dependencies = [ + "bitflags 2.13.2", + "input-sys", + "libc", + "log", + "udev", +] + +[[package]] +name = "input-sys" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36eee07d8e02bd95bf52b2e642cf13d33701b94c6e4b04fbf1d1fb07e9cb19e7" + +[[package]] +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi 0.3.9", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" + +[[package]] +name = "jni" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498" +dependencies = [ + "cfg-if", + "combine", + "jni-macros", + "jni-sys 0.4.1", + "log", + "simd_cesu8", + "thiserror 2.0.21", + "walkdir", + "windows-link", +] + +[[package]] +name = "jni-macros" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00109accc170f0bdb141fed3e393c565b6f5e072365c3bd58f5b062591560a3" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "simd_cesu8", + "syn 2.0.119", +] + +[[package]] +name = "jni-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41a652e1f9b6e0275df1f15b32661cf0d4b78d4d87ddec5e0c3c20f097433258" +dependencies = [ + "jni-sys 0.4.1", +] + +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "syn 2.0.119", +] + +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom 0.4.3", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "keyboard-types" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b750dcadc39a09dbadd74e118f6dd6598df77fa01df0cfcdc52c28dece74528a" +dependencies = [ + "bitflags 2.13.2", + "serde", + "unicode-segmentation", +] + +[[package]] +name = "khronos_api" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" + +[[package]] +name = "kurbo" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b60dfc32f652b926df6192e55525b16d186c69d47876c3ead4da5cc9f8450e2" +dependencies = [ + "arrayvec", + "euclid", + "polycool", + "smallvec", +] + +[[package]] +name = "lazy_static" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "libloading" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" +dependencies = [ + "cfg-if", + "windows-link", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61ff90caf6077a803a240f62fdbe88645a890bbca49ef8174c3cb0404362171d" +dependencies = [ + "bitflags 2.13.2", + "libc", + "plain", + "redox_syscall 0.9.5", +] + +[[package]] +name = "libseat" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6656c69b6e0366ffb83faa232f3e4fda5fc91161722d140f2c95ce2e90b1ef31" +dependencies = [ + "errno", + "libseat-sys", + "log", +] + +[[package]] +name = "libseat-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a484fa48be5f62a8d3ffed767779d0ab808cfead91de98ef4362d469097dfb" +dependencies = [ + "pkg-config", +] + +[[package]] +name = "libudev-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324" +dependencies = [ + "libc", + "pkg-config", +] + +[[package]] +name = "linebender_resource_handle" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "litrs" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4744e383959f0db86ede514b809b1c53251889093803c05267acc7d4e7030d70" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" + +[[package]] +name = "lyon_algorithms" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a6b9d4e8b48acd531fbf1241ad9b270df6e60b6b92bdea1469f4f40899d805" +dependencies = [ + "lyon_path", + "num-traits", +] + +[[package]] +name = "lyon_extra" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7755f08423275157ad1680aaecc9ccb7e0cc633da3240fea2d1522935cc15c72" +dependencies = [ + "lyon_path", + "thiserror 2.0.21", +] + +[[package]] +name = "lyon_geom" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d82dd26aa4dc0b5b70b9115de59824842bcb43cf4a28e1b1e6d0ad148c93f93e" +dependencies = [ + "arrayvec", + "euclid", + "num-traits", +] + +[[package]] +name = "lyon_path" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c463f9c428b7fc5ec885dcd39ce4aa61e29111d0e33483f6f98c74e89d8621e" +dependencies = [ + "lyon_geom", + "num-traits", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "memmap2" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b0ca1155a9ecc25aa12e8313a119f32edf0255fea2f44839c4ac0a12b2ac157" +dependencies = [ + "libc", +] + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "miniz_oxide" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "moxcms" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b" +dependencies = [ + "num-traits", + "pxfm", +] + +[[package]] +name = "muda" +version = "0.19.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd04e60bc0b07438a6771710ee1698f98f6ebbc7f89b61264af1563b8aeb878" +dependencies = [ + "crossbeam-channel", + "dpi", + "keyboard-types", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "once_cell", + "png", + "thiserror 2.0.21", + "windows-sys 0.61.2", +] + +[[package]] +name = "naga" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a616d2fb8c89516ac2723a581f69d6c18576046bed761bd6b305e5618e6ae130" +dependencies = [ + "arrayvec", + "bit-set", + "bitflags 2.13.2", + "cfg-if", + "cfg_aliases", + "codespan-reporting", + "half", + "hashbrown 0.17.1", + "indexmap", + "libm", + "log", + "naga-types", + "num-traits", + "once_cell", + "rustc-hash 1.1.0", + "spirv", + "thiserror 2.0.21", + "unicode-ident", +] + +[[package]] +name = "naga-types" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "590afbf58a6f4f62873cd5cff4468061844bafa1cdf399cc954537c22d768d49" +dependencies = [ + "hashbrown 0.17.1", + "indexmap", + "rustc-hash 1.1.0", + "thiserror 2.0.21", +] + +[[package]] +name = "natord" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "308d96db8debc727c3fd9744aac51751243420e46edf401010908da7f8d5e57c" + +[[package]] +name = "ndk" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" +dependencies = [ + "bitflags 2.13.2", + "jni-sys 0.3.1", + "log", + "ndk-sys", + "num_enum", + "raw-window-handle", + "thiserror 1.0.69", +] + +[[package]] +name = "ndk-context" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" + +[[package]] +name = "ndk-sys" +version = "0.6.0+11769913" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee6cda3051665f1fb8d9e08fc35c96d5a244fb1be711a03b71118828afc9a873" +dependencies = [ + "jni-sys 0.3.1", +] + +[[package]] +name = "nix" +version = "0.31.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d" +dependencies = [ + "bitflags 2.13.2", + "cfg-if", + "cfg_aliases", + "libc", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "num_enum" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0bca838442ec211fa11de3a8b0e0e8f3a4522575b5c4c06ed722e005036f26" +dependencies = [ + "num_enum_derive", + "rustversion", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "objc-sys" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" + +[[package]] +name = "objc2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d5490aaf8f1d7cf7688dfa9b0ce07900e168852c45cd2c03f534dfd27cfd0b" +dependencies = [ + "objc-sys", + "objc2-encode", +] + +[[package]] +name = "objc2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08849bbd4767dfae9457696856ae1c84fe4e0281bbe4a7abff2d0e06fb7981f8" +dependencies = [ + "objc2-encode", +] + +[[package]] +name = "objc2-app-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "libc", + "objc2 0.5.3", + "objc2-core-data", + "objc2-core-image", + "objc2-foundation 0.2.2", + "objc2-quartz-core 0.2.2", +] + +[[package]] +name = "objc2-app-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", +] + +[[package]] +name = "objc2-cloud-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-core-location", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-contacts" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5ff520e9c33812fd374d8deecef01d4a840e7b41862d849513de77e44aa4889" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-core-data" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-core-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" +dependencies = [ + "bitflags 2.13.2", + "dispatch2", + "objc2 0.6.5", +] + +[[package]] +name = "objc2-core-graphics" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" +dependencies = [ + "bitflags 2.13.2", + "dispatch2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-io-surface", +] + +[[package]] +name = "objc2-core-image" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", + "objc2-metal 0.2.2", +] + +[[package]] +name = "objc2-core-location" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "000cfee34e683244f284252ee206a27953279d370e309649dc3ee317b37e5781" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-contacts", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-core-text" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d" +dependencies = [ + "bitflags 2.13.2", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-encode" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" + +[[package]] +name = "objc2-foundation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "dispatch", + "libc", + "objc2 0.5.3", +] + +[[package]] +name = "objc2-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" +dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "objc2 0.6.5", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-io-surface" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-link-presentation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1a1ae721c5e35be65f01a03b6d2ac13a54cb4fa70d8a5da293d7b0020261398" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-metal" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-metal" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0125f776a10d00af4152d74616409f0d4a2053a6f57fa5b7d6aa2854ac04794" +dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "objc2 0.6.5", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", + "objc2-metal 0.2.2", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", + "objc2-metal 0.3.2", +] + +[[package]] +name = "objc2-symbols" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a684efe3dec1b305badae1a28f6555f6ddd3bb2c2267896782858d5a78404dc" +dependencies = [ + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-ui-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-cloud-kit", + "objc2-core-data", + "objc2-core-image", + "objc2-core-location", + "objc2-foundation 0.2.2", + "objc2-link-presentation", + "objc2-quartz-core 0.2.2", + "objc2-symbols", + "objc2-uniform-type-identifiers", + "objc2-user-notifications", +] + +[[package]] +name = "objc2-ui-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d87d638e33c06f577498cbcc50491496a3ed4246998a7fbba7ccb98b1e7eab22" +dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", +] + +[[package]] +name = "objc2-uniform-type-identifiers" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44fa5f9748dbfe1ca6c0b79ad20725a11eca7c2218bceb4b005cb1be26273bfe" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-user-notifications" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-core-location", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" +dependencies = [ + "critical-section", + "portable-atomic", +] + +[[package]] +name = "orbclient" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5df339f526ea9a60e371768d50efc2f2508c7203290731565d1f7a6f71d21747" +dependencies = [ + "libc", + "libredox", +] + +[[package]] +name = "ordered-float" +version = "5.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f59006ce1e204c30956638535b74d317bca99477b9356dfaec54c37f6f600ab" +dependencies = [ + "num-traits", +] + +[[package]] +name = "ordered-stream" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" +dependencies = [ + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "os_pipe" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "owned_ttf_parser" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36820e9051aca1014ddc75770aab4d68bc1e9e632f0f5627c4086bc216fb583b" +dependencies = [ + "ttf-parser", +] + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.5.18", + "smallvec", + "windows-link", +] + +[[package]] +name = "parlance" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73072a9470554c8e794778acece2312661218aaabb635600957d952cf01c716e" + +[[package]] +name = "parley" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22d2ff88bd3f7d68d1d9b09c7e6209f9a8e8c05088295140a2bcf2e9b17038c5" +dependencies = [ + "fontique", + "harfrust", + "hashbrown 0.17.1", + "icu_normalizer", + "icu_properties", + "icu_segmenter", + "linebender_resource_handle", + "parlance", + "parley_data", + "skrifa", +] + +[[package]] +name = "parley_data" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1567535334d6ba2d3cde19221ba9a7bd0fabb3cbd99046ddfb10ae061cfcc889" +dependencies = [ + "icu_properties", +] + +[[package]] +name = "percent-encoding" +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 = "pico-args" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" + +[[package]] +name = "pin-project" +version = "1.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pin-utils" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13bee6c73da26345c729282832b60b0363cf3dd9f4bfd81d8551b7a1c889a113" + +[[package]] +name = "pin-weak" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b330c9d1b92dfe68442ca20b009c717d5f0b1e3cf4965e62f704c3c6e95a1305" + +[[package]] +name = "piper" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c835479a4443ded371d6c535cbfd8d31ad92c5d23ae9770a61bc155e4992a3c1" +dependencies = [ + "atomic-waker", + "fastrand", + "futures-io", +] + +[[package]] +name = "pkg-config" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" + +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + +[[package]] +name = "png" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" +dependencies = [ + "bitflags 2.13.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.8.9", +] + +[[package]] +name = "polling" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi 0.5.3", + "pin-project-lite", + "rustix 1.1.6", + "windows-sys 0.61.2", +] + +[[package]] +name = "polycool" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50596ddc09eb5ad5f75cacd40209568e66df71baf86e1499a0e99c4cff12a5a6" +dependencies = [ + "arrayvec", +] + +[[package]] +name = "portable-atomic" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" +dependencies = [ + "critical-section", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "serde_core", + "writeable", + "zerovec", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "presser" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn 2.0.119", +] + +[[package]] +name = "proc-macro-crate" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "profiling" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d595e54a326bc53c1c197b32d295e14b169e3cfeaa8dc82b529f947fba6bcf5" + +[[package]] +name = "pulldown-cmark" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db2be46835f013dd3f4fa7f5f7402c537787b54ebb6fe2b94bbdd7e2669bb7b" +dependencies = [ + "bitflags 2.13.2", + "memchr", + "unicase", +] + +[[package]] +name = "pxfm" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" + +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + +[[package]] +name = "quick-xml" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1" +dependencies = [ + "memchr", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "range-alloc" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca45419789ae5a7899559e9512e58ca889e41f04f1f2445e9f4b290ceccd1d08" + +[[package]] +name = "raw-window-handle" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" + +[[package]] +name = "raw-window-metal" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40d213455a5f1dc59214213c7330e074ddf8114c9a42411eb890c767357ce135" +dependencies = [ + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", +] + +[[package]] +name = "rayon" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "read-fonts" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046a7d674daf459825b32f5062056d6882db0d2f5a479fbd76ccfc870ac18709" +dependencies = [ + "bytemuck", + "font-types", + "once_cell", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "redox_syscall" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "580c875845b41ecb1564ad1ae4703044cef774145e3d7a94dc2b3fa7c97868fd" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "regex" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "renderdoc-sys" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" + +[[package]] +name = "resvg" +version = "0.48.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67e3803f97b999e80cbf7c6ecdd07a8102204d92e1633cf48783720c521196bd" +dependencies = [ + "bytemuck", + "gif", + "image-webp", + "log", + "pico-args", + "rgb", + "svgtypes", + "tiny-skia 0.12.0", + "usvg", + "zune-jpeg", +] + +[[package]] +name = "rgb" +version = "0.8.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b34b781b31e5d73e9fbc8689c70551fd1ade9a19e3e28cfec8580a79290cc4" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "rowan" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14b574c58582fa59fa43a2feb6608b8744184659f08a2e0117e4b8224d95ed61" +dependencies = [ + "countme", + "hashbrown 0.14.5", + "memoffset", + "rustc-hash 1.1.0", + "text-size", +] + +[[package]] +name = "roxmltree" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9da7f59328b09405b181fee1018925fad50f157afb43c0c0f5c522c256dd5907" +dependencies = [ + "memchr", +] + +[[package]] +name = "rspolib" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fda9a7796aff63a7b1b39ccc93fffaaf65e20042984b4843041a49ca4677535" +dependencies = [ + "lazy_static", + "natord", + "snafu", + "unicode-linebreak", + "unicode-width", +] + +[[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.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys 0.4.15", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustix" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys 0.12.1", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scoped-tls-hkt" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9603871ffe5df3ac39cb624790c296dbd47a400d202f56bf3e414045099524d" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "sctk-adwaita" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6277f0217056f77f1d8f49f2950ac6c278c0d607c45f5ee99328d792ede24ec" +dependencies = [ + "ab_glyph", + "log", + "memmap2", + "smithay-client-toolkit", + "tiny-skia 0.11.4", +] + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_repr" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b1629de253c70a0508c3899572da79ca359fdab27c7920ff00406df418906" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "serde_spanned" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c187e0a369471c550af028cba56d4f4fa2a489ad28151ae95a4d340a2a8b782" +dependencies = [ + "serde_core", +] + +[[package]] +name = "sha1" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "simd-adler32" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" + +[[package]] +name = "simd_cesu8" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11031e251abf8611c80f460e19dbdeb54a66db918e49c65a7065b46ac7aec520" +dependencies = [ + "rustc_version", + "simdutf8", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "simplecss" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a9c6883ca9c3c7c90e888de77b7a5c849c779d25d74a1269b0218b14e8b136c" +dependencies = [ + "log", +] + +[[package]] +name = "siphasher" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256" + +[[package]] +name = "skia-bindings" +version = "0.153.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb325787c91b3f6c34a7c6f2b8a2297b20292d733ca53a08c233e5028aec49af" +dependencies = [ + "bindgen", + "cc", + "flate2", + "heck", + "pkg-config", + "regex", + "serde_json", + "tar", + "toml", +] + +[[package]] +name = "skia-safe" +version = "0.153.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61cb643dac43067f3eb76c866635a74377ac0abca0ff2590674e1e295514c3d" +dependencies = [ + "bitflags 2.13.2", + "skia-bindings", + "windows", +] + +[[package]] +name = "skrifa" +version = "0.44.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819ab7d62b1d3e72d9d9dea5650bac30424f9111364bb94928dbf5ecad1baa68" +dependencies = [ + "bytemuck", + "read-fonts", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "slint" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15e477d5ff6fec20909100ff8f7062432ebfbda7a62a0f37d0252aa126f38c83" +dependencies = [ + "const-field-offset", + "i-slint-backend-linuxkms", + "i-slint-backend-selector", + "i-slint-common", + "i-slint-core", + "i-slint-core-macros", + "i-slint-renderer-software", + "num-traits", + "once_cell", + "pin-weak", + "slint-macros", + "unicode-segmentation", + "vtable", +] + +[[package]] +name = "slint-build" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ea28d4e1ad47d829b91e227f17037fac07a8001668a93fee47ac04f88718ebc" +dependencies = [ + "derive_more", + "fontique", + "i-slint-compiler", + "spin_on", + "toml_edit", +] + +[[package]] +name = "slint-macros" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35e74b13d20884dc480ce37d0fabbf02cb4bc0df2a595434feac96ca7c2a0f15" +dependencies = [ + "i-slint-compiler", + "proc-macro2", + "quote", + "spin_on", +] + +[[package]] +name = "slotmap" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdd58c3c93c3d278ca835519292445cb4b0d4dc59ccfdf7ceadaab3f8aeb4038" +dependencies = [ + "version_check", +] + +[[package]] +name = "smallvec" +version = "1.16.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46" + +[[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", + "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 = "smol_str" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd538fb6910ac1099850255cf94a94df6551fbdd602454387d0adb2d1ca6dead" +dependencies = [ + "serde", +] + +[[package]] +name = "smol_str" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeb7109d23f319619d4cc0de5464613c8b7b1a09db2774a58101459cf6be2f10" +dependencies = [ + "borsh", + "serde_core", +] + +[[package]] +name = "snafu" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e84b3f4eacbf3a1ce05eac6763b4d629d60cbc94d632e4092c54ade71f1e1a2" +dependencies = [ + "snafu-derive", +] + +[[package]] +name = "snafu-derive" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1c97747dbf44bb1ca44a561ece23508e99cb592e862f22222dcf42f51d1e451" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "softbuffer" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aac18da81ebbf05109ab275b157c22a653bb3c12cf884450179942f81bcbf6c3" +dependencies = [ + "as-raw-xcb-connection", + "bytemuck", + "fastrand", + "js-sys", + "memmap2", + "ndk", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", + "raw-window-handle", + "redox_syscall 0.5.18", + "rustix 1.1.6", + "tiny-xlib", + "tracing", + "wasm-bindgen", + "wayland-backend", + "wayland-client", + "wayland-sys", + "web-sys", + "windows-sys 0.61.2", + "x11rb", +] + +[[package]] +name = "spin_on" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "076e103ed41b9864aa838287efe5f4e3a7a0362dd00671ae62a212e5e4612da2" +dependencies = [ + "pin-utils", +] + +[[package]] +name = "spirv" +version = "0.4.0+sdk-1.4.341.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9571ea910ebd84c86af4b3ed27f9dbdc6ad06f17c5f96146b2b671e2976744f" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strict-num" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" +dependencies = [ + "float-cmp", +] + +[[package]] +name = "strum" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9628de9b8791db39ceda2b119bbe13134770b56c138ec1d3af810d045c04f9bd" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab85eea0270ee17587ed4156089e10b9e6880ee688791d45a905f5b1ca36f664" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "svgtypes" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f12b12995e3638c70618c1facb1ce65302f6a6f706b675f07c58a5d7391120e" +dependencies = [ + "kurbo", + "siphasher", +] + +[[package]] +name = "swash" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c2499c2d826531388872b2268718aed907a39bd785ab0dcfe57fab26283f92e" +dependencies = [ + "skrifa", + "yazi", + "zeno", +] + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "sys-locale" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eab9a99a024a169fe8a903cf9d4a3b3601109bcc13bd9e3c6fff259138626c4" +dependencies = [ + "js-sys", + "libc", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "taffy" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aea22054047c16c3f34d3ac473a2170be1424b1115b2a3adcf28cfb067c88859" +dependencies = [ + "arrayvec", + "grid", + "serde", + "slotmap", +] + +[[package]] +name = "tar" +version = "0.4.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6221d9a6003c78398e3b239969f352578258df48c8eb051caadae0015bc840" +dependencies = [ + "filetime", + "libc", + "xattr", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.3", + "once_cell", + "rustix 1.1.6", + "windows-sys 0.61.2", +] + +[[package]] +name = "text-size" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f18aa187839b2bdb1ad2fa35ead8c4c2976b64e4363c386d45ac0f7ee85c9233" + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl 2.0.21", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "tiny-skia" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab" +dependencies = [ + "arrayref", + "arrayvec", + "bytemuck", + "cfg-if", + "log", + "tiny-skia-path 0.11.4", +] + +[[package]] +name = "tiny-skia" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47ffee5eaaf5527f630fb0e356b90ebdec84d5d18d937c5e440350f88c5a91ea" +dependencies = [ + "arrayref", + "arrayvec", + "bytemuck", + "cfg-if", + "log", + "png", + "tiny-skia-path 0.12.0", +] + +[[package]] +name = "tiny-skia-path" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93" +dependencies = [ + "arrayref", + "bytemuck", + "strict-num", +] + +[[package]] +name = "tiny-skia-path" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edca365c3faccca67d06593c5980fa6c57687de727a03131735bb85f01fdeeb9" +dependencies = [ + "arrayref", + "bytemuck", + "strict-num", +] + +[[package]] +name = "tiny-xlib" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a90a0ca3ee6a69f2ad28fd11621a4c3f03b371f366be500b64df260c4ffbafb4" +dependencies = [ + "as-raw-xcb-connection", + "ctor", + "libloading", + "pkg-config", + "tracing", +] + +[[package]] +name = "tinystr" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" +dependencies = [ + "displaydoc", + "serde_core", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" + +[[package]] +name = "tokio" +version = "1.54.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" +dependencies = [ + "pin-project-lite", +] + +[[package]] +name = "toml" +version = "1.2.1+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5755c51863cdac711f1956baf8eb9588e060755f7d3c4c979e70ea1e1f32cd7" +dependencies = [ + "indexmap", + "serde_core", + "serde_spanned", + "toml_datetime", + "toml_parser", + "toml_writer", + "winnow", +] + +[[package]] +name = "toml_datetime" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_edit" +version = "0.25.19+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd43688c4858d7264ae1cf9a9f874a67c3feb74a883b1cd7bebd6a4ea8307218" +dependencies = [ + "indexmap", + "toml_datetime", + "toml_parser", + "toml_writer", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.1.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" +dependencies = [ + "winnow", +] + +[[package]] +name = "toml_writer" +version = "1.2.0+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "009dbb7700f11c55ef83aebbe4c0e9cf1f1ac0844bd8d6f00dc38f302026e13a" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tree_magic_mini" +version = "3.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8765b90061cba6c22b5831f675da109ae5561588290f9fa2317adab2714d5a6" +dependencies = [ + "memchr", + "nom 8.0.0", + "petgraph", +] + +[[package]] +name = "ttf-parser" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" + +[[package]] +name = "tungstenite" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18e5b8366ee7a95b16d32197d0b2604b43a0be89dc5fac9f8e96ccafbaedda8a" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http", + "httparse", + "log", + "rand", + "sha1", + "thiserror 1.0.69", + "utf-8", +] + +[[package]] +name = "typed-index-collections" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "898160f1dfd383b4e92e17f0512a7d62f3c51c44937b23b6ffc3a1614a8eaccd" +dependencies = [ + "bincode", + "serde", +] + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "udev" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af4e37e9ea4401fc841ff54b9ddfc9be1079b1e89434c1a6a865dd68980f7e9f" +dependencies = [ + "io-lifetimes", + "libc", + "libudev-sys", + "pkg-config", +] + +[[package]] +name = "uds_windows" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e" +dependencies = [ + "memoffset", + "tempfile", + "windows-sys 0.61.2", +] + +[[package]] +name = "unicase" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357cc3acc6a036009fd6c973ed009037c732d60d0b4f6c673e9041497482a28f" + +[[package]] +name = "unicode-bidi" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-linebreak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" + +[[package]] +name = "unicode-script" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa04c955db05429d464c74d495c1ee677e1866e783a4c3747f9c0cef7756cabf" + +[[package]] +name = "unicode-segmentation" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" + +[[package]] +name = "unicode-vo" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94" + +[[package]] +name = "unicode-width" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca718471876992059f251e33aafc334346ada08042b7661dd1fe313a9bced557" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "unty" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae" + +[[package]] +name = "ureq" +version = "2.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02d1a66277ed75f640d608235660df48c8e3c19f3b4edb6a263315626cc3c01d" +dependencies = [ + "base64 0.22.1", + "log", + "once_cell", + "serde", + "serde_json", + "url", +] + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "usvg" +version = "0.48.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "977d0a4abdef933f424a99fe09f95576e089b90aebc6f016a3bc813762493e91" +dependencies = [ + "base64 0.23.1", + "data-url", + "flate2", + "fontdb", + "harfrust", + "imagesize", + "kurbo", + "log", + "pico-args", + "roxmltree", + "simplecss", + "siphasher", + "skrifa", + "strict-num", + "svgtypes", + "tiny-skia-path 0.12.0", + "unicode-bidi", + "unicode-script", + "unicode-vo", + "xmlwriter", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "utf8_iter" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af3bd9d3e571c26fcce9d033b87ea5ab061b8d2ffe9b7a5675d810d68f03edf0" +dependencies = [ + "utf_types", +] + +[[package]] +name = "utf_types" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6" + +[[package]] +name = "uuid" +version = "1.29.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bed99139f7dac9b5cfe5f17be4d66dc7079a34dee1d74bcc77217119240e267c" +dependencies = [ + "js-sys", + "serde_core", + "wasm-bindgen", +] + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "vtable" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "515a4b5b1399cc46fb0dc4081436cb40a3852a2d3e94fd1fa50bb68a334896eb" +dependencies = [ + "const-field-offset", + "portable-atomic", + "stable_deref_trait", + "vtable-macro", +] + +[[package]] +name = "vtable-macro" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8191d73ececf73fc94e65809bf0e667525a0bcff9aeeb8d042a4173a508332a1" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.4+wasi-0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c" +dependencies = [ + "cfg-if", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e14e0327cb5368ad60ccb22d04a9827a693c95a926d8d125e9fa39e0baec501" +dependencies = [ + "js-sys", + "tokio", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.10", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wayland-backend" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38a91b4eaddff87b1cd1074985e3713da4af2c49742d1b356b2c01670a67a078" +dependencies = [ + "cc", + "downcast-rs", + "rustix 1.1.6", + "scoped-tls", + "smallvec", + "wayland-sys", +] + +[[package]] +name = "wayland-client" +version = "0.31.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c36a0f861ad76d0901f2800b46321410d9f73f2ea88aac0650d86c32688073" +dependencies = [ + "bitflags 2.13.2", + "rustix 1.1.6", + "wayland-backend", + "wayland-scanner", +] + +[[package]] +name = "wayland-csd-frame" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" +dependencies = [ + "bitflags 2.13.2", + "cursor-icon", + "wayland-backend", +] + +[[package]] +name = "wayland-cursor" +version = "0.31.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a52d18780be9b1314328a3de5f930b73d2200112e3849ca6cb11822793fb34d" +dependencies = [ + "rustix 1.1.6", + "wayland-client", + "xcursor", +] + +[[package]] +name = "wayland-protocols" +version = "0.32.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d0c813de3daa2ed6520af85a3bd49b0e722a3078506899aa9686fea58dc4b6" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb04e52f7836d7c7976c78ca0250d61e33873c34156a2a1fc9474828ec268234" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-scanner" +version = "0.31.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "338e30461b3a2b67d70eb30a6d89f8e0c93a833e07d2ae89085cd070c4a00ac0" +dependencies = [ + "proc-macro2", + "quick-xml", + "quote", +] + +[[package]] +name = "wayland-sys" +version = "0.31.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8eab23fefc9e41f8e841df4a9c707e8a8c4ed26e944ef69297184de2785e3be" +dependencies = [ + "dlib", + "log", + "once_cell", + "pkg-config", +] + +[[package]] +name = "web-sys" +version = "0.3.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7d179596ff5ec0f6de4db64d54011bde6289cc49603d3a6e4ce3f329207ab88" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webbrowser" +version = "1.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe8d20d0214027baf11b8b0cc307c1da7657d8f4db9aa956f7de27a6fb1acbd5" +dependencies = [ + "jni", + "log", + "ndk-context", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "url", + "web-sys", +] + +[[package]] +name = "weezl" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88" + +[[package]] +name = "wgpu" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527ccdf43dd5b2e8676eed9984ce00e2bbb0a1b85b70c1969dcb6cd2eb55ab9e" +dependencies = [ + "arrayvec", + "bitflags 2.13.2", + "bytemuck", + "cfg-if", + "cfg_aliases", + "document-features", + "hashbrown 0.17.1", + "log", + "portable-atomic", + "profiling", + "raw-window-handle", + "smallvec", + "static_assertions", + "wgpu-core", + "wgpu-hal", + "wgpu-types", +] + +[[package]] +name = "wgpu-core" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c018fce9b6270aa203c2fdd56f3cce996713534bd757e4ea58c8560b121f14" +dependencies = [ + "arrayvec", + "bit-set", + "bit-vec", + "bitflags 2.13.2", + "bytemuck", + "cfg_aliases", + "document-features", + "hashbrown 0.17.1", + "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-apple", + "wgpu-core-deps-windows-linux-android", + "wgpu-hal", + "wgpu-naga-bridge", + "wgpu-types", +] + +[[package]] +name = "wgpu-core-deps-apple" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "061f3d319a40d39d00b1ecc2c33b89fe21d4e6fe01859df3500a3a8ecccd6b68" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-core-deps-windows-linux-android" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7586165fd5f6d881cb9ce4bb71f40d6caab2c0f1837e3fc1d9788a197fb6004f" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-hal" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6b7fb58561a792bc237628ba0792e332de418fefe145f13b5ed8201e6d52f58" +dependencies = [ + "android_system_properties", + "arrayvec", + "ash", + "bit-set", + "bitflags 2.13.2", + "block2 0.6.2", + "bytemuck", + "cfg-if", + "cfg_aliases", + "gpu-allocator", + "hashbrown 0.17.1", + "libc", + "libloading", + "log", + "naga", + "naga-types", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", + "objc2-metal 0.3.2", + "objc2-quartz-core 0.3.2", + "once_cell", + "ordered-float", + "parking_lot", + "portable-atomic", + "portable-atomic-util", + "profiling", + "range-alloc", + "raw-window-handle", + "raw-window-metal", + "renderdoc-sys", + "smallvec", + "static_assertions", + "thiserror 2.0.21", + "wgpu-naga-bridge", + "wgpu-types", + "windows", + "windows-core", +] + +[[package]] +name = "wgpu-naga-bridge" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f62e73117bb7a62bfd9c5a5841438a823f6566c6442a808ee269d2d055c081" +dependencies = [ + "naga", + "wgpu-types", +] + +[[package]] +name = "wgpu-types" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99dad6f1fbdbbdb4c278a6508b059d44688f5cebddf78d005a46a31340269286" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "log", + "naga-types", + "raw-window-handle", + "static_assertions", +] + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "windows" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580" +dependencies = [ + "windows-collections", + "windows-core", + "windows-future", + "windows-numerics", +] + +[[package]] +name = "windows-collections" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610" +dependencies = [ + "windows-core", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-future" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb" +dependencies = [ + "windows-core", + "windows-link", + "windows-threading", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-numerics" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26" +dependencies = [ + "windows-core", + "windows-link", +] + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-threading" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winit" +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", + "core-foundation", + "core-graphics", + "cursor-icon", + "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", + "sctk-adwaita", + "smithay-client-toolkit", + "smol_str 0.2.2", + "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", +] + +[[package]] +name = "winnow" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef" +dependencies = [ + "memchr", +] + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[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 = "write-fonts" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cae90d1d9f6d1d36ef116b0b1e651a6d7c12ba925439d4d06ff9adc94662a3d8" +dependencies = [ + "font-types", + "indexmap", + "kurbo", + "log", + "read-fonts", +] + +[[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", +] + +[[package]] +name = "x11rb-protocol" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd" + +[[package]] +name = "xattr" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "963d6fab92d5504b971dc8bd90ca743c2575e590bc8071ea5bc571598667ae08" +dependencies = [ + "libc", + "rustix 1.1.6", +] + +[[package]] +name = "xcursor" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "163b33ed8786455e2fa5d72f554057ce3f3182425434f756cd39c99839d88e23" + +[[package]] +name = "xkbcommon" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a974f48060a14e95705c01f24ad9c3345022f4d97441b8a36beb7ed5c4a02d" +dependencies = [ + "libc", + "memmap2", + "xkeysym", +] + +[[package]] +name = "xkbcommon-dl" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" +dependencies = [ + "bitflags 2.13.2", + "dlib", + "log", + "once_cell", + "xkeysym", +] + +[[package]] +name = "xkeysym" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" + +[[package]] +name = "xml-rs" +version = "0.8.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e450f9b2ed1dff33c94c12589a87338689467b9c4f5d8a5710bd09a847d2c8a7" + +[[package]] +name = "xmlwriter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" + +[[package]] +name = "yazi" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac366ea532fa8ee6a992cec9dea525b1dc284e69702f36c2ab5fbebadc81ec86" + +[[package]] +name = "yeslogic-fontconfig-sys" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d8b8abf912b9a29ff112e1671c97c33636903d13a69712037190e6805af4f76" +dependencies = [ + "dlib", + "once_cell", + "pkg-config", +] + +[[package]] +name = "yoke" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", + "synstructure", +] + +[[package]] +name = "zbus" +version = "5.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5db4be7c075cb421e4b7ee645541604239bd243ba7c357511f4ff3a74b555907" +dependencies = [ + "async-broadcast", + "async-executor", + "async-io", + "async-lock", + "async-process", + "async-recursion", + "async-task", + "async-trait", + "blocking", + "enumflags2", + "event-listener", + "futures-core", + "futures-lite", + "hex", + "libc", + "ordered-stream", + "rustix 1.1.6", + "serde", + "serde_repr", + "tracing", + "uds_windows", + "uuid", + "windows-sys 0.61.2", + "winnow", + "zbus_macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zbus_macros" +version = "5.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2990635d09ade6df1868f72f8cac69a876a90981e8bd3c40b1be413f8dc88f40" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 3.0.10", + "zbus_names", + "zvariant", + "zvariant_utils", +] + +[[package]] +name = "zbus_names" +version = "4.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812a12be4ead7a59e18ea8f047d08add0066b73bc62fc1467066a2472ae088dd" +dependencies = [ + "serde", + "winnow", + "zvariant", +] + +[[package]] +name = "zcheapstr" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "939f186d9ecebe044315a5cb6d6f78568bbc21152adc954d5a0c2f58bdbc9920" +dependencies = [ + "serde", +] + +[[package]] +name = "zeno" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6df3dc4292935e51816d896edcd52aa30bc297907c26167fec31e2b0c6a32524" + +[[package]] +name = "zerocopy" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "zerovec" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" +dependencies = [ + "serde", + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "zlib-rs" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" + +[[package]] +name = "zune-core" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b" + +[[package]] +name = "zune-jpeg" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296" +dependencies = [ + "zune-core", +] + +[[package]] +name = "zvariant" +version = "5.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80bf6d6cd6a4b601acb64cfb8284cdc643fcfa75ef26ae3c46ec8aa4e8a1fbb7" +dependencies = [ + "endi", + "enumflags2", + "serde", + "winnow", + "zcheapstr", + "zvariant_derive", + "zvariant_utils", +] + +[[package]] +name = "zvariant_derive" +version = "5.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2672456ba1cb54b5eaec136e63135b3c7495fb938e53b28a62e633496d486d" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 3.0.10", + "zvariant_utils", +] + +[[package]] +name = "zvariant_utils" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bad0294361a320b694a328460dc73add56c306150f5cb6bfafc44446120008a3" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "syn 3.0.10", + "winnow", +] diff --git a/cockpit/Cargo.toml b/cockpit/Cargo.toml new file mode 100644 index 00000000..361b1a6c --- /dev/null +++ b/cockpit/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "cockpit" +version = "0.1.0" +edition = "2021" +description = "Natives Windows-Cockpit (Rust + Slint): Neuschreibung der macOS-App unter mac/" +build = "build.rs" + +# Eigener Baum: das Crate gehoert nicht zum Wurzel-Cargo (src/), sondern steht allein. +[workspace] + +[dependencies] +serde_json = "1" +# Nur ws:// / http:// lokal: weder tungstenite noch ureq mit TLS. +tungstenite = { version = "0.24", default-features = false, features = ["handshake"] } +ureq = { version = "2", default-features = false, features = ["json"] } +slint = { version = "1", default-features = false, features = ["std", "compat-1-2", "backend-winit", "renderer-software"] } + +[build-dependencies] +slint-build = "1" + +# Nur fuer das Vorschaubild (examples/bild.rs): Systemschriften im Software-Renderer, PNG schreiben. +[dev-dependencies] +slint = { version = "1", default-features = false, features = ["software-renderer-systemfonts"] } +png = "0.18" diff --git a/cockpit/build.rs b/cockpit/build.rs new file mode 100644 index 00000000..95cca9c8 --- /dev/null +++ b/cockpit/build.rs @@ -0,0 +1,3 @@ +fn main() { + slint_build::compile("ui/fenster.slint").expect("Slint-Oberflaeche uebersetzen"); +} diff --git a/cockpit/examples/bild.rs b/cockpit/examples/bild.rs new file mode 100644 index 00000000..cbd7ceaf --- /dev/null +++ b/cockpit/examples/bild.rs @@ -0,0 +1,61 @@ +//! Zeichnet das Cockpit ohne Fenster in eine PNG-Datei (Software-Renderer), zum Pruefen des Aufbaus: +//! +//! cargo run --example bild -- [cash|uebung|frage|zuschauer|getrennt] [ansicht.json] + +use std::collections::BTreeSet; +use std::rc::Rc; + +use cockpit::ansicht::Ansicht; +use cockpit::anzeige::{Bedienung, Verbindung}; +use cockpit::bruecke; +use cockpit::formate::SpielFormat; +use cockpit::spielplan::{Modus, Spielplan}; +use slint::platform::software_renderer::{MinimalSoftwareWindow, RepaintBufferType}; +use slint::platform::{Platform, WindowAdapter}; +use slint::{ComponentHandle, PhysicalSize, PlatformError, Rgb8Pixel}; + +struct P(Rc); + +impl Platform for P { + fn create_window_adapter(&self) -> Result, PlatformError> { + Ok(self.0.clone()) + } +} + +fn main() { + let args: Vec = std::env::args().skip(1).collect(); + let aus = args.first().cloned().unwrap_or_else(|| "cockpit.png".into()); + let fall = args.get(1).map(String::as_str).unwrap_or("cash"); + let fenster = MinimalSoftwareWindow::new(RepaintBufferType::NewBuffer); + slint::platform::set_platform(Box::new(P(fenster.clone()))).unwrap(); + + let mut ansicht = Ansicht::default(); + if let Some(p) = args.get(2) { + ansicht.anwenden(&std::fs::read_to_string(p).unwrap()); + } + let mut b = Bedienung::default(); + b.verbindung = if fall == "getrennt" { Verbindung::Getrennt("Verbindung abgerissen".into()) } else { Verbindung::Verbunden }; + let mut plan = Spielplan::neu(if matches!(fall, "cash") { Modus::Echt } else { Modus::Uebung }, 4, None); + plan.gemessen = BTreeSet::from([SpielFormat::Cash, SpielFormat::CashPlo, SpielFormat::Aof, SpielFormat::Bombpot]); + plan.set_tische_bis(None); + b.wahl = plan; + b.cash_fragen = fall == "frage"; + + let f = bruecke::vorschau(ansicht, b).unwrap(); + f.show().unwrap(); + let (w, h) = (440u32, 900u32); + fenster.set_size(PhysicalSize::new(w, h)); + let mut puffer = vec![Rgb8Pixel::new(0, 0, 0); (w * h) as usize]; + slint::platform::update_timers_and_animations(); + fenster.draw_if_needed(|r| { + r.render(&mut puffer, w as usize); + }); + let datei = std::fs::File::create(&aus).unwrap(); + let mut enc = png::Encoder::new(std::io::BufWriter::new(datei), w, h); + enc.set_color(png::ColorType::Rgb); + enc.set_depth(png::BitDepth::Eight); + let mut wr = enc.write_header().unwrap(); + let roh: Vec = puffer.iter().flat_map(|p| [p.r, p.g, p.b]).collect(); + wr.write_image_data(&roh).unwrap(); + println!("{aus}"); +} diff --git a/cockpit/src/ansicht.rs b/cockpit/src/ansicht.rs new file mode 100644 index 00000000..a52f5a62 --- /dev/null +++ b/cockpit/src/ansicht.rs @@ -0,0 +1,98 @@ +//! Der Stand der Ansicht, wie der Server ihn ueber /ws schickt: beim Verbinden alle Bereiche, +//! danach nur die geaenderten (sicht/ANSICHT.md; Ansicht.swift). + +use serde_json::Value; + +use crate::modelle::*; +use crate::nachsichtig::Feld; +use crate::wachstum::Wachstum; + +/// Antwort auf einen Knopf (POST /api/steuern oder WebSocket-`rueckmeldung`). +/// Die Zusatzansichten (Stimme & KI, Sendung, Humanisierung) folgen mit den jeweiligen Bereichen. +#[derive(Clone, Debug, PartialEq)] +pub struct Rueckmeldung { + pub aktion: Option, + pub ok: bool, + pub text: String, + pub raum: Option, + pub bild: Option, +} + +impl Rueckmeldung { + /// Ohne boolesches `ok` ist es keine Rueckmeldung. + pub fn aus_json(v: &Value) -> Option { + let o = v.as_object()?; + let ok = o.get("ok")?.as_bool()?; + let s = |k: &str| o.get(k).and_then(Value::as_str).map(String::from); + Some(Rueckmeldung { + aktion: s("aktion"), + ok, + text: s("text").unwrap_or_else(|| if ok { "erledigt" } else { "fehlgeschlagen" }.to_string()), + raum: s("raum"), + bild: s("bild"), + }) + } +} + +/// Was eine Nachricht vom Server bewirkt hat. +#[derive(Clone, Debug, PartialEq)] +pub enum Nachricht { + /// Diese Bereiche kamen neu (auch kaputte: sie sind jetzt `None`). + Ansicht(Vec), + Rueckmeldung(Rueckmeldung), + Unbekannt, +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Ansicht { + pub kopf: Option, + pub jetzt: Option, + pub wachstum: Option, + pub entscheidungen: Option, + pub geld: Option, + pub sitzen: Option, + pub stil: Option, + pub ticker: Option, + pub zuschauer: Option, + pub stand: Option, +} + +impl Ansicht { + /// Eine Textnachricht einarbeiten. Panikt nie; Unlesbares ist `Unbekannt`, ein unlesbarer + /// Bereich wird `None` (die App zeigt dann seinen Leerzustand), die anderen kommen trotzdem an. + pub fn anwenden(&mut self, text: &str) -> Nachricht { + let Ok(json) = serde_json::from_str::(text) else { return Nachricht::Unbekannt }; + let Some(f) = Feld::aus(&json) else { return Nachricht::Unbekannt }; + match f.roh("typ").and_then(Value::as_str) { + Some("ansicht") => { + let Some(teile) = f.roh("teile").and_then(Value::as_object) else { return Nachricht::Unbekannt }; + let mut neu = Vec::new(); + for (name, wert) in teile { + let Some(b) = Bereich::aus_name(name) else { continue }; + self.setzen(b, wert); + neu.push(b); + } + if let Some(s) = f.roh("stand").and_then(Value::as_f64) { + self.stand = Some(s); + } + Nachricht::Ansicht(neu) + } + Some("rueckmeldung") => Rueckmeldung::aus_json(&json).map_or(Nachricht::Unbekannt, Nachricht::Rueckmeldung), + _ => Nachricht::Unbekannt, + } + } + + fn setzen(&mut self, b: Bereich, w: &Value) { + match b { + Bereich::Kopf => self.kopf = Kopf::aus(w), + Bereich::Jetzt => self.jetzt = Jetzt::aus(w), + Bereich::Wachstum => self.wachstum = Wachstum::aus(w), + Bereich::Entscheidungen => self.entscheidungen = Entscheidungen::aus(w), + Bereich::Geld => self.geld = Geld::aus(w), + Bereich::Sitzen => self.sitzen = Sitzen::aus(w), + Bereich::Stil => self.stil = Stil::aus(w), + Bereich::Ticker => self.ticker = Ticker::aus(w), + Bereich::Zuschauer => self.zuschauer = Zuschauer::aus(w), + } + } +} diff --git a/cockpit/src/anzeige.rs b/cockpit/src/anzeige.rs new file mode 100644 index 00000000..820e31bc --- /dev/null +++ b/cockpit/src/anzeige.rs @@ -0,0 +1,354 @@ +//! Was das Cash-Fenster zeigt, rein aus Daten gerechnet - ohne Slint. Die Brücke (`bruecke.rs`) +//! kopiert das Ergebnis in die Oberfläche. Beschriftungen wie in mac/Sources/Cockpit +//! (Spielplan.swift `PlanKacheln`/`FormatWahl`, ModusLeiste.swift, Wurzel.swift). + +use std::collections::BTreeSet; +use std::time::{Duration, Instant}; + +use serde_json::Value; + +use crate::ansicht::Ansicht; +use crate::format::zahl; +use crate::formate::SpielFormat; +use crate::hauptknopf::Hauptknopf; +use crate::modelle::Ton; +use crate::plankarte::{plan_text, Zeit}; +use crate::spielplan::{Modus, Spielplan, Tischform}; + +/// So lange fuehrt der optimistische Not-Aus (Cockpit.swift `notAusGnade`). +pub const NOT_AUS_GNADE: Duration = Duration::from_secs(6); + +/// Spielbar-Rueckfall, wenn der Server nichts sagt (FormatWahl.swift `SPIELBAR`). +const SPIELBAR: [SpielFormat; 3] = [SpielFormat::Cash, SpielFormat::Aof, SpielFormat::Bombpot]; + +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum Verbindung { + Startet, + Verbunden, + Getrennt(String), +} + +/// Der Teil des Zustands, der nur im Fenster lebt (Cockpit.swift): die Wahl, Rueckfragen, Laufendes. +#[derive(Clone, Debug)] +pub struct Bedienung { + pub wahl: Spielplan, + pub verbindung: Verbindung, + /// "Echtgeld einschalten?" steht offen. + pub cash_fragen: bool, + /// Knoepfe, deren Antwort noch aussteht. + pub laufend: BTreeSet, + pub not_aus_gewollt: Option, + /// Zuletzt gemeldet (Rueckmeldung): Text, ok. + pub meldung: Option<(String, bool)>, + /// Gewaehlter Reiter: 0 Cash, 1 Haende, 2 Statistik, 3 Protokoll. + pub reiter: i32, +} + +impl Default for Bedienung { + fn default() -> Self { + Bedienung { + wahl: Spielplan::standard(), + verbindung: Verbindung::Startet, + cash_fragen: false, + laufend: BTreeSet::new(), + not_aus_gewollt: None, + meldung: None, + reiter: 0, + } + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct Karte { + pub id: String, + pub name: String, + pub hinweis: String, + pub symbol: &'static str, + pub anzahl: i64, + pub voll: bool, + /// Platz in der Fuellfolge (nur mit Ausweichen), sonst -1. + pub rang: i32, +} + +#[derive(Clone, Debug, PartialEq)] +pub struct Anzeige { + /// 0 Zuschauer, 1 Uebung, 2 Echtgeld. + pub modus: i32, + pub modus_gesperrt: bool, + pub cash_frage: bool, + pub cash: bool, + pub tische_wert: String, + pub tische_fuss: String, + pub geld_titel: String, + pub geld_wert: String, + pub geld_fuss: String, + /// Der Inhalt des Budget-Felds (leer = "alles"); nur in Echtgeld eintippbar. + pub budget_text: String, + pub plan_titel: String, + pub plan_fuss: String, + pub plan_unendlich: bool, + /// 0 "immer N", 1 "ausgelost". + pub sitzung_art: i32, + pub sitzung_immer: String, + pub stepper_text: String, + pub stepper_auf_ok: bool, + pub stepper_ab_ok: bool, + /// 0 Multiway, 1 Heads-Up, 2 Beide. + pub form: i32, + pub micro_only: bool, + pub zusammen: String, + pub ausweichen: bool, + pub ziel_text: String, + pub karten: Vec, + pub status_satz: String, + pub status_ton: Ton, + pub knopf_titel: String, + pub knopf_symbol: &'static str, + pub knopf_farbe: u32, + pub knopf_aktiv: bool, + pub beschaeftigt: bool, + pub not_aus: bool, + pub werkzeuge_aktiv: bool, + pub meldung: String, + pub meldung_ok: bool, +} + +fn tische_wort(n: i64) -> &'static str { + if n == 1 { + "Tisch" + } else { + "Tische" + } +} + +/// Offene Tische aus der Ansicht: kopf.tische_offen, sonst die Liste. +fn offene(a: &Ansicht) -> i64 { + a.kopf.as_ref().map_or(0, |k| k.tische_offen.unwrap_or(k.tische.len() as i64)) +} + +/// Mit Ausweichen die gewaehlten in Fuellfolge zuerst; sonst fest. Ohne Echtgeld nur Gemessenes +/// (oder schon Gewaehltes). Freeroll und VIP sind keine Kacheln (FormatWahl.swift `reihe`). +fn reihe(w: &Spielplan, gemessen: &BTreeSet) -> Vec { + let mut alle: Vec = if w.ziel().is_none() { + SpielFormat::ALLE.to_vec() + } else { + let mut v = w.folge(); + let rest: Vec = SpielFormat::ALLE.into_iter().filter(|f| !v.contains(f)).collect(); + v.extend(rest); + v + }; + alle.retain(|f| !matches!(f, SpielFormat::Freeroll | SpielFormat::Vip)); + if !w.cash() { + alle.retain(|f| gemessen.contains(f) || w.anzahl(*f) > 0); + } + alle +} + +fn symbol(f: SpielFormat) -> &'static str { + match f { + SpielFormat::Cash => "kreis", + SpielFormat::CashPlo => "cluster", + SpielFormat::Aof => "blitz", + SpielFormat::Bombpot => "flamme", + SpielFormat::Turnier => "pokal", + SpielFormat::Kpoker => "tastatur", + SpielFormat::Vip => "krone", + SpielFormat::Freeroll => "geschenk", + } +} + +/// Hinweis unter dem Namen (FormatWahl.swift `FormatKarte.hinweis`). +fn hinweis(f: SpielFormat, gemessen: bool, spielbar: bool) -> &'static str { + if !gemessen { + "ungemessen" + } else if !spielbar { + "Menü nicht gemessen" + } else if f == SpielFormat::Bombpot { + "PLO5 · Engine schwächer" + } else { + "" + } +} + +fn geld_feld<'a>(w: &'a Spielplan, k: &str) -> Option<&'a Value> { + w.geld.as_ref()?.get(k) +} + +impl Anzeige { + pub fn berechne(a: &Ansicht, b: &Bedienung, jetzt: Instant) -> Anzeige { + let w = &b.wahl; + let kopf = a.kopf.as_ref(); + let verbunden = b.verbindung == Verbindung::Verbunden; + let zuschauen = a.zuschauer.as_ref().is_some_and(|z| z.laeuft); + let laeuft = kopf.map(|k| k.laeuft); + let cash = w.cash() && !zuschauen; + let not_aus = kopf.is_some_and(|k| k.not_aus) + || b.not_aus_gewollt.is_some_and(|t| jetzt.saturating_duration_since(t) < NOT_AUS_GNADE); + + let knopf = if verbunden { Hauptknopf::waehlen(kopf, true, w, zuschauen) } else { Hauptknopf::Unbekannt }; + + let (status_satz, status_ton) = match &b.verbindung { + Verbindung::Startet => ("verbindet mit dem Cockpit-Server …".to_string(), Ton::Grau), + Verbindung::Getrennt(warum) => (format!("Server weg - {warum}"), Ton::Grau), + Verbindung::Verbunden => ( + kopf.and_then(|k| k.status.as_ref().and_then(|s| s.satz.clone()).or_else(|| k.text.clone())) + .unwrap_or_else(|| "liest …".into()), + kopf.and_then(|k| k.status.as_ref()).map_or(Ton::Grau, |s| s.ton()), + ), + }; + + // Tische-Kachel: die Summe (die Zahl je Format steht unter "Was spielen"). + let tische = w.tische(); + let tische_wert = w.tische_bis().map_or(tische.to_string(), |bis| format!("{tische}–{bis}")); + let tische_fuss = if laeuft == Some(true) { + format!("{} von {} offen", offene(a), tische) + } else { + "füllt der Läufer auf".into() + }; + + // Geld-Kachel: Echtgeld = Budget (eintippbar), sonst Chips mit dem Buy-in. + let reserve = geld_feld(w, "reserve_buyins").and_then(Value::as_f64).map_or(20, |x| x as i64); + let kauf_max = geld_feld(w, "kauf").and_then(Value::as_str).map_or(true, |s| s != "min"); + let budget_text = w.budget.map_or(String::new(), |x| zahl(Some(x), 0)); + let (geld_titel, geld_wert, geld_fuss) = if w.cash() { + ( + "Budget".to_string(), + if budget_text.is_empty() { "alles".to_string() } else { budget_text.clone() }, + format!("{reserve} Buy-ins/Tisch"), + ) + } else { + ("Geld".to_string(), "Chips".to_string(), format!("Buy-in {}", if kauf_max { "Max" } else { "Min" })) + }; + + let (plan_titel, plan_fuss) = plan_text(w); + + let bis = w.tische_bis(); + let (stepper_text, stepper_auf_ok, stepper_ab_ok) = match bis { + Some(bis) => (format!("{tische} bis {bis}"), bis < Spielplan::HOECHSTENS, bis > tische + 1), + None => (format!("{tische} {}", tische_wort(tische)), tische < Spielplan::HOECHSTENS, tische > 1), + }; + + let gemessen = kopf.and_then(|k| k.spielplan.as_ref()).map_or_else(|| w.gemessen.clone(), |p| p.gemessen.clone()); + let spielbar = + kopf.and_then(|k| k.spielplan.as_ref()).map_or_else(|| SPIELBAR.into_iter().collect(), |p| p.spielbar.clone()); + let folge = w.folge(); + let karten = reihe(w, &gemessen) + .into_iter() + .map(|f| Karte { + id: f.roh().into(), + name: f.name().into(), + hinweis: hinweis(f, gemessen.contains(&f), spielbar.contains(&f)).into(), + symbol: symbol(f), + anzahl: w.anzahl(f), + voll: if w.ziel().is_none() { tische >= Spielplan::HOECHSTENS } else { w.anzahl(f) >= Spielplan::HOECHSTENS }, + rang: if w.ziel().is_none() { -1 } else { folge.iter().position(|x| *x == f).map_or(-1, |i| i as i32) }, + }) + .collect(); + + let ziel_text = w.ziel().map_or(String::new(), |z| { + format!("Ziel: {z} Tisch{} · Zahlen unten sind Obergrenzen", if z == 1 { "" } else { "e" }) + }); + + Anzeige { + modus: if zuschauen { + 0 + } else if cash { + 2 + } else { + 1 + }, + modus_gesperrt: laeuft == Some(true), + cash_frage: b.cash_fragen, + cash, + tische_wert, + tische_fuss, + geld_titel, + geld_wert, + geld_fuss, + budget_text, + plan_titel, + plan_fuss, + plan_unendlich: Zeit::aus(w.zeitplan.as_ref()).sitzung.is_none(), + sitzung_art: i32::from(bis.is_some()), + sitzung_immer: format!("immer {tische}"), + stepper_text, + stepper_auf_ok, + stepper_ab_ok, + form: match w.tischform { + Tischform::Multiway => 0, + Tischform::Hu => 1, + Tischform::Beide => 2, + }, + micro_only: w.micro_only, + zusammen: if tische == 0 { "nichts gewählt".into() } else { format!("{tische} {} zusammen", tische_wort(tische)) }, + ausweichen: w.ziel().is_some(), + ziel_text, + karten, + status_satz, + status_ton, + knopf_titel: knopf.titel().into(), + knopf_symbol: knopf.symbol(), + knopf_farbe: knopf.farbe(), + knopf_aktiv: knopf.wirksam() && b.laufend.is_empty(), + beschaeftigt: !b.laufend.is_empty(), + not_aus, + werkzeuge_aktiv: verbunden && kopf.is_some_and(|k| !k.tische.is_empty()), + meldung: b.meldung.as_ref().map_or(String::new(), |m| m.0.clone()), + meldung_ok: b.meldung.as_ref().is_none_or(|m| m.1), + } + } +} + +/// Der Modus der Wahl als Wort (Meldungen). +pub fn modus_name(m: Modus) -> &'static str { + match m { + Modus::Uebung => "Übung", + Modus::Echt => "Echtgeld", + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn bedienung(cash: bool) -> Bedienung { + let mut b = Bedienung::default(); + b.verbindung = Verbindung::Verbunden; + let mut p = Spielplan::neu(if cash { Modus::Echt } else { Modus::Uebung }, 4, None); + p.gemessen = BTreeSet::from([SpielFormat::Cash, SpielFormat::CashPlo, SpielFormat::Aof, SpielFormat::Bombpot]); + b.wahl = p; + b + } + + #[test] + fn echtgeld_zeigt_die_drei_karten_wie_die_vorlage() { + let a = Anzeige::berechne(&Ansicht::default(), &bedienung(true), Instant::now()); + assert_eq!(a.modus, 2); + assert_eq!((a.tische_wert.as_str(), a.tische_fuss.as_str()), ("4", "füllt der Läufer auf")); + assert_eq!((a.geld_titel.as_str(), a.geld_wert.as_str(), a.geld_fuss.as_str()), ("Budget", "alles", "20 Buy-ins/Tisch")); + assert_eq!(a.plan_titel, "Dauerlauf"); + assert_eq!(a.stepper_text, "4 Tische"); + assert_eq!(a.zusammen, "4 Tische zusammen"); + let namen: Vec<&str> = a.karten.iter().map(|k| k.name.as_str()).collect(); + assert_eq!(namen, ["Cash NLH", "Cash PLO", "All-In or Fold", "Bomb Pot", "Turnier", "K-Poker"]); + assert_eq!(a.karten[0].anzahl, 4); + assert_eq!(a.karten[4].hinweis, "ungemessen"); + } + + #[test] + fn uebung_zeigt_nur_gemessene_formate() { + let a = Anzeige::berechne(&Ansicht::default(), &bedienung(false), Instant::now()); + assert_eq!(a.modus, 1); + assert_eq!(a.geld_titel, "Geld"); + assert_eq!(a.karten.len(), 4); + } + + #[test] + fn ohne_verbindung_ist_der_knopf_stumm() { + let mut b = bedienung(true); + b.verbindung = Verbindung::Getrennt("weg".into()); + let a = Anzeige::berechne(&Ansicht::default(), &b, Instant::now()); + assert!(!a.knopf_aktiv); + assert_eq!(a.status_satz, "Server weg - weg"); + } +} diff --git a/cockpit/src/bruecke.rs b/cockpit/src/bruecke.rs new file mode 100644 index 00000000..0dc638c0 --- /dev/null +++ b/cockpit/src/bruecke.rs @@ -0,0 +1,576 @@ +//! Die Brücke zwischen Oberfläche (Slint) und Kern: der Zustand des Fensters lebt auf dem +//! Oberflächen-Thread (`STAND`), der ws-Thread schiebt nur fertige `Ansicht`en hinein, Knöpfe +//! gehen in einem eigenen Thread über `netz::steuern` hinaus (Cockpit.swift: `steuern`, `abgleichen`, +//! `hauptknopfDruecken`, `modusWaehlen`, `planWeitergeben`). + +use std::cell::RefCell; +use std::rc::Rc; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::Arc; +use std::time::{Duration, Instant}; + +use serde_json::Value; +use slint::{ComponentHandle, ModelRc, SharedString, VecModel, Weak}; + +use crate::ansicht::{Ansicht, Nachricht, Rueckmeldung}; +use crate::anzeige::{Anzeige, Bedienung, Verbindung}; +use crate::formate::SpielFormat; +use crate::hauptknopf::Hauptknopf; +use crate::modelle::Ton; +use crate::netz::{self, Adresse}; +use crate::spielplan::{Modus, Spielplan, Tischform}; + +pub mod ui { + slint::include_modules!(); +} +use ui::{CashZustand, Cockpit, KartenZeile}; + +/// Eine eigene Eingabe (Ausweichen, Feineinstellung) wird so lange nicht vom noch alten +/// Server-Stand überschrieben (Cockpit.swift `abgleichen`). +const EINGABE_GNADE: Duration = Duration::from_secs(3); +/// Änderungen an einem laufenden Läufer gehen kurz gesammelt hinaus (`planWeitergeben`). +const PLAN_VERZUG: Duration = Duration::from_millis(600); + +struct Stand { + ansicht: Ansicht, + b: Bedienung, + adresse: Adresse, + letzte_eingabe: Instant, + /// Die Wahl wurde einmal aus dem Server-Plan gesetzt (der Start ist immer Übung). + geimpft: bool, + karten: Rc>, + plan_timer: slint::Timer, + meldung_timer: slint::Timer, +} + +thread_local! { + static STAND: RefCell> = const { RefCell::new(None) }; +} + +fn mit(f: impl FnOnce(&mut Stand) -> R) -> R { + STAND.with(|s| f(s.borrow_mut().as_mut().expect("Stand nicht angelegt"))) +} + +pub fn farbe(t: Ton) -> slint::Color { + match t { + Ton::Rot => slint::Color::from_rgb_u8(0xe5, 0x53, 0x4b), + Ton::Gelb => slint::Color::from_rgb_u8(0xe3, 0xb3, 0x41), + Ton::Gruen => slint::Color::from_rgb_u8(0x57, 0xc7, 0x8a), + Ton::Blau => slint::Color::from_rgb_u8(0x4f, 0x8c, 0xf0), + Ton::Grau => slint::Color::from_rgb_u8(0x8a, 0x8f, 0x98), + } +} + +fn rgb(x: u32) -> slint::Color { + slint::Color::from_rgb_u8((x >> 16) as u8, (x >> 8) as u8, x as u8) +} + +/// `ws://host:port/ws` -> Host und Port für `POST /api/steuern`. +pub fn adresse_aus(url: &str) -> Adresse { + let rest = url.split_once("://").map_or(url, |(_, r)| r); + let hostport = rest.split('/').next().unwrap_or(rest); + let vorgabe = Adresse::default(); + match hostport.rsplit_once(':') { + Some((h, p)) => Adresse { host: h.to_string(), port: p.parse().unwrap_or(vorgabe.port) }, + None => Adresse { host: hostport.to_string(), port: vorgabe.port }, + } +} + +/// Die Anzeige in die Oberfläche schreiben. +fn zeigen(f: &Cockpit) { + let (a, budget) = mit(|s| (Anzeige::berechne(&s.ansicht, &s.b, Instant::now()), s.karten.clone())); + let z = CashZustand { + modus: a.modus, + modus_gesperrt: a.modus_gesperrt, + cash_frage: a.cash_frage, + cash: a.cash, + tische_wert: a.tische_wert.clone().into(), + tische_fuss: a.tische_fuss.clone().into(), + geld_titel: a.geld_titel.clone().into(), + geld_wert: a.geld_wert.clone().into(), + geld_fuss: a.geld_fuss.clone().into(), + plan_titel: a.plan_titel.clone().into(), + plan_fuss: a.plan_fuss.clone().into(), + plan_unendlich: a.plan_unendlich, + sitzung_art: a.sitzung_art, + sitzung_immer: a.sitzung_immer.clone().into(), + stepper_text: a.stepper_text.clone().into(), + stepper_auf_ok: a.stepper_auf_ok, + stepper_ab_ok: a.stepper_ab_ok, + form: a.form, + micro_only: a.micro_only, + zusammen: a.zusammen.clone().into(), + ausweichen: a.ausweichen, + ziel_text: a.ziel_text.clone().into(), + status_satz: a.status_satz.clone().into(), + status_ton: farbe(a.status_ton), + knopf_titel: a.knopf_titel.clone().into(), + knopf_symbol: a.knopf_symbol.into(), + knopf_farbe: rgb(a.knopf_farbe), + knopf_aktiv: a.knopf_aktiv, + beschaeftigt: a.beschaeftigt, + not_aus: a.not_aus, + werkzeuge_aktiv: a.werkzeuge_aktiv, + meldung: a.meldung.clone().into(), + meldung_ok: a.meldung_ok, + }; + f.set_lage(z); + let zeilen: Vec = a + .karten + .iter() + .map(|k| KartenZeile { + id: k.id.clone().into(), + name: k.name.clone().into(), + hinweis: k.hinweis.clone().into(), + symbol: k.symbol.into(), + anzahl: k.anzahl as i32, + voll: k.voll, + rang: k.rang, + }) + .collect(); + budget.set_vec(zeilen); + if !f.get_budget_tippt() { + f.set_budget_feld(SharedString::from(a.budget_text.as_str())); + } +} + +fn zeigen_schwach(w: &Weak) { + if let Some(f) = w.upgrade() { + zeigen(&f); + } +} + +/// Der Server hat Neues gesagt: einarbeiten, die Wahl abgleichen, zeigen. +fn neue_ansicht(w: &Weak, a: Ansicht) { + mit(|s| { + s.ansicht = a; + abgleichen(s); + }); + zeigen_schwach(w); +} + +/// Läuft der Läufer mit einem Spielplan, zeigt das Cockpit genau den - außer eine gerade getätigte +/// Eingabe. Davor (Start) übernimmt die Wahl einmal den Plan des Servers, immer als Übung. +fn abgleichen(s: &mut Stand) { + let Some(kopf) = s.ansicht.kopf.as_ref() else { return }; + let Some(p) = kopf.spielplan.clone() else { return }; + s.b.wahl.gemessen = p.gemessen.clone(); + s.b.wahl.spielbar = p.spielbar.clone(); + if !s.geimpft { + s.geimpft = true; + let mut neu = p; + neu.modus = Modus::Uebung; + s.b.wahl = neu; + return; + } + if kopf.laeuft && p != s.b.wahl && s.letzte_eingabe.elapsed() > EINGABE_GNADE { + s.b.cash_fragen = false; + s.b.wahl = p; + } +} + +/// Eine Eingabe an der Wahl: ändern, merken, zeigen; läuft der Läufer, geht der Plan bald hinaus. +fn eingabe(w: &Weak, tun: impl FnOnce(&mut Spielplan)) { + mit(|s| { + tun(&mut s.b.wahl); + s.letzte_eingabe = Instant::now(); + }); + plan_weitergeben(w); + zeigen_schwach(w); +} + +fn plan_weitergeben(w: &Weak) { + let laeuft = mit(|s| s.ansicht.kopf.as_ref().is_some_and(|k| k.laeuft || k.pid.is_some())); + if !laeuft { + return; + } + let w2 = w.clone(); + mit(|s| { + s.plan_timer.start(slint::TimerMode::SingleShot, PLAN_VERZUG, move || { + let daten = mit(|s| s.b.wahl.daten()); + senden(&w2, vec![("spielplan_setzen".into(), Some(daten))]); + }); + }); +} + +/// Knöpfe nacheinander an den Server; scheitert einer, folgt keiner mehr. Die Rückmeldung kommt +/// als Meldung ins Fenster (Cockpit.swift `ausfuehren`/`melden`). +fn senden(w: &Weak, schritte: Vec<(String, Option)>) { + if schritte.is_empty() { + return; + } + let adresse = mit(|s| { + for (a, _) in &schritte { + s.b.laufend.insert(a.clone()); + } + s.adresse.clone() + }); + zeigen_schwach(w); + let w = w.clone(); + std::thread::spawn(move || { + let mut abbruch = false; + for (aktion, daten) in schritte { + if abbruch { + let w2 = w.clone(); + let _ = slint::invoke_from_event_loop(move || { + mit(|s| s.b.laufend.remove(&aktion)); + zeigen_schwach(&w2); + }); + continue; + } + let r = netz::steuern(&adresse, &aktion, None, daten); + abbruch = !r.ok; + let w2 = w.clone(); + let _ = slint::invoke_from_event_loop(move || { + mit(|s| s.b.laufend.remove(&aktion)); + melden(&w2, &r); + }); + } + }); +} + +fn melden(w: &Weak, r: &Rueckmeldung) { + mit(|s| { + s.b.meldung = Some((r.text.clone(), r.ok)); + let w2 = w.clone(); + // wie Cockpit.swift: ok 4 s, Fehler 12 s + let frist = Duration::from_secs(if r.ok { 4 } else { 12 }); + s.meldung_timer.start(slint::TimerMode::SingleShot, frist, move || { + mit(|s| s.b.meldung = None); + zeigen_schwach(&w2); + }); + }); + zeigen_schwach(w); +} + +fn zuschauen() -> bool { + mit(|s| s.ansicht.zuschauer.as_ref().is_some_and(|z| z.laeuft)) +} + +fn verdrahten(f: &Cockpit) { + let w = f.as_weak(); + + // Modus (ModusLeiste.swift `modusWaehlen`, `zuschauenWaehlen`, `cashBestaetigen`) + f.on_modus_gewaehlt({ + let w = w.clone(); + move |i| { + match i { + 0 => { + mit(|s| { + s.b.cash_fragen = false; + s.b.wahl.modus = Modus::Uebung; + }); + if !zuschauen() { + senden(&w, vec![("zuschauer_starten".into(), None)]); + } + } + 1 => { + mit(|s| { + s.b.cash_fragen = false; + s.b.wahl.modus = Modus::Uebung; + }); + if zuschauen() { + senden(&w, vec![("zuschauer_stoppen".into(), None)]); + } + } + _ => { + // Echtgeld nur bewusst: erst die Rückfrage + let schon = mit(|s| s.b.wahl.cash()); + if !schon { + mit(|s| s.b.cash_fragen = true); + } else if zuschauen() { + senden(&w, vec![("zuschauer_stoppen".into(), None)]); + } + } + } + zeigen_schwach(&w); + } + }); + f.on_cash_bestaetigt({ + let w = w.clone(); + move || { + mit(|s| { + s.b.cash_fragen = false; + s.b.wahl.modus = Modus::Echt; + }); + if zuschauen() { + senden(&w, vec![("zuschauer_stoppen".into(), None)]); + } + zeigen_schwach(&w); + } + }); + f.on_cash_abgebrochen({ + let w = w.clone(); + move || { + mit(|s| s.b.cash_fragen = false); + zeigen_schwach(&w); + } + }); + + // Budget: leer = "alles"; Tausenderpunkt und Komma wie in Spielplan.swift `budgetUebernehmen` + f.on_budget_gesetzt({ + let w = w.clone(); + move |t| { + let roh = t.replace('.', "").replace(',', "."); + let b = roh.trim().parse::().ok().filter(|b| *b > 0.0); + if mit(|s| s.b.wahl.budget) != b { + eingabe(&w, |p| p.budget = b); + } else { + zeigen_schwach(&w); + } + } + }); + + // Tische je Sitzung + f.on_sitzung_art_gewaehlt({ + let w = w.clone(); + move |i| { + eingabe(&w, |p| { + let bis = if i == 1 { Some((p.tische() + 2).min(Spielplan::HOECHSTENS)) } else { None }; + p.set_tische_bis(bis); + }) + } + }); + f.on_stepper_auf({ + let w = w.clone(); + move || { + eingabe(&w, |p| match p.tische_bis() { + Some(b) => p.set_tische_bis(Some((b + 1).min(Spielplan::HOECHSTENS))), + None => p.set_tische((p.tische() + 1).min(Spielplan::HOECHSTENS)), + }) + } + }); + f.on_stepper_ab({ + let w = w.clone(); + move || { + eingabe(&w, |p| match p.tische_bis() { + Some(b) => p.set_tische_bis(Some(b - 1)), + None => p.set_tische((p.tische() - 1).max(1)), + }) + } + }); + + // Tischform und Micro only + f.on_form_gewaehlt({ + let w = w.clone(); + move |i| { + eingabe(&w, |p| { + p.tischform = match i { + 1 => Tischform::Hu, + 2 => Tischform::Beide, + _ => Tischform::Multiway, + } + }) + } + }); + f.on_micro_umschalten({ + let w = w.clone(); + move || eingabe(&w, |p| p.micro_only = !p.micro_only) + }); + + // Was spielen + f.on_ausweichen_umschalten({ + let w = w.clone(); + move || eingabe(&w, |p| p.ausweichen(p.ziel().is_none())) + }); + f.on_ziel_auf({ + let w = w.clone(); + move || eingabe(&w, |p| p.set_ziel(p.ziel().map(|z| z + 1))) + }); + f.on_ziel_ab({ + let w = w.clone(); + move || eingabe(&w, |p| p.set_ziel(p.ziel().map(|z| (z - 1).max(1)))) + }); + f.on_karte_plus({ + let w = w.clone(); + move |id| { + if let Some(fo) = SpielFormat::aus_roh(&id) { + eingabe(&w, |p| p.setzen(fo, p.anzahl(fo) + 1)); + } + } + }); + f.on_karte_minus({ + let w = w.clone(); + move |id| { + if let Some(fo) = SpielFormat::aus_roh(&id) { + eingabe(&w, |p| p.setzen(fo, p.anzahl(fo) - 1)); + } + } + }); + f.on_karte_vor({ + let w = w.clone(); + move |id| { + if let Some(fo) = SpielFormat::aus_roh(&id) { + eingabe(&w, |p| p.vorziehen(fo)); + } + } + }); + + // Hauptknopf: die Schritte nacheinander (Spielplan setzen, dann Läufer starten ...) + f.on_knopf_gedrueckt({ + let w = w.clone(); + move || { + let (schritte, daten) = mit(|s| { + let verbunden = s.b.verbindung == Verbindung::Verbunden; + let zu = s.ansicht.zuschauer.as_ref().is_some_and(|z| z.laeuft); + let k = if verbunden { Hauptknopf::waehlen(s.ansicht.kopf.as_ref(), true, &s.b.wahl, zu) } else { Hauptknopf::Unbekannt }; + (if s.b.laufend.is_empty() { k.schritte() } else { &[] }, s.b.wahl.daten()) + }); + let liste = schritte + .iter() + .map(|a| (a.to_string(), (*a == "spielplan_setzen").then(|| daten.clone()))) + .collect(); + senden(&w, liste); + } + }); + + // Not-Aus: ein Klick hält an, bei aktivem Not-Aus löst derselbe Knopf ihn wieder. + // (Die Mac-App schreibt zusätzlich selbst die Stopp-Dateien und verlangt zum Lösen 1 s Halten: + // beides gehört zum Windows-Seam und fehlt hier noch.) + f.on_not_aus({ + let w = w.clone(); + move || { + let aktiv = mit(|s| Anzeige::berechne(&s.ansicht, &s.b, Instant::now()).not_aus); + if aktiv { + mit(|s| s.b.not_aus_gewollt = None); + senden(&w, vec![("not_aus_loeschen".into(), None)]); + } else { + mit(|s| s.b.not_aus_gewollt = Some(Instant::now())); + senden(&w, vec![("not_aus_setzen".into(), None)]); + } + zeigen_schwach(&w); + } + }); + + // Werkzeugleiste: nur, was der Server kennt und nichts zerstört. Pause (schreibt Dateien) und + // Schließen (fragt in der Mac-App erst nach) bleiben folgenlos. + f.on_werkzeug({ + let w = w.clone(); + move |aktion| { + if matches!(aktion.as_str(), "tische_vorn" | "tische_anordnen" | "foto") { + senden(&w, vec![(aktion.to_string(), None)]); + } + } + }); + + // Fensterchrome + f.on_ziehen({ + let w = w.clone(); + move |dx, dy| { + if let Some(f) = w.upgrade() { + let sf = f.window().scale_factor(); + let p = f.window().position(); + f.window().set_position(slint::PhysicalPosition::new(p.x + (dx * sf) as i32, p.y + (dy * sf) as i32)); + } + } + }); + f.on_minimieren({ + let w = w.clone(); + move || { + if let Some(f) = w.upgrade() { + f.window().set_minimized(true); + } + } + }); + f.on_schliessen(|| { + let _ = slint::quit_event_loop(); + }); + // Stillgelegt, solange die Einstellungen und Editoren fehlen: Zahnrad, Geld- und Plan-Pfeil. + f.on_einstellungen(|| {}); + f.on_geld_oeffnen(|| {}); + f.on_plan_oeffnen(|| {}); +} + +fn anlegen(adresse: Adresse, verbindung: Verbindung, ansicht: Ansicht) -> Result { + let f = Cockpit::new()?; + let karten = Rc::new(VecModel::::default()); + f.set_karten(ModelRc::from(karten.clone())); + let mut b = Bedienung::default(); + b.verbindung = verbindung; + STAND.with(|s| { + *s.borrow_mut() = Some(Stand { + ansicht, + b, + adresse, + letzte_eingabe: Instant::now() - Duration::from_secs(60), + geimpft: false, + karten, + plan_timer: slint::Timer::default(), + meldung_timer: slint::Timer::default(), + }) + }); + mit(abgleichen); + verdrahten(&f); + zeigen(&f); + Ok(f) +} + +/// Das Fenster mit einer festen Ansicht (ohne Server). +pub fn fest(ansicht: Ansicht) -> Result<(), Box> { + let f = anlegen(Adresse::default(), Verbindung::Getrennt("kein Server (cockpit --live starten)".into()), ansicht)?; + f.run()?; + Ok(()) +} + +/// Das Fenster, live über `/ws`: der ws-Thread schiebt die Ansicht in den Event-Loop. +pub fn live(url: String) -> Result<(), Box> { + let f = anlegen(adresse_aus(&url), Verbindung::Startet, Ansicht::default())?; + let halt = Arc::new(AtomicBool::new(false)); + let w = f.as_weak(); + let w_zustand = f.as_weak(); + let halt_thread = halt.clone(); + let thread = std::thread::spawn(move || { + netz::lauschen( + &url, + &halt_thread, + |a, n| match n { + Nachricht::Ansicht(_) => { + let (a, w) = (a.clone(), w.clone()); + let _ = slint::invoke_from_event_loop(move || neue_ansicht(&w, a)); + } + Nachricht::Rueckmeldung(r) => { + let (r, w) = (r.clone(), w.clone()); + let _ = slint::invoke_from_event_loop(move || melden(&w, &r)); + } + Nachricht::Unbekannt => {} + }, + |z| { + let v = match z { + "verbunden" => Verbindung::Verbunden, + "getrennt" => Verbindung::Getrennt("Verbindung abgerissen".into()), + andere => Verbindung::Getrennt(andere.strip_prefix("keine Verbindung: ").unwrap_or(andere).to_string()), + }; + let w = w_zustand.clone(); + let _ = slint::invoke_from_event_loop(move || { + mit(|s| s.b.verbindung = v); + zeigen_schwach(&w); + }); + }, + ) + }); + f.run()?; + halt.store(true, Ordering::Relaxed); + drop(thread); // endet beim nächsten Frame/Neuverbinden; der Prozess geht ohnehin + Ok(()) +} + +/// Für das Vorschaubild (`examples/bild.rs`): ein Fenster mit fester Ansicht und Bedienungszustand, +/// ohne Netz und ohne Fensterschleife. +pub fn vorschau(ansicht: Ansicht, bedienung: Bedienung) -> Result { + let f = anlegen(Adresse::default(), bedienung.verbindung.clone(), ansicht)?; + mit(|s| s.b = bedienung); + zeigen(&f); + Ok(f) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn adresse_aus_der_ws_url() { + assert_eq!(adresse_aus("ws://127.0.0.1:8787/ws"), Adresse { host: "127.0.0.1".into(), port: 8787 }); + assert_eq!(adresse_aus("ws://pc:9000/ws").port, 9000); + assert_eq!(adresse_aus("ws://pc/ws").port, 8787); + } +} diff --git a/cockpit/src/format.rs b/cockpit/src/format.rs new file mode 100644 index 00000000..25321bc1 --- /dev/null +++ b/cockpit/src/format.rs @@ -0,0 +1,60 @@ +//! Zahlen, wie die App sie zeigt: deutsch, Strich fuer unbekannt (Darstellung.swift `Format`). + +/// Ohne Gruppierung und Locale - fuer Texte, die aus Zahlen werden (Platz, Blinds). +pub fn roh(x: f64) -> String { + if x == x.round() && x.abs() < 1e15 { + format!("{}", x as i64) + } else { + format!("{x}") + } +} + +/// Deutsch gerundet: Tausenderpunkt, Komma, hoechstens `stellen` Nachkommastellen (ohne Nullen hinten). +pub fn zahl(x: Option, stellen: usize) -> String { + let Some(x) = x.filter(|x| x.is_finite()) else { return "–".into() }; + let fest = format!("{:.*}", stellen, x.abs()); + let (ganz, bruch) = match fest.split_once('.') { + Some((g, b)) => (g.to_string(), b.trim_end_matches('0').to_string()), + None => (fest.clone(), String::new()), + }; + let mut gruppiert = String::new(); + for (i, c) in ganz.chars().enumerate() { + if i > 0 && (ganz.len() - i) % 3 == 0 { + gruppiert.push('.'); + } + gruppiert.push(c); + } + let null = gruppiert == "0" && bruch.is_empty(); + let minus = if x < 0.0 && !null { "-" } else { "" }; + if bruch.is_empty() { + format!("{minus}{gruppiert}") + } else { + format!("{minus}{gruppiert},{bruch}") + } +} + +/// Stellen nach Groesse: ab 100 keine, ab 10 eine, sonst zwei. +pub fn auto(x: Option) -> String { + let Some(v) = x else { return "–".into() }; + let a = v.abs(); + zahl(x, if a >= 100.0 { 0 } else if a >= 10.0 { 1 } else { 2 }) +} + +pub fn prozent(x: Option) -> String { + match x { + Some(v) => format!("{} %", zahl(Some(v * 100.0), 0)), + None => "–".into(), + } +} + +pub fn vorzeichen(x: Option, stellen: usize) -> String { + let Some(v) = x else { return "–".into() }; + let t = zahl(Some(v.abs()), stellen); + if v > 0.0 { + format!("+{t}") + } else if v < 0.0 { + format!("−{t}") + } else { + t + } +} diff --git a/cockpit/src/formate.rs b/cockpit/src/formate.rs new file mode 100644 index 00000000..220cf0b5 --- /dev/null +++ b/cockpit/src/formate.rs @@ -0,0 +1,103 @@ +//! Was an einem Tisch gespielt wird - wie lesen/formate.py (Format.swift). Nicht der Modus (Uebung/Cash). + +use serde_json::Value; + +use crate::nachsichtig::Feld; + +/// Die Reihenfolge der Varianten ist die der Swift-`allCases` (die Vorgabe der Fuellfolge). +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub enum SpielFormat { + Cash, + CashPlo, + Aof, + Bombpot, + Turnier, + Kpoker, + Vip, + Freeroll, +} + +impl SpielFormat { + pub const ALLE: [SpielFormat; 8] = [ + SpielFormat::Cash, + SpielFormat::CashPlo, + SpielFormat::Aof, + SpielFormat::Bombpot, + SpielFormat::Turnier, + SpielFormat::Kpoker, + SpielFormat::Vip, + SpielFormat::Freeroll, + ]; + + pub fn roh(&self) -> &'static str { + match self { + SpielFormat::Cash => "cash", + SpielFormat::CashPlo => "cash_plo", + SpielFormat::Aof => "aof", + SpielFormat::Bombpot => "bombpot", + SpielFormat::Turnier => "turnier", + SpielFormat::Kpoker => "kpoker", + SpielFormat::Vip => "vip", + SpielFormat::Freeroll => "freeroll", + } + } + + pub fn aus_roh(s: &str) -> Option { + Self::ALLE.into_iter().find(|f| f.roh() == s) + } + + pub fn name(&self) -> &'static str { + match self { + SpielFormat::Cash => "Cash NLH", + SpielFormat::CashPlo => "Cash PLO", + SpielFormat::Aof => "All-In or Fold", + SpielFormat::Bombpot => "Bomb Pot", + SpielFormat::Turnier => "Turnier", + SpielFormat::Kpoker => "K-Poker", + SpielFormat::Vip => "VIP Arena", + SpielFormat::Freeroll => "Freerolls", + } + } +} + +/// Eine Zeile des Vergleichs je Format (wachstum.je_format): bb/100 mit 95-%-Spanne. +#[derive(Clone, Debug, PartialEq)] +pub struct FormatZeile { + pub format: String, + pub name: String, + pub haende: i64, + pub netto_bb: Option, + pub bb100: Option, + pub unten: Option, + pub oben: Option, +} + +impl FormatZeile { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + let format = f.text("format").unwrap_or_else(|| "unbekannt".into()); + Some(FormatZeile { + name: f.text("name").unwrap_or_else(|| format.clone()), + format, + haende: f.ganz("haende").unwrap_or(0), + netto_bb: f.zahl("netto_bb"), + bb100: f.zahl("bb100"), + unten: f.zahl("unten"), + oben: f.zahl("oben"), + }) + } +} + +/// Welches Format vorn liegt - nur wenn die Spannen es tragen (betrieb/statistik.bestes_format). +#[derive(Clone, Debug, PartialEq)] +pub struct FormatUrteil { + pub format: Option, + pub grund: String, +} + +impl FormatUrteil { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(FormatUrteil { format: f.text("format"), grund: f.text("grund").unwrap_or_default() }) + } +} diff --git a/cockpit/src/hauptknopf.rs b/cockpit/src/hauptknopf.rs new file mode 100644 index 00000000..cb5b4c32 --- /dev/null +++ b/cockpit/src/hauptknopf.rs @@ -0,0 +1,200 @@ +//! Der eine grosse Knopf im Kopf: immer der naechste sinnvolle Schritt (Hauptknopf.swift). +//! +//! Not-Aus aktiv -> Not-Aus loesen +//! Laeufer hoert schon auf -> Hoert auf: nichts zu tun - ein zweiter Stopp braeche das Auslaufen +//! ab; sofort heisst Not-Aus +//! Laeufer laeuft -> Aufhoeren (er setzt aus und steht nach der Hand auf) +//! Zuschauer laeuft -> Zuschauen beenden: von hier startet nie ein Laeufer +//! Fenster nicht lesbar -> Freigabe fehlt: ein Laeufer saehe keine Tische und braeche ab +//! CoinPoker zu -> CoinPoker starten (mit dem Debug-Port fuer die Lobby) +//! ohne Guthaben/Budget -> Budget fehlt: die Lobby waehlte sonst blind (betrieb/spielplan.py) +//! sonst -> Uebung/starten: Spielplan setzen, Laeufer starten - er +//! oeffnet selbst Tische bis zur Tischzahl +//! +//! Die Fallreihenfolge ist Teil des Vertrags; die Pruefungen halten sie fest. + +use crate::modelle::Kopf; +use crate::spielplan::Spielplan; + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Hauptknopf { + Unbekannt, + NotAusLoesen, + HoertAuf, + Aufhoeren, + ZuschauenBeenden, + FreigabeFehlt, + ClientStarten, + BudgetFehlt, + /// CoinPoker ohne Debug-Port und ohne offene Tische: neu starten. + ClientNeuStarten, + /// CoinPoker ohne Debug-Port, aber Tische offen: Tische oeffnen ginge nicht. + PortFehlt, + Starten { cash: bool }, +} + +impl Hauptknopf { + /// `fenster_lesbar`: hat die App (und damit Server und Laeufer, die sie startet) die + /// Bedienungshilfen-Freigabe? `wahl`: der Spielplan, wie er im Cockpit eingestellt ist. + pub fn waehlen(kopf: Option<&Kopf>, fenster_lesbar: bool, wahl: &Spielplan, zuschauen: bool) -> Hauptknopf { + let Some(k) = kopf else { return Hauptknopf::Unbekannt }; + if k.not_aus { + return Hauptknopf::NotAusLoesen; + } + if k.laeuft || k.pid.is_some() { + return if k.hoert_auf { Hauptknopf::HoertAuf } else { Hauptknopf::Aufhoeren }; + } + if zuschauen { + return Hauptknopf::ZuschauenBeenden; + } + if !fenster_lesbar { + return Hauptknopf::FreigabeFehlt; + } + if k.client == Some(false) { + return Hauptknopf::ClientStarten; + } + if k.client_port == Some(false) { + return if k.tische_offen.unwrap_or(0) > 0 { Hauptknopf::PortFehlt } else { Hauptknopf::ClientNeuStarten }; + } + if wahl.cash() && k.guthaben.is_none() && wahl.budget.is_none() { + return Hauptknopf::BudgetFehlt; + } + Hauptknopf::Starten { cash: wahl.cash() } + } + + /// Mit den Vorgaben der Swift-Signatur: Freigabe da, Standard-Plan, kein Zuschauen. + pub fn waehlen_vorgabe(kopf: Option<&Kopf>) -> Hauptknopf { + Self::waehlen(kopf, true, &Spielplan::standard(), false) + } + + /// Die Knoepfe von sicht/steuern.py, nacheinander; bricht einer ab, folgt keiner mehr. + pub fn schritte(&self) -> &'static [&'static str] { + match self { + Hauptknopf::NotAusLoesen => &["not_aus_loeschen"], + Hauptknopf::Aufhoeren => &["laeufer_stoppen"], + Hauptknopf::ZuschauenBeenden => &["zuschauer_stoppen"], + Hauptknopf::Starten { .. } => &["spielplan_setzen", "laeufer_starten"], + Hauptknopf::ClientStarten => &["client_starten"], + Hauptknopf::ClientNeuStarten => &["client_neu_starten"], + Hauptknopf::HoertAuf + | Hauptknopf::FreigabeFehlt + | Hauptknopf::BudgetFehlt + | Hauptknopf::PortFehlt + | Hauptknopf::Unbekannt => &[], + } + } + + /// Beschriftung fuer die Oberflaeche, wie in Wurzel.swift (`Hauptknopf.titel`). + pub fn titel(&self) -> &'static str { + match self { + Hauptknopf::Unbekannt => "…", + Hauptknopf::NotAusLoesen => "Not-Aus lösen", + Hauptknopf::HoertAuf => "Hört auf …", + Hauptknopf::Aufhoeren => "Aufhören", + Hauptknopf::ZuschauenBeenden => "Zuschauen beenden", + Hauptknopf::FreigabeFehlt => "Freigabe fehlt", + Hauptknopf::ClientStarten => "CoinPoker starten", + Hauptknopf::BudgetFehlt => "Budget angeben", + Hauptknopf::ClientNeuStarten => "CoinPoker neu starten", + Hauptknopf::PortFehlt => "Debug-Port fehlt", + Hauptknopf::Starten { cash: true } => "Echtgeld starten", + Hauptknopf::Starten { cash: false } => "Übung starten", + } + } + + /// Symbolname fuer `Icon` in ui/bausteine.slint (Wurzel.swift `symbol`, auf die vorhandenen Zeichen abgebildet). + pub fn symbol(&self) -> &'static str { + match self { + Hauptknopf::Unbekannt => "punkte", + Hauptknopf::NotAusLoesen | Hauptknopf::Starten { cash: false } => "play", + Hauptknopf::HoertAuf => "pause", + Hauptknopf::Aufhoeren => "hand", + Hauptknopf::Starten { cash: true } | Hauptknopf::ClientStarten | Hauptknopf::ClientNeuStarten => "blitz", + Hauptknopf::ZuschauenBeenden | Hauptknopf::FreigabeFehlt | Hauptknopf::BudgetFehlt | Hauptknopf::PortFehlt => "stop", + } + } + + /// Farbe des Symbols als 0xRRGGBB (Wurzel.swift `farbe`: orange, teal, rot, gruen, grau). + pub fn farbe(&self) -> u32 { + match self { + Hauptknopf::Aufhoeren | Hauptknopf::HoertAuf => 0xe3b341, + Hauptknopf::ZuschauenBeenden => 0x3fb98f, + Hauptknopf::Starten { cash: true } => 0xe5484d, + Hauptknopf::Starten { cash: false } | Hauptknopf::NotAusLoesen | Hauptknopf::ClientStarten | Hauptknopf::ClientNeuStarten => 0x57c78a, + _ => 0x8a8f98, + } + } + + /// Hat der Knopf etwas zu tun, wenn man ihn drueckt? + pub fn wirksam(&self) -> bool { + !self.schritte().is_empty() + } +} + +/// Es laeuft schon ein Cockpit: die Zeile, mit der sicht/start.py dann endet (sicht/instanz.py). +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct Belegt { + pub pid: i32, + pub art: Option, + pub port: Option, +} + +impl Belegt { + /// "Cockpit belegt: pid=20745 art=Terminal port=8787" ("?" heisst unbekannt) + pub fn aus_startzeile(zeile: &str) -> Option { + let rest = zeile.strip_prefix("Cockpit belegt:")?; + let mut pid = None; + let mut art = None; + let mut port = None; + for teil in rest.split(' ').filter(|t| !t.is_empty()) { + if let Some((k, v)) = teil.split_once('=') { + match k { + "pid" => pid = Some(v), + "art" => art = Some(v), + "port" => port = Some(v), + _ => {} + } + } + } + let pid: i32 = pid.and_then(|p| p.parse().ok()).filter(|p| *p > 0)?; + Some(Belegt { + pid, + art: art.filter(|a| *a != "?").map(String::from), + port: port.and_then(|p| p.parse().ok()), + }) + } + + /// Ein App-Server, dessen App tot ist (sein Elternprozess ist launchd/init, Pid 1): den darf die + /// naechste App ohne Rueckfrage uebernehmen. Ein Terminal-Cockpit oder eine lebende App nie. + /// (Unter Windows gibt es kein Pid 1 - der Windows-Seam muss "verwaist" selbst bestimmen.) + pub fn verwaist(&self, eltern_pid: Option) -> bool { + self.art.as_deref() == Some("App") && eltern_pid == Some(1) + } + + pub fn text(&self) -> String { + let wo = match self.art.as_deref() { + Some("Terminal") => " im Terminal".to_string(), + Some(a) => format!(" als {a}"), + None => String::new(), + }; + let port = self.port.map(|p| format!(", Port {p}")).unwrap_or_default(); + format!("Ein Cockpit läuft schon{wo} (PID {}{port}).", self.pid) + } +} + +/// Was bis zum Spielen fehlt - fuer die Ansicht, wenn nichts laeuft. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct Checkpunkt { + pub titel: &'static str, + pub erledigt: bool, +} + +pub fn checkliste(k: Option<&Kopf>, fenster_lesbar: bool) -> Vec { + vec![ + Checkpunkt { titel: "Freigaben erteilt", erledigt: fenster_lesbar }, + Checkpunkt { titel: "CoinPoker läuft", erledigt: k.map_or(true, |k| k.client != Some(false)) }, + Checkpunkt { titel: "Not-Aus gelöst", erledigt: !k.map_or(false, |k| k.not_aus) }, + Checkpunkt { titel: "Tisch offen", erledigt: k.and_then(|k| k.tische_offen).unwrap_or(0) > 0 }, + Checkpunkt { titel: "Läufer spielt", erledigt: k.map_or(false, |k| k.laeuft) }, + ] +} diff --git a/cockpit/src/kachel.rs b/cockpit/src/kachel.rs new file mode 100644 index 00000000..cab9fdbc --- /dev/null +++ b/cockpit/src/kachel.rs @@ -0,0 +1,137 @@ +//! Eine Kachel der Ansicht: ein Tisch mit Karten, offenem Zug und der letzten Entscheidung (Kachel.swift). + +use crate::ansicht::Ansicht; +use crate::modelle::{Klick, Raum, Zug}; +use crate::modus::TischModus; + +#[derive(Clone, Debug, PartialEq)] +pub struct LiveKachel { + pub raum: String, + pub raum_info: Option, + pub karten: Vec, + pub board: Vec, + pub topf: Option, + pub zug: Option, + pub aktion: Option, + pub betrag_bb: Option, + pub equity: Option, + pub klartext: Option, + pub klick: Option, + pub hinweis: Option, + /// Cash, Turnier oder K-Poker - vom offenen Zug, sonst von der letzten Entscheidung am Tisch. + pub modus: Option, +} + +const BESETZT: [&str; 4] = ["gesessen", "ausgesetzt", "wartend", "Dialog offen"]; + +impl LiveKachel { + /// Reihenfolge: der Tisch mit dem Zug zuerst, dann gesessene Raeume, dann Kopf-Tische; nichts doppelt. + pub fn alle(a: &Ansicht) -> Vec { + let laeuft = a.kopf.as_ref().is_some_and(|k| k.laeuft); + let mut raeume: Vec = Vec::new(); + let mut dazu = |r: Option<&str>| { + if let Some(r) = r.filter(|r| !r.is_empty()) { + if !raeume.iter().any(|x| x == r) { + raeume.push(r.to_string()); + } + } + }; + if laeuft { + dazu(a.jetzt.as_ref().and_then(|j| j.raum.as_deref())); + } + if let Some(s) = &a.sitzen { + for r in &s.raeume { + let besetzt = r.platz.is_some() + || BESETZT.contains(&r.zustand.as_deref().unwrap_or("")) + || r.fenster.unwrap_or(0) > 0; + if besetzt { + dazu(Some(&r.raum)); // offenes Fenster: immer sehen, was er am Tisch erkennt + } + } + } + if laeuft { + if let Some(k) = &a.kopf { + for t in &k.tische { + dazu(Some(t)); + } + } + } + raeume.iter().map(|r| kachel(r, a)).collect() + } +} + +fn kachel(raum: &str, a: &Ansicht) -> LiveKachel { + let info = a.sitzen.as_ref().and_then(|s| s.raeume.iter().find(|r| r.raum == raum)); + let mut k = LiveKachel { + raum: raum.to_string(), + raum_info: info.cloned(), + karten: vec![], + board: vec![], + topf: None, + zug: None, + aktion: None, + betrag_bb: None, + equity: None, + klartext: None, + klick: None, + hinweis: None, + modus: None, + }; + let log = info.and_then(|i| i.hand.as_ref()); + let letzte = a.entscheidungen.as_ref().and_then(|e| e.zeilen.iter().find(|z| z.raum.as_deref() == Some(raum))); + let jetzt_hier = a.jetzt.as_ref().filter(|j| j.raum.as_deref() == Some(raum)); + k.modus = jetzt_hier.and_then(|j| j.modus.clone()).or_else(|| letzte.and_then(|z| z.modus.clone())); + + let jetzt_traegt = jetzt_hier.filter(|j| !j.karten.is_empty() || j.entscheidung.is_some() || j.zug.is_some()); + let log_neuer = log.filter(|l| l.hand.is_some() && letzte.and_then(|z| z.hand.as_ref()) != l.hand.as_ref()); + if let Some(j) = jetzt_traegt { + k.karten = j.karten.clone(); + k.board = j.board.clone(); + k.topf = j.topf; + k.zug = j.zug.clone(); + k.klick = j.klick.clone(); + if let Some(e) = &j.entscheidung { + k.aktion = e.aktion_text.clone().or_else(|| e.aktion.clone()); + k.betrag_bb = e.betrag_bb; + k.equity = e.equity; + k.klartext = e.klartext.clone(); + } + } else if let Some(l) = log_neuer { + // Die letzte Entscheidung gehoert zu einer frueheren Hand: zeigen, was jetzt am Tisch liegt + k.karten = l.karten.clone(); + k.board = l.board.clone(); + k.topf = l.topf; + } else if let Some(d) = letzte { + k.karten = d.karten.clone(); + k.board = log.map_or_else(|| d.board.clone(), |l| l.board.clone()); + k.topf = log.and_then(|l| l.topf); + k.aktion = d.aktion_text.clone().or_else(|| d.aktion.clone()); + k.betrag_bb = d.betrag_bb; + k.equity = d.equity; + k.klartext = d.klartext.clone(); + k.klick = Some(Klick { status: d.klick.clone(), warum: d.klick_warum.clone(), beleg: d.beleg.clone() }); + } + + let zug_offen = jetzt_hier.and_then(|j| j.zug.as_ref()).is_some_and(|z| z.offen); + if let Some(t) = info.and_then(|i| i.tisch.as_ref()) { + if t.ich().is_none() && !zug_offen { + // Kein eigener Platz an diesem Tisch: eigene Karten und Entscheidung waeren von frueher + k.karten.clear(); + k.aktion = None; + k.betrag_bb = None; + k.equity = None; + k.klartext = None; + k.klick = None; + k.hinweis = Some("du sitzt an diesem Tisch nicht".into()); + return k; + } + } + if k.aktion.is_none() { + if let Some(h) = info.and_then(|i| i.handlung.as_ref()) { + if let Some(art) = &h.art { + k.hinweis = Some(format!("{art}{}", h.grund.as_ref().map(|g| format!(": {g}")).unwrap_or_default())); + } + } + } + k +} diff --git a/cockpit/src/lib.rs b/cockpit/src/lib.rs new file mode 100644 index 00000000..fad43684 --- /dev/null +++ b/cockpit/src/lib.rs @@ -0,0 +1,18 @@ +//! Der reine Kern des nativen Cockpits: Modelle der Ansicht und ihre Regeln - ohne Oberflaeche, +//! ohne Seiteneffekte. Spiegelbild von mac/Sources/CockpitKern (Swift). + +pub mod ansicht; +pub mod anzeige; +pub mod bruecke; +pub mod format; +pub mod formate; +pub mod hauptknopf; +pub mod kachel; +pub mod modelle; +pub mod modus; +pub mod nachsichtig; +pub mod netz; +pub mod plankarte; +pub mod spielplan; +pub mod verlauf; +pub mod wachstum; diff --git a/cockpit/src/main.rs b/cockpit/src/main.rs new file mode 100644 index 00000000..8f6d7021 --- /dev/null +++ b/cockpit/src/main.rs @@ -0,0 +1,73 @@ +//! Cockpit-Fenster (Slint): der Reiter Cash mit Spielplan, Hauptknopf und Not-Aus. +//! +//! cockpit Fenster ohne Server ("kein Server") +//! cockpit Fenster mit dieser Ansicht (fest) +//! cockpit --drucken nur den Hauptknopf auf stdout (ohne Fenster) +//! cockpit --verbinden [url] live ueber /ws, je Frame eine Zeile auf stdout (ohne Fenster) +//! cockpit --live [url] Fenster, live ueber /ws aktualisiert und bedienbar +//! +//! Vorgabe-URL: ws://127.0.0.1:8787/ws + +use std::sync::atomic::AtomicBool; + +use cockpit::ansicht::{Ansicht, Nachricht}; +use cockpit::bruecke; +use cockpit::hauptknopf::Hauptknopf; +use cockpit::netz; +use cockpit::spielplan::Spielplan; + +const VORGABE_URL: &str = "ws://127.0.0.1:8787/ws"; + +fn lade(pfad: &str) -> Result { + let text = std::fs::read_to_string(pfad).map_err(|e| format!("{pfad}: {e}"))?; + let mut a = Ansicht::default(); + a.anwenden(&text); + Ok(a) +} + +fn url_aus(args: &[String]) -> String { + args.get(1).cloned().unwrap_or_else(|| VORGABE_URL.into()) +} + +/// Ohne Fenster: jeden eintreffenden Frame als eine Zeile. +fn verbinden(url: &str) { + let halt = AtomicBool::new(false); + eprintln!("verbinde {url}"); + netz::lauschen( + url, + &halt, + |a, n| { + if matches!(n, Nachricht::Ansicht(_)) { + println!("{}", netz::zeile(a)); + } + }, + |z| eprintln!("[{z}]"), + ); +} + +fn main() -> Result<(), Box> { + let mut args: Vec = std::env::args().skip(1).collect(); + match args.first().map(String::as_str) { + Some("--verbinden") => { + verbinden(&url_aus(&args)); + return Ok(()); + } + Some("--live") => return bruecke::live(url_aus(&args)), + _ => {} + } + let nur_drucken = args.first().is_some_and(|a| a == "--drucken"); + if nur_drucken { + args.remove(0); + } + let ansicht = match args.first() { + Some(p) => lade(p)?, + None => Ansicht::default(), + }; + if nur_drucken { + let knopf = Hauptknopf::waehlen(ansicht.kopf.as_ref(), true, &Spielplan::standard(), false); + let satz = ansicht.kopf.as_ref().and_then(|k| k.status.as_ref()).and_then(|s| s.satz.clone()).unwrap_or_else(|| "keine Verbindung".into()); + println!("{} ({:?}) | {}", knopf.titel(), knopf, satz); + return Ok(()); + } + bruecke::fest(ansicht) +} diff --git a/cockpit/src/modelle.rs b/cockpit/src/modelle.rs new file mode 100644 index 00000000..9ee0a28b --- /dev/null +++ b/cockpit/src/modelle.rs @@ -0,0 +1,858 @@ +//! Die Bereiche der Ansicht, wie sicht/ANSICHT.md sie beschreibt und mac/Sources/CockpitKern/ +//! Modelle.swift sie spiegelt. Alles ist nachsichtig gelesen: fehlende Felder sind `None` oder +//! leer, nie ein Fehler - die Datenschicht darf wachsen, unbekannte Felder werden ignoriert. +//! +//! Jedes Modell hat `aus(&Value) -> Option`: `None` heisst "kein Objekt" (der Bereich faellt +//! dann weg, wie in Swift ein unlesbarer Bereich nil wird). + +use serde_json::Value; + +use crate::modus::TischModus; +use crate::nachsichtig::Feld; + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Bereich { + Kopf, + Jetzt, + Wachstum, + Entscheidungen, + Geld, + Sitzen, + Stil, + Ticker, + Zuschauer, +} + +impl Bereich { + pub const ALLE: [Bereich; 9] = [ + Bereich::Kopf, + Bereich::Jetzt, + Bereich::Wachstum, + Bereich::Entscheidungen, + Bereich::Geld, + Bereich::Sitzen, + Bereich::Stil, + Bereich::Ticker, + Bereich::Zuschauer, + ]; + + pub fn aus_name(n: &str) -> Option { + Some(match n { + "kopf" => Bereich::Kopf, + "jetzt" => Bereich::Jetzt, + "wachstum" => Bereich::Wachstum, + "entscheidungen" => Bereich::Entscheidungen, + "geld" => Bereich::Geld, + "sitzen" => Bereich::Sitzen, + "stil" => Bereich::Stil, + "ticker" => Bereich::Ticker, + "zuschauer" => Bereich::Zuschauer, + _ => return None, + }) + } +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Ton { + Rot, + Gelb, + Gruen, + Blau, + Grau, +} + +impl Ton { + /// Unbekannt oder fehlend ist grau. + pub fn aus_farbe(farbe: Option<&str>) -> Ton { + match farbe { + Some("rot") => Ton::Rot, + Some("gelb") => Ton::Gelb, + Some("gruen") => Ton::Gruen, + Some("blau") => Ton::Blau, + _ => Ton::Grau, + } + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Status { + pub zustand: Option, + pub farbe: Option, + pub satz: Option, +} + +impl Status { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Status { zustand: f.text("zustand"), farbe: f.text("farbe"), satz: f.text("satz") }) + } + + pub fn ton(&self) -> Ton { + Ton::aus_farbe(self.farbe.as_deref()) + } +} + +/// Eine eigene Turnieranmeldung; der Server liefert die Zeilen fertig. +#[derive(Clone, Debug, PartialEq)] +pub struct TurnierAnmeldung { + pub raum: String, + pub name: Option, + pub status: Option, +} + +impl TurnierAnmeldung { + /// Ohne `raum` ist die Zeile unlesbar und faellt weg. + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(TurnierAnmeldung { raum: f.text("raum")?, name: f.text("name"), status: f.text("status") }) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Ende { + pub zeit: Option, + pub abbruch: bool, + pub grund: Option, +} + +impl Ende { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Ende { zeit: f.zahl("zeit"), abbruch: f.wahr("abbruch"), grund: f.text("grund") }) + } +} + +/// Konto- und Raumstatus; die Zeilen kommen fertig vom Server - die GUI rechnet nichts nach. +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Konto { + pub status: Option, + pub felder: Vec, + pub warn: bool, + pub verdacht: Option, + pub gesperrt: Option, + /// Diese Tische laufen gerade in der Ruhezeit des Raums - kein neuer Tisch. + pub schwarz_jetzt: bool, + pub schwarze_stunden: Vec, +} + +impl Konto { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Konto { + status: f.text("status"), + felder: f.liste("felder"), + warn: f.wahr("warn"), + verdacht: f.wahr_oder_nil("verdacht"), + gesperrt: f.wahr_oder_nil("gesperrt"), + schwarz_jetzt: f.wahr("schwarz_jetzt"), + schwarze_stunden: f.liste("schwarze_stunden").iter().filter_map(|s| s.parse().ok()).collect(), + }) + } + + /// Nur was gerade gefaehrlich ist: das gehoert in die Kopfzeile, der Rest in die Konto-Karte. + pub fn alarme(&self) -> Vec<&str> { + self.felder + .iter() + .map(String::as_str) + .filter(|f| f.starts_with("Verdacht: ja") || f.starts_with("Gesperrt: ja") || f.contains("(JETZT)")) + .collect() + } +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum PhaseArt { + Spielen, + Pause, + Ausserhalb, + Fertig, +} + +/// Die Phase des Zeitplans im laufenden Lauf (sicht/ansicht._phase). +#[derive(Clone, Debug, PartialEq)] +pub struct Phase { + pub art: Option, + pub nr: Option, + pub tische: Option, + pub bis: Option, + pub rest_s: Option, + pub grund: Option, + pub text: String, +} + +impl Phase { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + let art = f.text("art").and_then(|a| match a.as_str() { + "spielen" => Some(PhaseArt::Spielen), + "pause" => Some(PhaseArt::Pause), + "ausserhalb" => Some(PhaseArt::Ausserhalb), + "fertig" => Some(PhaseArt::Fertig), + _ => None, + }); + Some(Phase { + art, + nr: f.ganz("nr"), + tische: f.ganz("tische"), + bis: f.zahl("bis"), + rest_s: f.zahl("rest_s"), + grund: f.text("grund"), + text: f.text("text").unwrap_or_default(), + }) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Kopf { + pub leer: Option, + pub laeuft: bool, + /// Er laeuft noch, hat sein Ende aber gemeldet: Aufhoeren laeuft aus. + pub hoert_auf: bool, + pub text: Option, + pub seit: Option, + pub zuletzt: Option, + pub laufzeit_s: Option, + pub tische: Vec, + pub tische_offen: Option, + pub tische_text: Option, + pub modus: Option, + pub modus_quelle: Option, + pub klon: bool, + pub not_aus: bool, + pub guthaben: Option, + pub pid: Option, + pub status: Option, + /// Laeuft der CoinPoker-Client? `None`: unbekannt (Klon, aeltere Datenschicht). + pub client: Option, + /// Laeuft der Client mit Debug-Port? `false`: Lobby-Steuerung (Tische oeffnen) geht nicht. + pub client_port: Option, + /// Wie der letzte Lauf endete (`None`, solange er laeuft oder nie lief). + pub ende: Option, + /// Der Spielplan, den der Laeufer liest (`None`: keiner gesetzt). + pub spielplan: Option, + /// Streamer-Modus: die Maus ist an. + pub maus: Option, + pub phase: Option, + pub konto: Option, + pub turnier_anmeldungen: Vec, +} + +impl Kopf { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Kopf { + leer: f.text("leer"), + laeuft: f.wahr("laeuft"), + hoert_auf: f.wahr("hoert_auf"), + text: f.text("text"), + seit: f.zahl("seit"), + zuletzt: f.zahl("zuletzt"), + laufzeit_s: f.zahl("laufzeit_s"), + tische: f.liste("tische"), + tische_offen: f.ganz("tische_offen"), + tische_text: f.text("tische_text"), + modus: f.text("modus"), + modus_quelle: f.text("modus_quelle"), + klon: f.wahr("klon"), + not_aus: f.wahr("not_aus"), + guthaben: f.zahl("guthaben"), + pid: f.ganz("pid"), + status: f.kind("status", Status::aus), + client: f.wahr_oder_nil("client"), + client_port: f.wahr_oder_nil("client_port"), + ende: f.kind("ende", Ende::aus), + spielplan: f.kind("spielplan", crate::spielplan::Spielplan::aus), + maus: f.wahr_oder_nil("maus"), + phase: f.kind("phase", Phase::aus), + konto: f.kind("konto", Konto::aus), + turnier_anmeldungen: f.objekte("turnier_anmeldungen", TurnierAnmeldung::aus), + }) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Zug { + pub offen: bool, + pub frist_s: Option, + pub bis: Option, + pub seit: Option, +} + +impl Zug { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Zug { offen: f.wahr("offen"), frist_s: f.zahl("frist_s"), bis: f.zahl("bis"), seit: f.zahl("seit") }) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Entscheidung { + pub aktion: Option, + pub aktion_text: Option, + pub betrag: Option, + pub betrag_bb: Option, + pub grund: Option, + pub klartext: Option, + pub equity: Option, + pub confidence: Option, + pub gedenkzeit_s: Option, + pub zeit: Option, +} + +impl Entscheidung { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Entscheidung { + aktion: f.text("aktion"), + aktion_text: f.text("aktion_text"), + betrag: f.zahl("betrag"), + betrag_bb: f.zahl("betrag_bb"), + grund: f.text("grund"), + klartext: f.text("klartext"), + equity: f.zahl("equity"), + confidence: f.zahl("confidence"), + gedenkzeit_s: f.zahl("gedenkzeit_s"), + zeit: f.zahl("zeit"), + }) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Klick { + pub status: Option, + pub warum: Option, + pub beleg: Option, +} + +impl Klick { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Klick { status: f.text("status"), warum: f.text("warum"), beleg: f.text("beleg") }) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Jetzt { + pub leer: Option, + pub raum: Option, + pub hand: Option, + pub strasse: Option, + pub karten: Vec, + pub board: Vec, + pub topf: Option, + pub zu_zahlen: Option, + pub stack: Option, + pub zug: Option, + pub entscheidung: Option, + pub klick: Option, + pub modus: Option, +} + +impl Jetzt { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Jetzt { + leer: f.text("leer"), + raum: f.text("raum"), + hand: f.text("hand"), + strasse: f.text("strasse"), + karten: f.liste("karten"), + board: f.liste("board"), + topf: f.zahl("topf"), + zu_zahlen: f.zahl("zu_zahlen"), + stack: f.zahl("stack"), + zug: f.kind("zug", Zug::aus), + entscheidung: f.kind("entscheidung", Entscheidung::aus), + klick: f.kind("klick", Klick::aus), + modus: f.kind("modus", TischModus::aus), + }) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct EntscheidungsZeile { + pub zeit: Option, + pub raum: Option, + pub hand: Option, + pub strasse: Option, + pub karten: Vec, + pub board: Vec, + pub aktion: Option, + pub aktion_text: Option, + pub betrag_bb: Option, + pub grund: Option, + pub klartext: Option, + pub equity: Option, + pub confidence: Option, + pub stake: Option, + pub spielart: Option, + pub ergebnis_bb: Option, + pub ergebnis_text: Option, + pub klick: Option, + pub klick_warum: Option, + pub beleg: Option, + pub gedenkzeit_s: Option, + pub modus: Option, +} + +impl EntscheidungsZeile { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(EntscheidungsZeile { + zeit: f.zahl("zeit"), + raum: f.text("raum"), + hand: f.text("hand"), + strasse: f.text("strasse"), + karten: f.liste("karten"), + board: f.liste("board"), + aktion: f.text("aktion"), + aktion_text: f.text("aktion_text"), + betrag_bb: f.zahl("betrag_bb"), + grund: f.text("grund"), + klartext: f.text("klartext"), + equity: f.zahl("equity"), + confidence: f.zahl("confidence"), + stake: f.text("stake"), + spielart: f.text("spielart"), + ergebnis_bb: f.zahl("ergebnis_bb"), + ergebnis_text: f.text("ergebnis_text"), + klick: f.text("klick"), + klick_warum: f.text("klick_warum"), + beleg: f.text("beleg"), + gedenkzeit_s: f.zahl("gedenkzeit_s"), + modus: f.kind("modus", TischModus::aus), + }) + } + + /// Wie die Kennung in Swift: Zeit, Hand, Raum, Aktion. + pub fn id(&self) -> String { + format!( + "{}|{}|{}|{}", + crate::format::roh(self.zeit.unwrap_or(0.0)), + self.hand.as_deref().unwrap_or(""), + self.raum.as_deref().unwrap_or(""), + self.aktion.as_deref().unwrap_or("") + ) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Facetten { + pub aktion: Vec, + pub stake: Vec, + pub spielart: Vec, + pub ergebnis: Vec, +} + +impl Facetten { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Facetten { + aktion: f.liste("aktion"), + stake: f.liste("stake"), + spielart: f.liste("spielart"), + ergebnis: f.liste("ergebnis"), + }) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Entscheidungen { + pub leer: Option, + pub zeilen: Vec, + pub facetten: Option, + pub gesamt: Option, + pub angezeigt: Option, + pub gekappt: bool, + pub ausschnitt: bool, + pub hinweis: Option, +} + +impl Entscheidungen { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Entscheidungen { + leer: f.text("leer"), + zeilen: f.objekte("zeilen", EntscheidungsZeile::aus), + facetten: f.kind("facetten", Facetten::aus), + gesamt: f.ganz("gesamt"), + angezeigt: f.ganz("angezeigt"), + gekappt: f.wahr("gekappt"), + ausschnitt: f.wahr("ausschnitt"), + hinweis: f.text("hinweis"), + }) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct GeldZeile { + pub zeit: Option, + pub raum: Option, + pub art: Option, + pub betrag: Option, + pub betrag_bb: Option, + pub grund: Option, + pub uebung: Option, +} + +impl GeldZeile { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(GeldZeile { + zeit: f.zahl("zeit"), + raum: f.text("raum"), + art: f.text("art"), + betrag: f.zahl("betrag"), + betrag_bb: f.zahl("betrag_bb"), + grund: f.text("grund"), + uebung: f.wahr_oder_nil("uebung"), + }) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct GeldRegeln { + pub buyin_uebung: Option, + pub buyin_echt: Option, + pub nachkauf_unter_bb: Option, + pub aufstehen_unter_bb: Option, + pub stop_tisch_bb: Option, + pub stop_sitzung_bb: Option, + pub anteil_je_tisch: Option, + pub hoechstens_tische: Option, + pub ratholing: bool, + pub modell: Option, + pub kauf: Option, + pub stakes_bb: Option, + pub stops: Vec, +} + +impl GeldRegeln { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(GeldRegeln { + buyin_uebung: f.text("buyin_uebung"), + buyin_echt: f.text("buyin_echt"), + nachkauf_unter_bb: f.zahl("nachkauf_unter_bb"), + aufstehen_unter_bb: f.zahl("aufstehen_unter_bb"), + stop_tisch_bb: f.zahl("stop_tisch_bb"), + stop_sitzung_bb: f.zahl("stop_sitzung_bb"), + anteil_je_tisch: f.zahl("anteil_je_tisch"), + hoechstens_tische: f.ganz("hoechstens_tische"), + ratholing: f.wahr("ratholing"), + modell: f.text("modell"), + kauf: f.text("kauf"), + stakes_bb: f.zahl("stakes_bb"), + stops: f.liste("stops"), + }) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct GeldStandTisch { + pub raum: String, + pub netto_bb: Option, +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct GeldStand { + pub sitzung_bb: Option, + pub seit: Option, + pub tische: Vec, +} + +impl GeldStand { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(GeldStand { + sitzung_bb: f.zahl("sitzung_bb"), + seit: f.zahl("seit"), + tische: f.objekte("tische", |t| { + let g = Feld::aus(t)?; + Some(GeldStandTisch { raum: g.text("raum").unwrap_or_else(|| "?".into()), netto_bb: g.zahl("netto_bb") }) + }), + }) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Geld { + pub leer: Option, + pub zeilen: Vec, + pub uebung: bool, + pub regeln: Option, + pub stand: Option, + /// Ergebnis, Rake, Rakeback und netto in einer Zeile - brutto ist keine Zahl, auf die man spielt. + pub netto: Option, +} + +impl Geld { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Geld { + leer: f.text("leer"), + zeilen: f.objekte("zeilen", GeldZeile::aus), + uebung: f.wahr("uebung"), + regeln: f.kind("regeln", GeldRegeln::aus), + stand: f.kind("stand", GeldStand::aus), + netto: f.text("netto"), + }) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Handlung { + pub art: Option, + pub grund: Option, + pub zeit: Option, +} + +impl Handlung { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Handlung { art: f.text("art"), grund: f.text("grund"), zeit: f.zahl("zeit") }) + } +} + +/// Die laufende Hand aus dem Client-Log (sicht/ansicht._haende_im_log). +#[derive(Clone, Debug, Default, PartialEq)] +pub struct LogHand { + pub hand: Option, + pub karten: Vec, + pub board: Vec, + pub topf: Option, +} + +impl LogHand { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(LogHand { hand: f.text("hand"), karten: f.liste("karten"), board: f.liste("board"), topf: f.zahl("topf") }) + } +} + +/// Ein Platz am Tisch - im Geruest nur, was die Regeln brauchen (eigener Platz). +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Spieler { + pub sitz: Option, + pub name: Option, + pub stack: Option, + pub ich: bool, +} + +impl Spieler { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Spieler { sitz: f.ganz("sitz"), name: f.text("name"), stack: f.zahl("stack"), ich: f.wahr("ich") }) + } +} + +/// Ein Tisch fuer die Vorschau (sicht/ansicht._tisch_ansicht). +#[derive(Clone, Debug, Default, PartialEq)] +pub struct TischAnsicht { + pub hand: Option, + pub dealer: Option, + pub bb: Option, + pub strasse: Option, + pub spieler: Vec, +} + +impl TischAnsicht { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(TischAnsicht { + hand: f.text("hand"), + dealer: f.ganz("dealer"), + bb: f.zahl("bb"), + strasse: f.text("strasse"), + spieler: f.objekte("spieler", Spieler::aus), + }) + } + + /// Der eigene Platz - unten in der Vorschau. Gibt es keinen, sitzt man hier nicht. + /// Wie in Swift: ein eigener Platz ohne Nummer zaehlt wie keiner. + pub fn ich(&self) -> Option { + self.spieler.iter().find(|s| s.ich).and_then(|s| s.sitz) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Raum { + pub raum: String, + /// Der Name wie im Spiel ("NLH 1676973 - 1K/2K"); `raum` ist die interne Kennung. + pub titel: Option, + pub zustand: Option, + pub platz: Option, + pub stack: Option, + pub groesse: Option, + pub bb: Option, + pub modus: Option, + pub handlung: Option, + pub fenster: Option, + pub netto: Option, + pub netto_bb: Option, + pub netto_haende: Option, + pub hand: Option, + pub tisch: Option, +} + +impl Raum { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Raum { + raum: f.text("raum").unwrap_or_else(|| "?".into()), + titel: f.text("titel"), + zustand: f.text("zustand"), + platz: f.text("platz"), + stack: f.zahl("stack"), + groesse: f.ganz("groesse"), + bb: f.text("bb"), + modus: f.text("modus"), + handlung: f.kind("handlung", Handlung::aus), + fenster: f.ganz("fenster"), + netto: f.zahl("netto"), + netto_bb: f.zahl("netto_bb"), + netto_haende: f.ganz("netto_haende"), + hand: f.kind("hand", LogHand::aus), + tisch: f.kind("tisch", TischAnsicht::aus), + }) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct SitzenFenster { + pub zahl: Option, + pub ueberzaehlig: Vec, +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Sitzen { + pub leer: Option, + pub raeume: Vec, + pub fenster: Option, +} + +impl Sitzen { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Sitzen { + leer: f.text("leer"), + raeume: f.objekte("raeume", Raum::aus), + fenster: f.kind("fenster", |w| { + let g = Feld::aus(w)?; + Some(SitzenFenster { zahl: g.ganz("zahl"), ueberzaehlig: g.liste("ueberzaehlig") }) + }), + }) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Anteile { + pub t: Option, + pub fold: f64, + pub check: f64, + pub call: f64, + pub raise: f64, + pub allin: f64, + pub n: Option, +} + +impl Anteile { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Anteile { + t: f.zahl("t"), + fold: f.zahl("fold").unwrap_or(0.0), + check: f.zahl("check").unwrap_or(0.0), + call: f.zahl("call").unwrap_or(0.0), + raise: f.zahl("raise").unwrap_or(0.0), + allin: f.zahl("allin").unwrap_or(0.0), + n: f.ganz("n"), + }) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Groesse { + pub betrag_bb: Option, + pub topf_anteil: Option, +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Denkzeit { + pub median: Option, + pub streuung: Option, + pub vk: Option, + pub n: Option, +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Stil { + pub leer: Option, + pub verlauf: Vec, + pub groessen: Vec, + pub denkzeiten: Vec, + pub denkzeit: Option, + pub anteile: Option, +} + +impl Stil { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Stil { + leer: f.text("leer"), + verlauf: f.objekte("verlauf", Anteile::aus), + groessen: f.objekte("groessen", |g| { + let g = Feld::aus(g)?; + Some(Groesse { betrag_bb: g.zahl("betrag_bb"), topf_anteil: g.zahl("topf_anteil") }) + }), + denkzeiten: f.objekte("denkzeiten", |d| Feld::aus(d)?.zahl("s")), + denkzeit: f.kind("denkzeit", |d| { + let g = Feld::aus(d)?; + Some(Denkzeit { median: g.zahl("median"), streuung: g.zahl("streuung"), vk: g.zahl("vk"), n: g.ganz("n") }) + }), + anteile: f.kind("anteile", Anteile::aus), + }) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct TickerZeile { + pub zeit: Option, + pub art: Option, + pub raum: Option, + pub text: Option, +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Ticker { + pub leer: Option, + pub zeilen: Vec, + pub gedanken: Vec, +} + +impl Ticker { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Ticker { + leer: f.text("leer"), + zeilen: f.objekte("zeilen", |z| { + let g = Feld::aus(z)?; + Some(TickerZeile { zeit: g.zahl("zeit"), art: g.text("art"), raum: g.text("raum"), text: g.text("text") }) + }), + gedanken: f.liste("gedanken"), + }) + } +} + +/// Der Bereich `zuschauer`: im Geruest nur der Rahmen (laeuft, leer); Tische und Abgleich folgen. +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Zuschauer { + pub laeuft: bool, + pub leer: Option, +} + +impl Zuschauer { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Zuschauer { laeuft: f.wahr("laeuft"), leer: f.text("leer") }) + } +} diff --git a/cockpit/src/modus.rs b/cockpit/src/modus.rs new file mode 100644 index 00000000..c49fd999 --- /dev/null +++ b/cockpit/src/modus.rs @@ -0,0 +1,126 @@ +//! Der Modus eines Tisches (sicht/ANSICHT.md, `modus`; Modus.swift): womit der Kern entschieden hat. +//! Eine unbekannte Art ist kein Fehler - `aus` liefert dann `None`, und das Feld bleibt leer. + +use serde_json::Value; + +use crate::nachsichtig::Feld; + +#[derive(Clone, Debug, PartialEq)] +pub enum TischModus { + Cash { stake: Option }, + Turnier(Turnier), + KPoker(KPoker), +} + +#[derive(Clone, Debug, PartialEq)] +pub struct Turnier { + pub level: Option, + pub bb: Option, + pub ante: Option, + pub feld: i64, + pub bezahlt: i64, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Geldlage { + VorDemGeld(i64), + Bubble, + ImGeld, +} + +impl Geldlage { + pub fn text(&self) -> String { + match self { + Geldlage::VorDemGeld(n) => format!("{n} bis zum Geld"), + Geldlage::Bubble => "Bubble".into(), + Geldlage::ImGeld => "im Geld".into(), + } + } +} + +/// Die Spur zum Geld: je verbleibendem Spieler ein Strich, gefuellt = bezahlter Platz. +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum Spur { + Striche { gefuellt: i64, gesamt: i64 }, + Anteil(f64), +} + +impl Turnier { + /// Bis so viele Spieler zeigt die Spur einen Strich je Spieler, darueber einen Anteil. + pub const STRICHE_MAX: i64 = 40; + + pub fn lage(&self) -> Geldlage { + let bis_geld = (self.feld - self.bezahlt).max(0); + match bis_geld { + 0 => Geldlage::ImGeld, + 1 => Geldlage::Bubble, + n => Geldlage::VorDemGeld(n), + } + } + + /// Unter der Spur: wie viele der Uebrigen bezahlt werden. + pub fn spur_text(&self) -> String { + if self.lage() == Geldlage::ImGeld { + format!("alle {} im Geld", self.feld) + } else { + format!("{} von {} bezahlt", self.bezahlt, self.feld) + } + } + + pub fn spur(&self) -> Option { + if self.feld <= 0 { + return None; + } + if self.feld > Self::STRICHE_MAX { + return Some(Spur::Anteil((self.bezahlt as f64 / self.feld as f64).min(1.0))); + } + Some(Spur::Striche { gefuellt: self.bezahlt.min(self.feld), gesamt: self.feld }) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct KPunkt { + pub aktion: String, + pub groessen: Vec, +} + +impl KPunkt { + /// Ohne Aktion ist der Punkt unlesbar und faellt weg. + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(KPunkt { + aktion: f.text("aktion")?, + groessen: f.liste("groessen").iter().filter_map(|s| s.parse().ok()).collect(), + }) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct KPoker { + pub menue: Vec, + pub uhr_s: Option, +} + +impl TischModus { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + match f.text("art")?.as_str() { + "Turnier" => Some(TischModus::Turnier(Turnier { + level: f.ganz("level"), + bb: f.zahl("bb"), + ante: f.zahl("ante"), + feld: f.ganz("feld").unwrap_or(0), + bezahlt: f.ganz("bezahlt").unwrap_or(0), + })), + "K-Poker" => Some(TischModus::KPoker(KPoker { menue: f.objekte("menue", KPunkt::aus), uhr_s: f.zahl("uhr_s") })), + "Cash" => { + // "Cash · 0.05/0.1": der Stake steht hinter dem ersten Trenner + let text = f.text("text").unwrap_or_default(); + let teile: Vec<&str> = text.split(" · ").collect(); + let stake = if teile.len() > 1 { Some(teile[1..].join(" · ")) } else { None }; + Some(TischModus::Cash { stake }) + } + _ => None, + } + } +} diff --git a/cockpit/src/nachsichtig.rs b/cockpit/src/nachsichtig.rs new file mode 100644 index 00000000..aeece6c1 --- /dev/null +++ b/cockpit/src/nachsichtig.rs @@ -0,0 +1,83 @@ +//! Nachsichtiges Lesen (wie mac/Sources/CockpitKern/Nachsichtig.swift): ein Feld mit falschem +//! Typ ist "unbekannt", kein Fehler. Python schreibt Zahlen mal als int, mal als float, und manche +//! Felder (Platz, Blinds) mal als Text, mal als Zahl. + +use serde_json::{Map, Value}; + +use crate::format::roh; + +/// Text und Zahl eines beliebigen JSON-Werts, in der Reihenfolge des Swift-Kerns: +/// String, Bool ("ja"/"nein"), Zahl. Null, Liste und Objekt sind nichts. +fn beliebig(v: &Value) -> Option<(String, Option)> { + match v { + Value::String(s) => Some((s.clone(), s.parse::().ok())), + Value::Bool(b) => Some((if *b { "ja" } else { "nein" }.to_string(), None)), + Value::Number(n) => { + let x = n.as_f64()?; + let text = match n.as_i64() { + Some(i) => i.to_string(), + None => roh(x), + }; + Some((text, Some(x))) + } + _ => None, + } +} + +/// Ein Objekt, aus dem sich nachsichtig lesen laesst. +pub struct Feld<'a>(pub &'a Map); + +impl<'a> Feld<'a> { + /// `None`, wenn der Wert kein JSON-Objekt ist (dann faellt der ganze Bereich weg). + pub fn aus(v: &'a Value) -> Option> { + v.as_object().map(Feld) + } + + pub fn roh(&self, k: &str) -> Option<&'a Value> { + self.0.get(k) + } + + pub fn text(&self, k: &str) -> Option { + self.0.get(k).and_then(beliebig).map(|(t, _)| t) + } + + pub fn zahl(&self, k: &str) -> Option { + // Ein Text ist nur dann eine Zahl, wenn er sich als Zahl lesen laesst - "0.05/0.1" nicht. + self.0.get(k).and_then(beliebig).and_then(|(_, z)| z) + } + + pub fn ganz(&self, k: &str) -> Option { + self.zahl(k).map(|x| x as i64) + } + + /// Nur ein echtes Bool zaehlt; sonst `false`. + pub fn wahr(&self, k: &str) -> bool { + self.wahr_oder_nil(k).unwrap_or(false) + } + + /// Nur ein echtes Bool; alles andere ist unbekannt (`None`). + pub fn wahr_oder_nil(&self, k: &str) -> Option { + self.0.get(k).and_then(Value::as_bool) + } + + /// Eine Liste von Texten; was sich nicht lesen laesst, faellt weg. + pub fn liste(&self, k: &str) -> Vec { + match self.0.get(k) { + Some(Value::Array(a)) => a.iter().filter_map(|v| beliebig(v).map(|(t, _)| t)).collect(), + _ => Vec::new(), + } + } + + /// Eine Liste von Objekten; ein unlesbarer Eintrag faellt weg statt die Liste zu kippen. + pub fn objekte(&self, k: &str, lesen: impl Fn(&Value) -> Option) -> Vec { + match self.0.get(k) { + Some(Value::Array(a)) => a.iter().filter_map(lesen).collect(), + _ => Vec::new(), + } + } + + /// Ein verschachteltes Objekt; fehlt es, ist null oder unlesbar: `None`. + pub fn kind(&self, k: &str, lesen: impl Fn(&Value) -> Option) -> Option { + self.0.get(k).and_then(lesen) + } +} diff --git a/cockpit/src/netz.rs b/cockpit/src/netz.rs new file mode 100644 index 00000000..23fdbdaa --- /dev/null +++ b/cockpit/src/netz.rs @@ -0,0 +1,136 @@ +//! Die Netzschicht: WebSocket `/ws` empfaengt Nachrichten (-> `Ansicht::anwenden`), +//! `POST /api/steuern` schickt Knoepfe. Nur lokal (`ws://`, `http://`), ohne TLS. + +use std::sync::atomic::{AtomicBool, Ordering}; +use std::time::Duration; + +use serde_json::{json, Value}; +use tungstenite::Message; + +use crate::ansicht::{Ansicht, Nachricht, Rueckmeldung}; +use crate::hauptknopf::Hauptknopf; +use crate::spielplan::Spielplan; + +/// Pause nach einem Abriss, wie die Swift-`Verbindung`. +pub const WIEDER_NACH: Duration = Duration::from_millis(1500); + +/// Verbindet zu `url`, liest Textframes und arbeitet sie in `ansicht` ein; `bei_nachricht` wird nach +/// jedem Frame gerufen. Bei Abriss oder Fehlschlag wird nach 1,5 s neu verbunden, bis `halt` gesetzt +/// ist. Eine neue Verbindung beginnt mit leerer Ansicht (der Server schickt dann wieder alles). +pub fn lauschen(url: &str, halt: &AtomicBool, mut bei_nachricht: impl FnMut(&Ansicht, &Nachricht), mut bei_zustand: impl FnMut(&str)) { + while !halt.load(Ordering::Relaxed) { + match tungstenite::connect(url) { + Ok((mut ws, _)) => { + bei_zustand("verbunden"); + let mut ansicht = Ansicht::default(); + loop { + if halt.load(Ordering::Relaxed) { + let _ = ws.close(None); + return; + } + match ws.read() { + Ok(Message::Text(t)) => { + let n = ansicht.anwenden(&t); + bei_nachricht(&ansicht, &n); + } + Ok(Message::Close(_)) | Err(_) => break, + Ok(_) => {} + } + } + bei_zustand("getrennt"); + } + Err(e) => bei_zustand(&format!("keine Verbindung: {e}")), + } + // in kleinen Schritten warten, damit `halt` schnell greift + let mut warte = Duration::ZERO; + while warte < WIEDER_NACH && !halt.load(Ordering::Relaxed) { + std::thread::sleep(Duration::from_millis(100)); + warte += Duration::from_millis(100); + } + } +} + +/// Ein Knopf: `POST /api/steuern`. Netzfehler und Fehlstatus werden zur `Rueckmeldung` mit `ok: false`. +pub fn steuern(adresse: &Adresse, aktion: &str, raum: Option<&str>, daten: Option) -> Rueckmeldung { + let koerper = steuern_koerper(aktion, raum, daten); + let antwort = ureq::post(&adresse.steuern_url()).timeout(Duration::from_secs(30)).send_json(koerper); + let wert = match antwort { + Ok(r) => r.into_json::().ok(), + Err(ureq::Error::Status(_, r)) => r.into_json::().ok(), + Err(e) => return Rueckmeldung { aktion: Some(aktion.into()), ok: false, text: e.to_string(), raum: None, bild: None }, + }; + let mut r = wert.as_ref().and_then(Rueckmeldung::aus_json).unwrap_or(Rueckmeldung { + aktion: None, + ok: false, + text: "unlesbare Antwort".into(), + raum: None, + bild: None, + }); + r.aktion.get_or_insert_with(|| aktion.into()); + r +} + +/// Eine Zeile Stand: Hauptknopf, Status, laeuft, Tische, `jetzt`. +pub fn zeile(a: &Ansicht) -> String { + let knopf = Hauptknopf::waehlen(a.kopf.as_ref(), true, &Spielplan::standard(), false); + let satz = a.kopf.as_ref().and_then(|k| k.status.as_ref()).and_then(|s| s.satz.clone()).unwrap_or_else(|| "-".into()); + let laeuft = a.kopf.as_ref().is_some_and(|k| k.laeuft); + let tische = a.kopf.as_ref().map_or(0, |k| k.tische.len()); + let jetzt = match a.jetzt.as_ref() { + None => "-".to_string(), + Some(j) => match (&j.raum, &j.strasse) { + (None, None) => j.leer.clone().map_or("-".into(), |l| format!("leer: {l}")), + _ => { + let e = j.entscheidung.as_ref().and_then(|e| e.aktion_text.clone().or(e.aktion.clone())).unwrap_or_else(|| "-".into()); + format!("{} / {} / {}", j.raum.as_deref().unwrap_or("?"), j.strasse.as_deref().unwrap_or("?"), e) + } + }, + }; + format!("stand={} | knopf={} | status={} | laeuft={} | tische={} | jetzt={}", a.stand.map_or("-".into(), |s| format!("{s:.1}")), knopf.titel(), satz, laeuft, tische, jetzt) +} + +/// Wo der Cockpit-Server lauscht (sicht/start.py; Vorgabe Port 8787). +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct Adresse { + pub host: String, + pub port: u16, +} + +impl Default for Adresse { + fn default() -> Self { + Adresse { host: "127.0.0.1".into(), port: 8787 } + } +} + +impl Adresse { + pub fn ws_url(&self) -> String { + format!("ws://{}:{}/ws", self.host, self.port) + } + + pub fn steuern_url(&self) -> String { + format!("http://{}:{}/api/steuern", self.host, self.port) + } +} + +/// Der Koerper von `POST /api/steuern {aktion, raum?, daten?}`. +pub fn steuern_koerper(aktion: &str, raum: Option<&str>, daten: Option) -> Value { + let mut k = json!({ "aktion": aktion }); + if let Some(r) = raum { + k["raum"] = json!(r); + } + if let Some(d) = daten { + k["daten"] = d; + } + k +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn zeile_aus_leerer_ansicht() { + let z = zeile(&Ansicht::default()); + assert!(z.contains("laeuft=false") && z.contains("tische=0"), "{z}"); + } +} diff --git a/cockpit/src/plankarte.rs b/cockpit/src/plankarte.rs new file mode 100644 index 00000000..a58648fa --- /dev/null +++ b/cockpit/src/plankarte.rs @@ -0,0 +1,177 @@ +//! Die Plan-Kachel: Zeitplan und Geld eines Spielplans in einem Wort ("Dauerlauf") und einer +//! Zeile (PlanVorlage.swift, Zeitplan.kurz). Zeit- und Geldplan liegen im `Spielplan` noch roh +//! als JSON; hier wird nur gelesen, was die Kachel zum Erkennen und Beschriften braucht. + +use serde_json::Value; + +use crate::format::zahl; +use crate::nachsichtig::Feld; +use crate::spielplan::Spielplan; + +/// Minuten von..bis (fest, wenn beide gleich). +type Spanne = (f64, f64); + +/// Die Teile des Zeitplans, die die Kachel zeigt (betrieb/zeitplan.py; Swift `Zeitplan`). +#[derive(Clone, Debug, PartialEq)] +pub struct Zeit { + pub sitzung: Option, + pub pause: Spanne, + pub sitzungen: Option, + pub fenster: Option<(String, String)>, +} + +fn spanne(v: Option<&Value>) -> Option { + let a = v?.as_array()?; + if a.len() != 2 { + return None; + } + let (x, y) = (a[0].as_f64()?, a[1].as_f64()?); + Some((x.min(y).max(0.0), x.max(y).max(0.0))) +} + +fn minuten(s: Spanne) -> String { + let z = |x: f64| zahl(Some(x), 0); + if s.0 == s.1 { z(s.0) } else { format!("{}–{}", z(s.0), z(s.1)) } +} + +impl Zeit { + pub fn aus(v: Option<&Value>) -> Zeit { + let f = v.and_then(Feld::aus); + let roh = |k: &str| f.as_ref().and_then(|f| f.roh(k)); + let fenster = roh("fenster").and_then(Value::as_array).filter(|a| a.len() == 2).and_then(|a| { + Some((a[0].as_str()?.to_string(), a[1].as_str()?.to_string())) + }); + Zeit { + sitzung: spanne(roh("sitzung")).filter(|s| s.1 > 0.0), + pause: spanne(roh("pause")).unwrap_or((0.0, 0.0)), + sitzungen: roh("sitzungen").and_then(Value::as_f64).map(|n| n as i64).filter(|n| *n >= 1), + fenster, + } + } + + /// In einer Zeile: "60–90 min · Pause 10–20 · 3×". + pub fn kurz(&self) -> String { + let mut teile = vec![self.sitzung.map_or("ohne Ende".to_string(), |s| format!("{} min", minuten(s)))]; + if self.pause.1 > 0.0 { + teile.push(format!("Pause {}", minuten(self.pause))); + } + if let Some(n) = self.sitzungen { + teile.push(format!("{n}×")); + } + if let Some((a, b)) = &self.fenster { + teile.push(format!("{a}–{b}")); + } + teile.join(" · ") + } +} + +/// Die vier Stopps des Geldplans, die die Vorlagen unterscheiden. Fehlt ein Schluessel, gilt die +/// Vorgabe des Geldplans (Sitzungsverlust 250 BB, sonst keiner); `null` oder Unlesbares heisst "kein Stop". +type Stops = [Option<(f64, bool)>; 4]; + +fn stops(v: Option<&Value>) -> Stops { + let f = v.and_then(Feld::aus); + let eine = |k: &str, vorgabe: Option| -> Option<(f64, bool)> { + match f.as_ref().and_then(|f| f.roh(k)) { + None => vorgabe.map(|w| (w, false)), + Some(g) => { + let g = Feld::aus(g)?; + let w = g.zahl("wert").filter(|w| *w > 0.0)?; + Some((w, g.text("einheit").as_deref() == Some("prozent"))) + } + } + }; + [eine("sitzung_verlust", Some(250.0)), eine("sitzung_gewinn", None), eine("tag_verlust", None), eine("tag_gewinn", None)] +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Vorlage { + Dauerlauf, + Feierabend, + Kurz, +} + +impl Vorlage { + pub const ALLE: [Vorlage; 3] = [Vorlage::Dauerlauf, Vorlage::Feierabend, Vorlage::Kurz]; + + pub fn titel(&self) -> &'static str { + match self { + Vorlage::Dauerlauf => "Dauerlauf", + Vorlage::Feierabend => "Feierabend", + Vorlage::Kurz => "Kurz & sicher", + } + } + + pub fn untertitel(&self) -> &'static str { + match self { + Vorlage::Dauerlauf => "bis du stoppst · −250 BB", + Vorlage::Feierabend => "3 × 60–90 min · Pausen", + Vorlage::Kurz => "30–45 min · ±100 BB", + } + } + + fn zeit(&self) -> Zeit { + match self { + Vorlage::Dauerlauf => Zeit { sitzung: None, pause: (0.0, 0.0), sitzungen: None, fenster: None }, + Vorlage::Feierabend => Zeit { sitzung: Some((60.0, 90.0)), pause: (10.0, 20.0), sitzungen: Some(3), fenster: None }, + Vorlage::Kurz => Zeit { sitzung: Some((30.0, 45.0)), pause: (0.0, 0.0), sitzungen: Some(1), fenster: None }, + } + } + + fn geld(&self) -> Stops { + let s = |w: f64| Some((w, false)); + match self { + Vorlage::Dauerlauf => [s(250.0), None, None, None], + Vorlage::Feierabend => [s(150.0), None, s(300.0), None], + Vorlage::Kurz => [s(100.0), s(100.0), None, None], + } + } + + /// Welche Vorlage der Plan ist - `None`: ein eigener Plan. (Geld: nur die vier Stopps verglichen, + /// nicht Stakes und Einkauf - die Vorlagen lassen die ohnehin, wie sie sind.) + pub fn erkennen(plan: &Spielplan) -> Option { + let z = Zeit::aus(plan.zeitplan.as_ref()); + let g = stops(plan.geld.as_ref()); + Self::ALLE.into_iter().find(|v| v.zeit() == z && v.geld() == g) + } +} + +/// Titel und Fuss der Plan-Kachel: die Vorlage oder "Eigener" mit der Kurzform des Zeitplans. +pub fn plan_text(plan: &Spielplan) -> (String, String) { + match Vorlage::erkennen(plan) { + Some(v) => (v.titel().into(), v.untertitel().into()), + None => ("Eigener".into(), Zeit::aus(plan.zeitplan.as_ref()).kurz()), + } +} + +#[cfg(test)] +mod tests { + use super::*; + use serde_json::json; + + fn plan(z: Option, g: Option) -> Spielplan { + let mut p = Spielplan::standard(); + p.zeitplan = z; + p.geld = g; + p + } + + #[test] + fn ohne_zeitplan_ist_dauerlauf() { + assert_eq!(plan_text(&plan(None, None)), ("Dauerlauf".into(), "bis du stoppst · −250 BB".into())); + } + + #[test] + fn feierabend_und_kurz_werden_erkannt() { + let f = plan(Some(json!({"sitzung":[60,90],"pause":[10,20],"sitzungen":3})), Some(json!({"sitzung_verlust":{"wert":150,"einheit":"bb"},"tag_verlust":{"wert":300}}))); + assert_eq!(Vorlage::erkennen(&f), Some(Vorlage::Feierabend)); + let k = plan(Some(json!({"sitzung":[30,45],"sitzungen":1})), Some(json!({"sitzung_verlust":{"wert":100},"sitzung_gewinn":{"wert":100}}))); + assert_eq!(Vorlage::erkennen(&k), Some(Vorlage::Kurz)); + } + + #[test] + fn eigener_plan_zeigt_die_kurzform() { + let p = plan(Some(json!({"sitzung":[45,45],"pause":[5,10],"fenster":["20:00","23:30"]})), None); + assert_eq!(plan_text(&p), ("Eigener".into(), "45 min · Pause 5–10 · 20:00–23:30".into())); + } +} diff --git a/cockpit/src/spielplan.rs b/cockpit/src/spielplan.rs new file mode 100644 index 00000000..0ec72f5d --- /dev/null +++ b/cockpit/src/spielplan.rs @@ -0,0 +1,349 @@ +//! Der Spielplan, wie das Cockpit ihn einstellt und vom Server liest (Spielplan.swift, +//! betrieb/spielplan.py). Uebung oder Cash, Tische je Format, Budget, Ziel, Fuellfolge. +//! +//! Noch nicht portiert (Geruest): Zeitplan, Geldplan und Turnierplan. Sie liegen als rohes JSON +//! mit und werden von `daten()` nicht mitgeschickt. + +use std::collections::{BTreeMap, BTreeSet}; + +use serde_json::{json, Map, Number, Value}; + +use crate::formate::SpielFormat; +use crate::nachsichtig::Feld; + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Modus { + Uebung, + /// Im Protokoll "cash" (Echtgeld). + Echt, +} + +impl Modus { + pub fn roh(&self) -> &'static str { + match self { + Modus::Uebung => "uebung", + Modus::Echt => "cash", + } + } +} + +/// Tischform: Multiway (Ring) vs. Heads-Up (2 Plaetze). +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Tischform { + Multiway, + Hu, + Beide, +} + +impl Tischform { + pub fn roh(&self) -> &'static str { + match self { + Tischform::Multiway => "multiway", + Tischform::Hu => "hu", + Tischform::Beide => "beide", + } + } + + pub fn name(&self) -> &'static str { + match self { + Tischform::Multiway => "Multiway", + Tischform::Hu => "Heads-Up", + Tischform::Beide => "Beide", + } + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct Spielplan { + pub modus: Modus, + formate: BTreeMap, + /// Welche Formate der Laeufer oeffnen kann (kopf.spielplan.formate_liste) - nur vom Server. + pub gemessen: BTreeSet, + /// Welche Formate die Engine SPIELEN kann - modusabhaengig. Nur vom Server. + pub spielbar: BTreeSet, + ziel: Option, + /// Fuellfolge, wenn sie von der Vorgabe abweicht; sonst leer. + reihenfolge: Vec, + pub budget: Option, + tische_bis: Option, + pub zeiger: bool, + pub lehrer: bool, + pub tischform: Tischform, + pub micro_only: bool, + /// Noch nicht portierte Teile des Plans, roh. + pub zeitplan: Option, + pub geld: Option, + pub turnier: Option, +} + +impl Spielplan { + /// Wie betrieb/spielplan.HOECHSTENS. + pub const HOECHSTENS: i64 = 12; + + pub fn standard() -> Spielplan { + Spielplan::neu(Modus::Uebung, 1, None) + } + + pub fn neu(modus: Modus, tische: i64, budget: Option) -> Spielplan { + Spielplan { + modus, + formate: BTreeMap::from([(SpielFormat::Cash, Self::klemmen(tische))]), + gemessen: BTreeSet::from([SpielFormat::Cash]), + spielbar: BTreeSet::from([SpielFormat::Cash, SpielFormat::Aof]), + ziel: None, + reihenfolge: Vec::new(), + budget: budget.filter(|b| *b > 0.0), + tische_bis: None, + zeiger: false, + lehrer: false, + tischform: Tischform::Multiway, + micro_only: false, + zeitplan: None, + geld: None, + turnier: None, + } + } + + fn klemmen(n: i64) -> i64 { + n.clamp(1, Self::HOECHSTENS) + } + + pub fn cash(&self) -> bool { + self.modus == Modus::Echt + } + + pub fn formate(&self) -> &BTreeMap { + &self.formate + } + + pub fn anzahl(&self, f: SpielFormat) -> i64 { + self.formate.get(&f).copied().unwrap_or(0) + } + + /// Tische insgesamt: die Summe der Formate, mit Ziel (Ausweichen) hoechstens das Ziel. + pub fn tische(&self) -> i64 { + let summe: i64 = self.formate.values().sum(); + self.ziel.map_or(summe, |z| z.min(summe)) + } + + /// Setzen aendert das Ziel oder sonst Cash (die anderen Formate bleiben). + pub fn set_tische(&mut self, n: i64) { + if self.ziel.is_some() { + self.set_ziel(Some(n)); + } else { + let rest = self.tische() - self.anzahl(SpielFormat::Cash); + self.setzen(SpielFormat::Cash, n - rest); + } + } + + pub fn ziel(&self) -> Option { + self.ziel + } + + pub fn set_ziel(&mut self, ziel: Option) { + self.ziel = ziel.map(Self::klemmen); + self.tische_bis = Self::spanne(self.tische(), self.tische_bis); + } + + pub fn tische_bis(&self) -> Option { + self.tische_bis + } + + pub fn set_tische_bis(&mut self, bis: Option) { + self.tische_bis = Self::spanne(self.tische(), bis); + } + + fn spanne(von: i64, bis: Option) -> Option { + bis.and_then(|b| if b > von { Some(b.min(Self::HOECHSTENS)) } else { None }) + } + + /// Die gewaehlten Formate in Fuellfolge. + pub fn folge(&self) -> Vec { + let genannt: Vec = self.reihenfolge.iter().copied().filter(|f| self.anzahl(*f) > 0).collect(); + let mut folge = genannt.clone(); + folge.extend(SpielFormat::ALLE.into_iter().filter(|f| self.anzahl(*f) > 0 && !genannt.contains(f))); + folge + } + + /// Tische eines Formats: nicht unter 0, die Summe nicht ueber `HOECHSTENS`. + pub fn setzen(&mut self, f: SpielFormat, n: i64) { + let grenze = if self.ziel.is_some() { Self::HOECHSTENS } else { Self::HOECHSTENS - (self.tische() - self.anzahl(f)) }; + let neu = n.min(grenze).max(0); + let davor = self.folge(); + if neu > 0 { + self.formate.insert(f, neu); + } else { + self.formate.remove(&f); + } + let mut reihe: Vec = davor.iter().copied().filter(|x| self.anzahl(*x) > 0).collect(); + reihe.extend(self.folge().into_iter().filter(|x| !davor.contains(x))); + self.ordnen(reihe); + self.tische_bis = Self::spanne(self.tische(), self.tische_bis); + } + + /// Ausweichen an: das Ziel ist die jetzige Tischzahl. Aus: die Summe zaehlt wieder, die Formate + /// hinten in der Fuellfolge werden unter `HOECHSTENS` gekuerzt. + pub fn ausweichen(&mut self, an: bool) { + if an { + self.set_ziel(Some(self.tische().max(1))); + return; + } + let reihe = self.folge(); + self.ziel = None; + let mut rest = Self::HOECHSTENS; + for f in reihe { + let n = self.anzahl(f).min(rest); + if n > 0 { + self.formate.insert(f, n); + } else { + self.formate.remove(&f); + } + rest -= n; + } + self.tische_bis = Self::spanne(self.tische(), self.tische_bis); + } + + /// Ein Format in der Fuellfolge einen Platz nach vorn. + pub fn vorziehen(&mut self, f: SpielFormat) { + let mut reihe = self.folge(); + let Some(i) = reihe.iter().position(|x| *x == f) else { return }; + if i == 0 { + return; + } + reihe.swap(i, i - 1); + self.ordnen(reihe); + } + + /// Die Vorgabe (Folge wie `ALLE`) bleibt leer - so vergleichen sich Plaene und die Datei bleibt schlank. + fn ordnen(&mut self, reihe: Vec) { + let vorgabe: Vec = SpielFormat::ALLE.into_iter().filter(|f| reihe.contains(f)).collect(); + self.reihenfolge = if reihe == vorgabe { Vec::new() } else { reihe }; + } + + /// Aus kopf.spielplan; `None`, wenn Modus oder Tischzahl fehlen (z. B. Modus "turnier"). + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + let modus = match f.roh("modus").and_then(Value::as_str)? { + "uebung" => Modus::Uebung, + "cash" => Modus::Echt, + _ => return None, + }; + let tische = f.zahl("tische")? as i64; + let mut p = Spielplan::neu(modus, tische, f.zahl("budget")); + p.set_ziel(f.ganz("ziel")); + p.set_tische_bis(f.ganz("tische_bis")); + p.zeiger = f.wahr("zeiger"); + p.lehrer = f.wahr("lehrer"); + p.micro_only = f.wahr("micro_only"); + if let Some(t) = f.text("tischform") { + p.tischform = match t.as_str() { + "multiway" => Tischform::Multiway, + "hu" => Tischform::Hu, + "beide" => Tischform::Beide, + _ => p.tischform, + }; + } + p.zeitplan = f.roh("zeitplan").filter(|z| z.is_object()).cloned(); + p.geld = f.roh("geld").filter(|z| z.is_object()).cloned(); + p.turnier = f.roh("turnier").filter(|z| z.is_object()).cloned(); + + if let Some(roh) = f.roh("formate").and_then(Value::as_object) { + p.formate.clear(); + for fo in SpielFormat::ALLE { + if let Some(n) = roh.get(fo.roh()).and_then(Value::as_f64) { + p.setzen(fo, n as i64); + } + } + // Alt-Plaene mit eigenen freeroll/vip-Formaten ins neue Modell falten: EINE Turnier-Kachel, + // der Typ steckt in turnier.kategorie. Gesetzte Turnier-Zahl bleibt massgeblich. + let extra = p.anzahl(SpielFormat::Freeroll) + p.anzahl(SpielFormat::Vip); + if extra > 0 { + let turnier_neu = if p.anzahl(SpielFormat::Turnier) > 0 { p.anzahl(SpielFormat::Turnier) } else { extra }; + p.formate.remove(&SpielFormat::Freeroll); + p.formate.remove(&SpielFormat::Vip); + if turnier_neu > 0 { + p.formate.insert(SpielFormat::Turnier, turnier_neu); + } else { + p.formate.remove(&SpielFormat::Turnier); + } + } + p.tische_bis = Self::spanne(p.tische(), f.ganz("tische_bis")); + } + if let Some(Value::Array(namen)) = f.roh("reihenfolge") { + let genannt: Vec = + namen.iter().filter_map(Value::as_str).filter_map(SpielFormat::aus_roh).collect(); + let mut reihe: Vec = genannt.iter().copied().filter(|x| p.anzahl(*x) > 0).collect(); + reihe.extend(p.folge().into_iter().filter(|x| !genannt.contains(x))); + p.ordnen(reihe); + } + if let Some(Value::Array(liste)) = f.roh("formate_liste") { + let eintraege: Vec<(SpielFormat, bool, Option)> = liste + .iter() + .filter_map(|e| { + let g = Feld::aus(e)?; + let fo = SpielFormat::aus_roh(&g.text("format")?); + // ein Eintrag ohne lesbares "gemessen" faellt weg (wie in Swift) + let gemessen = g.wahr_oder_nil("gemessen")?; + Some((fo?, gemessen, g.wahr_oder_nil("spielbar"))) + }) + .collect(); + p.gemessen = eintraege.iter().filter(|e| e.1).map(|e| e.0).collect(); + if eintraege.iter().any(|e| e.2.is_some()) { + p.spielbar = eintraege.iter().filter(|e| e.2 == Some(true)).map(|e| e.0).collect(); + } + } + Some(p) + } + + /// Fuer POST /api/steuern {aktion: "spielplan_setzen", daten}. Budget nur im Cash-Modus. + pub fn daten(&self) -> Value { + let mut d = Map::new(); + d.insert("modus".into(), json!(self.modus.roh())); + d.insert("tische".into(), json!(self.tische().max(1))); + let nur_cash = self.formate.len() == 1 && self.formate.contains_key(&SpielFormat::Cash); + if !nur_cash { + // nur Cash ist die Vorgabe und bleibt weg + let m: Map = self.formate.iter().map(|(k, v)| (k.roh().to_string(), json!(v))).collect(); + d.insert("formate".into(), Value::Object(m)); + } + if let Some(z) = self.ziel { + d.insert("ziel".into(), json!(z)); + } + if !self.reihenfolge.is_empty() { + d.insert("reihenfolge".into(), json!(self.reihenfolge.iter().map(|f| f.roh()).collect::>())); + } + if self.cash() { + if let Some(b) = self.budget { + d.insert("budget".into(), zahl_json(b)); + } + } + if let Some(b) = self.tische_bis { + d.insert("tische_bis".into(), json!(b)); + } + if self.zeiger { + d.insert("zeiger".into(), json!(true)); + } + if self.lehrer { + d.insert("lehrer".into(), json!(true)); + } + if self.micro_only { + d.insert("micro_only".into(), json!(true)); + } + d.insert("tischform".into(), json!(self.tischform.roh())); // immer mitschicken (robuster Round-Trip) + Value::Object(d) + } + + /// Die Daten als Text mit sortierten Schluesseln (serde_json sortiert Objekte). + pub fn daten_text(&self) -> String { + self.daten().to_string() + } +} + +/// Ganze Zahlen ohne ".0" schicken, wie Swift sie schreibt. +fn zahl_json(x: f64) -> Value { + if x == x.trunc() && x.abs() < 1e15 { + json!(x as i64) + } else { + Number::from_f64(x).map_or(Value::Null, Value::Number) + } +} diff --git a/cockpit/src/verlauf.rs b/cockpit/src/verlauf.rs new file mode 100644 index 00000000..86b68686 --- /dev/null +++ b/cockpit/src/verlauf.rs @@ -0,0 +1,103 @@ +//! "Gerade eben": die Entscheidungen einer Hand als eine Zeile, die Haende in Bloecken je Sitzung (Verlauf.swift). + +use crate::modelle::EntscheidungsZeile; + +#[derive(Clone, Debug, PartialEq)] +pub struct Schritt { + pub aktion: String, + pub text: Option, + pub betrag_bb: Option, + pub strasse: Option, +} + +#[derive(Clone, Debug, PartialEq)] +pub struct HandZeile { + pub id: String, + pub zeit: Option, + pub raum: Option, + pub hand: Option, + pub karten: Vec, + /// in Spielreihenfolge, die erste Entscheidung zuerst + pub schritte: Vec, + pub ergebnis_bb: Option, + pub klartext: Option, +} + +#[derive(Clone, Debug, PartialEq)] +pub struct Verlaufsblock { + /// Zeit der aeltesten Entscheidung im Block + pub beginn: Option, + pub haende: Vec, +} + +/// Ab dieser Luecke zwischen zwei Entscheidungen beginnt eine neue Sitzung. +pub const SITZUNGSPAUSE_S: f64 = 30.0 * 60.0; + +/// `zeilen` neueste zuerst (wie ansicht.entscheidungen) - die Bloecke und Haende ebenso. +pub fn bloecke(zeilen: &[EntscheidungsZeile], hoechstens: usize, pause: f64) -> Vec { + let mut bloecke: Vec = Vec::new(); + let mut anzahl = 0; + let mut juengere: Option = None; + for z in zeilen { + let neuer_block = bloecke.is_empty() || luecke(juengere, z.zeit) > pause; + juengere = z.zeit.or(juengere); + if !neuer_block { + let block = bloecke.last_mut().expect("nicht leer, sonst neuer Block"); + if let Some(letzte) = block.haende.last_mut().filter(|h| gleiche_hand(h, z)) { + letzte.schritte.insert(0, schritt(z)); + letzte.ergebnis_bb = letzte.ergebnis_bb.or(z.ergebnis_bb); + letzte.klartext = letzte.klartext.take().or_else(|| z.klartext.clone()); + if letzte.karten.is_empty() { + letzte.karten = z.karten.clone(); + } + block.beginn = z.zeit.or(block.beginn); + continue; + } + } + if anzahl == hoechstens { + break; + } + anzahl += 1; + let h = HandZeile { + id: z.id(), + zeit: z.zeit, + raum: z.raum.clone(), + hand: z.hand.clone(), + karten: z.karten.clone(), + schritte: vec![schritt(z)], + ergebnis_bb: z.ergebnis_bb, + klartext: z.klartext.clone(), + }; + if neuer_block { + bloecke.push(Verlaufsblock { beginn: z.zeit, haende: vec![h] }); + } else { + let block = bloecke.last_mut().expect("nicht leer"); + block.haende.push(h); + block.beginn = z.zeit.or(block.beginn); + } + } + bloecke +} + +fn luecke(juengere: Option, zeit: Option) -> f64 { + match (juengere, zeit) { + (Some(j), Some(z)) => j - z, + _ => 0.0, + } +} + +fn gleiche_hand(h: &HandZeile, z: &EntscheidungsZeile) -> bool { + match z.hand.as_deref() { + Some(hand) if !hand.is_empty() => h.hand.as_deref() == Some(hand) && h.raum == z.raum, + _ => false, + } +} + +fn schritt(z: &EntscheidungsZeile) -> Schritt { + Schritt { + aktion: z.aktion.clone().unwrap_or_default(), + text: z.aktion_text.clone(), + betrag_bb: z.betrag_bb, + strasse: z.strasse.clone(), + } +} diff --git a/cockpit/src/wachstum.rs b/cockpit/src/wachstum.rs new file mode 100644 index 00000000..23c8d3bb --- /dev/null +++ b/cockpit/src/wachstum.rs @@ -0,0 +1,194 @@ +//! Der Bereich `wachstum` (Wachstum.swift): Kurven, Statistik je Modus und je Format. + +use serde_json::Value; + +use crate::format::auto; +use crate::formate::{FormatUrteil, FormatZeile}; +use crate::nachsichtig::Feld; + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct KurvenPunkt { + pub t: Option, + pub bb: Option, +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StakeZeile { + pub stake: String, + pub haende: Option, + pub bb100: Option, + pub unten: Option, + pub oben: Option, +} + +#[derive(Clone, Debug, PartialEq)] +pub struct Sitzung { + pub raum: Option, + pub von: Option, + pub bis: Option, + pub haende: Option, + pub netto_bb: Option, + pub bb100: Option, +} + +#[derive(Clone, Debug, PartialEq)] +pub struct Stunde { + pub stunde: Option, + pub haende: Option, +} + +#[derive(Clone, Debug, PartialEq)] +pub struct Klasse { + pub von: Option, + pub bis: Option, + pub anzahl: Option, +} + +impl Klasse { + /// "< 50", "50…100", "≥ 50" + pub fn beschriftung(&self) -> String { + match (self.von, self.bis) { + (None, Some(b)) => format!("< {}", auto(Some(b))), + (Some(v), None) => format!("≥ {}", auto(Some(v))), + (Some(v), Some(b)) => format!("{}…{}", auto(Some(v)), auto(Some(b))), + (None, None) => "?".into(), + } + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct Summe { + pub haende: Option, + pub netto_bb: Option, + pub gewonnen: Option, + pub verloren: Option, +} + +#[derive(Clone, Debug, PartialEq)] +pub struct StapelPunkt { + pub t: Option, + pub stack: Option, +} + +#[derive(Clone, Debug, PartialEq)] +pub struct Stapel { + pub raum: String, + pub punkte: Vec, +} + +/// Die Kurven einer Grundlage - eigene Haende oder der ganze Bestand. +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Kurven { + pub leer: Option, + pub ergebnis_kurve: Vec, + pub bb100: Vec, + pub je_stunde: Vec, + pub verteilung: Vec, + pub summe: Option, + pub grundlage: Option, + pub rechnet: bool, + /// Je Modus: ab wann gezaehlt wird (Statistik zurueckgesetzt), `None` = ab Anfang. + pub nullpunkt: Option, + pub je_format: Vec, + pub bestes_format: Option, +} + +impl Kurven { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + Some(Kurven { + leer: f.text("leer"), + ergebnis_kurve: f.objekte("ergebnis_kurve", |p| { + let g = Feld::aus(p)?; + Some(KurvenPunkt { t: g.zahl("t"), bb: g.zahl("bb") }) + }), + bb100: f.objekte("bb100", |z| { + let g = Feld::aus(z)?; + Some(StakeZeile { + stake: g.text("stake").unwrap_or_else(|| "?".into()), + haende: g.ganz("haende"), + bb100: g.zahl("bb100"), + unten: g.zahl("unten"), + oben: g.zahl("oben"), + }) + }), + je_stunde: f.objekte("je_stunde", |z| { + let g = Feld::aus(z)?; + Some(Stunde { stunde: g.zahl("stunde"), haende: g.ganz("haende") }) + }), + verteilung: f.objekte("verteilung", |z| { + let g = Feld::aus(z)?; + Some(Klasse { von: g.zahl("von"), bis: g.zahl("bis"), anzahl: g.ganz("anzahl") }) + }), + summe: f.kind("summe", |s| { + let g = Feld::aus(s)?; + Some(Summe { + haende: g.ganz("haende"), + netto_bb: g.zahl("netto_bb"), + gewonnen: g.ganz("gewonnen"), + verloren: g.ganz("verloren"), + }) + }), + grundlage: f.text("grundlage"), + rechnet: f.wahr("rechnet"), + nullpunkt: f.zahl("nullpunkt"), + je_format: f.objekte("je_format", FormatZeile::aus), + bestes_format: f.kind("bestes_format", FormatUrteil::aus), + }) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct Wachstum { + pub eigene: Kurven, + pub bestand: Option, + pub stapel: Vec, + pub sitzungen: Vec, + /// Statistik je Modus (ab dem Nullpunkt); `unklar`: Haende ohne bekannten Modus. + pub uebung: Option, + pub echt: Option, + pub unklar: Option, +} + +impl Wachstum { + pub fn aus(v: &Value) -> Option { + let f = Feld::aus(v)?; + let mut w = Wachstum { + eigene: Kurven::aus(v)?, + bestand: f.kind("bestand", Kurven::aus), + stapel: f.objekte("stapel", |s| { + let g = Feld::aus(s)?; + Some(Stapel { + raum: g.text("raum").unwrap_or_else(|| "?".into()), + punkte: g.objekte("punkte", |p| { + let h = Feld::aus(p)?; + Some(StapelPunkt { t: h.zahl("t"), stack: h.zahl("stack") }) + }), + }) + }), + sitzungen: f.objekte("sitzungen", |s| { + let g = Feld::aus(s)?; + Some(Sitzung { + raum: g.text("raum"), + von: g.zahl("von"), + bis: g.zahl("bis"), + haende: g.ganz("haende"), + netto_bb: g.zahl("netto_bb"), + bb100: g.zahl("bb100"), + }) + }), + ..Default::default() + }; + if let Some(m) = f.roh("je_modus").and_then(Feld::aus) { + w.uebung = m.kind("uebung", Kurven::aus); + // "echt": Plaene vor der Umbenennung + w.echt = m.kind("cash", Kurven::aus).or_else(|| m.kind("echt", Kurven::aus)); + w.unklar = m.ganz("unklar"); + } + Some(w) + } + + pub fn kurven(&self, cash: bool) -> Option<&Kurven> { + if cash { self.echt.as_ref() } else { self.uebung.as_ref() } + } +} diff --git a/cockpit/tests/ansicht_spec.rs b/cockpit/tests/ansicht_spec.rs new file mode 100644 index 00000000..232b94b2 --- /dev/null +++ b/cockpit/tests/ansicht_spec.rs @@ -0,0 +1,286 @@ +//! Port von NachrichtSpec.swift (Nachrichten, Kacheln, Kopf-Ende, Geld/Statistik je Modus) - +//! die erste Gruppe laeuft gegen die echte Fixture ansicht.json. + +mod hilfen; + +use cockpit::ansicht::{Ansicht, Nachricht, Rueckmeldung}; +use cockpit::hauptknopf::Hauptknopf; +use cockpit::kachel::LiveKachel; +use cockpit::modelle::{Bereich, Klick, Ton}; +use cockpit::spielplan::Spielplan; +use hilfen::{ansicht, fixture}; + +fn geladen() -> Ansicht { + let mut a = Ansicht::default(); + let n = a.anwenden(&fixture()); + match n { + Nachricht::Ansicht(b) => assert_eq!(b.len(), 9), + andere => panic!("keine Ansicht: {andere:?}"), + } + a +} + +#[test] +fn eine_ansicht_fuellt_alle_neun_bereiche() { + let mut a = Ansicht::default(); + let Nachricht::Ansicht(neu) = a.anwenden(&fixture()) else { panic!("keine Ansicht") }; + for b in Bereich::ALLE { + assert!(neu.contains(&b), "{b:?} fehlt"); + } + let kopf = a.kopf.as_ref().unwrap(); + assert_eq!(kopf.status.as_ref().unwrap().ton(), Ton::Blau); + assert_eq!(kopf.modus.as_deref(), Some("Übung")); + let jetzt = a.jetzt.as_ref().unwrap(); + assert_eq!(jetzt.karten.len(), 2); + assert_eq!(jetzt.entscheidung.as_ref().unwrap().aktion_text.as_deref(), Some("Aussetzen")); + let e = a.entscheidungen.as_ref().unwrap(); + assert_eq!(e.gesamt, Some(467)); + assert_eq!(e.zeilen.first().unwrap().klick.as_deref(), Some("ausgesetzt")); + assert_eq!(a.sitzen.as_ref().unwrap().raeume[0].handlung.as_ref().unwrap().art.as_deref(), Some("aussetzen")); + assert_eq!(a.stil.as_ref().unwrap().denkzeit.as_ref().unwrap().median, Some(4.0)); + assert!(a.wachstum.as_ref().unwrap().bestand.as_ref().unwrap().rechnet); + assert!(a.geld.as_ref().unwrap().uebung); + assert!(!a.ticker.as_ref().unwrap().gedanken.is_empty()); + assert_eq!(a.stand, Some(1793294407.5)); +} + +#[test] +fn die_fixture_zeigt_den_hauptknopf_ueben() { + // Die echte Ansicht: Laeufer laeuft (pid null, laeuft true) -> Aufhoeren. + let a = geladen(); + let k = Hauptknopf::waehlen(a.kopf.as_ref(), true, &Spielplan::standard(), false); + assert_eq!(k, Hauptknopf::Aufhoeren); + assert_eq!(k.schritte(), ["laeufer_stoppen"]); +} + +#[test] +fn ein_teil_update_ersetzt_nur_die_genannten_bereiche() { + let mut a = geladen(); + let n = a.anwenden( + r#"{"typ":"ansicht","teile":{"kopf":{"laeuft":false,"not_aus":true,"status":{"zustand":"gestoppt","farbe":"rot","satz":"Not-Aus aktiv"}}},"stand":5}"#, + ); + assert_eq!(n, Nachricht::Ansicht(vec![Bereich::Kopf])); + let kopf = a.kopf.as_ref().unwrap(); + assert!(kopf.not_aus); + assert_eq!(kopf.status.as_ref().unwrap().ton(), Ton::Rot); + assert_eq!(a.entscheidungen.as_ref().unwrap().gesamt, Some(467)); + assert_eq!(a.stand, Some(5.0)); +} + +#[test] +fn ein_leerer_bereich_traegt_seinen_text() { + let a = ansicht(r#"{"jetzt":{"leer":"keine Daten (OSError)"}}"#); + let j = a.jetzt.unwrap(); + assert_eq!(j.leer.as_deref(), Some("keine Daten (OSError)")); + assert!(j.karten.is_empty()); +} + +#[test] +fn ein_kaputter_bereich_faellt_weg_die_anderen_kommen_an() { + let mut a = Ansicht::default(); + let n = a.anwenden(r#"{"typ":"ansicht","teile":{"kopf":"quatsch","geld":{"zeilen":[],"uebung":false}},"stand":1}"#); + let Nachricht::Ansicht(neu) = n else { panic!("keine Ansicht") }; + assert!(neu.contains(&Bereich::Kopf) && neu.contains(&Bereich::Geld) && neu.len() == 2); + assert!(a.kopf.is_none()); + assert!(!a.geld.unwrap().uebung); +} + +#[test] +fn zahlen_und_texte_in_feldern_mit_wechselndem_typ() { + let a = ansicht( + r#"{"sitzen":{"raeume":[{"raum":"A","zustand":"gesessen","platz":3,"bb":"0.05/0.1"},{"raum":"B","platz":"7","bb":0.1}]}}"#, + ); + let r = a.sitzen.unwrap().raeume; + assert_eq!(r.iter().map(|x| x.platz.clone()).collect::>(), [Some("3".into()), Some("7".into())]); + assert_eq!(r.iter().map(|x| x.bb.clone()).collect::>(), [Some("0.05/0.1".into()), Some("0.1".into())]); +} + +#[test] +fn eine_rueckmeldung_wird_gemeldet_und_aendert_nichts() { + let mut a = Ansicht::default(); + let n = a.anwenden(r#"{"typ":"rueckmeldung","aktion":"foto","ok":true,"text":"Foto gemacht","raum":"T1","bild":"/foto/foto-1.png"}"#); + assert_eq!( + n, + Nachricht::Rueckmeldung(Rueckmeldung { + aktion: Some("foto".into()), + ok: true, + text: "Foto gemacht".into(), + raum: Some("T1".into()), + bild: Some("/foto/foto-1.png".into()), + }) + ); + assert!(a.kopf.is_none()); +} + +#[test] +fn unsinn_und_unbekannte_typen_sind_unbekannt_nie_ein_fehler() { + let mut a = Ansicht::default(); + assert_eq!(a.anwenden("kein json"), Nachricht::Unbekannt); + assert_eq!(a.anwenden(r#"{"typ":"wetter"}"#), Nachricht::Unbekannt); + assert_eq!(a.anwenden("[1,2]"), Nachricht::Unbekannt); +} + +// ---- Kacheln ---- + +fn raeume(a: &Ansicht) -> Vec { + LiveKachel::alle(a).into_iter().map(|k| k.raum).collect() +} + +#[test] +fn kacheln_reihenfolge() { + let a = ansicht( + r#"{"kopf":{"laeuft":true,"tische":["C","A"]}, + "jetzt":{"raum":"B","karten":["Qh","8c"]}, + "sitzen":{"raeume":[{"raum":"A","zustand":"gesessen"},{"raum":"X","zustand":"frei"},{"raum":"B","zustand":"wartend"},{"raum":"P","zustand":"unbekannt","platz":2}]}}"#, + ); + assert_eq!(raeume(&a), ["B", "A", "P", "C"]); +} + +#[test] +fn kacheln_ohne_lauf_zaehlen_nur_sitze_aus_dem_log() { + let a = ansicht( + r#"{"kopf":{"laeuft":false,"tische":["C"]},"jetzt":{"raum":"B","karten":["Qh","8c"]}, + "sitzen":{"raeume":[{"raum":"A","zustand":"ausgesetzt"}]}}"#, + ); + assert_eq!(raeume(&a), ["A"]); +} + +#[test] +fn kacheln_jeder_tisch_mit_offenem_fenster_hat_eine() { + let a = ansicht( + r#"{"kopf":{"laeuft":false}, + "sitzen":{"raeume":[{"raum":"A","zustand":"frei","fenster":1},{"raum":"X","zustand":"frei","fenster":0},{"raum":"S","zustand":"ausgesetzt"}]}}"#, + ); + assert_eq!(raeume(&a), ["A", "S"]); +} + +#[test] +fn kacheln_inhalt_jetzt_oder_letzte_entscheidung() { + let a = ansicht( + r#"{"kopf":{"laeuft":true,"tische":["A","B"]}, + "jetzt":{"raum":"A","karten":["Qh","8c"],"board":["2s"],"zug":{"offen":true,"frist_s":10,"bis":5}, + "entscheidung":{"aktion":"CALL","aktion_text":"Mitgehen"},"klick":{"status":"bestätigt"}}, + "entscheidungen":{"zeilen":[{"raum":"B","aktion":"FOLD","karten":["2c","7d"],"klick":"ausgesetzt","klick_warum":"x"}, + {"raum":"B","aktion":"RAISE"}]}, + "sitzen":{"raeume":[{"raum":"B","zustand":"gesessen","platz":4,"stack":12.5}]}}"#, + ); + let k = LiveKachel::alle(&a); + assert_eq!(k[0].karten, ["Qh", "8c"]); + assert!(k[0].zug.as_ref().unwrap().offen); + assert_eq!(k[0].aktion.as_deref(), Some("Mitgehen")); + assert_eq!(k[0].klick.as_ref().unwrap().status.as_deref(), Some("bestätigt")); + assert_eq!(k[1].karten, ["2c", "7d"]); + assert!(k[1].zug.is_none()); + assert_eq!(k[1].aktion.as_deref(), Some("FOLD")); + assert_eq!(k[1].klick, Some(Klick { status: Some("ausgesetzt".into()), warum: Some("x".into()), beleg: None })); + assert_eq!(k[1].raum_info.as_ref().unwrap().platz.as_deref(), Some("4")); +} + +#[test] +fn kacheln_die_laufende_hand_aus_dem_log_schlaegt_eine_alte_entscheidung() { + let a = ansicht( + r#"{"kopf":{"laeuft":false}, + "entscheidungen":{"zeilen":[{"raum":"A","hand":"h1","aktion":"FOLD","karten":["Qc","7d"]}]}, + "sitzen":{"raeume":[{"raum":"A","zustand":"gesessen","platz":1, + "hand":{"hand":"h2","karten":["9s","3s"],"board":["6h","Td","2h"],"topf":5000}}]}}"#, + ); + let k = &LiveKachel::alle(&a)[0]; + assert_eq!(k.karten, ["9s", "3s"]); + assert_eq!(k.board, ["6h", "Td", "2h"]); + assert_eq!(k.topf, Some(5000.0)); + assert!(k.aktion.is_none(), "die Entscheidung gehoerte zu h1"); +} + +#[test] +fn kacheln_gleiche_hand_entscheidung_bleibt_board_und_topf_frisch() { + let a = ansicht( + r#"{"kopf":{"laeuft":true,"tische":["A"]}, + "entscheidungen":{"zeilen":[{"raum":"A","hand":"h2","aktion":"CALL","karten":["9s","3s"],"board":[]}]}, + "sitzen":{"raeume":[{"raum":"A","zustand":"gesessen","platz":1, + "hand":{"hand":"h2","karten":["9s","3s"],"board":["6h","Td","2h"],"topf":5000}}]}}"#, + ); + let k = &LiveKachel::alle(&a)[0]; + assert_eq!(k.aktion.as_deref(), Some("CALL")); + assert_eq!(k.board, ["6h", "Td", "2h"]); + assert_eq!(k.topf, Some(5000.0)); +} + +#[test] +fn kacheln_ohne_entscheidung_erzaehlt_die_letzte_sitz_handlung() { + let a = ansicht( + r#"{"kopf":{"laeuft":true,"tische":[]}, + "sitzen":{"raeume":[{"raum":"A","zustand":"wartend","handlung":{"art":"warten","grund":"voll"}}]}}"#, + ); + let k = LiveKachel::alle(&a); + assert_eq!(k[0].aktion, None); + assert_eq!(k[0].hinweis.as_deref(), Some("warten: voll")); +} + +#[test] +fn kacheln_ohne_eigenen_platz_keine_alten_karten() { + let a = ansicht( + r#"{"kopf":{"laeuft":true,"tische":["A"]}, + "entscheidungen":{"zeilen":[{"raum":"A","hand":"h1","aktion":"FOLD","karten":["Qc","7d"]}]}, + "sitzen":{"raeume":[{"raum":"A","zustand":"gesessen","tisch":{"spieler":[{"sitz":2,"ich":false}]}}]}}"#, + ); + let k = &LiveKachel::alle(&a)[0]; + assert!(k.karten.is_empty() && k.aktion.is_none()); + assert_eq!(k.hinweis.as_deref(), Some("du sitzt an diesem Tisch nicht")); +} + +// ---- Kopf und Geld ---- + +#[test] +fn kopf_client_und_letztes_ende() { + let mut a = Ansicht::default(); + a.anwenden(r#"{"typ":"ansicht","teile":{"kopf":{"client":false,"ende":{"zeit":5,"abbruch":true,"grund":"Tischfenster nicht gefunden"}}}}"#); + let k = a.kopf.as_ref().unwrap(); + assert_eq!(k.client, Some(false)); + let e = k.ende.as_ref().unwrap(); + assert!(e.abbruch); + assert_eq!(e.grund.as_deref(), Some("Tischfenster nicht gefunden")); + a.anwenden(r#"{"typ":"ansicht","teile":{"kopf":{"ende":null}}}"#); + assert!(a.kopf.as_ref().unwrap().ende.is_none()); + assert_eq!(a.kopf.as_ref().unwrap().client, None); +} + +#[test] +fn geld_regeln_und_stand() { + let a = ansicht( + r#"{"geld":{"zeilen":[],"uebung":false,"regeln":{"nachkauf_unter_bb":60,"aufstehen_unter_bb":20,"stop_tisch_bb":100,"stop_sitzung_bb":250,"anteil_je_tisch":0.2,"hoechstens_tische":12,"buyin_echt":"20% des Guthabens, mindestens Min","buyin_uebung":"Max","ratholing":false},"stand":{"sitzung_bb":-42.5,"seit":5,"tische":[{"raum":"Big Ben 1","netto_bb":18.0}]}}}"#, + ); + let g = a.geld.unwrap(); + assert_eq!(g.regeln.as_ref().unwrap().stop_sitzung_bb, Some(250.0)); + assert_eq!(g.regeln.as_ref().unwrap().nachkauf_unter_bb, Some(60.0)); + assert_eq!(g.stand.as_ref().unwrap().sitzung_bb, Some(-42.5)); + assert_eq!(g.stand.as_ref().unwrap().tische[0].raum, "Big Ben 1"); +} + +#[test] +fn statistik_je_modus() { + let a = ansicht( + r#"{"wachstum":{"summe":{"haende":4},"je_modus":{"uebung":{"summe":{"haende":2,"netto_bb":1.0},"nullpunkt":100.0,"ergebnis_kurve":[]},"cash":{"summe":{"haende":1,"netto_bb":5.0},"nullpunkt":null},"unklar":1}}}"#, + ); + let w = a.wachstum.unwrap(); + assert_eq!(w.uebung.as_ref().unwrap().summe.as_ref().unwrap().haende, Some(2)); + assert_eq!(w.uebung.as_ref().unwrap().nullpunkt, Some(100.0)); + assert_eq!(w.echt.as_ref().unwrap().summe.as_ref().unwrap().netto_bb, Some(5.0)); + assert_eq!(w.echt.as_ref().unwrap().nullpunkt, None); + assert_eq!(w.unklar, Some(1)); +} + +// ---- Fixture-Drift ---- + +/// Die Kopie unter tests/fixtures/ muss der Swift-Fixture gleichen. Im abgetrennten Baum (ohne +/// `../mac`) wird die Pruefung uebersprungen; sonst bricht sie bei jeder Abweichung - Kopie dann +/// mit `cp ../mac/Tests/Pruefung/Fixtures/ansicht.json tests/fixtures/` erneuern. +#[test] +fn fixture_gleicht_der_swift_kopie() { + let Ok(swift) = std::fs::read(hilfen::FIXTURE_SWIFT) else { + eprintln!("mac/ nicht da: Fixture-Vergleich uebersprungen"); + return; + }; + let hier = std::fs::read(hilfen::FIXTURE_PFAD).unwrap(); + let norm = |b: Vec| String::from_utf8(b).unwrap().replace("\r\n", "\n"); + assert_eq!(norm(hier), norm(swift), "cockpit/tests/fixtures/ansicht.json ist nicht synchron zu mac/Tests/Pruefung/Fixtures/ansicht.json"); +} diff --git a/cockpit/tests/fixtures/ansicht.json b/cockpit/tests/fixtures/ansicht.json new file mode 100644 index 00000000..d39eb3f7 --- /dev/null +++ b/cockpit/tests/fixtures/ansicht.json @@ -0,0 +1,527 @@ +{ + "typ": "ansicht", + "teile": { + "kopf": { + "laeuft": true, + "text": "läuft seit 18:09", + "seit": 1793293791.0, + "zuletzt": 1793294407.0, + "laufzeit_s": 627.4, + "tische": [], + "tische_offen": 0, + "tische_text": "0 offen, 0 sitzend", + "modus": "Übung", + "modus_quelle": "Dialog", + "klon": false, + "not_aus": false, + "guthaben": null, + "pid": null, + "status": { + "zustand": "liest", + "farbe": "blau", + "satz": "liest den Client - noch kein Tisch" + }, + "leer": null + }, + "jetzt": { + "raum": null, + "hand": "166547800145", + "strasse": "Turn", + "karten": [ + "As", + "Ah" + ], + "board": [ + "FLOP", + "TURN" + ], + "topf": 85931.48, + "zu_zahlen": 0.0, + "stack": 47314.26, + "zug": { + "offen": false, + "frist_s": null, + "bis": null, + "seit": 1793293590.0 + }, + "entscheidung": { + "aktion": "ABSTAIN", + "aktion_text": "Aussetzen", + "betrag": null, + "betrag_bb": null, + "grund": "Übersetzung setzt aus: Knopf unbekannt (Hand vor dem Logbeginn angefangen)", + "klartext": "Übersetzung setzt aus: Knopf unbekannt (Hand vor dem Logbeginn angefangen)", + "equity": null, + "confidence": null, + "gedenkzeit_s": 0.0, + "zeit": 1793293590.0 + }, + "klick": { + "status": "ausgesetzt", + "warum": "der Kern setzt aus", + "beleg": "" + }, + "leer": null + }, + "wachstum": { + "ergebnis_kurve": [ + { + "t": 1793287940.0, + "chips": -2320.0, + "bb": -1.16 + } + ], + "stapel": [ + { + "raum": "Big Ben 1672117", + "punkte": [ + { + "t": 1793287981.0, + "stack": 77680.0 + }, + { + "t": 1793287985.0, + "stack": 77680.0 + } + ] + }, + { + "raum": "unbekannt", + "punkte": [ + { + "t": 1793198831.0, + "stack": 9.9 + }, + { + "t": 1793199213.0, + "stack": 2.4 + }, + { + "t": 1793199213.0, + "stack": 2.4 + } + ] + } + ], + "bb100": [ + { + "stake": "1000/2000", + "bb": 2000.0, + "haende": 1, + "bb100": -116.0, + "unten": null, + "oben": null + } + ], + "sitzungen": [ + { + "raum": "Big Ben 1672117", + "von": 1793287766.0, + "bis": 1793288986.0, + "haende": 1, + "netto_bb": -1.16, + "bb100": -116.0, + "unten": null, + "oben": null + } + ], + "je_stunde": [ + { + "stunde": 1793286000.0, + "haende": 1 + } + ], + "verteilung": [ + { + "von": null, + "bis": -50, + "anzahl": 0 + }, + { + "von": -50, + "bis": -20, + "anzahl": 0 + }, + { + "von": -20, + "bis": -10, + "anzahl": 0 + } + ], + "bestand": { + "ergebnis_kurve": [], + "bb100": [], + "je_stunde": [], + "verteilung": [ + { + "von": null, + "bis": -50, + "anzahl": 0 + }, + { + "von": -50, + "bis": -20, + "anzahl": 0 + }, + { + "von": -20, + "bis": -10, + "anzahl": 0 + } + ], + "summe": { + "haende": 0, + "netto_bb": 0.0, + "gewonnen": 0, + "verloren": 0 + }, + "haende": 0, + "von": null, + "bis": null, + "rechnet": true, + "grundlage": "0 Sitz-Hände aller Spieler aus dem Archiv (archiv/mitschrieb/main*.log.gz)", + "leer": "Bestand wird gerechnet - gleich da" + }, + "grundlage": "1 eigene Hände (Protokoll und Statistik, Spieler mmintel)", + "summe": { + "haende": 1, + "netto_bb": -1.16, + "gewonnen": 0, + "verloren": 1 + }, + "leer": null + }, + "entscheidungen": { + "zeilen": [ + { + "zeit": 1793293590.0, + "raum": null, + "hand": "166547800145", + "strasse": "Turn", + "karten": [ + "As", + "Ah" + ], + "board": [ + "FLOP", + "TURN" + ], + "aktion": "ABSTAIN", + "aktion_text": "Aussetzen", + "betrag_bb": null, + "grund": "Übersetzung setzt aus: Knopf unbekannt (Hand vor dem Logbeginn angefangen)", + "klartext": "Übersetzung setzt aus: Knopf unbekannt (Hand vor dem Logbeginn angefangen)", + "equity": null, + "confidence": null, + "stake": null, + "spielart": "NLHE", + "ergebnis_bb": null, + "ergebnis_text": "offen", + "klick": "ausgesetzt", + "klick_warum": "der Kern setzt aus", + "beleg": "", + "gedenkzeit_s": 0.0 + }, + { + "zeit": 1793293590.0, + "raum": null, + "hand": "166344000006", + "strasse": "Flop", + "karten": [ + "As", + "Kc", + "Qc" + ], + "board": [ + "FLOP" + ], + "aktion": "RAISE", + "aktion_text": "Raise auf 1 BB", + "betrag_bb": 1.0, + "grund": "double board: board 2 judged better (equity 0.66 against 0.57); approximation: better board although the pot split halves it - top pair good kicker on medium board: equity 0.66 vs break-even 0.00, EV raise to 0.05 +0.15", + "klartext": "Double board: board 2 judged better (Equity 0.66 gegen 0.57); approximation: better board although the pot split halves it - top pair good kicker on medium board: Equity 0.66 gegen nötige 0.00, EV Raise auf 0.05 +0.15", + "equity": 0.66, + "confidence": 0.744, + "stake": "0.025/0.05", + "spielart": "PLO4", + "ergebnis_bb": null, + "ergebnis_text": "offen", + "klick": "Schatten", + "klick_warum": "nur protokolliert, nicht geklickt", + "beleg": "", + "gedenkzeit_s": 0.0 + }, + { + "zeit": 1793293586.0, + "raum": null, + "hand": "166344000006", + "strasse": "Flop", + "karten": [ + "As", + "Kc", + "Qc" + ], + "board": [ + "FLOP" + ], + "aktion": "RAISE", + "aktion_text": "Raise auf 1 BB", + "betrag_bb": 1.0, + "grund": "double board: board 2 judged better (equity 0.66 against 0.57); approximation: better board although the pot split halves it - top pair good kicker on medium board: equity 0.66 vs break-even 0.00, EV raise to 0.05 +0.15", + "klartext": "Double board: board 2 judged better (Equity 0.66 gegen 0.57); approximation: better board although the pot split halves it - top pair good kicker on medium board: Equity 0.66 gegen nötige 0.00, EV Raise auf 0.05 +0.15", + "equity": 0.66, + "confidence": 0.744, + "stake": "0.025/0.05", + "spielart": "PLO4", + "ergebnis_bb": null, + "ergebnis_text": "offen", + "klick": "Schatten", + "klick_warum": "nur protokolliert, nicht geklickt", + "beleg": "", + "gedenkzeit_s": 0.0 + } + ], + "facetten": { + "aktion": [ + "ABSTAIN", + "CALL", + "CHECK" + ], + "stake": [ + "0.025/0.05", + "0.05/0.1", + "1000/2000" + ], + "spielart": [ + "NLHE", + "PLO4" + ], + "ergebnis": [ + "gewonnen", + "verloren", + "null" + ] + }, + "gesamt": 467, + "angezeigt": 467, + "gekappt": false, + "ausschnitt": false, + "hinweis": null, + "leer": null + }, + "geld": { + "zeilen": [ + { + "zeit": 1793288043.0, + "raum": "Big Ben 1672117", + "art": "Ausgesetzt", + "betrag": null, + "betrag_bb": null, + "stack": null, + "grund": "Stakes oder Stack unbekannt", + "geklickt": null, + "hinweis": "", + "uebung": true + }, + { + "zeit": 1793288023.0, + "raum": "Big Ben 1672117", + "art": "Ausgesetzt", + "betrag": null, + "betrag_bb": null, + "stack": null, + "grund": "Stakes oder Stack unbekannt", + "geklickt": null, + "hinweis": "", + "uebung": true + }, + { + "zeit": 1793288015.0, + "raum": "Big Ben 1672117", + "art": "Ausgesetzt", + "betrag": null, + "betrag_bb": null, + "stack": null, + "grund": "Stakes oder Stack unbekannt", + "geklickt": null, + "hinweis": "", + "uebung": true + } + ], + "uebung": true, + "leer": null + }, + "sitzen": { + "raeume": [ + { + "raum": "Big Ben 1667798", + "zustand": "unbekannt", + "platz": null, + "stack": null, + "freie": [], + "groesse": null, + "bb": null, + "modus": null, + "handlung": { + "art": "aussetzen", + "grund": "Tischgröße unbekannt (kein game_alldata)", + "zeit": 1793289013.0, + "geklickt": null, + "hinweis": "" + }, + "fenster": 0 + }, + { + "raum": "Big Ben 1668823", + "zustand": "unbekannt", + "platz": null, + "stack": null, + "freie": [], + "groesse": null, + "bb": null, + "modus": null, + "handlung": { + "art": "aussetzen", + "grund": "Tischgröße unbekannt (kein game_alldata)", + "zeit": 1793293771.0, + "geklickt": null, + "hinweis": "" + }, + "fenster": 0 + }, + { + "raum": "Big Ben 1669173", + "zustand": "unbekannt", + "platz": null, + "stack": null, + "freie": [], + "groesse": null, + "bb": null, + "modus": null, + "handlung": { + "art": "claim", + "grund": "Claim Chips offen", + "zeit": 1793287516.0, + "geklickt": [ + "claim" + ], + "hinweis": "" + }, + "fenster": 0 + } + ], + "fenster": { + "zahl": 0, + "ueberzaehlig": [] + }, + "leer": null + }, + "stil": { + "verlauf": [ + { + "fold": 0.25, + "check": 0.3, + "call": 0.15, + "raise": 0.2, + "allin": 0.1, + "n": 20, + "t": 1793198831.0 + }, + { + "fold": 0.15, + "check": 0.45, + "call": 0.05, + "raise": 0.35, + "allin": 0.0, + "n": 20, + "t": 1793229162.0 + }, + { + "fold": 0.05, + "check": 0.1, + "call": 0.15, + "raise": 0.5, + "allin": 0.2, + "n": 20, + "t": 1793229651.0 + } + ], + "groessen": [ + { + "betrag_bb": 2.0, + "topf_anteil": 0.93 + }, + { + "betrag_bb": 76.8, + "topf_anteil": 19.2 + }, + { + "betrag_bb": 2.0, + "topf_anteil": 0.87 + } + ], + "denkzeiten": [ + { + "s": 1.5 + }, + { + "s": 1.5 + }, + { + "s": 1.71 + } + ], + "denkzeit": { + "median": 4.0, + "streuung": 2.921, + "vk": 0.588, + "n": 28 + }, + "anteile": { + "fold": 0.108, + "check": 0.16, + "call": 0.093, + "raise": 0.561, + "allin": 0.078, + "n": 399 + }, + "leer": null + }, + "ticker": { + "zeilen": [ + { + "zeit": 1793294407.0, + "art": "sitzen", + "raum": "Big Ben 1672022", + "text": "Sitzen (aussetzen): Tischgröße unbekannt (kein game_alldata)." + }, + { + "zeit": 1793294398.0, + "art": "sitzen", + "raum": "Big Ben 1672022", + "text": "Sitzen (aussetzen): Tischgröße unbekannt (kein game_alldata)." + }, + { + "zeit": 1793294389.0, + "art": "sitzen", + "raum": "Big Ben 1672022", + "text": "Sitzen (aussetzen): Tischgröße unbekannt (kein game_alldata)." + } + ], + "gedanken": [ + "18:06:30 Hand 166547800145 Turn: Aussetzen | Grund: Übersetzung setzt aus: Knopf unbekannt (Hand vor dem Logbeginn angefangen) | Ergebnis: offen", + "18:06:30 Hand 166344000006 Flop: Raise auf 1 BB | Konfidenz 0,74 | Equity 66 % | Grund: double board: board 2 judged better (equity 0.66 against 0.57); approximation: better board although the pot split halves it - top pair good kicker on medium board: equity 0.66 vs break-even 0.00, EV raise to 0.05 +0.15 | Ergebnis: offen", + "18:06:26 Hand 166344000006 Flop: Raise auf 1 BB | Konfidenz 0,74 | Equity 66 % | Grund: double board: board 2 judged better (equity 0.66 against 0.57); approximation: better board although the pot split halves it - top pair good kicker on medium board: equity 0.66 vs break-even 0.00, EV raise to 0.05 +0.15 | Ergebnis: offen" + ], + "leer": null + }, + "zuschauer": { + "laeuft": false, + "aktuell": null, + "tisch": null, + "abgleich": [], + "leer": "Zuschauer läuft nicht" + } + }, + "stand": 1793294407.5 +} \ No newline at end of file diff --git a/cockpit/tests/hauptknopf_spec.rs b/cockpit/tests/hauptknopf_spec.rs new file mode 100644 index 00000000..7706cfc5 --- /dev/null +++ b/cockpit/tests/hauptknopf_spec.rs @@ -0,0 +1,220 @@ +//! Port von mac/Tests/Pruefung/HauptknopfSpec.swift: immer der naechste sinnvolle Schritt. + +mod hilfen; + +use cockpit::hauptknopf::{checkliste, Belegt, Hauptknopf}; +use cockpit::modelle::Kopf; +use cockpit::spielplan::{Modus, Spielplan}; +use hilfen::kopf; + +fn waehlen(k: &Option) -> Hauptknopf { + Hauptknopf::waehlen_vorgabe(k.as_ref()) +} + +fn ohne_freigabe(k: &Option) -> Hauptknopf { + Hauptknopf::waehlen(k.as_ref(), false, &Spielplan::standard(), false) +} + +fn mit_plan(k: &Option, wahl: &Spielplan) -> Hauptknopf { + Hauptknopf::waehlen(k.as_ref(), true, wahl, false) +} + +fn zuschauend(k: &Option, lesbar: bool) -> Hauptknopf { + Hauptknopf::waehlen(k.as_ref(), lesbar, &Spielplan::standard(), true) +} + +#[test] +fn ohne_daten_kein_schritt() { + assert_eq!(Hauptknopf::waehlen_vorgabe(None), Hauptknopf::Unbekannt); +} + +#[test] +fn not_aus_geht_vor_allem() { + let k = kopf(r#"{"not_aus":true,"laeuft":true,"pid":5,"tische_offen":2,"modus":"Übung"}"#); + assert_eq!(waehlen(&k), Hauptknopf::NotAusLoesen); +} + +#[test] +fn laeuft_der_laeufer_heisst_er_aufhoeren() { + assert_eq!(waehlen(&kopf(r#"{"laeuft":true,"pid":5,"modus":"Übung"}"#)), Hauptknopf::Aufhoeren); + assert_eq!(waehlen(&kopf(r#"{"laeuft":true,"modus":"cash"}"#)), Hauptknopf::Aufhoeren); +} + +#[test] +fn hoert_er_schon_auf_hat_der_knopf_nichts_mehr_zu_tun() { + assert_eq!(waehlen(&kopf(r#"{"laeuft":true,"pid":5,"hoert_auf":true}"#)), Hauptknopf::HoertAuf); + assert!(Hauptknopf::HoertAuf.schritte().is_empty(), "ein zweiter Druck braeche das Auslaufen ab"); + assert_eq!(waehlen(&kopf(r#"{"laeuft":true,"pid":5,"hoert_auf":false}"#)), Hauptknopf::Aufhoeren); + assert_eq!(waehlen(&kopf(r#"{"not_aus":true,"laeuft":true,"pid":5,"hoert_auf":true}"#)), Hauptknopf::NotAusLoesen); + assert!(!kopf(r#"{"laeuft":true}"#).unwrap().hoert_auf, "ohne Feld: hoert nicht auf"); +} + +#[test] +fn beim_zuschauen_startet_der_knopf_nie_einen_laeufer() { + let k = kopf(r#"{"laeuft":false,"tische_offen":1,"modus":"Übung"}"#); + assert_eq!(zuschauend(&k, true), Hauptknopf::ZuschauenBeenden); + assert_eq!(Hauptknopf::ZuschauenBeenden.schritte(), ["zuschauer_stoppen"]); + assert_eq!(zuschauend(&k, false), Hauptknopf::ZuschauenBeenden); + assert_eq!(waehlen(&k), Hauptknopf::Starten { cash: false }); +} + +#[test] +fn not_aus_und_laufender_laeufer_gehen_auch_beim_zuschauen_vor() { + assert_eq!(zuschauend(&kopf(r#"{"not_aus":true,"modus":"Übung"}"#), true), Hauptknopf::NotAusLoesen); + assert_eq!(zuschauend(&kopf(r#"{"laeuft":true,"pid":5,"modus":"Übung"}"#), true), Hauptknopf::Aufhoeren); +} + +#[test] +fn uebung_der_knopf_setzt_den_plan_und_startet_ihn() { + let wahl = Spielplan::neu(Modus::Uebung, 2, None); + assert_eq!(mit_plan(&kopf(r#"{"laeuft":false,"tische_offen":0}"#), &wahl), Hauptknopf::Starten { cash: false }); + assert_eq!(mit_plan(&kopf(r#"{"laeuft":false,"tische_offen":3}"#), &wahl), Hauptknopf::Starten { cash: false }); + assert_eq!(Hauptknopf::Starten { cash: false }.schritte(), ["spielplan_setzen", "laeufer_starten"]); +} + +#[test] +fn cash_braucht_ein_guthaben_oder_ein_budget() { + let ohne = Spielplan::neu(Modus::Echt, 2, None); + let mit = Spielplan::neu(Modus::Echt, 2, Some(250.0)); + assert_eq!(mit_plan(&kopf(r#"{"laeuft":false}"#), &ohne), Hauptknopf::BudgetFehlt); + assert_eq!(mit_plan(&kopf(r#"{"laeuft":false}"#), &mit), Hauptknopf::Starten { cash: true }); + assert_eq!(mit_plan(&kopf(r#"{"laeuft":false,"guthaben":8140}"#), &ohne), Hauptknopf::Starten { cash: true }); + assert!(Hauptknopf::BudgetFehlt.schritte().is_empty()); +} + +#[test] +fn schritte_der_uebrigen_faelle() { + assert_eq!(Hauptknopf::Aufhoeren.schritte(), ["laeufer_stoppen"]); + assert_eq!(Hauptknopf::NotAusLoesen.schritte(), ["not_aus_loeschen"]); + assert!(Hauptknopf::Unbekannt.schritte().is_empty()); +} + +// ---- Hauptknopf ohne Freigabe zum Fensterlesen: kein blinder Laeufer ---- + +#[test] +fn ohne_freigabe_startet_der_knopf_nichts() { + let ueben = kopf(r#"{"laeuft":false,"tische_offen":0,"modus":"Übung"}"#); + let spielen = kopf(r#"{"laeuft":false,"tische_offen":1,"modus":"Übung"}"#); + let echt = kopf(r#"{"laeuft":false,"tische_offen":0,"modus":"cash"}"#); + for k in [&ueben, &spielen, &echt] { + assert_eq!(ohne_freigabe(k), Hauptknopf::FreigabeFehlt); + } + assert!(Hauptknopf::FreigabeFehlt.schritte().is_empty()); +} + +#[test] +fn aufhoeren_und_not_aus_loesen_gehen_immer() { + assert_eq!(ohne_freigabe(&kopf(r#"{"laeuft":true,"modus":"Übung"}"#)), Hauptknopf::Aufhoeren); + assert_eq!(ohne_freigabe(&kopf(r#"{"not_aus":true}"#)), Hauptknopf::NotAusLoesen); +} + +#[test] +fn mit_freigabe_wie_bisher() { + let k = kopf(r#"{"laeuft":false,"tische_offen":1,"modus":"cash"}"#); + assert_eq!(waehlen(&k), Hauptknopf::Starten { cash: false }); +} + +// ---- Hauptknopf bei geschlossenem Client ---- + +#[test] +fn coinpoker_zu_der_knopf_startet_den_client() { + let k = kopf(r#"{"laeuft":false,"tische_offen":0,"modus":"Übung","client":false}"#); + assert_eq!(waehlen(&k), Hauptknopf::ClientStarten); + assert_eq!(Hauptknopf::ClientStarten.schritte(), ["client_starten"]); +} + +#[test] +fn ohne_freigabe_zuerst_die_freigabe_auch_wenn_der_client_zu_ist() { + assert_eq!(ohne_freigabe(&kopf(r#"{"laeuft":false,"client":false}"#)), Hauptknopf::FreigabeFehlt); +} + +#[test] +fn aufhoeren_und_not_aus_gehen_auch_bei_geschlossenem_client() { + assert_eq!(waehlen(&kopf(r#"{"laeuft":true,"client":false}"#)), Hauptknopf::Aufhoeren); + assert_eq!(waehlen(&kopf(r#"{"not_aus":true,"client":false}"#)), Hauptknopf::NotAusLoesen); +} + +#[test] +fn client_offen_oder_unbekannt_wie_bisher() { + let start = Hauptknopf::Starten { cash: false }; + assert_eq!(waehlen(&kopf(r#"{"laeuft":false,"tische_offen":0,"modus":"Übung","client":true}"#)), start); + assert_eq!(waehlen(&kopf(r#"{"laeuft":false,"tische_offen":0,"modus":"Übung"}"#)), start); +} + +// ---- CoinPoker ohne Debug-Port: die Lobby-Steuerung scheitert still ---- + +#[test] +fn ohne_port_und_ohne_offene_tische_neu_starten() { + let k = kopf(r#"{"laeuft":false,"client":true,"client_port":false,"tische_offen":0}"#); + assert_eq!(waehlen(&k), Hauptknopf::ClientNeuStarten); + assert_eq!(Hauptknopf::ClientNeuStarten.schritte(), ["client_neu_starten"]); +} + +#[test] +fn ohne_port_aber_tische_offen_nichts_neu_starten() { + let k = kopf(r#"{"laeuft":false,"client":true,"client_port":false,"tische_offen":2}"#); + assert_eq!(waehlen(&k), Hauptknopf::PortFehlt); + assert!(Hauptknopf::PortFehlt.schritte().is_empty()); +} + +#[test] +fn mit_port_oder_unbekannt_wie_bisher_aufhoeren_geht_vor() { + let start = Hauptknopf::Starten { cash: false }; + assert_eq!(waehlen(&kopf(r#"{"laeuft":false,"client":true,"client_port":true}"#)), start); + assert_eq!(waehlen(&kopf(r#"{"laeuft":false,"client":true}"#)), start); + assert_eq!(waehlen(&kopf(r#"{"laeuft":true,"client":true,"client_port":false}"#)), Hauptknopf::Aufhoeren); +} + +// ---- Cockpit schon belegt - die Zeile von sicht/start.py ---- + +#[test] +fn belegt_zeile() { + let b = |pid, art: Option<&str>, port| Belegt { pid, art: art.map(String::from), port }; + assert_eq!(Belegt::aus_startzeile("Cockpit belegt: pid=20745 art=Terminal port=8787"), Some(b(20745, Some("Terminal"), Some(8787)))); + assert_eq!(Belegt::aus_startzeile("Cockpit belegt: pid=99 art=? port=?"), Some(b(99, None, None))); + assert_eq!(Belegt::aus_startzeile("Cockpit: http://127.0.0.1:8787 (echt)"), None); + assert_eq!(Belegt::aus_startzeile("Cockpit belegt: pid=x art=App port=1"), None); +} + +#[test] +fn belegt_lesbar_wer_und_wo() { + let b = |pid, art: Option<&str>, port| Belegt { pid, art: art.map(String::from), port }; + assert_eq!(b(20745, Some("Terminal"), Some(8787)).text(), "Ein Cockpit läuft schon im Terminal (PID 20745, Port 8787)."); + assert_eq!(b(7, Some("App"), None).text(), "Ein Cockpit läuft schon als App (PID 7)."); + assert_eq!(b(7, None, None).text(), "Ein Cockpit läuft schon (PID 7)."); +} + +#[test] +fn verwaister_app_server_nur_der_wird_uebernommen() { + let b = |art: Option<&str>| Belegt { pid: 9, art: art.map(String::from), port: Some(1) }; + assert!(b(Some("App")).verwaist(Some(1))); + assert!(!b(Some("App")).verwaist(Some(4711))); + assert!(!b(Some("Terminal")).verwaist(Some(1))); + assert!(!b(None).verwaist(Some(1))); + assert!(!b(Some("App")).verwaist(None)); +} + +// ---- Checkliste, wenn nichts laeuft ---- + +#[test] +fn checkliste_reihenfolge_und_haken() { + let k = kopf(r#"{"laeuft":false,"tische_offen":0,"client":false,"not_aus":false}"#); + let p = checkliste(k.as_ref(), true); + let titel: Vec<_> = p.iter().map(|x| x.titel).collect(); + assert_eq!(titel, ["Freigaben erteilt", "CoinPoker läuft", "Not-Aus gelöst", "Tisch offen", "Läufer spielt"]); + let haken: Vec<_> = p.iter().map(|x| x.erledigt).collect(); + assert_eq!(haken, [true, false, true, false, false]); +} + +#[test] +fn checkliste_der_naechste_offene_punkt_ist_der_erste_ohne_haken() { + let k = kopf(r#"{"laeuft":false,"tische_offen":1,"client":true,"not_aus":true}"#); + let erster = checkliste(k.as_ref(), true).into_iter().find(|p| !p.erledigt).map(|p| p.titel); + assert_eq!(erster, Some("Not-Aus gelöst")); +} + +#[test] +fn checkliste_client_unbekannt_zaehlt_nicht_als_zu() { + let k = kopf(r#"{"laeuft":false}"#); + assert!(checkliste(k.as_ref(), false)[1].erledigt); +} diff --git a/cockpit/tests/hilfen/mod.rs b/cockpit/tests/hilfen/mod.rs new file mode 100644 index 00000000..769e268c --- /dev/null +++ b/cockpit/tests/hilfen/mod.rs @@ -0,0 +1,39 @@ +//! Gemeinsame Hilfen der Pruefungen (wie mac/Tests/Pruefung/Hilfen.swift). +#![allow(dead_code)] + +use cockpit::ansicht::Ansicht; +use cockpit::modelle::Kopf; +use cockpit::modus::TischModus; +use cockpit::spielplan::Spielplan; +use serde_json::Value; + +/// Die echte Ansicht. Eine Kopie von mac/Tests/Pruefung/Fixtures/ansicht.json; die Pruefung +/// `fixture_gleicht_der_swift_kopie` haelt beide synchron (Byte-Vergleich, wo der mac/-Baum liegt). +pub const FIXTURE_PFAD: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/ansicht.json"); +pub const FIXTURE_SWIFT: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../mac/Tests/Pruefung/Fixtures/ansicht.json"); + +pub fn fixture() -> String { + std::fs::read_to_string(FIXTURE_PFAD).expect("Fixture tests/fixtures/ansicht.json") +} + +/// Ein Kopf aus dem JSON-Text, so angewendet wie in der App. +pub fn kopf(json: &str) -> Option { + let mut a = Ansicht::default(); + a.anwenden(&format!(r#"{{"typ":"ansicht","teile":{{"kopf":{json}}}}}"#)); + a.kopf +} + +/// Eine Ansicht aus den Teilen (`json` ist das Objekt hinter "teile"). +pub fn ansicht(json: &str) -> Ansicht { + let mut a = Ansicht::default(); + a.anwenden(&format!(r#"{{"typ":"ansicht","teile":{json}}}"#)); + a +} + +pub fn modus(json: &str) -> Option { + serde_json::from_str::(json).ok().as_ref().and_then(TischModus::aus) +} + +pub fn spielplan(json: &str) -> Option { + serde_json::from_str::(json).ok().as_ref().and_then(Spielplan::aus) +} diff --git a/cockpit/tests/nachsichtig_spec.rs b/cockpit/tests/nachsichtig_spec.rs new file mode 100644 index 00000000..ca539d12 --- /dev/null +++ b/cockpit/tests/nachsichtig_spec.rs @@ -0,0 +1,85 @@ +//! Die nachsichtige Dekodierung und die Zahlformate (Nachsichtig.swift, Darstellung.swift `Format`). + +use cockpit::format::{auto, prozent, roh, vorzeichen, zahl}; +use cockpit::modelle::{Konto, Ton}; +use cockpit::nachsichtig::Feld; +use serde_json::{json, Value}; + +fn f(v: &Value) -> Feld<'_> { + Feld::aus(v).unwrap() +} + +#[test] +fn text_nimmt_text_zahl_und_bool() { + let v = json!({"s":"x","i":3,"d":0.1,"b":true,"n":null,"l":[1],"o":{}}); + let f = f(&v); + assert_eq!(f.text("s").as_deref(), Some("x")); + assert_eq!(f.text("i").as_deref(), Some("3")); + assert_eq!(f.text("d").as_deref(), Some("0.1")); + assert_eq!(f.text("b").as_deref(), Some("ja")); + assert_eq!(f.text("n"), None); + assert_eq!(f.text("l"), None); + assert_eq!(f.text("o"), None); + assert_eq!(f.text("fehlt"), None); +} + +#[test] +fn zahl_liest_zahlen_und_zahlentexte_aber_keine_blinds() { + let v = json!({"i":3,"d":2.5,"t":"7","blinds":"0.05/0.1","b":true}); + let f = f(&v); + assert_eq!(f.zahl("i"), Some(3.0)); + assert_eq!(f.zahl("d"), Some(2.5)); + assert_eq!(f.zahl("t"), Some(7.0)); + assert_eq!(f.zahl("blinds"), None); + assert_eq!(f.zahl("b"), None); +} + +#[test] +fn wahr_nimmt_nur_echte_bools() { + let v = json!({"a":true,"b":1,"c":"true","d":false}); + let f = f(&v); + assert!(f.wahr("a")); + assert!(!f.wahr("b") && !f.wahr("c") && !f.wahr("d") && !f.wahr("fehlt")); + assert_eq!(f.wahr_oder_nil("b"), None); + assert_eq!(f.wahr_oder_nil("d"), Some(false)); +} + +#[test] +fn listen_lassen_unlesbare_eintraege_weg() { + let v = json!({"l":["a",1,null,{"x":1},true]}); + assert_eq!(f(&v).liste("l"), ["a", "1", "ja"]); +} + +#[test] +fn ton_unbekannt_ist_grau() { + assert_eq!(Ton::aus_farbe(Some("blau")), Ton::Blau); + assert_eq!(Ton::aus_farbe(Some("lila")), Ton::Grau); + assert_eq!(Ton::aus_farbe(None), Ton::Grau); +} + +#[test] +fn konto_alarme_nur_was_gefaehrlich_ist() { + let v = json!({"felder":["Verdacht: ja (3)","Verdacht: nein","Gesperrt: ja","Ruhezeit 3 Uhr (JETZT)","Rake: 4 %"],"schwarze_stunden":[3,"4","x"]}); + let k = Konto::aus(&v).unwrap(); + assert_eq!(k.alarme(), ["Verdacht: ja (3)", "Gesperrt: ja", "Ruhezeit 3 Uhr (JETZT)"]); + assert_eq!(k.schwarze_stunden, [3, 4]); +} + +#[test] +fn zahlformat_deutsch_mit_strich_fuer_unbekannt() { + assert_eq!(zahl(None, 2), "–"); + assert_eq!(zahl(Some(f64::NAN), 2), "–"); + assert_eq!(zahl(Some(1234.5), 2), "1.234,5"); + assert_eq!(zahl(Some(1234567.891), 0), "1.234.568"); + assert_eq!(zahl(Some(-0.004), 2), "0"); + assert_eq!(zahl(Some(-3.0), 2), "-3"); + assert_eq!(auto(Some(250.0)), "250"); + assert_eq!(auto(Some(12.34)), "12,3"); + assert_eq!(auto(Some(1.234)), "1,23"); + assert_eq!(prozent(Some(0.256)), "26 %"); + assert_eq!(vorzeichen(Some(1.5), 2), "+1,5"); + assert_eq!(vorzeichen(Some(-1.5), 2), "−1,5"); + assert_eq!(vorzeichen(Some(0.0), 2), "0"); + assert_eq!(roh(2500.0), "2500"); + assert_eq!(roh(0.1), "0.1"); +} diff --git a/cockpit/tests/regeln_spec.rs b/cockpit/tests/regeln_spec.rs new file mode 100644 index 00000000..3e58c63d --- /dev/null +++ b/cockpit/tests/regeln_spec.rs @@ -0,0 +1,391 @@ +//! Port von SpielplanSpec (in HauptknopfSpec.swift), FormateSpec, ModusSpec und VerlaufSpec. +//! +//! Abweichungen vom Swift-Wortlaut, weil dessen Spezifikationen hinter dem Swift-Kern zurueckliegen: +//! * `SpielFormat.allCases` enthaelt `cash_plo` (Format.swift) - die Swift-Pruefung `namen` nennt es nicht. +//! * `Spielplan.daten` schickt `tischform` immer mit (Spielplan.swift) - `datenText` der Swift-Pruefung nicht. +//! Hier gilt der Kern (Quelle), nicht die Pruefung. + +mod hilfen; + +use cockpit::formate::SpielFormat::{self, *}; +use cockpit::modelle::EntscheidungsZeile; +use cockpit::modus::{Geldlage, Spur, TischModus}; +use cockpit::spielplan::{Modus, Spielplan}; +use cockpit::verlauf::{bloecke, SITZUNGSPAUSE_S}; +use hilfen::{kopf, modus, spielplan}; +use serde_json::json; +use std::collections::BTreeMap; + +fn plan(m: Modus, tische: i64, budget: Option) -> Spielplan { + Spielplan::neu(m, tische, budget) +} + +fn karte(p: &[(SpielFormat, i64)]) -> BTreeMap { + p.iter().copied().collect() +} + +// ---- Spielplan ---- + +#[test] +fn spielplan_als_daten_fuer_spielplan_setzen() { + assert_eq!(plan(Modus::Echt, 3, Some(250.0)).daten_text(), r#"{"budget":250,"modus":"cash","tische":3,"tischform":"multiway"}"#); + // Budget nur im Cash-Modus + assert_eq!(plan(Modus::Uebung, 1, Some(99.0)).daten_text(), r#"{"modus":"uebung","tische":1,"tischform":"multiway"}"#); +} + +#[test] +fn spielplan_aus_dem_kopf_gelesen() { + let k = kopf(r#"{"spielplan":{"modus":"cash","tische":3,"budget":250.0}}"#).unwrap(); + assert_eq!(k.spielplan, Some(plan(Modus::Echt, 3, Some(250.0)))); + assert!(kopf(r#"{"spielplan":null}"#).unwrap().spielplan.is_none()); + assert!(kopf(r#"{"spielplan":{"modus":"turnier","tische":3}}"#).unwrap().spielplan.is_none()); + // ein alter Plan mit dem fruheren Maus-Schalter wird weiter gelesen + let alt = kopf(r#"{"spielplan":{"modus":"uebung","tische":1,"maus":false}}"#).unwrap().spielplan; + assert_eq!(alt, Some(plan(Modus::Uebung, 1, None))); +} + +#[test] +fn spielplan_tischzahl_bleibt_in_grenzen() { + assert_eq!(plan(Modus::Uebung, 0, None).tische(), 1); + assert_eq!(plan(Modus::Uebung, 40, None).tische(), Spielplan::HOECHSTENS); +} + +// ---- Formate im Spielplan ---- + +#[test] +fn formate_ein_neuer_plan_ist_cash() { + let p = plan(Modus::Uebung, 3, None); + assert_eq!(p.formate(), &karte(&[(Cash, 3)])); + assert_eq!(p.tische(), 3); +} + +#[test] +fn formate_je_format_setzen_summe_ist_die_tischzahl() { + let mut p = plan(Modus::Echt, 2, Some(100.0)); + p.setzen(Aof, 1); + p.setzen(Bombpot, 2); + assert_eq!(p.formate(), &karte(&[(Cash, 2), (Aof, 1), (Bombpot, 2)])); + assert_eq!(p.tische(), 5); + p.setzen(Cash, 0); + assert_eq!(p.formate(), &karte(&[(Aof, 1), (Bombpot, 2)])); + assert_eq!(p.anzahl(Cash), 0); +} + +#[test] +fn formate_die_summe_bleibt_unter_hoechstens() { + let mut p = plan(Modus::Uebung, 10, None); + p.setzen(Aof, 9); + assert_eq!(p.anzahl(Aof), Spielplan::HOECHSTENS - 10); + assert_eq!(p.tische(), Spielplan::HOECHSTENS); + p.setzen(Aof, -3); + assert_eq!(p.anzahl(Aof), 0); +} + +#[test] +fn formate_an_den_laeufer() { + let mut p = plan(Modus::Uebung, 1, None); + p.setzen(Aof, 2); + let d = p.daten(); + assert_eq!(d["formate"], json!({"cash": 1, "aof": 2})); + assert_eq!(d["tische"], json!(3)); + p.setzen(Cash, 0); + p.setzen(Aof, 0); + let d = p.daten(); + assert_eq!(d["formate"], json!({})); + assert_eq!(d["tische"], json!(1)); + assert!(plan(Modus::Uebung, 2, None).daten().get("formate").is_none(), "nur Cash: Vorgabe"); +} + +#[test] +fn formate_vom_server_und_welche_gemessen_sind() { + let p = spielplan( + r#"{"modus":"cash","tische":3,"formate":{"cash":2,"aof":1,"erfunden":4}, + "formate_liste":[{"format":"cash","name":"Cash","gemessen":true},{"format":"aof","name":"All-In or Fold","gemessen":false}]}"#, + ) + .unwrap(); + assert_eq!(p.formate(), &karte(&[(Cash, 2), (Aof, 1)])); + assert_eq!(p.gemessen.iter().copied().collect::>(), [Cash]); +} + +#[test] +fn formate_ein_alter_plan_ohne_formate_ist_cash() { + assert_eq!(spielplan(r#"{"modus":"uebung","tische":2}"#).unwrap().formate(), &karte(&[(Cash, 2)])); +} + +#[test] +fn formate_tischziel_die_zahlen_sind_obergrenzen() { + let mut p = plan(Modus::Echt, 2, Some(100.0)); + p.ausweichen(true); + assert_eq!(p.ziel(), Some(2)); + p.set_ziel(Some(10)); + assert_eq!(p.tische(), 2, "mehr als die Grenzen hergeben geht nicht"); + p.setzen(Kpoker, 8); + p.setzen(Aof, 8); + assert_eq!(p.anzahl(Aof), 8, "die Summe darf ueber dem Ziel liegen"); + assert_eq!(p.tische(), 10); + p.setzen(Cash, 99); + assert_eq!(p.anzahl(Cash), Spielplan::HOECHSTENS); + p.set_ziel(Some(99)); + assert_eq!(p.ziel(), Some(Spielplan::HOECHSTENS)); +} + +#[test] +fn formate_ausweichen_aus_die_summe_ist_wieder_die_tischzahl() { + let mut p = plan(Modus::Echt, 8, Some(100.0)); + p.ausweichen(true); + p.setzen(Aof, 8); + p.ausweichen(false); + assert_eq!(p.ziel(), None); + assert_eq!(p.anzahl(Cash), 8); + assert_eq!(p.anzahl(Aof), Spielplan::HOECHSTENS - 8); + assert_eq!(p.tische(), Spielplan::HOECHSTENS); +} + +#[test] +fn formate_fuellfolge_vorziehen_aendert_sie_die_vorgabe_bleibt_weg() { + let mut p = plan(Modus::Echt, 1, Some(100.0)); + p.ausweichen(true); + p.setzen(Aof, 1); + p.setzen(Kpoker, 1); + assert_eq!(p.folge(), [Cash, Aof, Kpoker]); + assert!(p.daten().get("reihenfolge").is_none()); + p.vorziehen(Kpoker); + assert_eq!(p.folge(), [Cash, Kpoker, Aof]); + p.vorziehen(Kpoker); + p.vorziehen(Kpoker); + assert_eq!(p.folge(), [Kpoker, Cash, Aof]); + assert_eq!(p.daten()["reihenfolge"], json!(["kpoker", "cash", "aof"])); + p.setzen(Cash, 0); + assert_eq!(p.folge(), [Kpoker, Aof]); + p.vorziehen(Aof); + p.vorziehen(Kpoker); + assert_eq!(p.folge(), [Kpoker, Aof]); + assert_eq!(p.daten()["reihenfolge"], json!(["kpoker", "aof"])); +} + +#[test] +fn formate_ziel_und_fuellfolge_vom_server_und_zurueck() { + let p = spielplan( + r#"{"modus":"cash","tische":10,"ziel":10,"formate":{"kpoker":8,"aof":8,"cash":8},"reihenfolge":["kpoker","aof","cash"]}"#, + ) + .unwrap(); + assert_eq!(p.ziel(), Some(10)); + assert_eq!(p.tische(), 10); + assert_eq!(p.anzahl(Kpoker), 8); + assert_eq!(p.folge(), [Kpoker, Aof, Cash]); + assert_eq!(p.daten()["ziel"], json!(10)); + assert_eq!(p.daten()["tische"], json!(10)); + assert!(plan(Modus::Uebung, 2, None).daten().get("ziel").is_none()); +} + +#[test] +fn formate_namen_und_reihenfolge_wie_lesen_formate_py() { + let roh: Vec<&str> = SpielFormat::ALLE.iter().map(|f| f.roh()).collect(); + assert_eq!(roh, ["cash", "cash_plo", "aof", "bombpot", "turnier", "kpoker", "vip", "freeroll"]); + assert_eq!(Aof.name(), "All-In or Fold"); +} + +// ---- Vergleich je Format ---- + +#[test] +fn format_vergleich_je_format_mit_spanne_urteil_mit_grund() { + let a = hilfen::ansicht( + r#"{"wachstum":{"je_format":[{"format":"aof","name":"All-In or Fold","haende":40,"netto_bb":420,"bb100":1050.0,"unten":900.0,"oben":1200.0}, + {"format":"cash","name":"Cash","haende":40,"netto_bb":-80,"bb100":-200.0,"unten":-260.0,"oben":-140.0}], + "bestes_format":{"format":"aof","grund":"aof liegt mit 95 % Sicherheit vorn"}}}"#, + ); + let k = a.wachstum.unwrap().eigene; + assert_eq!(k.je_format.iter().map(|z| z.format.as_str()).collect::>(), ["aof", "cash"]); + assert_eq!(k.je_format[0].unten, Some(900.0)); + let u = k.bestes_format.unwrap(); + assert_eq!(u.format.as_deref(), Some("aof")); + assert!(u.grund.contains("95")); +} + +#[test] +fn format_ohne_urteil_format_nil_grund_bleibt() { + let a = hilfen::ansicht(r#"{"wachstum":{"je_format":[],"bestes_format":{"format":null,"grund":"zu wenig Hände für ein Urteil"}}}"#); + let u = a.wachstum.unwrap().eigene.bestes_format.unwrap(); + assert_eq!(u.format, None); + assert_eq!(u.grund, "zu wenig Hände für ein Urteil"); +} + +// ---- Modus ---- + +#[test] +fn modus_turnier_auf_der_bubble() { + let m = modus(r#"{"art":"Turnier","level":19,"bb":2500.0,"ante":312,"feld":15,"bezahlt":14,"bis_geld":1,"bubble":true,"im_geld":false,"text":"Turnier · Level 19"}"#); + let Some(TischModus::Turnier(t)) = m else { panic!("kein Turnier: {m:?}") }; + assert_eq!(t.level, Some(19)); + assert_eq!(t.bb, Some(2500.0)); + assert_eq!(t.ante, Some(312.0)); + assert_eq!((t.feld, t.bezahlt), (15, 14)); + assert_eq!(t.lage(), Geldlage::Bubble); + assert_eq!(t.lage().text(), "Bubble"); +} + +fn turnier(json: &str) -> cockpit::modus::Turnier { + match modus(json) { + Some(TischModus::Turnier(t)) => t, + andere => panic!("kein Turnier: {andere:?}"), + } +} + +#[test] +fn modus_vor_dem_geld_und_im_geld() { + let vor = turnier(r#"{"art":"Turnier","level":3,"feld":18,"bezahlt":14}"#); + let drin = turnier(r#"{"art":"Turnier","level":3,"feld":9,"bezahlt":14}"#); + assert_eq!(vor.lage(), Geldlage::VorDemGeld(4)); + assert_eq!(vor.lage().text(), "4 bis zum Geld"); + assert_eq!(drin.lage(), Geldlage::ImGeld); + assert_eq!(drin.lage().text(), "im Geld"); + assert_eq!(vor.spur_text(), "14 von 18 bezahlt"); + assert_eq!(drin.spur_text(), "alle 9 im Geld"); +} + +#[test] +fn modus_spur_zum_geld() { + let t = turnier(r#"{"art":"Turnier","feld":15,"bezahlt":14}"#); + let gross = turnier(r#"{"art":"Turnier","feld":95,"bezahlt":14}"#); + let drin = turnier(r#"{"art":"Turnier","feld":9,"bezahlt":14}"#); + assert_eq!(t.spur(), Some(Spur::Striche { gefuellt: 14, gesamt: 15 })); + assert_eq!(drin.spur(), Some(Spur::Striche { gefuellt: 9, gesamt: 9 })); + assert_eq!(gross.spur(), Some(Spur::Anteil(14.0 / 95.0))); +} + +#[test] +fn modus_kpoker_menue_mit_groessen_und_uhr() { + let m = modus(r#"{"art":"K-Poker","menue":[{"aktion":"FOLD"},{"aktion":"CALL"},{"aktion":"RAISE","groessen":[0.8,2.4]}],"uhr_s":10,"text":"K-Poker"}"#); + let Some(TischModus::KPoker(k)) = m else { panic!("kein K-Poker: {m:?}") }; + assert_eq!(k.menue.iter().map(|p| p.aktion.as_str()).collect::>(), ["FOLD", "CALL", "RAISE"]); + assert_eq!(k.menue.last().unwrap().groessen, [0.8, 2.4]); + assert!(k.menue[0].groessen.is_empty()); + assert_eq!(k.uhr_s, Some(10.0)); +} + +#[test] +fn modus_kpoker_ohne_menue_und_uhr_bleibt_kpoker() { + let Some(TischModus::KPoker(k)) = modus(r#"{"art":"K-Poker","menue":[],"uhr_s":null}"#) else { panic!("kein K-Poker") }; + assert!(k.menue.is_empty()); + assert_eq!(k.uhr_s, None); +} + +#[test] +fn modus_cash_nennt_den_stake_aus_dem_text() { + assert_eq!(modus(r#"{"art":"Cash","text":"Cash · 0.05/0.1"}"#), Some(TischModus::Cash { stake: Some("0.05/0.1".into()) })); + assert_eq!(modus(r#"{"art":"Cash","text":"Cash"}"#), Some(TischModus::Cash { stake: None })); +} + +#[test] +fn modus_unbekannte_art_ist_kein_fehler_sondern_kein_modus() { + assert_eq!(modus(r#"{"art":"Sit&Go"}"#), None); + assert_eq!(modus("{}"), None); +} + +#[test] +fn modus_zahlen_mal_als_text_mal_als_zahl() { + let t = turnier(r#"{"art":"Turnier","level":"7","bb":"300","feld":"x","bezahlt":3}"#); + assert_eq!(t.level, Some(7)); + assert_eq!(t.bb, Some(300.0)); + assert_eq!(t.feld, 0); + assert_eq!(t.spur(), None); +} + +#[test] +fn modus_in_der_kachel_der_laufende_zug_zuerst() { + let teile = r#"{"kopf":{"laeuft":true,"tische":["A","B"]}, + "jetzt":{"raum":"A","karten":["Qh","8c"],"zug":{"offen":true,"bis":1}, + "entscheidung":{"aktion":"FOLD"},"modus":{"art":"Turnier","level":4,"feld":15,"bezahlt":14}}, + "entscheidungen":{"zeilen":[ + {"raum":"B","hand":"h9","aktion":"CALL","modus":{"art":"K-Poker","menue":[{"aktion":"FOLD"}],"uhr_s":10}}, + {"raum":"A","hand":"h1","aktion":"CALL","modus":{"art":"Cash","text":"Cash · 0.05/0.1"}}]}, + "sitzen":{"raeume":[]}}"#; + let a = hilfen::ansicht(teile); + let Some(TischModus::Turnier(t)) = a.jetzt.as_ref().unwrap().modus.clone() else { panic!("jetzt ohne Turnier") }; + assert_eq!(t.lage(), Geldlage::Bubble); + assert_eq!( + a.entscheidungen.as_ref().unwrap().zeilen.last().unwrap().modus, + Some(TischModus::Cash { stake: Some("0.05/0.1".into()) }) + ); + let k = cockpit::kachel::LiveKachel::alle(&a); + let ka = k.iter().find(|x| x.raum == "A").unwrap(); + let kb = k.iter().find(|x| x.raum == "B").unwrap(); + assert!(matches!(ka.modus, Some(TischModus::Turnier(_))), "A: {:?}", ka.modus); + let Some(TischModus::KPoker(kp)) = &kb.modus else { panic!("B ohne K-Poker: {:?}", kb.modus) }; + assert_eq!(kp.uhr_s, Some(10.0)); + let c = hilfen::ansicht(r#"{"kopf":{"laeuft":true,"tische":["C"]},"sitzen":{"raeume":[]}}"#); + assert_eq!(cockpit::kachel::LiveKachel::alle(&c)[0].modus, None); +} + +// ---- Verlauf ---- + +#[allow(clippy::too_many_arguments)] +fn z(zeit: f64, hand: Option<&str>, raum: &str, aktion: &str, text: Option<&str>, bb: Option, strasse: &str, ergebnis: Option) -> EntscheidungsZeile { + EntscheidungsZeile { + zeit: Some(zeit), + raum: Some(raum.into()), + hand: hand.map(String::from), + strasse: Some(strasse.into()), + karten: vec!["AS".into(), "KH".into()], + aktion: Some(aktion.into()), + aktion_text: text.map(String::from), + betrag_bb: bb, + ergebnis_bb: ergebnis, + ..Default::default() + } +} + +fn e(zeit: f64, hand: Option<&str>, aktion: &str) -> EntscheidungsZeile { + z(zeit, hand, "A", aktion, None, None, "PREFLOP", None) +} + +#[test] +fn verlauf_entscheidungen_derselben_hand_werden_eine_zeile() { + let b = bloecke( + &[ + z(103.0, Some("h1"), "A", "FOLD", None, None, "TURN", Some(-3.5)), + z(102.0, Some("h1"), "A", "CHECK", None, None, "FLOP", None), + z(100.0, Some("h1"), "A", "RAISE", Some("Raise auf 2 BB"), Some(2.0), "PREFLOP", None), + ], + 10, + SITZUNGSPAUSE_S, + ); + assert_eq!(b.len(), 1); + let h = &b[0].haende; + assert_eq!(h.len(), 1); + assert_eq!(h[0].schritte.iter().map(|s| s.aktion.as_str()).collect::>(), ["RAISE", "CHECK", "FOLD"]); + assert_eq!(h[0].zeit, Some(103.0)); + assert_eq!(h[0].ergebnis_bb, Some(-3.5)); + assert_eq!(h[0].karten, ["AS", "KH"]); +} + +#[test] +fn verlauf_gleiche_handnummer_an_zwei_tischen_bleibt_getrennt() { + let b = bloecke( + &[z(101.0, Some("h1"), "B", "CALL", None, None, "PREFLOP", None), z(100.0, Some("h1"), "A", "FOLD", None, None, "PREFLOP", None)], + 10, + SITZUNGSPAUSE_S, + ); + assert_eq!(b[0].haende.len(), 2); +} + +#[test] +fn verlauf_eine_pause_ueber_30_minuten_beginnt_einen_neuen_block() { + let b = bloecke(&[e(10_000.0, Some("h3"), "FOLD"), e(5_000.0, Some("h2"), "CALL"), e(4_900.0, Some("h1"), "RAISE")], 10, SITZUNGSPAUSE_S); + assert_eq!(b.iter().map(|x| x.haende.len()).collect::>(), [1, 2]); + assert_eq!(b[0].beginn, Some(10_000.0)); + assert_eq!(b[1].beginn, Some(4_900.0)); +} + +#[test] +fn verlauf_hoechstens_n_haende_ueber_bloecke_hinweg() { + let b = bloecke(&[e(10_000.0, Some("h3"), "FOLD"), e(5_000.0, Some("h2"), "CALL"), e(4_900.0, Some("h1"), "RAISE")], 2, SITZUNGSPAUSE_S); + let haende: Vec<_> = b.iter().flat_map(|x| x.haende.iter().map(|h| h.hand.clone())).collect(); + assert_eq!(haende, [Some("h3".to_string()), Some("h2".to_string())]); +} + +#[test] +fn verlauf_ohne_handnummer_steht_jede_entscheidung_fuer_sich() { + let b = bloecke(&[e(101.0, None, "FOLD"), e(100.0, None, "FOLD")], 10, SITZUNGSPAUSE_S); + assert_eq!(b[0].haende.len(), 2); +} diff --git a/cockpit/ui/bausteine.slint b/cockpit/ui/bausteine.slint new file mode 100644 index 00000000..df1db026 --- /dev/null +++ b/cockpit/ui/bausteine.slint @@ -0,0 +1,517 @@ +// Das Design-System des Cockpits: Farben, Zeichen (aus Slint-Pfaden, keine Dateien), und die +// Grundbausteine. Nichts hier kennt Poker; die Inhalte stehen in cash.slint und fenster.slint. +// Masse und Farben sind aus einem Screenshot der Mac-App abgelesen (Radius 12, Karten #22252b ...). + +export global Farbe { + out property grund: #16181c; + out property karte: #22252b; + out property feld: #2a2e35; // Auswahl, kleine Knoepfe auf Karten + out property knopf: #2f333b; // der Hauptknopf + out property linie: #ffffff14; + out property text: #e8eaed; + out property hell: #c7cbd1; + out property gedaempft: #8a8f98; + out property rot: #e5484d; // Echtgeld, Not-Aus + out property blau: #2d6cdf; // ausgewaehlt + out property blau-hell: #4f8cf0; // Werte, Icon der aktiven Karte + out property teal: #3fb98f; // Schalter, aktiver Reiter, Zuschauer + out property gruen: #57c78a; + out property bernstein: #e3b341; +} + +// ---- Zeichen ------------------------------------------------------------------------------- + +component Strich inherits Path { + in property f: white; + in property d: 2; // Dicke in Einheiten der 24er Zeichenflaeche + viewbox-width: 24; + viewbox-height: 24; + fill: transparent; + stroke: f; + stroke-width: self.width * d / 24; + stroke-line-cap: round; + stroke-line-join: round; +} + +component Flaeche inherits Path { + in property f: white; + viewbox-width: 24; + viewbox-height: 24; + fill: f; +} + +// Ein Zeichen auf 24er Zeichenflaeche. `art` waehlt es; Unbekanntes bleibt leer. +export component Icon inherits Rectangle { + in property art; + in property farbe: Farbe.text; + in property groesse: 18px; + width: groesse; + height: groesse; + + if art == "kreis": Strich { width: parent.width; height: parent.height; f: farbe; commands: "M 12 3 A 9 9 0 1 0 12 21 A 9 9 0 1 0 12 3 Z"; } + if art == "kreis": Flaeche { width: parent.width; height: parent.height; f: farbe; commands: "M 12 8.5 A 3.5 3.5 0 1 0 12 15.5 A 3.5 3.5 0 1 0 12 8.5 Z"; } + if art == "cluster": Flaeche { + width: parent.width; height: parent.height; f: farbe; + commands: "M 9.7 12 A 2.3 2.3 0 1 0 14.3 12 A 2.3 2.3 0 1 0 9.7 12 Z M 16.2 12 A 2.3 2.3 0 1 0 20.8 12 A 2.3 2.3 0 1 0 16.2 12 Z M 3.2 12 A 2.3 2.3 0 1 0 7.8 12 A 2.3 2.3 0 1 0 3.2 12 Z M 12.95 17.6 A 2.3 2.3 0 1 0 17.55 17.6 A 2.3 2.3 0 1 0 12.95 17.6 Z M 6.45 17.6 A 2.3 2.3 0 1 0 11.05 17.6 A 2.3 2.3 0 1 0 6.45 17.6 Z M 6.45 6.4 A 2.3 2.3 0 1 0 11.05 6.4 A 2.3 2.3 0 1 0 6.45 6.4 Z M 12.95 6.4 A 2.3 2.3 0 1 0 17.55 6.4 A 2.3 2.3 0 1 0 12.95 6.4 Z"; + } + if art == "blitz": Flaeche { width: parent.width; height: parent.height; f: farbe; commands: "M 13.5 2 L 5 13.5 H 11 L 10 22 L 19 10 H 13 Z"; } + if art == "flamme": Flaeche { width: parent.width; height: parent.height; f: farbe; commands: "M 12 2 C 13 6 18 8.5 18 14.5 A 6 6 0 0 1 6 14.5 C 6 11.5 7.5 9.5 9 8 C 9 10 10 11 11 11 C 11 8 10 5 12 2 Z"; } + if art == "pokal": Flaeche { width: parent.width; height: parent.height; f: farbe; commands: "M 6 3 H 18 V 9 A 6 6 0 0 1 6 9 Z M 10.5 14.5 H 13.5 V 18 H 17 V 21 H 7 V 18 H 10.5 Z"; } + if art == "pokal": Strich { width: parent.width; height: parent.height; f: farbe; commands: "M 6 5 H 3 V 8 A 3 3 0 0 0 6 11 M 18 5 H 21 V 8 A 3 3 0 0 1 18 11"; } + if art == "tastatur": Strich { width: parent.width; height: parent.height; f: farbe; commands: "M 4 6 H 20 A 2 2 0 0 1 22 8 V 16 A 2 2 0 0 1 20 18 H 4 A 2 2 0 0 1 2 16 V 8 A 2 2 0 0 1 4 6 Z"; } + if art == "tastatur": Flaeche { width: parent.width; height: parent.height; f: farbe; commands: "M 5 9 H 7 V 11 H 5 Z M 9 9 H 11 V 11 H 9 Z M 13 9 H 15 V 11 H 13 Z M 17 9 H 19 V 11 H 17 Z M 7 13.5 H 17 V 15.5 H 7 Z"; } + if art == "zahnrad": Strich { width: parent.width; height: parent.height; f: farbe; commands: "M 12 8.5 A 3.5 3.5 0 1 0 12 15.5 A 3.5 3.5 0 1 0 12 8.5 Z M 12 5 A 7 7 0 1 0 12 19 A 7 7 0 1 0 12 5 Z M 12 2.5 V 5 M 12 19 V 21.5 M 2.5 12 H 5 M 19 12 H 21.5 M 5.3 5.3 L 7.1 7.1 M 16.9 16.9 L 18.7 18.7 M 18.7 5.3 L 16.9 7.1 M 7.1 16.9 L 5.3 18.7"; } + if art == "rechts": Strich { width: parent.width; height: parent.height; f: farbe; commands: "M 9 5 L 16 12 L 9 19"; } + if art == "runter": Strich { width: parent.width; height: parent.height; f: farbe; commands: "M 5 9 L 12 16 L 19 9"; } + if art == "rauf": Strich { width: parent.width; height: parent.height; f: farbe; commands: "M 5 15 L 12 8 L 19 15"; } + if art == "pfeil-hoch": Strich { width: parent.width; height: parent.height; f: farbe; commands: "M 12 19 V 5 M 6 11 L 12 5 L 18 11"; } + if art == "plus": Strich { width: parent.width; height: parent.height; f: farbe; d: 2.4; commands: "M 12 5 V 19 M 5 12 H 19"; } + if art == "minus": Strich { width: parent.width; height: parent.height; f: farbe; d: 2.4; commands: "M 5 12 H 19"; } + if art == "x": Strich { width: parent.width; height: parent.height; f: farbe; commands: "M 6 6 L 18 18 M 18 6 L 6 18"; } + if art == "klein": Strich { width: parent.width; height: parent.height; f: farbe; commands: "M 5 12 H 19"; } + if art == "hand": Flaeche { width: parent.width; height: parent.height; f: farbe; commands: "M 6 11 H 21 V 15 A 6 6 0 0 1 15 21 H 12 A 6 6 0 0 1 6 15 Z"; } + if art == "hand": Strich { width: parent.width; height: parent.height; f: farbe; d: 3.4; commands: "M 8 11 V 5.5 M 12 10 V 3.5 M 16 10.5 V 5 M 20 12 V 9 M 6 13 L 3.5 10.5"; } + if art == "stop": Flaeche { width: parent.width; height: parent.height; f: farbe; commands: "M 6 4 H 18 A 2 2 0 0 1 20 6 V 18 A 2 2 0 0 1 18 20 H 6 A 2 2 0 0 1 4 18 V 6 A 2 2 0 0 1 6 4 Z"; } + if art == "play": Flaeche { width: parent.width; height: parent.height; f: farbe; commands: "M 7 4 L 20 12 L 7 20 Z"; } + if art == "pause": Flaeche { width: parent.width; height: parent.height; f: farbe; commands: "M 6 4 H 10 V 20 H 6 Z M 14 4 H 18 V 20 H 14 Z"; } + if art == "punkte": Flaeche { width: parent.width; height: parent.height; f: farbe; commands: "M 3.2 12 A 1.8 1.8 0 1 0 6.8 12 A 1.8 1.8 0 1 0 3.2 12 Z M 10.2 12 A 1.8 1.8 0 1 0 13.8 12 A 1.8 1.8 0 1 0 10.2 12 Z M 17.2 12 A 1.8 1.8 0 1 0 20.8 12 A 1.8 1.8 0 1 0 17.2 12 Z"; } + if art == "nach-vorn": Strich { width: parent.width; height: parent.height; f: farbe; commands: "M 3 4 H 15 V 14 H 3 Z M 9 9 H 21 V 20 H 9 Z"; } + if art == "anordnen": Strich { width: parent.width; height: parent.height; f: farbe; commands: "M 3 3 H 10.5 V 10.5 H 3 Z M 13.5 3 H 21 V 10.5 H 13.5 Z M 3 13.5 H 10.5 V 21 H 3 Z M 13.5 13.5 H 21 V 21 H 13.5 Z"; } + if art == "foto": Strich { width: parent.width; height: parent.height; f: farbe; commands: "M 3 8 H 7 L 9 5 H 15 L 17 8 H 21 V 19 H 3 Z M 12 10 A 3.5 3.5 0 1 0 12 17 A 3.5 3.5 0 1 0 12 10 Z"; } + if art == "schliessen": Strich { width: parent.width; height: parent.height; f: farbe; commands: "M 3 5 H 21 V 19 H 3 Z M 9.5 9.5 L 14.5 14.5 M 14.5 9.5 L 9.5 14.5"; } + if art == "cash": Flaeche { width: parent.width; height: parent.height; f: farbe; commands: "M 10 12 A 2 2 0 1 0 14 12 A 2 2 0 1 0 10 12 Z"; } + if art == "cash": Strich { width: parent.width; height: parent.height; f: farbe; commands: "M 7.5 8.5 A 5 5 0 0 0 7.5 15.5 M 16.5 8.5 A 5 5 0 0 1 16.5 15.5 M 4.5 5.5 A 9 9 0 0 0 4.5 18.5 M 19.5 5.5 A 9 9 0 0 1 19.5 18.5"; } + if art == "haende": Strich { width: parent.width; height: parent.height; f: farbe; commands: "M 3 4 H 21 V 20 H 3 Z M 8 9 H 18 M 8 12 H 18 M 8 15 H 18"; } + if art == "statistik": Strich { width: parent.width; height: parent.height; f: farbe; commands: "M 3 18 L 9 12 L 13 15 L 21 6 M 16 6 H 21 V 11"; } + if art == "protokoll": Strich { width: parent.width; height: parent.height; f: farbe; commands: "M 4 5 H 20 M 4 10 H 14 M 4 15 H 20 M 4 20 H 11"; } +} + +// ---- Segmentschalter ----------------------------------------------------------------------- +// Die Kapsel "Zuschauer | Übung | Echtgeld": das gewaehlte Segment ist in seiner Farbe gefuellt. + +export component Segmentschalter inherits Rectangle { + in property <[string]> titel; + in property <[color]> farben; + in property aktuell; + in property gesperrt: false; + callback gewaehlt(int); + + height: 40px; + border-radius: self.height / 2; + background: #ffffff12; + opacity: gesperrt ? 0.55 : 1; + + HorizontalLayout { + padding: 3px; + spacing: 0px; + for t[i] in titel: Rectangle { + border-radius: (root.height - 6px) / 2; + background: i == root.aktuell ? root.farben[i] : transparent; + Text { + text: t; + color: i == root.aktuell ? white : Farbe.gedaempft; + font-size: 14px; + font-weight: i == root.aktuell ? 700 : 600; + } + TouchArea { + enabled: !root.gesperrt; + clicked => { root.gewaehlt(i); } + } + } + } +} + +// ---- Statuskarte --------------------------------------------------------------------------- +// Kleine Beschriftung, grosser Wert, kleine Unterzeile; mit `pfeil` ein ">" oben rechts. +// Mit `eingabe` ist der Wert ein Textfeld (das Budget); leer zeigt es `leer-text`. + +export component Statuskarte inherits Rectangle { + in property titel; + in property wert; + in property fuss; + in property wert-groesse: 26px; + in property wert-farbe: Farbe.text; + in property pfeil: false; + in property eingabe: false; + in property leer-text: "alles"; + in-out property feld; + out property tippt: feldtext.has-focus; + callback geklickt(); + callback angenommen(string); + + background: Farbe.karte; + border-radius: 12px; + min-height: 84px; + + VerticalLayout { + padding-left: 12px; + padding-right: 10px; + padding-top: 10px; + padding-bottom: 10px; + spacing: 2px; + Text { + text: root.titel; + color: Farbe.gedaempft; + font-size: 12px; + font-weight: 600; + overflow: elide; + } + Rectangle { + height: 34px; + Text { + visible: !root.eingabe; + x: 0px; + width: parent.width; + vertical-alignment: center; + horizontal-alignment: left; + text: root.wert; + color: root.wert-farbe; + font-size: root.wert-groesse; + font-weight: 700; + overflow: elide; + } + feldtext := TextInput { + visible: root.eingabe; + enabled: root.eingabe; + width: parent.width; + height: parent.height; + vertical-alignment: center; + text <=> root.feld; + color: Farbe.text; + font-size: root.wert-groesse; + font-weight: 700; + single-line: true; + accepted => { root.angenommen(self.text); } + changed has-focus => { if (!self.has-focus) { root.angenommen(self.text); } } + } + Text { + visible: root.eingabe && root.feld == "" && !feldtext.has-focus; + width: parent.width; + vertical-alignment: center; + text: root.leer-text; + color: Farbe.text; + font-size: root.wert-groesse; + font-weight: 700; + opacity: 0.9; + } + } + Text { + text: root.fuss; + color: Farbe.gedaempft; + font-size: 11px; + overflow: elide; + } + } + + if root.pfeil: Icon { + x: parent.width - self.width - 8px; + y: 9px; + art: "rechts"; + farbe: Farbe.gedaempft; + groesse: 14px; + } + // Die Karte als Ganzes ist anklickbar, aber nicht ueber dem Textfeld. + if root.pfeil && !root.eingabe: TouchArea { clicked => { root.geklickt(); } } + if root.pfeil && root.eingabe: TouchArea { + x: parent.width - 34px; + y: 0px; + width: 34px; + height: 34px; + clicked => { root.geklickt(); } + } +} + +// ---- Auswahl (Dropdown) -------------------------------------------------------------------- + +export component Auswahl inherits Rectangle { + in property <[string]> optionen; + in property index; + in property menue-breite: 150px; + callback gewaehlt(int); + + height: 30px; + background: Farbe.feld; + border-radius: 8px; + + HorizontalLayout { + padding-left: 10px; + padding-right: 8px; + spacing: 6px; + Text { + text: root.optionen[root.index]; + color: Farbe.text; + font-size: 13px; + font-weight: 600; + vertical-alignment: center; + overflow: elide; + } + Icon { art: "runter"; farbe: Farbe.gedaempft; groesse: 12px; y: (parent.height - self.height) / 2; } + } + TouchArea { clicked => { menue.show(); } } + + menue := PopupWindow { + x: 0px; + y: root.height + 2px; + width: max(root.width, root.menue-breite); + Rectangle { + background: Farbe.feld; + border-radius: 8px; + border-width: 1px; + border-color: Farbe.linie; + VerticalLayout { + padding: 4px; + for o[i] in root.optionen: Rectangle { + height: 30px; + border-radius: 6px; + background: ta.has-hover ? #ffffff14 : transparent; + Text { + x: 8px; + text: o; + color: i == root.index ? Farbe.blau-hell : Farbe.text; + font-size: 13px; + font-weight: i == root.index ? 700 : 400; + vertical-alignment: center; + } + ta := TouchArea { clicked => { root.gewaehlt(i); menue.close(); } } + } + } + } + } +} + +// ---- Stepper ------------------------------------------------------------------------------- +// "4 Tische" mit einem Paar Auf/Ab daneben. + +export component Stepper inherits Rectangle { + in property text; + in property auf-ok: true; + in property ab-ok: true; + callback auf(); + callback ab(); + + height: 30px; + HorizontalLayout { + spacing: 8px; + alignment: end; + Text { + text: root.text; + color: Farbe.hell; + font-size: 13px; + font-weight: 600; + vertical-alignment: center; + } + Rectangle { + width: 26px; + background: Farbe.feld; + border-radius: 8px; + VerticalLayout { + Rectangle { + opacity: root.auf-ok ? 1 : 0.3; + Icon { art: "rauf"; farbe: Farbe.hell; groesse: 12px; } + TouchArea { enabled: root.auf-ok; clicked => { root.auf(); } } + } + Rectangle { + opacity: root.ab-ok ? 1 : 0.3; + Icon { art: "runter"; farbe: Farbe.hell; groesse: 12px; } + TouchArea { enabled: root.ab-ok; clicked => { root.ab(); } } + } + } + } + } +} + +// ---- Toggle -------------------------------------------------------------------------------- + +export component Toggle inherits Rectangle { + in property an; + callback umgeschaltet(); + + width: 42px; + height: 24px; + border-radius: 12px; + background: an ? Farbe.teal : #3a3e46; + animate background { duration: 120ms; } + + Rectangle { + y: 2px; + x: root.an ? root.width - self.width - 2px : 2px; + width: 20px; + height: 20px; + border-radius: 10px; + background: white; + animate x { duration: 120ms; } + } + TouchArea { clicked => { root.umgeschaltet(); } } +} + +// ---- Formatkarte --------------------------------------------------------------------------- +// Icon, Name, optional eine gedaempfte Zeile; rechts "+" oder bei aktivem Format "- n +". + +export component Formatkarte inherits Rectangle { + in property name; + in property hinweis; + in property symbol; + in property anzahl; + in property voll; + in property rang: -1; // Platz in der Fuellfolge (nur mit Ausweichen) + callback plus(); + callback minus(); + callback vorziehen(); + + property aktiv: anzahl > 0; + + height: 56px; + border-radius: 10px; + background: aktiv ? #2d6cdf24 : Farbe.karte; + border-width: 1.5px; + border-color: aktiv ? Farbe.blau : transparent; + + HorizontalLayout { + padding-left: 10px; + padding-right: 8px; + spacing: 7px; + Icon { + art: root.symbol; + farbe: root.aktiv ? Farbe.blau-hell : Farbe.gedaempft; + groesse: 20px; + y: (parent.height - self.height) / 2; + } + VerticalLayout { + alignment: center; + spacing: 1px; + Text { + text: root.name; + color: Farbe.text; + font-size: 13px; + font-weight: 600; + overflow: elide; + } + if root.hinweis != "": Text { + text: root.hinweis; + color: Farbe.gedaempft; + font-size: 10px; + overflow: elide; + } + } + if root.rang > 0: Rectangle { + width: 20px; + Icon { art: "pfeil-hoch"; farbe: Farbe.gedaempft; groesse: 14px; } + TouchArea { clicked => { root.vorziehen(); } } + } + if root.aktiv: Rectangle { + width: 22px; + Icon { art: "minus"; farbe: Farbe.hell; groesse: 14px; } + TouchArea { clicked => { root.minus(); } } + } + if root.aktiv: Text { + text: root.anzahl; + color: Farbe.text; + font-size: 15px; + font-weight: 700; + vertical-alignment: center; + horizontal-alignment: center; + min-width: 14px; + } + Rectangle { + width: root.aktiv ? 22px : 28px; + opacity: root.voll ? 0.3 : 1; + Rectangle { + width: root.aktiv ? 0px : 28px; + height: root.aktiv ? 0px : 28px; + border-radius: 14px; + background: root.aktiv ? transparent : Farbe.knopf; + } + Icon { art: "plus"; farbe: Farbe.hell; groesse: 14px; } + TouchArea { enabled: !root.voll; clicked => { root.plus(); } } + } + } +} + +// ---- Werkzeugknopf ------------------------------------------------------------------------- + +export component Werkzeugknopf inherits Rectangle { + in property art; + in property titel; + in property aktiv: true; + in property rot: false; + callback geklickt(); + + height: 52px; + border-radius: 9px; + background: ta.has-hover && aktiv ? #ffffff0d : transparent; + opacity: aktiv ? 1 : 0.4; + + VerticalLayout { + alignment: center; + spacing: 4px; + Rectangle { + height: 18px; + Icon { + art: root.art; + farbe: root.rot ? #e5484de6 : Farbe.hell; + groesse: 18px; + x: (parent.width - self.width) / 2; + } + } + Text { + text: root.titel; + color: root.rot ? #e5484de6 : Farbe.hell; + font-size: 10.5px; + font-weight: 600; + horizontal-alignment: center; + overflow: elide; + } + } + ta := TouchArea { enabled: root.aktiv; clicked => { root.geklickt(); } } +} + +// ---- Tableiste ----------------------------------------------------------------------------- + +export component Reiter inherits Rectangle { + in property art; + in property titel; + in property gewaehlt; + callback geklickt(); + + VerticalLayout { + alignment: center; + spacing: 3px; + Rectangle { + height: 22px; + Icon { + art: root.art; + farbe: root.gewaehlt ? Farbe.teal : Farbe.gedaempft; + groesse: 22px; + x: (parent.width - self.width) / 2; + } + } + Text { + text: root.titel; + color: root.gewaehlt ? Farbe.teal : Farbe.gedaempft; + font-size: 11px; + font-weight: root.gewaehlt ? 700 : 600; + horizontal-alignment: center; + } + } + TouchArea { clicked => { root.geklickt(); } } +} + +export component Tableiste inherits Rectangle { + in property aktuell; + callback gewaehlt(int); + + height: 62px; + background: #121417; + Rectangle { + y: 0px; + height: 1px; + background: Farbe.linie; + } + HorizontalLayout { + padding-top: 4px; + Reiter { art: "cash"; titel: "Cash"; gewaehlt: root.aktuell == 0; geklickt => { root.gewaehlt(0); } } + Reiter { art: "haende"; titel: "Hände"; gewaehlt: root.aktuell == 1; geklickt => { root.gewaehlt(1); } } + Reiter { art: "statistik"; titel: "Statistik"; gewaehlt: root.aktuell == 2; geklickt => { root.gewaehlt(2); } } + Reiter { art: "protokoll"; titel: "Protokoll"; gewaehlt: root.aktuell == 3; geklickt => { root.gewaehlt(3); } } + } +} diff --git a/cockpit/ui/cash.slint b/cockpit/ui/cash.slint new file mode 100644 index 00000000..57e9de82 --- /dev/null +++ b/cockpit/ui/cash.slint @@ -0,0 +1,355 @@ +// Der Inhalt des Reiters "Cash": Modus, die drei Statuskarten, Tischzahl und -form, "Was spielen", +// Status, Hauptknopf mit Not-Aus und die Werkzeugleiste (Wurzel.swift `Kopfzeile`, ab ModusSchalter). +// Alles Gezeigte steht in `CashZustand`; was geschieht, geht ueber die Rueckrufe an Rust (bruecke.rs). + +import { Farbe, Icon, Segmentschalter, Statuskarte, Auswahl, Stepper, Toggle, Formatkarte, Werkzeugknopf } from "bausteine.slint"; + +export struct KartenZeile { + id: string, + name: string, + hinweis: string, + symbol: string, + anzahl: int, + voll: bool, + rang: int, +} + +export struct CashZustand { + modus: int, // 0 Zuschauer, 1 Uebung, 2 Echtgeld + modus-gesperrt: bool, + cash-frage: bool, + cash: bool, + tische-wert: string, + tische-fuss: string, + geld-titel: string, + geld-wert: string, + geld-fuss: string, + plan-titel: string, + plan-fuss: string, + plan-unendlich: bool, + sitzung-art: int, // 0 "immer N", 1 "ausgelost" + sitzung-immer: string, + stepper-text: string, + stepper-auf-ok: bool, + stepper-ab-ok: bool, + form: int, // 0 Multiway, 1 Heads-Up, 2 Beide + micro-only: bool, + zusammen: string, + ausweichen: bool, + ziel-text: string, + status-satz: string, + status-ton: color, + knopf-titel: string, + knopf-symbol: string, + knopf-farbe: color, + knopf-aktiv: bool, + beschaeftigt: bool, + not-aus: bool, + werkzeuge-aktiv: bool, + meldung: string, + meldung-ok: bool, +} + +export component CashInhalt inherits VerticalLayout { + in property lage; + in property <[KartenZeile]> karten; + in-out property budget-feld; + in-out property budget-tippt; + + callback modus-gewaehlt(int); + callback cash-bestaetigt(); + callback cash-abgebrochen(); + callback budget-gesetzt(string); + callback geld-oeffnen(); + callback plan-oeffnen(); + callback sitzung-art-gewaehlt(int); + callback stepper-auf(); + callback stepper-ab(); + callback form-gewaehlt(int); + callback micro-umschalten(); + callback ausweichen-umschalten(); + callback ziel-auf(); + callback ziel-ab(); + callback karte-plus(string); + callback karte-minus(string); + callback karte-vor(string); + callback knopf-gedrueckt(); + callback not-aus(); + callback werkzeug(string); + + property spalte: (self.width - 28px - 8px) / 2; + + padding-left: 14px; + padding-right: 14px; + padding-top: 8px; + padding-bottom: 18px; + spacing: 12px; + + // 2) Modus-Leiste + Segmentschalter { + titel: ["Zuschauer", "Übung", "Echtgeld"]; + farben: [Farbe.teal, Farbe.blau, Farbe.rot]; + aktuell: root.lage.modus; + gesperrt: root.lage.modus-gesperrt; + gewaehlt(i) => { root.modus-gewaehlt(i); } + } + + // Rueckfrage, bevor Echtgeld einschaltet (ModusLeiste.swift `LiveFrage`) + if root.lage.cash-frage: Rectangle { + background: #e5484d1f; + border-radius: 12px; + VerticalLayout { + padding: 12px; + spacing: 8px; + HorizontalLayout { + spacing: 6px; + alignment: start; + Text { text: "⚠"; color: Farbe.rot; font-size: 14px; font-weight: 700; vertical-alignment: center; } + Text { text: "Echtgeld heißt echtes Geld"; color: Farbe.rot; font-size: 14px; font-weight: 700; vertical-alignment: center; } + } + Text { + text: "Der Läufer öffnet selbst Tische und setzt Geld."; + color: Farbe.gedaempft; + font-size: 12px; + wrap: word-wrap; + } + HorizontalLayout { + spacing: 8px; + Rectangle { + height: 32px; + border-radius: 8px; + background: Farbe.feld; + Text { text: "Abbrechen"; color: Farbe.text; font-size: 13px; font-weight: 600; } + TouchArea { clicked => { root.cash-abgebrochen(); } } + } + Rectangle { + height: 32px; + border-radius: 8px; + background: Farbe.rot; + Text { text: "Echtgeld einschalten"; color: white; font-size: 13px; font-weight: 700; } + TouchArea { clicked => { root.cash-bestaetigt(); } } + } + } + } + } + + if !(root.lage.modus == 0): VerticalLayout { + spacing: 12px; + + // 3) die drei Statuskarten + HorizontalLayout { + spacing: 8px; + Statuskarte { + titel: "Tische"; + wert: root.lage.tische-wert; + fuss: root.lage.tische-fuss; + wert-groesse: root.lage.tische-wert.character-count > 3 ? 20px : 26px; + } + budget := Statuskarte { + titel: root.lage.geld-titel; + wert: root.lage.geld-wert; + fuss: root.lage.geld-fuss; + pfeil: true; + eingabe: root.lage.cash; + feld <=> root.budget-feld; + wert-groesse: root.lage.cash ? 26px : 20px; + wert-farbe: root.lage.cash ? Farbe.text : Farbe.gedaempft; + geklickt => { root.geld-oeffnen(); } + angenommen(t) => { root.budget-gesetzt(t); } + changed tippt => { root.budget-tippt = self.tippt; } + } + Statuskarte { + titel: "Plan"; + wert: (root.lage.plan-unendlich && root.lage.plan-titel == "Dauerlauf" ? "∞ " : "") + root.lage.plan-titel; + fuss: root.lage.plan-fuss; + wert-groesse: 15px; + pfeil: true; + geklickt => { root.plan-oeffnen(); } + } + } + + // 4) Tische je Sitzung + HorizontalLayout { + spacing: 8px; + height: 30px; + Text { text: "Tische je Sitzung"; color: Farbe.hell; font-size: 13px; font-weight: 600; vertical-alignment: center; } + Auswahl { + width: 112px; + optionen: [root.lage.sitzung-immer, "ausgelost"]; + index: root.lage.sitzung-art; + gewaehlt(i) => { root.sitzung-art-gewaehlt(i); } + } + Rectangle { } + Stepper { + text: root.lage.stepper-text; + auf-ok: root.lage.stepper-auf-ok; + ab-ok: root.lage.stepper-ab-ok; + auf => { root.stepper-auf(); } + ab => { root.stepper-ab(); } + } + } + + // 5) Tischform + HorizontalLayout { + spacing: 8px; + height: 30px; + Text { text: "Tischform"; color: Farbe.hell; font-size: 13px; font-weight: 600; vertical-alignment: center; } + Auswahl { + width: 112px; + optionen: ["Multiway", "Heads-Up", "Beide"]; + index: root.lage.form; + gewaehlt(i) => { root.form-gewaehlt(i); } + } + Rectangle { } + Text { text: "Micro only"; color: Farbe.hell; font-size: 13px; font-weight: 600; vertical-alignment: center; } + Toggle { + y: (parent.height - self.height) / 2; + an: root.lage.micro-only; + umgeschaltet => { root.micro-umschalten(); } + } + } + + // 6) Was spielen + VerticalLayout { + spacing: 8px; + HorizontalLayout { + spacing: 10px; + height: 24px; + Text { text: "Was spielen"; color: Farbe.gedaempft; font-size: 12px; font-weight: 600; vertical-alignment: center; } + Rectangle { } + Text { text: root.lage.zusammen; color: Farbe.gedaempft; font-size: 12px; vertical-alignment: center; } + Rectangle { + width: ausw-text.preferred-width + 22px; + border-radius: 12px; + background: root.lage.ausweichen ? Farbe.blau : #ffffff14; + ausw-text := Text { + text: "Ausweichen"; + color: root.lage.ausweichen ? white : Farbe.hell; + font-size: 12px; + font-weight: 600; + } + TouchArea { clicked => { root.ausweichen-umschalten(); } } + } + } + if root.lage.ausweichen: HorizontalLayout { + spacing: 8px; + height: 30px; + Text { + text: root.lage.ziel-text; + color: Farbe.gedaempft; + font-size: 11px; + vertical-alignment: center; + overflow: elide; + } + Stepper { auf => { root.ziel-auf(); } ab => { root.ziel-ab(); } text: ""; } + } + Rectangle { + height: Math.ceil(root.karten.length / 2) * 64px - 8px; + for k[i] in root.karten: Formatkarte { + x: Math.mod(i, 2) * (root.spalte + 8px); + y: Math.floor(i / 2) * 64px; + width: root.spalte; + name: k.name; + hinweis: k.hinweis; + symbol: k.symbol; + anzahl: k.anzahl; + voll: k.voll; + rang: k.rang; + plus => { root.karte-plus(k.id); } + minus => { root.karte-minus(k.id); } + vorziehen => { root.karte-vor(k.id); } + } + } + } + } + + // 7) Statuszeile + HorizontalLayout { + spacing: 9px; + alignment: start; + Rectangle { + width: 10px; + Rectangle { + width: 10px; + height: 10px; + y: 5px; + border-radius: 5px; + background: root.lage.status-ton; + } + } + Text { + text: root.lage.status-satz; + color: Farbe.text; + font-size: 15px; + font-weight: 600; + wrap: word-wrap; + horizontal-stretch: 1; + } + } + + if root.lage.meldung != "": Text { + text: root.lage.meldung; + color: root.lage.meldung-ok ? Farbe.gruen : Farbe.bernstein; + font-size: 12px; + wrap: word-wrap; + } + + // 8) Hauptknopf und Not-Aus + HorizontalLayout { + spacing: 10px; + height: 56px; + Rectangle { + border-radius: 12px; + background: Farbe.knopf; + opacity: root.lage.knopf-aktiv ? 1 : 0.55; + HorizontalLayout { + alignment: center; + spacing: 8px; + Icon { + art: root.lage.beschaeftigt ? "punkte" : root.lage.knopf-symbol; + farbe: root.lage.knopf-farbe; + groesse: 20px; + y: (parent.height - self.height) / 2; + } + Text { + text: root.lage.knopf-titel; + color: Farbe.text; + font-size: 16px; + font-weight: 700; + vertical-alignment: center; + } + } + TouchArea { enabled: root.lage.knopf-aktiv; clicked => { root.knopf-gedrueckt(); } } + } + Rectangle { + width: 56px; + border-radius: 28px; + // Not-Aus aktiv: der Knopf loest ihn (gruen, Play); sonst rot mit der Hand. + background: root.lage.not-aus ? #ffffff1a : Farbe.rot; + border-width: 1px; + border-color: root.lage.not-aus ? Farbe.gruen : #ffffff59; + Icon { + art: root.lage.not-aus ? "play" : "hand"; + farbe: root.lage.not-aus ? Farbe.gruen : white; + groesse: 26px; + } + TouchArea { clicked => { root.not-aus(); } } + } + } + + // 9) Werkzeugleiste + Rectangle { + height: 60px; + border-radius: 12px; + background: Farbe.karte; + HorizontalLayout { + padding: 4px; + spacing: 2px; + Werkzeugknopf { art: "pause"; titel: "Pause"; aktiv: root.lage.werkzeuge-aktiv; geklickt => { root.werkzeug("pause"); } } + Werkzeugknopf { art: "nach-vorn"; titel: "Nach vorn"; aktiv: root.lage.werkzeuge-aktiv; geklickt => { root.werkzeug("tische_vorn"); } } + Werkzeugknopf { art: "anordnen"; titel: "Anordnen"; aktiv: root.lage.werkzeuge-aktiv; geklickt => { root.werkzeug("tische_anordnen"); } } + Werkzeugknopf { art: "foto"; titel: "Foto"; aktiv: root.lage.werkzeuge-aktiv; geklickt => { root.werkzeug("foto"); } } + Werkzeugknopf { art: "schliessen"; titel: "Schließen"; rot: true; aktiv: root.lage.werkzeuge-aktiv; geklickt => { root.werkzeug("tische_schliessen"); } } + } + } +} diff --git a/cockpit/ui/fenster.slint b/cockpit/ui/fenster.slint new file mode 100644 index 00000000..0f07ee3b --- /dev/null +++ b/cockpit/ui/fenster.slint @@ -0,0 +1,133 @@ +// Das Cockpit-Fenster: ein schmales, hohes, randloses Panel (Wurzel.swift `Leiste`). +// Oben die Kopfzeile mit eigenem Fensterchrome, darunter der scrollende Inhalt des gewaehlten +// Reiters, unten fest die Tableiste. Der Reiter "Cash" ist ausgebaut (cash.slint); Haende, +// Statistik und Protokoll sind in dieser Stufe leere Flaechen mit Titel. + +import { Farbe, Icon, Tableiste } from "bausteine.slint"; +import { CashInhalt, CashZustand, KartenZeile } from "cash.slint"; + +export { CashZustand, KartenZeile } + +component Platzhalter inherits Rectangle { + in property titel; + in property hinweis; + VerticalLayout { + alignment: center; + spacing: 6px; + Text { text: root.titel; color: Farbe.text; font-size: 20px; font-weight: 700; horizontal-alignment: center; } + Text { text: root.hinweis; color: Farbe.gedaempft; font-size: 13px; horizontal-alignment: center; } + } +} + +// Ein kleiner Knopf im Fensterchrome (Minimieren, Schliessen, Einstellungen). +component Chromeknopf inherits Rectangle { + in property art; + in property farbe: Farbe.gedaempft; + callback geklickt(); + width: 28px; + height: 28px; + border-radius: 14px; + background: ta.has-hover ? #ffffff14 : transparent; + Icon { art: root.art; farbe: root.farbe; groesse: 16px; } + ta := TouchArea { clicked => { root.geklickt(); } } +} + +export component Cockpit inherits Window { + title: "Pokerfreak Cockpit"; + no-frame: true; + preferred-width: 440px; + preferred-height: 900px; + min-width: 380px; + min-height: 520px; + background: Farbe.grund; + + in property lage <=> cash.lage; + in property <[KartenZeile]> karten <=> cash.karten; + in-out property budget-feld <=> cash.budget-feld; + in-out property budget-tippt <=> cash.budget-tippt; + in-out property reiter: 0; + + callback modus-gewaehlt <=> cash.modus-gewaehlt; + callback cash-bestaetigt <=> cash.cash-bestaetigt; + callback cash-abgebrochen <=> cash.cash-abgebrochen; + callback budget-gesetzt <=> cash.budget-gesetzt; + callback geld-oeffnen <=> cash.geld-oeffnen; + callback plan-oeffnen <=> cash.plan-oeffnen; + callback sitzung-art-gewaehlt <=> cash.sitzung-art-gewaehlt; + callback stepper-auf <=> cash.stepper-auf; + callback stepper-ab <=> cash.stepper-ab; + callback form-gewaehlt <=> cash.form-gewaehlt; + callback micro-umschalten <=> cash.micro-umschalten; + callback ausweichen-umschalten <=> cash.ausweichen-umschalten; + callback ziel-auf <=> cash.ziel-auf; + callback ziel-ab <=> cash.ziel-ab; + callback karte-plus <=> cash.karte-plus; + callback karte-minus <=> cash.karte-minus; + callback karte-vor <=> cash.karte-vor; + callback knopf-gedrueckt <=> cash.knopf-gedrueckt; + callback not-aus <=> cash.not-aus; + callback werkzeug <=> cash.werkzeug; + callback reiter-gewaehlt(int); + callback einstellungen(); + callback minimieren(); + callback schliessen(); + callback ziehen(length, length); + + // Der Schimmer oben: weinrot in Echtgeld und bei Not-Aus, sonst ein kuehles Blau. + Rectangle { + y: 0px; + height: 180px; + background: @linear-gradient(180deg, (root.lage.cash || root.lage.not-aus) ? #3b2026 : #1b2638 0%, Farbe.grund 100%); + } + + VerticalLayout { + // 1) Kopfzeile: links der eigene Fensterchrome, rechts das Zahnrad. Der freie Rest zieht das Fenster. + Rectangle { + height: 44px; + TouchArea { + moved => { root.ziehen(self.mouse-x - self.pressed-x, self.mouse-y - self.pressed-y); } + } + HorizontalLayout { + padding-left: 10px; + padding-right: 10px; + spacing: 2px; + alignment: stretch; + Chromeknopf { art: "klein"; geklickt => { root.minimieren(); } y: (parent.height - self.height) / 2; } + Chromeknopf { art: "x"; geklickt => { root.schliessen(); } y: (parent.height - self.height) / 2; } + Rectangle { } + Chromeknopf { art: "zahnrad"; geklickt => { root.einstellungen(); } y: (parent.height - self.height) / 2; } + } + } + + Rectangle { + vertical-stretch: 1; + clip: true; + + Flickable { + visible: root.reiter == 0; + content-width: self.width; + content-height: cash.preferred-height; + cash := CashInhalt { + width: parent.width; + height: cash.preferred-height; + } + } + Platzhalter { visible: root.reiter == 1; titel: "Hände"; hinweis: "folgt in einer späteren Stufe"; } + Platzhalter { visible: root.reiter == 2; titel: "Statistik"; hinweis: "folgt in einer späteren Stufe"; } + Platzhalter { visible: root.reiter == 3; titel: "Protokoll"; hinweis: "folgt in einer späteren Stufe"; } + } + + // 10) Tableiste, fest unten + Tableiste { + aktuell: root.reiter; + gewaehlt(i) => { root.reiter = i; root.reiter-gewaehlt(i); } + } + } + + // Rahmen: rot in Echtgeld und bei Not-Aus (Wurzel.swift `rand`), sonst ein Hauch Weiss. + Rectangle { + background: transparent; + border-width: (root.lage.cash || root.lage.not-aus) ? 2px : 1px; + border-color: root.lage.not-aus ? Farbe.rot : root.lage.cash ? #e5484db3 : #ffffff1a; + } +} diff --git a/sicht/instanz.py b/sicht/instanz.py index bbf8f867..aba78a31 100644 --- a/sicht/instanz.py +++ b/sicht/instanz.py @@ -65,19 +65,41 @@ def uebernehmen(pfade, frist=5.0, takt=0.05): r = sperre.nehmen(pfade.sperre) if not isinstance(r, sperre.Belegt): return r - try: - os.kill(r.besitzer, signal.SIGINT) - except OSError: - pass + if sys.platform == "win32": + # Windows: SIGINT toetet per TerminateProcess, Strg-Pause an eine fremde pid trifft die + # ganze Konsole. Der Besitzer sieht stattdessen die Bitte-Datei (bitte_ende) und geht sauber. + try: + open(pfade.sperre + ".ende", "w").close() + except OSError: + pass + else: + try: + os.kill(r.besitzer, signal.SIGINT) + except OSError: + pass ende = time.time() + frist while time.time() < ende: time.sleep(takt) r = sperre.nehmen(pfade.sperre) if not isinstance(r, sperre.Belegt): + _weg(pfade.sperre + ".ende") return r return r +def _weg(pfad): + try: + os.remove(pfad) + except OSError: + pass + + +def bitte_ende(pfade): + """Windows: hat jemand per `uebernehmen` gebeten aufzuhoeren? (Die Datei gilt nur fuer den + Besitzer; wer die Sperre neu nimmt, raeumt sie weg.)""" + return os.path.exists(pfade.sperre + ".ende") + + def aufraeumen(pfade): """Eigene Sperre und eigene Beschreibung weg - fremde bleiben.""" d = lesen(pfade) diff --git a/sicht/quellen.py b/sicht/quellen.py index a73cb854..99a762c5 100644 --- a/sicht/quellen.py +++ b/sicht/quellen.py @@ -279,6 +279,9 @@ def _start_lebt(schatten): pid = e.get("pid") if not isinstance(pid, int) or pid <= 1: return None + if sys.platform == "win32": # os.kill(pid, 0) beendet dort den Prozess + import sperre + return sperre.lebt(pid) try: os.kill(pid, 0) except ProcessLookupError: diff --git a/sicht/start.py b/sicht/start.py index 0a9b415a..20532048 100644 --- a/sicht/start.py +++ b/sicht/start.py @@ -61,10 +61,13 @@ def main(argv=None): print(instanz.belegt_zeile(pfade, r.besitzer), flush=True) print("Es läuft schon ein Cockpit - mit --uebernehmen ablösen.", flush=True) return instanz.BELEGT_CODE + instanz._weg(pfade.sperre + ".ende") # Rest einer frueheren Uebernahme # SIGTERM (die App beim Beenden, kill) wie Strg-C: sauber aufraeumen. SIGINT ausdruecklich # setzen: mit & oder nohup gestartet ist es sonst ignoriert, und --uebernehmen liefe ins Leere. signal.signal(signal.SIGINT, signal.default_int_handler) signal.signal(signal.SIGTERM, lambda *_: (_ for _ in ()).throw(KeyboardInterrupt())) + if sys.platform == "win32": # Strg-Pause (uebernehmen, Laeufer-Gruppe) wie Strg-C + signal.signal(signal.SIGBREAK, signal.default_int_handler) c = server.Cockpit(args.port) try: port = c.starten() @@ -77,8 +80,9 @@ def main(argv=None): url = f"http://{server.HOST}:{port}" print(f"Cockpit: {url} ({modus})", flush=True) try: - while True: + while not (sys.platform == "win32" and instanz.bitte_ende(pfade)): # Windows: Bitte-Datei time.sleep(1) + print("Cockpit abgelöst.") except KeyboardInterrupt: print("Cockpit beendet.") finally: diff --git a/sicht/steuern.py b/sicht/steuern.py index 699cffda..55f0e175 100644 --- a/sicht/steuern.py +++ b/sicht/steuern.py @@ -149,6 +149,35 @@ def not_aus_loeschen(): # ---- Laeufer --------------------------------------------------------------------------------- +def _signal_sanft(pid): + """Wie Strg-C an den Prozess. Unter Windows Strg-Pause an seine Gruppe (er muss mit + CREATE_NEW_PROCESS_GROUP gestartet sein); os.kill(pid, SIGINT) wuerde ihn dort beenden.""" + if sys.platform != "win32": + os.kill(pid, signal.SIGINT) + return + # CTRL_BREAK an eine pid, die KEINE eigene Gruppe fuehrt, geht an alle Prozesse der Konsole + # (auch das Cockpit selbst): nur an Kinder, die wir mit CREATE_NEW_PROCESS_GROUP gestartet haben. + if any(k is not None and k.pid == pid for k in (_kind, _zuschauer_kind)): + os.kill(pid, signal.CTRL_BREAK_EVENT) + else: + _signal_hart(pid) + + +def _signal_hart(pid, terminieren=False): + """Hart beenden. Windows kennt nur TerminateProcess (os.kill mit beliebigem anderen Signal, + SIGKILL gibt es dort nicht). -> False, wenn es den Prozess nicht (mehr) gibt.""" + sig = signal.SIGTERM if terminieren or sys.platform == "win32" else signal.SIGKILL + try: + os.kill(pid, sig) + except ProcessLookupError: + return False + except OSError: + if sys.platform == "win32" and not _lebt(pid): + return False + raise + return True + + def _lebt(pid): """Gibt es den Prozess? Unter Windows ohne os.kill(pid, 0) - das beendet dort den Prozess.""" if not pid or pid <= 0: @@ -214,7 +243,7 @@ def laeufer_starten(): return _antwort(False, f"Läufer läuft schon (PID {z['pid']})", pid=z["pid"]) # Wie der Hauptknopf (CockpitKern/Hauptknopf: freigabeFehlt): ohne Fensterzugriff waere er # blind - 5.11. 19:06 oeffnete er so drei Tische und stuerzte beim Beenden ab. - if not _fenster_lesbar(): + if sys.platform == "darwin" and not _fenster_lesbar(): return _antwort(False, "Freigabe fehlt: macOS lässt das Cockpit die Tischfenster nicht lesen - " "ein Läufer von hier wäre blind. In den Systemeinstellungen für Cockpit " "Bedienungshilfen und Bildschirmaufnahme einschalten.") @@ -226,11 +255,19 @@ def laeufer_starten(): kw["start_new_session"] = True log = open(LAEUFER_LOG, "ab") befehl = engine_befehl() + # Klon-Lauf: der Klon kennt keinen Kanal (runner.kanal_da -> False), jeder Zug geht als + # klonmaus-Klick ueber CDP. Dessen Beleg ist am headless Klon unzuverlaessig - die strenge + # "beleg"-Invariante braeche sonst den ganzen Lauf ab ("unbestaetigt ohne Grund"), obwohl + # der Zug lief. Wie am echten Client (umgebung.betrieb_am_client: INVARIANTEN=melden) nur + # melden; ein ausdruecklich gesetztes INVARIANTEN bleibt unberuehrt. + umg = dict(os.environ, SCRATCH=treffpunkt(), PYTHONUTF8="1", # UTF-8 auch unter Windows (cp1252 wirft bei Umlauten) + PYTHONUNBUFFERED="1") # Laeufer-Log live statt gepuffert (wie tests/klonlauf) + if umgebung.klon() and "INVARIANTEN" not in os.environ: + umg["INVARIANTEN"] = "melden" try: # eigene Prozessgruppe: Strg-C im Cockpit und ein Absturz des Cockpits treffen den # Läufer nicht; Strg-Pause an seine Gruppe (laeufer_stoppen) erreicht ihn trotzdem - _kind = subprocess.Popen(befehl, cwd=WURZEL, - env=dict(os.environ, SCRATCH=treffpunkt()), + _kind = subprocess.Popen(befehl, cwd=WURZEL, env=umg, stdin=subprocess.DEVNULL, stdout=log, stderr=subprocess.STDOUT, **kw) finally: @@ -249,10 +286,7 @@ def laeufer_stoppen(): return _antwort(False, "Dieser Läufer wurde nicht von hier gestartet - dort mit Strg-C beenden") if not z["laeuft"]: return _antwort(False, f"Läufer (PID {z['pid']}) läuft nicht mehr") - if sys.platform == "win32": - os.kill(z["pid"], signal.CTRL_BREAK_EVENT) - else: - os.kill(z["pid"], signal.SIGINT) + _signal_sanft(z["pid"]) return _antwort(True, "Stopp gesendet - er setzt aus und steht nach der Hand auf", pid=z["pid"]) except Exception as e: return _fehler("Läufer stoppen", e) @@ -277,7 +311,7 @@ def laeufer_neustarten(frist=30.0): time.sleep(0.5) if _lebt(pid): # bockt: haerter beenden, dann starten try: - os.kill(pid, signal.SIGKILL) + _signal_hart(pid) except OSError: pass time.sleep(0.5) @@ -311,10 +345,11 @@ def zuschauer_starten(): if z["laeuft"] or (_zuschauer_kind is not None and _zuschauer_kind.poll() is None): return _antwort(False, "Zuschauer läuft schon") os.makedirs(os.path.dirname(ZUSCHAUER_LOG), exist_ok=True) + kw = {"creationflags": subprocess.CREATE_NEW_PROCESS_GROUP} if sys.platform == "win32" else {} with open(ZUSCHAUER_LOG, "ab") as log: _zuschauer_kind = subprocess.Popen([sys.executable, os.path.join(WURZEL, "betrieb", "zuschauer_lauf.py")], - cwd=WURZEL, env=dict(os.environ), stdin=subprocess.DEVNULL, - stdout=log, stderr=subprocess.STDOUT) + cwd=WURZEL, env=dict(os.environ, PYTHONUTF8="1"), stdin=subprocess.DEVNULL, + stdout=log, stderr=subprocess.STDOUT, **kw) return _antwort(True, "Zuschauer gestartet: er liest nur und klickt nie", pid=_zuschauer_kind.pid) except Exception as e: return _fehler("Zuschauer starten", e) @@ -325,7 +360,7 @@ def zuschauer_stoppen(): z = zuschauer_zustand() if not z["laeuft"]: return _antwort(False, "Zuschauer läuft nicht") - os.kill(z["pid"], signal.SIGINT) + _signal_sanft(z["pid"]) return _antwort(True, "Zuschauer gestoppt", pid=z["pid"]) except Exception as e: return _fehler("Zuschauer stoppen", e) @@ -338,6 +373,8 @@ ZU_TAKT = 0.25 def _prozess_lebt(pid): + if sys.platform == "win32": + return _lebt(pid) try: os.kill(pid, 0) except ProcessLookupError: @@ -384,15 +421,11 @@ def _schliessen(name, f): if pid is None: # Klon: kein Prozess zum Beenden - das Kreuz ok = bool(act.stellen_klicken(f, [("kreuz", sitzen.KREUZ)], trotz_stopp=True)) return ok, f"{name}: {'geklickt' if ok else 'nicht geklickt'}" - try: - os.kill(pid, signal.SIGTERM) - except ProcessLookupError: + if not _signal_hart(pid, terminieren=True): return True, f"{name}: zu" if _ist_zu(pid): return True, f"{name}: zu" - try: # reagiert nicht -> hart beenden - os.kill(pid, signal.SIGKILL) - except ProcessLookupError: + if not _signal_hart(pid): # reagiert nicht -> hart beenden return True, f"{name}: zu" return (True, f"{name}: hart zu") if _ist_zu(pid) else (False, f"{name}: Prozess reagiert nicht") diff --git a/werkzeuge/fensterdienst/.gitignore b/werkzeuge/fensterdienst/.gitignore new file mode 100644 index 00000000..ea8c4bf7 --- /dev/null +++ b/werkzeuge/fensterdienst/.gitignore @@ -0,0 +1 @@ +/target diff --git a/werkzeuge/fensterdienst/Cargo.lock b/werkzeuge/fensterdienst/Cargo.lock new file mode 100644 index 00000000..3860a412 --- /dev/null +++ b/werkzeuge/fensterdienst/Cargo.lock @@ -0,0 +1,121 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "fensterdienst" +version = "0.1.0" +dependencies = [ + "serde_json", + "windows-sys", +] + +[[package]] +name = "itoa" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/werkzeuge/fensterdienst/Cargo.toml b/werkzeuge/fensterdienst/Cargo.toml new file mode 100644 index 00000000..ad7db218 --- /dev/null +++ b/werkzeuge/fensterdienst/Cargo.toml @@ -0,0 +1,39 @@ +[package] +name = "fensterdienst" +version = "0.1.0" +edition = "2021" +description = "Duenne, robuste Windows-Fensterbedienung (JSON rein, JSON raus)" + +[lib] +name = "fensterdienst" +path = "src/lib.rs" + +[[bin]] +name = "fensterdienst" +path = "src/main.rs" + +[dependencies] +serde_json = "1" + +[dependencies.windows-sys] +version = "0.61" +features = [ + "Win32_Foundation", + "Win32_Graphics_Dwm", + "Win32_Graphics_Gdi", + "Win32_UI_HiDpi", + "Win32_UI_WindowsAndMessaging", +] + +[dev-dependencies.windows-sys] +version = "0.61" +features = ["Win32_System_LibraryLoader", "Win32_UI_WindowsAndMessaging", "Win32_Foundation"] + +# eigener Arbeitsbereich: der Root-Cargo.toml bleibt unberuehrt +[workspace] + +[profile.release] +opt-level = "s" +lto = true +strip = true +panic = "abort" diff --git a/werkzeuge/fensterdienst/README.md b/werkzeuge/fensterdienst/README.md new file mode 100644 index 00000000..0d3ecf51 --- /dev/null +++ b/werkzeuge/fensterdienst/README.md @@ -0,0 +1,30 @@ +# fensterdienst + +Duennes, robustes Windows-Fensterwerkzeug (Ersatz fuer osascript/AX auf dem Mac). +Reines OS-Primitiv: liest und bewegt Fenster. Kachel-/Platzierungslogik bleibt in `sicht/tische.py`; +welche Fenster CoinPoker-Tische sind (Prozess/Titel) und die Mac-Umstellung sind spaetere Schritte. + +Aufruf: `fensterdienst [json]` oder JSON mit Feld `"befehl"` auf stdin. +Antwort: eine JSON-Zeile auf stdout. Exit 0 = ok (bzw. Liste), 1 = `ok:false`, 2 = Eingabefehler +(`{"ok":false,"grund":"eingabe_ungueltig","meldung":...}`). Harte Frist 3 s (`zeitueberschreitung`). + +Koordinaten: echte Pixel (Per-Monitor-DPI-v2), virtueller Desktop, **sichtbarer Rahmen** +(ohne den unsichtbaren Win11-Schattenrand; `DWMWA_EXTENDED_FRAME_BOUNDS`). + +| Befehl | Eingabe | Antwort | +|---|---|---| +| `liste` | optional `{"pid":n,"titel_enthaelt":"..."}` | `[{"id","pid","titel","rect":{x,y,w,h},"minimiert","maximiert"}]` (nur sichtbare, normale Top-Level-Fenster; keine Werkzeug-/Besitzer-/getarnten Fenster) | +| `setze` | `{"id","rect":{x,y,w,h},"toleranz"?=2,"versuche"?=5 (max 10)}` | `{"ok","rect"(erreicht),"versuche","grund"?,"abweichung"?}` | +| `vorn` | `{"id","aktiv"?=false}` | `{"ok","aktiv","grund"?}` | +| `arbeitsflaeche` | optional `{"monitor":index}` (0 = Hauptmonitor) | `{"ok","rect"(ohne Taskleiste),"monitor","monitore":[{"index","primaer","rect","voll"}]}` | + +`id` ist das HWND als Zahl. `grund`-Werte: `fenster_weg`, `unbekannte_id`, `haengt`, `kein_zugriff`, +`abweichung_nach_versuchen` (Mindestgroesse/Zurueckschnappen), `vordergrund_verweigert`, +`monitor_unbekannt`, `setwindowpos_fehler_`, `eingabe_ungueltig`, `zeitueberschreitung`. + +Garantien: `setze`/`vorn aktiv:false` ohne Fokusraub (`SWP_NOACTIVATE`, kein `SetForegroundWindow`); +Setzen, Zurücklesen, bei Abweichung wiederholen (begrenzt, Abbruch bei Stillstand); schon passendes +Fenster -> `versuche:0`, keine Aenderung; minimierte/maximierte Fenster werden ohne Aktivierung normalisiert. + +Test: `cargo test` (Unit + echter Lauf mit eigenem Testfenster). Bauen: `cargo build --release`. +Eigener `[workspace]`, beruehrt den Root-`Cargo.toml` nicht. diff --git a/werkzeuge/fensterdienst/src/befehl.rs b/werkzeuge/fensterdienst/src/befehl.rs new file mode 100644 index 00000000..8b785237 --- /dev/null +++ b/werkzeuge/fensterdienst/src/befehl.rs @@ -0,0 +1,141 @@ +//! Befehle und deren Parsing (rein). Eingabe: Argumente oder JSON auf stdin. + +use crate::logik::Rect; +use serde_json::Value; + +pub const STANDARD_TOLERANZ: i32 = 2; +pub const STANDARD_VERSUCHE: u32 = 5; +pub const MAX_VERSUCHE: u32 = 10; + +#[derive(Debug, PartialEq)] +pub enum Befehl { + Liste { pid: Option, titel_enthaelt: Option }, + Setze { id: u64, rect: Rect, toleranz: i32, versuche: u32 }, + Vorn { id: u64, aktiv: bool }, + Arbeitsflaeche { monitor: Option }, +} + +/// `args`: Programmargumente ohne Programmname. `stdin`: liefert bei Bedarf den stdin-Text. +/// - ` [json]` oder +/// - ohne Argumente: stdin-JSON mit Feld "befehl" +pub fn lies(args: &[String], stdin: impl FnOnce() -> String) -> Result { + match args.len() { + 0 => { + let v: Value = parse_json(&stdin())?; + let name = v + .get("befehl") + .and_then(Value::as_str) + .ok_or("stdin-JSON braucht das Feld \"befehl\"")? + .to_string(); + parse(&name, &v) + } + 1 => parse(&args[0], &Value::Null), + 2 => parse(&args[0], &parse_json(&args[1])?), + _ => Err("zu viele Argumente (erwartet: [json])".into()), + } +} + +fn parse_json(text: &str) -> Result { + if text.trim().is_empty() { + return Err("keine Eingabe".into()); + } + serde_json::from_str(text.trim()).map_err(|e| format!("JSON ungueltig: {e}")) +} + +pub fn parse(name: &str, p: &Value) -> Result { + let id = || -> Result { + match p.get("id") { + Some(Value::Number(n)) => n.as_u64().ok_or("id muss eine nichtnegative ganze Zahl sein".to_string()), + _ => Err("id fehlt".to_string()), + } + }; + match name { + "liste" => { + let pid = match p.get("pid") { + None | Some(Value::Null) => None, + Some(v) => Some(v.as_u64().and_then(|n| u32::try_from(n).ok()).ok_or("pid ungueltig")?), + }; + let titel_enthaelt = match p.get("titel_enthaelt") { + None | Some(Value::Null) => None, + Some(v) => Some(v.as_str().ok_or("titel_enthaelt muss Text sein")?.to_string()), + }; + Ok(Befehl::Liste { pid, titel_enthaelt }) + } + "setze" => { + let rect = Rect::aus_json(p.get("rect").ok_or("rect fehlt")?)?; + let toleranz = p + .get("toleranz") + .and_then(Value::as_i64) + .map(|t| t.clamp(0, 100) as i32) + .unwrap_or(STANDARD_TOLERANZ); + let versuche = p + .get("versuche") + .and_then(Value::as_u64) + .map(|v| v.clamp(1, MAX_VERSUCHE as u64) as u32) + .unwrap_or(STANDARD_VERSUCHE); + Ok(Befehl::Setze { id: id()?, rect, toleranz, versuche }) + } + "vorn" => { + let aktiv = match p.get("aktiv") { + None | Some(Value::Null) => false, + Some(v) => v.as_bool().ok_or("aktiv muss true/false sein")?, + }; + Ok(Befehl::Vorn { id: id()?, aktiv }) + } + "arbeitsflaeche" => { + let monitor = match p.get("monitor") { + None | Some(Value::Null) => None, + Some(v) => Some(v.as_u64().ok_or("monitor muss ein Index (0-basiert) sein")? as usize), + }; + Ok(Befehl::Arbeitsflaeche { monitor }) + } + andere => Err(format!("unbekannter Befehl: {andere}")), + } +} + +#[cfg(test)] +mod tests { + use super::*; + use serde_json::json; + + fn s(v: &[&str]) -> Vec { + v.iter().map(|x| x.to_string()).collect() + } + + #[test] + fn liste_ohne_und_mit_filter() { + assert_eq!(lies(&s(&["liste"]), String::new).unwrap(), Befehl::Liste { pid: None, titel_enthaelt: None }); + let b = lies(&s(&["liste", r#"{"pid":42,"titel_enthaelt":"Tisch"}"#]), String::new).unwrap(); + assert_eq!(b, Befehl::Liste { pid: Some(42), titel_enthaelt: Some("Tisch".into()) }); + } + + #[test] + fn setze_aus_stdin() { + let eingabe = || r#"{"befehl":"setze","id":658,"rect":{"x":1,"y":2,"w":300,"h":200},"versuche":99}"#.to_string(); + match lies(&[], eingabe).unwrap() { + Befehl::Setze { id, rect, toleranz, versuche } => { + assert_eq!(id, 658); + assert_eq!(rect, Rect::neu(1, 2, 300, 200)); + assert_eq!(toleranz, STANDARD_TOLERANZ); + assert_eq!(versuche, MAX_VERSUCHE); + } + x => panic!("falsch: {x:?}"), + } + } + + #[test] + fn fehler_sind_klar() { + assert!(lies(&[], String::new).is_err()); + assert!(lies(&s(&["nix"]), String::new).unwrap_err().contains("unbekannter Befehl")); + assert!(parse("setze", &json!({"id":1})).unwrap_err().contains("rect")); + assert!(parse("vorn", &json!({"aktiv":true})).unwrap_err().contains("id")); + assert!(parse("vorn", &json!({"id":-1})).is_err()); + assert!(lies(&s(&["liste", "{kaputt"]), String::new).unwrap_err().contains("JSON")); + } + + #[test] + fn vorn_standard_ohne_fokus() { + assert_eq!(parse("vorn", &json!({"id":5})).unwrap(), Befehl::Vorn { id: 5, aktiv: false }); + assert_eq!(parse("arbeitsflaeche", &json!({"monitor":1})).unwrap(), Befehl::Arbeitsflaeche { monitor: Some(1) }); + } +} diff --git a/werkzeuge/fensterdienst/src/lib.rs b/werkzeuge/fensterdienst/src/lib.rs new file mode 100644 index 00000000..4ba6add1 --- /dev/null +++ b/werkzeuge/fensterdienst/src/lib.rs @@ -0,0 +1,7 @@ +//! Fensterdienst: duenne, robuste Windows-Fensterbedienung. +//! `logik` und `befehl` sind rein (ohne OS), `win` ist die Win32-Naht. + +pub mod befehl; +pub mod logik; +#[cfg(windows)] +pub mod win; diff --git a/werkzeuge/fensterdienst/src/logik.rs b/werkzeuge/fensterdienst/src/logik.rs new file mode 100644 index 00000000..1861ced7 --- /dev/null +++ b/werkzeuge/fensterdienst/src/logik.rs @@ -0,0 +1,134 @@ +//! Reine Rechtecklogik: Abweichungsmass, Toleranz, Rahmen-Versatz. + +use serde_json::{json, Value}; + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct Rect { + pub x: i32, + pub y: i32, + pub w: i32, + pub h: i32, +} + +/// Versatz zwischen Fensterrechteck (GetWindowRect) und sichtbarem Rahmen +/// (DWMWA_EXTENDED_FRAME_BOUNDS): unsichtbarer Schattenrand je Seite. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)] +pub struct Rand { + pub links: i32, + pub oben: i32, + pub rechts: i32, + pub unten: i32, +} + +impl Rect { + pub fn neu(x: i32, y: i32, w: i32, h: i32) -> Rect { + Rect { x, y, w, h } + } + + pub fn aus_kanten(l: i32, t: i32, r: i32, b: i32) -> Rect { + Rect { x: l, y: t, w: r - l, h: b - t } + } + + pub fn rechts(&self) -> i32 { + self.x + self.w + } + + pub fn unten(&self) -> i32 { + self.y + self.h + } + + /// Groesste Einzelabweichung von x, y, w, h (in Pixeln). + pub fn abweichung(&self, ziel: &Rect) -> i32 { + [self.x - ziel.x, self.y - ziel.y, self.w - ziel.w, self.h - ziel.h] + .iter() + .map(|d| d.abs()) + .max() + .unwrap_or(0) + } + + pub fn passt(&self, ziel: &Rect, toleranz: i32) -> bool { + self.abweichung(ziel) <= toleranz.max(0) + } + + pub fn zu_json(&self) -> Value { + json!({"x": self.x, "y": self.y, "w": self.w, "h": self.h}) + } + + pub fn aus_json(v: &Value) -> Result { + let o = v.as_object().ok_or("rect muss ein Objekt {x,y,w,h} sein")?; + let zahl = |k: &str| -> Result { + let n = o.get(k).and_then(Value::as_f64).ok_or(format!("rect.{k} fehlt oder keine Zahl"))?; + if !n.is_finite() || n.abs() > 1.0e7 { + return Err(format!("rect.{k} ausserhalb des Bereichs")); + } + Ok(n.round() as i32) + }; + let r = Rect { x: zahl("x")?, y: zahl("y")?, w: zahl("w")?, h: zahl("h")? }; + if r.w <= 0 || r.h <= 0 { + return Err("rect.w und rect.h muessen > 0 sein".into()); + } + Ok(r) + } +} + +/// Rand = Fensterrechteck minus sichtbarer Rahmen. +pub fn rand_von(fenster: Rect, sichtbar: Rect) -> Rand { + Rand { + links: sichtbar.x - fenster.x, + oben: sichtbar.y - fenster.y, + rechts: fenster.rechts() - sichtbar.rechts(), + unten: fenster.unten() - sichtbar.unten(), + } +} + +/// Rechteck fuer SetWindowPos, damit der *sichtbare* Rahmen auf `sichtbar` faellt. +pub fn fenster_ziel(sichtbar: Rect, rand: Rand) -> Rect { + Rect::aus_kanten( + sichtbar.x - rand.links, + sichtbar.y - rand.oben, + sichtbar.rechts() + rand.rechts, + sichtbar.unten() + rand.unten, + ) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn abweichung_ist_groesste_kante() { + let a = Rect::neu(10, 10, 100, 100); + assert_eq!(a.abweichung(&a), 0); + assert_eq!(a.abweichung(&Rect::neu(12, 10, 100, 95)), 5); + assert_eq!(a.abweichung(&Rect::neu(7, 10, 100, 100)), 3); + } + + #[test] + fn toleranz_grenze() { + let a = Rect::neu(0, 0, 100, 100); + assert!(a.passt(&Rect::neu(2, 0, 100, 100), 2)); + assert!(!a.passt(&Rect::neu(3, 0, 100, 100), 2)); + assert!(a.passt(&a, -5)); // negative Toleranz wird zu 0 + } + + #[test] + fn rand_und_ziel_sind_invers() { + let fenster = Rect::neu(92, 100, 816, 639); + let sichtbar = Rect::neu(100, 100, 800, 631); + let rand = rand_von(fenster, sichtbar); + assert_eq!(rand, Rand { links: 8, oben: 0, rechts: 8, unten: 8 }); + assert_eq!(fenster_ziel(sichtbar, rand), fenster); + let neu = Rect::neu(300, 200, 640, 480); + assert_eq!(fenster_ziel(neu, rand), Rect::neu(292, 200, 656, 488)); + } + + #[test] + fn rect_json() { + let v = json!({"x": 5, "y": -3, "w": 400.4, "h": 300}); + assert_eq!(Rect::aus_json(&v).unwrap(), Rect::neu(5, -3, 400, 300)); + assert!(Rect::aus_json(&json!({"x":0,"y":0,"w":0,"h":5})).is_err()); + assert!(Rect::aus_json(&json!({"x":0,"y":0,"w":5})).is_err()); + assert!(Rect::aus_json(&json!(7)).is_err()); + assert_eq!(Rect::neu(1, 2, 3, 4).zu_json(), json!({"x":1,"y":2,"w":3,"h":4})); + } +} diff --git a/werkzeuge/fensterdienst/src/main.rs b/werkzeuge/fensterdienst/src/main.rs new file mode 100644 index 00000000..de0fafbe --- /dev/null +++ b/werkzeuge/fensterdienst/src/main.rs @@ -0,0 +1,52 @@ +//! fensterdienst [json] oder JSON mit "befehl" auf stdin. Antwort: eine JSON-Zeile. +//! Exit 0 bei ok (bzw. Liste), 1 bei ok:false, 2 bei Eingabefehler. + +use fensterdienst::befehl::{lies, Befehl}; +use serde_json::{json, Value}; +use std::io::{Read, Write}; + +/// Harte Obergrenze fuer den ganzen Aufruf: danach strukturierte Absage statt Haengen. +const GESAMT_FRIST_MS: u64 = 3000; + +fn ausgeben(v: &Value) -> ! { + let ok = match v { + Value::Array(_) => true, + o => o.get("ok").and_then(Value::as_bool).unwrap_or(false), + }; + let mut out = std::io::stdout().lock(); + let _ = writeln!(out, "{v}"); + let _ = out.flush(); + std::process::exit(if ok { 0 } else { 1 }); +} + +fn main() { + std::thread::spawn(|| { + std::thread::sleep(std::time::Duration::from_millis(GESAMT_FRIST_MS)); + ausgeben(&json!({"ok": false, "grund": "zeitueberschreitung"})); + }); + + fensterdienst::win::dpi_bewusst(); + let args: Vec = std::env::args().skip(1).collect(); + let stdin = || { + let mut s = String::new(); + let _ = std::io::stdin().read_to_string(&mut s); + s + }; + let befehl = match lies(&args, stdin) { + Ok(b) => b, + Err(e) => { + let mut out = std::io::stdout().lock(); + let _ = writeln!(out, "{}", json!({"ok": false, "grund": "eingabe_ungueltig", "meldung": e})); + let _ = out.flush(); + std::process::exit(2); + } + }; + use fensterdienst::win; + let antwort = match befehl { + Befehl::Liste { pid, titel_enthaelt } => win::liste(pid, titel_enthaelt.as_deref()), + Befehl::Setze { id, rect, toleranz, versuche } => win::setze(id, rect, toleranz, versuche), + Befehl::Vorn { id, aktiv } => win::vorn(id, aktiv), + Befehl::Arbeitsflaeche { monitor } => win::arbeitsflaeche(monitor), + }; + ausgeben(&antwort); +} diff --git a/werkzeuge/fensterdienst/src/win.rs b/werkzeuge/fensterdienst/src/win.rs new file mode 100644 index 00000000..3d1c9a38 --- /dev/null +++ b/werkzeuge/fensterdienst/src/win.rs @@ -0,0 +1,310 @@ +//! Win32-Naht. Alles synchron, nichts blockiert unbegrenzt: +//! Titel per SendMessageTimeout, Setzen asynchron (SWP_ASYNCWINDOWPOS), begrenzte Wiederholung. + +use crate::logik::{fenster_ziel, rand_von, Rect}; +use serde_json::{json, Value}; +use std::ffi::c_void; +use std::time::Duration; +use windows_sys::Win32::Foundation::{GetLastError, HWND, LPARAM, RECT}; +use windows_sys::Win32::Graphics::Dwm::{DwmGetWindowAttribute, DWMWA_CLOAKED, DWMWA_EXTENDED_FRAME_BOUNDS}; +use windows_sys::Win32::Graphics::Gdi::{EnumDisplayMonitors, GetMonitorInfoW, HDC, HMONITOR, MONITORINFO}; +use windows_sys::Win32::UI::HiDpi::{SetProcessDpiAwarenessContext, DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2}; +use windows_sys::Win32::UI::WindowsAndMessaging::*; + +type BOOL = i32; +const ABBRUCH_ZEIT_MS: u32 = 150; +const NACHLESE_SCHRITTE: u32 = 12; +const NACHLESE_PAUSE_MS: u64 = 10; + +/// Pro-Monitor-DPI, damit Koordinaten echte Pixel sind. Fehler ignorieren (z. B. schon gesetzt). +pub fn dpi_bewusst() { + unsafe { + SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); + } +} + +fn fehler(grund: impl Into) -> Value { + json!({"ok": false, "grund": grund.into()}) +} + +fn hwnd_von(id: u64) -> HWND { + id as usize as HWND +} + +fn pruefe(id: u64) -> Result { + if id > usize::MAX as u64 { + return Err(fehler("unbekannte_id")); + } + let h = hwnd_von(id); + if h.is_null() || unsafe { IsWindow(h) } == 0 { + return Err(fehler("fenster_weg")); + } + Ok(h) +} + +fn fenster_rect(h: HWND) -> Option { + let mut r = RECT { left: 0, top: 0, right: 0, bottom: 0 }; + if unsafe { GetWindowRect(h, &mut r) } == 0 { + return None; + } + Some(Rect::aus_kanten(r.left, r.top, r.right, r.bottom)) +} + +/// Sichtbarer Rahmen (ohne unsichtbaren Schatten); Rueckfall: GetWindowRect. +fn sichtbar_rect(h: HWND) -> Option { + let mut r = RECT { left: 0, top: 0, right: 0, bottom: 0 }; + let hr = unsafe { + DwmGetWindowAttribute( + h, + DWMWA_EXTENDED_FRAME_BOUNDS as u32, + &mut r as *mut RECT as *mut c_void, + std::mem::size_of::() as u32, + ) + }; + if hr == 0 { + Some(Rect::aus_kanten(r.left, r.top, r.right, r.bottom)) + } else { + fenster_rect(h) + } +} + +fn titel(h: HWND) -> String { + let mut puffer = [0u16; 1024]; + let mut laenge: usize = 0; + let ok = unsafe { + SendMessageTimeoutW( + h, + WM_GETTEXT, + puffer.len(), + puffer.as_mut_ptr() as LPARAM, + SMTO_ABORTIFHUNG | SMTO_BLOCK, + ABBRUCH_ZEIT_MS, + &mut laenge, + ) + }; + if ok == 0 { + return String::new(); + } + String::from_utf16_lossy(&puffer[..laenge.min(puffer.len() - 1)]) +} + +fn pid_von(h: HWND) -> u32 { + let mut pid = 0u32; + unsafe { GetWindowThreadProcessId(h, &mut pid) }; + pid +} + +fn ist_getarnt(h: HWND) -> bool { + let mut c = 0u32; + let hr = unsafe { DwmGetWindowAttribute(h, DWMWA_CLOAKED as u32, &mut c as *mut u32 as *mut c_void, 4) }; + hr == 0 && c != 0 +} + +/// Sichtbares, normales Top-Level-Fenster (kein Werkzeugfenster, kein Besitzerfenster, nicht getarnt). +fn ist_normal(h: HWND) -> bool { + unsafe { + if IsWindowVisible(h) == 0 { + return false; + } + let ex = GetWindowLongW(h, GWL_EXSTYLE) as u32; + if ex & WS_EX_TOOLWINDOW != 0 && ex & WS_EX_APPWINDOW == 0 { + return false; + } + if ex & WS_EX_NOACTIVATE != 0 && ex & WS_EX_APPWINDOW == 0 { + return false; + } + if !GetWindow(h, GW_OWNER).is_null() && ex & WS_EX_APPWINDOW == 0 { + return false; + } + } + !ist_getarnt(h) +} + +unsafe extern "system" fn sammle(h: HWND, lp: LPARAM) -> BOOL { + let liste = &mut *(lp as *mut Vec); + liste.push(h); + 1 +} + +pub fn liste(pid: Option, titel_enthaelt: Option<&str>) -> Value { + let mut alle: Vec = Vec::new(); + unsafe { EnumWindows(Some(sammle), &mut alle as *mut Vec as LPARAM) }; + let filter = titel_enthaelt.map(str::to_lowercase); + let mut aus = Vec::new(); + for h in alle { + if !ist_normal(h) { + continue; + } + let p = pid_von(h); + if pid.is_some_and(|w| w != p) { + continue; + } + let t = titel(h); + if t.is_empty() { + continue; + } + if let Some(f) = &filter { + if !t.to_lowercase().contains(f) { + continue; + } + } + let Some(r) = sichtbar_rect(h) else { continue }; + aus.push(json!({ + "id": h as usize as u64, + "pid": p, + "titel": t, + "rect": r.zu_json(), + "minimiert": unsafe { IsIconic(h) } != 0, + "maximiert": unsafe { IsZoomed(h) } != 0, + })); + } + Value::Array(aus) +} + +/// Minimiert/maximiert -> normaler Zustand, ohne Aktivierung (SW_SHOWNOACTIVATE). +fn normalisieren(h: HWND) -> bool { + unsafe { + if IsIconic(h) == 0 && IsZoomed(h) == 0 { + return false; + } + let mut wp: WINDOWPLACEMENT = std::mem::zeroed(); + wp.length = std::mem::size_of::() as u32; + if GetWindowPlacement(h, &mut wp) == 0 { + return false; + } + wp.showCmd = SW_SHOWNOACTIVATE as u32; + SetWindowPlacement(h, &wp); + true + } +} + +pub fn setze(id: u64, ziel: Rect, toleranz: i32, max_versuche: u32) -> Value { + let h = match pruefe(id) { + Ok(h) => h, + Err(e) => return e, + }; + if unsafe { IsHungAppWindow(h) } != 0 { + return fehler("haengt"); + } + let normalisiert = normalisieren(h); + let Some(mut jetzt) = sichtbar_rect(h) else { + return fehler("fenster_weg"); + }; + // Idempotent: schon passend -> nichts tun. + if !normalisiert && jetzt.passt(&ziel, toleranz) { + return json!({"ok": true, "rect": jetzt.zu_json(), "versuche": 0}); + } + + let flags = SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_ASYNCWINDOWPOS; + let mut versuche = 0u32; + let mut vorher: Option = None; + while versuche < max_versuche { + versuche += 1; + let (Some(fr), Some(sv)) = (fenster_rect(h), sichtbar_rect(h)) else { + return fehler("fenster_weg"); + }; + let wz = fenster_ziel(ziel, rand_von(fr, sv)); + if unsafe { SetWindowPos(h, std::ptr::null_mut(), wz.x, wz.y, wz.w, wz.h, flags) } == 0 { + let code = unsafe { GetLastError() }; + if unsafe { IsWindow(h) } == 0 { + return fehler("fenster_weg"); + } + let grund = if code == 5 { "kein_zugriff".to_string() } else { format!("setwindowpos_fehler_{code}") }; + return json!({"ok": false, "rect": jetzt.zu_json(), "versuche": versuche, "grund": grund}); + } + // Asynchron gesetzt: kurz und begrenzt zurueckpruefen. + for _ in 0..NACHLESE_SCHRITTE { + std::thread::sleep(Duration::from_millis(NACHLESE_PAUSE_MS)); + match sichtbar_rect(h) { + Some(r) => jetzt = r, + None => return fehler("fenster_weg"), + } + if jetzt.passt(&ziel, toleranz) { + return json!({"ok": true, "rect": jetzt.zu_json(), "versuche": versuche}); + } + } + // Zweimal dasselbe Ergebnis trotz neuem Setzen: Fenster erzwingt Groesse/Lage. + if vorher == Some(jetzt) { + break; + } + vorher = Some(jetzt); + } + json!({ + "ok": false, + "rect": jetzt.zu_json(), + "versuche": versuche, + "grund": "abweichung_nach_versuchen", + "abweichung": jetzt.abweichung(&ziel), + }) +} + +pub fn vorn(id: u64, aktiv: bool) -> Value { + let h = match pruefe(id) { + Ok(h) => h, + Err(e) => return e, + }; + unsafe { + if aktiv { + if IsIconic(h) != 0 { + ShowWindow(h, SW_RESTORE); + } + // Z-Reihenfolge nach oben, dann Fokus anfordern. + SetWindowPos(h, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_ASYNCWINDOWPOS); + SetForegroundWindow(h); + std::thread::sleep(Duration::from_millis(30)); + let vorn = GetForegroundWindow() == h; + if vorn { + json!({"ok": true, "aktiv": true}) + } else { + json!({"ok": false, "aktiv": false, "grund": "vordergrund_verweigert"}) + } + } else { + if IsIconic(h) != 0 { + ShowWindow(h, SW_SHOWNOACTIVATE); + } + let ok = SetWindowPos(h, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_ASYNCWINDOWPOS); + if ok == 0 { + let code = GetLastError(); + return fehler(if code == 5 { "kein_zugriff".to_string() } else { format!("setwindowpos_fehler_{code}") }); + } + json!({"ok": true, "aktiv": false}) + } + } +} + +unsafe extern "system" fn sammle_monitore(m: HMONITOR, _dc: HDC, _r: *mut RECT, lp: LPARAM) -> BOOL { + let liste = &mut *(lp as *mut Vec); + liste.push(m); + 1 +} + +pub fn arbeitsflaeche(monitor: Option) -> Value { + let mut ms: Vec = Vec::new(); + unsafe { EnumDisplayMonitors(std::ptr::null_mut(), std::ptr::null(), Some(sammle_monitore), &mut ms as *mut Vec as LPARAM) }; + let mut infos = Vec::new(); + for m in ms { + let mut mi: MONITORINFO = unsafe { std::mem::zeroed() }; + mi.cbSize = std::mem::size_of::() as u32; + if unsafe { GetMonitorInfoW(m, &mut mi) } == 0 { + continue; + } + let a = Rect::aus_kanten(mi.rcWork.left, mi.rcWork.top, mi.rcWork.right, mi.rcWork.bottom); + let v = Rect::aus_kanten(mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom); + infos.push((a, v, mi.dwFlags & MONITORINFOF_PRIMARY != 0)); + } + if infos.is_empty() { + return fehler("kein_monitor"); + } + // primaerer Monitor zuerst, damit Index 0 verlaesslich der Hauptmonitor ist + infos.sort_by_key(|i| !i.2); + let liste: Vec = infos + .iter() + .enumerate() + .map(|(i, (a, v, p))| json!({"index": i, "primaer": p, "rect": a.zu_json(), "voll": v.zu_json()})) + .collect(); + let wahl = monitor.unwrap_or(0); + match infos.get(wahl) { + Some((a, _, _)) => json!({"ok": true, "rect": a.zu_json(), "monitor": wahl, "monitore": liste}), + None => json!({"ok": false, "grund": "monitor_unbekannt", "monitore": liste}), + } +} diff --git a/werkzeuge/fensterdienst/tests/echt.rs b/werkzeuge/fensterdienst/tests/echt.rs new file mode 100644 index 00000000..cc3be678 --- /dev/null +++ b/werkzeuge/fensterdienst/tests/echt.rs @@ -0,0 +1,139 @@ +//! Echter Lauf: eigenes Top-Level-Fenster (Mindestgroesse 300x200) als Testziel, +//! das Werkzeug wird als Prozess gestartet (wie spaeter von Python). +#![cfg(windows)] + +use serde_json::{json, Value}; +use std::process::Command; +use std::sync::mpsc; +use windows_sys::Win32::Foundation::{HWND, LPARAM, LRESULT, WPARAM}; +use windows_sys::Win32::System::LibraryLoader::GetModuleHandleW; +use windows_sys::Win32::UI::WindowsAndMessaging::*; + +unsafe extern "system" fn wndproc(h: HWND, m: u32, w: WPARAM, l: LPARAM) -> LRESULT { + if m == WM_GETMINMAXINFO { + let mm = &mut *(l as *mut MINMAXINFO); + mm.ptMinTrackSize.x = 300; + mm.ptMinTrackSize.y = 200; + return 0; + } + if m == WM_DESTROY { + PostQuitMessage(0); + return 0; + } + DefWindowProcW(h, m, w, l) +} + +fn wide(s: &str) -> Vec { + s.encode_utf16().chain(Some(0)).collect() +} + +/// Fenster auf eigenem Thread mit Nachrichtenschleife; liefert HWND, beendet sich bei WM_CLOSE. +fn testfenster(titel: &str) -> (u64, std::thread::JoinHandle<()>) { + let (tx, rx) = mpsc::channel(); + let titel = titel.to_string(); + let th = std::thread::spawn(move || unsafe { + let klasse = wide("FensterdienstTest"); + let wc = WNDCLASSW { + style: 0, + lpfnWndProc: Some(wndproc), + cbClsExtra: 0, + cbWndExtra: 0, + hInstance: GetModuleHandleW(std::ptr::null()), + hIcon: std::ptr::null_mut(), + hCursor: std::ptr::null_mut(), + hbrBackground: std::ptr::null_mut(), + lpszMenuName: std::ptr::null(), + lpszClassName: klasse.as_ptr(), + }; + RegisterClassW(&wc); + let t = wide(&titel); + let h = CreateWindowExW(0, klasse.as_ptr(), t.as_ptr(), WS_OVERLAPPEDWINDOW, 50, 50, 500, 400, + std::ptr::null_mut(), std::ptr::null_mut(), GetModuleHandleW(std::ptr::null()), std::ptr::null()); + ShowWindow(h, SW_SHOWNOACTIVATE); + tx.send(h as usize as u64).unwrap(); + let mut msg: MSG = std::mem::zeroed(); + while GetMessageW(&mut msg, std::ptr::null_mut(), 0, 0) > 0 { + TranslateMessage(&msg); + DispatchMessageW(&msg); + } + }); + (rx.recv().unwrap(), th) +} + +fn dienst(args: &[&str]) -> (Value, i32) { + let aus = Command::new(env!("CARGO_BIN_EXE_fensterdienst")).args(args).output().unwrap(); + let text = String::from_utf8(aus.stdout).unwrap(); + println!("> fensterdienst {}\n{}", args.join(" "), text.trim()); + (serde_json::from_str(text.trim()).expect("JSON-Antwort"), aus.status.code().unwrap_or(-1)) +} + +fn vordergrund() -> usize { + unsafe { GetForegroundWindow() as usize } +} + +#[test] +fn ganzer_ablauf() { + let titel = format!("FD-Test-{}", std::process::id()); + let (id, th) = testfenster(&titel); + let pid = std::process::id(); + + // liste (Filter pid + titel) + let (l, _) = dienst(&["liste", &json!({"pid": pid, "titel_enthaelt": &titel}).to_string()]); + let eintrag = l.as_array().unwrap().iter().find(|e| e["id"] == id).expect("Testfenster in liste"); + assert_eq!(eintrag["pid"], pid); + assert_eq!(eintrag["titel"], titel); + + // setze -> Zurueckgelesen + let ziel = json!({"x": 120, "y": 140, "w": 640, "h": 420}); + let (s, code) = dienst(&["setze", &json!({"id": id, "rect": ziel}).to_string()]); + assert_eq!(code, 0); + assert_eq!(s["ok"], true); + for k in ["x", "y", "w", "h"] { + let d = (s["rect"][k].as_i64().unwrap() - ziel[k].as_i64().unwrap()).abs(); + assert!(d <= 2, "{k} weicht um {d} ab"); + } + // unabhaengig per liste gegenlesen + let (l2, _) = dienst(&["liste", &json!({"titel_enthaelt": &titel}).to_string()]); + assert_eq!(l2[0]["rect"], s["rect"]); + + // idempotent + let (s2, _) = dienst(&["setze", &json!({"id": id, "rect": ziel}).to_string()]); + assert_eq!(s2["ok"], true); + assert_eq!(s2["versuche"], 0); + + // Mindestgroesse wird erzwungen: strukturierte Absage, nicht endlos + let (k, code) = dienst(&["setze", &json!({"id": id, "rect": {"x":120,"y":140,"w":100,"h":80}}).to_string()]); + assert_eq!(code, 1); + assert_eq!(k["ok"], false); + assert_eq!(k["grund"], "abweichung_nach_versuchen"); + assert!(k["versuche"].as_u64().unwrap() <= 5); + assert!(k["rect"]["w"].as_i64().unwrap() >= 300 - 20); + + // vorn ohne Fokusraub + let vor = vordergrund(); + let (v, _) = dienst(&["vorn", &json!({"id": id, "aktiv": false}).to_string()]); + assert_eq!(v["ok"], true); + std::thread::sleep(std::time::Duration::from_millis(100)); + assert_eq!(vordergrund(), vor, "Vordergrund hat sich geaendert"); + + // arbeitsflaeche + let (a, _) = dienst(&["arbeitsflaeche"]); + assert_eq!(a["ok"], true); + assert!(a["rect"]["w"].as_i64().unwrap() > 0); + assert!(!a["monitore"].as_array().unwrap().is_empty()); + let (a9, _) = dienst(&["arbeitsflaeche", r#"{"monitor":99}"#]); + assert_eq!(a9["grund"], "monitor_unbekannt"); + + // Fehlerfaelle + let (u, _) = dienst(&["setze", &json!({"id": 123456789u64, "rect": ziel}).to_string()]); + assert_eq!(u["grund"], "fenster_weg"); + let (e, code) = dienst(&["setze", r#"{"id":1}"#]); + assert_eq!(code, 2); + assert_eq!(e["grund"], "eingabe_ungueltig"); + + // Abraeumen: Fenster schliessen, Thread beenden, dann ist die id weg + unsafe { PostMessageW(id as usize as HWND, WM_CLOSE, 0, 0) }; + th.join().unwrap(); + let (w, _) = dienst(&["setze", &json!({"id": id, "rect": ziel}).to_string()]); + assert_eq!(w["grund"], "fenster_weg"); +}