diff --git a/.github/dependabot.yml b/.github/dependabot.yml index ee0db1a..904ae72 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,4 +4,4 @@ updates: directory: "/" target-branch: "dev" schedule: - interval: "weekly" + interval: "daily" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 419efd9..0bb5747 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,9 +13,15 @@ jobs: ubuntu_build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install Dependencies run: sudo apt-get install -y libgtk-3-dev libsoup2.4-dev libjavascriptcoregtk-4.0-dev libwebkit2gtk-4.0-dev + - name: Switch to nightly + run: rustup default nightly + - name: Install Clippy + run: rustup component add clippy + - name: Clippy + run: cargo clippy - name: Build run: cargo build - name: Test @@ -24,7 +30,13 @@ jobs: windows_build: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - name: Switch to nightly + run: rustup default nightly + - name: Install Clippy + run: rustup component add clippy + - name: Clippy + run: cargo clippy - name: Build run: cargo build - name: Test @@ -33,7 +45,13 @@ jobs: macos_build: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - name: Switch to nightly + run: rustup default nightly + - name: Install Clippy + run: rustup component add clippy + - name: Clippy + run: cargo clippy - name: Build run: cargo build - name: Test diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f351df7..f137b14 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Login run: cargo login ${{ secrets.CRATES_IO_TOKEN }} - name: Install Dependencies diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7865eb6..9e2d9e3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1 +1 @@ -If you're in this deep and haven't understood that this is satire and a joke, please read again. In general, I don't really need help because nobody will actually use this. However, if you are feeling really quirky today you can add some additional trolls or fix existing ones because they're actually not that well programmed. Be aware though: Many terrible grammar, code style and consistency choices were made on purpose. I will not accept your PR if you report those. +If you're in this deep and haven't understood that this is satire and a joke, please read again. In general, I don't really need help because nobody will actually use this. However, if you are feeling really quirky today you can add some additional trolls or fix existing ones because they're actually not that well programmed. Be aware though: Many terrible grammar, code style and consistency choices were made on purpose. I will not accept your PR if you report those. If you're wondering, what the motivation for this project is/was, read [this](MOTIVATION.md) diff --git a/Cargo.lock b/Cargo.lock old mode 100755 new mode 100644 index 3a97240..5fc9920 --- a/Cargo.lock +++ b/Cargo.lock @@ -72,9 +72,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2faccea4cc4ab4a667ce676a30e8ec13922a692c99bb8f5b11f1502c72e04220" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" @@ -137,6 +137,12 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +[[package]] +name = "ascii" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" + [[package]] name = "async-broadcast" version = "0.5.1" @@ -372,7 +378,7 @@ dependencies = [ [[package]] name = "badlang" -version = "0.3.1" +version = "0.3.3" dependencies = [ "argon2", "clap", @@ -385,7 +391,9 @@ dependencies = [ "humansize", "indicatif", "inquire", + "jod-thread", "local-ip-address", + "native-dialog", "notify-rust", "open", "rand 0.8.5", @@ -709,8 +717,24 @@ dependencies = [ "block", "cocoa-foundation", "core-foundation", - "core-graphics", - "foreign-types", + "core-graphics 0.22.3", + "foreign-types 0.3.2", + "libc", + "objc", +] + +[[package]] +name = "cocoa" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6140449f97a6e97f9511815c5632d84c8aacf8ac271ad77c559218161a1373c" +dependencies = [ + "bitflags 1.3.2", + "block", + "cocoa-foundation", + "core-foundation", + "core-graphics 0.23.1", + "foreign-types 0.5.0", "libc", "objc", ] @@ -814,7 +838,20 @@ dependencies = [ "bitflags 1.3.2", "core-foundation", "core-graphics-types", - "foreign-types", + "foreign-types 0.3.2", + "libc", +] + +[[package]] +name = "core-graphics" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "970a29baf4110c26fedbc7f82107d42c23f7e88e404c4577ed73fe99ff85a212" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "core-graphics-types", + "foreign-types 0.5.0", "libc", ] @@ -1302,7 +1339,28 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" dependencies = [ - "foreign-types-shared", + "foreign-types-shared 0.1.1", +] + +[[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 0.3.1", +] + +[[package]] +name = "foreign-types-macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", ] [[package]] @@ -1311,6 +1369,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" +[[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.1" @@ -1837,9 +1901,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" [[package]] name = "hex" @@ -1967,9 +2031,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.59" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -2188,6 +2252,15 @@ dependencies = [ "waker-fn", ] +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "0.4.8" @@ -2243,6 +2316,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" +[[package]] +name = "jod-thread" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b23360e99b8717f20aaa4598f5a6541efbe30630039fbc7706cf954a87947ae" + [[package]] name = "js-sys" version = "0.3.67" @@ -2479,11 +2558,17 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[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.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", "simd-adler32", @@ -2501,6 +2586,29 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "native-dialog" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84e7038885d2aeab236bd60da9e159a5967b47cde3292da3b15ff1bec27c039f" +dependencies = [ + "ascii", + "block", + "cocoa 0.25.0", + "core-foundation", + "dirs-next", + "objc", + "objc-foundation", + "objc_id", + "once_cell", + "raw-window-handle", + "thiserror", + "versions", + "wfd", + "which", + "winapi", +] + [[package]] name = "native-tls" version = "0.2.11" @@ -2605,6 +2713,16 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" +[[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 = "notify-rust" version = "4.10.0" @@ -2786,7 +2904,7 @@ checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" dependencies = [ "bitflags 2.4.2", "cfg-if", - "foreign-types", + "foreign-types 0.3.2", "libc", "once_cell", "openssl-macros", @@ -3545,9 +3663,9 @@ dependencies = [ [[package]] name = "savefile" -version = "0.16.4" +version = "0.16.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e5dc7c89e125f74cb67784646819ad63c9522aa39185f4883b6f88e825d8b7" +checksum = "4b0066dc64379049384fd7b26358f92316e95c95a079af5c8cd02b1a1b62efd4" dependencies = [ "arrayvec", "bit-set", @@ -3562,9 +3680,9 @@ dependencies = [ [[package]] name = "savefile-derive" -version = "0.16.4" +version = "0.16.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a4c5bd5525edb4cb83fb0febff5aee308053554a765a745856bd59c65d573f" +checksum = "2c624cb24aceeeff8b993f54dec710e0a9ef06e71ad3841b4dd711be542263ff" dependencies = [ "proc-macro2", "quote", @@ -3997,9 +4115,9 @@ checksum = "723b93e8addf9aa965ebe2d11da6d7540fa2283fcea14b3371ff055f7ba13f5f" [[package]] name = "strum_macros" -version = "0.25.3" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +checksum = "7a3417fc93d76740d974a01654a09777cb500428cc874ca9f45edfe0c4d4cd18" dependencies = [ "heck 0.4.1", "proc-macro2", @@ -4098,9 +4216,9 @@ dependencies = [ "bitflags 1.3.2", "cairo-rs", "cc", - "cocoa", + "cocoa 0.24.1", "core-foundation", - "core-graphics", + "core-graphics 0.22.3", "crossbeam-channel", "dispatch", "gdk", @@ -4171,7 +4289,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd27c04b9543776a972c86ccf70660b517ecabbeced9fb58d8b961a13ad129af" dependencies = [ "anyhow", - "cocoa", + "cocoa 0.24.1", "dirs-next", "embed_plist", "encoding_rs", @@ -4294,7 +4412,7 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6cae61fbc731f690a4899681c9052dde6d05b159b44563ace8186fc1bfb7d158" dependencies = [ - "cocoa", + "cocoa 0.24.1", "gtk", "percent-encoding", "rand 0.8.5", @@ -4360,13 +4478,12 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.9.0" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" dependencies = [ "cfg-if", "fastrand 2.0.1", - "redox_syscall", "rustix 0.38.31", "windows-sys 0.52.0", ] @@ -4420,9 +4537,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.32" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe80ced77cbfb4cb91a94bf72b378b4b6791a0d9b7f09d0be747d1bdff4e68bd" +checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" dependencies = [ "deranged", "itoa 1.0.10", @@ -4652,9 +4769,9 @@ dependencies = [ [[package]] name = "treediff" -version = "4.0.2" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52984d277bdf2a751072b5df30ec0377febdb02f7696d64c2d7d54630bac4303" +checksum = "4d127780145176e2b5d16611cc25a900150e86e9fd79d3bde6ff3a37359c9cb5" dependencies = [ "serde_json", ] @@ -4784,6 +4901,16 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "versions" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c73a36bc44e3039f51fbee93e39f41225f6b17b380eb70cc2aab942df06b34dd" +dependencies = [ + "itertools", + "nom", +] + [[package]] name = "vswhom" version = "0.1.0" @@ -5002,6 +5129,28 @@ dependencies = [ "windows-metadata", ] +[[package]] +name = "wfd" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e713040b67aae5bf1a0ae3e1ebba8cc29ab2b90da9aa1bff6e09031a8a41d7a8" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix 0.38.31", +] + [[package]] name = "winapi" version = "0.3.9" @@ -5324,8 +5473,8 @@ checksum = "6ad85d0e067359e409fcb88903c3eac817c392e5d638258abfb3da5ad8ba6fc4" dependencies = [ "base64 0.13.1", "block", - "cocoa", - "core-graphics", + "cocoa 0.24.1", + "core-graphics 0.22.3", "crossbeam-channel", "dunce", "gdk", @@ -5388,19 +5537,19 @@ dependencies = [ [[package]] name = "xdg-home" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2769203cd13a0c6015d515be729c526d041e9cf2c0cc478d57faee85f40c6dcd" +checksum = "21e5a325c3cb8398ad6cf859c1135b25dd29e186679cf2da7581d9679f63b38e" dependencies = [ - "nix", + "libc", "winapi", ] [[package]] name = "zbus" -version = "3.14.1" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31de390a2d872e4cd04edd71b425e29853f786dc99317ed72d73d6fcf5ebb948" +checksum = "c45d06ae3b0f9ba1fb2671268b975557d8f5a84bb5ec6e43964f87e763d8bca8" dependencies = [ "async-broadcast", "async-executor", @@ -5439,9 +5588,9 @@ dependencies = [ [[package]] name = "zbus_macros" -version = "3.14.1" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d1794a946878c0e807f55a397187c11fc7a038ba5d868e7db4f3bd7760bc9d" +checksum = "b4a1ba45ed0ad344b85a2bb5a1fe9830aed23d67812ea39a586e7d0136439c7d" dependencies = [ "proc-macro-crate", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 100a7e6..9fe27f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "badlang" -version = "0.3.2" +version = "0.3.3" authors = ["Gian Zellweger *Real age redacted for privacy reasons and out of laziness of having to update it every year. And yes, I am indeed one person who is driving everything behind this project. + +**Whether that is a good concept or not will not be tackled in this document. diff --git a/README.md b/README.md index 573ffd7..84724af 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,10 @@ [![Crates.io Version](https://img.shields.io/crates/v/badlang)](https://crates.io/crates/badlang) [![Fortnite Balls](https://img.shields.io/badge/Balls-a?logo=Rust&label=Fortnite)](https://youtu.be/dQw4w9WgXcQ) [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fgianzellweger%2Fbadlang%2Fbadge%3Fref%3Drelease&style=flat)](https://actions-badge.atrox.dev/gianzellweger/badlang/goto?ref=release) +[![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/badlang_dev?style=flat&logo=twitter)](https://x.com/badlang_dev) +[![Instagram URL](https://img.shields.io/twitter/url?url=https%3A%2F%2Finstagram.com%2Fbadlang_dev&style=flat&logo=instagram&label=Follow%20%40badlang_dev)](https://instagram.com/badlang_dev) + + BadLang™ Logo @@ -29,7 +33,7 @@ This revolutionary blazingly fast example shows the grace of stack-based program ### Hello world -See [this file](https://github.com/gianzellweger/badlang/blob/release/examples/hello.bl). +See [this file](./examples/hello.bl). --- diff --git a/src/main.rs b/src/main.rs index 478a26f..97ce3e6 100755 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ #![feature(let_chains)] -// #![feature(panic_backtrace_config)] #![feature(if_let_guard)] #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] #![forbid(unsafe_code)] @@ -12,6 +11,7 @@ #![allow(clippy::cast_precision_loss)] #![allow(clippy::cast_possible_truncation)] #![allow(clippy::cast_sign_loss)] +#![allow(clippy::cast_possible_wrap)] use core::str; use std::{ @@ -294,8 +294,9 @@ impl Distribution for rand::distributions::Standard { } #[cfg(any(target_os = "linux", target_os = "windows"))] +#[allow(clippy::needless_pass_by_value)] #[tauri::command] -fn tauri_handler(window: tauri::Window) -> Result<(), String> { +fn tauri_handler(window: tauri::Window) { static VELOCITY: std::sync::Mutex<(i32, i32)> = std::sync::Mutex::new((20, 20)); static POSITION: std::sync::Mutex<(i32, i32)> = std::sync::Mutex::new((0, 0)); @@ -304,11 +305,10 @@ fn tauri_handler(window: tauri::Window) -> Result<(), Stri .ok() .flatten() .map(|monitor| *monitor.size()) - .map(|pos| (pos.height as i32, pos.width as i32)) - .unwrap_or((1920, 1080)); + .map_or((1920, 1080), |pos| (pos.height as i32, pos.width as i32)); - let mut position = POSITION.lock().unwrap(); - let mut velocity = VELOCITY.lock().unwrap(); + let mut position = POSITION.lock().expect("Unreachable"); + let mut velocity = VELOCITY.lock().expect("Unreachable"); if position.0 > screen_x || position.0 < 0 { velocity.0 = -velocity.0; } @@ -318,14 +318,15 @@ fn tauri_handler(window: tauri::Window) -> Result<(), Stri position.0 += velocity.0; position.1 += velocity.1; + drop(velocity); let _ = window.set_position(tauri::Position::Physical((*position).into())); + drop(position); let _ = window.set_focus(); - Ok(()) } -#[derive(Savefile)] +#[derive(Savefile, Clone, Debug)] struct Account { name: String, // Yes I am actually taking a programming account (that doesn't do anything) serious enough to actually use encryption. @@ -334,11 +335,12 @@ struct Account { google_auth_secret: String, } -#[derive(Savefile)] +#[derive(Savefile, Clone, Debug, Default)] struct SaveData { - account: Option, - runs_so_far: usize, - last_update: u64, // This is in seconds since UNIX_EPOCH + account: Option, + runs_so_far: usize, + last_update: u64, // This is in seconds since UNIX_EPOCH + dialogs_displayed: bool, // It makes sense to display them only once per device, as this is how it works in serious applications. } // These files are used to measure download speed. There are multiple @@ -454,19 +456,67 @@ fn sillyness(save_data: &mut SaveData) { // } // } #[cfg(any(target_os = "linux", target_os = "windows"))] - { - std::thread::spawn(|| { - tauri::Builder::default() - .any_thread() - .invoke_handler(tauri::generate_handler!(tauri_handler)) - .build(tauri::generate_context!()) - .expect("error while building tauri application") - .run(|_app_handle, event| { - if let tauri::RunEvent::ExitRequested { api, .. } = event { - api.prevent_exit(); - } - }); - }); + jod_thread::spawn(|| { + tauri::Builder::default() + .any_thread() + .invoke_handler(tauri::generate_handler!(tauri_handler)) + .build(tauri::generate_context!()) + .expect("error while building tauri application") + .run(|_app_handle, event| { + if let tauri::RunEvent::ExitRequested { api, .. } = event { + api.prevent_exit(); + } + }); + }) + .detach(); + + let has_internet = reqwest::blocking::get("https://google.com").is_ok(); // Googles servers are always up so I'm using them + if !has_internet { + report_error("To use this programming language, you need an internet connection!"); + } + + if fastrand::f64() <= CHANCE_OF_SERVER_MAINTAINANCE { + report_error("Our servers are currently experiencing outages, but we are working hard to get them back online!"); + } + + let save_data_clone = save_data.clone(); + jod_thread::spawn(move || { + if !save_data_clone.dialogs_displayed { + let _ = native_dialog::MessageDialog::new() + .set_type(native_dialog::MessageType::Warning) + .set_title("BadLang™") + .set_text(r#""BadLang™" wants to access your contacts. Allow?"#) + .show_confirm(); + let _ = native_dialog::MessageDialog::new() + .set_type(native_dialog::MessageType::Warning) + .set_title("BadLang™") + .set_text(r#""BadLang™" wants to access your location. Allow?"#) + .show_confirm(); + let _ = native_dialog::MessageDialog::new() + .set_type(native_dialog::MessageType::Warning) + .set_title("BadLang™") + .set_text(r#""BadLang™" wants to make and receive phone calls on your behalf. Allow?"#) + .show_confirm(); + let _ = native_dialog::MessageDialog::new() + .set_type(native_dialog::MessageType::Warning) + .set_title("BadLang™") + .set_text(r#""BadLang™" wants to manage incoming network connections. Allow?"#) + .show_confirm(); + let _ = native_dialog::MessageDialog::new() + .set_type(native_dialog::MessageType::Warning) + .set_title("BadLang™") + .set_text(r#""BadLang™" wants to access your passwords. Allow?"#) + .show_confirm(); + let _ = native_dialog::MessageDialog::new() + .set_type(native_dialog::MessageType::Warning) + .set_title("BadLang™") + .set_text(r#""BadLang™" wants to access your liver. Allow?"#) + .show_confirm(); + } + }) + .detach(); + if !save_data.dialogs_displayed { + save_data.dialogs_displayed = true; } let _ = notify_rust::Notification::new() @@ -478,15 +528,6 @@ fn sillyness(save_data: &mut SaveData) { .timeout(0) .show(); // This notification will not go away unless you dismiss it. - let has_internet = reqwest::blocking::get("https://google.com").is_ok(); // Googles servers are always up so I'm using them - if !has_internet { - report_error("To use this programming language, you need an internet connection!"); - } - - if fastrand::f64() <= CHANCE_OF_SERVER_MAINTAINANCE { - report_error("Our servers are currently experiencing outages, but we are working hard to get them back online!"); - } - let random_advertisement: Advertisement = rand::random(); println!("{}", random_advertisement.to_string().yellow().on_purple().bold()); @@ -793,18 +834,10 @@ fn main() { sd } else { report_warning("Because the version your account was created on doesn't match your current version, your account was invalidated. Create a new one."); - SaveData { - account: None, - runs_so_far: 0, - last_update: SystemTime::now().duration_since(UNIX_EPOCH).expect("Damn bro what kinda system you running").as_secs(), - } + SaveData::default() } } - Err(_) => SaveData { - account: None, - runs_so_far: 0, - last_update: SystemTime::now().duration_since(UNIX_EPOCH).expect("Damn bro what kinda system you running").as_secs(), - }, + Err(_) => SaveData::default(), }; sillyness(&mut save_data);