Restructure xtreme settings app

This commit is contained in:
Willy-JL
2023-03-16 00:12:46 +00:00
parent 3b0daf2f21
commit 1e60ff81e8
17 changed files with 351 additions and 304 deletions

View File

@@ -1,13 +1,14 @@
ADD_SCENE(xtreme_app, start, Start)
ADD_SCENE(xtreme_app, graphics, Graphics)
ADD_SCENE(xtreme_app, mainmenu, Mainmenu)
ADD_SCENE(xtreme_app, mainmenu_add, MainmenuAdd)
ADD_SCENE(xtreme_app, statusbar, Statusbar)
ADD_SCENE(xtreme_app, interface, Interface)
ADD_SCENE(xtreme_app, interface_graphics, InterfaceGraphics)
ADD_SCENE(xtreme_app, interface_mainmenu, InterfaceMainmenu)
ADD_SCENE(xtreme_app, interface_mainmenu_add, InterfaceMainmenuAdd)
ADD_SCENE(xtreme_app, interface_statusbar, InterfaceStatusbar)
ADD_SCENE(xtreme_app, interface_common, InterfaceCommon)
ADD_SCENE(xtreme_app, protocols, Protocols)
ADD_SCENE(xtreme_app, protocols_frequencies, ProtocolsFrequencies)
ADD_SCENE(xtreme_app, protocols_frequencies_static, ProtocolsFrequenciesStatic)
ADD_SCENE(xtreme_app, protocols_frequencies_hopper, ProtocolsFrequenciesHopper)
ADD_SCENE(xtreme_app, protocols_frequencies_add, ProtocolsFrequenciesAdd)
ADD_SCENE(xtreme_app, dolphin, Dolphin)
ADD_SCENE(xtreme_app, misc, Misc)
ADD_SCENE(xtreme_app, misc_rename, MiscRename)

View File

@@ -1,92 +0,0 @@
#include "../xtreme_app.h"
enum VarItemListIndex {
VarItemListIndexXpLevel,
VarItemListIndexButthurtTimer,
};
void xtreme_app_scene_dolphin_var_item_list_callback(void* context, uint32_t index) {
XtremeApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, index);
}
static void xtreme_app_scene_dolphin_xp_level_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
app->dolphin_level = variable_item_get_current_value_index(item) + 1;
char level_str[4];
snprintf(level_str, 4, "%i", app->dolphin_level);
variable_item_set_current_value_text(item, level_str);
app->save_level = true;
}
const char* const butthurt_timer_names[] =
{"OFF", "30 M", "1 H", "2 H", "4 H", "6 H", "8 H", "12 H", "24 H", "48 H"};
const int32_t butthurt_timer_values[COUNT_OF(butthurt_timer_names)] =
{-1, 1800, 3600, 7200, 14400, 21600, 28800, 43200, 86400, 172800};
static void xtreme_app_scene_dolphin_butthurt_timer_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, butthurt_timer_names[index]);
XTREME_SETTINGS()->butthurt_timer = butthurt_timer_values[index];
app->save_settings = true;
app->require_reboot = true;
}
void xtreme_app_scene_dolphin_on_enter(void* context) {
XtremeApp* app = context;
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
VariableItemList* var_item_list = app->var_item_list;
VariableItem* item;
uint8_t value_index;
char level_str[4];
snprintf(level_str, 4, "%i", app->dolphin_level);
item = variable_item_list_add(
var_item_list,
"XP Level",
DOLPHIN_LEVEL_COUNT + 1,
xtreme_app_scene_dolphin_xp_level_changed,
app);
variable_item_set_current_value_index(item, app->dolphin_level - 1);
variable_item_set_current_value_text(item, level_str);
item = variable_item_list_add(
var_item_list,
"Butthurt Timer",
COUNT_OF(butthurt_timer_names),
xtreme_app_scene_dolphin_butthurt_timer_changed,
app);
value_index = value_index_int32(
xtreme_settings->butthurt_timer, butthurt_timer_values, COUNT_OF(butthurt_timer_names));
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, butthurt_timer_names[value_index]);
variable_item_list_set_enter_callback(
var_item_list, xtreme_app_scene_dolphin_var_item_list_callback, app);
variable_item_list_set_selected_item(
var_item_list, scene_manager_get_scene_state(app->scene_manager, XtremeAppSceneDolphin));
view_dispatcher_switch_to_view(app->view_dispatcher, XtremeAppViewVarItemList);
}
bool xtreme_app_scene_dolphin_on_event(void* context, SceneManagerEvent event) {
XtremeApp* app = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
scene_manager_set_scene_state(app->scene_manager, XtremeAppSceneDolphin, event.event);
consumed = true;
switch(event.event) {
default:
break;
}
}
return consumed;
}
void xtreme_app_scene_dolphin_on_exit(void* context) {
XtremeApp* app = context;
variable_item_list_reset(app->var_item_list);
}

View File

@@ -0,0 +1,64 @@
#include "../xtreme_app.h"
enum VarItemListIndex {
VarItemListIndexGraphics,
VarItemListIndexMainmenu,
VarItemListIndexStatusbar,
VarItemListIndexCommon,
};
void xtreme_app_scene_interface_var_item_list_callback(void* context, uint32_t index) {
XtremeApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, index);
}
void xtreme_app_scene_interface_on_enter(void* context) {
XtremeApp* app = context;
VariableItemList* var_item_list = app->var_item_list;
variable_item_list_add(var_item_list, "Graphics", 0, NULL, app);
variable_item_list_add(var_item_list, "Mainmenu", 0, NULL, app);
variable_item_list_add(var_item_list, "Statusbar", 0, NULL, app);
variable_item_list_add(var_item_list, "Common", 0, NULL, app);
variable_item_list_set_enter_callback(
var_item_list, xtreme_app_scene_interface_var_item_list_callback, app);
variable_item_list_set_selected_item(
var_item_list, scene_manager_get_scene_state(app->scene_manager, XtremeAppSceneInterface));
view_dispatcher_switch_to_view(app->view_dispatcher, XtremeAppViewVarItemList);
}
bool xtreme_app_scene_interface_on_event(void* context, SceneManagerEvent event) {
XtremeApp* app = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
scene_manager_set_scene_state(app->scene_manager, XtremeAppSceneInterface, event.event);
consumed = true;
switch(event.event) {
case VarItemListIndexGraphics:
scene_manager_next_scene(app->scene_manager, XtremeAppSceneInterfaceGraphics);
break;
case VarItemListIndexMainmenu:
scene_manager_next_scene(app->scene_manager, XtremeAppSceneInterfaceMainmenu);
break;
case VarItemListIndexStatusbar:
scene_manager_next_scene(app->scene_manager, XtremeAppSceneInterfaceStatusbar);
break;
case VarItemListIndexCommon:
scene_manager_next_scene(app->scene_manager, XtremeAppSceneInterfaceCommon);
break;
default:
break;
}
}
return consumed;
}
void xtreme_app_scene_interface_on_exit(void* context) {
XtremeApp* app = context;
variable_item_list_reset(app->var_item_list);
}

View File

@@ -0,0 +1,90 @@
#include "../xtreme_app.h"
enum VarItemListIndex {
VarItemListIndexSortDirsFirst,
VarItemListIndexDarkMode,
VarItemListIndexLeftHanded,
};
void xtreme_app_scene_interface_common_var_item_list_callback(void* context, uint32_t index) {
XtremeApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, index);
}
static void xtreme_app_scene_interface_common_sort_dirs_first_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
XTREME_SETTINGS()->sort_dirs_first = value;
app->save_settings = true;
}
static void xtreme_app_scene_interface_common_dark_mode_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
XTREME_SETTINGS()->dark_mode = value;
app->save_settings = true;
}
static void xtreme_app_scene_interface_common_left_handed_changed(VariableItem* item) {
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
if(value) {
furi_hal_rtc_set_flag(FuriHalRtcFlagHandOrient);
} else {
furi_hal_rtc_reset_flag(FuriHalRtcFlagHandOrient);
}
}
void xtreme_app_scene_interface_common_on_enter(void* context) {
XtremeApp* app = context;
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
VariableItemList* var_item_list = app->var_item_list;
VariableItem* item;
item = variable_item_list_add(
var_item_list, "Sort Dirs First", 2, xtreme_app_scene_interface_common_sort_dirs_first_changed, app);
variable_item_set_current_value_index(item, xtreme_settings->sort_dirs_first);
variable_item_set_current_value_text(item, xtreme_settings->sort_dirs_first ? "ON" : "OFF");
item = variable_item_list_add(
var_item_list, "Dark Mode", 2, xtreme_app_scene_interface_common_dark_mode_changed, app);
variable_item_set_current_value_index(item, xtreme_settings->dark_mode);
variable_item_set_current_value_text(item, xtreme_settings->dark_mode ? "ON" : "OFF");
item = variable_item_list_add(
var_item_list, "Left Handed", 2, xtreme_app_scene_interface_common_left_handed_changed, app);
bool value = furi_hal_rtc_is_flag_set(FuriHalRtcFlagHandOrient);
variable_item_set_current_value_index(item, value);
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
variable_item_list_set_enter_callback(
var_item_list, xtreme_app_scene_interface_common_var_item_list_callback, app);
variable_item_list_set_selected_item(
var_item_list, scene_manager_get_scene_state(app->scene_manager, XtremeAppSceneInterfaceCommon));
view_dispatcher_switch_to_view(app->view_dispatcher, XtremeAppViewVarItemList);
}
bool xtreme_app_scene_interface_common_on_event(void* context, SceneManagerEvent event) {
XtremeApp* app = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
scene_manager_set_scene_state(app->scene_manager, XtremeAppSceneInterfaceCommon, event.event);
consumed = true;
switch(event.event) {
default:
break;
}
}
return consumed;
}
void xtreme_app_scene_interface_common_on_exit(void* context) {
XtremeApp* app = context;
variable_item_list_reset(app->var_item_list);
}

View File

@@ -7,21 +7,21 @@ enum VarItemListIndex {
VarItemListIndexUnlockAnims,
};
void xtreme_app_scene_graphics_var_item_list_callback(void* context, uint32_t index) {
void xtreme_app_scene_interface_graphics_var_item_list_callback(void* context, uint32_t index) {
XtremeApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, index);
}
static void xtreme_app_scene_graphics_asset_pack_changed(VariableItem* item) {
static void xtreme_app_scene_interface_graphics_asset_pack_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(
item, index == 0 ? "SFW" : *CharList_get(app->asset_packs, index - 1));
item, index == 0 ? "SFW" : *CharList_get(app->asset_pack_names, index - 1));
strlcpy(
XTREME_SETTINGS()->asset_pack,
index == 0 ? "" : *CharList_get(app->asset_packs, index - 1),
index == 0 ? "" : *CharList_get(app->asset_pack_names, index - 1),
MAX_PACK_NAME_LEN);
app->asset_pack = index;
app->asset_pack_index = index;
app->save_settings = true;
app->require_reboot = true;
}
@@ -30,7 +30,7 @@ const char* const anim_speed_names[] =
{"25%", "50%", "75%", "100%", "125%", "150%", "175%", "200%", "225%", "250%", "275%", "300%"};
const int32_t anim_speed_values[COUNT_OF(anim_speed_names)] =
{25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300};
static void xtreme_app_scene_graphics_anim_speed_changed(VariableItem* item) {
static void xtreme_app_scene_interface_graphics_anim_speed_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, anim_speed_names[index]);
@@ -54,7 +54,7 @@ const char* const cycle_anims_names[] = {
"24 H"};
const int32_t cycle_anims_values[COUNT_OF(cycle_anims_names)] =
{-1, 0, 30, 60, 300, 600, 900, 1800, 3600, 7200, 21600, 43200, 86400};
static void xtreme_app_scene_graphics_cycle_anims_changed(VariableItem* item) {
static void xtreme_app_scene_interface_graphics_cycle_anims_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, cycle_anims_names[index]);
@@ -62,7 +62,7 @@ static void xtreme_app_scene_graphics_cycle_anims_changed(VariableItem* item) {
app->save_settings = true;
}
static void xtreme_app_scene_graphics_unlock_anims_changed(VariableItem* item) {
static void xtreme_app_scene_interface_graphics_unlock_anims_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
@@ -70,7 +70,7 @@ static void xtreme_app_scene_graphics_unlock_anims_changed(VariableItem* item) {
app->save_settings = true;
}
void xtreme_app_scene_graphics_on_enter(void* context) {
void xtreme_app_scene_interface_graphics_on_enter(void* context) {
XtremeApp* app = context;
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
VariableItemList* var_item_list = app->var_item_list;
@@ -80,19 +80,19 @@ void xtreme_app_scene_graphics_on_enter(void* context) {
item = variable_item_list_add(
var_item_list,
"Asset Pack",
CharList_size(app->asset_packs) + 1,
xtreme_app_scene_graphics_asset_pack_changed,
CharList_size(app->asset_pack_names) + 1,
xtreme_app_scene_interface_graphics_asset_pack_changed,
app);
variable_item_set_current_value_index(item, app->asset_pack);
variable_item_set_current_value_index(item, app->asset_pack_index);
variable_item_set_current_value_text(
item,
app->asset_pack == 0 ? "SFW" : *CharList_get(app->asset_packs, app->asset_pack - 1));
app->asset_pack_index == 0 ? "SFW" : *CharList_get(app->asset_pack_names, app->asset_pack_index - 1));
item = variable_item_list_add(
var_item_list,
"Anim Speed",
COUNT_OF(anim_speed_names),
xtreme_app_scene_graphics_anim_speed_changed,
xtreme_app_scene_interface_graphics_anim_speed_changed,
app);
value_index = value_index_int32(
xtreme_settings->anim_speed, anim_speed_values, COUNT_OF(anim_speed_names));
@@ -103,7 +103,7 @@ void xtreme_app_scene_graphics_on_enter(void* context) {
var_item_list,
"Cycle Anims",
COUNT_OF(cycle_anims_names),
xtreme_app_scene_graphics_cycle_anims_changed,
xtreme_app_scene_interface_graphics_cycle_anims_changed,
app);
value_index = value_index_int32(
xtreme_settings->cycle_anims, cycle_anims_values, COUNT_OF(cycle_anims_names));
@@ -111,25 +111,25 @@ void xtreme_app_scene_graphics_on_enter(void* context) {
variable_item_set_current_value_text(item, cycle_anims_names[value_index]);
item = variable_item_list_add(
var_item_list, "Unlock Anims", 2, xtreme_app_scene_graphics_unlock_anims_changed, app);
var_item_list, "Unlock Anims", 2, xtreme_app_scene_interface_graphics_unlock_anims_changed, app);
variable_item_set_current_value_index(item, xtreme_settings->unlock_anims);
variable_item_set_current_value_text(item, xtreme_settings->unlock_anims ? "ON" : "OFF");
variable_item_list_set_enter_callback(
var_item_list, xtreme_app_scene_graphics_var_item_list_callback, app);
var_item_list, xtreme_app_scene_interface_graphics_var_item_list_callback, app);
variable_item_list_set_selected_item(
var_item_list, scene_manager_get_scene_state(app->scene_manager, XtremeAppSceneGraphics));
var_item_list, scene_manager_get_scene_state(app->scene_manager, XtremeAppSceneInterfaceGraphics));
view_dispatcher_switch_to_view(app->view_dispatcher, XtremeAppViewVarItemList);
}
bool xtreme_app_scene_graphics_on_event(void* context, SceneManagerEvent event) {
bool xtreme_app_scene_interface_graphics_on_event(void* context, SceneManagerEvent event) {
XtremeApp* app = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
scene_manager_set_scene_state(app->scene_manager, XtremeAppSceneGraphics, event.event);
scene_manager_set_scene_state(app->scene_manager, XtremeAppSceneInterfaceGraphics, event.event);
consumed = true;
switch(event.event) {
default:
@@ -140,7 +140,7 @@ bool xtreme_app_scene_graphics_on_event(void* context, SceneManagerEvent event)
return consumed;
}
void xtreme_app_scene_graphics_on_exit(void* context) {
void xtreme_app_scene_interface_graphics_on_exit(void* context) {
XtremeApp* app = context;
variable_item_list_reset(app->var_item_list);
}

View File

@@ -7,14 +7,14 @@ enum VarItemListIndex {
VarItemListIndexAddApp,
};
void xtreme_app_scene_mainmenu_var_item_list_callback(
void xtreme_app_scene_interface_mainmenu_var_item_list_callback(
void* context,
uint32_t index) {
XtremeApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, index);
}
static void xtreme_app_scene_mainmenu_wii_menu_changed(VariableItem* item) {
static void xtreme_app_scene_interface_mainmenu_wii_menu_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
@@ -22,33 +22,33 @@ static void xtreme_app_scene_mainmenu_wii_menu_changed(VariableItem* item) {
app->save_settings = true;
}
static void xtreme_app_scene_mainmenu_app_changed(VariableItem* item) {
static void xtreme_app_scene_interface_mainmenu_app_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
app->mainmenu_app_index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, *CharList_get(app->mainmenu_apps_names, app->mainmenu_app_index));
variable_item_set_current_value_text(item, *CharList_get(app->mainmenu_app_names, app->mainmenu_app_index));
}
void xtreme_app_scene_mainmenu_on_enter(void* context) {
void xtreme_app_scene_interface_mainmenu_on_enter(void* context) {
XtremeApp* app = context;
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
VariableItemList* var_item_list = app->var_item_list;
VariableItem* item;
item = variable_item_list_add(
var_item_list, "Wii menu", 2, xtreme_app_scene_mainmenu_wii_menu_changed, app);
var_item_list, "Wii menu", 2, xtreme_app_scene_interface_mainmenu_wii_menu_changed, app);
variable_item_set_current_value_index(item, xtreme_settings->wii_menu);
variable_item_set_current_value_text(item, xtreme_settings->wii_menu ? "ON" : "OFF");
item = variable_item_list_add(
var_item_list,
"App",
CharList_size(app->mainmenu_apps_names),
xtreme_app_scene_mainmenu_app_changed,
CharList_size(app->mainmenu_app_names),
xtreme_app_scene_interface_mainmenu_app_changed,
app);
app->mainmenu_app_index = 0;
variable_item_set_current_value_index(item, app->mainmenu_app_index);
if(CharList_size(app->mainmenu_apps_names)) {
variable_item_set_current_value_text(item, *CharList_get(app->mainmenu_apps_names, app->mainmenu_app_index));
if(CharList_size(app->mainmenu_app_names)) {
variable_item_set_current_value_text(item, *CharList_get(app->mainmenu_app_names, app->mainmenu_app_index));
} else {
variable_item_set_current_value_text(item, "None");
}
@@ -58,37 +58,37 @@ void xtreme_app_scene_mainmenu_on_enter(void* context) {
variable_item_list_add(var_item_list, "Add App", 0, NULL, app);
variable_item_list_set_enter_callback(
var_item_list, xtreme_app_scene_mainmenu_var_item_list_callback, app);
var_item_list, xtreme_app_scene_interface_mainmenu_var_item_list_callback, app);
variable_item_list_set_selected_item(
var_item_list,
scene_manager_get_scene_state(
app->scene_manager, XtremeAppSceneMainmenu));
app->scene_manager, XtremeAppSceneInterfaceMainmenu));
view_dispatcher_switch_to_view(app->view_dispatcher, XtremeAppViewVarItemList);
}
bool xtreme_app_scene_mainmenu_on_event(void* context, SceneManagerEvent event) {
bool xtreme_app_scene_interface_mainmenu_on_event(void* context, SceneManagerEvent event) {
XtremeApp* app = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
scene_manager_set_scene_state(
app->scene_manager, XtremeAppSceneMainmenu, event.event);
app->scene_manager, XtremeAppSceneInterfaceMainmenu, event.event);
consumed = true;
switch(event.event) {
case VarItemListIndexRemoveApp:
if(!CharList_size(app->mainmenu_apps_names)) break;
if(!CharList_size(app->mainmenu_apps_paths)) break;
CharList_remove_v(app->mainmenu_apps_names, app->mainmenu_app_index, app->mainmenu_app_index + 1);
CharList_remove_v(app->mainmenu_apps_paths, app->mainmenu_app_index, app->mainmenu_app_index + 1);
if(!CharList_size(app->mainmenu_app_names)) break;
if(!CharList_size(app->mainmenu_app_paths)) break;
CharList_remove_v(app->mainmenu_app_names, app->mainmenu_app_index, app->mainmenu_app_index + 1);
CharList_remove_v(app->mainmenu_app_paths, app->mainmenu_app_index, app->mainmenu_app_index + 1);
app->save_mainmenu_apps = true;
app->require_reboot = true;
scene_manager_previous_scene(app->scene_manager);
scene_manager_next_scene(app->scene_manager, XtremeAppSceneMainmenu);
scene_manager_next_scene(app->scene_manager, XtremeAppSceneInterfaceMainmenu);
break;
case VarItemListIndexAddApp:
scene_manager_next_scene(app->scene_manager, XtremeAppSceneMainmenuAdd);
scene_manager_next_scene(app->scene_manager, XtremeAppSceneInterfaceMainmenuAdd);
break;
default:
break;
@@ -98,7 +98,7 @@ bool xtreme_app_scene_mainmenu_on_event(void* context, SceneManagerEvent event)
return consumed;
}
void xtreme_app_scene_mainmenu_on_exit(void* context) {
void xtreme_app_scene_interface_mainmenu_on_exit(void* context) {
XtremeApp* app = context;
variable_item_list_reset(app->var_item_list);
}

View File

@@ -4,7 +4,7 @@ enum FileBrowserResult {
FileBrowserResultOk,
};
static bool xtreme_app_scene_mainmenu_add_file_browser_callback(
static bool xtreme_app_scene_interface_mainmenu_add_file_browser_callback(
FuriString* file_path,
void* context,
uint8_t** icon_ptr,
@@ -16,7 +16,7 @@ static bool xtreme_app_scene_mainmenu_add_file_browser_callback(
return success;
}
void xtreme_app_scene_mainmenu_add_on_enter(void* context) {
void xtreme_app_scene_interface_mainmenu_add_on_enter(void* context) {
XtremeApp* app = context;
FuriString* string = furi_string_alloc_set_str(EXT_PATH("apps"));
@@ -24,17 +24,17 @@ void xtreme_app_scene_mainmenu_add_on_enter(void* context) {
.extension = ".fap",
.skip_assets = true,
.hide_ext = true,
.item_loader_callback = xtreme_app_scene_mainmenu_add_file_browser_callback,
.item_loader_callback = xtreme_app_scene_interface_mainmenu_add_file_browser_callback,
.item_loader_context = app,
.base_path = EXT_PATH("apps"),
};
if(dialog_file_browser_show(app->dialogs, string, string, &browser_options)) {
CharList_push_back(app->mainmenu_apps_paths, strdup(furi_string_get_cstr(string)));
CharList_push_back(app->mainmenu_app_paths, strdup(furi_string_get_cstr(string)));
Storage* storage = furi_record_open(RECORD_STORAGE);
fap_loader_load_name_and_icon(string, storage, NULL, string);
furi_record_close(RECORD_STORAGE);
CharList_push_back(app->mainmenu_apps_names, strdup(furi_string_get_cstr(string)));
CharList_push_back(app->mainmenu_app_names, strdup(furi_string_get_cstr(string)));
app->save_mainmenu_apps = true;
app->require_reboot = true;
}
@@ -44,7 +44,7 @@ void xtreme_app_scene_mainmenu_add_on_enter(void* context) {
view_dispatcher_send_custom_event(app->view_dispatcher, FileBrowserResultOk);
}
bool xtreme_app_scene_mainmenu_add_on_event(void* context, SceneManagerEvent event) {
bool xtreme_app_scene_interface_mainmenu_add_on_event(void* context, SceneManagerEvent event) {
XtremeApp* app = context;
bool consumed = false;
@@ -62,6 +62,6 @@ bool xtreme_app_scene_mainmenu_add_on_event(void* context, SceneManagerEvent eve
return consumed;
}
void xtreme_app_scene_mainmenu_add_on_exit(void* context) {
void xtreme_app_scene_interface_mainmenu_add_on_exit(void* context) {
UNUSED(context);
}

View File

@@ -7,14 +7,14 @@ enum VarItemListIndex {
VarItemListIndexbarBackground,
};
void xtreme_app_scene_statusbar_var_item_list_callback(void* context, uint32_t index) {
void xtreme_app_scene_interface_statusbar_var_item_list_callback(void* context, uint32_t index) {
XtremeApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, index);
}
const char* const battery_icon_names[] =
{"OFF", "Bar", "%", "Inv. %", "Retro 3", "Retro 5", "Bar %"};
static void xtreme_app_scene_statusbar_battery_icon_changed(VariableItem* item) {
static void xtreme_app_scene_interface_statusbar_battery_icon_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, battery_icon_names[index]);
@@ -22,7 +22,7 @@ static void xtreme_app_scene_statusbar_battery_icon_changed(VariableItem* item)
app->save_settings = true;
}
static void xtreme_app_scene_statusbar_status_icons_changed(VariableItem* item) {
static void xtreme_app_scene_interface_statusbar_status_icons_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
@@ -30,7 +30,7 @@ static void xtreme_app_scene_statusbar_status_icons_changed(VariableItem* item)
app->save_settings = true;
}
static void xtreme_app_scene_statusbar_bar_borders_changed(VariableItem* item) {
static void xtreme_app_scene_interface_statusbar_bar_borders_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
@@ -38,7 +38,7 @@ static void xtreme_app_scene_statusbar_bar_borders_changed(VariableItem* item) {
app->save_settings = true;
}
static void xtreme_app_scene_statusbar_bar_background_changed(VariableItem* item) {
static void xtreme_app_scene_interface_statusbar_bar_background_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
@@ -46,7 +46,7 @@ static void xtreme_app_scene_statusbar_bar_background_changed(VariableItem* item
app->save_settings = true;
}
void xtreme_app_scene_statusbar_on_enter(void* context) {
void xtreme_app_scene_interface_statusbar_on_enter(void* context) {
XtremeApp* app = context;
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
VariableItemList* var_item_list = app->var_item_list;
@@ -56,41 +56,41 @@ void xtreme_app_scene_statusbar_on_enter(void* context) {
var_item_list,
"Battery Icon",
BatteryIconCount,
xtreme_app_scene_statusbar_battery_icon_changed,
xtreme_app_scene_interface_statusbar_battery_icon_changed,
app);
variable_item_set_current_value_index(item, xtreme_settings->battery_icon);
variable_item_set_current_value_text(item, battery_icon_names[xtreme_settings->battery_icon]);
item = variable_item_list_add(
var_item_list, "Status Icons", 2, xtreme_app_scene_statusbar_status_icons_changed, app);
var_item_list, "Status Icons", 2, xtreme_app_scene_interface_statusbar_status_icons_changed, app);
variable_item_set_current_value_index(item, xtreme_settings->status_icons);
variable_item_set_current_value_text(item, xtreme_settings->status_icons ? "ON" : "OFF");
item = variable_item_list_add(
var_item_list, "Bar Borders", 2, xtreme_app_scene_statusbar_bar_borders_changed, app);
var_item_list, "Bar Borders", 2, xtreme_app_scene_interface_statusbar_bar_borders_changed, app);
variable_item_set_current_value_index(item, xtreme_settings->bar_borders);
variable_item_set_current_value_text(item, xtreme_settings->bar_borders ? "ON" : "OFF");
item = variable_item_list_add(
var_item_list, "Bar Background", 2, xtreme_app_scene_statusbar_bar_background_changed, app);
var_item_list, "Bar Background", 2, xtreme_app_scene_interface_statusbar_bar_background_changed, app);
variable_item_set_current_value_index(item, xtreme_settings->bar_background);
variable_item_set_current_value_text(item, xtreme_settings->bar_background ? "ON" : "OFF");
variable_item_list_set_enter_callback(
var_item_list, xtreme_app_scene_statusbar_var_item_list_callback, app);
var_item_list, xtreme_app_scene_interface_statusbar_var_item_list_callback, app);
variable_item_list_set_selected_item(
var_item_list, scene_manager_get_scene_state(app->scene_manager, XtremeAppSceneStatusbar));
var_item_list, scene_manager_get_scene_state(app->scene_manager, XtremeAppSceneInterfaceStatusbar));
view_dispatcher_switch_to_view(app->view_dispatcher, XtremeAppViewVarItemList);
}
bool xtreme_app_scene_statusbar_on_event(void* context, SceneManagerEvent event) {
bool xtreme_app_scene_interface_statusbar_on_event(void* context, SceneManagerEvent event) {
XtremeApp* app = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
scene_manager_set_scene_state(app->scene_manager, XtremeAppSceneStatusbar, event.event);
scene_manager_set_scene_state(app->scene_manager, XtremeAppSceneInterfaceStatusbar, event.event);
consumed = true;
switch(event.event) {
default:
@@ -101,7 +101,7 @@ bool xtreme_app_scene_statusbar_on_event(void* context, SceneManagerEvent event)
return consumed;
}
void xtreme_app_scene_statusbar_on_exit(void* context) {
void xtreme_app_scene_interface_statusbar_on_exit(void* context) {
XtremeApp* app = context;
variable_item_list_reset(app->var_item_list);
}

View File

@@ -1,11 +1,9 @@
#include "../xtreme_app.h"
enum VarItemListIndex {
VarItemListIndexSortDirsFirst,
VarItemListIndexChangeDeviceName,
VarItemListIndexExperimentalOptions,
VarItemListIndexDarkMode,
VarItemListIndexLeftHanded,
VarItemListIndexXpLevel,
VarItemListIndexButthurtTimer,
};
void xtreme_app_scene_misc_var_item_list_callback(void* context, uint32_t index) {
@@ -13,30 +11,26 @@ void xtreme_app_scene_misc_var_item_list_callback(void* context, uint32_t index)
view_dispatcher_send_custom_event(app->view_dispatcher, index);
}
static void xtreme_app_scene_misc_sort_dirs_first_changed(VariableItem* item) {
static void xtreme_app_scene_misc_xp_level_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
XTREME_SETTINGS()->sort_dirs_first = value;
app->save_settings = true;
app->xp_level = variable_item_get_current_value_index(item) + 1;
char level_str[4];
snprintf(level_str, 4, "%li", app->xp_level);
variable_item_set_current_value_text(item, level_str);
app->save_level = true;
}
static void xtreme_app_scene_misc_dark_mode_changed(VariableItem* item) {
const char* const butthurt_timer_names[] =
{"OFF", "30 M", "1 H", "2 H", "4 H", "6 H", "8 H", "12 H", "24 H", "48 H"};
const int32_t butthurt_timer_values[COUNT_OF(butthurt_timer_names)] =
{-1, 1800, 3600, 7200, 14400, 21600, 28800, 43200, 86400, 172800};
static void xtreme_app_scene_misc_butthurt_timer_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
XTREME_SETTINGS()->dark_mode = value;
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, butthurt_timer_names[index]);
XTREME_SETTINGS()->butthurt_timer = butthurt_timer_values[index];
app->save_settings = true;
}
static void xtreme_app_scene_misc_left_handed_changed(VariableItem* item) {
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
if(value) {
furi_hal_rtc_set_flag(FuriHalRtcFlagHandOrient);
} else {
furi_hal_rtc_reset_flag(FuriHalRtcFlagHandOrient);
}
app->require_reboot = true;
}
void xtreme_app_scene_misc_on_enter(void* context) {
@@ -44,26 +38,31 @@ void xtreme_app_scene_misc_on_enter(void* context) {
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
VariableItemList* var_item_list = app->var_item_list;
VariableItem* item;
item = variable_item_list_add(
var_item_list, "Sort Dirs First", 2, xtreme_app_scene_misc_sort_dirs_first_changed, app);
variable_item_set_current_value_index(item, xtreme_settings->sort_dirs_first);
variable_item_set_current_value_text(item, xtreme_settings->sort_dirs_first ? "ON" : "OFF");
uint8_t value_index;
variable_item_list_add(var_item_list, "Change Device Name", 0, NULL, app);
variable_item_list_add(var_item_list, " Experimental Options:", 0, NULL, app);
char level_str[4];
snprintf(level_str, 4, "%li", app->xp_level);
item = variable_item_list_add(
var_item_list,
"XP Level",
DOLPHIN_LEVEL_COUNT + 1,
xtreme_app_scene_misc_xp_level_changed,
app);
variable_item_set_current_value_index(item, app->xp_level - 1);
variable_item_set_current_value_text(item, level_str);
item = variable_item_list_add(
var_item_list, "Dark Mode", 2, xtreme_app_scene_misc_dark_mode_changed, app);
variable_item_set_current_value_index(item, xtreme_settings->dark_mode);
variable_item_set_current_value_text(item, xtreme_settings->dark_mode ? "ON" : "OFF");
item = variable_item_list_add(
var_item_list, "Left Handed", 2, xtreme_app_scene_misc_left_handed_changed, app);
bool value = furi_hal_rtc_is_flag_set(FuriHalRtcFlagHandOrient);
variable_item_set_current_value_index(item, value);
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
var_item_list,
"Butthurt Timer",
COUNT_OF(butthurt_timer_names),
xtreme_app_scene_misc_butthurt_timer_changed,
app);
value_index = value_index_int32(
xtreme_settings->butthurt_timer, butthurt_timer_values, COUNT_OF(butthurt_timer_names));
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, butthurt_timer_names[value_index]);
variable_item_list_set_enter_callback(
var_item_list, xtreme_app_scene_misc_var_item_list_callback, app);

View File

@@ -17,9 +17,9 @@ static void xtreme_app_scene_protocols_frequencies_add_text_input_callback(void*
bool is_hopper =
scene_manager_get_scene_state(app->scene_manager, XtremeAppSceneProtocolsFrequenciesAdd);
if(is_hopper) {
FrequencyList_push_back(app->subghz_hopper_frequencies, value);
FrequencyList_push_back(app->subghz_hopper_freqs, value);
} else {
FrequencyList_push_back(app->subghz_static_frequencies, value);
FrequencyList_push_back(app->subghz_static_freqs, value);
}
app->save_subghz_frequencies = true;
view_dispatcher_send_custom_event(app->view_dispatcher, TextInputResultOk);

View File

@@ -16,7 +16,7 @@ void xtreme_app_scene_protocols_frequencies_hopper_var_item_list_callback(
static void xtreme_app_scene_protocols_frequencies_hopper_frequency_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
app->subghz_hopper_index = variable_item_get_current_value_index(item);
uint32_t value = *FrequencyList_get(app->subghz_hopper_frequencies, app->subghz_hopper_index);
uint32_t value = *FrequencyList_get(app->subghz_hopper_freqs, app->subghz_hopper_index);
char text[10] = {0};
snprintf(text, sizeof(text), "%lu.%02lu", value / 1000000, (value % 1000000) / 10000);
variable_item_set_current_value_text(item, text);
@@ -30,14 +30,14 @@ void xtreme_app_scene_protocols_frequencies_hopper_on_enter(void* context) {
item = variable_item_list_add(
var_item_list,
"Hopper Freq",
FrequencyList_size(app->subghz_hopper_frequencies),
FrequencyList_size(app->subghz_hopper_freqs),
xtreme_app_scene_protocols_frequencies_hopper_frequency_changed,
app);
app->subghz_hopper_index = 0;
variable_item_set_current_value_index(item, app->subghz_hopper_index);
if(FrequencyList_size(app->subghz_hopper_frequencies)) {
if(FrequencyList_size(app->subghz_hopper_freqs)) {
uint32_t value =
*FrequencyList_get(app->subghz_hopper_frequencies, app->subghz_hopper_index);
*FrequencyList_get(app->subghz_hopper_freqs, app->subghz_hopper_index);
char text[10] = {0};
snprintf(text, sizeof(text), "%lu.%02lu", value / 1000000, (value % 1000000) / 10000);
variable_item_set_current_value_text(item, text);
@@ -70,14 +70,14 @@ bool xtreme_app_scene_protocols_frequencies_hopper_on_event(void* context, Scene
consumed = true;
switch(event.event) {
case VarItemListIndexRemoveHopperFreq:
if(!FrequencyList_size(app->subghz_hopper_frequencies)) break;
if(!FrequencyList_size(app->subghz_hopper_freqs)) break;
uint32_t value =
*FrequencyList_get(app->subghz_hopper_frequencies, app->subghz_hopper_index);
*FrequencyList_get(app->subghz_hopper_freqs, app->subghz_hopper_index);
FrequencyList_it_t it;
FrequencyList_it(it, app->subghz_hopper_frequencies);
FrequencyList_it(it, app->subghz_hopper_freqs);
while(!FrequencyList_end_p(it)) {
if(*FrequencyList_ref(it) == value) {
FrequencyList_remove(app->subghz_hopper_frequencies, it);
FrequencyList_remove(app->subghz_hopper_freqs, it);
} else {
FrequencyList_next(it);
}

View File

@@ -16,7 +16,7 @@ void xtreme_app_scene_protocols_frequencies_static_var_item_list_callback(
static void xtreme_app_scene_protocols_frequencies_static_frequency_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
app->subghz_static_index = variable_item_get_current_value_index(item);
uint32_t value = *FrequencyList_get(app->subghz_static_frequencies, app->subghz_static_index);
uint32_t value = *FrequencyList_get(app->subghz_static_freqs, app->subghz_static_index);
char text[10] = {0};
snprintf(text, sizeof(text), "%lu.%02lu", value / 1000000, (value % 1000000) / 10000);
variable_item_set_current_value_text(item, text);
@@ -30,14 +30,14 @@ void xtreme_app_scene_protocols_frequencies_static_on_enter(void* context) {
item = variable_item_list_add(
var_item_list,
"Static Freq",
FrequencyList_size(app->subghz_static_frequencies),
FrequencyList_size(app->subghz_static_freqs),
xtreme_app_scene_protocols_frequencies_static_frequency_changed,
app);
app->subghz_static_index = 0;
variable_item_set_current_value_index(item, app->subghz_static_index);
if(FrequencyList_size(app->subghz_static_frequencies)) {
if(FrequencyList_size(app->subghz_static_freqs)) {
uint32_t value =
*FrequencyList_get(app->subghz_static_frequencies, app->subghz_static_index);
*FrequencyList_get(app->subghz_static_freqs, app->subghz_static_index);
char text[10] = {0};
snprintf(text, sizeof(text), "%lu.%02lu", value / 1000000, (value % 1000000) / 10000);
variable_item_set_current_value_text(item, text);
@@ -70,14 +70,14 @@ bool xtreme_app_scene_protocols_frequencies_static_on_event(void* context, Scene
consumed = true;
switch(event.event) {
case VarItemListIndexRemoveStaticFreq:
if(!FrequencyList_size(app->subghz_static_frequencies)) break;
if(!FrequencyList_size(app->subghz_static_freqs)) break;
uint32_t value =
*FrequencyList_get(app->subghz_static_frequencies, app->subghz_static_index);
*FrequencyList_get(app->subghz_static_freqs, app->subghz_static_index);
FrequencyList_it_t it;
FrequencyList_it(it, app->subghz_static_frequencies);
FrequencyList_it(it, app->subghz_static_freqs);
while(!FrequencyList_end_p(it)) {
if(*FrequencyList_ref(it) == value) {
FrequencyList_remove(app->subghz_static_frequencies, it);
FrequencyList_remove(app->subghz_static_freqs, it);
} else {
FrequencyList_next(it);
}

View File

@@ -1,12 +1,10 @@
#include "../xtreme_app.h"
enum VarItemListIndex {
VarItemListIndexGraphics,
VarItemListIndexMainmenu,
VarItemListIndexStatusbar,
VarItemListIndexInterface,
VarItemListIndexProtocols,
VarItemListIndexDolphin,
VarItemListIndexMisc,
VarItemListIndexVersion,
};
void xtreme_app_scene_start_var_item_list_callback(void* context, uint32_t index) {
@@ -18,13 +16,9 @@ void xtreme_app_scene_start_on_enter(void* context) {
XtremeApp* app = context;
VariableItemList* var_item_list = app->var_item_list;
variable_item_list_add(var_item_list, "Graphics", 0, NULL, app);
variable_item_list_add(var_item_list, "Mainmenu", 0, NULL, app);
variable_item_list_add(var_item_list, "Statusbar", 0, NULL, app);
variable_item_list_add(var_item_list, "Interface", 0, NULL, app);
variable_item_list_add(var_item_list, "Protocols", 0, NULL, app);
variable_item_list_add(var_item_list, "Dolphin", 0, NULL, app);
variable_item_list_add(var_item_list, "Misc", 0, NULL, app);
variable_item_list_add(var_item_list, furi_string_get_cstr(app->version_tag), 0, NULL, app);
variable_item_list_set_enter_callback(
@@ -44,21 +38,12 @@ bool xtreme_app_scene_start_on_event(void* context, SceneManagerEvent event) {
scene_manager_set_scene_state(app->scene_manager, XtremeAppSceneStart, event.event);
consumed = true;
switch(event.event) {
case VarItemListIndexGraphics:
scene_manager_next_scene(app->scene_manager, XtremeAppSceneGraphics);
break;
case VarItemListIndexMainmenu:
scene_manager_next_scene(app->scene_manager, XtremeAppSceneMainmenu);
break;
case VarItemListIndexStatusbar:
scene_manager_next_scene(app->scene_manager, XtremeAppSceneStatusbar);
case VarItemListIndexInterface:
scene_manager_next_scene(app->scene_manager, XtremeAppSceneInterface);
break;
case VarItemListIndexProtocols:
scene_manager_next_scene(app->scene_manager, XtremeAppSceneProtocols);
break;
case VarItemListIndexDolphin:
scene_manager_next_scene(app->scene_manager, XtremeAppSceneDolphin);
break;
case VarItemListIndexMisc:
scene_manager_next_scene(app->scene_manager, XtremeAppSceneMisc);
break;

View File

@@ -22,19 +22,15 @@ static bool xtreme_app_back_event_callback(void* context) {
Stream* stream = file_stream_alloc(storage);
if(file_stream_open(stream, XTREME_APPS_PATH, FSAM_READ_WRITE, FSOM_CREATE_ALWAYS)){
CharList_it_t it;
CharList_it(it, app->mainmenu_apps_paths);
for(uint i = 0; i < CharList_size(app->mainmenu_apps_paths); i++) {
stream_write_format(stream, "%s\n", *CharList_get(app->mainmenu_apps_paths, i));
CharList_it(it, app->mainmenu_app_paths);
for(uint i = 0; i < CharList_size(app->mainmenu_app_paths); i++) {
stream_write_format(stream, "%s\n", *CharList_get(app->mainmenu_app_paths, i));
}
}
file_stream_close(stream);
stream_free(stream);
}
if(app->save_subghz) {
furi_hal_subghz_set_extend_settings(app->subghz_extend, app->subghz_bypass);
}
if(app->save_subghz_frequencies) {
FlipperFormat* file = flipper_format_file_alloc(storage);
do {
@@ -54,33 +50,28 @@ static bool xtreme_app_back_event_callback(void* context) {
if(!flipper_format_rewind(file)) break;
while(flipper_format_delete_key(file, "Frequency"))
;
FrequencyList_it(it, app->subghz_static_frequencies);
for(uint i = 0; i < FrequencyList_size(app->subghz_static_frequencies); i++) {
FrequencyList_it(it, app->subghz_static_freqs);
for(uint i = 0; i < FrequencyList_size(app->subghz_static_freqs); i++) {
flipper_format_write_uint32(
file, "Frequency", FrequencyList_get(app->subghz_static_frequencies, i), 1);
file, "Frequency", FrequencyList_get(app->subghz_static_freqs, i), 1);
}
if(!flipper_format_rewind(file)) break;
while(flipper_format_delete_key(file, "Hopper_frequency"))
;
for(uint i = 0; i < FrequencyList_size(app->subghz_hopper_frequencies); i++) {
for(uint i = 0; i < FrequencyList_size(app->subghz_hopper_freqs); i++) {
flipper_format_write_uint32(
file,
"Hopper_frequency",
FrequencyList_get(app->subghz_hopper_frequencies, i),
FrequencyList_get(app->subghz_hopper_freqs, i),
1);
}
} while(false);
flipper_format_free(file);
}
if(app->save_level) {
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
int xp = app->dolphin_level > 1 ? dolphin_get_levels()[app->dolphin_level - 2] : 0;
dolphin->state->data.icounter = xp + 1;
dolphin->state->dirty = true;
dolphin_state_save(dolphin->state);
furi_record_close(RECORD_DOLPHIN);
if(app->save_subghz) {
furi_hal_subghz_set_extend_settings(app->subghz_extend, app->subghz_bypass);
}
if(app->save_name) {
@@ -114,6 +105,15 @@ static bool xtreme_app_back_event_callback(void* context) {
}
}
if(app->save_level) {
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
int32_t xp = app->xp_level > 1 ? dolphin_get_levels()[app->xp_level - 2] : 0;
dolphin->state->data.icounter = xp + 1;
dolphin->state->dirty = true;
dolphin_state_save(dolphin->state);
furi_record_close(RECORD_DOLPHIN);
}
if(app->save_settings) {
XTREME_SETTINGS_SAVE();
}
@@ -171,8 +171,8 @@ XtremeApp* xtreme_app_alloc() {
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
app->asset_pack = 0;
CharList_init(app->asset_packs);
app->asset_pack_index = 0;
CharList_init(app->asset_pack_names);
Storage* storage = furi_record_open(RECORD_STORAGE);
File* folder = storage_file_alloc(storage);
FileInfo info;
@@ -184,18 +184,18 @@ XtremeApp* xtreme_app_alloc() {
strlcpy(copy, name, MAX_PACK_NAME_LEN);
uint idx = 0;
if(strcmp(copy, "NSFW") != 0) {
for(; idx < CharList_size(app->asset_packs); idx++) {
char* comp = *CharList_get(app->asset_packs, idx);
for(; idx < CharList_size(app->asset_pack_names); idx++) {
char* comp = *CharList_get(app->asset_pack_names, idx);
if(strcasecmp(copy, comp) < 0 && strcmp(comp, "NSFW") != 0) {
break;
}
}
}
CharList_push_at(app->asset_packs, idx, copy);
if(app->asset_pack != 0) {
if(idx < app->asset_pack) app->asset_pack++;
CharList_push_at(app->asset_pack_names, idx, copy);
if(app->asset_pack_index != 0) {
if(idx < app->asset_pack_index) app->asset_pack_index++;
} else {
if(strcmp(copy, xtreme_settings->asset_pack) == 0) app->asset_pack = idx + 1;
if(strcmp(copy, xtreme_settings->asset_pack) == 0) app->asset_pack_index = idx + 1;
}
}
}
@@ -203,17 +203,17 @@ XtremeApp* xtreme_app_alloc() {
free(name);
storage_file_free(folder);
CharList_init(app->mainmenu_apps_names);
CharList_init(app->mainmenu_apps_paths);
CharList_init(app->mainmenu_app_names);
CharList_init(app->mainmenu_app_paths);
Stream* stream = file_stream_alloc(storage);
FuriString* line = furi_string_alloc();
if(file_stream_open(stream, XTREME_APPS_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) {
while(stream_read_line(stream, line)) {
furi_string_replace_all(line, "\r", "");
furi_string_replace_all(line, "\n", "");
CharList_push_back(app->mainmenu_apps_paths, strdup(furi_string_get_cstr(line)));
CharList_push_back(app->mainmenu_app_paths, strdup(furi_string_get_cstr(line)));
fap_loader_load_name_and_icon(line, storage, NULL, line);
CharList_push_back(app->mainmenu_apps_names, strdup(furi_string_get_cstr(line)));
CharList_push_back(app->mainmenu_app_names, strdup(furi_string_get_cstr(line)));
}
}
furi_string_free(line);
@@ -221,8 +221,8 @@ XtremeApp* xtreme_app_alloc() {
stream_free(stream);
FlipperFormat* file = flipper_format_file_alloc(storage);
FrequencyList_init(app->subghz_static_frequencies);
FrequencyList_init(app->subghz_hopper_frequencies);
FrequencyList_init(app->subghz_static_freqs);
FrequencyList_init(app->subghz_hopper_freqs);
app->subghz_use_defaults = true;
do {
uint32_t temp;
@@ -233,14 +233,14 @@ XtremeApp* xtreme_app_alloc() {
if(!flipper_format_rewind(file)) break;
while(flipper_format_read_uint32(file, "Frequency", &temp, 1)) {
if(furi_hal_subghz_is_frequency_valid(temp)) {
FrequencyList_push_back(app->subghz_static_frequencies, temp);
FrequencyList_push_back(app->subghz_static_freqs, temp);
}
}
if(!flipper_format_rewind(file)) break;
while(flipper_format_read_uint32(file, "Hopper_frequency", &temp, 1)) {
if(furi_hal_subghz_is_frequency_valid(temp)) {
FrequencyList_push_back(app->subghz_hopper_frequencies, temp);
FrequencyList_push_back(app->subghz_hopper_freqs, temp);
}
}
} while(false);
@@ -249,13 +249,13 @@ XtremeApp* xtreme_app_alloc() {
furi_hal_subghz_get_extend_settings(&app->subghz_extend, &app->subghz_bypass);
strlcpy(app->device_name, furi_hal_version_get_name_ptr(), NAMECHANGER_TEXT_STORE_SIZE);
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
DolphinStats stats = dolphin_stats(dolphin);
app->dolphin_level = stats.level;
app->xp_level = stats.level;
furi_record_close(RECORD_DOLPHIN);
strlcpy(app->device_name, furi_hal_version_get_name_ptr(), NAMECHANGER_TEXT_STORE_SIZE);
app->version_tag =
furi_string_alloc_printf("%s %s", version_get_version(NULL), version_get_builddate(NULL));
@@ -280,21 +280,22 @@ void xtreme_app_free(XtremeApp* app) {
// Settings deinit
CharList_it_t it;
for(CharList_it(it, app->asset_packs); !CharList_end_p(it); CharList_next(it)) {
for(CharList_it(it, app->asset_pack_names); !CharList_end_p(it); CharList_next(it)) {
free(*CharList_cref(it));
}
CharList_clear(app->asset_packs);
for(CharList_it(it, app->mainmenu_apps_names); !CharList_end_p(it); CharList_next(it)) {
free(*CharList_cref(it));
}
CharList_clear(app->mainmenu_apps_names);
for(CharList_it(it, app->mainmenu_apps_paths); !CharList_end_p(it); CharList_next(it)) {
free(*CharList_cref(it));
}
CharList_clear(app->mainmenu_apps_paths);
CharList_clear(app->asset_pack_names);
FrequencyList_clear(app->subghz_static_frequencies);
FrequencyList_clear(app->subghz_hopper_frequencies);
for(CharList_it(it, app->mainmenu_app_names); !CharList_end_p(it); CharList_next(it)) {
free(*CharList_cref(it));
}
CharList_clear(app->mainmenu_app_names);
for(CharList_it(it, app->mainmenu_app_paths); !CharList_end_p(it); CharList_next(it)) {
free(*CharList_cref(it));
}
CharList_clear(app->mainmenu_app_paths);
FrequencyList_clear(app->subghz_static_freqs);
FrequencyList_clear(app->subghz_hopper_freqs);
furi_string_free(app->version_tag);

View File

@@ -36,27 +36,29 @@ typedef struct {
VariableItemList* var_item_list;
TextInput* text_input;
Popup* popup;
uint asset_pack;
CharList_t asset_packs;
CharList_t mainmenu_apps_names;
CharList_t mainmenu_apps_paths;
CharList_t asset_pack_names;
uint8_t asset_pack_index;
CharList_t mainmenu_app_names;
CharList_t mainmenu_app_paths;
uint8_t mainmenu_app_index;
bool subghz_use_defaults;
FrequencyList_t subghz_static_frequencies;
FrequencyList_t subghz_static_freqs;
uint8_t subghz_static_index;
FrequencyList_t subghz_hopper_frequencies;
FrequencyList_t subghz_hopper_freqs;
uint8_t subghz_hopper_index;
char subghz_freq_buffer[XTREME_SUBGHZ_FREQ_BUFFER_SIZE];
bool subghz_extend;
bool subghz_bypass;
int dolphin_level;
char device_name[NAMECHANGER_TEXT_STORE_SIZE];
int32_t xp_level;
FuriString* version_tag;
bool save_mainmenu_apps;
bool save_subghz;
bool save_subghz_frequencies;
bool save_level;
bool save_subghz;
bool save_name;
bool save_level;
bool save_settings;
bool require_reboot;
} XtremeApp;

View File

@@ -44,11 +44,11 @@ void XTREME_SETTINGS_LOAD() {
xtreme_settings->status_icons = true; // ON
xtreme_settings->bar_borders = true; // ON
xtreme_settings->bar_background = false; // OFF
xtreme_settings->sort_dirs_first = true; // ON
xtreme_settings->dark_mode = false; // OFF
xtreme_settings->bad_bt = false; // USB
xtreme_settings->bad_bt_remember = false; // OFF
xtreme_settings->butthurt_timer = 43200; // 12 H
xtreme_settings->sort_dirs_first = true; // ON
xtreme_settings->dark_mode = false; // OFF
}
}
}

View File

@@ -15,16 +15,13 @@ extern "C" {
#define MAX_PACK_NAME_LEN 32
#define XTREME_SETTINGS_VERSION (6)
#define XTREME_SETTINGS_VERSION (7)
#define XTREME_SETTINGS_PATH_OLD INT_PATH(XTREME_SETTINGS_FILE_NAME)
#define XTREME_SETTINGS_PATH EXT_PATH(XTREME_SETTINGS_FILE_NAME)
#define XTREME_SETTINGS_MAGIC (0x69)
#define XTREME_APPS_PATH EXT_PATH(XTREME_APPS_FILE_NAME)
// Some settings function backwards (logically) in
// order to fit the default value we want
// (values will default to 0 / false)
typedef struct {
char asset_pack[MAX_PACK_NAME_LEN];
uint16_t anim_speed;
@@ -35,11 +32,11 @@ typedef struct {
bool status_icons;
bool bar_borders;
bool bar_background;
bool sort_dirs_first;
bool dark_mode;
bool bad_bt;
bool bad_bt_remember;
int32_t butthurt_timer;
bool sort_dirs_first;
bool dark_mode;
} XtremeSettings;
XtremeSettings* XTREME_SETTINGS();