summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2020-12-08 21:19:17 -0500
committer AJR <ajrhacker@users.noreply.github.com>2020-12-08 21:24:46 -0500
commitc22cb17f326b4939d8ff4219410909e32e70ab86 (patch)
tree8db68c201fa9673eeb6acab37a5d221c7a338ea6
parent6172111b187c1dd66329adb2b9bba2a82a0ce116 (diff)
C++17 string handling updates (without charconv so as not to break GCC 7)
- render.cpp, rendlay.cpp, ui/ui.cpp, ui/menu.cpp: Change argument types for text processing functions from const char * to std::string_view - ui/menu.cpp: Add overloads of item_append omitting the frequently empty subtext argument - cheat.cpp: Remove some c_str() calls that became unnecessary a while ago
-rw-r--r--src/emu/render.h3
-rw-r--r--src/emu/rendfont.cpp20
-rw-r--r--src/emu/rendfont.h4
-rw-r--r--src/emu/rendlay.cpp49
-rw-r--r--src/frontend/mame/cheat.cpp28
-rw-r--r--src/frontend/mame/ui/about.cpp4
-rw-r--r--src/frontend/mame/ui/analogipt.cpp2
-rw-r--r--src/frontend/mame/ui/auditmenu.cpp4
-rw-r--r--src/frontend/mame/ui/barcode.cpp4
-rw-r--r--src/frontend/mame/ui/cheatopt.cpp4
-rw-r--r--src/frontend/mame/ui/confswitch.cpp4
-rw-r--r--src/frontend/mame/ui/custui.cpp62
-rw-r--r--src/frontend/mame/ui/datmenu.cpp26
-rw-r--r--src/frontend/mame/ui/devopt.cpp2
-rw-r--r--src/frontend/mame/ui/dirmenu.cpp18
-rw-r--r--src/frontend/mame/ui/filecreate.cpp14
-rw-r--r--src/frontend/mame/ui/filemngr.cpp14
-rw-r--r--src/frontend/mame/ui/filesel.cpp12
-rw-r--r--src/frontend/mame/ui/info.cpp20
-rw-r--r--src/frontend/mame/ui/info_pty.cpp6
-rw-r--r--src/frontend/mame/ui/inputmap.cpp10
-rw-r--r--src/frontend/mame/ui/mainmenu.cpp56
-rw-r--r--src/frontend/mame/ui/menu.cpp70
-rw-r--r--src/frontend/mame/ui/menu.h18
-rw-r--r--src/frontend/mame/ui/miscmenu.cpp26
-rw-r--r--src/frontend/mame/ui/optsmenu.cpp18
-rw-r--r--src/frontend/mame/ui/pluginopt.cpp2
-rw-r--r--src/frontend/mame/ui/selector.cpp4
-rw-r--r--src/frontend/mame/ui/selgame.cpp10
-rw-r--r--src/frontend/mame/ui/selmenu.cpp52
-rw-r--r--src/frontend/mame/ui/selsoft.cpp2
-rw-r--r--src/frontend/mame/ui/simpleselgame.cpp4
-rw-r--r--src/frontend/mame/ui/sliders.cpp4
-rw-r--r--src/frontend/mame/ui/slotopt.cpp2
-rw-r--r--src/frontend/mame/ui/state.cpp12
-rw-r--r--src/frontend/mame/ui/state.h6
-rw-r--r--src/frontend/mame/ui/submenu.cpp6
-rw-r--r--src/frontend/mame/ui/swlist.cpp14
-rw-r--r--src/frontend/mame/ui/tapectrl.cpp10
-rw-r--r--src/frontend/mame/ui/text.cpp15
-rw-r--r--src/frontend/mame/ui/text.h5
-rw-r--r--src/frontend/mame/ui/ui.cpp30
-rw-r--r--src/frontend/mame/ui/ui.h13
-rw-r--r--src/frontend/mame/ui/utils.cpp51
-rw-r--r--src/frontend/mame/ui/videoopt.cpp9
-rw-r--r--src/frontend/mame/ui/viewgfx.cpp6
46 files changed, 355 insertions, 400 deletions
diff --git a/src/emu/render.h b/src/emu/render.h
index a94a23a0c97..3b945a08b8c 100644
--- a/src/emu/render.h
+++ b/src/emu/render.h
@@ -56,6 +56,7 @@
#include <memory>
#include <mutex>
#include <string>
+#include <string_view>
#include <tuple>
#include <unordered_map>
#include <utility>
@@ -591,7 +592,7 @@ private:
virtual void draw_aligned(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state);
// drawing helpers
- void draw_text(render_font &font, bitmap_argb32 &dest, const rectangle &bounds, const char *str, int align, const render_color &color);
+ void draw_text(render_font &font, bitmap_argb32 &dest, const rectangle &bounds, std::string_view str, int align, const render_color &color);
void draw_segment_horizontal_caps(bitmap_argb32 &dest, int minx, int maxx, int midy, int width, int caps, rgb_t color);
void draw_segment_horizontal(bitmap_argb32 &dest, int minx, int maxx, int midy, int width, rgb_t color);
void draw_segment_vertical_caps(bitmap_argb32 &dest, int miny, int maxy, int midx, int width, int caps, rgb_t color);
diff --git a/src/emu/rendfont.cpp b/src/emu/rendfont.cpp
index 13249a083fc..93072ffdc01 100644
--- a/src/emu/rendfont.cpp
+++ b/src/emu/rendfont.cpp
@@ -856,21 +856,19 @@ float render_font::char_width(float height, float aspect, char32_t ch)
// at the given height
//-------------------------------------------------
-float render_font::string_width(float height, float aspect, const char *string)
+float render_font::string_width(float height, float aspect, std::string_view string)
{
// loop over the string and accumulate widths
int totwidth = 0;
- const char *ends = string + strlen(string);
- const char *s = string;
char32_t schar;
// loop over characters
- while (*s != 0)
+ while (!string.empty())
{
- int scharcount = uchar_from_utf8(&schar, s, ends - s);
+ int scharcount = uchar_from_utf8(&schar, &string[0], string.length());
totwidth += get_char(schar).width;
- s += scharcount;
+ string.remove_prefix(scharcount);
}
@@ -884,21 +882,19 @@ float render_font::string_width(float height, float aspect, const char *string)
// UTF8-encoded string at the given height
//-------------------------------------------------
-float render_font::utf8string_width(float height, float aspect, const char *utf8string)
+float render_font::utf8string_width(float height, float aspect, std::string_view utf8string)
{
- std::size_t const length = std::strlen(utf8string);
-
// loop over the string and accumulate widths
- int count;
s32 totwidth = 0;
- for (std::size_t offset = 0U; offset < length; offset += unsigned(count))
+ while (!utf8string.empty())
{
char32_t uchar;
- count = uchar_from_utf8(&uchar, utf8string + offset, length - offset);
+ int count = uchar_from_utf8(&uchar, &utf8string[0], utf8string.length());
if (count < 0)
break;
totwidth += get_char(uchar).width;
+ utf8string.remove_prefix(count);
}
// scale the final result based on height
diff --git a/src/emu/rendfont.h b/src/emu/rendfont.h
index fc0c4853733..f4ceb78bf09 100644
--- a/src/emu/rendfont.h
+++ b/src/emu/rendfont.h
@@ -37,8 +37,8 @@ public:
// size queries
s32 pixel_height() const { return m_height; }
float char_width(float height, float aspect, char32_t ch);
- float string_width(float height, float aspect, const char *string);
- float utf8string_width(float height, float aspect, const char *utf8string);
+ float string_width(float height, float aspect, std::string_view string);
+ float utf8string_width(float height, float aspect, std::string_view utf8string);
// texture/bitmap queries
render_texture *get_char_texture_and_bounds(float height, float aspect, char32_t ch, render_bounds &bounds);
diff --git a/src/emu/rendlay.cpp b/src/emu/rendlay.cpp
index 422b93e7268..50882d0d214 100644
--- a/src/emu/rendlay.cpp
+++ b/src/emu/rendlay.cpp
@@ -2295,7 +2295,7 @@ protected:
virtual void draw_aligned(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state) override
{
auto font = machine.render().font_alloc("default");
- draw_text(*font, dest, bounds, m_string.c_str(), m_textalign, color(state));
+ draw_text(*font, dest, bounds, m_string, m_textalign, color(state));
}
private:
@@ -2985,7 +2985,7 @@ protected:
virtual void draw_aligned(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state) override
{
auto font = machine.render().font_alloc("default");
- draw_text(*font, dest, bounds, string_format("%0*d", m_digits, state).c_str(), m_textalign, color(state));
+ draw_text(*font, dest, bounds, string_format("%0*d", m_digits, state), m_textalign, color(state));
}
private:
@@ -3137,18 +3137,13 @@ protected:
// allocate a temporary bitmap
bitmap_argb32 tempbitmap(dest.width(), dest.height());
- const char *origs = m_stopnames[fruit].c_str();
- const char *ends = origs + strlen(origs);
- const char *s = origs;
- char32_t schar;
-
// get the width of the string
float aspect = 1.0f;
s32 width;
while (1)
{
- width = font->string_width(ourheight / num_shown, aspect, m_stopnames[fruit].c_str());
+ width = font->string_width(ourheight / num_shown, aspect, m_stopnames[fruit]);
if (width < bounds.width())
break;
aspect *= 0.9f;
@@ -3157,9 +3152,11 @@ protected:
s32 curx = bounds.left() + (bounds.width() - width) / 2;
// loop over characters
- while (*s != 0)
+ std::string_view s = m_stopnames[fruit];
+ while (!s.empty())
{
- int scharcount = uchar_from_utf8(&schar, s, ends - s);
+ char32_t schar;
+ int scharcount = uchar_from_utf8(&schar, &s[0], s.length());
if (scharcount == -1)
break;
@@ -3199,7 +3196,7 @@ protected:
// advance in the X direction
curx += font->char_width(ourheight/num_shown, aspect, schar);
- s += scharcount;
+ s.remove_prefix(scharcount);
}
}
}
@@ -3294,7 +3291,7 @@ private:
s32 width;
while (1)
{
- width = font->string_width(dest.height(), aspect, m_stopnames[fruit].c_str());
+ width = font->string_width(dest.height(), aspect, m_stopnames[fruit]);
if (width < bounds.width())
break;
aspect *= 0.9f;
@@ -3305,15 +3302,12 @@ private:
// allocate a temporary bitmap
bitmap_argb32 tempbitmap(dest.width(), dest.height());
- const char *origs = m_stopnames[fruit].c_str();
- const char *ends = origs + strlen(origs);
- const char *s = origs;
- char32_t schar;
-
// loop over characters
- while (*s != 0)
+ std::string_view s = m_stopnames[fruit];
+ while (!s.empty())
{
- int scharcount = uchar_from_utf8(&schar, s, ends - s);
+ char32_t schar;
+ int scharcount = uchar_from_utf8(&schar, &s[0], s.length());
if (scharcount == -1)
break;
@@ -3353,7 +3347,7 @@ private:
// advance in the X direction
curx += font->char_width(dest.height(), aspect, schar);
- s += scharcount;
+ s.remove_prefix(scharcount);
}
}
}
@@ -3650,7 +3644,7 @@ void layout_element::component::draw_text(
render_font &font,
bitmap_argb32 &dest,
const rectangle &bounds,
- const char *str,
+ std::string_view str,
int align,
const render_color &color)
{
@@ -3696,15 +3690,10 @@ void layout_element::component::draw_text(
bitmap_argb32 tempbitmap(dest.width(), dest.height());
// loop over characters
- const char *origs = str;
- const char *ends = origs + strlen(origs);
- const char *s = origs;
- char32_t schar;
-
- // loop over characters
- while (*s != 0)
+ while (!str.empty())
{
- int scharcount = uchar_from_utf8(&schar, s, ends - s);
+ char32_t schar;
+ int scharcount = uchar_from_utf8(&schar, &str[0], str.length());
if (scharcount == -1)
break;
@@ -3743,7 +3732,7 @@ void layout_element::component::draw_text(
// advance in the X direction
curx += font.char_width(bounds.height(), aspect, schar);
- s += scharcount;
+ str.remove_prefix(scharcount);
}
}
diff --git a/src/frontend/mame/cheat.cpp b/src/frontend/mame/cheat.cpp
index be5e9da9191..125a6634dbb 100644
--- a/src/frontend/mame/cheat.cpp
+++ b/src/frontend/mame/cheat.cpp
@@ -212,11 +212,11 @@ void cheat_parameter::save(emu_file &cheatfile) const
{
// if no items, just output min/max/step
if (m_minval != 0)
- cheatfile.printf(" min=\"%s\"", m_minval.format().c_str());
+ cheatfile.printf(" min=\"%s\"", m_minval.format());
if (m_maxval != 0)
- cheatfile.printf(" max=\"%s\"", m_maxval.format().c_str());
+ cheatfile.printf(" max=\"%s\"", m_maxval.format());
if (m_stepval != 1)
- cheatfile.printf(" step=\"%s\"", m_stepval.format().c_str());
+ cheatfile.printf(" step=\"%s\"", m_stepval.format());
cheatfile.printf("/>\n");
}
else
@@ -224,7 +224,7 @@ void cheat_parameter::save(emu_file &cheatfile) const
// iterate over items
cheatfile.printf(">\n");
for (item const &curitem : m_itemlist)
- cheatfile.printf("\t\t\t<item value=\"%s\">%s</item>\n", curitem.value().format().c_str(), curitem.text());
+ cheatfile.printf("\t\t\t<item value=\"%s\">%s</item>\n", curitem.value().format(), curitem.text());
cheatfile.printf("\t\t</parameter>\n");
}
}
@@ -533,15 +533,15 @@ void cheat_script::script_entry::save(emu_file &cheatfile) const
// output an action
cheatfile.printf("\t\t\t<action");
if (!m_condition.is_empty())
- cheatfile.printf(" condition=\"%s\"", cheat_manager::quote_expression(m_condition).c_str());
- cheatfile.printf(">%s</action>\n", cheat_manager::quote_expression(m_expression).c_str());
+ cheatfile.printf(" condition=\"%s\"", cheat_manager::quote_expression(m_condition));
+ cheatfile.printf(">%s</action>\n", cheat_manager::quote_expression(m_expression));
}
else
{
// output an output
cheatfile.printf("\t\t\t<output format=\"%s\"", m_format.c_str());
if (!m_condition.is_empty())
- cheatfile.printf(" condition=\"%s\"", cheat_manager::quote_expression(m_condition).c_str());
+ cheatfile.printf(" condition=\"%s\"", cheat_manager::quote_expression(m_condition));
if (m_line != 0)
cheatfile.printf(" line=\"%d\"", m_line);
@@ -588,14 +588,14 @@ void cheat_script::script_entry::validate_format(std::string const &filename, in
// look for a valid type
if (!strchr("cdiouxX", *p))
- throw emu_fatalerror("%s.xml(%d): invalid format specification \"%s\"\n", filename, line, m_format.c_str());
+ throw emu_fatalerror("%s.xml(%d): invalid format specification \"%s\"\n", filename, line, m_format);
}
// did we match?
if (argscounted < argsprovided)
- throw emu_fatalerror("%s.xml(%d): too many arguments provided (%d) for format \"%s\"\n", filename, line, argsprovided, m_format.c_str());
+ throw emu_fatalerror("%s.xml(%d): too many arguments provided (%d) for format \"%s\"\n", filename, line, argsprovided, m_format);
if (argscounted > argsprovided)
- throw emu_fatalerror("%s.xml(%d): not enough arguments provided (%d) for format \"%s\"\n", filename, line, argsprovided, m_format.c_str());
+ throw emu_fatalerror("%s.xml(%d): not enough arguments provided (%d) for format \"%s\"\n", filename, line, argsprovided, m_format);
}
@@ -662,7 +662,7 @@ void cheat_script::script_entry::output_argument::save(emu_file &cheatfile) cons
cheatfile.printf("\t\t\t\t<argument");
if (m_count != 1)
cheatfile.printf(" count=\"%d\"", int(m_count));
- cheatfile.printf(">%s</argument>\n", cheat_manager::quote_expression(m_expression).c_str());
+ cheatfile.printf(">%s</argument>\n", cheat_manager::quote_expression(m_expression));
}
@@ -763,7 +763,7 @@ void cheat_entry::save(emu_file &cheatfile) const
bool const has_scripts(m_off_script || m_on_script || m_run_script || m_change_script);
// output the cheat tag
- cheatfile.printf("\t<cheat desc=\"%s\"", m_description.c_str());
+ cheatfile.printf("\t<cheat desc=\"%s\"", m_description);
if (m_numtemp != DEFAULT_TEMP_VARIABLES)
cheatfile.printf(" tempvariables=\"%d\"", m_numtemp);
@@ -777,7 +777,7 @@ void cheat_entry::save(emu_file &cheatfile) const
// save the comment
if (!m_comment.empty())
- cheatfile.printf("\t\t<comment><![CDATA[\n%s\n\t\t]]></comment>\n", m_comment.c_str());
+ cheatfile.printf("\t\t<comment><![CDATA[\n%s\n\t\t]]></comment>\n", m_comment);
// output the parameter, if present
if (m_parameter) m_parameter->save(cheatfile);
@@ -1235,7 +1235,7 @@ void cheat_manager::render_text(mame_ui_manager &mui, render_container &containe
if (!m_output[linenum].empty())
{
// output the text
- mui.draw_text_full(container, m_output[linenum].c_str(),
+ mui.draw_text_full(container, m_output[linenum],
0.0f, float(linenum) * mui.get_line_height(), 1.0f,
m_justify[linenum], ui::text_layout::NEVER, mame_ui_manager::OPAQUE_,
rgb_t::white(), rgb_t::black(), nullptr, nullptr);
diff --git a/src/frontend/mame/ui/about.cpp b/src/frontend/mame/ui/about.cpp
index 5472fc727c4..b55267d1b96 100644
--- a/src/frontend/mame/ui/about.cpp
+++ b/src/frontend/mame/ui/about.cpp
@@ -58,11 +58,11 @@ menu_about::~menu_about()
void menu_about::populate(float &customtop, float &custombottom)
{
std::string title = string_format(_("%1$s %2$s"), emulator_info::get_appname(), bare_build_version);
- item_append(title, "", 0, nullptr);
+ item_append(title, 0, nullptr);
item_append(menu_item_type::SEPARATOR);
for (char const *const *line = copying_text; *line; ++line)
- item_append(*line, "", 0, nullptr);
+ item_append(*line, 0, nullptr);
item_append(menu_item_type::SEPARATOR);
}
diff --git a/src/frontend/mame/ui/analogipt.cpp b/src/frontend/mame/ui/analogipt.cpp
index 075a5e0bf4e..83b7b48f09d 100644
--- a/src/frontend/mame/ui/analogipt.cpp
+++ b/src/frontend/mame/ui/analogipt.cpp
@@ -207,7 +207,7 @@ void menu_analog::populate(float &customtop, float &custombottom)
first_entry = false;
else
item_append(menu_item_type::SEPARATOR);
- item_append(string_format("[root%s]", prev_owner->tag()), "", 0, nullptr);
+ item_append(string_format("[root%s]", prev_owner->tag()), 0, nullptr);
}
}
diff --git a/src/frontend/mame/ui/auditmenu.cpp b/src/frontend/mame/ui/auditmenu.cpp
index 32d73b1fadd..0842443b63e 100644
--- a/src/frontend/mame/ui/auditmenu.cpp
+++ b/src/frontend/mame/ui/auditmenu.cpp
@@ -131,7 +131,7 @@ void menu_audit::custom_render(void *selectedref, float top, float bottom, float
driver ? driver->type.fullname() : "",
audited + 1,
m_total));
- ui().draw_text_box(container(), text.c_str(), ui::text_layout::CENTER, 0.5f, 0.5f, UI_GREEN_COLOR);
+ ui().draw_text_box(container(), text, ui::text_layout::CENTER, 0.5f, 0.5f, UI_GREEN_COLOR);
}
break;
}
@@ -139,7 +139,7 @@ void menu_audit::custom_render(void *selectedref, float top, float bottom, float
void menu_audit::populate(float &customtop, float &custombottom)
{
- item_append(_("Start Audit"), "", 0, ITEMREF_START);
+ item_append(_("Start Audit"), 0, ITEMREF_START);
customtop = (ui().get_line_height() * 2.0f) + (ui().box_tb_border() * 3.0f);
}
diff --git a/src/frontend/mame/ui/barcode.cpp b/src/frontend/mame/ui/barcode.cpp
index 2cda13f4a51..fad2af9ffc6 100644
--- a/src/frontend/mame/ui/barcode.cpp
+++ b/src/frontend/mame/ui/barcode.cpp
@@ -58,7 +58,7 @@ void menu_barcode_reader::populate(float &customtop, float &custombottom)
const char *new_barcode;
// selected device
- item_append(current_display_name(), "", current_display_flags(), ITEMREF_SELECT_READER);
+ item_append(current_display_name(), current_display_flags(), ITEMREF_SELECT_READER);
// append the "New Barcode" item
if (get_selection_ref() == ITEMREF_NEW_BARCODE)
@@ -75,7 +75,7 @@ void menu_barcode_reader::populate(float &customtop, float &custombottom)
// finish up the menu
item_append(menu_item_type::SEPARATOR);
- item_append(_("Enter Code"), "", 0, ITEMREF_ENTER_BARCODE);
+ item_append(_("Enter Code"), 0, ITEMREF_ENTER_BARCODE);
customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
}
diff --git a/src/frontend/mame/ui/cheatopt.cpp b/src/frontend/mame/ui/cheatopt.cpp
index e6fd1fe9dc0..1bfd8e4e0b3 100644
--- a/src/frontend/mame/ui/cheatopt.cpp
+++ b/src/frontend/mame/ui/cheatopt.cpp
@@ -137,10 +137,10 @@ void menu_cheat::populate(float &customtop, float &custombottom)
item_append(menu_item_type::SEPARATOR);
/* add a reset all option */
- item_append(_("Reset All"), "", 0, (void *)ITEMREF_CHEATS_RESET_ALL);
+ item_append(_("Reset All"), 0, (void *)ITEMREF_CHEATS_RESET_ALL);
/* add a reload all cheats option */
- item_append(_("Reload All"), "", 0, (void *)ITEMREF_CHEATS_RELOAD_ALL);
+ item_append(_("Reload All"), 0, (void *)ITEMREF_CHEATS_RELOAD_ALL);
}
}
diff --git a/src/frontend/mame/ui/confswitch.cpp b/src/frontend/mame/ui/confswitch.cpp
index ac45e91a9eb..4f0ec775260 100644
--- a/src/frontend/mame/ui/confswitch.cpp
+++ b/src/frontend/mame/ui/confswitch.cpp
@@ -110,7 +110,7 @@ void menu_confswitch::populate(float &customtop, float &custombottom)
first_entry = false;
else
item_append(menu_item_type::SEPARATOR);
- item_append(string_format("[root%s]", prev_owner->tag()), "", 0, nullptr);
+ item_append(string_format("[root%s]", prev_owner->tag()), 0, nullptr);
}
// set the left/right flags appropriately
@@ -159,7 +159,7 @@ void menu_confswitch::populate(float &customtop, float &custombottom)
}
item_append(menu_item_type::SEPARATOR);
- item_append(_("Reset"), "", 0, (void *)1);
+ item_append(_("Reset"), 0, (void *)1);
}
diff --git a/src/frontend/mame/ui/custui.cpp b/src/frontend/mame/ui/custui.cpp
index dfd206706b8..f8ad831aca2 100644
--- a/src/frontend/mame/ui/custui.cpp
+++ b/src/frontend/mame/ui/custui.cpp
@@ -166,8 +166,8 @@ void menu_custom_ui::handle()
void menu_custom_ui::populate(float &customtop, float &custombottom)
{
uint32_t arrow_flags;
- item_append(_("Fonts"), "", 0, (void *)(uintptr_t)FONT_MENU);
- item_append(_("Colors"), "", 0, (void *)(uintptr_t)COLORS_MENU);
+ item_append(_("Fonts"), 0, (void *)(uintptr_t)FONT_MENU);
+ item_append(_("Colors"), 0, (void *)(uintptr_t)COLORS_MENU);
if (!m_lang.empty())
{
@@ -484,25 +484,25 @@ void menu_colors_ui::handle()
void menu_colors_ui::populate(float &customtop, float &custombottom)
{
- item_append(_("Normal text"), "", 0, (void *)(uintptr_t)MUI_TEXT_COLOR);
- item_append(_("Selected color"), "", 0, (void *)(uintptr_t)MUI_SELECTED_COLOR);
- item_append(_("Normal text background"), "", 0, (void *)(uintptr_t)MUI_TEXT_BG_COLOR);
- item_append(_("Selected background color"), "", 0, (void *)(uintptr_t)MUI_SELECTED_BG_COLOR);
- item_append(_("Subitem color"), "", 0, (void *)(uintptr_t)MUI_SUBITEM_COLOR);
- item_append(_("Clone"), "", 0, (void *)(uintptr_t)MUI_CLONE_COLOR);
- item_append(_("Border"), "", 0, (void *)(uintptr_t)MUI_BORDER_COLOR);
- item_append(_("Background"), "", 0, (void *)(uintptr_t)MUI_BACKGROUND_COLOR);
- item_append(_("Dipswitch"), "", 0, (void *)(uintptr_t)MUI_DIPSW_COLOR);
- item_append(_("Unavailable color"), "", 0, (void *)(uintptr_t)MUI_UNAVAILABLE_COLOR);
- item_append(_("Slider color"), "", 0, (void *)(uintptr_t)MUI_SLIDER_COLOR);
- item_append(_("Gfx viewer background"), "", 0, (void *)(uintptr_t)MUI_GFXVIEWER_BG_COLOR);
- item_append(_("Mouse over color"), "", 0, (void *)(uintptr_t)MUI_MOUSEOVER_COLOR);
- item_append(_("Mouse over background color"), "", 0, (void *)(uintptr_t)MUI_MOUSEOVER_BG_COLOR);
- item_append(_("Mouse down color"), "", 0, (void *)(uintptr_t)MUI_MOUSEDOWN_COLOR);
- item_append(_("Mouse down background color"), "", 0, (void *)(uintptr_t)MUI_MOUSEDOWN_BG_COLOR);
+ item_append(_("Normal text"), 0, (void *)(uintptr_t)MUI_TEXT_COLOR);
+ item_append(_("Selected color"), 0, (void *)(uintptr_t)MUI_SELECTED_COLOR);
+ item_append(_("Normal text background"), 0, (void *)(uintptr_t)MUI_TEXT_BG_COLOR);
+ item_append(_("Selected background color"), 0, (void *)(uintptr_t)MUI_SELECTED_BG_COLOR);
+ item_append(_("Subitem color"), 0, (void *)(uintptr_t)MUI_SUBITEM_COLOR);
+ item_append(_("Clone"), 0, (void *)(uintptr_t)MUI_CLONE_COLOR);
+ item_append(_("Border"), 0, (void *)(uintptr_t)MUI_BORDER_COLOR);
+ item_append(_("Background"), 0, (void *)(uintptr_t)MUI_BACKGROUND_COLOR);
+ item_append(_("Dipswitch"), 0, (void *)(uintptr_t)MUI_DIPSW_COLOR);
+ item_append(_("Unavailable color"), 0, (void *)(uintptr_t)MUI_UNAVAILABLE_COLOR);
+ item_append(_("Slider color"), 0, (void *)(uintptr_t)MUI_SLIDER_COLOR);
+ item_append(_("Gfx viewer background"), 0, (void *)(uintptr_t)MUI_GFXVIEWER_BG_COLOR);
+ item_append(_("Mouse over color"), 0, (void *)(uintptr_t)MUI_MOUSEOVER_COLOR);
+ item_append(_("Mouse over background color"), 0, (void *)(uintptr_t)MUI_MOUSEOVER_BG_COLOR);
+ item_append(_("Mouse down color"), 0, (void *)(uintptr_t)MUI_MOUSEDOWN_COLOR);
+ item_append(_("Mouse down background color"), 0, (void *)(uintptr_t)MUI_MOUSEDOWN_BG_COLOR);
item_append(menu_item_type::SEPARATOR);
- item_append(_("Restore originals colors"), "", 0, (void *)(uintptr_t)MUI_RESTORE);
+ item_append(_("Restore originals colors"), 0, (void *)(uintptr_t)MUI_RESTORE);
custombottom = customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
}
@@ -549,7 +549,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f
for (auto & elem: sampletxt)
{
- ui().draw_text_full(container(), elem.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
+ ui().draw_text_full(container(), elem, 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width, nullptr);
width += 2 * lr_border;
maxwidth = std::max(maxwidth, width);
@@ -590,29 +590,29 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f
y1 += ui().box_tb_border();
// draw normal text
- ui().draw_text_full(container(), sampletxt[0].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
+ ui().draw_text_full(container(), sampletxt[0], x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, m_color_table[MUI_TEXT_COLOR].color, m_color_table[MUI_TEXT_BG_COLOR].color, nullptr, nullptr);
y1 += line_height;
// draw subitem text
- ui().draw_text_full(container(), sampletxt[1].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
+ ui().draw_text_full(container(), sampletxt[1], x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, m_color_table[MUI_SUBITEM_COLOR].color, m_color_table[MUI_TEXT_BG_COLOR].color, nullptr, nullptr);
y1 += line_height;
// draw selected text
highlight(x1, y1, x2, y1 + line_height, m_color_table[MUI_SELECTED_BG_COLOR].color);
- ui().draw_text_full(container(), sampletxt[2].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
+ ui().draw_text_full(container(), sampletxt[2], x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, m_color_table[MUI_SELECTED_COLOR].color, m_color_table[MUI_SELECTED_BG_COLOR].color, nullptr, nullptr);
y1 += line_height;
// draw mouse over text
highlight(x1, y1, x2, y1 + line_height, m_color_table[MUI_MOUSEOVER_BG_COLOR].color);
- ui().draw_text_full(container(), sampletxt[3].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
+ ui().draw_text_full(container(), sampletxt[3], x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, m_color_table[MUI_MOUSEOVER_COLOR].color, m_color_table[MUI_MOUSEOVER_BG_COLOR].color, nullptr, nullptr);
y1 += line_height;
// draw clone text
- ui().draw_text_full(container(), sampletxt[4].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
+ ui().draw_text_full(container(), sampletxt[4], x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, m_color_table[MUI_CLONE_COLOR].color, m_color_table[MUI_TEXT_BG_COLOR].color, nullptr, nullptr);
}
@@ -774,7 +774,7 @@ void menu_rgb_ui::populate(float &customtop, float &custombottom)
// set filter arrow
uint32_t arrow_flags = FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW;
std::string s_text = std::string(m_search).append("_");
- item_append(_("ARGB Settings"), "", FLAG_DISABLE | FLAG_UI_HEADING, nullptr);
+ item_append(_("ARGB Settings"), FLAG_DISABLE | FLAG_UI_HEADING, nullptr);
if (m_lock_ref != RGB_ALPHA)
{
@@ -809,7 +809,7 @@ void menu_rgb_ui::populate(float &customtop, float &custombottom)
item_append(_("Blue"), s_text, 0, (void *)(uintptr_t)RGB_BLUE);
item_append(menu_item_type::SEPARATOR);
- item_append(_("Choose from palette"), "", 0, (void *)(uintptr_t)PALETTE_CHOOSE);
+ item_append(_("Choose from palette"), 0, (void *)(uintptr_t)PALETTE_CHOOSE);
item_append(menu_item_type::SEPARATOR);
custombottom = customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
@@ -824,7 +824,7 @@ void menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, floa
float width, maxwidth = origx2 - origx1;
// top text
- ui().draw_text_full(container(), m_title.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
+ ui().draw_text_full(container(), m_title, 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width);
const float lr_border = ui().box_lr_border() * machine().render().ui_aspect(&container());
width += 2 * lr_border;
@@ -845,11 +845,11 @@ void menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, floa
y1 += ui().box_tb_border();
// draw the text within it
- ui().draw_text_full(container(), m_title.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
+ ui().draw_text_full(container(), m_title, x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color());
std::string sampletxt(_("Color preview ="));
- ui().draw_text_full(container(), sampletxt.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
+ ui().draw_text_full(container(), sampletxt, 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width);
width += 2 * lr_border;
maxwidth = std::max(origx2 - origx1, width);
@@ -868,7 +868,7 @@ void menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, floa
y1 += ui().box_tb_border();
// draw the normal text
- ui().draw_text_full(container(), sampletxt.c_str(), x1, y1, width - lr_border, ui::text_layout::CENTER, ui::text_layout::NEVER,
+ ui().draw_text_full(container(), sampletxt, x1, y1, width - lr_border, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, rgb_t::white(), rgb_t::black());
x1 += width + lr_border;
diff --git a/src/frontend/mame/ui/datmenu.cpp b/src/frontend/mame/ui/datmenu.cpp
index daf5afe1953..b772273d61a 100644
--- a/src/frontend/mame/ui/datmenu.cpp
+++ b/src/frontend/mame/ui/datmenu.cpp
@@ -196,7 +196,7 @@ void menu_dats_view::draw(uint32_t flags)
float const line_y = visible_top + float(linenum) * line_height;
int const itemnum = top_line + linenum;
menu_item const &pitem = item(itemnum);
- char const *const itemtext = pitem.text.c_str();
+ std::string_view const itemtext = pitem.text;
float const line_x0 = x1 + 0.5f * UI_LINE_WIDTH;
float const line_y0 = line_y;
float const line_x1 = x2 - 0.5f * UI_LINE_WIDTH;
@@ -250,7 +250,7 @@ void menu_dats_view::draw(uint32_t flags)
for (size_t count = visible_items; count < item_count(); count++)
{
menu_item const &pitem = item(count);
- char const *const itemtext = pitem.text.c_str();
+ std::string_view const itemtext = pitem.text;
float const line_x0 = x1 + 0.5f * UI_LINE_WIDTH;
float const line_y0 = line;
float const line_x1 = x2 - 0.5f * UI_LINE_WIDTH;
@@ -298,7 +298,7 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f
std::string driver = (m_issoft == true) ? m_swinfo->longname : m_driver->type.fullname();
float const lr_border = ui().box_lr_border() * machine().render().ui_aspect(&container());
- ui().draw_text_full(container(), driver.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
+ ui().draw_text_full(container(), driver, 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width, nullptr);
width += 2 * lr_border;
maxwidth = std::max(maxwidth, width);
@@ -317,13 +317,13 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f
x2 -= lr_border;
y1 += ui().box_tb_border();
- ui().draw_text_full(container(), driver.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
+ ui().draw_text_full(container(), driver, x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(), nullptr, nullptr);
maxwidth = 0;
for (auto & elem : m_items_list)
{
- ui().draw_text_full(container(), elem.label.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
+ ui().draw_text_full(container(), elem.label, 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width, nullptr);
maxwidth += width;
}
@@ -349,13 +349,13 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f
x1 += space;
rgb_t fcolor = (m_actual == x) ? rgb_t(0xff, 0xff, 0xff, 0x00) : ui().colors().text_color();
rgb_t bcolor = (m_actual == x) ? rgb_t(0xff, 0xff, 0xff, 0xff) : ui().colors().text_bg_color();
- ui().draw_text_full(container(), elem.label.c_str(), x1, y1, 1.0f, ui::text_layout::LEFT, ui::text_layout::NEVER, mame_ui_manager::NONE, fcolor, bcolor, &width, nullptr);
+ ui().draw_text_full(container(), elem.label, x1, y1, 1.0f, ui::text_layout::LEFT, ui::text_layout::NEVER, mame_ui_manager::NONE, fcolor, bcolor, &width, nullptr);
if (bcolor != ui().colors().text_bg_color())
ui().draw_textured_box(container(), x1 - (space / 2), y1, x1 + width + (space / 2), y2, bcolor, rgb_t(255, 43, 43, 43),
hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1));
- ui().draw_text_full(container(), elem.label.c_str(), x1, y1, 1.0f, ui::text_layout::LEFT, ui::text_layout::NEVER, mame_ui_manager::NORMAL, fcolor, bcolor, &width, nullptr);
+ ui().draw_text_full(container(), elem.label, x1, y1, 1.0f, ui::text_layout::LEFT, ui::text_layout::NEVER, mame_ui_manager::NORMAL, fcolor, bcolor, &width, nullptr);
x1 += width + space;
++x;
}
@@ -363,7 +363,7 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f
// bottom
std::string revision;
revision.assign(_("Revision: ")).append(m_items_list[m_actual].revision);
- ui().draw_text_full(container(), revision.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width, nullptr);
+ ui().draw_text_full(container(), revision, 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width, nullptr);
width += 2 * lr_border;
maxwidth = std::max(origx2 - origx1, width);
@@ -382,7 +382,7 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f
y1 += ui().box_tb_border();
// draw the text within it
- ui().draw_text_full(container(), revision.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
+ ui().draw_text_full(container(), revision, x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(), nullptr, nullptr);
}
@@ -402,12 +402,12 @@ void menu_dats_view::get_data()
float const visible_width = 1.0f - (2.0f * ui().box_lr_border() * aspect);
float const effective_width = visible_width - 2.0f * gutter_width;
- auto lines = ui().wrap_text(container(), buffer.c_str(), 0.0f, 0.0f, effective_width, xstart, xend);
+ auto lines = ui().wrap_text(container(), buffer, 0.0f, 0.0f, effective_width, xstart, xend);
for (int x = 0; x < lines; ++x)
{
std::string tempbuf(buffer.substr(xstart[x], xend[x] - xstart[x]));
if ((tempbuf[0] != '#') || x)
- item_append(tempbuf, "", (FLAG_UI_DATS | FLAG_DISABLE), (void *)(uintptr_t)(x + 1));
+ item_append(std::move(tempbuf), (FLAG_UI_DATS | FLAG_DISABLE), (void *)(uintptr_t)(x + 1));
}
}
@@ -421,11 +421,11 @@ void menu_dats_view::get_data_sw()
else
mame_machine_manager::instance()->lua()->call_plugin("data", m_items_list[m_actual].option - 1, buffer);
- auto lines = ui().wrap_text(container(), buffer.c_str(), 0.0f, 0.0f, 1.0f - (4.0f * ui().box_lr_border() * machine().render().ui_aspect(&container())), xstart, xend);
+ auto lines = ui().wrap_text(container(), buffer, 0.0f, 0.0f, 1.0f - (4.0f * ui().box_lr_border() * machine().render().ui_aspect(&container())), xstart, xend);
for (int x = 0; x < lines; ++x)
{
std::string tempbuf(buffer.substr(xstart[x], xend[x] - xstart[x]));
- item_append(tempbuf, "", (FLAG_UI_DATS | FLAG_DISABLE), (void *)(uintptr_t)(x + 1));
+ item_append(std::move(tempbuf), (FLAG_UI_DATS | FLAG_DISABLE), (void *)(uintptr_t)(x + 1));
}
}
diff --git a/src/frontend/mame/ui/devopt.cpp b/src/frontend/mame/ui/devopt.cpp
index 0172a65b3de..e423bfd4370 100644
--- a/src/frontend/mame/ui/devopt.cpp
+++ b/src/frontend/mame/ui/devopt.cpp
@@ -293,7 +293,7 @@ void menu_device_config::populate(float &customtop, float &custombottom)
str << _("[None]\n");
mconfig.device_remove(m_option->name());
- item_append(str.str(), "", FLAG_MULTILINE, nullptr);
+ item_append(str.str(), FLAG_MULTILINE, nullptr);
}
void menu_device_config::handle()
diff --git a/src/frontend/mame/ui/dirmenu.cpp b/src/frontend/mame/ui/dirmenu.cpp
index 50afe928561..bda3c74cf62 100644
--- a/src/frontend/mame/ui/dirmenu.cpp
+++ b/src/frontend/mame/ui/dirmenu.cpp
@@ -101,7 +101,7 @@ void menu_directory::handle()
void menu_directory::populate(float &customtop, float &custombottom)
{
for (auto & elem : s_folders)
- item_append(_(elem.name), "", 0, (void *)(uintptr_t)elem.action);
+ item_append(_(elem.name), 0, (void *)(uintptr_t)elem.action);
item_append(menu_item_type::SEPARATOR);
customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
@@ -176,10 +176,10 @@ void menu_display_actual::populate(float &customtop, float &custombottom)
while (path.next(curpath, nullptr))
m_folders.push_back(curpath);
- item_append((s_folders[m_ref].action == CHANGE) ? _("Change Folder") : _("Add Folder"), "", 0, (void *)ADD_CHANGE);
+ item_append((s_folders[m_ref].action == CHANGE) ? _("Change Folder") : _("Add Folder"), 0, (void *)ADD_CHANGE);
if (m_folders.size() > 1)
- item_append(_("Remove Folder"), "", 0, (void *)REMOVE);
+ item_append(_("Remove Folder"), 0, (void *)REMOVE);
item_append(menu_item_type::SEPARATOR);
customtop = (m_folders.size() + 1) * ui().get_line_height() + 6.0f * ui().box_tb_border();
@@ -253,7 +253,7 @@ void menu_add_change_folder::handle()
const menu_item &pitem = item(index);
// go up to the parent path
- if (!strcmp(pitem.text.c_str(), ".."))
+ if (pitem.text == "..")
{
size_t first_sep = m_current_path.find_first_of(PATH_SEPARATOR[0]);
size_t last_sep = m_current_path.find_last_of(PATH_SEPARATOR[0]);
@@ -263,7 +263,7 @@ void menu_add_change_folder::handle()
else
{
// if isn't a drive, appends the directory
- if (strcmp(pitem.subtext.c_str(), "[DRIVE]") != 0)
+ if (pitem.subtext != "[DRIVE]")
{
if (m_current_path[m_current_path.length() - 1] == PATH_SEPARATOR[0])
m_current_path.append(pitem.text);
@@ -290,7 +290,7 @@ void menu_add_change_folder::handle()
{
if (ui().options().exists(s_folders[m_ref].option))
ui().options().set_value(s_folders[m_ref].option, m_current_path, OPTION_PRIORITY_CMDLINE);
- else if (strcmp(machine().options().value(s_folders[m_ref].option), m_current_path.c_str()) != 0)
+ else if (machine().options().value(s_folders[m_ref].option) != m_current_path)
{
machine().options().set_value(s_folders[m_ref].option, m_current_path, OPTION_PRIORITY_CMDLINE);
}
@@ -308,7 +308,7 @@ void menu_add_change_folder::handle()
if (ui().options().exists(s_folders[m_ref].option))
ui().options().set_value(s_folders[m_ref].option, tmppath, OPTION_PRIORITY_CMDLINE);
- else if (strcmp(machine().options().value(s_folders[m_ref].option), tmppath.c_str()) != 0)
+ else if (machine().options().value(s_folders[m_ref].option) != tmppath)
{
machine().options().set_value(s_folders[m_ref].option, tmppath, OPTION_PRIORITY_CMDLINE);
}
@@ -480,7 +480,7 @@ void menu_remove_folder::handle()
if (ui().options().exists(s_folders[m_ref].option))
ui().options().set_value(s_folders[m_ref].option, tmppath, OPTION_PRIORITY_CMDLINE);
- else if (strcmp(machine().options().value(s_folders[m_ref].option),tmppath.c_str())!=0)
+ else if (machine().options().value(s_folders[m_ref].option) != tmppath)
{
machine().options().set_value(s_folders[m_ref].option, tmppath, OPTION_PRIORITY_CMDLINE);
}
@@ -498,7 +498,7 @@ void menu_remove_folder::populate(float &customtop, float &custombottom)
{
int folders_count = 0;
for (auto & elem : m_folders)
- item_append(elem, "", 0, (void *)(uintptr_t)++folders_count);
+ item_append(elem, 0, (void *)(uintptr_t)++folders_count);
item_append(menu_item_type::SEPARATOR);
customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
diff --git a/src/frontend/mame/ui/filecreate.cpp b/src/frontend/mame/ui/filecreate.cpp
index 157b19bec9a..181c4a985ab 100644
--- a/src/frontend/mame/ui/filecreate.cpp
+++ b/src/frontend/mame/ui/filecreate.cpp
@@ -76,10 +76,10 @@ menu_confirm_save_as::~menu_confirm_save_as()
void menu_confirm_save_as::populate(float &customtop, float &custombottom)
{
- item_append(_("File Already Exists - Override?"), "", FLAG_DISABLE, nullptr);
+ item_append(_("File Already Exists - Override?"), FLAG_DISABLE, nullptr);
item_append(menu_item_type::SEPARATOR);
- item_append(_("No"), "", 0, ITEMREF_NO);
- item_append(_("Yes"), "", 0, ITEMREF_YES);
+ item_append(_("No"), 0, ITEMREF_NO);
+ item_append(_("Yes"), 0, ITEMREF_YES);
}
//-------------------------------------------------
@@ -143,8 +143,8 @@ menu_file_create::~menu_file_create()
void menu_file_create::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
extra_text_render(top, bottom, origx1, origy1, origx2, origy2,
- m_current_directory.c_str(),
- nullptr);
+ m_current_directory,
+ std::string_view());
}
@@ -180,7 +180,7 @@ void menu_file_create::populate(float &customtop, float &custombottom)
// finish up the menu
item_append(menu_item_type::SEPARATOR);
- item_append(_("Create"), "", 0, ITEMREF_CREATE);
+ item_append(_("Create"), 0, ITEMREF_CREATE);
customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
}
@@ -263,7 +263,7 @@ menu_select_format::~menu_select_format()
void menu_select_format::populate(float &customtop, float &custombottom)
{
- item_append(_("Select image format"), "", FLAG_DISABLE, nullptr);
+ item_append(_("Select image format"), FLAG_DISABLE, nullptr);
for (int i = 0; i < m_total_usable; i++)
{
const floppy_image_format_t *fmt = m_formats[i];
diff --git a/src/frontend/mame/ui/filemngr.cpp b/src/frontend/mame/ui/filemngr.cpp
index 6c5423746f8..2face5b6dd1 100644
--- a/src/frontend/mame/ui/filemngr.cpp
+++ b/src/frontend/mame/ui/filemngr.cpp
@@ -59,11 +59,9 @@ menu_file_manager::~menu_file_manager()
void menu_file_manager::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
- const char *path;
-
// access the path
- path = selected_device ? selected_device->filename() : nullptr;
- extra_text_render(top, bottom, origx1, origy1, origx2, origy2, nullptr, path);
+ std::string_view path = selected_device ? selected_device->filename() : std::string_view();
+ extra_text_render(top, bottom, origx1, origy1, origx2, origy2, std::string_view(), path);
}
@@ -110,8 +108,8 @@ void menu_file_manager::populate(float &customtop, float &custombottom)
if (!m_warnings.empty())
{
- item_append(m_warnings, "", FLAG_DISABLE, nullptr);
- item_append("", "", FLAG_DISABLE, nullptr);
+ item_append(m_warnings, FLAG_DISABLE, nullptr);
+ item_append(std::string(), FLAG_DISABLE, nullptr);
}
// cycle through all devices for this system
@@ -143,7 +141,7 @@ void menu_file_manager::populate(float &customtop, float &custombottom)
first_entry = false;
else
item_append(menu_item_type::SEPARATOR);
- item_append(string_format("[root%s]", dev.tag()), "", 0, nullptr);
+ item_append(string_format("[root%s]", dev.tag()), 0, nullptr);
tag_appended = true;
}
// finally, append the image interface to the menu
@@ -156,7 +154,7 @@ void menu_file_manager::populate(float &customtop, float &custombottom)
item_append(menu_item_type::SEPARATOR);
if (m_warnings.empty() || m_curr_selected)
- item_append("Reset", "", 0, (void *)1);
+ item_append("Reset", 0, (void *)1);
custombottom = ui().get_line_height() + 3.0f * ui().box_tb_border();
}
diff --git a/src/frontend/mame/ui/filesel.cpp b/src/frontend/mame/ui/filesel.cpp
index 2461cd9d231..376202cb1c8 100644
--- a/src/frontend/mame/ui/filesel.cpp
+++ b/src/frontend/mame/ui/filesel.cpp
@@ -76,7 +76,7 @@ void menu_file_selector::custom_render(void *selectedref, float top, float botto
{
// lay out extra text
auto layout = ui().create_layout(container());
- layout.add_text(m_current_directory.c_str());
+ layout.add_text(m_current_directory);
// position this extra text
float x1, y1, x2, y2;
@@ -533,12 +533,12 @@ menu_select_rw::~menu_select_rw()
void menu_select_rw::populate(float &customtop, float &custombottom)
{
- item_append(_("Select access mode"), "", FLAG_DISABLE, nullptr);
- item_append(_("Read-only"), "", 0, itemref_from_result(result::READONLY));
+ item_append(_("Select access mode"), FLAG_DISABLE, nullptr);
+ item_append(_("Read-only"), 0, itemref_from_result(result::READONLY));
if (m_can_in_place)
- item_append(_("Read-write"), "", 0, itemref_from_result(result::READWRITE));
- item_append(_("Read this image, write to another image"), "", 0, itemref_from_result(result::WRITE_OTHER));
- item_append(_("Read this image, write to diff"), "", 0, itemref_from_result(result::WRITE_DIFF));
+ item_append(_("Read-write"), 0, itemref_from_result(result::READWRITE));
+ item_append(_("Read this image, write to another image"), 0, itemref_from_result(result::WRITE_OTHER));
+ item_append(_("Read this image, write to diff"), 0, itemref_from_result(result::WRITE_DIFF));
}
diff --git a/src/frontend/mame/ui/info.cpp b/src/frontend/mame/ui/info.cpp
index 9bac109258a..7d11970966f 100644
--- a/src/frontend/mame/ui/info.cpp
+++ b/src/frontend/mame/ui/info.cpp
@@ -490,8 +490,7 @@ menu_game_info::~menu_game_info()
void menu_game_info::populate(float &customtop, float &custombottom)
{
- std::string tempstring = ui().machine_info().game_info_string();
- item_append(std::move(tempstring), "", FLAG_MULTILINE, nullptr);
+ item_append(ui().machine_info().game_info_string(), FLAG_MULTILINE, nullptr);
}
void menu_game_info::handle()
@@ -515,8 +514,7 @@ menu_warn_info::~menu_warn_info()
void menu_warn_info::populate(float &customtop, float &custombottom)
{
- std::string tempstring = ui().machine_info().warnings_string();
- item_append(std::move(tempstring), "", FLAG_MULTILINE, nullptr);
+ item_append(ui().machine_info().warnings_string(), FLAG_MULTILINE, nullptr);
}
void menu_warn_info::handle()
@@ -540,8 +538,8 @@ menu_image_info::~menu_image_info()
void menu_image_info::populate(float &customtop, float &custombottom)
{
- item_append(machine().system().type.fullname(), "", FLAG_DISABLE, nullptr);
- item_append("", "", FLAG_DISABLE, nullptr);
+ item_append(machine().system().type.fullname(), FLAG_DISABLE, nullptr);
+ item_append(std::string(), FLAG_DISABLE, nullptr);
for (device_image_interface &image : image_interface_enumerator(machine().root_device()))
image_info(&image);
@@ -570,19 +568,19 @@ void menu_image_info::image_info(device_image_interface *image)
if (image->loaded_through_softlist())
{
// display long filename
- item_append(image->longname(), "", FLAG_DISABLE, nullptr);
+ item_append(image->longname(), FLAG_DISABLE, nullptr);
// display manufacturer and year
- item_append(string_format("%s, %s", image->manufacturer(), image->year()), "", FLAG_DISABLE, nullptr);
+ item_append(string_format("%s, %s", image->manufacturer(), image->year()), FLAG_DISABLE, nullptr);
// display supported information, if available
switch (image->supported())
{
case SOFTWARE_SUPPORTED_NO:
- item_append(_("Not supported"), "", FLAG_DISABLE, nullptr);
+ item_append(_("Not supported"), FLAG_DISABLE, nullptr);
break;
case SOFTWARE_SUPPORTED_PARTIAL:
- item_append(_("Partially supported"), "", FLAG_DISABLE, nullptr);
+ item_append(_("Partially supported"), FLAG_DISABLE, nullptr);
break;
default:
break;
@@ -591,7 +589,7 @@ void menu_image_info::image_info(device_image_interface *image)
}
else
item_append(image->brief_instance_name(), _("[empty]"), 0, nullptr);
- item_append("", "", FLAG_DISABLE, nullptr);
+ item_append(std::string(), FLAG_DISABLE, nullptr);
}
} // namespace ui
diff --git a/src/frontend/mame/ui/info_pty.cpp b/src/frontend/mame/ui/info_pty.cpp
index 49d0737cbad..12c2733af1a 100644
--- a/src/frontend/mame/ui/info_pty.cpp
+++ b/src/frontend/mame/ui/info_pty.cpp
@@ -27,8 +27,8 @@ menu_pty_info::~menu_pty_info()
void menu_pty_info::populate(float &customtop, float &custombottom)
{
- item_append(_("Pseudo terminals"), "", FLAG_DISABLE, nullptr);
- item_append("", "", FLAG_DISABLE, nullptr);
+ item_append(_("Pseudo terminals"), FLAG_DISABLE, nullptr);
+ item_append(std::string(), FLAG_DISABLE, nullptr);
for (device_pty_interface &pty : pty_interface_enumerator(machine().root_device()))
{
@@ -37,7 +37,7 @@ void menu_pty_info::populate(float &customtop, float &custombottom)
item_append(port_name, pty.slave_name(), FLAG_DISABLE, nullptr);
else
item_append(port_name, _("[failed]"), FLAG_DISABLE, nullptr);
- item_append("", "", FLAG_DISABLE, nullptr);
+ item_append(std::string(), FLAG_DISABLE, nullptr);
}
}
diff --git a/src/frontend/mame/ui/inputmap.cpp b/src/frontend/mame/ui/inputmap.cpp
index c0a36642e5d..0d49fc1ad29 100644
--- a/src/frontend/mame/ui/inputmap.cpp
+++ b/src/frontend/mame/ui/inputmap.cpp
@@ -35,13 +35,13 @@ menu_input_groups::~menu_input_groups()
void menu_input_groups::populate(float &customtop, float &custombottom)
{
// build up the menu
- item_append(_("User Interface"), "", 0, (void *)uintptr_t(IPG_UI + 1));
+ item_append(_("User Interface"), 0, (void *)uintptr_t(IPG_UI + 1));
for (int player = 0; player < MAX_PLAYERS; player++)
{
auto s = string_format("Player %d Controls", player + 1);
- item_append(s, "", 0, (void *)uintptr_t(IPG_PLAYER1 + player + 1));
+ item_append(s, 0, (void *)uintptr_t(IPG_PLAYER1 + player + 1));
}
- item_append(_("Other Controls"), "", 0, (void *)uintptr_t(IPG_OTHER + 1));
+ item_append(_("Other Controls"), 0, (void *)uintptr_t(IPG_OTHER + 1));
}
void menu_input_groups::handle()
@@ -445,9 +445,9 @@ void menu_input::populate_sorted(float &customtop, float &custombottom)
else
item_append(menu_item_type::SEPARATOR);
if (item.owner->owner())
- item_append(string_format(_("%1$s [root%2$s]"), item.owner->type().fullname(), item.owner->tag()), "", 0, nullptr);
+ item_append(string_format(_("%1$s [root%2$s]"), item.owner->type().fullname(), item.owner->tag()), 0, nullptr);
else
- item_append(string_format(_("[root%1$s]"), item.owner->tag()), "", 0, nullptr);
+ item_append(string_format(_("[root%1$s]"), item.owner->tag()), 0, nullptr);
prev_owner = item.owner;
}
diff --git a/src/frontend/mame/ui/mainmenu.cpp b/src/frontend/mame/ui/mainmenu.cpp
index 5c129f76397..23a68c979c5 100644
--- a/src/frontend/mame/ui/mainmenu.cpp
+++ b/src/frontend/mame/ui/mainmenu.cpp
@@ -61,89 +61,89 @@ menu_main::menu_main(mame_ui_manager &mui, render_container &container) : menu(m
void menu_main::populate(float &customtop, float &custombottom)
{
/* add main menu items */
- item_append(_("Input (general)"), "", 0, (void *)INPUT_GROUPS);
+ item_append(_("Input (general)"), 0, (void *)INPUT_GROUPS);
- item_append(_("Input (this Machine)"), "", 0, (void *)INPUT_SPECIFIC);
+ item_append(_("Input (this Machine)"), 0, (void *)INPUT_SPECIFIC);
if (ui().machine_info().has_analog())
- item_append(_("Analog Controls"), "", 0, (void *)ANALOG);
+ item_append(_("Analog Controls"), 0, (void *)ANALOG);
if (ui().machine_info().has_dips())
- item_append(_("DIP Switches"), "", 0, (void *)SETTINGS_DIP_SWITCHES);
+ item_append(_("DIP Switches"), 0, (void *)SETTINGS_DIP_SWITCHES);
if (ui().machine_info().has_configs())
- item_append(_("Machine Configuration"), "", 0, (void *)SETTINGS_DRIVER_CONFIG);
+ item_append(_("Machine Configuration"), 0, (void *)SETTINGS_DRIVER_CONFIG);
- item_append(_("Bookkeeping Info"), "", 0, (void *)BOOKKEEPING);
+ item_append(_("Bookkeeping Info"), 0, (void *)BOOKKEEPING);
- item_append(_("Machine Information"), "", 0, (void *)GAME_INFO);
+ item_append(_("Machine Information"), 0, (void *)GAME_INFO);
if (ui().found_machine_warnings())
- item_append(_("Warning Information"), "", 0, (void *)WARN_INFO);
+ item_append(_("Warning Information"), 0, (void *)WARN_INFO);
for (device_image_interface &image : image_interface_enumerator(machine().root_device()))
{
if (image.user_loadable())
{
- item_append(_("Image Information"), "", 0, (void *)IMAGE_MENU_IMAGE_INFO);
+ item_append(_("Image Information"), 0, (void *)IMAGE_MENU_IMAGE_INFO);
- item_append(_("File Manager"), "", 0, (void *)IMAGE_MENU_FILE_MANAGER);
+ item_append(_("File Manager"), 0, (void *)IMAGE_MENU_FILE_MANAGER);
break;
}
}
if (cassette_device_enumerator(machine().root_device()).first() != nullptr)
- item_append(_("Tape Control"), "", 0, (void *)TAPE_CONTROL);
+ item_append(_("Tape Control"), 0, (void *)TAPE_CONTROL);
if (pty_interface_enumerator(machine().root_device()).first() != nullptr)
- item_append(_("Pseudo terminals"), "", 0, (void *)PTY_INFO);
+ item_append(_("Pseudo terminals"), 0, (void *)PTY_INFO);
if (ui().machine_info().has_bioses())
- item_append(_("BIOS Selection"), "", 0, (void *)BIOS_SELECTION);
+ item_append(_("BIOS Selection"), 0, (void *)BIOS_SELECTION);
if (slot_interface_enumerator(machine().root_device()).first() != nullptr)
- item_append(_("Slot Devices"), "", 0, (void *)SLOT_DEVICES);
+ item_append(_("Slot Devices"), 0, (void *)SLOT_DEVICES);
if (barcode_reader_device_enumerator(machine().root_device()).first() != nullptr)
- item_append(_("Barcode Reader"), "", 0, (void *)BARCODE_READ);
+ item_append(_("Barcode Reader"), 0, (void *)BARCODE_READ);
if (network_interface_enumerator(machine().root_device()).first() != nullptr)
- item_append(_("Network Devices"), "", 0, (void*)NETWORK_DEVICES);
+ item_append(_("Network Devices"), 0, (void*)NETWORK_DEVICES);
if (machine().ioport().natkeyboard().keyboard_count())
- item_append(_("Keyboard Mode"), "", 0, (void *)KEYBOARD_MODE);
+ item_append(_("Keyboard Mode"), 0, (void *)KEYBOARD_MODE);
- item_append(_("Slider Controls"), "", 0, (void *)SLIDERS);
+ item_append(_("Slider Controls"), 0, (void *)SLIDERS);
- item_append(_("Video Options"), "", 0, (machine().render().target_by_index(1) != nullptr) ? (void *)VIDEO_TARGETS : (void *)VIDEO_OPTIONS);
+ item_append(_("Video Options"), 0, (machine().render().target_by_index(1) != nullptr) ? (void *)VIDEO_TARGETS : (void *)VIDEO_OPTIONS);
if (machine().crosshair().get_usage())
- item_append(_("Crosshair Options"), "", 0, (void *)CROSSHAIR);
+ item_append(_("Crosshair Options"), 0, (void *)CROSSHAIR);
if (machine().options().cheat())
- item_append(_("Cheat"), "", 0, (void *)CHEAT);
+ item_append(_("Cheat"), 0, (void *)CHEAT);
if (machine().options().plugins())
- item_append(_("Plugin Options"), "", 0, (void *)PLUGINS);
+ item_append(_("Plugin Options"), 0, (void *)PLUGINS);
if (mame_machine_manager::instance()->lua()->call_plugin_check<const char *>("data_list", "", true))
- item_append(_("External DAT View"), "", 0, (void *)EXTERNAL_DATS);
+ item_append(_("External DAT View"), 0, (void *)EXTERNAL_DATS);
item_append(menu_item_type::SEPARATOR);
if (!mame_machine_manager::instance()->favorite().is_favorite(machine()))
- item_append(_("Add To Favorites"), "", 0, (void *)ADD_FAVORITE);
+ item_append(_("Add To Favorites"), 0, (void *)ADD_FAVORITE);
else
- item_append(_("Remove From Favorites"), "", 0, (void *)REMOVE_FAVORITE);
+ item_append(_("Remove From Favorites"), 0, (void *)REMOVE_FAVORITE);
item_append(menu_item_type::SEPARATOR);
- item_append(string_format(_("About %s"), emulator_info::get_appname()), "", 0, (void *)ABOUT);
+ item_append(string_format(_("About %s"), emulator_info::get_appname()), 0, (void *)ABOUT);
item_append(menu_item_type::SEPARATOR);
-// item_append(_("Quit from Machine"), nullptr, 0, (void *)QUIT_GAME);
+// item_append(_("Quit from Machine"), 0, (void *)QUIT_GAME);
- item_append(_("Select New Machine"), "", 0, (void *)SELECT_GAME);
+ item_append(_("Select New Machine"), 0, (void *)SELECT_GAME);
}
menu_main::~menu_main()
diff --git a/src/frontend/mame/ui/menu.cpp b/src/frontend/mame/ui/menu.cpp
index b0a84d3a95c..c52b61449e7 100644
--- a/src/frontend/mame/ui/menu.cpp
+++ b/src/frontend/mame/ui/menu.cpp
@@ -293,21 +293,21 @@ void menu::reset(reset_options options)
// add an item to return
if (!m_parent)
{
- item_append(_("Return to Machine"), "", 0, nullptr);
+ item_append(_("Return to Machine"), 0, nullptr);
}
else if (m_parent->is_special_main_menu())
{
if (machine().options().ui() == emu_options::UI_SIMPLE)
- item_append(_("Exit"), "", 0, nullptr);
+ item_append(_("Exit"), 0, nullptr);
else
- item_append(_("Exit"), "", FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, nullptr);
+ item_append(_("Exit"), FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, nullptr);
}
else
{
if (machine().options().ui() != emu_options::UI_SIMPLE && stack_has_special_main_menu())
- item_append(_("Return to Previous Menu"), "", FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, nullptr);
+ item_append(_("Return to Previous Menu"), FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, nullptr);
else
- item_append(_("Return to Previous Menu"), "", 0, nullptr);
+ item_append(_("Return to Previous Menu"), 0, nullptr);
}
}
@@ -339,30 +339,10 @@ void menu::set_special_main_menu(bool special)
// end of the menu
//-------------------------------------------------
-void menu::item_append(menu_item item)
-{
- item_append(item.text, item.subtext, item.flags, item.ref, item.type);
-}
-
-//-------------------------------------------------
-// item_append - append a new item to the
-// end of the menu
-//-------------------------------------------------
-
void menu::item_append(menu_item_type type, uint32_t flags)
{
if (type == menu_item_type::SEPARATOR)
- item_append(MENU_SEPARATOR_ITEM, "", flags, nullptr, menu_item_type::SEPARATOR);
-}
-
-//-------------------------------------------------
-// item_append - append a new item to the
-// end of the menu
-//-------------------------------------------------
-
-void menu::item_append(const std::string &text, const std::string &subtext, uint32_t flags, void *ref, menu_item_type type)
-{
- item_append(std::string(text), std::string(subtext), flags, ref, type);
+ item_append(MENU_SEPARATOR_ITEM, flags, nullptr, menu_item_type::SEPARATOR);
}
//-------------------------------------------------
@@ -510,7 +490,7 @@ void menu::draw(uint32_t flags)
// first draw the FPS counter
if (ui().show_fps_counter())
{
- ui().draw_text_full(container(), machine().video().speed_text().c_str(), 0.0f, 0.0f, 1.0f,
+ ui().draw_text_full(container(), machine().video().speed_text(), 0.0f, 0.0f, 1.0f,
ui::text_layout::RIGHT, ui::text_layout::WORD, mame_ui_manager::OPAQUE_, rgb_t::white(), rgb_t::black(), nullptr, nullptr);
}
@@ -533,11 +513,11 @@ void menu::draw(uint32_t flags)
for (auto const &pitem : m_items)
{
// compute width of left hand side
- float total_width = gutter_width + ui().get_string_width(pitem.text.c_str()) + gutter_width;
+ float total_width = gutter_width + ui().get_string_width(pitem.text) + gutter_width;
// add in width of right hand side
if (!pitem.subtext.empty())
- total_width += 2.0f * gutter_width + ui().get_string_width(pitem.subtext.c_str());
+ total_width += 2.0f * gutter_width + ui().get_string_width(pitem.subtext);
// track the maximum
if (total_width > visible_width)
@@ -612,7 +592,7 @@ void menu::draw(uint32_t flags)
{
auto const itemnum = top_line + linenum;
menu_item const &pitem = m_items[itemnum];
- char const *const itemtext = pitem.text.c_str();
+ std::string_view const itemtext = pitem.text;
rgb_t fgcolor = ui().colors().text_color();
rgb_t bgcolor = ui().colors().text_bg_color();
rgb_t fgcolor2 = ui().colors().subitem_color();
@@ -689,7 +669,6 @@ void menu::draw(uint32_t flags)
{
// otherwise, draw the item on the left and the subitem text on the right
bool const subitem_invert(pitem.flags & FLAG_INVERT);
- char const *subitem_text(pitem.subtext.c_str());
float item_width, subitem_width;
// draw the left-side text
@@ -698,7 +677,7 @@ void menu::draw(uint32_t flags)
if (pitem.flags & FLAG_COLOR_BOX)
{
- rgb_t color = rgb_t((uint32_t)strtoul(subitem_text, nullptr, 16));
+ rgb_t color = rgb_t((uint32_t)strtoul(pitem.subtext.c_str(), nullptr, 16));
// give 2 spaces worth of padding
subitem_width = ui().get_string_width("FF00FF00");
@@ -708,6 +687,8 @@ void menu::draw(uint32_t flags)
}
else
{
+ std::string_view subitem_text(pitem.subtext);
+
// give 2 spaces worth of padding
item_width += 2.0f * gutter_width;
@@ -720,13 +701,13 @@ void menu::draw(uint32_t flags)
}
// customize subitem text color
- if (!core_stricmp(subitem_text, _("On")))
+ if (!core_strnicmp(&subitem_text[0], _("On"), subitem_text.length()))
fgcolor2 = rgb_t(0x00,0xff,0x00);
- if (!core_stricmp(subitem_text, _("Off")))
+ if (!core_strnicmp(&subitem_text[0], _("Off"), subitem_text.length()))
fgcolor2 = rgb_t(0xff,0x00,0x00);
- if (!core_stricmp(subitem_text, _("Auto")))
+ if (!core_strnicmp(&subitem_text[0], _("Auto"), subitem_text.length()))
fgcolor2 = rgb_t(0xff,0xff,0x00);
// draw the subitem right-justified
@@ -769,7 +750,7 @@ void menu::draw(uint32_t flags)
float target_width, target_height;
// compute the multi-line target width/height
- ui().draw_text_full(container(), pitem.subtext.c_str(), 0, 0, visible_width * 0.75f,
+ ui().draw_text_full(container(), pitem.subtext, 0, 0, visible_width * 0.75f,
ui::text_layout::RIGHT, ui::text_layout::WORD, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &target_width, &target_height);
// determine the target location
@@ -785,7 +766,7 @@ void menu::draw(uint32_t flags)
target_y + target_height + ui().box_tb_border(),
subitem_invert ? ui().colors().selected_bg_color() : ui().colors().background_color());
- ui().draw_text_full(container(), pitem.subtext.c_str(), target_x, target_y, target_width,
+ ui().draw_text_full(container(), pitem.subtext, target_x, target_y, target_width,
ui::text_layout::RIGHT, ui::text_layout::WORD, mame_ui_manager::NORMAL, ui().colors().selected_color(), ui().colors().selected_bg_color(), nullptr, nullptr);
}
@@ -805,8 +786,8 @@ void menu::custom_render(void *selectedref, float top, float bottom, float x, fl
void menu::draw_text_box()
{
- const char *text = m_items[0].text.c_str();
- const char *backtext = m_items[1].text.c_str();
+ std::string_view const text = m_items[0].text;
+ std::string_view const backtext = m_items[1].text;
float const aspect = machine().render().ui_aspect(&container());
float line_height = ui().get_line_height();
float lr_arrow_width = 0.4f * line_height * aspect;
@@ -1286,7 +1267,7 @@ void menu::draw_arrow(float x0, float y0, float x1, float y1, rgb_t fgcolor, uin
// or footer text
//-------------------------------------------------
-void menu::extra_text_draw_box(float origx1, float origx2, float origy, float yspan, const char *text, int direction)
+void menu::extra_text_draw_box(float origx1, float origx2, float origy, float yspan, std::string_view text, int direction)
{
// get the size of the text
auto layout = ui().create_layout(container());
@@ -1343,14 +1324,11 @@ void menu::extra_text_position(float origx1, float origx2, float origy, float ys
// and footer text
//-------------------------------------------------
-void menu::extra_text_render(float top, float bottom, float origx1, float origy1, float origx2, float origy2, const char *header, const char *footer)
+void menu::extra_text_render(float top, float bottom, float origx1, float origy1, float origx2, float origy2, std::string_view header, std::string_view footer)
{
- header = (header && *header) ? header : nullptr;
- footer = (footer && *footer) ? footer : nullptr;
-
- if (header != nullptr)
+ if (!header.empty())
extra_text_draw_box(origx1, origx2, origy1, top, header, -1);
- if (footer != nullptr)
+ if (!footer.empty())
extra_text_draw_box(origx1, origx2, origy2, bottom, footer, +1);
}
diff --git a/src/frontend/mame/ui/menu.h b/src/frontend/mame/ui/menu.h
index 5a7d4374bf6..eacbae32609 100644
--- a/src/frontend/mame/ui/menu.h
+++ b/src/frontend/mame/ui/menu.h
@@ -23,6 +23,7 @@
#include <map>
#include <memory>
#include <mutex>
+#include <string_view>
#include <vector>
@@ -84,9 +85,11 @@ public:
virtual ~menu();
// append a new item to the end of the menu
- void item_append(const std::string &text, const std::string &subtext, uint32_t flags, void *ref, menu_item_type type = menu_item_type::UNKNOWN);
+ void item_append(const std::string &text, uint32_t flags, void *ref, menu_item_type type = menu_item_type::UNKNOWN) { item_append(std::string(text), std::string(), flags, ref, type); }
+ void item_append(const std::string &text, const std::string &subtext, uint32_t flags, void *ref, menu_item_type type = menu_item_type::UNKNOWN) { item_append(std::string(text), std::string(subtext), flags, ref, type); }
+ void item_append(std::string &&text, uint32_t flags, void *ref, menu_item_type type = menu_item_type::UNKNOWN) { item_append(text, std::string(), flags, ref, type); }
void item_append(std::string &&text, std::string &&subtext, uint32_t flags, void *ref, menu_item_type type = menu_item_type::UNKNOWN);
- void item_append(menu_item item);
+ void item_append(menu_item item) { item_append(item.text, item.subtext, item.flags, item.ref, item.type); }
void item_append(menu_item_type type, uint32_t flags = 0);
void item_append_on_off(const std::string &text, bool state, uint32_t flags, void *ref, menu_item_type type = menu_item_type::UNKNOWN);
@@ -229,7 +232,7 @@ protected:
void draw_arrow(float x0, float y0, float x1, float y1, rgb_t fgcolor, uint32_t orientation);
// draw header and footer text
- void extra_text_render(float top, float bottom, float origx1, float origy1, float origx2, float origy2, const char *header, const char *footer);
+ void extra_text_render(float top, float bottom, float origx1, float origy1, float origx2, float origy2, std::string_view header, std::string_view footer);
void extra_text_position(float origx1, float origx2, float origy, float yspan, text_layout &layout,
int direction, float &x1, float &y1, float &x2, float &y2);
@@ -248,7 +251,7 @@ protected:
{
float width;
ui().draw_text_full(
- container(), get_c_str(*it),
+ container(), std::string_view(*it),
0.0f, 0.0f, 1.0f, justify, wrap,
mame_ui_manager::NONE, rgb_t::black(), rgb_t::white(),
&width, nullptr, text_size);
@@ -274,7 +277,7 @@ protected:
for (Iter it = begin; it != end; ++it)
{
ui().draw_text_full(
- container(), get_c_str(*it),
+ container(), std::string_view(*it),
x1, y1, x2 - x1, justify, wrap,
mame_ui_manager::NORMAL, fgcolor, ui().colors().text_bg_color(),
nullptr, nullptr, text_size);
@@ -377,7 +380,7 @@ private:
// push a new menu onto the stack
static void stack_push(std::unique_ptr<menu> &&menu) { get_global_state(menu->machine())->stack_push(std::move(menu)); }
- void extra_text_draw_box(float origx1, float origx2, float origy, float yspan, const char *text, int direction);
+ void extra_text_draw_box(float origx1, float origx2, float origy, float yspan, std::string_view text, int direction);
bool first_item_visible() const { return top_line <= 0; }
bool last_item_visible() const { return (top_line + m_visible_lines) >= m_items.size(); }
@@ -385,9 +388,6 @@ private:
static void exit(running_machine &machine);
static global_state_ptr get_global_state(running_machine &machine);
- static char const *get_c_str(std::string const &str) { return str.c_str(); }
- static char const *get_c_str(char const *str) { return str; }
-
int m_selected; // which item is selected
int m_hover; // which item is being hovered over
std::vector<menu_item> m_items; // array of items
diff --git a/src/frontend/mame/ui/miscmenu.cpp b/src/frontend/mame/ui/miscmenu.cpp
index 1a6e95417ba..5de57de2ea6 100644
--- a/src/frontend/mame/ui/miscmenu.cpp
+++ b/src/frontend/mame/ui/miscmenu.cpp
@@ -73,7 +73,7 @@ void menu_bios_selection::populate(float &customtop, float &custombottom)
}
item_append(menu_item_type::SEPARATOR);
- item_append(_("Reset"), "", 0, (void *)1);
+ item_append(_("Reset"), 0, (void *)1);
}
menu_bios_selection::~menu_bios_selection()
@@ -237,7 +237,7 @@ void menu_bookkeeping::populate(float &customtop, float &custombottom)
}
/* append the single item */
- item_append(tempstring.str(), "", FLAG_MULTILINE, nullptr);
+ item_append(tempstring.str(), FLAG_MULTILINE, nullptr);
}
/*-------------------------------------------------
@@ -668,9 +668,9 @@ void menu_export::handle()
void menu_export::populate(float &customtop, float &custombottom)
{
// add options items
- item_append(_("Export list in XML format (like -listxml)"), "", 0, (void *)(uintptr_t)1);
- item_append(_("Export list in XML format (like -listxml, but exclude devices)"), "", 0, (void *)(uintptr_t)3);
- item_append(_("Export list in TXT format (like -listfull)"), "", 0, (void *)(uintptr_t)2);
+ item_append(_("Export list in XML format (like -listxml)"), 0, (void *)(uintptr_t)1);
+ item_append(_("Export list in XML format (like -listxml, but exclude devices)"), 0, (void *)(uintptr_t)3);
+ item_append(_("Export list in TXT format (like -listfull)"), 0, (void *)(uintptr_t)2);
item_append(menu_item_type::SEPARATOR);
}
@@ -782,28 +782,28 @@ void menu_machine_configure::handle()
void menu_machine_configure::populate(float &customtop, float &custombottom)
{
// add options items
- item_append(_("BIOS"), "", FLAG_DISABLE | FLAG_UI_HEADING, nullptr);
+ item_append(_("BIOS"), FLAG_DISABLE | FLAG_UI_HEADING, nullptr);
if (!m_bios.empty())
{
uint32_t arrows = get_arrow_flags(std::size_t(0), m_bios.size() - 1, m_curbios);
item_append(_("Driver"), m_bios[m_curbios].first, arrows, (void *)(uintptr_t)BIOS);
}
else
- item_append(_("This machine has no BIOS."), "", FLAG_DISABLE, nullptr);
+ item_append(_("This machine has no BIOS."), FLAG_DISABLE, nullptr);
item_append(menu_item_type::SEPARATOR);
- item_append(_(submenu::advanced_options[0].description), "", 0, (void *)(uintptr_t)ADVANCED);
- item_append(_(submenu::video_options[0].description), "", 0, (void *)(uintptr_t)VIDEO);
- item_append(_(submenu::control_options[0].description), "", 0, (void *)(uintptr_t)CONTROLLER);
+ item_append(_(submenu::advanced_options[0].description), 0, (void *)(uintptr_t)ADVANCED);
+ item_append(_(submenu::video_options[0].description), 0, (void *)(uintptr_t)VIDEO);
+ item_append(_(submenu::control_options[0].description), 0, (void *)(uintptr_t)CONTROLLER);
item_append(menu_item_type::SEPARATOR);
if (!m_want_favorite)
- item_append(_("Add To Favorites"), "", 0, (void *)ADDFAV);
+ item_append(_("Add To Favorites"), 0, (void *)ADDFAV);
else
- item_append(_("Remove From Favorites"), "", 0, (void *)DELFAV);
+ item_append(_("Remove From Favorites"), 0, (void *)DELFAV);
item_append(menu_item_type::SEPARATOR);
- item_append(_("Save machine configuration"), "", 0, (void *)(uintptr_t)SAVE);
+ item_append(_("Save machine configuration"), 0, (void *)(uintptr_t)SAVE);
item_append(menu_item_type::SEPARATOR);
customtop = 2.0f * ui().get_line_height() + 3.0f * ui().box_tb_border();
}
diff --git a/src/frontend/mame/ui/optsmenu.cpp b/src/frontend/mame/ui/optsmenu.cpp
index 98c1936510f..4fc9b94505c 100644
--- a/src/frontend/mame/ui/optsmenu.cpp
+++ b/src/frontend/mame/ui/optsmenu.cpp
@@ -68,14 +68,14 @@ void menu_simple_game_options::handle()
void menu_simple_game_options::populate(float &customtop, float &custombottom)
{
- item_append(_(submenu::video_options[0].description), "", 0, (void *)(uintptr_t)DISPLAY_MENU);
- item_append(_("Sound Options"), "", 0, (void *)(uintptr_t)SOUND_MENU);
- item_append(_(submenu::misc_options[0].description), "", 0, (void *)(uintptr_t)MISC_MENU);
- item_append(_(submenu::control_options[0].description), "", 0, (void *)(uintptr_t)CONTROLLER_MENU);
- item_append(_("General Inputs"), "", 0, (void *)(uintptr_t)CGI_MENU);
- item_append(_(submenu::advanced_options[0].description), "", 0, (void *)(uintptr_t)ADVANCED_MENU);
+ item_append(_(submenu::video_options[0].description), 0, (void *)(uintptr_t)DISPLAY_MENU);
+ item_append(_("Sound Options"), 0, (void *)(uintptr_t)SOUND_MENU);
+ item_append(_(submenu::misc_options[0].description), 0, (void *)(uintptr_t)MISC_MENU);
+ item_append(_(submenu::control_options[0].description), 0, (void *)(uintptr_t)CONTROLLER_MENU);
+ item_append(_("General Inputs"), 0, (void *)(uintptr_t)CGI_MENU);
+ item_append(_(submenu::advanced_options[0].description), 0, (void *)(uintptr_t)ADVANCED_MENU);
item_append(menu_item_type::SEPARATOR);
- item_append(_("Save Configuration"), "", 0, (void *)(uintptr_t)SAVE_CONFIG);
+ item_append(_("Save Configuration"), 0, (void *)(uintptr_t)SAVE_CONFIG);
custombottom = 2.0f * ui().get_line_height() + 3.0f * ui().box_tb_border();
customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
@@ -209,8 +209,8 @@ void menu_game_options::populate(float &customtop, float &custombottom)
item_append(menu_item_type::SEPARATOR);
// add options items
- item_append(_("Customize UI"), "", 0, (void *)(uintptr_t)CUSTOM_MENU);
- item_append(_("Configure Directories"), "", 0, (void *)(uintptr_t)CONF_DIR);
+ item_append(_("Customize UI"), 0, (void *)(uintptr_t)CUSTOM_MENU);
+ item_append(_("Configure Directories"), 0, (void *)(uintptr_t)CONF_DIR);
// add the options that don't relate to the UI
menu_simple_game_options::populate(customtop, custombottom);
diff --git a/src/frontend/mame/ui/pluginopt.cpp b/src/frontend/mame/ui/pluginopt.cpp
index fabd5c44337..2fb36393ba7 100644
--- a/src/frontend/mame/ui/pluginopt.cpp
+++ b/src/frontend/mame/ui/pluginopt.cpp
@@ -38,7 +38,7 @@ menu_plugin::menu_plugin(mame_ui_manager &mui, render_container &container) :
void menu_plugin::populate(float &customtop, float &custombottom)
{
for (auto &curplugin : m_plugins)
- item_append(curplugin, "", 0, (void *)curplugin.c_str());
+ item_append(curplugin, 0, (void *)curplugin.c_str());
item_append(menu_item_type::SEPARATOR);
}
diff --git a/src/frontend/mame/ui/selector.cpp b/src/frontend/mame/ui/selector.cpp
index e57012ca5af..c7a04c266ca 100644
--- a/src/frontend/mame/ui/selector.cpp
+++ b/src/frontend/mame/ui/selector.cpp
@@ -88,7 +88,7 @@ void menu_selector::populate(float &customtop, float &custombottom)
find_matches(m_search.c_str());
for (int curitem = 0; m_searchlist[curitem]; ++curitem)
- item_append(*m_searchlist[curitem], "", 0, (void *)m_searchlist[curitem]);
+ item_append(*m_searchlist[curitem], 0, (void *)m_searchlist[curitem]);
}
else
{
@@ -97,7 +97,7 @@ void menu_selector::populate(float &customtop, float &custombottom)
if ((0 <= m_initial) && (unsigned(m_initial) == index))
set_selected_index(index);
- item_append(m_str_items[index], "", 0, (void *)&m_str_items[index]);
+ item_append(m_str_items[index], 0, (void *)&m_str_items[index]);
}
}
diff --git a/src/frontend/mame/ui/selgame.cpp b/src/frontend/mame/ui/selgame.cpp
index 116ead68f94..1f657f28100 100644
--- a/src/frontend/mame/ui/selgame.cpp
+++ b/src/frontend/mame/ui/selgame.cpp
@@ -556,7 +556,7 @@ void menu_select_game::populate(float &customtop, float &custombottom)
cloneof = false;
}
- item_append(elem.driver->type.fullname(), "", (cloneof) ? (FLAGS_UI | FLAG_INVERT) : FLAGS_UI, (void *)elem.driver);
+ item_append(elem.driver->type.fullname(), (cloneof) ? (FLAGS_UI | FLAG_INVERT) : FLAGS_UI, (void *)elem.driver);
curitem++;
}
}
@@ -581,7 +581,7 @@ void menu_select_game::populate(float &customtop, float &custombottom)
cloneof = false;
}
- item_append(info.longname, "", cloneof ? (FLAGS_UI | FLAG_INVERT) : FLAGS_UI, (void *)&info);
+ item_append(info.longname, cloneof ? (FLAGS_UI | FLAG_INVERT) : FLAGS_UI, (void *)&info);
}
else
{
@@ -599,12 +599,12 @@ void menu_select_game::populate(float &customtop, float &custombottom)
// add special items
if (stack_has_special_main_menu())
{
- item_append(_("Configure Options"), "", FLAGS_UI, (void *)(uintptr_t)CONF_OPTS);
- item_append(_("Configure Machine"), "", FLAGS_UI, (void *)(uintptr_t)CONF_MACHINE);
+ item_append(_("Configure Options"), FLAGS_UI, (void *)(uintptr_t)CONF_OPTS);
+ item_append(_("Configure Machine"), FLAGS_UI, (void *)(uintptr_t)CONF_MACHINE);
skip_main_items = 2;
if (machine().options().plugins())
{
- item_append(_("Plugins"), "", FLAGS_UI, (void *)(uintptr_t)CONF_PLUGINS);
+ item_append(_("Plugins"), FLAGS_UI, (void *)(uintptr_t)CONF_PLUGINS);
skip_main_items++;
}
}
diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp
index 9a58691b988..9ba8811f4f7 100644
--- a/src/frontend/mame/ui/selmenu.cpp
+++ b/src/frontend/mame/ui/selmenu.cpp
@@ -363,7 +363,7 @@ menu_select_launch::bios_selection::~bios_selection()
void menu_select_launch::bios_selection::populate(float &customtop, float &custombottom)
{
for (auto & elem : m_bios)
- item_append(elem.first, "", 0, (void *)&elem.first);
+ item_append(elem.first, 0, (void *)&elem.first);
item_append(menu_item_type::SEPARATOR);
customtop = ui().get_line_height() + (3.0f * ui().box_tb_border());
@@ -945,7 +945,7 @@ void menu_select_launch::draw_info_arrow(int ub, float origx1, float origx2, flo
bool menu_select_launch::draw_error_text()
{
if (m_ui_error)
- ui().draw_text_box(container(), m_error_text.c_str(), ui::text_layout::CENTER, 0.5f, 0.5f, UI_RED_COLOR);
+ ui().draw_text_box(container(), m_error_text, ui::text_layout::CENTER, 0.5f, 0.5f, UI_RED_COLOR);
return m_ui_error;
}
@@ -974,7 +974,7 @@ float menu_select_launch::draw_left_panel(
// calculate horizontal offset for unadorned names
std::string tmp("_# ");
convert_command_glyph(tmp);
- float const text_sign = ui().get_string_width(tmp.c_str(), text_size);
+ float const text_sign = ui().get_string_width(tmp, text_size);
// get the maximum width of a filter name
float left_width(0.0f);
@@ -1038,7 +1038,7 @@ float menu_select_launch::draw_left_panel(
// finally draw the text itself and move to the next line
float const x1t = x1 + ((str == Filter::display_name(filter)) ? text_sign : 0.0f);
ui().draw_text_full(
- container(), str.c_str(),
+ container(), str,
x1t, y1, x2 - x1,
ui::text_layout::LEFT, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, fgcolor, bgcolor,
@@ -1952,7 +1952,7 @@ void menu_select_launch::draw(uint32_t flags)
float line_y = visible_top + (float)linenum * line_height;
int itemnum = top_line + linenum;
const menu_item &pitem = item(itemnum);
- const char *itemtext = pitem.text.c_str();
+ const std::string_view itemtext = pitem.text;
rgb_t fgcolor = ui().colors().text_color();
rgb_t bgcolor = ui().colors().text_bg_color();
rgb_t fgcolor3 = ui().colors().clone_color();
@@ -2033,14 +2033,14 @@ void menu_select_launch::draw(uint32_t flags)
else
{
int const item_invert = pitem.flags & FLAG_INVERT;
- const char *subitem_text = pitem.subtext.c_str();
+ std::string_view const subitem_text = pitem.subtext;
float item_width, subitem_width;
// compute right space for subitem
ui().draw_text_full(
container(),
subitem_text,
- effective_left + icon_offset, line_y, ui().get_string_width(pitem.subtext.c_str()),
+ effective_left + icon_offset, line_y, ui().get_string_width(pitem.subtext),
ui::text_layout::RIGHT, ui::text_layout::NEVER,
mame_ui_manager::NONE, item_invert ? fgcolor3 : fgcolor, bgcolor,
&subitem_width, nullptr);
@@ -2071,7 +2071,7 @@ void menu_select_launch::draw(uint32_t flags)
for (size_t count = m_available_items; count < item_count(); count++)
{
const menu_item &pitem = item(count);
- const char *itemtext = pitem.text.c_str();
+ const std::string_view itemtext = pitem.text;
float line_x0 = x1 + 0.5f * UI_LINE_WIDTH;
float line_y0 = line;
float line_x1 = x2 - 0.5f * UI_LINE_WIDTH;
@@ -2203,7 +2203,7 @@ float menu_select_launch::draw_right_box_title(float x1, float y1, float x2, flo
float text_size = 1.0f;
for (auto & elem : buffer)
{
- auto textlen = ui().get_string_width(elem.c_str()) + 0.01f;
+ auto textlen = ui().get_string_width(elem) + 0.01f;
float tmp_size = (textlen > midl) ? (midl / textlen) : 1.0f;
text_size = std::min(text_size, tmp_size);
}
@@ -2244,7 +2244,7 @@ float menu_select_launch::draw_right_box_title(float x1, float y1, float x2, flo
bgcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1));
}
- ui().draw_text_full(container(), buffer[cells].c_str(), x1 + UI_LINE_WIDTH, y1, midl - UI_LINE_WIDTH,
+ ui().draw_text_full(container(), buffer[cells], x1 + UI_LINE_WIDTH, y1, midl - UI_LINE_WIDTH,
ui::text_layout::CENTER, ui::text_layout::NEVER, mame_ui_manager::NORMAL, fgcolor, bgcolor, nullptr, nullptr, text_size);
x1 += midl;
}
@@ -2373,7 +2373,7 @@ std::string menu_select_launch::arts_render_common(float origx1, float origy1, f
}
ui().draw_text_full(container(),
- snaptext.c_str(), origx1, origy1 + ui().box_tb_border(), origx2 - origx1,
+ snaptext, origx1, origy1 + ui().box_tb_border(), origx2 - origx1,
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, fgcolor, bgcolor,
nullptr, nullptr, tmp_size);
@@ -2683,13 +2683,13 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2,
float const ud_arrow_width = line_height * aspect;
float oy1 = origy1 + line_height;
- char const *const snaptext(m_info_view ? m_items_list[m_info_view - 1].c_str() : _(first));
+ std::string_view const snaptext(m_info_view ? std::string_view(m_items_list[m_info_view - 1]) : std::string_view(_(first)));
// get width of widest title
float title_size(0.0f);
for (std::size_t x = 0; total > x; ++x)
{
- char const *const name(x ? m_items_list[x - 1].c_str() : _(first));
+ std::string_view const name(x ? std::string_view(m_items_list[x - 1]) : std::string_view(_(first)));
float txt_length(0.0f);
ui().draw_text_full(
container(), name,
@@ -2736,7 +2736,7 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2,
if (justify == 'f')
{
m_total_lines = ui().wrap_text(
- container(), m_info_buffer.c_str(),
+ container(), m_info_buffer,
0.0f, 0.0f, 1.0f - (2.0f * gutter_width),
xstart, xend,
text_size);
@@ -2744,7 +2744,7 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2,
else
{
m_total_lines = ui().wrap_text(
- container(), m_info_buffer.c_str(),
+ container(), m_info_buffer,
origx1, origy1, origx2 - origx1 - (2.0f * gutter_width),
xstart, xend,
text_size);
@@ -2765,7 +2765,7 @@ 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 const tempbuf(m_info_buffer.substr(xstart[itemline], xend[itemline] - xstart[itemline]));
+ std::string_view const tempbuf(std::string_view(m_info_buffer).substr(xstart[itemline], xend[itemline] - xstart[itemline]));
if (tempbuf[0] == '#')
continue;
@@ -2780,26 +2780,26 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2,
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)));
+ std::string_view::size_type const splitpos(tempbuf.find('\t'));
+ std::string_view const leftcol(tempbuf.substr(0, (std::string_view::npos == splitpos) ? 0U : splitpos));
+ std::string_view const rightcol(tempbuf.substr((std::string_view::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 leftlen(ui().get_string_width(leftcol, text_size));
+ float const rightlen(ui().get_string_width(rightcol, 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(),
+ container(), leftcol,
origx1 + gutter_width, oy1, sc,
ui::text_layout::LEFT, ui::text_layout::TRUNCATE,
mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(),
nullptr, nullptr,
tmp_size3);
ui().draw_text_full(
- container(), rightcol.c_str(),
+ container(), rightcol,
origx1 + gutter_width, oy1, sc,
ui::text_layout::RIGHT, ui::text_layout::TRUNCATE,
mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(),
@@ -2809,10 +2809,10 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2,
else if (justify == 'f' || justify == 'p') // full or partial justify
{
// check size
- float const textlen = ui().get_string_width(tempbuf.c_str(), text_size);
+ float const textlen = ui().get_string_width(tempbuf, text_size);
float tmp_size3 = (textlen > sc) ? text_size * (sc / textlen) : text_size;
ui().draw_text_full(
- container(), tempbuf.c_str(),
+ container(), tempbuf,
origx1 + gutter_width, oy1, origx2 - origx1,
ui::text_layout::LEFT, ui::text_layout::TRUNCATE,
mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(),
@@ -2822,7 +2822,7 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2,
else
{
ui().draw_text_full(
- container(), tempbuf.c_str(),
+ container(), tempbuf,
origx1 + gutter_width, oy1, origx2 - origx1,
ui::text_layout::LEFT, ui::text_layout::TRUNCATE,
mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(),
diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp
index ba3c33849e0..f56d04f9fb0 100644
--- a/src/frontend/mame/ui/selsoft.cpp
+++ b/src/frontend/mame/ui/selsoft.cpp
@@ -272,7 +272,7 @@ void menu_select_software::populate(float &customtop, float &custombottom)
{
// if the device can be loaded empty, add an item
if (m_has_empty_start)
- item_append("[Start empty]", "", flags_ui, (void *)&m_swinfo[0]);
+ item_append("[Start empty]", flags_ui, (void *)&m_swinfo[0]);
if (m_filters.end() == flt)
std::copy(std::next(m_swinfo.begin()), m_swinfo.end(), std::back_inserter(m_displaylist));
diff --git a/src/frontend/mame/ui/simpleselgame.cpp b/src/frontend/mame/ui/simpleselgame.cpp
index f74c064640e..7625e5519d3 100644
--- a/src/frontend/mame/ui/simpleselgame.cpp
+++ b/src/frontend/mame/ui/simpleselgame.cpp
@@ -250,7 +250,7 @@ void simple_menu_select_game::populate(float &customtop, float &custombottom)
"the docs directory for information on configuring %2$s."),
emulator_info::get_configname(),
emulator_info::get_appname());
- item_append(txt, "", FLAG_MULTILINE | FLAG_REDTEXT, nullptr);
+ item_append(txt, FLAG_MULTILINE | FLAG_REDTEXT, nullptr);
return;
}
@@ -275,7 +275,7 @@ void simple_menu_select_game::populate(float &customtop, float &custombottom)
if (stack_has_special_main_menu())
{
item_append(menu_item_type::SEPARATOR);
- item_append(_("Configure Options"), "", 0, (void *)1);
+ item_append(_("Configure Options"), 0, (void *)1);
m_skip_main_items = 1;
}
diff --git a/src/frontend/mame/ui/sliders.cpp b/src/frontend/mame/ui/sliders.cpp
index aa3ebac7976..935c4b50d5d 100644
--- a/src/frontend/mame/ui/sliders.cpp
+++ b/src/frontend/mame/ui/sliders.cpp
@@ -241,7 +241,7 @@ void menu_sliders::custom_render(void *selectedref, float top, float bottom, flo
y1 += ui().box_tb_border();
// determine the text height
- ui().draw_text_full(container(), tempstring.c_str(), 0, 0, x2 - x1 - 2.0f * lr_border,
+ ui().draw_text_full(container(), tempstring, 0, 0, x2 - x1 - 2.0f * lr_border,
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), nullptr, &text_height);
// draw the thermometer
@@ -268,7 +268,7 @@ void menu_sliders::custom_render(void *selectedref, float top, float bottom, flo
container().add_line(default_x, bar_bottom, default_x, bar_area_top + bar_area_height, UI_LINE_WIDTH, ui().colors().border_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
// draw the actual text
- ui().draw_text_full(container(), tempstring.c_str(), x1 + lr_border, y1 + line_height, x2 - x1 - 2.0f * lr_border,
+ ui().draw_text_full(container(), tempstring, x1 + lr_border, y1 + line_height, x2 - x1 - 2.0f * lr_border,
ui::text_layout::CENTER, ui::text_layout::WORD, mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(), nullptr, &text_height);
}
}
diff --git a/src/frontend/mame/ui/slotopt.cpp b/src/frontend/mame/ui/slotopt.cpp
index eac072bfa37..982a15d7a83 100644
--- a/src/frontend/mame/ui/slotopt.cpp
+++ b/src/frontend/mame/ui/slotopt.cpp
@@ -200,7 +200,7 @@ void menu_slot_devices::populate(float &customtop, float &custombottom)
item_append(slot.slot_name(), opt_name, item_flags, (void *)&slot);
}
item_append(menu_item_type::SEPARATOR);
- item_append(_("Reset"), "", 0, ITEMREF_RESET);
+ item_append(_("Reset"), 0, ITEMREF_RESET);
// leave space for the name of the current option at the bottom
custombottom = ui().get_line_height() + 3.0f * ui().box_tb_border();
diff --git a/src/frontend/mame/ui/state.cpp b/src/frontend/mame/ui/state.cpp
index 6939401d566..3064fd654dd 100644
--- a/src/frontend/mame/ui/state.cpp
+++ b/src/frontend/mame/ui/state.cpp
@@ -82,7 +82,7 @@ menu_load_save_state_base::file_entry::file_entry(std::string &&file_name, std::
// ctor
//-------------------------------------------------
-menu_load_save_state_base::menu_load_save_state_base(mame_ui_manager &mui, render_container &container, const char *header, const char *footer, bool must_exist)
+menu_load_save_state_base::menu_load_save_state_base(mame_ui_manager &mui, render_container &container, std::string_view header, std::string_view footer, bool must_exist)
: menu(mui, container)
, m_header(header)
, m_footer(footer)
@@ -200,7 +200,7 @@ void menu_load_save_state_base::populate(float &customtop, float &custombottom)
// append the menu item
void *const itemref = itemref_from_file_entry(*entry);
- item_append(std::move(text), std::string(), 0, itemref);
+ item_append(std::move(text), 0, itemref);
// is this item selected?
if (entry->file_name() == s_last_file_selected)
@@ -209,7 +209,7 @@ void menu_load_save_state_base::populate(float &customtop, float &custombottom)
if (m_entries_vec.empty())
{
- item_append(_("No save states found"), std::string(), 0, nullptr);
+ item_append(_("No save states found"), 0, nullptr);
set_selection(nullptr);
}
item_append(menu_item_type::SEPARATOR);
@@ -334,10 +334,10 @@ void menu_load_save_state_base::slot_selected(std::string &&name)
void menu_load_save_state_base::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
- extra_text_render(top, bottom, origx1, origy1, origx2, origy2, m_header, nullptr);
- if (m_footer)
+ extra_text_render(top, bottom, origx1, origy1, origx2, origy2, m_header, std::string_view());
+ if (!m_footer.empty())
{
- char const *const text[] = { m_footer };
+ std::string_view const text[] = { m_footer };
draw_text_box(
std::begin(text), std::end(text),
origx1, origx2, origy2 + ui().box_tb_border(), origy2 + bottom,
diff --git a/src/frontend/mame/ui/state.h b/src/frontend/mame/ui/state.h
index 72c76f238de..30bd9513bf3 100644
--- a/src/frontend/mame/ui/state.h
+++ b/src/frontend/mame/ui/state.h
@@ -30,7 +30,7 @@ public:
virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override;
protected:
- menu_load_save_state_base(mame_ui_manager &mui, render_container &container, const char *header, const char *footer, bool must_exist);
+ menu_load_save_state_base(mame_ui_manager &mui, render_container &container, std::string_view header, std::string_view footer, bool must_exist);
virtual void process_file(std::string &&file_name) = 0;
private:
@@ -56,8 +56,8 @@ private:
std::unordered_map<std::string, file_entry> m_file_entries;
std::unordered_map<std::string, std::string> m_filename_to_code_map;
- char const *const m_header;
- char const *const m_footer;
+ std::string_view const m_header;
+ std::string_view const m_footer;
bool const m_must_exist;
bool m_was_paused;
bool m_keys_released;
diff --git a/src/frontend/mame/ui/submenu.cpp b/src/frontend/mame/ui/submenu.cpp
index cb1d3e38089..c6e6cfbcd85 100644
--- a/src/frontend/mame/ui/submenu.cpp
+++ b/src/frontend/mame/ui/submenu.cpp
@@ -325,13 +325,13 @@ void submenu::populate(float &customtop, float &custombottom)
switch (sm_option->type)
{
case option_type::HEAD:
- item_append(_(sm_option->description), "", FLAG_DISABLE | FLAG_UI_HEADING, nullptr);
+ item_append(_(sm_option->description), FLAG_DISABLE | FLAG_UI_HEADING, nullptr);
break;
case option_type::SEP:
item_append(menu_item_type::SEPARATOR);
break;
case option_type::CMD:
- item_append(_(sm_option->description), "", 0, static_cast<void*>(&(*sm_option)));
+ item_append(_(sm_option->description), 0, static_cast<void*>(&(*sm_option)));
break;
case option_type::EMU:
case option_type::UI:
@@ -382,7 +382,7 @@ void submenu::populate(float &customtop, float &custombottom)
arrow_flags = get_arrow_flags(f_min, f_max, f_cur);
std::string tmptxt = string_format("%g", f_cur);
item_append(_(sm_option->description),
- tmptxt.c_str(),
+ tmptxt,
arrow_flags,
static_cast<void*>(&(*sm_option)));
}
diff --git a/src/frontend/mame/ui/swlist.cpp b/src/frontend/mame/ui/swlist.cpp
index d1e3f66da56..99ce1e5bc72 100644
--- a/src/frontend/mame/ui/swlist.cpp
+++ b/src/frontend/mame/ui/swlist.cpp
@@ -83,18 +83,18 @@ void menu_software_parts::populate(float &customtop, float &custombottom)
software_part_menu_entry &entry1(*m_entries.emplace(m_entries.end()));
entry1.type = result::EMPTY;
entry1.part = nullptr;
- item_append(_("[empty slot]"), "", 0, &entry1);
+ item_append(_("[empty slot]"), 0, &entry1);
software_part_menu_entry &entry2(*m_entries.emplace(m_entries.end()));
entry2.type = result::FMGR;
entry2.part = nullptr;
- item_append(_("[file manager]"), "", 0, &entry2);
+ item_append(_("[file manager]"), 0, &entry2);
software_part_menu_entry &entry3(*m_entries.emplace(m_entries.end()));
entry3.type = result::SWLIST;
entry3.part = nullptr;
- item_append(_("[software list]"), "", 0, &entry3);
+ item_append(_("[software list]"), 0, &entry3);
}
for (const software_part &swpart : m_info->parts())
@@ -228,7 +228,7 @@ void menu_software_list::populate(float &customtop, float &custombottom)
append_software_entry(swinfo);
// add an entry to change ordering
- item_append(_("Switch Item Ordering"), "", 0, ITEMREF_SWITCH_ITEM_ORDERING);
+ item_append(_("Switch Item Ordering"), 0, ITEMREF_SWITCH_ITEM_ORDERING);
// append all of the menu entries
for (auto &entry : m_entrylist)
@@ -370,7 +370,7 @@ void menu_software::populate(float &customtop, float &custombottom)
break;
}
if (found)
- item_append(swlistdev.description(), "", 0, (void *)&swlistdev);
+ item_append(swlistdev.description(), 0, (void *)&swlistdev);
}
// add compatible software lists for this system
@@ -389,8 +389,8 @@ void menu_software::populate(float &customtop, float &custombottom)
if (found)
{
if (!have_compatible)
- item_append(_("[compatible lists]"), "", FLAG_DISABLE, nullptr);
- item_append(swlistdev.description(), "", 0, (void *)&swlistdev);
+ item_append(_("[compatible lists]"), FLAG_DISABLE, nullptr);
+ item_append(swlistdev.description(), 0, (void *)&swlistdev);
}
have_compatible = true;
}
diff --git a/src/frontend/mame/ui/tapectrl.cpp b/src/frontend/mame/ui/tapectrl.cpp
index 1517554efd9..75d62038931 100644
--- a/src/frontend/mame/ui/tapectrl.cpp
+++ b/src/frontend/mame/ui/tapectrl.cpp
@@ -92,19 +92,19 @@ void menu_tape_control::populate(float &customtop, float &custombottom)
TAPECMD_SLIDER);
// pause or stop
- item_append(_("Pause/Stop"), "", 0, TAPECMD_STOP);
+ item_append(_("Pause/Stop"), 0, TAPECMD_STOP);
// play
- item_append(_("Play"), "", 0, TAPECMD_PLAY);
+ item_append(_("Play"), 0, TAPECMD_PLAY);
// record
- item_append(_("Record"), "", 0, TAPECMD_RECORD);
+ item_append(_("Record"), 0, TAPECMD_RECORD);
// rewind
- item_append(_("Rewind"), "", 0, TAPECMD_REWIND);
+ item_append(_("Rewind"), 0, TAPECMD_REWIND);
// fast forward
- item_append(_("Fast Forward"), "", 0, TAPECMD_FAST_FORWARD);
+ item_append(_("Fast Forward"), 0, TAPECMD_FAST_FORWARD);
}
}
}
diff --git a/src/frontend/mame/ui/text.cpp b/src/frontend/mame/ui/text.cpp
index 0e61b1710db..54bd327cacc 100644
--- a/src/frontend/mame/ui/text.cpp
+++ b/src/frontend/mame/ui/text.cpp
@@ -121,12 +121,9 @@ text_layout::~text_layout()
// add_text
//-------------------------------------------------
-void text_layout::add_text(const char *text, const char_style &style)
+void text_layout::add_text(std::string_view text, const char_style &style)
{
- std::size_t position = 0;
- std::size_t const text_length = std::strlen(text);
-
- while (position < text_length)
+ while (!text.empty())
{
// adding a character - we might change the width
invalidate_calculated_actual_width();
@@ -136,7 +133,7 @@ void text_layout::add_text(const char *text, const char_style &style)
{
// get the current character
char32_t schar;
- int const scharcount = uchar_from_utf8(&schar, &text[position], text_length - position);
+ int const scharcount = uchar_from_utf8(&schar, &text[0], text.length());
if (scharcount < 0)
break;
@@ -144,7 +141,7 @@ void text_layout::add_text(const char *text, const char_style &style)
text_justify line_justify = justify();
if (schar == '\t')
{
- position += unsigned(scharcount);
+ text.remove_prefix(scharcount);
line_justify = text_layout::CENTER;
}
@@ -154,10 +151,10 @@ void text_layout::add_text(const char *text, const char_style &style)
// get the current character
char32_t ch;
- int const scharcount = uchar_from_utf8(&ch, &text[position], text_length - position);
+ int const scharcount = uchar_from_utf8(&ch, &text[0], text.length());
if (scharcount < 0)
break;
- position += unsigned(scharcount);
+ text.remove_prefix(scharcount);
// set up source information
source_info source = { 0, };
diff --git a/src/frontend/mame/ui/text.h b/src/frontend/mame/ui/text.h
index fdf000c850a..78f4905bbf4 100644
--- a/src/frontend/mame/ui/text.h
+++ b/src/frontend/mame/ui/text.h
@@ -12,6 +12,7 @@
#pragma once
+#include <string_view>
class render_font;
class render_container;
@@ -63,7 +64,7 @@ public:
void restyle(size_t start, size_t span, rgb_t *fgcolor, rgb_t *bgcolor);
int get_wrap_info(std::vector<int> &xstart, std::vector<int> &xend) const;
void emit(render_container &container, float x, float y);
- void add_text(const char *text, rgb_t fgcolor = rgb_t::white(), rgb_t bgcolor = rgb_t::transparent(), float size = 1.0)
+ void add_text(std::string_view text, rgb_t fgcolor = rgb_t::white(), rgb_t bgcolor = rgb_t::transparent(), float size = 1.0)
{
// create the style
char_style style = { 0, };
@@ -147,7 +148,7 @@ private:
bool m_truncating;
// methods
- void add_text(const char *text, const char_style &style);
+ void add_text(std::string_view text, const char_style &style);
void start_new_line(text_justify justify, float height);
float get_char_width(char32_t ch, float size);
void truncate_wrap();
diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp
index 948be161a28..1400cc19295 100644
--- a/src/frontend/mame/ui/ui.cpp
+++ b/src/frontend/mame/ui/ui.cpp
@@ -598,7 +598,7 @@ void mame_ui_manager::update_and_render(render_container &container)
// display any popup messages
if (osd_ticks() < m_popup_text_end)
- draw_text_box(container, messagebox_poptext.c_str(), ui::text_layout::CENTER, 0.5f, 0.9f, messagebox_backcolor);
+ draw_text_box(container, messagebox_poptext, ui::text_layout::CENTER, 0.5f, 0.9f, messagebox_backcolor);
else
m_popup_text_end = 0;
@@ -703,7 +703,7 @@ float mame_ui_manager::get_char_width(char32_t ch)
// character string
//-------------------------------------------------
-float mame_ui_manager::get_string_width(const char *s, float text_size)
+float mame_ui_manager::get_string_width(std::string_view s, float text_size)
{
return get_font()->utf8string_width(get_line_height() * text_size, machine().render().ui_aspect(), s);
}
@@ -741,7 +741,7 @@ void mame_ui_manager::draw_outlined_box(render_container &container, float x0, f
// draw_text - simple text renderer
//-------------------------------------------------
-void mame_ui_manager::draw_text(render_container &container, const char *buf, float x, float y)
+void mame_ui_manager::draw_text(render_container &container, std::string_view buf, float x, float y)
{
draw_text_full(container, buf, x, y, 1.0f - x, ui::text_layout::LEFT, ui::text_layout::WORD, mame_ui_manager::NORMAL, colors().text_color(), colors().text_bg_color(), nullptr, nullptr);
}
@@ -753,7 +753,7 @@ void mame_ui_manager::draw_text(render_container &container, const char *buf, fl
// and full size computation
//-------------------------------------------------
-void mame_ui_manager::draw_text_full(render_container &container, const char *origs, float x, float y, float origwrapwidth, ui::text_layout::text_justify justify, ui::text_layout::word_wrapping wrap, draw_mode draw, rgb_t fgcolor, rgb_t bgcolor, float *totalwidth, float *totalheight, float text_size)
+void mame_ui_manager::draw_text_full(render_container &container, std::string_view origs, float x, float y, float origwrapwidth, ui::text_layout::text_justify justify, ui::text_layout::word_wrapping wrap, draw_mode draw, rgb_t fgcolor, rgb_t bgcolor, float *totalwidth, float *totalheight, float text_size)
{
// create the layout
auto layout = create_layout(container, origwrapwidth, justify, wrap);
@@ -782,7 +782,7 @@ void mame_ui_manager::draw_text_full(render_container &container, const char *or
// message with a box around it
//-------------------------------------------------
-void mame_ui_manager::draw_text_box(render_container &container, const char *text, ui::text_layout::text_justify justify, float xpos, float ypos, rgb_t backcolor)
+void mame_ui_manager::draw_text_box(render_container &container, std::string_view text, ui::text_layout::text_justify justify, float xpos, float ypos, rgb_t backcolor)
{
// cap the maximum width
float maximum_width = 1.0f - box_lr_border() * 2;
@@ -829,7 +829,7 @@ void mame_ui_manager::draw_text_box(render_container &container, ui::text_layout
// message with a box around it
//-------------------------------------------------
-void mame_ui_manager::draw_message_window(render_container &container, const char *text)
+void mame_ui_manager::draw_message_window(render_container &container, std::string_view text)
{
draw_text_box(container, text, ui::text_layout::text_justify::LEFT, 0.5f, 0.5f, colors().background_color());
}
@@ -953,7 +953,7 @@ bool mame_ui_manager::is_menu_active(void)
uint32_t mame_ui_manager::handler_messagebox(render_container &container)
{
- draw_text_box(container, messagebox_text.c_str(), ui::text_layout::LEFT, 0.5f, 0.5f, messagebox_backcolor);
+ draw_text_box(container, messagebox_text, ui::text_layout::LEFT, 0.5f, 0.5f, messagebox_backcolor);
return 0;
}
@@ -969,7 +969,7 @@ uint32_t mame_ui_manager::handler_messagebox_anykey(render_container &container)
uint32_t state = 0;
// draw a standard message window
- draw_text_box(container, messagebox_text.c_str(), ui::text_layout::LEFT, 0.5f, 0.5f, messagebox_backcolor);
+ draw_text_box(container, messagebox_text, ui::text_layout::LEFT, 0.5f, 0.5f, messagebox_backcolor);
// if the user cancels, exit out completely
if (machine().ui_input().pressed(IPT_UI_CANCEL))
@@ -1090,7 +1090,7 @@ bool mame_ui_manager::can_paste()
void mame_ui_manager::draw_fps_counter(render_container &container)
{
- draw_text_full(container, machine().video().speed_text().c_str(), 0.0f, 0.0f, 1.0f,
+ draw_text_full(container, machine().video().speed_text(), 0.0f, 0.0f, 1.0f,
ui::text_layout::RIGHT, ui::text_layout::WORD, OPAQUE_, rgb_t::white(), rgb_t::black(), nullptr, nullptr);
}
@@ -1102,7 +1102,7 @@ void mame_ui_manager::draw_fps_counter(render_container &container)
void mame_ui_manager::draw_timecode_counter(render_container &container)
{
std::string tempstring;
- draw_text_full(container, machine().video().timecode_text(tempstring).c_str(), 0.0f, 0.0f, 1.0f,
+ draw_text_full(container, machine().video().timecode_text(tempstring), 0.0f, 0.0f, 1.0f,
ui::text_layout::RIGHT, ui::text_layout::WORD, OPAQUE_, rgb_t(0xf0, 0xf0, 0x10, 0x10), rgb_t::black(), nullptr, nullptr);
}
@@ -1114,7 +1114,7 @@ void mame_ui_manager::draw_timecode_counter(render_container &container)
void mame_ui_manager::draw_timecode_total(render_container &container)
{
std::string tempstring;
- draw_text_full(container, machine().video().timecode_total_text(tempstring).c_str(), 0.0f, 0.0f, 1.0f,
+ draw_text_full(container, machine().video().timecode_total_text(tempstring), 0.0f, 0.0f, 1.0f,
ui::text_layout::LEFT, ui::text_layout::WORD, OPAQUE_, rgb_t(0xf0, 0x10, 0xf0, 0x10), rgb_t::black(), nullptr, nullptr);
}
@@ -1125,7 +1125,7 @@ void mame_ui_manager::draw_timecode_total(render_container &container)
void mame_ui_manager::draw_profiler(render_container &container)
{
- const char *text = g_profiler.text(machine());
+ std::string_view text = g_profiler.text(machine());
draw_text_full(container, text, 0.0f, 0.0f, 1.0f, ui::text_layout::LEFT, ui::text_layout::WORD, OPAQUE_, rgb_t::white(), rgb_t::black(), nullptr, nullptr);
}
@@ -1172,7 +1172,7 @@ void mame_ui_manager::image_handler_ingame()
std::string str = image.call_display();
if (!str.empty())
{
- layout.add_text(str.c_str());
+ layout.add_text(str);
layout.add_text("\n");
}
}
@@ -1445,7 +1445,7 @@ uint32_t mame_ui_manager::handler_confirm_quit(render_container &container)
ui_select_text,
ui_cancel_text);
- draw_text_box(container, quit_message.c_str(), ui::text_layout::CENTER, 0.5f, 0.5f, UI_RED_COLOR);
+ draw_text_box(container, quit_message, ui::text_layout::CENTER, 0.5f, 0.5f, UI_RED_COLOR);
machine().pause();
// if the user press ENTER, quit the game
@@ -2204,7 +2204,7 @@ ui::text_layout mame_ui_manager::create_layout(render_container &container, floa
// wrap_text
//-------------------------------------------------
-int mame_ui_manager::wrap_text(render_container &container, const char *origs, float x, float y, float origwrapwidth, std::vector<int> &xstart, std::vector<int> &xend, float text_size)
+int mame_ui_manager::wrap_text(render_container &container, std::string_view origs, float x, float y, float origwrapwidth, std::vector<int> &xstart, std::vector<int> &xend, float text_size)
{
// create the layout
auto layout = create_layout(container, origwrapwidth, ui::text_layout::LEFT, ui::text_layout::WORD);
diff --git a/src/frontend/mame/ui/ui.h b/src/frontend/mame/ui/ui.h
index af9ad03efcc..d2fcd19d512 100644
--- a/src/frontend/mame/ui/ui.h
+++ b/src/frontend/mame/ui/ui.h
@@ -24,6 +24,7 @@
#include <ctime>
#include <functional>
#include <set>
+#include <string_view>
#include <utility>
#include <vector>
@@ -207,14 +208,14 @@ public:
render_font *get_font();
float get_line_height();
float get_char_width(char32_t ch);
- float get_string_width(const char *s, float text_size = 1.0f);
+ float get_string_width(std::string_view s, float text_size = 1.0f);
void draw_outlined_box(render_container &container, float x0, float y0, float x1, float y1, rgb_t backcolor);
void draw_outlined_box(render_container &container, float x0, float y0, float x1, float y1, rgb_t fgcolor, rgb_t bgcolor);
- void draw_text(render_container &container, const char *buf, float x, float y);
- void draw_text_full(render_container &container, const char *origs, float x, float y, float origwrapwidth, ui::text_layout::text_justify justify, ui::text_layout::word_wrapping wrap, draw_mode draw, rgb_t fgcolor, rgb_t bgcolor, float *totalwidth = nullptr, float *totalheight = nullptr, float text_size = 1.0f);
- void draw_text_box(render_container &container, const char *text, ui::text_layout::text_justify justify, float xpos, float ypos, rgb_t backcolor);
+ void draw_text(render_container &container, std::string_view buf, float x, float y);
+ void draw_text_full(render_container &container, std::string_view origs, float x, float y, float origwrapwidth, ui::text_layout::text_justify justify, ui::text_layout::word_wrapping wrap, draw_mode draw, rgb_t fgcolor, rgb_t bgcolor, float *totalwidth = nullptr, float *totalheight = nullptr, float text_size = 1.0f);
+ void draw_text_box(render_container &container, std::string_view text, ui::text_layout::text_justify justify, float xpos, float ypos, rgb_t backcolor);
void draw_text_box(render_container &container, ui::text_layout &layout, float xpos, float ypos, rgb_t backcolor);
- void draw_message_window(render_container &container, const char *text);
+ void draw_message_window(render_container &container, std::string_view text);
// load/save options to file
void load_ui_options();
@@ -258,7 +259,7 @@ public:
ui::text_layout create_layout(render_container &container, float width = 1.0, ui::text_layout::text_justify justify = ui::text_layout::LEFT, ui::text_layout::word_wrapping wrap = ui::text_layout::WORD);
// word wrap
- int wrap_text(render_container &container, const char *origs, float x, float y, float origwrapwidth, std::vector<int> &xstart, std::vector<int> &xend, float text_size = 1.0f);
+ int wrap_text(render_container &container, std::string_view origs, float x, float y, float origwrapwidth, std::vector<int> &xstart, std::vector<int> &xend, float text_size = 1.0f);
// draw an outlined box with given line color and filled with a texture
void draw_textured_box(render_container &container, float x0, float y0, float x1, float y1, rgb_t backcolor, rgb_t linecolor, render_texture *texture = nullptr, uint32_t flags = PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
diff --git a/src/frontend/mame/ui/utils.cpp b/src/frontend/mame/ui/utils.cpp
index 58ee1e09f8d..22b8ebdf288 100644
--- a/src/frontend/mame/ui/utils.cpp
+++ b/src/frontend/mame/ui/utils.cpp
@@ -519,9 +519,9 @@ void composite_filter_impl_base<Impl, Base, Type>::menu_configure::populate(floa
// add remove/add handlers
if (1 < i)
- item_append(_("Remove last filter"), "", 0, (void *)REMOVE_FILTER);
+ item_append(_("Remove last filter"), 0, (void *)REMOVE_FILTER);
if (MAX > i)
- item_append(_("Add filter"), "", 0, (void *)ADD_FILTER);
+ item_append(_("Add filter"), 0, (void *)ADD_FILTER);
item_append(menu_item_type::SEPARATOR);
// leave space for heading
@@ -845,21 +845,18 @@ public:
inifile_manager const &mgr(mame_machine_manager::instance()->inifile());
if (value)
{
- char const *const split(std::strchr(value, '/'));
- std::string ini;
- if (split)
- ini.assign(value, split);
- else
- ini.assign(value);
+ std::string_view const s(value);
+ std::string_view::size_type const split(s.find('/'));
+ std::string_view const ini(s.substr(0, split));
for (unsigned i = 0; mgr.get_file_count() > i; ++i)
{
if (mgr.get_file_name(i) == ini)
{
m_ini = i;
- if (split)
+ if (std::string_view::npos != split)
{
- std::string const group(split + 1);
+ std::string_view const group(s.substr(split + 1));
for (unsigned j = 0; mgr.get_category_count(i) > j; ++j)
{
if (mgr.get_category_name(i, j) == group)
@@ -1036,7 +1033,7 @@ void category_machine_filter::menu_configure::populate(float &customtop, float &
unsigned const filecnt(mgr.get_file_count());
if (!filecnt)
{
- item_append(_("No category INI files found"), "", FLAG_DISABLE, nullptr);
+ item_append(_("No category INI files found"), FLAG_DISABLE, nullptr);
}
else
{
@@ -1045,7 +1042,7 @@ void category_machine_filter::menu_configure::populate(float &customtop, float &
unsigned const groupcnt(mgr.get_category_count(m_ini));
if (!groupcnt)
{
- item_append(_("No groups found in category file"), "", FLAG_DISABLE, nullptr);
+ item_append(_("No groups found in category file"), FLAG_DISABLE, nullptr);
}
else
{
@@ -1601,7 +1598,7 @@ std::string software_filter_data::extract_region(std::string const &longname)
if (found != std::string::npos)
{
std::string::size_type const ends(fullname.find_first_not_of("abcdefghijklmnopqrstuvwxyz", found + 1));
- std::string const temp(fullname.substr(found + 1, ends - found - 1));
+ std::string_view const temp(std::string_view(fullname).substr(found + 1, ends - found - 1));
auto const match(std::find_if(
std::begin(SOFTWARE_REGIONS),
std::end(SOFTWARE_REGIONS),
@@ -1686,19 +1683,19 @@ machine_filter::ptr machine_filter::create(emu_file &file, machine_filter_data c
return nullptr;
// split it into a key/value or bail
- std::string key(buffer);
- for (std::string::size_type i = 0; (2 * indent) > i; ++i)
+ std::string_view key(buffer);
+ for (std::string_view::size_type i = 0; (2 * indent) > i; ++i)
{
if ((key.length() <= i) || (' ' != key[i]))
return nullptr;
}
key = key.substr(2 * indent);
- std::string::size_type const split(key.find(" = "));
- if (std::string::npos == split)
+ std::string_view::size_type const split(key.find(" = "));
+ if (std::string_view::npos == split)
return nullptr;
- std::string::size_type const nl(key.find_first_of("\r\n", split));
- std::string const value(key.substr(split + 3, (std::string::npos == nl) ? nl : (nl - split - 3)));
- key.resize(split);
+ std::string_view::size_type const nl(key.find_first_of("\r\n", split));
+ std::string const value(key.substr(split + 3, (std::string_view::npos == nl) ? nl : (nl - split - 3)));
+ key = key.substr(0, split);
// look for a filter type that matches
for (type n = FIRST; COUNT > n; ++n)
@@ -1794,19 +1791,19 @@ software_filter::ptr software_filter::create(emu_file &file, software_filter_dat
return nullptr;
// split it into a key/value or bail
- std::string key(buffer);
- for (std::string::size_type i = 0; (2 * indent) > i; ++i)
+ std::string_view key(buffer);
+ for (std::string_view::size_type i = 0; (2 * indent) > i; ++i)
{
if ((key.length() <= i) || (' ' != key[i]))
return nullptr;
}
key = key.substr(2 * indent);
- std::string::size_type const split(key.find(" = "));
- if (std::string::npos == split)
+ std::string_view::size_type const split(key.find(" = "));
+ if (std::string_view::npos == split)
return nullptr;
- std::string::size_type const nl(key.find_first_of("\r\n", split));
- std::string const value(key.substr(split + 3, (std::string::npos == nl) ? nl : (nl - split - 3)));
- key.resize(split);
+ std::string_view::size_type const nl(key.find_first_of("\r\n", split));
+ std::string const value(key.substr(split + 3, (std::string_view::npos == nl) ? nl : (nl - split - 3)));
+ key = key.substr(0, split);
// look for a filter type that matches
for (type n = FIRST; COUNT > n; ++n)
diff --git a/src/frontend/mame/ui/videoopt.cpp b/src/frontend/mame/ui/videoopt.cpp
index 2a876c5a1af..da8a554d550 100644
--- a/src/frontend/mame/ui/videoopt.cpp
+++ b/src/frontend/mame/ui/videoopt.cpp
@@ -51,7 +51,7 @@ void menu_video_targets::populate(float &customtop, float &custombottom)
break;
// add a menu item
- item_append(util::string_format(_("Screen #%d"), targetnum), "", 0, target);
+ item_append(util::string_format(_("Screen #%d"), targetnum), 0, target);
}
}
@@ -89,7 +89,7 @@ void menu_video_options::populate(float &customtop, float &custombottom)
// add items for each view
for (char const *name = m_target.view_name(ref = 0); name; name = m_target.view_name(++ref))
- item_append(name, "", 0, reinterpret_cast<void *>(ITEM_VIEW_FIRST + ref));
+ item_append(name, 0, reinterpret_cast<void *>(ITEM_VIEW_FIRST + ref));
item_append(menu_item_type::SEPARATOR);
// add items for visibility toggles
@@ -105,8 +105,7 @@ void menu_video_options::populate(float &customtop, float &custombottom)
bool eclipsed(false);
for (auto it = toggles.begin(); !eclipsed && (toggle != it); ++it)
eclipsed = ((current_mask & it->mask()) != it->mask()) && ((toggle_mask & it->mask()) == it->mask());
- u32 const flags((enabled ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW) | (eclipsed ? (FLAG_INVERT | FLAG_DISABLE) : 0U));
- item_append(toggle->name(), enabled ? _("On") : _("Off"), flags, reinterpret_cast<void *>(ITEM_TOGGLE_FIRST + ref));
+ item_append_on_off(toggle->name(), enabled, eclipsed ? (FLAG_INVERT | FLAG_DISABLE) : 0U, reinterpret_cast<void *>(ITEM_TOGGLE_FIRST + ref));
}
item_append(menu_item_type::SEPARATOR);
}
@@ -126,7 +125,7 @@ void menu_video_options::populate(float &customtop, float &custombottom)
// cropping
int enabled;
enabled = m_target.zoom_to_screen();
- item_append(_("Zoom to Screen Area"), enabled ? _("On") : _("Off"), enabled ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, reinterpret_cast<void *>(ITEM_ZOOM));
+ item_append_on_off(_("Zoom to Screen Area"), enabled, 0, reinterpret_cast<void *>(ITEM_ZOOM));
}
diff --git a/src/frontend/mame/ui/viewgfx.cpp b/src/frontend/mame/ui/viewgfx.cpp
index 188c939c011..6816d56bb68 100644
--- a/src/frontend/mame/ui/viewgfx.cpp
+++ b/src/frontend/mame/ui/viewgfx.cpp
@@ -452,7 +452,7 @@ static void palette_handler(mame_ui_manager &mui, render_container &container, u
// expand the outer box to fit the title
const std::string title = title_buf.str();
- titlewidth = ui_font->string_width(chheight, aspect, title.c_str());
+ titlewidth = ui_font->string_width(chheight, aspect, title);
x0 = 0.0f;
if (boxbounds.x1 - boxbounds.x0 < titlewidth + chwidth)
x0 = boxbounds.x0 - (0.5f - 0.5f * (titlewidth + chwidth));
@@ -743,7 +743,7 @@ static void gfxset_handler(mame_ui_manager &mui, render_container &container, ui
// expand the outer box to fit the title
const std::string title = title_buf.str();
- const float titlewidth = ui_font->string_width(chheight, aspect, title.c_str());
+ const float titlewidth = ui_font->string_width(chheight, aspect, title);
x0 = 0.0f;
if (boxbounds.x1 - boxbounds.x0 < titlewidth + chwidth)
x0 = boxbounds.x0 - (0.5f - 0.5f * (titlewidth + chwidth));
@@ -1148,7 +1148,7 @@ static void tilemap_handler(mame_ui_manager &mui, render_container &container, u
// expand the outer box to fit the title
const std::string title = title_buf.str();
- titlewidth = ui_font->string_width(chheight, aspect, title.c_str());
+ titlewidth = ui_font->string_width(chheight, aspect, title);
if (boxbounds.x1 - boxbounds.x0 < titlewidth + chwidth)
{
boxbounds.x0 = 0.5f - 0.5f * (titlewidth + chwidth);