Skip to content

Commit

Permalink
Moved midnight format setting into new Interface > General
Browse files Browse the repository at this point in the history
  • Loading branch information
956MB committed Jan 25, 2025
1 parent ff7bae0 commit 9ab9a26
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ADD_SCENE(momentum_app, interface_mainmenu_style, InterfaceMainmenuStyle)
ADD_SCENE(momentum_app, interface_lockscreen, InterfaceLockscreen)
ADD_SCENE(momentum_app, interface_statusbar, InterfaceStatusbar)
ADD_SCENE(momentum_app, interface_filebrowser, InterfaceFilebrowser)
ADD_SCENE(momentum_app, interface_general, InterfaceGeneral)
ADD_SCENE(momentum_app, protocols, Protocols)
ADD_SCENE(momentum_app, protocols_freqs, ProtocolsFreqs)
ADD_SCENE(momentum_app, protocols_freqs_static, ProtocolsFreqsStatic)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ enum VarItemListIndex {
VarItemListIndexLockscreen,
VarItemListIndexStatusbar,
VarItemListIndexFileBrowser,
VarItemListIndexGeneral,
};

void momentum_app_scene_interface_var_item_list_callback(void* context, uint32_t index) {
Expand Down Expand Up @@ -33,6 +34,9 @@ void momentum_app_scene_interface_on_enter(void* context) {
item = variable_item_list_add(var_item_list, "File Browser", 0, NULL, app);
variable_item_set_current_value_text(item, ">");

item = variable_item_list_add(var_item_list, "General", 0, NULL, app);
variable_item_set_current_value_text(item, ">");

variable_item_list_set_enter_callback(
var_item_list, momentum_app_scene_interface_var_item_list_callback, app);

Expand Down Expand Up @@ -76,6 +80,10 @@ bool momentum_app_scene_interface_on_event(void* context, SceneManagerEvent even
app->scene_manager, MomentumAppSceneInterfaceFilebrowser, 0);
scene_manager_next_scene(app->scene_manager, MomentumAppSceneInterfaceFilebrowser);
break;
case VarItemListIndexGeneral:
scene_manager_set_scene_state(app->scene_manager, MomentumAppSceneInterfaceGeneral, 0);
scene_manager_next_scene(app->scene_manager, MomentumAppSceneInterfaceGeneral);
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include "../momentum_app.h"

enum VarItemListIndex {
VarItemListIndexMidnightFormat,
};

void momentum_app_scene_interface_general_var_item_list_callback(void* context, uint32_t index) {
MomentumApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, index);
}

static void momentum_app_scene_interface_general_midnight_format_changed(VariableItem* item) {
MomentumApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "00:XX" : "XX:00");
momentum_settings.midnight_format_00 = value;
app->save_settings = true;
}

void momentum_app_scene_interface_general_on_enter(void* context) {
MomentumApp* app = context;
VariableItemList* var_item_list = app->var_item_list;
VariableItem* item;

item = variable_item_list_add(
var_item_list,
"Clock Midnight Format",
2,
momentum_app_scene_interface_general_midnight_format_changed,
app);
variable_item_set_current_value_index(item, momentum_settings.midnight_format_00);
variable_item_set_current_value_text(
item, momentum_settings.midnight_format_00 ? "00:XX" : "12:XX");

variable_item_list_set_enter_callback(
var_item_list, momentum_app_scene_interface_general_var_item_list_callback, app);

variable_item_list_set_selected_item(
var_item_list,
scene_manager_get_scene_state(app->scene_manager, MomentumAppSceneInterfaceGeneral));

view_dispatcher_switch_to_view(app->view_dispatcher, MomentumAppViewVarItemList);
}

bool momentum_app_scene_interface_general_on_event(void* context, SceneManagerEvent event) {
MomentumApp* app = context;
bool consumed = false;

if(event.type == SceneManagerEventTypeCustom) {
scene_manager_set_scene_state(
app->scene_manager, MomentumAppSceneInterfaceGeneral, event.event);
consumed = true;
}

return consumed;
}

void momentum_app_scene_interface_general_on_exit(void* context) {
MomentumApp* app = context;
variable_item_list_reset(app->var_item_list);
}
19 changes: 0 additions & 19 deletions applications/main/momentum_app/scenes/momentum_app_scene_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ enum VarItemListIndex {
VarItemListIndexSpoof,
VarItemListIndexVgm,
VarItemListIndexChargeCap,
VarItemListIndexMidnightFormat,
VarItemListIndexShowMomentumIntro,
};

Expand All @@ -26,14 +25,6 @@ static void momentum_app_scene_misc_charge_cap_changed(VariableItem* item) {
app->save_settings = true;
}

static void momentum_app_scene_interface_midnight_format_changed(VariableItem* item) {
MomentumApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "00:XX" : "12:XX");
momentum_settings.midnight_format_00 = value;
app->save_settings = true;
}

void momentum_app_scene_misc_on_enter(void* context) {
MomentumApp* app = context;
VariableItemList* var_item_list = app->var_item_list;
Expand Down Expand Up @@ -64,16 +55,6 @@ void momentum_app_scene_misc_on_enter(void* context) {
variable_item_set_current_value_index(item, value_index - 1);
variable_item_set_current_value_text(item, cap_str);

item = variable_item_list_add(
var_item_list,
"Clock Midnight Format",
2,
momentum_app_scene_interface_midnight_format_changed,
app);
variable_item_set_current_value_index(item, momentum_settings.midnight_format_00);
variable_item_set_current_value_text(
item, momentum_settings.midnight_format_00 ? "00:XX" : "12:XX");

variable_item_list_add(var_item_list, "Show Momentum Intro", 0, NULL, app);

variable_item_list_set_enter_callback(
Expand Down

0 comments on commit 9ab9a26

Please sign in to comment.