Просмотр исходного кода

Merge 4inrow from https://github.com/xMasterX/all-the-plugins

Willy-JL 2 лет назад
Родитель
Сommit
2fb6c939ad
5 измененных файлов с 52 добавлено и 45 удалено
  1. 47 43
      4inrow/4inrow.c
  2. 5 2
      4inrow/application.fam
  3. BIN
      4inrow/img/1.png
  4. BIN
      4inrow/img/2.png
  5. BIN
      4inrow/img/3.png

+ 47 - 43
4inrow/4inrow.c

@@ -256,65 +256,69 @@ int32_t four_in_row_app(void* p) {
     while(1) {
         // Выбираем событие из очереди в переменную event (ждем бесконечно долго, если очередь пуста)
         // и проверяем, что у нас получилось это сделать
-        furi_check(furi_message_queue_get(event_queue, &event, FuriWaitForever) == FuriStatusOk);
-        furi_mutex_acquire(fourinrow_state->mutex, FuriWaitForever);
-        // Если нажата кнопка "назад", то выходим из цикла, а следовательно и из приложения
-        if(wincheck() != -1) {
-            notification_message(notification, &end);
-            furi_delay_ms(1000);
-            if(wincheck() == 1) {
-                scoreX++;
-            }
-            if(wincheck() == 2) {
-                scoreO++;
+        if(furi_message_queue_get(event_queue, &event, FuriWaitForever) == FuriStatusOk) {
+            if((event.type == InputTypePress) && (event.key == InputKeyBack)) {
+                break;
             }
-            init();
-        }
 
-        if(event.type == InputTypePress) {
-            if(event.key == InputKeyOk) {
-                int nh = next_height(cursorx);
-                if(nh != -1) {
-                    matrix[nh][cursorx] = player;
-                    player = 3 - player;
+            furi_mutex_acquire(fourinrow_state->mutex, FuriWaitForever);
+            if(wincheck() != -1) {
+                notification_message(notification, &end);
+                furi_delay_ms(1000);
+                if(wincheck() == 1) {
+                    scoreX++;
                 }
-            }
-            if(event.key == InputKeyUp) {
-                //cursory--;
-            }
-            if(event.key == InputKeyDown) {
-                //cursory++;
-            }
-            if(event.key == InputKeyLeft) {
-                if(cursorx > 0) {
-                    cursorx--;
+                if(wincheck() == 2) {
+                    scoreO++;
                 }
+                init();
+                furi_mutex_release(fourinrow_state->mutex);
+                continue;
             }
-            if(event.key == InputKeyRight) {
-                if(cursorx < 6) {
-                    cursorx++;
+
+            if(event.type == InputTypePress) {
+                if(event.key == InputKeyOk) {
+                    int nh = next_height(cursorx);
+                    if(nh != -1) {
+                        matrix[nh][cursorx] = player;
+                        player = 3 - player;
+                    }
+                }
+                if(event.key == InputKeyUp) {
+                    //cursory--;
+                }
+                if(event.key == InputKeyDown) {
+                    //cursory++;
+                }
+                if(event.key == InputKeyLeft) {
+                    if(cursorx > 0) {
+                        cursorx--;
+                    }
+                }
+                if(event.key == InputKeyRight) {
+                    if(cursorx < 6) {
+                        cursorx++;
+                    }
                 }
             }
-            if(event.key == InputKeyBack) {
-                break;
-            }
+
+            furi_mutex_release(fourinrow_state->mutex);
         }
         view_port_update(view_port);
-        furi_mutex_release(fourinrow_state->mutex);
     }
 
+    // Чистим созданные объекты, связанные с интерфейсом
+    view_port_enabled_set(view_port, false);
+    gui_remove_view_port(gui, view_port);
+    view_port_free(view_port);
+    furi_message_queue_free(event_queue);
+    furi_record_close(RECORD_GUI);
     // Clear notification
     notification_message_block(notification, &sequence_display_backlight_enforce_auto);
     furi_record_close(RECORD_NOTIFICATION);
 
-    // Специальная очистка памяти, занимаемой очередью
-    furi_message_queue_free(event_queue);
-
-    // Чистим созданные объекты, связанные с интерфейсом
-    gui_remove_view_port(gui, view_port);
-    view_port_free(view_port);
     furi_mutex_free(fourinrow_state->mutex);
-    furi_record_close(RECORD_GUI);
+
     free(fourinrow_state);
 
     return 0;

+ 5 - 2
4inrow/application.fam

@@ -3,12 +3,15 @@ App(
     name="4 in a Row",
     apptype=FlipperAppType.EXTERNAL,
     entry_point="four_in_row_app",
-    cdefines=["4INROW_WORLD"],
     requires=[
         "gui",
     ],
     stack_size=1 * 1024,
     order=90,
-	fap_icon="4inrow_10px.png",
+    fap_icon="4inrow_10px.png",
     fap_category="Games",
+    fap_author="leo-need-more-coffee",
+    fap_weburl="https://github.com/leo-need-more-coffee/flipperzero-4inrow",
+    fap_version="1.1",
+    fap_description="4 in row Game",
 )

BIN
4inrow/img/1.png


BIN
4inrow/img/2.png


BIN
4inrow/img/3.png