diff --git a/.gitignore b/.gitignore index ea8c4bf..40d9aca 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +/.idea \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 11ab34d..02b63b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,6 +20,17 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + [[package]] name = "aho-corasick" version = "0.7.18" @@ -189,12 +200,6 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" -[[package]] -name = "bytes" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" - [[package]] name = "calloop" version = "0.9.3" @@ -748,15 +753,6 @@ dependencies = [ "void", ] -[[package]] -name = "encoding_rs" -version = "0.8.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dc8abb250ffdda33912550faa54c88ec8b998dec0b2c55ab224921ce11df" -dependencies = [ - "cfg-if 1.0.0", -] - [[package]] name = "euclid" version = "0.22.6" @@ -792,6 +788,15 @@ dependencies = [ "threadpool", ] +[[package]] +name = "fallible_collections" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52db5973b6a19247baf19b30f41c23a1bfffc2e9ce0a5db2f60e3cd5dc8895f7" +dependencies = [ + "hashbrown 0.11.2", +] + [[package]] name = "fastrand" version = "1.7.0" @@ -966,95 +971,18 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "futures" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" -dependencies = [ - "futures-core", - "futures-sink", -] - [[package]] name = "futures-core" version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" -[[package]] -name = "futures-executor" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" - -[[package]] -name = "futures-macro" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "futures-sink" version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" -[[package]] -name = "futures-task" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" - -[[package]] -name = "futures-util" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - [[package]] name = "generational-arena" version = "0.2.8" @@ -1182,25 +1110,6 @@ dependencies = [ "gl_generator", ] -[[package]] -name = "h2" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9f1f717ddc7b2ba36df7e871fd88db79326551d3d6f1fc406fbfd28b582ff8e" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "half" version = "1.8.2" @@ -1212,6 +1121,9 @@ name = "hashbrown" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash", +] [[package]] name = "hashbrown" @@ -1237,77 +1149,6 @@ dependencies = [ "libc", ] -[[package]] -name = "http" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6" -dependencies = [ - "bytes", - "http", - "pin-project-lite", -] - -[[package]] -name = "httparse" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9100414882e15fb7feccb4897e5f0ff0ff1ca7d1a86a23208ada4d7a18e6c6c4" - -[[package]] -name = "httpdate" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" - -[[package]] -name = "hyper" -version = "0.14.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043f0e083e9901b6cc658a77d1eb86f4fc650bbb977a4337dd63192826aa85dd" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper", - "native-tls", - "tokio", - "tokio-native-tls", -] - [[package]] name = "i-slint-backend-gl" version = "0.2.0" @@ -1513,16 +1354,6 @@ version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d0c0db6c932f8262e0ed8909f2e7f8c0e9b1cfb4da884267ce09a10be54365" -[[package]] -name = "indexmap" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" -dependencies = [ - "autocfg", - "hashbrown 0.11.2", -] - [[package]] name = "inflate" version = "0.4.5" @@ -1544,12 +1375,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "ipnet" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" - [[package]] name = "itertools" version = "0.10.3" @@ -1559,12 +1384,6 @@ dependencies = [ "either", ] -[[package]] -name = "itoa" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" - [[package]] name = "jni-sys" version = "0.3.0" @@ -1595,6 +1414,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "json" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd" + [[package]] name = "khronos_api" version = "3.1.0" @@ -1668,6 +1493,19 @@ dependencies = [ "scopeguard", ] +[[package]] +name = "lodepng" +version = "3.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f84e1fdcdbe8b3f0f9caaadb6b86d0e0647786e993f6ea70686f6837b989ec7" +dependencies = [ + "crc32fast", + "fallible_collections", + "flate2", + "libc", + "rgb", +] + [[package]] name = "log" version = "0.4.14" @@ -1771,12 +1609,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "mime" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" - [[package]] name = "minimal-lexical" version = "0.2.1" @@ -1802,19 +1634,6 @@ dependencies = [ "adler", ] -[[package]] -name = "mio" -version = "0.7.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" -dependencies = [ - "libc", - "log", - "miow", - "ntapi", - "winapi", -] - [[package]] name = "mio" version = "0.8.0" @@ -2320,15 +2139,15 @@ dependencies = [ [[package]] name = "pt-launcher" -version = "0.1.3" +version = "0.1.4" dependencies = [ - "futures", - "image", + "json", + "lodepng", "open", - "reqwest", - "serde", + "rgb", "slint", "slint-build", + "tinyget", "tokio", ] @@ -2446,42 +2265,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "reqwest" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f242f1488a539a79bac6dbe7c8609ae43b7914b7736210f239a37cccb32525" -dependencies = [ - "base64", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper", - "hyper-tls", - "ipnet", - "js-sys", - "lazy_static", - "log", - "mime", - "native-tls", - "percent-encoding", - "pin-project-lite", - "serde", - "serde_json", - "serde_urlencoded", - "tokio", - "tokio-native-tls", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg", -] - [[package]] name = "resvg" version = "0.20.0" @@ -2606,12 +2389,6 @@ dependencies = [ "unicode-script", ] -[[package]] -name = "ryu" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" - [[package]] name = "safe_arch" version = "0.5.2" @@ -2731,43 +2508,6 @@ name = "serde" version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.136" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_urlencoded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" -dependencies = [ - "form_urlencoded", - "itoa", - "ryu", - "serde", -] [[package]] name = "servo-fontconfig" @@ -2809,15 +2549,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "signal-hook-registry" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" -dependencies = [ - "libc", -] - [[package]] name = "simplecss" version = "0.2.1" @@ -2937,16 +2668,6 @@ dependencies = [ "serde", ] -[[package]] -name = "socket2" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "spin" version = "0.9.2" @@ -3128,6 +2849,15 @@ dependencies = [ "safe_arch", ] +[[package]] +name = "tinyget" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0d8b7e0e50b97386327d8d736605b2a352eebe7f8aed72f5172a04e3754e87" +dependencies = [ + "native-tls", +] + [[package]] name = "tinyvec" version = "1.5.1" @@ -3145,21 +2875,13 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.16.1" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c27a64b625de6d309e8c57716ba93021dccf1b3b5c97edd6d3dd2d2135afc0a" +checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee" dependencies = [ - "bytes", - "libc", - "memchr", - "mio 0.7.14", "num_cpus", - "once_cell", - "parking_lot", "pin-project-lite", - "signal-hook-registry", "tokio-macros", - "winapi", ] [[package]] @@ -3173,30 +2895,6 @@ dependencies = [ "syn", ] -[[package]] -name = "tokio-native-tls" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" -dependencies = [ - "native-tls", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e99e1983e5d376cd8eb4b66604d2e99e79f5bd988c3055891dcd8c9e2604cc0" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "log", - "pin-project-lite", - "tokio", -] - [[package]] name = "toml" version = "0.5.8" @@ -3206,38 +2904,6 @@ dependencies = [ "serde", ] -[[package]] -name = "tower-service" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" - -[[package]] -name = "tracing" -version = "0.1.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d8d93354fe2a8e50d5953f5ae2e47a3fc2ef03292e7ea46e3cc38f549525fb9" -dependencies = [ - "cfg-if 1.0.0", - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03cfcb51380632a72d3111cb8d3447a8d908e577d31beeac006f836383d29a23" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "try-lock" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" - [[package]] name = "ttf-parser" version = "0.12.3" @@ -3419,16 +3085,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "want" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" -dependencies = [ - "log", - "try-lock", -] - [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" @@ -3460,18 +3116,6 @@ dependencies = [ "wasm-bindgen-shared", ] -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb6ec270a31b1d3c7e266b999739109abce8b6c87e4b31fcfcd788b65267395" -dependencies = [ - "cfg-if 1.0.0", - "js-sys", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "wasm-bindgen-macro" version = "0.2.79" @@ -3647,7 +3291,7 @@ dependencies = [ "lazy_static", "libc", "log", - "mio 0.8.0", + "mio", "ndk", "ndk-glue", "ndk-sys", @@ -3664,15 +3308,6 @@ dependencies = [ "x11-dl", ] -[[package]] -name = "winreg" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" -dependencies = [ - "winapi", -] - [[package]] name = "wio" version = "0.2.2" diff --git a/Cargo.toml b/Cargo.toml index 48eb415..8dd30af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,16 +1,16 @@ [package] name = "pt-launcher" -version = "0.1.3" +version = "0.1.4" edition = "2021" [dependencies] -slint = "0.2.0" +slint = { version = "0.2.0", features = ["std", "backend-qt"] } open = "2.0.3" -futures = "0.3.21" -image = "0.24.0" -reqwest = { version = "0.11.9", features = ["json"] } -tokio = { version = "1.16.1", features = ["full"] } -serde = { version = "1.0.136", features = ["derive"] } +tinyget = { version = "1.0.1", features = ["https"] } +json = "0.12.4" +lodepng = "3.6.1" +rgb = "0.8.31" +tokio = { version = "1.17.0", features = ["rt", "macros", "rt-multi-thread"] } [build-dependencies] slint-build = "0.2.0" diff --git a/src/assets/account-group.svg b/src/assets/account-group.svg index af9d809..89b69d8 100644 --- a/src/assets/account-group.svg +++ b/src/assets/account-group.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/archive.svg b/src/assets/archive.svg index d85c9bc..c994dcd 100644 --- a/src/assets/archive.svg +++ b/src/assets/archive.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/avatar.png b/src/assets/avatar.png index ca4fec7..c35f312 100644 Binary files a/src/assets/avatar.png and b/src/assets/avatar.png differ diff --git a/src/assets/bell.svg b/src/assets/bell.svg index 0055056..a3503fb 100644 --- a/src/assets/bell.svg +++ b/src/assets/bell.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/ch.svg b/src/assets/ch.svg new file mode 100644 index 0000000..bda132a --- /dev/null +++ b/src/assets/ch.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cloud-download.svg b/src/assets/cloud-download.svg index acfd1f0..89cc0e0 100644 --- a/src/assets/cloud-download.svg +++ b/src/assets/cloud-download.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/cog.svg b/src/assets/cog.svg index 731a5a7..88d5750 100644 --- a/src/assets/cog.svg +++ b/src/assets/cog.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/de.png b/src/assets/de.png deleted file mode 100644 index 64f9777..0000000 Binary files a/src/assets/de.png and /dev/null differ diff --git a/src/assets/de.svg b/src/assets/de.svg new file mode 100644 index 0000000..650cfc2 --- /dev/null +++ b/src/assets/de.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/devlog.jpg b/src/assets/devlog.jpg deleted file mode 100644 index afaf37b..0000000 Binary files a/src/assets/devlog.jpg and /dev/null differ diff --git a/src/assets/logo.svg b/src/assets/logo.svg index bf2ecd4..d542088 100644 --- a/src/assets/logo.svg +++ b/src/assets/logo.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/logout.svg b/src/assets/logout.svg index 71cdbf6..4283990 100644 --- a/src/assets/logout.svg +++ b/src/assets/logout.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/newspaper.svg b/src/assets/newspaper.svg index 629d548..9213b43 100644 --- a/src/assets/newspaper.svg +++ b/src/assets/newspaper.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/pl.png b/src/assets/pl.png deleted file mode 100644 index 545b53c..0000000 Binary files a/src/assets/pl.png and /dev/null differ diff --git a/src/assets/pl.svg b/src/assets/pl.svg new file mode 100644 index 0000000..6dcbffc --- /dev/null +++ b/src/assets/pl.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/play-circle.svg b/src/assets/play-circle.svg index 9835bb8..3465c17 100644 --- a/src/assets/play-circle.svg +++ b/src/assets/play-circle.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/ru.png b/src/assets/ru.png deleted file mode 100644 index c96471b..0000000 Binary files a/src/assets/ru.png and /dev/null differ diff --git a/src/assets/ru.svg b/src/assets/ru.svg new file mode 100644 index 0000000..b0d67fc --- /dev/null +++ b/src/assets/ru.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/us.png b/src/assets/us.png deleted file mode 100644 index 160895b..0000000 Binary files a/src/assets/us.png and /dev/null differ diff --git a/src/assets/us.svg b/src/assets/us.svg new file mode 100644 index 0000000..4a6f2df --- /dev/null +++ b/src/assets/us.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 22b36b6..04512fd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,30 +1,22 @@ -use image; -use image::GenericImageView; +use lodepng::decode32; +use rgb::ComponentBytes; +use slint::{Image, SharedPixelBuffer}; -pub async fn load_img(url: &str) -> (Vec, u32, u32) { - let resp = reqwest::get(url).await.unwrap(); - let img = image::load_from_memory(resp.bytes().await.unwrap().as_ref()).unwrap(); - let (w, h) = img.dimensions(); - (img.as_bytes().to_vec(), w, h) +pub mod post; + +pub async fn load_img(url: &str) -> (Vec, usize, usize) { + let resp = tinyget::get(url).send().unwrap(); + let bytes = resp.as_bytes(); + let img = decode32(bytes).unwrap(); + (img.buffer.as_bytes().to_vec(), img.width, img.height) } -pub fn parse_img(img_bytes: Vec, w: u32, h: u32) -> slint::Image { - let mut pixel_buffer = slint::SharedPixelBuffer::new(w, h); +pub fn parse_img(img_bytes: Vec, w: usize, h: usize) -> Image { + let mut pixel_buffer = SharedPixelBuffer::new(w as u32, h as u32); let bytes = pixel_buffer.make_mut_bytes(); - - // print!("w * h: {0}\n", w * h); - // print!("img_bytes: {0}\n", img_bytes.len()); - // print!("bytes: {0}\n", bytes.len()); - // print!("\n"); - for i in 0..img_bytes.len() { - // Index out of bounds check - // if i >= bytes.len() || i >= img_bytes.len() { - // break; - // } - bytes[i] = img_bytes[i]; } - slint::Image::from_rgba8(pixel_buffer) + Image::from_rgba8(pixel_buffer) } diff --git a/src/main.rs b/src/main.rs index a4569da..e2190d1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,107 +1,55 @@ slint::slint!(import { MainWindow } from "src/ui/main.slint";); slint::slint!(import { NewsData } from "src/ui/newsdata.slint";); -//use std::collections::HashMap; -use pt_launcher::{load_img, parse_img}; -use serde::Deserialize; +use pt_launcher::{parse_img, post::Post}; use slint::SharedString; -use std::time::Duration; - -#[derive(Debug, Deserialize)] -struct DiscussionsIncludesAttributes { - featuredImage : String, -} - -#[derive(Debug, Deserialize)] -struct DiscussionsIncludes { - id : String, - attributes : DiscussionsIncludesAttributes, -} - -#[derive(Debug, Deserialize)] -struct DiscussionsDataAttributes { - title : String, - shareUrl : String, -} - -#[derive(Debug, Deserialize)] -struct DiscussionsData { - id : String, - attributes : DiscussionsDataAttributes, -} - -#[derive(Debug, Deserialize)] -struct Discussions { - data : Vec, - included : Vec -} - -struct Discussion { - title : String, - image_buffer : Vec, - width: u32, - height: u32 -} #[tokio::main] -async fn main() -> Result<(), Box> { +async fn main() { let main_window = MainWindow::new(); let handle_weak = main_window.as_weak(); - let mut discussions: Vec = vec![]; - main_window.on_blog_redirect({ - move || { - open::that("https://project-trains.pl/").unwrap(); - } + main_window.on_url_redirect(move |url| { + open::that(url.as_str()).unwrap(); }); - main_window.on_close({ - move || { - std::process::exit(0); - } + main_window.on_close(move || { + std::process::exit(0); }); tokio::spawn(async move { - // delay for testing - std::thread::sleep(Duration::new(2, 0)); - - let disc_resp = reqwest::get("https://project-trains.pl/api/discussions?include=blogMeta&filter[q]=is:blog+tag:devlogi&sort=-createdAt").await; - let disc_json = disc_resp.unwrap().json::().await.unwrap(); - println!("{:#?}", disc_json); - - for i in 0..disc_json.data.len() { - let img_url : &str = &disc_json.included[i].attributes.featuredImage; - let (img_buffer, w, h) = load_img(img_url).await; - // let (img_buffer, w, h) = load_img("https://picsum.photos/800/450").await; + let json = Post::fetch(); + let posts = Post::parse_posts(&json); + update_discussions(handle_weak.clone(), posts); - let disc = Discussion { - title: disc_json.data[i].attributes.title.clone(), - image_buffer: img_buffer, - width: w, - height: h - }; + let mut posts = Post::parse_posts(&json); + posts = Post::load_feature_image(posts).await; - discussions.push(disc); - } + update_discussions(handle_weak.clone(), posts); - update_discussions(handle_weak.clone(), discussions); + let mut posts = Post::parse_posts(&json); + posts = Post::load_images(posts).await; - let (img, w, h) = load_img("https://picsum.photos/800/450").await; - update_featured(handle_weak.clone(), img, w, h); + update_discussions(handle_weak.clone(), posts); }); main_window.run(); - Ok(()) } -fn update_discussions(handle: slint::Weak, discussions: Vec) { +fn update_discussions(handle: slint::Weak, posts: Vec) { handle.upgrade_in_event_loop(move |handle| { let mut news_data: Vec = vec![]; - for i in 0..discussions.len() { + for i in 0..posts.len() { let news = NewsData { - title: SharedString::from(discussions[i].title.clone()), - cover: parse_img(discussions[i].image_buffer.to_vec(), discussions[i].width, discussions[i].height) + title: SharedString::from(posts[i].title.clone()), + excerpt: SharedString::from(posts[i].excerpt.clone()), + cover: parse_img( + posts[i].image_buffer.to_vec(), + posts[i].width, + posts[i].height, + ), + url: SharedString::from(posts[i].url.clone()), }; news_data.push(news); @@ -111,10 +59,3 @@ fn update_discussions(handle: slint::Weak, discussions: Vec, image: Vec, w: u32, h: u32) { - handle.upgrade_in_event_loop(move |handle| { - let img = parse_img(image, w, h); - handle.set_featured(img); - }); -} \ No newline at end of file diff --git a/src/post.rs b/src/post.rs new file mode 100644 index 0000000..56c38d4 --- /dev/null +++ b/src/post.rs @@ -0,0 +1,98 @@ +use json::JsonValue; +use crate::load_img; + +const URL: &str = "https://project-trains.pl/api/discussions?include=blogMeta&filter[q]=is:blog+tag:devlogi&sort=-createdAt"; + +pub struct Post { + pub title: String, + pub url: String, + pub excerpt: String, + pub image_url: String, + pub image_buffer: Vec, + pub width: usize, + pub height: usize, +} + +impl Post { + fn new( + title: Option<&str>, + excerpt: Option<&str>, + url: Option<&str>, + image_url: Option<&str>, + image_buffer: Vec, + width: usize, + height: usize, + ) -> Self { + Post { + title: Self::get_string(title), + excerpt: Self::get_string(excerpt), + url: Self::get_string(url), + image_url: Self::get_string(image_url), + image_buffer, + width, + height, + } + } + + pub fn get_string(option: Option<&str>) -> String { + match option { + Some(v) => v.to_string(), + None => String::new(), + } + } + + pub fn fetch() -> JsonValue { + let res = tinyget::get(URL).send().unwrap(); + let json = json::parse(res.as_str().unwrap()).unwrap(); + json + } + + pub fn parse_posts(json: &JsonValue) -> Vec { + let mut posts: Vec = vec![]; + + for i in 0..json["data"].len() { + let data = &json["data"][i]["attributes"]; + let included = &json["included"][i]["attributes"]; + + let post = Post::new( + data["title"].as_str(), + included["summary"].as_str(), + data["shareUrl"].as_str(), + included["featuredImage"].as_str(), + vec![0, 0], + 1, + 1, + ); + + posts.push(post); + } + + posts + } + + pub async fn load_feature_image(posts: Vec) -> Vec { + let mut posts = posts; + let img_url: String = posts[0].image_url.clone(); + let (img_buffer, w, h) = load_img(img_url.as_str()).await; + + posts[0].image_buffer = img_buffer; + posts[0].width = w; + posts[0].height = h; + + posts + } + + pub async fn load_images(posts: Vec) -> Vec { + let mut posts = posts; + for i in 0..posts.len() { + let img_url: String = posts[i].image_url.clone(); + let (img_buffer, w, h) = load_img(img_url.as_str()).await; + + posts[i].image_buffer = img_buffer; + posts[i].width = w; + posts[i].height = h; + } + + posts + } +} diff --git a/src/ui/home.slint b/src/ui/home.slint index df7f820..da411e2 100644 --- a/src/ui/home.slint +++ b/src/ui/home.slint @@ -1,4 +1,5 @@ import { TopBar } from "./topbar.slint"; +import { NewsData } from "./newsdata.slint"; ServerTile := Rectangle { property server-name; @@ -50,22 +51,27 @@ ServerTile := Rectangle { } Home := Rectangle { + property featured-data; + + callback forum-button-clicked(); + callback featured-button-clicked(string); + background: #12171d; vertical-stretch: 1; horizontal-stretch: 1; - callback forum-button-clicked(); - property featured-image; - VerticalLayout { padding-left: 20phx; padding-right: 20phx; + TopBar { forum-click() => { root.forum-button-clicked() } } + Rectangle { height: 15phx; } + Text { text: "Wybierz serwer, na który chcesz dołączyć"; color: #ffffff; @@ -79,19 +85,19 @@ Home := Rectangle { ServerTile { server-name: "Serwer PL"; - flag-path: @image-url("../assets/pl.png"); + flag-path: @image-url("../assets/pl.svg"); } ServerTile { server-name: "Serwer DE"; - flag-path: @image-url("../assets/de.png"); + flag-path: @image-url("../assets/de.svg"); } ServerTile { server-name: "Serwer RU"; - flag-path: @image-url("../assets/ru.png"); + flag-path: @image-url("../assets/ru.svg"); } ServerTile { - server-name: "Serwer US"; - flag-path: @image-url("../assets/us.png"); + server-name: "Serwer CH"; + flag-path: @image-url("../assets/ch.svg"); } } Text { @@ -100,6 +106,7 @@ Home := Rectangle { font-size: 15phx; font-weight: 800; } + Rectangle { height: 15phx; } Rectangle { @@ -110,47 +117,69 @@ Home := Rectangle { drop-shadow-color: #0000006e; drop-shadow-blur: 12phx; clip: true; - Image { - source: featured-image; - image-fit: cover; - height: parent.height; - width: parent.width; - } - Rectangle { - height: parent.height; - width: parent.width; - background: @linear-gradient(0deg, #171b20dc 0%, transparent 95%); - } - VerticalLayout { - padding: 16phx; - spacing: 4phx; - Rectangle { - vertical-stretch: 1; - } - Text { - text: "Najnowszy"; - color: #ffffff; - font-size: 16phx; + ta := TouchArea { + mouse-cursor: pointer; + clicked => { + root.featured-button-clicked(featured-data.url); } - Text { - text: "Devlog #3 - Nowy User Interface gry"; - color: #ffffff; - font-size: 32phx; - font-weight: 800; - overflow: TextOverflow.elide; - } - Rectangle { - vertical-stretch: 0; + + Image { + source: featured-data.cover; + image-fit: cover; + height: parent.height; + width: parent.width; } - Text { - text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."; - color: #ffffff; - font-size: 15phx; - wrap: word-wrap; + Rectangle { + height: parent.height; + width: parent.width; + background: @linear-gradient(0deg, ta.has-hover ? #171b208d : #171b20dc 0%, transparent 95%); } - Rectangle { - vertical-stretch: 0; + VerticalLayout { + padding: 22phx; + spacing: 4phx; + + Rectangle { + vertical-stretch: 1; + } + HorizontalLayout { + alignment: start; + Text { + text: "Najnowszy"; + color: #ffffff; + font-size: 16phx; + } + + Rectangle { + Rectangle { + width: 9phx; + height: 9phx; + x: 5phx; + y: 4phx; + border-radius: 5phx; + background: #45cc58; + } + } + } + Text { + text: featured-data.title; + color: #ffffff; + font-size: 32phx; + font-weight: 800; + overflow: TextOverflow.elide; + } + Rectangle { + vertical-stretch: 0; + } + Text { + text: featured-data.excerpt; + color: #ffffff; + font-size: 15phx; + wrap: word-wrap; + } + Rectangle { + vertical-stretch: 0; + } } } } diff --git a/src/ui/main.slint b/src/ui/main.slint index 250761e..5841eb1 100644 --- a/src/ui/main.slint +++ b/src/ui/main.slint @@ -8,8 +8,8 @@ import { Credits } from "./credits.slint"; MainWindow := Window { property tab: 0; + property forum_url: "https://project-trains.pl/"; property <[NewsData]> news: []; - property featured; title: "Project Trains - Launcher"; background: #12171d; @@ -20,7 +20,7 @@ MainWindow := Window { preferred-width: 1000phx; preferred-height: 650phx; - callback blog-redirect(); + callback url-redirect(string); callback close(); HorizontalLayout { @@ -35,36 +35,43 @@ MainWindow := Window { } } if tab == 0: Home { - featured-image: root.featured; + featured-data: root.news[0]; + forum-button-clicked() => { - root.blog-redirect(); + root.url-redirect(forum_url); + } + featured-button-clicked(featured_url) => { + root.url-redirect(featured_url); } } if tab == 1: Home { forum-button-clicked() => { - root.blog-redirect(); + root.url-redirect(forum_url); } } if tab == 2: News { - news : root.news; + news: root.news; forum-button-clicked() => { - root.blog-redirect(); + root.url-redirect(forum_url); + } + news-button-clicked(url) => { + root.url-redirect(url); } } if tab == 3: Market { forum-button-clicked() => { - root.blog-redirect(); + root.url-redirect(forum_url); } } if tab == 4: Settings { forum-button-clicked() => { - root.blog-redirect(); + root.url-redirect(forum_url); } } if tab == 5: Credits { forum-button-clicked() => { - root.blog-redirect(); + root.url-redirect(forum_url); } } } diff --git a/src/ui/menu.slint b/src/ui/menu.slint index 636b11a..89ab634 100644 --- a/src/ui/menu.slint +++ b/src/ui/menu.slint @@ -8,6 +8,7 @@ MenuButton := Rectangle { callback menu-clicked; ta := TouchArea { + mouse-cursor: pointer; clicked => { root.menu-clicked() } @@ -120,6 +121,7 @@ Menu := Rectangle { quit-ta := TouchArea { width: 260phx; height: 46phx; + mouse-cursor: pointer; clicked => { root.quit-launcher() diff --git a/src/ui/news.slint b/src/ui/news.slint index ac3f375..b779b0d 100644 --- a/src/ui/news.slint +++ b/src/ui/news.slint @@ -4,12 +4,21 @@ import { NewsData } from "./newsdata.slint"; Item := Rectangle { property title; property image; - height: 150phx; + + callback news-clicked(); + + height: 170phx; + preferred-width: 800phx; ta := TouchArea { + mouse-cursor: pointer; + clicked => { + root.news-clicked() + } + Rectangle { border-radius: 12phx; - height: 135phx; + height: parent.height - 15phx; width: parent.width; clip: true; @@ -43,28 +52,37 @@ Item := Rectangle { News := Rectangle { property <[NewsData]> news; background: #12171d; + vertical-stretch: 1; + horizontal-stretch: 1; clip: true; callback forum-button-clicked(); + callback news-button-clicked(string); VerticalLayout { padding-left: 20phx; padding-right: 20phx; + TopBar { forum-click() => { - root.forum-button-clicked() + root.forum-button-clicked(); } } Rectangle { height: 15phx; } - VerticalLayout { - Flickable { + Flickable { + HorizontalLayout { + alignment: center; VerticalLayout { for data[i] in root.news : Item { title: data.title; image: data.cover; + + news-clicked() => { + root.news-button-clicked(data.url); + } } } } - } + } } } \ No newline at end of file diff --git a/src/ui/newsdata.slint b/src/ui/newsdata.slint index 9311b4a..82c975e 100644 --- a/src/ui/newsdata.slint +++ b/src/ui/newsdata.slint @@ -1,4 +1,6 @@ export struct NewsData := { title : string, - cover : image + excerpt : string, + cover : image, + url : string } diff --git a/src/ui/topbar.slint b/src/ui/topbar.slint index f06a3fe..874bdd2 100644 --- a/src/ui/topbar.slint +++ b/src/ui/topbar.slint @@ -7,6 +7,7 @@ InstallButton := Rectangle { installButton := TouchArea { height: parent.height; width: parent.width; + mouse-cursor: pointer; clicked => { root.install-click() @@ -83,6 +84,7 @@ TopBar := Rectangle { y: 12phx; height: parent.height; width: parent.width; + mouse-cursor: pointer; clicked => { root.forum-click()