mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-24 05:34:45 -07:00
New asset system base and passport PoC
This commit is contained in:
@@ -7,35 +7,9 @@
|
||||
#include <furi_hal_version.h>
|
||||
#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);
|
||||
|
||||
26
applications/settings/xtreme_settings/xtreme_assets.c
Normal file
26
applications/settings/xtreme_settings/xtreme_assets.c
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
14
applications/settings/xtreme_settings/xtreme_assets.h
Normal file
14
applications/settings/xtreme_settings/xtreme_assets.h
Normal file
@@ -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();
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "xtreme_settings.h"
|
||||
#include "xtreme_assets.h"
|
||||
|
||||
void xtreme_on_system_start() {
|
||||
XTREME_SETTINGS_LOAD();
|
||||
XTREME_ASSETS_UPDATE();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user