mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Change mood in xfw app
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
|
||||
enum VarItemListIndex {
|
||||
VarItemListIndexChangeDeviceName,
|
||||
VarItemListIndexXpLevel,
|
||||
VarItemListIndexDolphinLevel,
|
||||
VarItemListIndexDolphinAngry,
|
||||
VarItemListIndexButthurtTimer,
|
||||
VarItemListIndexRgbBacklight,
|
||||
VarItemListIndexLcdColor,
|
||||
@@ -13,15 +14,24 @@ 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_xp_level_changed(VariableItem* item) {
|
||||
static void xtreme_app_scene_misc_dolphin_level_changed(VariableItem* item) {
|
||||
XtremeApp* app = variable_item_get_context(item);
|
||||
app->xp_level = variable_item_get_current_value_index(item) + 1;
|
||||
app->dolphin_level = variable_item_get_current_value_index(item) + 1;
|
||||
char level_str[4];
|
||||
snprintf(level_str, 4, "%li", app->xp_level);
|
||||
snprintf(level_str, 4, "%li", app->dolphin_level);
|
||||
variable_item_set_current_value_text(item, level_str);
|
||||
app->save_level = true;
|
||||
}
|
||||
|
||||
static void xtreme_app_scene_misc_dolphin_angry_changed(VariableItem* item) {
|
||||
XtremeApp* app = variable_item_get_context(item);
|
||||
app->dolphin_angry = variable_item_get_current_value_index(item);
|
||||
char angry_str[4];
|
||||
snprintf(angry_str, 4, "%li", app->dolphin_angry);
|
||||
variable_item_set_current_value_text(item, angry_str);
|
||||
app->save_angry = 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)] =
|
||||
@@ -54,16 +64,27 @@ void xtreme_app_scene_misc_on_enter(void* context) {
|
||||
variable_item_list_add(var_item_list, "Change Device Name", 0, NULL, app);
|
||||
|
||||
char level_str[4];
|
||||
snprintf(level_str, 4, "%li", app->xp_level);
|
||||
snprintf(level_str, 4, "%li", app->dolphin_level);
|
||||
item = variable_item_list_add(
|
||||
var_item_list,
|
||||
"XP Level",
|
||||
"Dolphin Level",
|
||||
DOLPHIN_LEVEL_COUNT + 1,
|
||||
xtreme_app_scene_misc_xp_level_changed,
|
||||
xtreme_app_scene_misc_dolphin_level_changed,
|
||||
app);
|
||||
variable_item_set_current_value_index(item, app->xp_level - 1);
|
||||
variable_item_set_current_value_index(item, app->dolphin_level - 1);
|
||||
variable_item_set_current_value_text(item, level_str);
|
||||
|
||||
char angry_str[4];
|
||||
snprintf(angry_str, 4, "%li", app->dolphin_angry);
|
||||
item = variable_item_list_add(
|
||||
var_item_list,
|
||||
"Dolphin Angry",
|
||||
BUTTHURT_MAX + 1,
|
||||
xtreme_app_scene_misc_dolphin_angry_changed,
|
||||
app);
|
||||
variable_item_set_current_value_index(item, app->dolphin_angry);
|
||||
variable_item_set_current_value_text(item, angry_str);
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list,
|
||||
"Butthurt Timer",
|
||||
|
||||
@@ -84,10 +84,15 @@ bool xtreme_app_apply(XtremeApp* app) {
|
||||
}
|
||||
}
|
||||
|
||||
if(app->save_level) {
|
||||
if(app->save_level || app->save_angry) {
|
||||
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;
|
||||
if(app->save_level) {
|
||||
int32_t xp = app->dolphin_level > 1 ? dolphin_get_levels()[app->dolphin_level - 2] : 0;
|
||||
dolphin->state->data.icounter = xp + 1;
|
||||
}
|
||||
if(app->save_angry) {
|
||||
dolphin->state->data.butthurt = app->dolphin_angry;
|
||||
}
|
||||
dolphin->state->dirty = true;
|
||||
dolphin_state_save(dolphin->state);
|
||||
furi_record_close(RECORD_DOLPHIN);
|
||||
@@ -253,7 +258,8 @@ XtremeApp* xtreme_app_alloc() {
|
||||
|
||||
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
|
||||
DolphinStats stats = dolphin_stats(dolphin);
|
||||
app->xp_level = stats.level;
|
||||
app->dolphin_level = stats.level;
|
||||
app->dolphin_angry = stats.butthurt;
|
||||
furi_record_close(RECORD_DOLPHIN);
|
||||
|
||||
app->version_tag =
|
||||
|
||||
@@ -52,7 +52,8 @@ typedef struct {
|
||||
char subghz_freq_buffer[XTREME_SUBGHZ_FREQ_BUFFER_SIZE];
|
||||
bool subghz_extend;
|
||||
char device_name[FURI_HAL_VERSION_ARRAY_NAME_LENGTH];
|
||||
int32_t xp_level;
|
||||
int32_t dolphin_level;
|
||||
int32_t dolphin_angry;
|
||||
FuriString* version_tag;
|
||||
|
||||
bool save_mainmenu_apps;
|
||||
@@ -60,6 +61,7 @@ typedef struct {
|
||||
bool save_subghz;
|
||||
bool save_name;
|
||||
bool save_level;
|
||||
bool save_angry;
|
||||
bool save_backlight;
|
||||
bool save_settings;
|
||||
bool show_slideshow;
|
||||
|
||||
@@ -18,9 +18,6 @@ const int DOLPHIN_LEVELS[DOLPHIN_LEVEL_COUNT] = {100, 200, 300, 450, 600, 7
|
||||
3700, 4050, 4450, 4850, 5250, 5700, 6150, 6600,
|
||||
7100, 7600, 8100, 8650, 9200};
|
||||
|
||||
#define BUTTHURT_MAX 14
|
||||
#define BUTTHURT_MIN 0
|
||||
|
||||
DolphinState* dolphin_state_alloc() {
|
||||
return malloc(sizeof(DolphinState));
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ extern "C" {
|
||||
|
||||
#define DOLPHIN_LEVEL_COUNT 29
|
||||
|
||||
#define BUTTHURT_MAX 14
|
||||
#define BUTTHURT_MIN 0
|
||||
|
||||
typedef struct DolphinState DolphinState;
|
||||
typedef struct {
|
||||
uint8_t icounter_daily_limit[DolphinAppMAX];
|
||||
|
||||
Reference in New Issue
Block a user