73 FILE *file = fopen(filename,
"a");
76 fprintf(file,
"%s\n", message);
84 static char modifiedMessage[256];
85 snprintf(modifiedMessage,
sizeof(modifiedMessage),
"[WARNING] %s", message);
92 static char modifiedMessage[256];
93 snprintf(modifiedMessage,
sizeof(modifiedMessage),
"[SFSF] %s", message);
100 int lastError = GetLastError();
101 static char modifiedMessage[256];
102 snprintf(modifiedMessage,
sizeof(modifiedMessage),
103 "[ERROR] %s [(Win32 SysErr) Last Error: %d]", message, lastError);
119 if ((_this->
type == 10000) || (_this->
type == 0x2711))
148 delta = (uint32_t)(uint16_t)pointA->
X - (uint32_t)(uint16_t)pointB->
X;
149 uVar2 = (int)delta >> 0x1f;
150 uVar2 = (delta ^ uVar2) - uVar2;
151 uVar4 = uVar2 & 0xffff;
152 delta = (uint32_t)(uint16_t)pointA->
Y - (uint32_t)(uint16_t)pointB->
Y;
153 uVar3 = (int)delta >> 0x1f;
154 uVar3 = (delta ^ uVar3) - uVar3;
155 uVar1 = uVar3 & 0xffff;
157 if ((uint16_t)uVar2 < (uint16_t)uVar3)
162 return ((delta * 0xd) >> 5) + uVar4;
176 uint16_t spell_index,
178 uint16_t source_index,
179 uint16_t spell_index),
181 uint16_t source_index,
182 uint16_t spell_index))
184 if (!condition || !callback)
191 uint16_t current_index =
194 if ((*condition)(_this, current_index, spell_index))
196 (*callback)(_this, source_index, current_index);
209 bool invalid = FALSE;
329 char *label_chars, uint8_t font_index,
330 uint16_t x_pos, uint16_t y_pos,
331 uint16_t width, uint16_t height)
336 font_index, x_pos, y_pos, width, height);
339void wrap_text(
const char *input,
char *output,
size_t max_width)
341 size_t input_len = strlen(input);
342 size_t current_line_width = 0;
343 size_t output_index = 0;
345 for (
size_t i = 0; i < input_len; ++i)
347 output[output_index++] = input[i];
348 current_line_width++;
350 if (current_line_width >= max_width)
352 size_t break_point = output_index;
353 while (break_point > 0 && !isspace(output[break_point - 1]))
360 output[break_point - 1] =
'\n';
361 current_line_width = output_index - break_point;
365 output[output_index++] =
'\n';
366 current_line_width = 0;
371 output[output_index] =
'\0';
374static bool is_init_finished =
false;
382static void update_label_text(
CMnuLabel *label,
const char *text)
410 const int start_index = mods_per_page * page;
411 const int end_index = start_index + mods_per_page;
412 const int y_base_offset = 48;
413 const int y_item_spacing = 36;
415 SFMod *current_parent =
nullptr;
421 SFMod *parent_mod = spell_data->parent_mod;
424 if (current_parent != parent_mod)
427 if (mod_index >= start_index && mod_index < end_index)
429 const int relative_y_pos = (mod_index - start_index) *
431 const int absolute_y_pos = y_base_offset + relative_y_pos;
434 char mod_title[512] = {0};
435 snprintf(mod_title,
sizeof(mod_title),
"%s %s\nby %s",
440 char mod_description[512] = {0};
441 snprintf(mod_description,
sizeof(mod_description),
"%s",
444 char wrapped_description[1024] = {0};
445 wrap_text(mod_description, wrapped_description, 64);
447 char mod_page_info[48] = {0};
448 snprintf(mod_page_info,
sizeof(mod_page_info),
"(%u / %u)",
451 char mod_error_info[512] = {0};
454 snprintf(mod_error_info,
sizeof(mod_error_info),
"%s",
459 snprintf(mod_error_info,
sizeof(mod_error_info),
463 char wrapped_error_info[1024] = {0};
464 wrap_text(mod_error_info, wrapped_error_info, 64);
467 if (is_init_finished)
472 wrapped_description);
482 6, 100, absolute_y_pos - 32, 50,
488 11, 48, absolute_y_pos + 24,
489 227, y_item_spacing);
493 6, 92, 382, 50, y_item_spacing);
497 11, 48, absolute_y_pos + 224,
498 227, y_item_spacing);
508 is_init_finished =
true;
512 current_parent = parent_mod;
519 int32_t *cui_menu_ptr_maybe)
539 int32_t *cui_menu_ptr_maybe)
557static bool is_mod_list_shown =
false;
558static bool does_mod_list_exist =
false;
566 if(!does_mod_list_exist)
568 is_mod_list_shown =
true;
569 SF_String s_menu_border, s_menu_background, s_alt_btn_name;
570 SF_String *p_menu_border, *p_menu_background, *p_alt_btn_name;
572 char alt_name[32] =
"HIDE MOD LIST";
582 char menu_border[128] =
"ui_bgr_options_select_border.msb";
583 char menu_background_fade[128] =
584 "ui_bgr_options_select_border_transparency.msb";
587 menu_background_fade);
590 p_menu_background, p_menu_border);
601 char btn_disabled[128]=
"ui_btn_togglearrow_right_disabled.msh";
602 char btn_pressed[128] =
"ui_btn_togglearrow_right_pressed.msh";
603 char btn_load[1] =
"";
604 char btn_default[128] =
"ui_btn_togglearrow_right_default.msh";
605 char btn_label[1] =
"";
608 btn_disabled, btn_label, 7, (432 - (48 + 32)), 332,
611 char btn_disabled_left[128] =
"ui_btn_togglearrow_left_disabled.msh";
612 char btn_pressed_left[128] =
"ui_btn_togglearrow_left_pressed.msh";
613 char btn_default_left[128] =
"ui_btn_togglearrow_left_default.msh";
616 btn_load, btn_disabled_left, btn_label, 7, 28, 332,
620 does_mod_list_exist =
true;
624 if(is_mod_list_shown)
627 char alt_name[32] =
"SHOW MOD LIST";
636 is_mod_list_shown =
false;
641 char alt_name[32] =
"HIDE MOD LIST";
650 is_mod_list_shown =
true;
656 int32_t *cui_menu_ptr_maybe)
667 char *button_mesh_default,
668 char *button_mesh_pressed,
669 char *button_initial_load_mesh,
670 char *button_mesh_disabled,
char *label_char,
671 uint8_t font_index, uint16_t x_pos,
672 uint16_t y_pos, uint16_t width,
673 uint16_t height,
int button_index,
674 uint32_t callback_func_ptr)
683 void *new_btn_operation;
690 button_mesh_default);
694 button_mesh_pressed);
698 button_initial_load_mesh);
709 log_error(
"Invalid font index 0~32, defaulting to font 6");
720 init_load_mesh,mesh_string_pressed,mesh_string_disabled);
722 set_font(new_button, selected_font);
735 uint32_t param1, param2, param3;
759 uint16_t x_pos, uint16_t y_pos,
760 uint16_t width, uint16_t height)
773 log_error(
"Invalid font index 0~32, defaulting to font 6");
803 const char *mod_author,
const char *mod_description)
807 strncpy(mod->
mod_id, mod_id, 63);
826 char *video_loc_and_name_chars)
831 video_loc_and_name_chars);
836 char controller_mark_chars[64];
837 sprintf(controller_mark_chars,
"<Cont>CreditsVideoController");
SpellFunctions * spellAPI
FigureFunctions * figureAPI
ToolboxFunctions * toolboxAPI
void console_log(const char *message)
IteratorFunctions iteratorAPI
void __thiscall addBonusMultToStatistic(SF_CGdFigure *figure, StatisticDataKey key, uint16_t target, int8_t value)
initialize_menu_container_ptr initialize_menu_container
CMnuLabel *__thiscall attach_new_label(CMnuLabel *label_ptr, CMnuContainer *parent, char *label_chars, uint8_t font_index, uint16_t x_pos, uint16_t y_pos, uint16_t width, uint16_t height)
void __thiscall attach_new_button(CMnuContainer *parent, char *button_mesh_default, char *button_mesh_pressed, char *button_initial_load_mesh, char *button_mesh_disabled, char *label_char, uint8_t font_index, uint16_t x_pos, uint16_t y_pos, uint16_t width, uint16_t height, int button_index, uint32_t callback_func_ptr)
uint32_t getDistance(SF_Coord *pointA, SF_Coord *pointB)
void __thiscall spellEffectCallback(SF_CGdSpell *_this, uint16_t source_index, uint16_t spell_index, bool(*condition)(SF_CGdSpell *_this, uint16_t source_index, uint16_t spell_index), void(*callback)(SF_CGdSpell *_this, uint16_t source_index, uint16_t spell_index))
void __thiscall show_mod_list(CMnuSmpButton *button)
CMnuBase_setname_ptr CMnuBase_setname
void log_info(const char *message)
SFSF_ModlistStruct modinformation
container_alpha_ptr set_container_alpha
void wrap_text(const char *input, char *output, size_t max_width)
void __thiscall setupFigureIterator(CGdFigureIterator *iterator, SF_CGdSpell *spell)
create_button_ptr create_button_func
vfunction_ptr vfunction176
vfunction_ptr vfunction16_attach_callback
void log_warning(const char *message)
has_spell_effect_ptr has_spell_effect
vfunction2_callback_attach_ptr attach_callback
initialize_smp_button_ptr initialize_smp_button
void __fastcall navigate_callback_left(CMnuSmpButton *button, int32_t *cui_menu_ptr_maybe)
set_btn_name_ptr set_button_name
set_label_color_ptr set_label_color
set_button_flag_ptr set_menu_button_flag
void log_error(const char *message)
bool __thiscall hasSpellTag(uint16_t spell_id, SpellTag tag)
bool __thiscall hasAuraActive(SF_CGdFigureToolbox *_this, uint16_t figure_id)
void attachVideo(CAppMenu *CAppMenu_ptr, CMnuContainer *parent, char *video_loc_and_name_chars)
SF_String_ctor_ptr g_create_sf_string
void __thiscall spellClearFigureFlag(SF_CGdSpell *_this, uint16_t spell_id, SpellFlagKey key)
void __thiscall disposeFigureIterator(CGdFigureIterator *iterator)
void attach_mod_labels(CMnuContainer *container, int mods_per_page, int page)
void __fastcall show_mod_list_callback(CMnuSmpButton *button, int32_t *cui_menu_ptr_maybe)
void log_message(const char *filename, const char *message)
FUN_0069eaf0_ptr FUN_0069eaf0
void initialize_wrapper_data_hooks()
SF_String_dtor_ptr g_destroy_sf_string
CMnuLabel *__thiscall attach_new_meshed_label(CMnuLabel *new_label, CMnuContainer *parent, char *mesh_char, char *label_char, uint8_t font_index, uint16_t x_pos, uint16_t y_pos, uint16_t width, uint16_t height)
uint16_t __thiscall sf_get_spell_id(SF_CGdSpell *_this, uint16_t spell_index)
SFMod * createModInfo(const char *mod_id, const char *mod_version, const char *mod_author, const char *mod_description)
attach_string_ptr vfunction_apply_string
set_btn_index_ptr set_button_index
vfunction_ptr vfunction25
bool __thiscall isActionMelee(SF_SGtFigureAction *_this)
void __fastcall navigate_callback_right(CMnuSmpButton *button, int32_t *cui_menu_ptr_maybe)
setup_menu_container_data_ptr setup_menu_container_data
vfunction12_ptr vfunction12
int AddrOf(int offset)
returns "real" virtual address of given memory offset
void(* fidfree_ptr)(uint32_t *memory_ptr)
void(__thiscall * initialize_menu_container_ptr)(CMnuContainer *_this)
uint32_t(__thiscall * FUN_0069eaf0_ptr)(void *ac69, void *ac69_2, void *ac69_3, void *ac69_4)
std::list< SFSpell * > g_internal_spell_list
@ CHECK_SPELLS_BEFORE_JOB2
@ CHECK_SPELLS_BEFORE_CHECK_BATTLE
bool(__thiscall * has_spell_effect_ptr)(SF_CGdFigureToolbox *_this, uint16_t param_1, uint16_t param_2)
SF_String *(__thiscall * SF_String_ctor_ptr)(SF_String *, const char *)
void(__thiscall * SF_String_dtor_ptr)(SF_String *)
void(__thiscall * container_alpha_ptr)(CMnuContainer *_this, float alpha)
void(__thiscall * set_button_flag_ptr)(void *container, char flag)
void(__thiscall * set_btn_index_ptr)(void *container, int index)
void(__thiscall * vfunction_2_ptr)(void *_this, void *input)
void(__thiscall * vfunction2_callback_attach_ptr)(void *, void *, void *, void *)
void(__thiscall * set_label_color_ptr)(CMnuLabel *_this, float r, float g, float b, char flag)
void(__thiscall * set_btn_name_ptr)(void *button, SF_String *string)
void(__thiscall * CMnuBase_setname_ptr)(CMnuBase *_this, SF_String *name)
void(__thiscall * setup_menu_container_data_ptr)(CMnuContainer *_this, float x, float y, float width, float height, SF_String *background, SF_String *border)
void(__thiscall * create_button_ptr)(CMnuSmpButton *smpButton, float x_pos, float y_pos, float width, float height, SF_String *default_mesh, SF_String *unkn_mesh_string, SF_String *pressed_mesh, SF_String *disable_mesh)
void(__thiscall * vfunction12_ptr)(void *container, void *test, char p1)
void(__thiscall * attach_string_ptr)(void *container, void *string)
CMnuSmpButton *(__thiscall * initialize_smp_button_ptr)(CMnuSmpButton *btn)
void(__thiscall * vfunction_ptr)(void *_this, char p1)
uint32_t param_1_callback
uint32_t param_2_callback
uint32_t param_3_callback
figureIteratorSetPointers_ptr figureIteratorSetPointers
figureIteratorInit_ptr figureIteratorInit
void * SF_CGdDoubleLinkedList
SF_CGdFigure * SF_CGdFigure
SF_CGdWorld * SF_CGdWorld
SF_GdSpell active_spell_list[800]
log_function_ptr logError
log_function_ptr logWarning
char mod_description[128]
getSpellTags_ptr getSpellTags
Retrieves the tags associated with a spell.
figTryClrCHkSPlBfrJob2_ptr figTryClrCHkSPlBfrJob2
clears the CHECK_SPELLS_BEFORE_JOB2 flag
figTryUnfreeze_ptr figTryUnfreeze
clears the UNFREEZE flag
figClrChkSplBfrChkBattle_ptr figClrChkSplBfrChkBattle
Clears the CHECK_SPELLS_BEFORE_CHECK_BATTLE flag.