Revert "Merge branch 'dev' of https://github.com/ClaraCrazy/Flipper-Xtreme into dev"

This reverts commit 708dd167c8.
This commit is contained in:
Willy-JL
2023-02-10 20:50:30 +00:00
parent 176c01c0da
commit 6555082e2a
2348 changed files with 216 additions and 298 deletions
@@ -40,7 +40,7 @@ static void render_callback(Canvas* canvas, void* _ctx) {
const char* mood_str = NULL;
const Icon* portrait = NULL;
if(XTREME_SETTINGS()->nsfw_mode) {
if(XTREME_ASSETS()->is_nsfw) {
if(stats->butthurt <= 4) {
portrait = xtreme_assets->I_passport_happy_46x49;
mood_str = "Status: Wet";
@@ -12,7 +12,7 @@ void power_settings_scene_power_off_on_enter(void* context) {
DialogEx* dialog = app->dialog;
dialog_ex_set_header(dialog, "Turn Off Device?", 64, 2, AlignCenter, AlignTop);
if(XTREME_SETTINGS()->nsfw_mode) {
if(XTREME_ASSETS()->is_nsfw) {
dialog_ex_set_text(
dialog, " I will be\nwaiting for\n you master", 78, 16, AlignLeft, AlignTop);
} else {
@@ -3,15 +3,6 @@
#include <power/power_service/power.h>
#include <lib/toolbox/version.h>
static void xtreme_settings_scene_start_base_graphics_changed(VariableItem* item) {
XtremeSettingsApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "NSFW" : "SFW");
XTREME_SETTINGS()->nsfw_mode = value;
app->settings_changed = true;
app->assets_changed = true;
}
static void xtreme_settings_scene_start_asset_pack_changed(VariableItem* item) {
XtremeSettingsApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
@@ -172,11 +163,6 @@ void xtreme_settings_scene_start_on_enter(void* context) {
storage_file_free(folder);
furi_record_close(RECORD_STORAGE);
item = variable_item_list_add(
var_item_list, "Base Graphics", 2, xtreme_settings_scene_start_base_graphics_changed, app);
variable_item_set_current_value_index(item, xtreme_settings->nsfw_mode);
variable_item_set_current_value_text(item, xtreme_settings->nsfw_mode ? "NSFW" : "SFW");
item = variable_item_list_add(
var_item_list,
"Asset Pack",
@@ -2,175 +2,50 @@
#include "assets_icons.h"
#include <core/dangerous_defines.h>
#define ICONS_FMT PACKS_DIR "/%s/Icons/%s"
XtremeAssets* xtreme_assets = NULL;
XtremeAssets* XTREME_ASSETS() {
if(xtreme_assets == NULL) {
XTREME_ASSETS_LOAD();
}
return xtreme_assets;
void anim(const Icon** replace, const char* name, FuriString* path, File* file) {
do {
furi_string_printf(path, ICONS_FMT "/meta", XTREME_SETTINGS()->asset_pack, name);
if(!storage_file_open(file, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING))
break;
int32_t width, height, frame_rate, frame_count;
storage_file_read(file, &width, 4);
storage_file_read(file, &height, 4);
storage_file_read(file, &frame_rate, 4);
storage_file_read(file, &frame_count, 4);
storage_file_close(file);
Icon* icon = malloc(sizeof(Icon));
FURI_CONST_ASSIGN(icon->width, width);
FURI_CONST_ASSIGN(icon->height, height);
FURI_CONST_ASSIGN(icon->frame_rate, frame_rate);
FURI_CONST_ASSIGN(icon->frame_count, frame_count);
icon->frames = malloc(sizeof(const uint8_t*) * icon->frame_count);
const char* pack = XTREME_SETTINGS()->asset_pack;
bool ok = true;
for(int i = 0; ok && i < icon->frame_count; ++i) {
ok = false;
furi_string_printf(path, ICONS_FMT "/frame_%02d.bm", pack, name, i);
if(!storage_file_open(file, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING))
break;
uint64_t size = storage_file_size(file);
FURI_CONST_ASSIGN_PTR(icon->frames[i], malloc(size));
if(storage_file_read(file, (void*)icon->frames[i], size) == size) ok = true;
storage_file_close(file);
}
if(!ok) break;
*replace = icon;
} while(false);
}
void XTREME_ASSETS_LOAD() {
if(xtreme_assets != NULL) return;
xtreme_assets = malloc(sizeof(XtremeAssets));
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
if(xtreme_settings->nsfw_mode) {
xtreme_assets->I_BLE_Pairing_128x64 = &I_BLE_Pairing_128x64;
xtreme_assets->I_DolphinCommon_56x48 = &I_DolphinCommon_56x48;
xtreme_assets->I_DolphinMafia_115x62 = &I_DolphinMafia_115x62;
xtreme_assets->I_DolphinNice_96x59 = &I_DolphinNice_96x59;
xtreme_assets->I_DolphinWait_61x59 = &I_DolphinWait_61x59;
xtreme_assets->I_iButtonDolphinVerySuccess_108x52 = &I_iButtonDolphinVerySuccess_108x52;
xtreme_assets->I_DolphinReadingSuccess_59x63 = &I_DolphinReadingSuccess_59x63;
xtreme_assets->I_NFC_dolphin_emulation_47x61 = &I_NFC_dolphin_emulation_47x61;
xtreme_assets->I_passport_bad_46x49 = &I_flipper;
xtreme_assets->I_passport_DB = &I_passport_DB;
xtreme_assets->I_passport_happy_46x49 = &I_flipper;
xtreme_assets->I_passport_okay_46x49 = &I_flipper;
xtreme_assets->I_RFIDDolphinReceive_97x61 = &I_RFIDDolphinReceive_97x61;
xtreme_assets->I_RFIDDolphinSend_97x61 = &I_RFIDDolphinSend_97x61;
xtreme_assets->I_RFIDDolphinSuccess_108x57 = &I_RFIDDolphinSuccess_108x57;
xtreme_assets->I_Cry_dolph_55x52 = &I_Cry_dolph_55x52;
xtreme_assets->I_Scanning_123x52 = &I_Scanning_123x52;
xtreme_assets->I_Auth_62x31 = &I_Auth_62x31;
xtreme_assets->I_Connect_me_62x31 = &I_Connect_me_62x31;
xtreme_assets->I_Connected_62x31 = &I_Connected_62x31;
xtreme_assets->I_Error_62x31 = &I_Error_62x31;
} else {
xtreme_assets->I_BLE_Pairing_128x64 = &I_BLE_Pairing_128x64_sfw;
xtreme_assets->I_DolphinCommon_56x48 = &I_DolphinCommon_56x48_sfw;
xtreme_assets->I_DolphinMafia_115x62 = &I_DolphinMafia_115x62_sfw;
xtreme_assets->I_DolphinNice_96x59 = &I_DolphinNice_96x59_sfw;
xtreme_assets->I_DolphinWait_61x59 = &I_DolphinWait_61x59_sfw;
xtreme_assets->I_iButtonDolphinVerySuccess_108x52 =
&I_iButtonDolphinVerySuccess_108x52_sfw;
xtreme_assets->I_DolphinReadingSuccess_59x63 = &I_DolphinReadingSuccess_59x63_sfw;
xtreme_assets->I_NFC_dolphin_emulation_47x61 = &I_NFC_dolphin_emulation_47x61_sfw;
xtreme_assets->I_passport_bad_46x49 = &I_passport_bad1_46x49_sfw;
xtreme_assets->I_passport_DB = &I_passport_DB_sfw;
xtreme_assets->I_passport_happy_46x49 = &I_passport_happy1_46x49_sfw;
xtreme_assets->I_passport_okay_46x49 = &I_passport_okay1_46x49_sfw;
xtreme_assets->I_RFIDDolphinReceive_97x61 = &I_RFIDDolphinReceive_97x61_sfw;
xtreme_assets->I_RFIDDolphinSend_97x61 = &I_RFIDDolphinSend_97x61_sfw;
xtreme_assets->I_RFIDDolphinSuccess_108x57 = &I_RFIDDolphinSuccess_108x57_sfw;
xtreme_assets->I_Cry_dolph_55x52 = &I_Cry_dolph_55x52_sfw;
xtreme_assets->I_Scanning_123x52 = &I_Scanning_123x52_sfw;
xtreme_assets->I_Auth_62x31 = &I_Auth_62x31_sfw;
xtreme_assets->I_Connect_me_62x31 = &I_Connect_me_62x31_sfw;
xtreme_assets->I_Connected_62x31 = &I_Connected_62x31_sfw;
xtreme_assets->I_Error_62x31 = &I_Error_62x31_sfw;
}
if(xtreme_settings->asset_pack[0] == '\0') return;
FileInfo info;
FuriString* path = furi_string_alloc();
const char* pack = xtreme_settings->asset_pack;
furi_string_printf(path, PACKS_DIR "/%s", pack);
Storage* storage = furi_record_open(RECORD_STORAGE);
if(storage_common_stat(storage, furi_string_get_cstr(path), &info) == FSE_OK &&
info.flags & FSF_DIRECTORY) {
File* file = storage_file_alloc(storage);
swap_bmx_icon(
&xtreme_assets->I_BLE_Pairing_128x64, pack, "BLE/BLE_Pairing_128x64.bmx", path, file);
swap_bmx_icon(
&xtreme_assets->I_DolphinCommon_56x48,
pack,
"Dolphin/DolphinCommon_56x48.bmx",
path,
file);
swap_bmx_icon(
&xtreme_assets->I_DolphinMafia_115x62,
pack,
"iButton/DolphinMafia_115x62.bmx",
path,
file);
swap_bmx_icon(
&xtreme_assets->I_DolphinNice_96x59, pack, "iButton/DolphinNice_96x59.bmx", path, file);
swap_bmx_icon(
&xtreme_assets->I_DolphinWait_61x59, pack, "iButton/DolphinWait_61x59.bmx", path, file);
swap_bmx_icon(
&xtreme_assets->I_iButtonDolphinVerySuccess_108x52,
pack,
"iButton/iButtonDolphinVerySuccess_108x52.bmx",
path,
file);
swap_bmx_icon(
&xtreme_assets->I_DolphinReadingSuccess_59x63,
pack,
"Infrared/DolphinReadingSuccess_59x63.bmx",
path,
file);
swap_bmx_icon(
&xtreme_assets->I_NFC_dolphin_emulation_47x61,
pack,
"NFC/NFC_dolphin_emulation_47x61.bmx",
path,
file);
swap_bmx_icon(
&xtreme_assets->I_passport_bad_46x49,
pack,
"Passport/passport_bad_46x49.bmx",
path,
file);
swap_bmx_icon(&xtreme_assets->I_passport_DB, pack, "Passport/passport_DB.bmx", path, file);
swap_bmx_icon(
&xtreme_assets->I_passport_happy_46x49,
pack,
"Passport/passport_happy_46x49.bmx",
path,
file);
swap_bmx_icon(
&xtreme_assets->I_passport_okay_46x49,
pack,
"Passport/passport_okay_46x49.bmx",
path,
file);
swap_bmx_icon(
&xtreme_assets->I_RFIDDolphinReceive_97x61,
pack,
"RFID/RFIDDolphinReceive_97x61.bmx",
path,
file);
swap_bmx_icon(
&xtreme_assets->I_RFIDDolphinSend_97x61,
pack,
"RFID/RFIDDolphinSend_97x61.bmx",
path,
file);
swap_bmx_icon(
&xtreme_assets->I_RFIDDolphinSuccess_108x57,
pack,
"RFID/RFIDDolphinSuccess_108x57.bmx",
path,
file);
swap_bmx_icon(
&xtreme_assets->I_Cry_dolph_55x52, pack, "Settings/Cry_dolph_55x52.bmx", path, file);
swap_bmx_icon(
&xtreme_assets->I_Scanning_123x52, pack, "SubGhz/Scanning_123x52.bmx", path, file);
swap_bmx_icon(&xtreme_assets->I_Auth_62x31, pack, "U2F/Auth_62x31.bmx", path, file);
swap_bmx_icon(
&xtreme_assets->I_Connect_me_62x31, pack, "U2F/Connect_me_62x31.bmx", path, file);
swap_bmx_icon(
&xtreme_assets->I_Connected_62x31, pack, "U2F/Connected_62x31.bmx", path, file);
swap_bmx_icon(&xtreme_assets->I_Error_62x31, pack, "U2F/Error_62x31.bmx", path, file);
storage_file_free(file);
}
furi_record_close(RECORD_STORAGE);
furi_string_free(path);
}
void swap_bmx_icon(
const Icon** replace,
const char* pack,
const char* name,
FuriString* path,
File* file) {
furi_string_printf(path, PACKS_DIR "/%s/Icons/%s", pack, name);
void icon(const Icon** replace, const char* name, FuriString* path, File* file) {
furi_string_printf(path, ICONS_FMT ".bmx", XTREME_SETTINGS()->asset_pack, name);
if(storage_file_open(file, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
uint64_t size = storage_file_size(file) - 8;
int32_t width, height;
@@ -190,3 +65,80 @@ void swap_bmx_icon(
storage_file_close(file);
}
}
void swap(XtremeAssets* x, FuriString* p, File* f) {
anim(&x->A_Levelup_128x64, "Animations/Levelup_128x64", p, f);
icon(&x->I_BLE_Pairing_128x64, "BLE/BLE_Pairing_128x64", p, f);
icon(&x->I_DolphinCommon_56x48, "Dolphin/DolphinCommon_56x48", p, f);
icon(&x->I_DolphinMafia_115x62, "iButton/DolphinMafia_115x62", p, f);
icon(&x->I_DolphinNice_96x59, "iButton/DolphinNice_96x59", p, f);
icon(&x->I_DolphinWait_61x59, "iButton/DolphinWait_61x59", p, f);
icon(&x->I_iButtonDolphinVerySuccess_108x52, "iButton/iButtonDolphinVerySuccess_108x52", p, f);
icon(&x->I_DolphinReadingSuccess_59x63, "Infrared/DolphinReadingSuccess_59x63", p, f);
icon(&x->I_NFC_dolphin_emulation_47x61, "NFC/NFC_dolphin_emulation_47x61", p, f);
icon(&x->I_passport_bad_46x49, "Passport/passport_bad_46x49", p, f);
icon(&x->I_passport_DB, "Passport/passport_DB", p, f);
icon(&x->I_passport_happy_46x49, "Passport/passport_happy_46x49", p, f);
icon(&x->I_passport_okay_46x49, "Passport/passport_okay_46x49", p, f);
icon(&x->I_RFIDDolphinReceive_97x61, "RFID/RFIDDolphinReceive_97x61", p, f);
icon(&x->I_RFIDDolphinSend_97x61, "RFID/RFIDDolphinSend_97x61", p, f);
icon(&x->I_RFIDDolphinSuccess_108x57, "RFID/RFIDDolphinSuccess_108x57", p, f);
icon(&x->I_Cry_dolph_55x52, "Settings/Cry_dolph_55x52", p, f);
icon(&x->I_Scanning_123x52, "SubGhz/Scanning_123x52", p, f);
icon(&x->I_Auth_62x31, "U2F/Auth_62x31", p, f);
icon(&x->I_Connect_me_62x31, "U2F/Connect_me_62x31", p, f);
icon(&x->I_Connected_62x31, "U2F/Connected_62x31", p, f);
icon(&x->I_Error_62x31, "U2F/Error_62x31", p, f);
}
void XTREME_ASSETS_LOAD() {
if(xtreme_assets != NULL) return;
xtreme_assets = malloc(sizeof(XtremeAssets));
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
xtreme_assets->A_Levelup_128x64 = &A_Levelup_128x64;
xtreme_assets->I_BLE_Pairing_128x64 = &I_BLE_Pairing_128x64;
xtreme_assets->I_DolphinCommon_56x48 = &I_DolphinCommon_56x48;
xtreme_assets->I_DolphinMafia_115x62 = &I_DolphinMafia_115x62;
xtreme_assets->I_DolphinNice_96x59 = &I_DolphinNice_96x59;
xtreme_assets->I_DolphinWait_61x59 = &I_DolphinWait_61x59;
xtreme_assets->I_iButtonDolphinVerySuccess_108x52 = &I_iButtonDolphinVerySuccess_108x52;
xtreme_assets->I_DolphinReadingSuccess_59x63 = &I_DolphinReadingSuccess_59x63;
xtreme_assets->I_NFC_dolphin_emulation_47x61 = &I_NFC_dolphin_emulation_47x61;
xtreme_assets->I_passport_bad_46x49 = &I_passport_bad_46x49;
xtreme_assets->I_passport_DB = &I_passport_DB;
xtreme_assets->I_passport_happy_46x49 = &I_passport_happy_46x49;
xtreme_assets->I_passport_okay_46x49 = &I_passport_okay_46x49;
xtreme_assets->I_RFIDDolphinReceive_97x61 = &I_RFIDDolphinReceive_97x61;
xtreme_assets->I_RFIDDolphinSend_97x61 = &I_RFIDDolphinSend_97x61;
xtreme_assets->I_RFIDDolphinSuccess_108x57 = &I_RFIDDolphinSuccess_108x57;
xtreme_assets->I_Cry_dolph_55x52 = &I_Cry_dolph_55x52;
xtreme_assets->I_Scanning_123x52 = &I_Scanning_123x52;
xtreme_assets->I_Auth_62x31 = &I_Auth_62x31;
xtreme_assets->I_Connect_me_62x31 = &I_Connect_me_62x31;
xtreme_assets->I_Connected_62x31 = &I_Connected_62x31;
xtreme_assets->I_Error_62x31 = &I_Error_62x31;
if(xtreme_settings->asset_pack[0] == '\0') return;
xtreme_assets->is_nsfw = strncmp(xtreme_settings->asset_pack, "NSFW", strlen("NSFW")) == 0;
FileInfo info;
FuriString* path = furi_string_alloc();
furi_string_printf(path, PACKS_DIR "/%s", xtreme_settings->asset_pack);
Storage* storage = furi_record_open(RECORD_STORAGE);
if(storage_common_stat(storage, furi_string_get_cstr(path), &info) == FSE_OK &&
info.flags & FSF_DIRECTORY) {
File* file = storage_file_alloc(storage);
swap(xtreme_assets, path, file);
storage_file_free(file);
}
furi_record_close(RECORD_STORAGE);
furi_string_free(path);
}
XtremeAssets* XTREME_ASSETS() {
if(xtreme_assets == NULL) {
XTREME_ASSETS_LOAD();
}
return xtreme_assets;
}
@@ -7,6 +7,8 @@
#define PACKS_DIR EXT_PATH("dolphin_custom")
typedef struct {
bool is_nsfw;
const Icon* A_Levelup_128x64;
const Icon* I_BLE_Pairing_128x64;
const Icon* I_DolphinCommon_56x48;
const Icon* I_DolphinMafia_115x62;
@@ -30,15 +32,6 @@ typedef struct {
const Icon* I_Error_62x31;
} XtremeAssets;
XtremeAssets* XTREME_ASSETS();
void XTREME_ASSETS_LOAD();
void swap_bmx_icon(
const Icon** replace,
const char* base,
const char* name,
FuriString* path,
File* file);
void free_bmx_icon(Icon* icon);
XtremeAssets* XTREME_ASSETS();
@@ -18,7 +18,6 @@
typedef struct {
int32_t cycle_anims;
bool unlock_anims;
bool nsfw_mode;
char asset_pack[MAX_PACK_NAME_LEN];
BatteryStyle battery_style;
uint16_t anim_speed;