diff options
author | 2016-03-02 21:49:49 +0100 | |
---|---|---|
committer | 2016-03-02 21:49:49 +0100 | |
commit | 9fe9f6d93e672bcd926f9e7461774bc9cc22e094 (patch) | |
tree | 3911b611dd010a4108b90fb8b8c82116eec21117 /src/emu/ui/miscmenu.cpp | |
parent | dbdf21ee465acadf3e643d62d6bedfcc297ada85 (diff) | |
parent | 1914702e6fae052668df5b068a502bca57c9a3b0 (diff) |
Merge remote-tracking branch 'refs/remotes/mamedev/master'
# Resolved Conflicts:
# src/osd/modules/render/d3d/d3dhlsl.cpp
# src/osd/windows/winmain.cpp
Diffstat (limited to 'src/emu/ui/miscmenu.cpp')
-rw-r--r-- | src/emu/ui/miscmenu.cpp | 253 |
1 files changed, 233 insertions, 20 deletions
diff --git a/src/emu/ui/miscmenu.cpp b/src/emu/ui/miscmenu.cpp index 5d232729bd2..89bf4182ffd 100644 --- a/src/emu/ui/miscmenu.cpp +++ b/src/emu/ui/miscmenu.cpp @@ -16,6 +16,7 @@ #include "ui/menu.h" #include "ui/miscmenu.h" #include "ui/utils.h" +#include "../info.h" /*************************************************************************** MENU HANDLERS @@ -124,8 +125,7 @@ void ui_menu_bios_selection::handle() assert(error.empty()); } else { std::string error; - std::string value = machine().options().main_value(dev->owner()->tag()+1); - strcatprintf(value,",bios=%d",val-1); + std::string value = string_format("%s,bios=%d", machine().options().main_value(dev->owner()->tag()+1), val-1); machine().options().set_value(dev->owner()->tag()+1, value.c_str(), OPTION_PRIORITY_CMDLINE, error); assert(error.empty()); } @@ -231,18 +231,18 @@ ui_menu_bookkeeping::~ui_menu_bookkeeping() void ui_menu_bookkeeping::populate() { int tickets = machine().bookkeeping().get_dispensed_tickets(); - std::string tempstring; + std::ostringstream tempstring; int ctrnum; /* show total time first */ - if (prevtime.seconds() >= 60 * 60) - strcatprintf(tempstring, "Uptime: %d:%02d:%02d\n\n", prevtime.seconds() / (60 * 60), (prevtime.seconds() / 60) % 60, prevtime.seconds() % 60); + if (prevtime.seconds() >= (60 * 60)) + util::stream_format(tempstring, _("Uptime: %1$d:%2$02d:%3$02d\n\n"), prevtime.seconds() / (60 * 60), (prevtime.seconds() / 60) % 60, prevtime.seconds() % 60); else - strcatprintf(tempstring,"Uptime: %d:%02d\n\n", (prevtime.seconds() / 60) % 60, prevtime.seconds() % 60); + util::stream_format(tempstring, _("Uptime: %1$d:%2$02d\n\n"), (prevtime.seconds() / 60) % 60, prevtime.seconds() % 60); /* show tickets at the top */ if (tickets > 0) - strcatprintf(tempstring,"Tickets dispensed: %d\n\n", tickets); + util::stream_format(tempstring, _("Tickets dispensed: %1$d\n\n"), tickets); /* loop over coin counters */ for (ctrnum = 0; ctrnum < COIN_COUNTERS; ctrnum++) @@ -250,22 +250,17 @@ void ui_menu_bookkeeping::populate() int count = machine().bookkeeping().coin_counter_get_count(ctrnum); /* display the coin counter number */ - strcatprintf(tempstring,"Coin %c: ", ctrnum + 'A'); - /* display how many coins */ - if (count == 0) - tempstring.append("NA"); - else - strcatprintf(tempstring, "%d", count); - /* display whether or not we are locked out */ - if (machine().bookkeeping().coin_lockout_get_state(ctrnum)) - tempstring.append(_(" (locked)")); - tempstring.append("\n"); + util::stream_format(tempstring, + (count == 0) ? _("Coin %1$c: NA%3$s\n") : _("Coin %1$c: %2$d%3$s\n"), + ctrnum + 'A', + count, + machine().bookkeeping().coin_lockout_get_state(ctrnum) ? _(" (locked)") : ""); } /* append the single item */ - item_append(tempstring.c_str(), nullptr, MENU_FLAG_MULTILINE, nullptr); + item_append(tempstring.str().c_str(), nullptr, MENU_FLAG_MULTILINE, nullptr); } /*------------------------------------------------- @@ -651,7 +646,7 @@ void ui_menu_misc_options::custom_render(void *selectedref, float top, float bot ui_manager &mui = machine().ui(); mui.draw_text_full(container, _("Miscellaneous Options"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, - DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); + DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); width += 2 * UI_BOX_LR_BORDER; float maxwidth = MAX(origx2 - origx1, width); @@ -671,5 +666,223 @@ void ui_menu_misc_options::custom_render(void *selectedref, float top, float bot // draw the text within it mui.draw_text_full(container, _("Miscellaneous Options"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, - DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); + DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); +} + +//------------------------------------------------- +// ctor / dtor +//------------------------------------------------- + +ui_menu_export::ui_menu_export(running_machine &machine, render_container *container, std::vector<const game_driver *> drvlist) + : ui_menu(machine, container), m_list(drvlist) +{ +} + +ui_menu_export::~ui_menu_export() +{ +} + +//------------------------------------------------- +// handlethe options menu +//------------------------------------------------- + +void ui_menu_export::handle() +{ + // process the menu + ui_menu::menu_stack->parent->process(UI_MENU_PROCESS_NOINPUT); + const ui_menu_event *m_event = process(UI_MENU_PROCESS_NOIMAGE); + if (m_event != nullptr && m_event->itemref != nullptr) + { + switch ((FPTR)m_event->itemref) + { + case 1: + { + if (m_event->iptkey == IPT_UI_SELECT) + { + std::string filename("exported"); + emu_file infile(machine().ui().options().ui_path(), OPEN_FLAG_READ); + if (infile.open(filename.c_str(), ".xml") == FILERR_NONE) + for (int seq = 0; ; ++seq) + { + std::string seqtext = string_format("%s_%04d", filename, seq); + if (infile.open(seqtext.c_str(), ".xml") != FILERR_NONE) + { + filename = seqtext; + break; + } + } + + // attempt to open the output file + emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); + if (file.open(filename.c_str(), ".xml") == FILERR_NONE) + { + FILE *pfile; + std::string fullpath(file.fullpath()); + file.close(); + pfile = fopen(fullpath.c_str(), "w"); + + // create the XML and save to file + driver_enumerator drvlist(machine().options()); + drvlist.exclude_all(); + for (auto & elem : m_list) + drvlist.include(driver_list::find(*elem)); + + info_xml_creator creator(drvlist); + creator.output(pfile, false); + fclose(pfile); + machine().popmessage(_("%s.xml saved under ui folder."), filename.c_str()); + } + } + break; + } + case 2: + { + if (m_event->iptkey == IPT_UI_SELECT) + { + std::string filename("exported"); + emu_file infile(machine().ui().options().ui_path(), OPEN_FLAG_READ); + if (infile.open(filename.c_str(), ".txt") == FILERR_NONE) + for (int seq = 0; ; ++seq) + { + std::string seqtext = string_format("%s_%04d", filename, seq); + if (infile.open(seqtext.c_str(), ".txt") != FILERR_NONE) + { + filename = seqtext; + break; + } + } + + // attempt to open the output file + emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); + if (file.open(filename.c_str(), ".txt") == FILERR_NONE) + { + // print the header + std::ostringstream buffer; + buffer << _("Name: Description:\n"); + driver_enumerator drvlist(machine().options()); + drvlist.exclude_all(); + for (auto & elem : m_list) + drvlist.include(driver_list::find(*elem)); + + // iterate through drivers and output the info + while (drvlist.next()) + if ((drvlist.driver().flags & MACHINE_NO_STANDALONE) == 0) + util::stream_format(buffer, "%-18s\"%s\"\n", drvlist.driver().name, drvlist.driver().description); + file.puts(buffer.str().c_str()); + file.close(); + machine().popmessage(_("%s.txt saved under ui folder."), filename.c_str()); + } + } + break; + } + default: + break; + } + } +} + +//------------------------------------------------- +// populate +//------------------------------------------------- + +void ui_menu_export::populate() +{ + // add options items + item_append(_("Export XML format (like -listxml)"), nullptr, 0, (void *)(FPTR)1); + item_append(_("Export TXT format (like -listfull)"), nullptr, 0, (void *)(FPTR)2); + item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); +} + +//------------------------------------------------- +// ctor / dtor +//------------------------------------------------- + +ui_menu_machine_configure::ui_menu_machine_configure(running_machine &machine, render_container *container, const game_driver *prev) + : ui_menu(machine, container), m_drv(prev) +{ +} + +ui_menu_machine_configure::~ui_menu_machine_configure() +{ +} + +//------------------------------------------------- +// handlethe options menu +//------------------------------------------------- + +void ui_menu_machine_configure::handle() +{ + // process the menu + ui_menu::menu_stack->parent->process(UI_MENU_PROCESS_NOINPUT); + const ui_menu_event *m_event = process(UI_MENU_PROCESS_NOIMAGE); + if (m_event != nullptr && m_event->itemref != nullptr) + { + switch ((FPTR)m_event->itemref) + { + case 1: + { + if (m_event->iptkey == IPT_UI_SELECT) + { + std::string filename(m_drv->name); + emu_file file(machine().options().ini_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE); + file_error filerr = file.open(filename.c_str(), ".ini"); + if (filerr == FILERR_NONE) + { + std::string inistring = machine().options().output_ini(); + file.puts(inistring.c_str()); + } + } + break; + } + default: + break; + } + } +} + +//------------------------------------------------- +// populate +//------------------------------------------------- + +void ui_menu_machine_configure::populate() +{ + // add options items + item_append(_("Dummy"), nullptr, 0, (void *)(FPTR)10); + item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); + item_append(_("Save machine configuration"), nullptr, 0, (void *)(FPTR)1); + item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); + customtop = machine().ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER); } + +//------------------------------------------------- +// perform our special rendering +//------------------------------------------------- + +void ui_menu_machine_configure::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +{ + float width; + ui_manager &mui = machine().ui(); + + mui.draw_text_full(container, m_drv->description, 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, + DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); + width += 2 * UI_BOX_LR_BORDER; + float maxwidth = MAX(origx2 - origx1, width); + + // compute our bounds + float x1 = 0.5f - 0.5f * maxwidth; + float x2 = x1 + maxwidth; + float y1 = origy1 - top; + float y2 = origy1 - UI_BOX_TB_BORDER; + + // draw a box + mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR); + + // take off the borders + x1 += UI_BOX_LR_BORDER; + x2 -= UI_BOX_LR_BORDER; + y1 += UI_BOX_TB_BORDER; + + // draw the text within it + mui.draw_text_full(container, m_drv->description, x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, + DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); +}
\ No newline at end of file |