diff --git a/CHANGELOG.md b/CHANGELOG.md index e5cdac57..09584a7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fix: [#297] Menu click sound not played. - Fix: [#303] Play title music preference is not saved. - Fix: [#340] Cargo rating is calculated incorrectly in some edge cases. +- Fix: Strings were not wrapping properly in the file browser window. 19.03 (2019-03-01) ------------------------------------------------------------------------ diff --git a/src/openloco/graphics/gfx.cpp b/src/openloco/graphics/gfx.cpp index 741e3b8a..37886789 100644 --- a/src/openloco/graphics/gfx.cpp +++ b/src/openloco/graphics/gfx.cpp @@ -525,15 +525,17 @@ namespace openloco::gfx // 0x00495224 // al: colour + // bp: width // bx: string id // cx: x // dx: y // esi: args // edi: dpi - void draw_string_495224( + int16_t draw_string_495224( drawpixelinfo_t& dpi, int16_t x, int16_t y, + int16_t width, uint8_t colour, string_id stringId, const void* args) @@ -541,11 +543,14 @@ namespace openloco::gfx registers regs; regs.al = colour; regs.bx = stringId; + regs.bp = width; regs.cx = x; regs.dx = y; regs.esi = (int32_t)args; regs.edi = (int32_t)&dpi; call(0x00495224, regs); + + return regs.dx; } // 0x00494B3F diff --git a/src/openloco/graphics/gfx.h b/src/openloco/graphics/gfx.h index 767a0604..5a5aec51 100644 --- a/src/openloco/graphics/gfx.h +++ b/src/openloco/graphics/gfx.h @@ -138,10 +138,11 @@ namespace openloco::gfx gfx::point_t draw_string(drawpixelinfo_t* context, int16_t x, int16_t y, uint8_t colour, void* str); - void draw_string_495224( + int16_t draw_string_495224( drawpixelinfo_t& dpi, int16_t x, int16_t y, + int16_t width, uint8_t colour, string_id stringId, const void* args = nullptr); diff --git a/src/openloco/windows/promptbrowsewnd.cpp b/src/openloco/windows/promptbrowsewnd.cpp index de67def1..28e427c6 100644 --- a/src/openloco/windows/promptbrowsewnd.cpp +++ b/src/openloco/windows/promptbrowsewnd.cpp @@ -390,19 +390,18 @@ namespace openloco::ui::prompt_browse } y += 207; + uint16_t maxWidth = window.width - window.widgets[7].right; + // Company set_common_args_stringptr(saveInfo.company); - gfx::draw_string_495224(dpi, x, y, 0, string_ids::window_browse_company, _commonFormatArgs); - y += 10; + y = gfx::draw_string_495224(dpi, x, y, maxWidth, colour::black, string_ids::window_browse_company, _commonFormatArgs); // Owner set_common_args_stringptr(saveInfo.owner); - gfx::draw_string_495224(dpi, x, y, 0, string_ids::owner_label, _commonFormatArgs); - y += 10; + y = gfx::draw_string_495224(dpi, x, y, maxWidth, colour::black, string_ids::owner_label, _commonFormatArgs); // Date - gfx::draw_string_495224(dpi, x, y, 0, string_ids::window_browse_date, &saveInfo.date); - y += 10; + y = gfx::draw_string_495224(dpi, x, y, maxWidth, colour::black, string_ids::window_browse_date, &saveInfo.date); // Challenge progress auto flags = saveInfo.challenge_flags; @@ -419,7 +418,7 @@ namespace openloco::ui::prompt_browse progress = saveInfo.challenge_progress; } } - gfx::draw_string_495224(dpi, x, y, 0, stringId, &progress); + gfx::draw_string_495224(dpi, x, y, maxWidth, colour::black, stringId, &progress); } }