diff --git a/applications/settings/dolphin_passport/passport.c b/applications/settings/dolphin_passport/passport.c index c4104a255..83f67ad1c 100644 --- a/applications/settings/dolphin_passport/passport.c +++ b/applications/settings/dolphin_passport/passport.c @@ -7,35 +7,9 @@ #include #include "dolphin/dolphin.h" #include "../xtreme_settings/xtreme_settings.h" +#include "../xtreme_settings/xtreme_assets.h" #include "math.h" -#define MOODS_TOTAL 3 -#define BUTTHURT_MAX 3 - -static const Icon* const portrait_happy_sfw[BUTTHURT_MAX] = { - &I_passport_happy1_46x49_sfw, - &I_passport_happy2_46x49_sfw, - &I_passport_happy3_46x49_sfw}; -static const Icon* const portrait_ok_sfw[BUTTHURT_MAX] = { - &I_passport_okay1_46x49_sfw, - &I_passport_okay2_46x49_sfw, - &I_passport_okay3_46x49_sfw}; -static const Icon* const portrait_bad_sfw[BUTTHURT_MAX] = { - &I_passport_bad1_46x49_sfw, - &I_passport_bad2_46x49_sfw, - &I_passport_bad3_46x49_sfw}; - -static const Icon* const portrait_happy[BUTTHURT_MAX] = {&I_flipper}; -static const Icon* const portrait_ok[BUTTHURT_MAX] = {&I_flipper}; -static const Icon* const portrait_bad[BUTTHURT_MAX] = {&I_flipper}; - -static const Icon* const* portraits_sfw[MOODS_TOTAL] = { - portrait_happy_sfw, - portrait_ok_sfw, - portrait_bad_sfw}; -static const Icon* const* portraits[MOODS_TOTAL] = {portrait_happy, portrait_ok, portrait_bad}; -// static const Icon* const* portraits[MOODS_TOTAL] = {portrait_happy}; - typedef struct { FuriSemaphore* semaphore; DolphinStats* stats; @@ -64,30 +38,30 @@ static void render_callback(Canvas* canvas, void* _ctx) { char level_str[20]; char xp_str[12]; - char mood_str[32]; - uint8_t mood = 0; + const char* mood_str = NULL; + const Icon* portrait = NULL; if(xtreme_settings->sfw_mode) { if(stats->butthurt <= 4) { - mood = 0; - snprintf(mood_str, 20, "Mood: Happy"); + portrait = XTREME_ASSETS()->passport_happy; + mood_str = "Mood: Happy"; } else if(stats->butthurt <= 9) { - mood = 1; - snprintf(mood_str, 20, "Mood: Okay"); + portrait = XTREME_ASSETS()->passport_okay; + mood_str = "Mood: Okay"; } else { - mood = 2; - snprintf(mood_str, 20, "Mood: Angry"); + portrait = XTREME_ASSETS()->passport_angry; + mood_str = "Mood: Angry"; } } else { if(stats->butthurt <= 4) { - mood = 0; - snprintf(mood_str, 20, "Status: Wet"); + portrait = XTREME_ASSETS()->passport_happy; + mood_str = "Status: Wet"; } else if(stats->butthurt <= 9) { - mood = 1; - snprintf(mood_str, 20, "Status: Horny"); + portrait = XTREME_ASSETS()->passport_okay; + mood_str = "Status: Horny"; } else { - mood = 2; - snprintf(mood_str, 20, "Status: Desperate"); + portrait = XTREME_ASSETS()->passport_angry; + mood_str = "Status: Desperate"; } } uint32_t xp_progress = 0; @@ -116,12 +90,7 @@ static void render_callback(Canvas* canvas, void* _ctx) { // portrait furi_assert((stats->level > 0) && (stats->level <= DOLPHIN_LEVEL_COUNT + 1)); - uint16_t tmpLvl = 0; - if(xtreme_settings->sfw_mode) { - canvas_draw_icon(canvas, 11, 2, portraits_sfw[mood][tmpLvl]); - } else { - canvas_draw_icon(canvas, 11, 2, portraits[mood][tmpLvl]); - } + canvas_draw_icon(canvas, 11, 2, portrait); const char* my_name = furi_hal_version_get_name_ptr(); snprintf(level_str, 12, "Level: %hu", stats->level); diff --git a/applications/settings/xtreme_settings/xtreme_assets.c b/applications/settings/xtreme_settings/xtreme_assets.c new file mode 100644 index 000000000..49f67e97c --- /dev/null +++ b/applications/settings/xtreme_settings/xtreme_assets.c @@ -0,0 +1,26 @@ +#include "xtreme_assets.h" + +XtremeAssets* xtreme_assets = NULL; + +XtremeAssets* XTREME_ASSETS() { + if (xtreme_assets == NULL) { + XTREME_ASSETS_UPDATE(); + } + return xtreme_assets; +} + +void XTREME_ASSETS_UPDATE() { + if (xtreme_assets == NULL) { + xtreme_assets = malloc(sizeof(XtremeAssets)); + } + XtremeSettings* xtreme_settings = XTREME_SETTINGS(); + if (xtreme_settings->sfw_mode) { + xtreme_assets->passport_happy = &I_passport_happy1_46x49_sfw; + xtreme_assets->passport_okay = &I_passport_okay1_46x49_sfw; + xtreme_assets->passport_angry = &I_passport_bad1_46x49_sfw; + } else { + xtreme_assets->passport_happy = &I_flipper; + xtreme_assets->passport_okay = &I_flipper; + xtreme_assets->passport_angry = &I_flipper; + } +} diff --git a/applications/settings/xtreme_settings/xtreme_assets.h b/applications/settings/xtreme_settings/xtreme_assets.h new file mode 100644 index 000000000..157a0543b --- /dev/null +++ b/applications/settings/xtreme_settings/xtreme_assets.h @@ -0,0 +1,14 @@ +#pragma once + +#include "xtreme_settings.h" +#include "assets_icons.h" + +typedef struct { + const Icon* passport_happy; + const Icon* passport_okay; + const Icon* passport_angry; +} XtremeAssets; + +XtremeAssets* XTREME_ASSETS(); + +void XTREME_ASSETS_UPDATE(); diff --git a/applications/settings/xtreme_settings/xtreme_on_system_start.c b/applications/settings/xtreme_settings/xtreme_on_system_start.c index bc241aa74..4a8597a60 100644 --- a/applications/settings/xtreme_settings/xtreme_on_system_start.c +++ b/applications/settings/xtreme_settings/xtreme_on_system_start.c @@ -1,5 +1,7 @@ #include "xtreme_settings.h" +#include "xtreme_assets.h" void xtreme_on_system_start() { XTREME_SETTINGS_LOAD(); + XTREME_ASSETS_UPDATE(); }