From 3c0c2d596f16b41ef65a944f55374ef20188ea19 Mon Sep 17 00:00:00 2001 From: sdasda7777 <17746796+sdasda7777@users.noreply.github.com> Date: Fri, 22 Mar 2024 09:23:00 +0100 Subject: [PATCH] Probably finally fixed the config for web --- assets/sw.js | 2 +- index.html | 1 - src/main.rs | 12 +++--------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/assets/sw.js b/assets/sw.js index 7ecd229..5cf014b 100644 --- a/assets/sw.js +++ b/assets/sw.js @@ -1,4 +1,4 @@ -var cacheName = 'egui-template-pwa'; +var cacheName = 'minesweeper6d-pwa'; var filesToCache = [ './', './index.html', diff --git a/index.html b/index.html index 55d9141..324ddf2 100644 --- a/index.html +++ b/index.html @@ -22,7 +22,6 @@ - diff --git a/src/main.rs b/src/main.rs index 2ed14ab..d5707a2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,8 +8,6 @@ extern crate toml; extern crate rand_chacha; use itertools::Itertools; -#[cfg(target_arch = "wasm32")] -use wasm_bindgen::prelude::wasm_bindgen; pub mod hhmmss; use hhmmss::Hhmmss; @@ -24,7 +22,7 @@ use eframe::{egui, emath::Align2}; use eframe::egui::{Button, containers::panel::TopBottomPanel, Key, KeyboardShortcut, menu, Modifiers, PointerButton, Response, RichText, Sense}; use eframe::epaint::{Color32, FontId, Pos2, Rect, Rounding, Shadow, Shape, Stroke}; -use std::{cmp::min, fs, time::Duration}; +use std::{cmp::min, fs, time::Duration, include_str}; use web_time::SystemTime; use toml::Table; @@ -100,6 +98,7 @@ fn main() { eframe::WebLogger::init(log::LevelFilter::Debug).ok(); let web_options = eframe::WebOptions::default(); + let config_content = include_str!("../config.toml").to_owned(); wasm_bindgen_futures::spawn_local(async { eframe::WebRunner::new() @@ -113,18 +112,13 @@ fn main() { style.visuals.window_rounding = Rounding::ZERO; style.visuals.window_shadow = Shadow::NONE; }); - Box::new(MinesweeperViewController::new(get_config())) + Box::new(MinesweeperViewController::new(config_content)) }), ) .await .expect("failed to start eframe"); }); } -#[cfg(target_arch = "wasm32")] -#[wasm_bindgen] -extern "C" { - fn get_config() -> String; -} struct MinesweeperViewController { current_initial_settings: InitialGameSettings,