Skip to content

Commit

Permalink
Improved text box auto-resize to take into account lenght of characte…
Browse files Browse the repository at this point in the history
…r names
  • Loading branch information
CosmosXIII authored and julianxhokaxhiu committed Oct 24, 2024
1 parent 5c1963b commit 40b7b1a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/ff7.h
Original file line number Diff line number Diff line change
Expand Up @@ -3170,6 +3170,7 @@ struct ff7_externals
uint32_t field_text_box_window_create_631586;
void (*field_text_box_window_opening_6317A9)(short);
void (*field_text_box_window_paging_631945)(short);
byte* (*sub_6CB9B8)(int a1);
uint32_t field_text_box_window_reverse_paging_632CAA;
uint32_t field_text_box_window_closing_632EB8;
char* field_entity_id_list; // 0xCC0960
Expand Down
16 changes: 13 additions & 3 deletions src/ff7/japanese_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2213,11 +2213,21 @@ void auto_resize_text_box(int16_t WINDOW_ID, int16_t* pOutW, int16_t* pOutH)
}

// character names
// add constant width for now
if(character >= 0xEA && character <= 0xF5)
{
charWidth = 16 * 6;
leftPadding = 0;
auto name_buffer = ff7_externals.sub_6CB9B8(character - 0xEA);
for (int j = 0; j < 9; ++j)
{
auto name_char = name_buffer[j];

if (name_char == 0xFF) break;

charWidth = charWidthData[0][name_char] & 0x1F;
leftPadding = charWidthData[0][name_char] >> 5;
W += leftPadding + std::ceil(0.5f * charWidth);
}

continue;
}

if(character == 0xE7)
Expand Down
1 change: 1 addition & 0 deletions src/ff7_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ inline void ff7_find_externals(struct ff7_game_obj* game_object)
ff7_externals.field_text_box_window_create_631586 = get_relative_call(ff7_externals.field_opcode_message_update_loop_630D50, 0x39);
ff7_externals.field_text_box_window_opening_6317A9 = (void (*)(short))get_relative_call(ff7_externals.field_opcode_message_update_loop_630D50, 0x5A);
ff7_externals.field_text_box_window_paging_631945 = (void (*)(short))get_relative_call(ff7_externals.field_opcode_message_update_loop_630D50, 0x6D);;
ff7_externals.sub_6CB9B8 = (byte* (*)(int))get_relative_call((uint32_t)ff7_externals.field_text_box_window_paging_631945, 0x693);
ff7_externals.field_text_box_window_reverse_paging_632CAA = get_relative_call(ff7_externals.field_opcode_message_update_loop_630D50, 0x80);
ff7_externals.field_text_box_window_closing_632EB8 = get_relative_call(ff7_externals.field_opcode_message_update_loop_630D50, 0x235);
ff7_externals.opcode_message_loop_code = (WORD*)get_absolute_value(ff7_externals.field_opcode_message_update_loop_630D50, 0x12);
Expand Down

0 comments on commit 40b7b1a

Please sign in to comment.