shrink talk text when it doesn't fit
This commit is contained in:
@@ -662,15 +662,16 @@ std::vector<std::string> preset_words = {
|
|||||||
"Ask About...",
|
"Ask About...",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::vector<location> preset_word_locs = {
|
||||||
|
{4, 366}, {70, 366}, {136, 366},
|
||||||
|
{4, 389}, {70, 389}, {121, 389},
|
||||||
|
{210, 389}, {190, 366},
|
||||||
|
{4, 343}
|
||||||
|
};
|
||||||
|
|
||||||
static void reset_talk_words() {
|
static void reset_talk_words() {
|
||||||
// first initialise talk_words here
|
// first initialise talk_words here
|
||||||
talk_words.clear();
|
talk_words.clear();
|
||||||
static const std::vector<location> preset_word_locs = {
|
|
||||||
{4, 366}, {70, 366}, {136, 366},
|
|
||||||
{4, 389}, {70, 389}, {121, 389},
|
|
||||||
{210, 389}, {190, 366},
|
|
||||||
{4, 343}
|
|
||||||
};
|
|
||||||
TextStyle style;
|
TextStyle style;
|
||||||
style.font = FONT_DUNGEON;
|
style.font = FONT_DUNGEON;
|
||||||
style.pointSize = TALK_WORD_SIZE;
|
style.pointSize = TALK_WORD_SIZE;
|
||||||
|
@@ -1022,6 +1022,16 @@ void place_talk_str(std::string str_to_place,std::string str_to_place2,short col
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the text will overflow onto the preset talk words, shrink it
|
||||||
|
extern std::vector<location> preset_word_locs;
|
||||||
|
auto break_info = calculate_line_wrapping(word_place_rect, str, style);
|
||||||
|
short lines = break_info.size();
|
||||||
|
short height = lines * (style.lineHeight+1);
|
||||||
|
if(height >= word_place_rect.height()){
|
||||||
|
short overflow = height - preset_word_locs.back().y;
|
||||||
|
style.lineHeight -= ceil(overflow / (float) lines);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<rectangle> word_rects = draw_string_hilite(talk_gworld(), word_place_rect, str, style, hilites, color ? CUSTOM_WORD_ON : CUSTOM_WORD_OFF);
|
std::vector<rectangle> word_rects = draw_string_hilite(talk_gworld(), word_place_rect, str, style, hilites, color ? CUSTOM_WORD_ON : CUSTOM_WORD_OFF);
|
||||||
|
|
||||||
if(!talk_end_forced) {
|
if(!talk_end_forced) {
|
||||||
|
Reference in New Issue
Block a user