Преглед на файлове

Slots: Port viewport and save path changes

Willy-JL преди 2 години
родител
ревизия
fba05c59e8
променени са 1 файла, в които са добавени 35 реда и са изтрити 32 реда
  1. 35 32
      slots/slotmachine.c

+ 35 - 32
slots/slotmachine.c

@@ -39,13 +39,14 @@ typedef struct {
 #define START_BET 300;
 #define SLOTS_RAND_MAX 5;
 #define DEFAULT_SPEED 16;
-#define HIGHSCORES_FILENAME EXT_PATH("apps/Games/slotmachine.save")
+#define HIGHSCORES_FILENAME APP_DATA_PATH("slotmachine.save")
 
 uint8_t DEFAULT_SPINNING_TIMES = 10;
 static SlotsHighscore highscore;
 
 static bool highscores_load() {
     Storage* storage = furi_record_open(RECORD_STORAGE); 
+    storage_common_migrate(storage, EXT_PATH("apps/Games/slotmachine.save"), HIGHSCORES_FILENAME);
     File* file = storage_file_alloc(storage);
 
     uint16_t bytes_readed = 0;
@@ -275,40 +276,42 @@ int32_t slotmachine_app(void* p) {
         memset(&highscore, 0, sizeof(highscore));
     }
     // endless input cycle
-    while(furi_message_queue_get(slotmachine->input_queue, &input, FuriWaitForever) == FuriStatusOk) {
-        // if thread idle - take it
-        furi_check(furi_mutex_acquire(slotmachine->model_mutex, FuriWaitForever) == FuriStatusOk);
-
-        if (!checkIsSpinning(slotmachine)) {
-            if (input.key == InputKeyBack) {
-                // exit on back button
-                furi_mutex_release(slotmachine->model_mutex);
-                break;
-            } else if (input.key == InputKeyOk && input.type == InputTypeShort && (slotmachine->winview || slotmachine->loseview)) {   
-                slotmachine->winview = false; 
-                slotmachine->loseview = false; 
-            } else if (input.key == InputKeyOk && input.type == InputTypeShort && slotmachine->bet <= slotmachine->money) {
-                COLUMNS_COUNT = rand() % 3 + 2;
-                slotmachine->money -= slotmachine->bet;
-                slotmachine->columns[0]->spining = true;
-                
-                for (int i = 0; i < COLUMNS_COUNT; i++) {
-                    slotmachine->columns[i]->times = DEFAULT_SPINNING_TIMES;
-                    slotmachine->columns[i]->speed = DEFAULT_SPEED;
-                }
-            } else if (input.key == InputKeyUp) {
-                if (slotmachine->bet + 10 <= slotmachine->money) {
-                    slotmachine->bet += 10;
-                }
-            } else if (input.key == InputKeyDown) {
-                if (slotmachine->bet - 10 > 0) {
-                    slotmachine->bet -= 10;
+    while(1) {
+        if(furi_message_queue_get(slotmachine->input_queue, &input, 100) == FuriStatusOk) {
+            // if thread idle - take it
+            furi_check(furi_mutex_acquire(slotmachine->model_mutex, FuriWaitForever) == FuriStatusOk);
+
+            if (!checkIsSpinning(slotmachine)) {
+                if (input.key == InputKeyBack) {
+                    // exit on back button
+                    furi_mutex_release(slotmachine->model_mutex);
+                    break;
+                } else if (input.key == InputKeyOk && input.type == InputTypeShort && (slotmachine->winview || slotmachine->loseview)) {   
+                    slotmachine->winview = false; 
+                    slotmachine->loseview = false; 
+                } else if (input.key == InputKeyOk && input.type == InputTypeShort && slotmachine->bet <= slotmachine->money) {
+                    COLUMNS_COUNT = rand() % 3 + 2;
+                    slotmachine->money -= slotmachine->bet;
+                    slotmachine->columns[0]->spining = true;
+                    
+                    for (int i = 0; i < COLUMNS_COUNT; i++) {
+                        slotmachine->columns[i]->times = DEFAULT_SPINNING_TIMES;
+                        slotmachine->columns[i]->speed = DEFAULT_SPEED;
+                    }
+                } else if (input.key == InputKeyUp) {
+                    if (slotmachine->bet + 10 <= slotmachine->money) {
+                        slotmachine->bet += 10;
+                    }
+                } else if (input.key == InputKeyDown) {
+                    if (slotmachine->bet - 10 > 0) {
+                        slotmachine->bet -= 10;
+                    }
                 }
             }
-        }
 
-        // release thread
-        furi_mutex_release(slotmachine->model_mutex);
+            // release thread
+            furi_mutex_release(slotmachine->model_mutex);
+        }
         // redraw viewport
         view_port_update(slotmachine->view_port);  
     }