don't use hairline spaces for alingment in the info box

This commit is contained in:
Vas Crabb 2017-07-27 13:19:12 +10:00
parent 814607df5e
commit ea7bc5dd72
4 changed files with 110 additions and 66 deletions

View File

@ -1188,50 +1188,52 @@ void menu_select_game::general_info(const game_driver *driver, std::string &buff
{
std::ostringstream str;
util::stream_format(str, _("Romset: %1$-.100s\n"), driver->name);
util::stream_format(str, _("Year: %1$s\n"), driver->year);
util::stream_format(str, _("Manufacturer: %1$-.100s\n"), driver->manufacturer);
str << "#j2\n";
util::stream_format(str, _("Romset\t%1$-.100s\n"), driver->name);
util::stream_format(str, _("Year\t%1$s\n"), driver->year);
util::stream_format(str, _("Manufacturer\t%1$-.100s\n"), driver->manufacturer);
int cloneof = driver_list::non_bios_clone(*driver);
if (cloneof != -1)
util::stream_format(str, _("Driver is Clone of: %1$-.100s\n"), driver_list::driver(cloneof).type.fullname());
util::stream_format(str, _("Driver is Clone of\t%1$-.100s\n"), driver_list::driver(cloneof).type.fullname());
else
str << _("Driver is Parent:\n");
str << _("Driver is Parent\t\n");
if (driver->flags & machine_flags::NOT_WORKING)
str << _("Overall: NOT WORKING\n");
str << _("Overall\tNOT WORKING\n");
else if ((driver->type.unemulated_features() | driver->type.imperfect_features()) & device_t::feature::PROTECTION)
str << _("Overall: Unemulated Protection\n");
str << _("Overall\tUnemulated Protection\n");
else
str << _("Overall: Working\n");
str << _("Overall\tWorking\n");
if (driver->type.unemulated_features() & device_t::feature::GRAPHICS)
str << _("Graphics: Unimplemented\n");
str << _("Graphics\tUnimplemented\n");
else if (driver->type.unemulated_features() & device_t::feature::PALETTE)
str << ("Graphics: Wrong Colors\n");
str << ("Graphics\tWrong Colors\n");
else if (driver->type.imperfect_features() & device_t::feature::PALETTE)
str << _("Graphics: Imperfect Colors\n");
str << _("Graphics\tImperfect Colors\n");
else if (driver->type.imperfect_features() & device_t::feature::GRAPHICS)
str << _("Graphics: Imperfect\n");
str << _("Graphics\tImperfect\n");
else
str << _("Graphics: OK\n");
str << _("Graphics\tOK\n");
if (driver->flags & machine_flags::NO_SOUND_HW)
str << _("Sound: None\n");
str << _("Sound\tNone\n");
else if (driver->type.unemulated_features() & device_t::feature::SOUND)
str << _("Sound: Unimplemented\n");
str << _("Sound\tUnimplemented\n");
else if (driver->type.imperfect_features() & device_t::feature::SOUND)
str << _("Sound: Imperfect\n");
str << _("Sound\tImperfect\n");
else
str << _("Sound: OK\n");
str << _("Sound\tOK\n");
util::stream_format(str, _("Game is Mechanical: %1$s\n"), ((driver->flags & machine_flags::MECHANICAL) ? _("Yes") : _("No")));
util::stream_format(str, _("Requires Artwork: %1$s\n"), ((driver->flags & machine_flags::REQUIRES_ARTWORK) ? _("Yes") : _("No")));
util::stream_format(str, _("Requires Clickable Artwork: %1$s\n"), ((driver->flags & machine_flags::CLICKABLE_ARTWORK) ? _("Yes") : _("No")));
util::stream_format(str, _("Support Cocktail: %1$s\n"), ((driver->flags & machine_flags::NO_COCKTAIL) ? _("Yes") : _("No")));
util::stream_format(str, _("Driver is Bios: %1$s\n"), ((driver->flags & machine_flags::IS_BIOS_ROOT) ? _("Yes") : _("No")));
util::stream_format(str, _("Support Save: %1$s\n"), ((driver->flags & machine_flags::SUPPORTS_SAVE) ? _("Yes") : _("No")));
util::stream_format(str, _("Screen Orientation: %1$s\n"), ((driver->flags & ORIENTATION_SWAP_XY) ? _("Vertical") : _("Horizontal")));
util::stream_format(str, _("Game is Mechanical\t%1$s\n"), ((driver->flags & machine_flags::MECHANICAL) ? _("Yes") : _("No")));
util::stream_format(str, _("Requires Artwork\t%1$s\n"), ((driver->flags & machine_flags::REQUIRES_ARTWORK) ? _("Yes") : _("No")));
util::stream_format(str, _("Requires Clickable Artwork\t%1$s\n"), ((driver->flags & machine_flags::CLICKABLE_ARTWORK) ? _("Yes") : _("No")));
util::stream_format(str, _("Support Cocktail\t%1$s\n"), ((driver->flags & machine_flags::NO_COCKTAIL) ? _("Yes") : _("No")));
util::stream_format(str, _("Driver is Bios\t%1$s\n"), ((driver->flags & machine_flags::IS_BIOS_ROOT) ? _("Yes") : _("No")));
util::stream_format(str, _("Support Save\t%1$s\n"), ((driver->flags & machine_flags::SUPPORTS_SAVE) ? _("Yes") : _("No")));
util::stream_format(str, _("Screen Orientation\t%1$s\n"), ((driver->flags & ORIENTATION_SWAP_XY) ? _("Vertical") : _("Horizontal")));
bool found = false;
auto entries = rom_build_entries(driver->rom);
for (const rom_entry &rom : entries)
@ -1240,7 +1242,7 @@ void menu_select_game::general_info(const game_driver *driver, std::string &buff
found = true;
break;
}
util::stream_format(str, _("Requires CHD: %1$s\n"), found ? _("Yes") : _("No"));
util::stream_format(str, _("Requires CHD\t%1$s\n"), found ? _("Yes") : _("No"));
// audit the game first to see if we're going to work
if (ui().options().info_audit())
@ -1253,38 +1255,20 @@ void menu_select_game::general_info(const game_driver *driver, std::string &buff
// if everything looks good, schedule the new driver
if (summary == media_auditor::CORRECT || summary == media_auditor::BEST_AVAILABLE || summary == media_auditor::NONE_NEEDED)
str << _("Roms Audit Pass: OK\n");
str << _("Roms Audit Pass\tOK\n");
else
str << _("Roms Audit Pass: BAD\n");
str << _("Roms Audit Pass\tBAD\n");
if (summary_samples == media_auditor::NONE_NEEDED)
str << _("Samples Audit Pass: None Needed\n");
str << _("Samples Audit Pass\tNone Needed\n");
else if (summary_samples == media_auditor::CORRECT || summary_samples == media_auditor::BEST_AVAILABLE)
str << _("Samples Audit Pass: OK\n");
str << _("Samples Audit Pass\tOK\n");
else
str << _("Samples Audit Pass: BAD\n");
str << _("Samples Audit Pass\tBAD\n");
}
else
str << _("Roms Audit Pass: Disabled\nSamples Audit Pass: Disabled\n");
str << _("Roms Audit Pass\tDisabled\nSamples Audit Pass\tDisabled\n");
std::istringstream istr(str.str());
std::string line;
float spacewid = ui().get_char_width(0x200a);
str.clear();
str.seekp(0);
str << "#jp\n";
while(std::getline(istr, line))
{
int nspace = floor((0.35 - ui().get_string_width(line.c_str())) / spacewid);
if(nspace < 5)
nspace = 5;
std::string newstr;
newstr.reserve((nspace * 3) + line.length());
newstr.append(line.substr(0, line.find(':')));
for(int i = 0; i < nspace; i++)
newstr.append("\xE2\x80\x8A");
str << newstr.append(line.substr(line.find(':') + 1, line.npos)).append("\n");
}
buffer = str.str();
}

View File

@ -2452,9 +2452,21 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2,
draw_common_arrow(origx1, origy1, origx2, origy2, m_info_view, 0, total - 1, title_size);
if (justify == 'f')
m_total_lines = ui().wrap_text(container(), m_info_buffer.c_str(), 0.0f, 0.0f, 1.0f - (2.0f * gutter_width), xstart, xend, text_size);
{
m_total_lines = ui().wrap_text(
container(), m_info_buffer.c_str(),
0.0f, 0.0f, 1.0f - (2.0f * gutter_width),
xstart, xend,
text_size);
}
else
m_total_lines = ui().wrap_text(container(), m_info_buffer.c_str(), origx1, origy1, origx2 - origx1 - (2.0f * gutter_width), xstart, xend, text_size);
{
m_total_lines = ui().wrap_text(
container(), m_info_buffer.c_str(),
origx1, origy1, origx2 - origx1 - (2.0f * gutter_width),
xstart, xend,
text_size);
}
int r_visible_lines = floor((origy2 - oy1) / (line_height * text_size));
if (m_total_lines < r_visible_lines)
@ -2468,28 +2480,69 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2,
for (int r = 0; r < r_visible_lines; ++r)
{
int itemline = r + m_topline_datsview;
std::string tempbuf(m_info_buffer.substr(xstart[itemline], xend[itemline] - xstart[itemline]));
std::string const tempbuf(m_info_buffer.substr(xstart[itemline], xend[itemline] - xstart[itemline]));
if (tempbuf[0] == '#')
continue;
// up arrow
if (r == 0 && m_topline_datsview != 0)
if (r == 0 && m_topline_datsview != 0) // up arrow
{
draw_info_arrow(0, origx1, origx2, oy1, line_height, text_size, ud_arrow_width);
// bottom arrow
else if (r == r_visible_lines - 1 && itemline != m_total_lines - 1)
}
else if (r == r_visible_lines - 1 && itemline != m_total_lines - 1) // bottom arrow
{
draw_info_arrow(1, origx1, origx2, oy1, line_height, text_size, ud_arrow_width);
}
else if (justify == '2') // two-column layout
{
// split at first tab
std::string::size_type const splitpos(tempbuf.find('\t'));
std::string const leftcol(tempbuf.substr(0, (std::string::npos == splitpos) ? 0U : splitpos));
std::string const rightcol(tempbuf.substr((std::string::npos == splitpos) ? 0U : (splitpos + 1U)));
// measure space needed, condense if necessary
float const leftlen(ui().get_string_width(leftcol.c_str(), text_size));
float const rightlen(ui().get_string_width(rightcol.c_str(), text_size));
float const textlen(leftlen + rightlen);
float const tmp_size3((textlen > sc) ? (text_size * (sc / textlen)) : text_size);
// draw in two parts
ui().draw_text_full(
container(), leftcol.c_str(),
origx1 + gutter_width, oy1, sc,
ui::text_layout::LEFT, ui::text_layout::TRUNCATE,
mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR,
nullptr, nullptr,
tmp_size3);
ui().draw_text_full(
container(), rightcol.c_str(),
origx1 + gutter_width, oy1, sc,
ui::text_layout::RIGHT, ui::text_layout::TRUNCATE,
mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR,
nullptr, nullptr,
tmp_size3);
}
else if (justify == 'f' || justify == 'p') // full or partial justify
{
// check size
float textlen = ui().get_string_width(tempbuf.c_str(), text_size);
float const textlen = ui().get_string_width(tempbuf.c_str(), text_size);
float tmp_size3 = (textlen > sc) ? text_size * (sc / textlen) : text_size;
ui().draw_text_full(container(), tempbuf.c_str(), origx1 + gutter_width, oy1, origx2 - origx1, ui::text_layout::LEFT,
ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, tmp_size3);
ui().draw_text_full(
container(), tempbuf.c_str(),
origx1 + gutter_width, oy1, origx2 - origx1,
ui::text_layout::LEFT, ui::text_layout::TRUNCATE,
mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR,
nullptr, nullptr,
tmp_size3);
}
else
{
ui().draw_text_full(container(), tempbuf.c_str(), origx1 + gutter_width, oy1, origx2 - origx1, ui::text_layout::LEFT,
ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, text_size);
ui().draw_text_full(
container(), tempbuf.c_str(),
origx1 + gutter_width, oy1, origx2 - origx1,
ui::text_layout::LEFT, ui::text_layout::TRUNCATE,
mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR,
nullptr, nullptr,
text_size);
}
oy1 += (line_height * text_size);

View File

@ -18,6 +18,7 @@
namespace ui {
/***************************************************************************
INLINE FUNCTIONS
***************************************************************************/
@ -82,8 +83,11 @@ CORE IMPLEMENTATION
//-------------------------------------------------
text_layout::text_layout(render_font &font, float xscale, float yscale, float width, text_layout::text_justify justify, text_layout::word_wrapping wrap)
: m_font(font), m_xscale(xscale), m_yscale(yscale), m_width(width), m_justify(justify), m_wrap(wrap), m_current_line(nullptr), m_last_break(0), m_text_position(0), m_truncating(false)
: m_font(font)
, m_xscale(xscale), m_yscale(yscale)
, m_width(width)
, m_justify(justify), m_wrap(wrap)
, m_current_line(nullptr), m_last_break(0), m_text_position(0), m_truncating(false)
{
invalidate_calculated_actual_width();
}
@ -94,8 +98,11 @@ text_layout::text_layout(render_font &font, float xscale, float yscale, float wi
//-------------------------------------------------
text_layout::text_layout(text_layout &&that)
: m_font(that.m_font), m_xscale(that.m_xscale), m_yscale(that.m_yscale), m_width(that.m_width), m_calculated_actual_width(that.m_calculated_actual_width), m_justify(that.m_justify), m_wrap(that.m_wrap), m_lines(std::move(that.m_lines)),
m_current_line(that.m_current_line), m_last_break(that.m_last_break), m_text_position(that.m_text_position), m_truncating(false)
: m_font(that.m_font)
, m_xscale(that.m_xscale), m_yscale(that.m_yscale)
, m_width(that.m_width), m_calculated_actual_width(that.m_calculated_actual_width)
, m_justify(that.m_justify), m_wrap(that.m_wrap)
, m_lines(std::move(that.m_lines)), m_current_line(that.m_current_line), m_last_break(that.m_last_break), m_text_position(that.m_text_position), m_truncating(false)
{
that.invalidate_calculated_actual_width();
}

View File

@ -2019,7 +2019,7 @@ int32_t mame_ui_manager::slider_crossoffset(running_machine &machine, void *arg,
//-------------------------------------------------
// wrap_text
// create_layout
//-------------------------------------------------
ui::text_layout mame_ui_manager::create_layout(render_container &container, float width, ui::text_layout::text_justify justify, ui::text_layout::word_wrapping wrap)