Skip to content

Commit

Permalink
Merge pull request #15 from sdasda7777/sdasda7777_pages16
Browse files Browse the repository at this point in the history
Added note to readme, more debug output
  • Loading branch information
sdasda7777 authored Dec 7, 2023
2 parents b097a87 + ec59dbe commit 2b1ac40
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Minesweeper in 6D written in safe Rust with:

You can play online through https://sdasda7777.github.io/minesweeper6d/

(beware, performance is a lot worse compared to native builds)

### On Windows

You can use prebuild binary from [releases](https://github.com/sdasda7777/minesweeper6d/releases ).
Expand Down
17 changes: 14 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,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};
use std::{cmp::min, fs, env};
use web_time::SystemTime;
use toml::Table;

Expand Down Expand Up @@ -306,6 +306,11 @@ impl Default for MinesweeperViewController {
// Sanity check
//println!("{}", std::mem::size_of::<CellState>());

match env::current_dir() {
Ok(p) => println!("The current directory is {}", p.display()),
Err(_) => println!("The current directory cannot be obtained")
};

let settings = InitialGameSettings {
name: "Custom".into(),
size: [4, 4, 4, 4, 1, 1],
Expand Down Expand Up @@ -354,9 +359,15 @@ impl Default for MinesweeperViewController {
shortcuts: Shortcuts::new(),
};

let config_text = fs::read_to_string("config.toml").unwrap_or_else(|_| "".into());
let config_text = match fs::read_to_string("config.toml") {
Ok(s) => s,
Err(_) => {
println!("config could not be read");
"".into()
}
}; //.unwrap_or_else(|_| "".into());
let config_table: Table = config_text.parse::<Table>().expect("Invalid configuration file");

// Load in presets
if let Some(val) = config_table.get("preset"){
for e in val.as_array().unwrap() {
Expand Down

0 comments on commit 2b1ac40

Please sign in to comment.