Fix strings not wrapping the file browser window.

This commit is contained in:
Aaron van Geffen 2019-05-18 19:17:14 +02:00
parent c0358a44ce
commit b66921e19e
4 changed files with 15 additions and 9 deletions

View File

@ -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)
------------------------------------------------------------------------

View File

@ -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

View File

@ -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);

View File

@ -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);
}
}