Преглед изворни кода

Add form to info(figure, card, yarn)

Eric Betts пре 8 месеци
родитељ
комит
9b3d6ea113
3 измењених фајлова са 30 додато и 2 уклоњено
  1. 5 2
      scenes/weebo_scene_info.c
  2. 24 0
      weebo.c
  3. 1 0
      weebo.h

+ 5 - 2
scenes/weebo_scene_info.c

@@ -8,17 +8,20 @@ void weebo_scene_info_on_enter(void* context) {
 
 
     furi_string_reset(weebo->text_box_store);
     furi_string_reset(weebo->text_box_store);
     FuriString* str = weebo->text_box_store;
     FuriString* str = weebo->text_box_store;
-
     FuriString* name = furi_string_alloc();
     FuriString* name = furi_string_alloc();
+
     furi_string_cat_printf(str, "Info:\n");
     furi_string_cat_printf(str, "Info:\n");
     if(weebo_get_figure_name(weebo, name)) {
     if(weebo_get_figure_name(weebo, name)) {
         furi_string_cat_printf(str, "%s\n", furi_string_get_cstr(name));
         furi_string_cat_printf(str, "%s\n", furi_string_get_cstr(name));
     } else {
     } else {
         furi_string_cat_printf(str, "Unknown\n");
         furi_string_cat_printf(str, "Unknown\n");
     }
     }
-    furi_string_free(name);
     furi_string_cat_printf(str, "ID: %04x\n", weebo_get_figure_id(weebo));
     furi_string_cat_printf(str, "ID: %04x\n", weebo_get_figure_id(weebo));
+    if(weebo_get_figure_form(weebo, name)) {
+        furi_string_cat_printf(str, "Form: %s\n", furi_string_get_cstr(name));
+    }
 
 
+    furi_string_free(name);
     text_box_set_font(weebo->text_box, TextBoxFontText);
     text_box_set_font(weebo->text_box, TextBoxFontText);
     text_box_set_text(weebo->text_box, furi_string_get_cstr(weebo->text_box_store));
     text_box_set_text(weebo->text_box, furi_string_get_cstr(weebo->text_box_store));
     view_dispatcher_switch_to_view(weebo->view_dispatcher, WeeboViewTextBox);
     view_dispatcher_switch_to_view(weebo->view_dispatcher, WeeboViewTextBox);

+ 24 - 0
weebo.c

@@ -147,6 +147,30 @@ uint16_t weebo_get_figure_id(Weebo* weebo) {
     return id;
     return id;
 }
 }
 
 
+bool weebo_get_figure_form(Weebo* weebo, FuriString* name) {
+    bool parsed = false;
+    uint8_t form = weebo->figure[UNPACKED_FIGURE_ID + 3];
+    FURI_LOG_D(TAG, "form = %02x", form);
+    switch(form) {
+    case 0x00:
+        furi_string_set_str(name, "Figure");
+        parsed = true;
+        break;
+    case 0x01:
+        furi_string_set_str(name, "Card");
+        parsed = true;
+        break;
+    case 0x02:
+        furi_string_set_str(name, "Yarn");
+        parsed = true;
+        break;
+    default:
+        break;
+    }
+
+    return parsed;
+}
+
 bool weebo_get_figure_name(Weebo* weebo, FuriString* name) {
 bool weebo_get_figure_name(Weebo* weebo, FuriString* name) {
     bool parsed = false;
     bool parsed = false;
 
 

+ 1 - 0
weebo.h

@@ -5,3 +5,4 @@ typedef struct Weebo Weebo;
 uint16_t weebo_get_figure_id(Weebo* weebo);
 uint16_t weebo_get_figure_id(Weebo* weebo);
 
 
 bool weebo_get_figure_name(Weebo* weebo, FuriString* name);
 bool weebo_get_figure_name(Weebo* weebo, FuriString* name);
+bool weebo_get_figure_form(Weebo* weebo, FuriString* name);