From 3ad647c7000bd4edc2a14944cf0419e54b020c8c Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Tue, 4 Feb 2025 08:48:18 -0600 Subject: [PATCH] Fit preset talk word click rects. Fix #566 --- src/game/boe.consts.hpp | 2 ++ src/game/boe.dlgutil.cpp | 26 ++++++++++++++++++-------- src/game/boe.newgraph.cpp | 2 +- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/game/boe.consts.hpp b/src/game/boe.consts.hpp index a4f3b315..dffd510f 100644 --- a/src/game/boe.consts.hpp +++ b/src/game/boe.consts.hpp @@ -164,6 +164,8 @@ const int UI_LAYER_MENUBAR = 1200; const int talk_gword_offset_x = 19; const int talk_gword_offset_y = 7; +const int TALK_WORD_SIZE = 18; + #ifdef __APPLE__ enum eMenuChoice { MENU_CHOICE_NONE, diff --git a/src/game/boe.dlgutil.cpp b/src/game/boe.dlgutil.cpp index bf0690ef..cd457036 100644 --- a/src/game/boe.dlgutil.cpp +++ b/src/game/boe.dlgutil.cpp @@ -581,22 +581,32 @@ void set_up_shop_array() { static void reset_talk_words() { // first initialise talk_words here talk_words.clear(); - static const rectangle preset_rects[9] = { - rectangle{366,4,386,54}, rectangle{366,70,386,130}, rectangle{366,136,386,186}, - rectangle{389,4,409,54}, rectangle{389,70,409,120}, rectangle{389,121,409,186}, - rectangle{389,210,409,270}, rectangle{366,190,386,270}, - rectangle{343,4,363,134}, + static const std::vector preset_word_locs = { + {4, 366}, {70, 366}, {136, 366}, + {4, 389}, {70, 389}, {121, 389}, + {210, 389}, {190, 366}, + {4, 343} }; - static const char*const preset_words[9] = { + static const std::vector preset_words = { "Look", "Name", "Job", "Buy", "Sell", "Record", "Done", "Go Back", "Ask About...", }; + TextStyle style; + style.font = FONT_DUNGEON; + style.pointSize = TALK_WORD_SIZE; // Place buttons at bottom. - for(short i = 0; i < 9; i++) { - word_rect_t preset_word(preset_words[i], preset_rects[i]); + for(short i = 0; i < preset_words.size(); i++) { + std::string word = preset_words[i]; + location tl = preset_word_locs[i]; + location br = tl; + short h; + br.x += string_length(word, style, &h); + br.y += h; + rectangle rect {tl,br}; + word_rect_t preset_word(word, rect); preset_word.on = PRESET_WORD_ON; preset_word.off = PRESET_WORD_OFF; switch(i) { diff --git a/src/game/boe.newgraph.cpp b/src/game/boe.newgraph.cpp index 797d71f2..72f053ff 100644 --- a/src/game/boe.newgraph.cpp +++ b/src/game/boe.newgraph.cpp @@ -863,7 +863,7 @@ void place_talk_str(std::string str_to_place,std::string str_to_place2,short col TextStyle style; style.font = FONT_DUNGEON; - style.pointSize = 18; + style.pointSize = TALK_WORD_SIZE; if(c_rect.right > 0) { mainPtr.setActive(false);