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

clean up and fix game always on setting

jblanked 1 год назад
Родитель
Сommit
c79e5cb2cf
4 измененных файлов с 10 добавлено и 12 удалено
  1. 2 1
      alloc/alloc.c
  2. 2 2
      alloc/alloc.h
  3. 5 8
      callback/callback.c
  4. 1 1
      flip_world.c

+ 2 - 1
alloc/alloc.c

@@ -90,5 +90,6 @@ void flip_world_app_free(FlipWorldApp *app)
     furi_record_close(RECORD_GUI);
     furi_record_close(RECORD_GUI);
 
 
     // free the app
     // free the app
-    free(app);
+    if (app)
+        free(app);
 }
 }

+ 2 - 2
alloc/alloc.h

@@ -2,5 +2,5 @@
 #include <flip_world.h>
 #include <flip_world.h>
 #include <callback/callback.h>
 #include <callback/callback.h>
 
 
-extern FlipWorldApp *flip_world_app_alloc();
-extern void flip_world_app_free(FlipWorldApp *app);
+FlipWorldApp *flip_world_app_alloc();
+void flip_world_app_free(FlipWorldApp *app);

+ 5 - 8
callback/callback.c

@@ -596,7 +596,7 @@ void free_all_views(void *context, bool should_free_variable_item_list, bool sho
 
 
     if (app_instance)
     if (app_instance)
     {
     {
-        free(app_instance);
+        // free(app_instance); // no need to free since it's a reference to app
         app_instance = NULL;
         app_instance = NULL;
     }
     }
 }
 }
@@ -1058,13 +1058,7 @@ void callback_submenu_choices(void *context, uint32_t index)
             FURI_LOG_E(TAG, "Failed to initialize FlipperHTTP");
             FURI_LOG_E(TAG, "Failed to initialize FlipperHTTP");
             return;
             return;
         }
         }
-        app_instance = malloc(sizeof(FlipWorldApp));
-        if (!app_instance)
-        {
-            FURI_LOG_E(TAG, "Failed to allocate FlipWorldApp");
-            return;
-        }
-        memcpy(app_instance, app, sizeof(FlipWorldApp));
+        app_instance = app;
         // check if logged in
         // check if logged in
         if (is_logged_in() || is_logged_in_to_flip_social())
         if (is_logged_in() || is_logged_in_to_flip_social())
         {
         {
@@ -1369,6 +1363,7 @@ static void flip_world_game_fps_change(VariableItem *item)
     uint8_t index = variable_item_get_current_value_index(item);
     uint8_t index = variable_item_get_current_value_index(item);
     game_fps_index = index;
     game_fps_index = index;
     variable_item_set_current_value_text(item, game_fps_choices[index]);
     variable_item_set_current_value_text(item, game_fps_choices[index]);
+    variable_item_set_current_value_index(item, index);
 
 
     // save the fps
     // save the fps
     save_char("Game-FPS", game_fps_choices[index]);
     save_char("Game-FPS", game_fps_choices[index]);
@@ -1376,7 +1371,9 @@ static void flip_world_game_fps_change(VariableItem *item)
 static void flip_world_game_screen_always_on_change(VariableItem *item)
 static void flip_world_game_screen_always_on_change(VariableItem *item)
 {
 {
     uint8_t index = variable_item_get_current_value_index(item);
     uint8_t index = variable_item_get_current_value_index(item);
+    game_screen_always_on_index = index;
     variable_item_set_current_value_text(item, game_screen_always_on_choices[index]);
     variable_item_set_current_value_text(item, game_screen_always_on_choices[index]);
+    variable_item_set_current_value_index(item, index);
 
 
     // save the screen always on
     // save the screen always on
     save_char("Game-Screen-Always-On", game_screen_always_on_choices[index]);
     save_char("Game-Screen-Always-On", game_screen_always_on_choices[index]);

+ 1 - 1
flip_world.c

@@ -1,7 +1,7 @@
 #include <flip_world.h>
 #include <flip_world.h>
 char *game_fps_choices[] = {"30", "60", "120", "240"};
 char *game_fps_choices[] = {"30", "60", "120", "240"};
 const float game_fps_choices_2[] = {30.0, 60.0, 120.0, 240.0};
 const float game_fps_choices_2[] = {30.0, 60.0, 120.0, 240.0};
-int game_fps_index = 1;
+int game_fps_index = 0;
 char *game_screen_always_on_choices[] = {"No", "Yes"};
 char *game_screen_always_on_choices[] = {"No", "Yes"};
 int game_screen_always_on_index = 1;
 int game_screen_always_on_index = 1;
 FlipWorldApp *app_instance = NULL;
 FlipWorldApp *app_instance = NULL;