jblanked 1 год назад
Родитель
Сommit
b3610d52d2
4 измененных файлов с 10 добавлено и 30 удалено
  1. 3 4
      callback/callback.c
  2. 2 1
      flip_world.c
  3. 2 1
      flip_world.h
  4. 3 24
      game/game.c

+ 3 - 4
callback/callback.c

@@ -29,7 +29,7 @@ static int32_t game_app(void *p)
         return -1;
         return -1;
     }
     }
     GameEngineSettings settings = game_engine_settings_init();
     GameEngineSettings settings = game_engine_settings_init();
-    settings.target_fps = game.target_fps;
+    settings.target_fps = game_fps_choices_2[game_fps_index];
     settings.show_fps = game.show_fps;
     settings.show_fps = game.show_fps;
     settings.always_backlight = game.always_backlight;
     settings.always_backlight = game.always_backlight;
     settings.frame_callback = frame_cb;
     settings.frame_callback = frame_cb;
@@ -328,7 +328,6 @@ static bool alloc_variable_item_list(void *context, uint32_t view_id)
                                                                                             : 0;
                                                                                             : 0;
                 variable_item_set_current_value_text(app->variable_item_game_fps, game_fps_choices[index]);
                 variable_item_set_current_value_text(app->variable_item_game_fps, game_fps_choices[index]);
                 variable_item_set_current_value_index(app->variable_item_game_fps, index);
                 variable_item_set_current_value_index(app->variable_item_game_fps, index);
-                snprintf(game_fps, 8, "%s", _game_fps);
             }
             }
             break;
             break;
         }
         }
@@ -822,11 +821,11 @@ static void wifi_settings_item_selected(void *context, uint32_t index)
 static void flip_world_game_fps_change(VariableItem *item)
 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;
     variable_item_set_current_value_text(item, game_fps_choices[index]);
     variable_item_set_current_value_text(item, game_fps_choices[index]);
 
 
     // save the fps
     // save the fps
-    snprintf(game_fps, 8, "%s", game_fps_choices[index]);
-    save_char("Game-FPS", game_fps);
+    save_char("Game-FPS", game_fps_choices[index]);
 }
 }
 
 
 static bool flip_world_fetch_worlds(DataLoaderModel *model)
 static bool flip_world_fetch_worlds(DataLoaderModel *model)

+ 2 - 1
flip_world.c

@@ -1,3 +1,4 @@
 #include <flip_world.h>
 #include <flip_world.h>
 char *game_fps_choices[] = {"30", "60", "120", "240"};
 char *game_fps_choices[] = {"30", "60", "120", "240"};
-char *game_fps = "60";
+const float game_fps_choices_2[] = {30.0, 60.0, 120.0, 240.0};
+int game_fps_index = 1;

+ 2 - 1
flip_world.h

@@ -73,4 +73,5 @@ typedef struct
 } FlipWorldApp;
 } FlipWorldApp;
 
 
 extern char *game_fps_choices[];
 extern char *game_fps_choices[];
-extern char *game_fps; // The game FPS
+extern const float game_fps_choices_2[];
+extern int game_fps_index;

+ 3 - 24
game/game.c

@@ -181,34 +181,13 @@ static void game_stop(void *ctx)
     //  For simplicity, we will just print it.
     //  For simplicity, we will just print it.
     // FURI_LOG_I("Game", "Your score: %lu", game_context->score);
     // FURI_LOG_I("Game", "Your score: %lu", game_context->score);
 }
 }
-float game_fps_int()
-{
-    if (strcmp(game_fps, "30") == 0)
-    {
-        return 30.0;
-    }
-    else if (strcmp(game_fps, "60") == 0)
-    {
-        return 60.0;
-    }
-    else if (strcmp(game_fps, "120") == 0)
-    {
-        return 120.0;
-    }
-    else if (strcmp(game_fps, "240") == 0)
-    {
-        return 240.0;
-    }
-    else
-    {
-        return 60.0;
-    }
-}
+
 /*
 /*
     Your game configuration, do not rename this variable, but you can change its content here.
     Your game configuration, do not rename this variable, but you can change its content here.
 */
 */
+
 const Game game = {
 const Game game = {
-    .target_fps = 30,                    // target fps, game will try to keep this value
+    .target_fps = 0,                     // set to 0 because we set this in game_app (callback.c line 22)
     .show_fps = false,                   // show fps counter on the screen
     .show_fps = false,                   // show fps counter on the screen
     .always_backlight = true,            // keep display backlight always on
     .always_backlight = true,            // keep display backlight always on
     .start = game_start,                 // will be called once, when game starts
     .start = game_start,                 // will be called once, when game starts