Skip to content

Commit

Permalink
Merge with testing branch for solver implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
squee72564 committed Jan 9, 2024
2 parents 66f93fd + d98c610 commit 498aacb
Show file tree
Hide file tree
Showing 4 changed files with 464 additions and 69 deletions.
12 changes: 12 additions & 0 deletions helpers/mine_sweeper_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ void mine_sweeper_save_settings(void* context) {
flipper_format_write_uint32(
fff_file, MINESWEEPER_SETTINGS_KEY_LED, &app->led, 1);

flipper_format_write_bool(
fff_file, MINESWEEPER_SETTINGS_KEY_ENSURE_SOLVABLE, &app->ensure_map_solvable, 1);

uint32_t w = app->settings_info.board_width, h = app->settings_info.board_height, d = app->settings_info.difficulty;

flipper_format_write_uint32(
Expand Down Expand Up @@ -120,10 +123,19 @@ bool mine_sweeper_read_settings(void* context) {
flipper_format_read_uint32(fff_file, MINESWEEPER_SETTINGS_KEY_HEIGHT, &h, 1);
flipper_format_read_uint32(fff_file, MINESWEEPER_SETTINGS_KEY_DIFFICULTY, &d, 1);

if (w > 146) {w = 146;}
if (w < 16 ) {w = 16;}
if (h > 64 ) {h = 64;}
if (h < 7 ) {h = 7;}
if (d > 4 ) {d = 4;}

app->settings_info.board_width = (uint8_t) w;
app->settings_info.board_height = (uint8_t) h;
app->settings_info.difficulty = (uint8_t) d;

flipper_format_read_bool(
fff_file, MINESWEEPER_SETTINGS_KEY_ENSURE_SOLVABLE, &app->ensure_map_solvable, 1);

flipper_format_read_uint32(fff_file, MINESWEEPER_SETTINGS_KEY_HAPTIC, &app->haptic, 1);
flipper_format_read_uint32(fff_file, MINESWEEPER_SETTINGS_KEY_SPEAKER, &app->speaker, 1);
flipper_format_read_uint32(fff_file, MINESWEEPER_SETTINGS_KEY_LED, &app->led, 1);
Expand Down
2 changes: 2 additions & 0 deletions helpers/mine_sweeper_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#define MINESWEEPER_SETTINGS_KEY_HEIGHT "BoardHeight"
#define MINESWEEPER_SETTINGS_KEY_DIFFICULTY "BoardDifficulty"

#define MINESWEEPER_SETTINGS_KEY_ENSURE_SOLVABLE "EnsureSolvable"

#define MINESWEEPER_SETTINGS_KEY_HAPTIC "Haptic"
#define MINESWEEPER_SETTINGS_KEY_LED "Led"
#define MINESWEEPER_SETTINGS_KEY_SPEAKER "Speaker"
Expand Down
6 changes: 5 additions & 1 deletion minesweeper.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#define TAG "Mine Sweeper Application"

// This is a helper struct for the settings view/scene
typedef struct {
uint8_t board_width, board_height, difficulty;
FuriString* width_str;
Expand All @@ -34,7 +35,7 @@ typedef struct {
VariableItem* height_item;
} MineSweeperAppSettings;

// MineSweeperApp
// Main MineSweeperApp
typedef struct MineSweeperApp {
SceneManager* scene_manager;
ViewDispatcher* view_dispatcher;
Expand All @@ -48,7 +49,10 @@ typedef struct MineSweeperApp {

MineSweeperAppSettings settings_info;
MineSweeperAppSettings t_settings_info;

bool is_settings_changed;
bool ensure_map_solvable;

uint32_t haptic;
uint32_t speaker;
uint32_t led;
Expand Down
Loading

0 comments on commit 498aacb

Please sign in to comment.