summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/ui/dirmenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/ui/dirmenu.cpp')
-rw-r--r--src/emu/ui/dirmenu.cpp629
1 files changed, 311 insertions, 318 deletions
diff --git a/src/emu/ui/dirmenu.cpp b/src/emu/ui/dirmenu.cpp
index 69c360920dd..f1cc16bae0b 100644
--- a/src/emu/ui/dirmenu.cpp
+++ b/src/emu/ui/dirmenu.cpp
@@ -16,54 +16,266 @@
#include "ui/utils.h"
#include "ui/optsmenu.h"
+static int ADDING = 1;
+static int CHANGE = 2;
+
struct folders_entry
{
const char *name;
const char *option;
+ const int action;
};
-static const folders_entry s_folders_entry[] =
+static const folders_entry s_folders[] =
{
- { "ROMs", OPTION_MEDIAPATH },
- { "UI", OPTION_UI_PATH },
- { "Samples", OPTION_SAMPLEPATH },
- { "DATs", OPTION_HISTORY_PATH },
- { "INIs", OPTION_INIPATH },
- { "Extra INIs", OPTION_EXTRAINI_PATH },
- { "Icons", OPTION_ICONS_PATH },
- { "Cheats", OPTION_CHEATPATH },
- { "Snapshots", OPTION_SNAPSHOT_DIRECTORY },
- { "Cabinets", OPTION_CABINETS_PATH },
- { "Flyers", OPTION_FLYERS_PATH },
- { "Titles", OPTION_TITLES_PATH },
- { "Ends", OPTION_ENDS_PATH },
- { "PCBs", OPTION_PCBS_PATH },
- { "Marquees", OPTION_MARQUEES_PATH },
- { "Controls Panels", OPTION_CPANELS_PATH },
- { "Crosshairs", OPTION_CROSSHAIRPATH },
- { "Artworks", OPTION_ARTPATH },
- { "Bosses", OPTION_BOSSES_PATH },
- { "Artworks Preview", OPTION_ARTPREV_PATH },
- { "Select", OPTION_SELECT_PATH },
- { "GameOver", OPTION_GAMEOVER_PATH },
- { "HowTo", OPTION_HOWTO_PATH },
- { "Logos", OPTION_LOGOS_PATH },
- { "Scores", OPTION_SCORES_PATH },
- { "Versus", OPTION_VERSUS_PATH },
- { nullptr }
+ { __("ROMs"), OPTION_MEDIAPATH, ADDING },
+ { __("UI"), OPTION_UI_PATH, CHANGE },
+ { __("Language"), OPTION_LANGUAGEPATH, CHANGE },
+ { __("Samples"), OPTION_SAMPLEPATH, ADDING },
+ { __("DATs"), OPTION_HISTORY_PATH, CHANGE },
+ { __("INIs"), OPTION_INIPATH, ADDING },
+ { __("Extra INIs"), OPTION_EXTRAINI_PATH, CHANGE },
+ { __("Icons"), OPTION_ICONS_PATH, ADDING },
+ { __("Cheats"), OPTION_CHEATPATH, ADDING },
+ { __("Snapshots"), OPTION_SNAPSHOT_DIRECTORY, ADDING },
+ { __("Cabinets"), OPTION_CABINETS_PATH, ADDING },
+ { __("Flyers"), OPTION_FLYERS_PATH, ADDING },
+ { __("Titles"), OPTION_TITLES_PATH, ADDING },
+ { __("Ends"), OPTION_ENDS_PATH, ADDING },
+ { __("PCBs"), OPTION_PCBS_PATH, ADDING },
+ { __("Marquees"), OPTION_MARQUEES_PATH, ADDING },
+ { __("Controls Panels"), OPTION_CPANELS_PATH, ADDING },
+ { __("Crosshairs"), OPTION_CROSSHAIRPATH, ADDING },
+ { __("Artworks"), OPTION_ARTPATH, ADDING },
+ { __("Bosses"), OPTION_BOSSES_PATH, ADDING },
+ { __("Artworks Preview"), OPTION_ARTPREV_PATH, ADDING },
+ { __("Select"), OPTION_SELECT_PATH, ADDING },
+ { __("GameOver"), OPTION_GAMEOVER_PATH, ADDING },
+ { __("HowTo"), OPTION_HOWTO_PATH, ADDING },
+ { __("Logos"), OPTION_LOGOS_PATH, ADDING },
+ { __("Scores"), OPTION_SCORES_PATH, ADDING },
+ { __("Versus"), OPTION_VERSUS_PATH, ADDING },
};
+
+/**************************************************
+ MENU DIRECTORY
+**************************************************/
+//-------------------------------------------------
+// ctor / dtor
+//-------------------------------------------------
+
+ui_menu_directory::ui_menu_directory(running_machine &machine, render_container *container) : ui_menu(machine, container)
+{
+}
+
+ui_menu_directory::~ui_menu_directory()
+{
+ save_ui_options(machine());
+ ui_globals::reset = true;
+}
+
+//-------------------------------------------------
+// handle
+//-------------------------------------------------
+
+void ui_menu_directory::handle()
+{
+ // process the menu
+ const ui_menu_event *m_event = process(0);
+
+ if (m_event != nullptr && m_event->itemref != nullptr && m_event->iptkey == IPT_UI_SELECT)
+ ui_menu::stack_push(global_alloc_clear<ui_menu_display_actual>(machine(), container, selected));
+}
+
+//-------------------------------------------------
+// populate
+//-------------------------------------------------
+
+void ui_menu_directory::populate()
+{
+
+ for (auto & elem : s_folders)
+ item_append(_(elem.name), nullptr, 0, (void *)(FPTR)elem.action);
+
+ 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_directory::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
+{
+ float width;
+ ui_manager &mui = machine().ui();
+
+ // get the size of the text
+ mui.draw_text_full(container, _("Folders Setup"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
+ DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
+ width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
+ float maxwidth = MAX(width, origx2 - origx1);
+
+ // 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, _("Folders Setup"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
+ DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
+}
+
+/**************************************************
+ MENU DISPLAY PATH
+**************************************************/
+//-------------------------------------------------
+// ctor / dtor
+//-------------------------------------------------
+
+ui_menu_display_actual::ui_menu_display_actual(running_machine &machine, render_container *container, int ref)
+ : ui_menu(machine, container), m_ref(ref)
+{
+}
+
+ui_menu_display_actual::~ui_menu_display_actual()
+{
+}
+
+//-------------------------------------------------
+// handle
+//-------------------------------------------------
+
+void ui_menu_display_actual::handle()
+{
+ // process the menu
+ const ui_menu_event *m_event = process(0);
+ if (m_event != nullptr && m_event->itemref != nullptr && m_event->iptkey == IPT_UI_SELECT)
+ switch ((FPTR)m_event->itemref)
+ {
+ case REMOVE:
+ ui_menu::stack_push(global_alloc_clear<ui_menu_remove_folder>(machine(), container, m_ref));
+ break;
+
+ case ADD_CHANGE:
+ ui_menu::stack_push(global_alloc_clear<ui_menu_add_change_folder>(machine(), container, m_ref));
+ break;
+ }
+}
+
+//-------------------------------------------------
+// populate
+//-------------------------------------------------
+
+void ui_menu_display_actual::populate()
+{
+ m_tempbuf.assign(_("Current ")).append(_(s_folders[m_ref].name)).append(_(" Folders"));
+ if (machine().ui().options().exists(s_folders[m_ref].option)) {
+ m_searchpath.assign(machine().ui().options().value(s_folders[m_ref].option));
+ }
+ else {
+ m_searchpath.assign(machine().options().value(s_folders[m_ref].option));
+ }
+ path_iterator path(m_searchpath.c_str());
+ std::string curpath;
+ m_folders.clear();
+ while (path.next(curpath, nullptr))
+ m_folders.push_back(curpath);
+
+ item_append((s_folders[m_ref].action == CHANGE) ? _("Change Folder") : _("Add Folder"), nullptr, 0, (void *)ADD_CHANGE);
+
+ if (m_folders.size() > 1)
+ item_append(_("Remove Folder"), nullptr, 0, (void *)REMOVE);
+
+ item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr);
+ customtop = (m_folders.size() + 1) * machine().ui().get_line_height() + 6.0f * UI_BOX_TB_BORDER;
+}
+
+//-------------------------------------------------
+// perform our special rendering
+//-------------------------------------------------
+
+void ui_menu_display_actual::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
+{
+ float width, maxwidth = origx2 - origx1;
+ ui_manager &mui = machine().ui();
+ float lineh = mui.get_line_height();
+
+ for (auto & elem : m_folders)
+ {
+ mui.draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
+ width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
+ maxwidth = MAX(maxwidth, width);
+ }
+
+ // get the size of the text
+ mui.draw_text_full(container, m_tempbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
+ width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
+ maxwidth = MAX(width, maxwidth);
+
+ // compute our bounds
+ float x1 = 0.5f - 0.5f * maxwidth;
+ float x2 = x1 + maxwidth;
+ float y1 = origy1 - top;
+ float y2 = y1 + lineh + 2.0f * 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_tempbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
+ DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
+
+ // compute our bounds
+ x1 = 0.5f - 0.5f * maxwidth;
+ x2 = x1 + maxwidth;
+ y1 = y2 + 2.0f * UI_BOX_TB_BORDER;
+ y2 = origy1 - UI_BOX_TB_BORDER;
+
+ // draw a box
+ mui.draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_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
+ for (auto & elem : m_folders)
+ {
+ mui.draw_text_full(container, elem.c_str(), x1, y1, x2 - x1, JUSTIFY_LEFT, WRAP_TRUNCATE,
+ DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
+ y1 += lineh;
+ }
+
+}
+
/**************************************************
- MENU ADD FOLDER
+MENU ADD FOLDER
**************************************************/
//-------------------------------------------------
// ctor / dtor
//-------------------------------------------------
-ui_menu_add_change_folder::ui_menu_add_change_folder(running_machine &machine, render_container *container, int ref, bool _change) : ui_menu(machine, container)
+ui_menu_add_change_folder::ui_menu_add_change_folder(running_machine &machine, render_container *container, int ref) : ui_menu(machine, container)
{
- m_ref = ref - 1;
- m_change = _change;
+ m_ref = ref;
+ m_change = (s_folders[ref].action == CHANGE);
m_search[0] = '\0';
// configure the starting path
@@ -71,6 +283,22 @@ ui_menu_add_change_folder::ui_menu_add_change_folder(running_machine &machine, r
osd_get_full_path(&dst, ".");
m_current_path = dst;
osd_free(dst);
+
+ std::string searchpath;
+ if (machine.ui().options().exists(s_folders[m_ref].option))
+ {
+ searchpath = machine.ui().options().value(s_folders[m_ref].option);
+ }
+ else
+ {
+ searchpath = machine.options().value(s_folders[m_ref].option);
+ }
+
+ path_iterator path(searchpath.c_str());
+ std::string curpath;
+ while (path.next(curpath, nullptr))
+ m_folders.push_back(curpath);
+
}
ui_menu_add_change_folder::~ui_menu_add_change_folder()
@@ -144,38 +372,41 @@ void ui_menu_add_change_folder::handle()
std::string error_string;
if (m_change)
{
- if (machine().ui().options().exists(s_folders_entry[m_ref].option))
+ if (machine().ui().options().exists(s_folders[m_ref].option))
{
- machine().ui().options().set_value(s_folders_entry[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
+ machine().ui().options().set_value(s_folders[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
}
- else {
- if (strcmp(machine().options().value(s_folders_entry[m_ref].option), m_current_path.c_str()) != 0)
+ else
+ {
+ if (strcmp(machine().options().value(s_folders[m_ref].option), m_current_path.c_str()) != 0)
{
- machine().options().set_value(s_folders_entry[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
- machine().options().mark_changed(s_folders_entry[m_ref].option);
+ machine().options().set_value(s_folders[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
+ machine().options().mark_changed(s_folders[m_ref].option);
}
}
machine().datfile().reset_run();
}
else
{
+ m_folders.push_back(m_current_path);
std::string tmppath;
- if (machine().ui().options().exists(s_folders_entry[m_ref].option)) {
- tmppath.assign(machine().ui().options().value(s_folders_entry[m_ref].option)).append(";").append(m_current_path.c_str());
- }
- else {
- tmppath.assign(machine().options().value(s_folders_entry[m_ref].option)).append(";").append(m_current_path.c_str());
+ for (int x = 0; x < m_folders.size(); ++x)
+ {
+ tmppath.append(m_folders[x]);
+ if (x != m_folders.size() - 1)
+ tmppath.append(";");
}
-
- if (machine().ui().options().exists(s_folders_entry[m_ref].option))
+
+ if (machine().ui().options().exists(s_folders[m_ref].option))
{
- machine().ui().options().set_value(s_folders_entry[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
+ machine().ui().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
}
- else {
- if (strcmp(machine().options().value(s_folders_entry[m_ref].option), tmppath.c_str()) != 0)
+ else
+ {
+ if (strcmp(machine().options().value(s_folders[m_ref].option), tmppath.c_str()) != 0)
{
- machine().options().set_value(s_folders_entry[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
- machine().options().mark_changed(s_folders_entry[m_ref].option);
+ machine().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
+ machine().options().mark_changed(s_folders[m_ref].option);
}
}
}
@@ -278,15 +509,15 @@ void ui_menu_add_change_folder::custom_render(void *selectedref, float top, floa
float width, maxwidth = origx2 - origx1;
ui_manager &mui = machine().ui();
std::string tempbuf[2];
- tempbuf[0] = (m_change) ? "Change" : "Add";
- tempbuf[0].append(" ").append(s_folders_entry[m_ref].name).append(" Folder - Search: ").append(m_search).append("_");
+ tempbuf[0] = (m_change) ? _("Change)") : _("Add");
+ tempbuf[0].append(" ").append(_(s_folders[m_ref].name)).append(_(" Folder - Search: ")).append(m_search).append("_");
tempbuf[1] = m_current_path;
// get the size of the text
- for (auto & elem: tempbuf)
+ for (auto & elem : tempbuf)
{
mui.draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
- DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
+ DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
maxwidth = MAX(width, maxwidth);
}
@@ -314,7 +545,7 @@ void ui_menu_add_change_folder::custom_render(void *selectedref, float top, floa
}
// bottom text
- tempbuf[0] = "Press TAB to set";
+ tempbuf[0] = _("Press TAB to set");
mui.draw_text_full(container, tempbuf[0].c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
@@ -342,261 +573,24 @@ void ui_menu_add_change_folder::custom_render(void *selectedref, float top, floa
}
/**************************************************
- MENU DIRECTORY
-**************************************************/
-//-------------------------------------------------
-// ctor / dtor
-//-------------------------------------------------
-
-ui_menu_directory::ui_menu_directory(running_machine &machine, render_container *container) : ui_menu(machine, container)
-{
-}
-
-ui_menu_directory::~ui_menu_directory()
-{
- save_ui_options(machine());
- ui_globals::reset = true;
-}
-
-//-------------------------------------------------
-// handle
-//-------------------------------------------------
-
-void ui_menu_directory::handle()
-{
- // process the menu
- const ui_menu_event *m_event = process(0);
-
- if (m_event != nullptr && m_event->itemref != nullptr && m_event->iptkey == IPT_UI_SELECT)
- {
- int ref = (FPTR)m_event->itemref;
- bool change = (ref == HISTORY_FOLDERS || ref == EXTRAINI_FOLDERS || ref == UI_FOLDERS);
- ui_menu::stack_push(global_alloc_clear<ui_menu_display_actual>(machine(), container, ref, change));
- }
-}
-
-//-------------------------------------------------
-// populate
-//-------------------------------------------------
-
-void ui_menu_directory::populate()
-{
- item_append("Roms", nullptr, 0, (void *)(FPTR)ROM_FOLDERS);
- item_append("UI", nullptr, 0, (void *)(FPTR)UI_FOLDERS);
- item_append("Samples", nullptr, 0, (void *)(FPTR)SAMPLE_FOLDERS);
- item_append("INIs", nullptr, 0, (void *)(FPTR)INI_FOLDERS);
- item_append("Artwork", nullptr, 0, (void *)(FPTR)ARTWORK_FOLDERS);
- item_append("DATs (History, Mameinfo, etc...)", nullptr, 0, (void *)(FPTR)HISTORY_FOLDERS);
- item_append("Extra INI (Category, etc...)", nullptr, 0, (void *)(FPTR)EXTRAINI_FOLDERS);
- item_append("Icons", nullptr, 0, (void *)(FPTR)ICON_FOLDERS);
- item_append("Cheats", nullptr, 0, (void *)(FPTR)CHEAT_FOLDERS);
- item_append("Snapshots", nullptr, 0, (void *)(FPTR)SNAPSHOT_FOLDERS);
- item_append("Cabinets", nullptr, 0, (void *)(FPTR)CABINET_FOLDERS);
- item_append("Flyers", nullptr, 0, (void *)(FPTR)FLYER_FOLDERS);
- item_append("Titles", nullptr, 0, (void *)(FPTR)TITLE_FOLDERS);
- item_append("Ends", nullptr, 0, (void *)(FPTR)ENDS_FOLDERS);
- item_append("PCBs", nullptr, 0, (void *)(FPTR)PCB_FOLDERS);
- item_append("Marquees", nullptr, 0, (void *)(FPTR)MARQUEES_FOLDERS);
- item_append("Control Panels", nullptr, 0, (void *)(FPTR)CPANEL_FOLDERS);
- item_append("Bosses", nullptr, 0, (void *)(FPTR)BOSSES_FOLDERS);
- item_append("Versus", nullptr, 0, (void *)(FPTR)VERSUS_FOLDERS);
- item_append("Game Over", nullptr, 0, (void *)(FPTR)GAMEOVER_FOLDERS);
- item_append("How To", nullptr, 0, (void *)(FPTR)HOWTO_FOLDERS);
- item_append("Select", nullptr, 0, (void *)(FPTR)SELECT_FOLDERS);
- item_append("Artwork Preview", nullptr, 0, (void *)(FPTR)ARTPREV_FOLDERS);
- item_append("Scores", nullptr, 0, (void *)(FPTR)SCORES_FOLDERS);
- item_append("Logos", nullptr, 0, (void *)(FPTR)LOGO_FOLDERS);
- item_append("Crosshairs", nullptr, 0, (void *)(FPTR)CROSSHAIR_FOLDERS);
-
- 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_directory::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
-{
- float width;
- ui_manager &mui = machine().ui();
-
- // get the size of the text
- mui.draw_text_full(container, "Folder Setup", 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
- DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
- width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
- float maxwidth = MAX(width, origx2 - origx1);
-
- // 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, "Folder Setup", x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
- DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
-}
-
-/**************************************************
- MENU DISPLAY PATH
+ MENU REMOVE FOLDER
**************************************************/
//-------------------------------------------------
// ctor / dtor
//-------------------------------------------------
-ui_menu_display_actual::ui_menu_display_actual(running_machine &machine, render_container *container, int ref, bool _change) : ui_menu(machine, container)
+ui_menu_remove_folder::ui_menu_remove_folder(running_machine &machine, render_container *container, int ref) : ui_menu(machine, container)
{
m_ref = ref;
- m_change = _change;
-}
-
-ui_menu_display_actual::~ui_menu_display_actual()
-{
-}
-
-//-------------------------------------------------
-// handle
-//-------------------------------------------------
-
-void ui_menu_display_actual::handle()
-{
- // process the menu
- const ui_menu_event *m_event = process(0);
- if (m_event != nullptr && m_event->itemref != nullptr && m_event->iptkey == IPT_UI_SELECT)
- switch ((FPTR)m_event->itemref)
- {
- case REMOVE_FOLDER:
- ui_menu::stack_push(global_alloc_clear<ui_menu_remove_folder>(machine(), container, m_ref));
- break;
-
- case ADD_FOLDER:
- case CHANGE_FOLDER:
- ui_menu::stack_push(global_alloc_clear<ui_menu_add_change_folder>(machine(), container, m_ref, m_change));
- break;
- }
-}
-
-//-------------------------------------------------
-// populate
-//-------------------------------------------------
+ if (machine.ui().options().exists(s_folders[m_ref].option))
+ m_searchpath.assign(machine.ui().options().value(s_folders[m_ref].option));
+ else
+ m_searchpath.assign(machine.options().value(s_folders[m_ref].option));
-void ui_menu_display_actual::populate()
-{
- m_tempbuf.assign("Current ").append(s_folders_entry[m_ref - 1].name).append(" Folders");
- if (machine().ui().options().exists(s_folders_entry[m_ref - 1].option)) {
- m_searchpath.assign(machine().ui().options().value(s_folders_entry[m_ref - 1].option));
- }
- else {
- m_searchpath.assign(machine().options().value(s_folders_entry[m_ref - 1].option));
- }
path_iterator path(m_searchpath.c_str());
std::string curpath;
- m_folders.clear();
while (path.next(curpath, nullptr))
m_folders.push_back(curpath);
-
- if (m_change)
- item_append("Change Folder", nullptr, 0, (void *)CHANGE_FOLDER);
- else
- item_append("Add Folder", nullptr, 0, (void *)ADD_FOLDER);
-
- if (m_folders.size() > 1)
- item_append("Remove Folder", nullptr, 0, (void *)REMOVE_FOLDER);
-
- item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr);
- customtop = (m_folders.size() + 1) * machine().ui().get_line_height() + 6.0f * UI_BOX_TB_BORDER;
-}
-
-//-------------------------------------------------
-// perform our special rendering
-//-------------------------------------------------
-
-void ui_menu_display_actual::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
-{
- float width, maxwidth = origx2 - origx1;
- ui_manager &mui = machine().ui();
- float lineh = mui.get_line_height();
-
- for (auto & elem : m_folders)
- {
- mui.draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
- width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
- maxwidth = MAX(maxwidth, width);
- }
-
- // get the size of the text
- mui.draw_text_full(container, m_tempbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
- width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
- maxwidth = MAX(width, maxwidth);
-
- // compute our bounds
- float x1 = 0.5f - 0.5f * maxwidth;
- float x2 = x1 + maxwidth;
- float y1 = origy1 - top;
- float y2 = y1 + lineh + 2.0f * 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_tempbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
- DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
-
- // compute our bounds
- x1 = 0.5f - 0.5f * maxwidth;
- x2 = x1 + maxwidth;
- y1 = y2 + 2.0f * UI_BOX_TB_BORDER;
- y2 = origy1 - UI_BOX_TB_BORDER;
-
- // draw a box
- mui.draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_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
- for (auto & elem : m_folders)
- {
- mui.draw_text_full(container, elem.c_str(), x1, y1, x2 - x1, JUSTIFY_LEFT, WRAP_TRUNCATE,
- DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
- y1 += lineh;
- }
-
-}
-
-/**************************************************
- MENU REMOVE FOLDER
-**************************************************/
-//-------------------------------------------------
-// ctor / dtor
-//-------------------------------------------------
-
-ui_menu_remove_folder::ui_menu_remove_folder(running_machine &machine, render_container *container, int ref) : ui_menu(machine, container)
-{
- m_ref = ref - 1;
- if (machine.ui().options().exists(s_folders_entry[m_ref].option)) {
- m_searchpath.assign(machine.ui().options().value(s_folders_entry[m_ref].option));
- }
- else {
- m_searchpath.assign(machine.options().value(s_folders_entry[m_ref].option));
- }
-
}
ui_menu_remove_folder::~ui_menu_remove_folder()
@@ -613,23 +607,25 @@ void ui_menu_remove_folder::handle()
const ui_menu_event *m_event = process(0);
if (m_event != nullptr && m_event->itemref != nullptr && m_event->iptkey == IPT_UI_SELECT)
{
- int index = (FPTR)m_event->itemref - 1;
- std::string tmppath;
- for (size_t i = 0; i < item.size() - 2; i++)
- if (i != index)
- tmppath.append(item[i].text).append(";");
-
- tmppath.substr(0, tmppath.size() - 1);
- std::string error_string;
- if (machine().ui().options().exists(s_folders_entry[m_ref].option))
+ std::string tmppath, error_string;
+ for (int x = 0; x < m_folders.size(); ++x)
+ {
+ if (x != selected)
+ tmppath.append(m_folders[x]);
+ if (x < m_folders.size() - 1)
+ tmppath.append(";");
+ }
+
+ if (machine().ui().options().exists(s_folders[m_ref].option))
{
- machine().ui().options().set_value(s_folders_entry[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
+ machine().ui().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
}
- else {
- if (strcmp(machine().options().value(s_folders_entry[m_ref].option),tmppath.c_str())!=0)
+ else
+ {
+ if (strcmp(machine().options().value(s_folders[m_ref].option),tmppath.c_str())!=0)
{
- machine().options().set_value(s_folders_entry[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
- machine().options().mark_changed(s_folders_entry[m_ref].option);
+ machine().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
+ machine().options().mark_changed(s_folders[m_ref].option);
}
}
@@ -644,12 +640,9 @@ void ui_menu_remove_folder::handle()
void ui_menu_remove_folder::populate()
{
- path_iterator path(m_searchpath.c_str());
- std::string curpath;
int folders_count = 0;
-
- while (path.next(curpath, nullptr))
- item_append(curpath.c_str(), nullptr, 0, (void *)(FPTR)++folders_count);
+ for (auto & elem : m_folders)
+ item_append(elem.c_str(), nullptr, 0, (void *)(FPTR)++folders_count);
item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr);
@@ -664,7 +657,7 @@ void ui_menu_remove_folder::custom_render(void *selectedref, float top, float bo
{
float width;
ui_manager &mui = machine().ui();
- std::string tempbuf = std::string("Remove ").append(s_folders_entry[m_ref].name).append(" Folder");
+ std::string tempbuf = std::string(_("Remove ")).append(_(s_folders[m_ref].name)).append(_(" Folder"));
// get the size of the text
mui.draw_text_full(container, tempbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);