mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-07 05:29:09 -07:00
Add reset menu apps button
This commit is contained in:
@@ -4,6 +4,7 @@ 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_mainmenu_add_main, InterfaceMainmenuAddMain)
|
||||
ADD_SCENE(xtreme_app, interface_mainmenu_reset, InterfaceMainmenuReset)
|
||||
ADD_SCENE(xtreme_app, interface_lockscreen, InterfaceLockscreen)
|
||||
ADD_SCENE(xtreme_app, interface_statusbar, InterfaceStatusbar)
|
||||
ADD_SCENE(xtreme_app, interface_filebrowser, InterfaceFilebrowser)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
enum VarItemListIndex {
|
||||
VarItemListIndexMenuStyle,
|
||||
VarItemListIndexResetMenu,
|
||||
VarItemListIndexMenuApp,
|
||||
VarItemListIndexAddApp,
|
||||
VarItemListIndexMoveApp,
|
||||
@@ -65,6 +66,8 @@ void xtreme_app_scene_interface_mainmenu_on_enter(void* context) {
|
||||
variable_item_set_current_value_text(
|
||||
item, xtreme_settings->wii_menu ? "Wii Grid" : "App List");
|
||||
|
||||
variable_item_list_add(var_item_list, "Reset Menu", 0, NULL, app);
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list,
|
||||
"Menu App",
|
||||
@@ -113,6 +116,9 @@ bool xtreme_app_scene_interface_mainmenu_on_event(void* context, SceneManagerEve
|
||||
app->scene_manager, XtremeAppSceneInterfaceMainmenu, event.event);
|
||||
consumed = true;
|
||||
switch(event.event) {
|
||||
case VarItemListIndexResetMenu:
|
||||
scene_manager_next_scene(app->scene_manager, XtremeAppSceneInterfaceMainmenuReset);
|
||||
break;
|
||||
case VarItemListIndexRemoveApp:
|
||||
if(!CharList_size(app->mainmenu_app_labels)) break;
|
||||
if(!CharList_size(app->mainmenu_app_exes)) break;
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#include "../xtreme_app.h"
|
||||
|
||||
static void
|
||||
xtreme_app_scene_interface_mainmenu_reset_dialog_callback(DialogExResult result, void* context) {
|
||||
XtremeApp* app = context;
|
||||
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
|
||||
void xtreme_app_scene_interface_mainmenu_reset_on_enter(void* context) {
|
||||
XtremeApp* app = context;
|
||||
DialogEx* dialog_ex = app->dialog_ex;
|
||||
|
||||
dialog_ex_set_header(dialog_ex, "Reset Menu Apps?", 64, 10, AlignCenter, AlignCenter);
|
||||
dialog_ex_set_text(dialog_ex, "Your edits will be lost!", 64, 32, AlignCenter, AlignCenter);
|
||||
dialog_ex_set_left_button_text(dialog_ex, "Cancel");
|
||||
dialog_ex_set_right_button_text(dialog_ex, "Reset");
|
||||
|
||||
dialog_ex_set_context(dialog_ex, app);
|
||||
dialog_ex_set_result_callback(
|
||||
dialog_ex, xtreme_app_scene_interface_mainmenu_reset_dialog_callback);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, XtremeAppViewDialogEx);
|
||||
}
|
||||
|
||||
bool xtreme_app_scene_interface_mainmenu_reset_on_event(void* context, SceneManagerEvent event) {
|
||||
XtremeApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
switch(event.event) {
|
||||
case DialogExResultRight:
|
||||
storage_common_remove(furi_record_open(RECORD_STORAGE), XTREME_MENU_PATH);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
app->save_mainmenu_apps = false;
|
||||
app->require_reboot = true;
|
||||
xtreme_app_apply(app);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void xtreme_app_scene_interface_mainmenu_reset_on_exit(void* context) {
|
||||
XtremeApp* app = context;
|
||||
DialogEx* dialog_ex = app->dialog_ex;
|
||||
|
||||
dialog_ex_reset(dialog_ex);
|
||||
}
|
||||
@@ -196,6 +196,10 @@ XtremeApp* xtreme_app_alloc() {
|
||||
app->popup = popup_alloc();
|
||||
view_dispatcher_add_view(app->view_dispatcher, XtremeAppViewPopup, popup_get_view(app->popup));
|
||||
|
||||
app->dialog_ex = dialog_ex_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, XtremeAppViewDialogEx, dialog_ex_get_view(app->dialog_ex));
|
||||
|
||||
// Settings init
|
||||
|
||||
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
|
||||
@@ -315,6 +319,8 @@ void xtreme_app_free(XtremeApp* app) {
|
||||
text_input_free(app->text_input);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, XtremeAppViewPopup);
|
||||
popup_free(app->popup);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, XtremeAppViewDialogEx);
|
||||
dialog_ex_free(app->dialog_ex);
|
||||
|
||||
// View Dispatcher and Scene Manager
|
||||
view_dispatcher_free(app->view_dispatcher);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/scene_manager.h>
|
||||
#include <dialogs/dialogs.h>
|
||||
#include <gui/modules/dialog_ex.h>
|
||||
#include <assets_icons.h>
|
||||
#include <applications.h>
|
||||
#include <gui/modules/variable_item_list.h>
|
||||
@@ -42,6 +43,7 @@ typedef struct {
|
||||
Submenu* submenu;
|
||||
TextInput* text_input;
|
||||
Popup* popup;
|
||||
DialogEx* dialog_ex;
|
||||
|
||||
CharList_t asset_pack_names;
|
||||
uint8_t asset_pack_index;
|
||||
@@ -78,6 +80,7 @@ typedef enum {
|
||||
XtremeAppViewSubmenu,
|
||||
XtremeAppViewTextInput,
|
||||
XtremeAppViewPopup,
|
||||
XtremeAppViewDialogEx,
|
||||
} XtremeAppView;
|
||||
|
||||
bool xtreme_app_apply(XtremeApp* app);
|
||||
|
||||
Reference in New Issue
Block a user