From b0b161ceb5b1ab5da62f782085941a1517ffe01a Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 2 Sep 2023 19:31:16 +0300 Subject: [PATCH] Add proto_subdata_setup_fid_button --- src/art.cc | 8 ++++++ src/art.h | 1 + src/mapper/mp_proto.cc | 58 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) diff --git a/src/art.cc b/src/art.cc index bb1a0f3..1e92439 100644 --- a/src/art.cc +++ b/src/art.cc @@ -438,6 +438,14 @@ void artRender(int fid, unsigned char* dest, int width, int height, int pitch) artUnlock(handle); } +// mapper2.exe: 0x40A03C +int art_list_str(int fid, char* name) +{ + // TODO: Incomplete. + + return -1; +} + // 0x419160 Art* artLock(int fid, CacheEntry** handlePtr) { diff --git a/src/art.h b/src/art.h index f7c31b4..650b241 100644 --- a/src/art.h +++ b/src/art.h @@ -123,6 +123,7 @@ char* artGetObjectTypeName(int objectType); int artIsObjectTypeHidden(int objectType); int artGetFidgetCount(int headFid); void artRender(int fid, unsigned char* dest, int width, int height, int pitch); +int art_list_str(int fid, char* name); Art* artLock(int fid, CacheEntry** cache_entry); unsigned char* artLockFrameData(int fid, int frame, int direction, CacheEntry** out_cache_entry); unsigned char* artLockFrameDataReturningSize(int fid, CacheEntry** out_cache_entry, int* widthPtr, int* heightPtr); diff --git a/src/mapper/mp_proto.cc b/src/mapper/mp_proto.cc index 7e787fd..8de5c5d 100644 --- a/src/mapper/mp_proto.cc +++ b/src/mapper/mp_proto.cc @@ -2,6 +2,7 @@ #include +#include "art.h" #include "color.h" #include "combat_ai.h" #include "critter.h" @@ -23,6 +24,7 @@ namespace fallout { static int proto_choose_container_flags(Proto* proto); static int proto_subdata_setup_int_button(const char* title, int key, int value, int min_value, int max_value, int* y, int a7); +static int proto_subdata_setup_fid_button(const char* title, int key, int fid, int* y, int a5); static void proto_critter_flags_redraw(int win, int pid); static int proto_critter_flags_modify(int pid); static int mp_pick_kill_type(); @@ -276,6 +278,62 @@ int proto_subdata_setup_int_button(const char* title, int key, int value, int mi return 0; } +// 0x492B28 +int proto_subdata_setup_fid_button(const char* title, int key, int fid, int* y, int a5) +{ + char text[36]; + char* pch; + int button_x; + int value_offset_x; + + button_x = 10; + value_offset_x = 90; + + if (a5 == 9) { + *y -= 189; + } + + if (a5 > 8) { + button_x = 165; + value_offset_x -= 16; + } + + _win_register_text_button(subwin, + button_x, + *y, + -1, + -1, + -1, + key, + title, + 0); + + if (art_list_str(fid, text) != -1) { + pch = strchr(text, '.'); + if (pch != NULL) { + *pch = '\0'; + } + + windowDrawText(subwin, + text, + 80, + button_x + value_offset_x, + *y + 4, + _colorTable[32747] | 0x10000); + } else { + windowDrawText(subwin, + "None", + 80, + button_x + value_offset_x, + *y + 4, + _colorTable[992] | 0x10000); + } + + *y += 21; + + return 0; +} + // 0x495438 const char* proto_wall_light_str(int flags) {