Previous 199869 Revisions Next

r44684 Friday 5th February, 2016 at 07:53:00 UTC by Miodrag Milanović
added UI parameter, option simple gives back old style start screen, features for configuration and in game stays same as with new (nw)
[scripts/src]emu.lua
[src/emu]emuopts.cpp emuopts.h
[src/emu/drivers]empty.cpp
[src/emu/ui]mainmenu.cpp optsmenu.cpp simpleselgame.cpp* simpleselgame.h*

trunk/scripts/src/emu.lua
r253195r253196
264264   MAME_DIR .. "src/emu/ui/selector.h",
265265   MAME_DIR .. "src/emu/ui/selgame.cpp",
266266   MAME_DIR .. "src/emu/ui/selgame.h",
267   MAME_DIR .. "src/emu/ui/simpleselgame.cpp",
268   MAME_DIR .. "src/emu/ui/simpleselgame.h",
267269   MAME_DIR .. "src/emu/ui/selsoft.cpp",
268270   MAME_DIR .. "src/emu/ui/selsoft.h",
269271   MAME_DIR .. "src/emu/ui/sndmenu.cpp",
trunk/src/emu/drivers/empty.cpp
r253195r253196
1111#include "emu.h"
1212#include "render.h"
1313#include "ui/selgame.h"
14#include "ui/simpleselgame.h"
1415
1516
1617//**************************************************************************
r253195r253196
2930   virtual void machine_start() override
3031   {
3132      // force the UI to show the game select screen
32      ui_menu_select_game::force_game_select(machine(), &machine().render().ui_container());
33      if (strcmp(machine().options().ui(),"simple")==0) {
34         ui_simple_menu_select_game::force_game_select(machine(), &machine().render().ui_container());
35      } else {
36         ui_menu_select_game::force_game_select(machine(), &machine().render().ui_container());         
37      }
3338   }
3439
3540   UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
trunk/src/emu/emuopts.cpp
r253195r253196
180180   { OPTION_CHEAT ";c",                                 "0",         OPTION_BOOLEAN,    "enable cheat subsystem" },
181181   { OPTION_SKIP_GAMEINFO,                              "0",         OPTION_BOOLEAN,    "skip displaying the information screen at startup" },
182182   { OPTION_UI_FONT,                                    "default",   OPTION_STRING,     "specify a font to use" },
183   { OPTION_UI,                                          "cabinet",   OPTION_STRING,     "type of UI (simple|cabinet)" },
183184   { OPTION_RAMSIZE ";ram",                             nullptr,        OPTION_STRING,     "size of RAM (if supported by driver)" },
184185   { OPTION_CONFIRM_QUIT,                               "0",         OPTION_BOOLEAN,    "display confirm quit screen on exit" },
185186   { OPTION_UI_MOUSE,                                   "1",         OPTION_BOOLEAN,    "display ui mouse cursor" },
trunk/src/emu/emuopts.h
r253195r253196
175175#define OPTION_CHEAT                "cheat"
176176#define OPTION_SKIP_GAMEINFO        "skip_gameinfo"
177177#define OPTION_UI_FONT              "uifont"
178#define OPTION_UI                   "ui"
178179#define OPTION_RAMSIZE              "ramsize"
179180
180181// core comm options
r253195r253196
350351   bool cheat() const { return bool_value(OPTION_CHEAT); }
351352   bool skip_gameinfo() const { return bool_value(OPTION_SKIP_GAMEINFO); }
352353   const char *ui_font() const { return value(OPTION_UI_FONT); }
354   const char *ui() const { return value(OPTION_UI); }
353355   const char *ram_size() const { return value(OPTION_RAMSIZE); }
354356
355357   // core comm options
trunk/src/emu/ui/mainmenu.cpp
r253195r253196
2323#include "ui/mainmenu.h"
2424#include "ui/miscmenu.h"
2525#include "ui/selgame.h"
26#include "ui/simpleselgame.h"
2627#include "ui/sliders.h"
2728#include "ui/slotopt.h"
2829#include "ui/tapectrl.h"
r253195r253196
284285         break;
285286
286287      case SELECT_GAME:
287         ui_menu::stack_push(global_alloc_clear<ui_menu_select_game>(machine(), container, nullptr));
288         if (strcmp(machine().options().ui(),"simple")==0) {
289            ui_menu::stack_push(global_alloc_clear<ui_simple_menu_select_game>(machine(), container, nullptr));
290         } else {
291            ui_menu::stack_push(global_alloc_clear<ui_menu_select_game>(machine(), container, nullptr));
292         }     
288293         break;
289294
290295      case BIOS_SELECTION:
trunk/src/emu/ui/optsmenu.cpp
r253195r253196
217217
218218void ui_menu_game_options::populate()
219219{
220   // set filter arrow
221   std::string fbuff;
220   if (strcmp(machine().options().ui(),"simple")!=0)
221   {   
222      // set filter arrow
223      std::string fbuff;
222224
223   // add filter item
224   UINT32 arrow_flags = get_arrow_flags((int)FILTER_FIRST, (int)FILTER_LAST, main_filters::actual);
225   item_append("Filter", main_filters::text[main_filters::actual], arrow_flags, (void *)(FPTR)FILTER_MENU);
225      // add filter item
226      UINT32 arrow_flags = get_arrow_flags((int)FILTER_FIRST, (int)FILTER_LAST, main_filters::actual);
227      item_append("Filter", main_filters::text[main_filters::actual], arrow_flags, (void *)(FPTR)FILTER_MENU);
226228
227   // add category subitem
228   if (main_filters::actual == FILTER_CATEGORY && !machine().inifile().ini_index.empty())
229   {
230      inifile_manager &inif = machine().inifile();
231      int afile = inif.current_file;
229      // add category subitem
230      if (main_filters::actual == FILTER_CATEGORY && !machine().inifile().ini_index.empty())
231      {
232         inifile_manager &inif = machine().inifile();
233         int afile = inif.current_file;
232234
233      arrow_flags = get_arrow_flags(0, inif.ini_index.size() - 1, afile);
234      fbuff = " ^!File";
235      convert_command_glyph(fbuff);
236      item_append(fbuff.c_str(), inif.actual_file().c_str(), arrow_flags, (void *)(FPTR)FILE_CATEGORY_FILTER);
235         arrow_flags = get_arrow_flags(0, inif.ini_index.size() - 1, afile);
236         fbuff = " ^!File";
237         convert_command_glyph(fbuff);
238         item_append(fbuff.c_str(), inif.actual_file().c_str(), arrow_flags, (void *)(FPTR)FILE_CATEGORY_FILTER);
237239
238      arrow_flags = get_arrow_flags(0, inif.ini_index[afile].category.size() - 1, inif.current_category);
239      fbuff = " ^!Category";
240      convert_command_glyph(fbuff);
241      item_append(fbuff.c_str(), inif.actual_category().c_str(), arrow_flags, (void *)(FPTR)CATEGORY_FILTER);
242   }
243   // add manufacturer subitem
244   else if (main_filters::actual == FILTER_MANUFACTURER && c_mnfct::ui.size() > 0)
245   {
246      arrow_flags = get_arrow_flags(0, c_mnfct::ui.size() - 1, c_mnfct::actual);
247      fbuff = "^!Manufacturer";
248      convert_command_glyph(fbuff);
249      item_append(fbuff.c_str(), c_mnfct::ui[c_mnfct::actual].c_str(), arrow_flags, (void *)(FPTR)MANUFACT_CAT_FILTER);
250   }
251   // add year subitem
252   else if (main_filters::actual == FILTER_YEAR && c_year::ui.size() > 0)
253   {
254      arrow_flags = get_arrow_flags(0, c_year::ui.size() - 1, c_year::actual);
255      fbuff.assign("^!Year");
256      convert_command_glyph(fbuff);
257      item_append(fbuff.c_str(), c_year::ui[c_year::actual].c_str(), arrow_flags, (void *)(FPTR)YEAR_CAT_FILTER);
258   }
259   // add screen subitem
260   else if (main_filters::actual == FILTER_SCREEN)
261   {
262      arrow_flags = get_arrow_flags(0, screen_filters::length - 1, screen_filters::actual);
263      fbuff = "^!Screen type";
264      convert_command_glyph(fbuff);
265      item_append(fbuff.c_str(), screen_filters::text[screen_filters::actual], arrow_flags, (void *)(FPTR)SCREEN_CAT_FILTER);
266   }
267   // add custom subitem
268   else if (main_filters::actual == FILTER_CUSTOM)
269   {
270      fbuff = "^!Setup custom filter";
271      convert_command_glyph(fbuff);
272      item_append(fbuff.c_str(), nullptr, 0, (void *)(FPTR)CUSTOM_FILTER);
273   }
240         arrow_flags = get_arrow_flags(0, inif.ini_index[afile].category.size() - 1, inif.current_category);
241         fbuff = " ^!Category";
242         convert_command_glyph(fbuff);
243         item_append(fbuff.c_str(), inif.actual_category().c_str(), arrow_flags, (void *)(FPTR)CATEGORY_FILTER);
244      }
245      // add manufacturer subitem
246      else if (main_filters::actual == FILTER_MANUFACTURER && c_mnfct::ui.size() > 0)
247      {
248         arrow_flags = get_arrow_flags(0, c_mnfct::ui.size() - 1, c_mnfct::actual);
249         fbuff = "^!Manufacturer";
250         convert_command_glyph(fbuff);
251         item_append(fbuff.c_str(), c_mnfct::ui[c_mnfct::actual].c_str(), arrow_flags, (void *)(FPTR)MANUFACT_CAT_FILTER);
252      }
253      // add year subitem
254      else if (main_filters::actual == FILTER_YEAR && c_year::ui.size() > 0)
255      {
256         arrow_flags = get_arrow_flags(0, c_year::ui.size() - 1, c_year::actual);
257         fbuff.assign("^!Year");
258         convert_command_glyph(fbuff);
259         item_append(fbuff.c_str(), c_year::ui[c_year::actual].c_str(), arrow_flags, (void *)(FPTR)YEAR_CAT_FILTER);
260      }
261      // add screen subitem
262      else if (main_filters::actual == FILTER_SCREEN)
263      {
264         arrow_flags = get_arrow_flags(0, screen_filters::length - 1, screen_filters::actual);
265         fbuff = "^!Screen type";
266         convert_command_glyph(fbuff);
267         item_append(fbuff.c_str(), screen_filters::text[screen_filters::actual], arrow_flags, (void *)(FPTR)SCREEN_CAT_FILTER);
268      }
269      // add custom subitem
270      else if (main_filters::actual == FILTER_CUSTOM)
271      {
272         fbuff = "^!Setup custom filter";
273         convert_command_glyph(fbuff);
274         item_append(fbuff.c_str(), nullptr, 0, (void *)(FPTR)CUSTOM_FILTER);
275      }
274276
275   item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr);
277      item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr);
276278
277   // add options items
278   item_append("Customize UI", nullptr, 0, (void *)(FPTR)CUSTOM_MENU);
279      // add options items
280      item_append("Customize UI", nullptr, 0, (void *)(FPTR)CUSTOM_MENU);
281   }
279282   item_append("Display Options", nullptr, 0, (void *)(FPTR)DISPLAY_MENU);
280283   item_append("Sound Options", nullptr, 0, (void *)(FPTR)SOUND_MENU);
281284   item_append("Miscellaneous Options", nullptr, 0, (void *)(FPTR)MISC_MENU);
trunk/src/emu/ui/simpleselgame.cpp
r0r253196
1// license:BSD-3-Clause
2// copyright-holders:Nicola Salmoria, Aaron Giles, Nathan Woods
3/***************************************************************************
4
5    ui/simpleselgame.c
6
7    Game selector
8
9***************************************************************************/
10
11#include "emu.h"
12#include "emuopts.h"
13#include "ui/ui.h"
14#include "ui/menu.h"
15#include "uiinput.h"
16#include "ui/simpleselgame.h"
17#include "ui/inputmap.h"
18#include "ui/miscmenu.h"
19#include "ui/optsmenu.h"
20#include "audit.h"
21#include <ctype.h>
22
23
24//-------------------------------------------------
25//  ctor
26//-------------------------------------------------
27
28ui_simple_menu_select_game::ui_simple_menu_select_game(running_machine &machine, render_container *container, const char *gamename) : ui_menu(machine, container), m_driverlist(driver_list::total() + 1)
29{
30   build_driver_list();
31   if(gamename)
32      strcpy(m_search, gamename);
33   m_matchlist[0] = -1;
34}
35
36
37//-------------------------------------------------
38//  dtor
39//-------------------------------------------------
40
41ui_simple_menu_select_game::~ui_simple_menu_select_game()
42{
43}
44
45
46
47//-------------------------------------------------
48//  build_driver_list - build a list of available
49//  drivers
50//-------------------------------------------------
51
52void ui_simple_menu_select_game::build_driver_list()
53{
54   // start with an empty list
55   m_drivlist = std::make_unique<driver_enumerator>(machine().options());
56   m_drivlist->exclude_all();
57
58   // open a path to the ROMs and find them in the array
59   file_enumerator path(machine().options().media_path());
60   const osd_directory_entry *dir;
61
62   // iterate while we get new objects
63   while ((dir = path.next()) != nullptr)
64   {
65      char drivername[50];
66      char *dst = drivername;
67      const char *src;
68
69      // build a name for it
70      for (src = dir->name; *src != 0 && *src != '.' && dst < &drivername[ARRAY_LENGTH(drivername) - 1]; src++)
71         *dst++ = tolower((UINT8)*src);
72      *dst = 0;
73
74      int drivnum = m_drivlist->find(drivername);
75      if (drivnum != -1)
76         m_drivlist->include(drivnum);
77   }
78
79   // now build the final list
80   m_drivlist->reset();
81   int listnum = 0;
82   while (m_drivlist->next())
83      m_driverlist[listnum++] = &m_drivlist->driver();
84
85   // NULL-terminate
86   m_driverlist[listnum] = nullptr;
87}
88
89
90
91//-------------------------------------------------
92//  handle - handle the game select menu
93//-------------------------------------------------
94
95void ui_simple_menu_select_game::handle()
96{
97   // ignore pause keys by swallowing them before we process the menu
98   machine().ui_input().pressed(IPT_UI_PAUSE);
99
100   // process the menu
101   const ui_menu_event *menu_event = process(0);
102   if (menu_event != nullptr && menu_event->itemref != nullptr)
103   {
104      // reset the error on any future menu_event
105      if (m_error)
106         m_error = false;
107
108      // handle selections
109      else
110      {
111         switch(menu_event->iptkey)
112         {
113            case IPT_UI_SELECT:
114               inkey_select(menu_event);
115               break;
116            case IPT_UI_CANCEL:
117               inkey_cancel(menu_event);
118               break;
119            case IPT_SPECIAL:
120               inkey_special(menu_event);
121               break;
122         }
123      }
124   }
125
126   // if we're in an error state, overlay an error message
127   if (m_error)
128      machine().ui().draw_text_box(container,
129                     "The selected game is missing one or more required ROM or CHD images. "
130                     "Please select a different game.\n\nPress any key to continue.",
131                     JUSTIFY_CENTER, 0.5f, 0.5f, UI_RED_COLOR);
132}
133
134
135//-------------------------------------------------
136//  inkey_select
137//-------------------------------------------------
138
139void ui_simple_menu_select_game::inkey_select(const ui_menu_event *menu_event)
140{
141   const game_driver *driver = (const game_driver *)menu_event->itemref;
142
143   // special case for configure inputs
144   if ((FPTR)driver == 1)
145      ui_menu::stack_push(global_alloc_clear<ui_menu_game_options>(machine(), container));
146
147   // anything else is a driver
148   else
149   {
150      // audit the game first to see if we're going to work
151      driver_enumerator enumerator(machine().options(), *driver);
152      enumerator.next();
153      media_auditor auditor(enumerator);
154      media_auditor::summary summary = auditor.audit_media(AUDIT_VALIDATE_FAST);
155
156      // if everything looks good, schedule the new driver
157      if (summary == media_auditor::CORRECT || summary == media_auditor::BEST_AVAILABLE || summary == media_auditor::NONE_NEEDED)
158      {
159         machine().manager().schedule_new_driver(*driver);
160         machine().schedule_hard_reset();
161         ui_menu::stack_reset(machine());
162      }
163
164      // otherwise, display an error
165      else
166      {
167         reset(UI_MENU_RESET_REMEMBER_REF);
168         m_error = true;
169      }
170   }
171}
172
173
174//-------------------------------------------------
175//  inkey_cancel
176//-------------------------------------------------
177
178void ui_simple_menu_select_game::inkey_cancel(const ui_menu_event *menu_event)
179{
180   // escape pressed with non-empty text clears the text
181   if (m_search[0] != 0)
182   {
183      // since we have already been popped, we must recreate ourself from scratch
184      ui_menu::stack_push(global_alloc_clear<ui_simple_menu_select_game>(machine(), container, nullptr));
185   }
186}
187
188
189//-------------------------------------------------
190//  inkey_special - typed characters append to the buffer
191//-------------------------------------------------
192
193void ui_simple_menu_select_game::inkey_special(const ui_menu_event *menu_event)
194{
195   // typed characters append to the buffer
196   int buflen = strlen(m_search);
197
198   // if it's a backspace and we can handle it, do so
199   if ((menu_event->unichar == 8 || menu_event->unichar == 0x7f) && buflen > 0)
200   {
201      *(char *)utf8_previous_char(&m_search[buflen]) = 0;
202      m_rerandomize = true;
203      reset(UI_MENU_RESET_SELECT_FIRST);
204   }
205
206   // if it's any other key and we're not maxed out, update
207   else if (menu_event->unichar >= ' ' && menu_event->unichar < 0x7f)
208   {
209      buflen += utf8_from_uchar(&m_search[buflen], ARRAY_LENGTH(m_search) - buflen, menu_event->unichar);
210      m_search[buflen] = 0;
211      reset(UI_MENU_RESET_SELECT_FIRST);
212   }
213}
214
215
216//-------------------------------------------------
217//  populate - populate the game select menu
218//-------------------------------------------------
219
220void ui_simple_menu_select_game::populate()
221{
222   int matchcount;
223   int curitem;
224
225   for (curitem = matchcount = 0; m_driverlist[curitem] != nullptr && matchcount < VISIBLE_GAMES_IN_LIST; curitem++)
226      if (!(m_driverlist[curitem]->flags & MACHINE_NO_STANDALONE))
227         matchcount++;
228
229   // if nothing there, add a single multiline item and return
230   if (matchcount == 0)
231   {
232      std::string txt;
233      strprintf(txt, "No %s found. Please check the rompath specified in the %s.ini file.\n\n"
234               "If this is your first time using %s, please see the config.txt file in "
235               "the docs directory for information on configuring %s.",
236               emulator_info::get_gamesnoun(),
237               emulator_info::get_configname(),
238               emulator_info::get_appname(),emulator_info::get_appname() );
239      item_append(txt.c_str(), nullptr, MENU_FLAG_MULTILINE | MENU_FLAG_REDTEXT, nullptr);
240      return;
241   }
242
243   // otherwise, rebuild the match list
244   assert(m_drivlist != nullptr);
245   if (m_search[0] != 0 || m_matchlist[0] == -1 || m_rerandomize)
246      m_drivlist->find_approximate_matches(m_search, matchcount, m_matchlist);
247   m_rerandomize = false;
248
249   // iterate over entries
250   for (curitem = 0; curitem < matchcount; curitem++)
251   {
252      int curmatch = m_matchlist[curitem];
253      if (curmatch != -1)
254      {
255         int cloneof = m_drivlist->non_bios_clone(curmatch);
256         item_append(m_drivlist->driver(curmatch).name, m_drivlist->driver(curmatch).description, (cloneof == -1) ? 0 : MENU_FLAG_INVERT, (void *)&m_drivlist->driver(curmatch));
257      }
258   }
259
260   // if we're forced into this, allow general input configuration as well
261   if (ui_menu::stack_has_special_main_menu())
262   {
263      item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr);
264      item_append("Configure Options", nullptr, 0, (void *)1);
265   }
266
267   // configure the custom rendering
268   customtop = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
269   custombottom = 4.0f * machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
270}
271
272
273//-------------------------------------------------
274//  custom_render - perform our special rendering
275//-------------------------------------------------
276
277void ui_simple_menu_select_game::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
278{
279   const game_driver *driver;
280   float width, maxwidth;
281   float x1, y1, x2, y2;
282   std::string tempbuf[5];
283   rgb_t color;
284   int line;
285
286   // display the current typeahead
287   if (m_search[0] != 0)
288      strprintf(tempbuf[0], "Type name or select: %s_", m_search);
289   else
290      strprintf(tempbuf[0],"Type name or select: (random)");
291
292   // get the size of the text
293   machine().ui().draw_text_full(container, tempbuf[0].c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
294                  DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
295   width += 2 * UI_BOX_LR_BORDER;
296   maxwidth = MAX(width, origx2 - origx1);
297
298   // compute our bounds
299   x1 = 0.5f - 0.5f * maxwidth;
300   x2 = x1 + maxwidth;
301   y1 = origy1 - top;
302   y2 = origy1 - UI_BOX_TB_BORDER;
303
304   // draw a box
305   machine().ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
306
307   // take off the borders
308   x1 += UI_BOX_LR_BORDER;
309   x2 -= UI_BOX_LR_BORDER;
310   y1 += UI_BOX_TB_BORDER;
311
312   // draw the text within it
313   machine().ui().draw_text_full(container, tempbuf[0].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
314                  DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
315
316   // determine the text to render below
317   driver = ((FPTR)selectedref > 1) ? (const game_driver *)selectedref : nullptr;
318   if ((FPTR)driver > 1)
319   {
320      const char *gfxstat, *soundstat;
321
322      // first line is game name
323      strprintf(tempbuf[0],"%-.100s", driver->description);
324
325      // next line is year, manufacturer
326      strprintf(tempbuf[1], "%s, %-.100s", driver->year, driver->manufacturer);
327
328      // next line source path
329      strprintf(tempbuf[2],"Driver: %-.100s", core_filename_extract_base(driver->source_file).c_str());
330
331      // next line is overall driver status
332      if (driver->flags & MACHINE_NOT_WORKING)
333         tempbuf[3].assign("Overall: NOT WORKING");
334      else if (driver->flags & MACHINE_UNEMULATED_PROTECTION)
335         tempbuf[3].assign("Overall: Unemulated Protection");
336      else
337         tempbuf[3].assign("Overall: Working");
338
339      // next line is graphics, sound status
340      if (driver->flags & (MACHINE_IMPERFECT_GRAPHICS | MACHINE_WRONG_COLORS | MACHINE_IMPERFECT_COLORS))
341         gfxstat = "Imperfect";
342      else
343         gfxstat = "OK";
344
345      if (driver->flags & MACHINE_NO_SOUND)
346         soundstat = "Unimplemented";
347      else if (driver->flags & MACHINE_IMPERFECT_SOUND)
348         soundstat = "Imperfect";
349      else
350         soundstat = "OK";
351
352      strprintf(tempbuf[4], "Gfx: %s, Sound: %s", gfxstat, soundstat);
353   }
354   else
355   {
356      const char *s = emulator_info::get_copyright();
357      line = 0;
358
359      // first line is version string
360      strprintf(tempbuf[line++], "%s %s", emulator_info::get_appname(), build_version);
361
362      // output message
363      while (line < ARRAY_LENGTH(tempbuf))
364      {
365         if (!(*s == 0 || *s == '\n'))
366            tempbuf[line].push_back(*s);
367
368         if (*s == '\n')
369         {
370            line++;
371            s++;
372         } else if (*s != 0)
373            s++;
374         else
375            line++;
376      }
377   }
378
379   // get the size of the text
380   maxwidth = origx2 - origx1;
381   for (line = 0; line < 4; line++)
382   {
383      machine().ui().draw_text_full(container, tempbuf[line].c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
384                     DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
385      width += 2 * UI_BOX_LR_BORDER;
386      maxwidth = MAX(maxwidth, width);
387   }
388
389   // compute our bounds
390   x1 = 0.5f - 0.5f * maxwidth;
391   x2 = x1 + maxwidth;
392   y1 = origy2 + UI_BOX_TB_BORDER;
393   y2 = origy2 + bottom;
394
395   // draw a box
396   color = UI_BACKGROUND_COLOR;
397   if (driver != nullptr)
398      color = UI_GREEN_COLOR;
399   if (driver != nullptr && (driver->flags & (MACHINE_IMPERFECT_GRAPHICS | MACHINE_WRONG_COLORS | MACHINE_IMPERFECT_COLORS | MACHINE_NO_SOUND | MACHINE_IMPERFECT_SOUND)) != 0)
400      color = UI_YELLOW_COLOR;
401   if (driver != nullptr && (driver->flags & (MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION)) != 0)
402      color = UI_RED_COLOR;
403   machine().ui().draw_outlined_box(container, x1, y1, x2, y2, color);
404
405   // take off the borders
406   x1 += UI_BOX_LR_BORDER;
407   x2 -= UI_BOX_LR_BORDER;
408   y1 += UI_BOX_TB_BORDER;
409
410   // draw all lines
411   for (line = 0; line < 4; line++)
412   {
413      machine().ui().draw_text_full(container, tempbuf[line].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
414                     DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
415      y1 += machine().ui().get_line_height();
416   }
417}
418
419
420//-------------------------------------------------
421//  force_game_select - force the game
422//  select menu to be visible and inescapable
423//-------------------------------------------------
424
425void ui_simple_menu_select_game::force_game_select(running_machine &machine, render_container *container)
426{
427   char *gamename = (char *)machine.options().system_name();
428
429   // reset the menu stack
430   ui_menu::stack_reset(machine);
431
432   // add the quit entry followed by the game select entry
433   ui_menu *quit = global_alloc_clear<ui_menu_quit_game>(machine, container);
434   quit->set_special_main_menu(true);
435   ui_menu::stack_push(quit);
436   ui_menu::stack_push(global_alloc_clear<ui_simple_menu_select_game>(machine, container, gamename));
437
438   // force the menus on
439   machine.ui().show_menu();
440
441   // make sure MAME is paused
442   machine.pause();
443}
trunk/src/emu/ui/simpleselgame.h
r0r253196
1// license:BSD-3-Clause
2// copyright-holders:Nicola Salmoria, Aaron Giles, Nathan Woods
3/***************************************************************************
4
5    ui/selgame.h
6
7    Game selector
8
9***************************************************************************/
10
11#pragma once
12
13#ifndef __UI_SIMPLESELGAME_H__
14#define __UI_SIMPLESELGAME_H__
15
16#include "drivenum.h"
17#include "menu.h"
18
19class ui_simple_menu_select_game : public ui_menu {
20public:
21   ui_simple_menu_select_game(running_machine &machine, render_container *container, const char *gamename);
22   virtual ~ui_simple_menu_select_game();
23   virtual void populate() override;
24   virtual void handle() override;
25   virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override;
26
27   // force game select menu
28   static void force_game_select(running_machine &machine, render_container *container);
29
30private:
31   // internal state
32   enum { VISIBLE_GAMES_IN_LIST = 15 };
33   UINT8                   m_error;
34   bool                    m_rerandomize;
35   char                    m_search[40];
36   int                     m_matchlist[VISIBLE_GAMES_IN_LIST];
37   std::vector<const game_driver *> m_driverlist;
38   std::unique_ptr<driver_enumerator> m_drivlist;
39
40   // internal methods
41   void build_driver_list();
42   void inkey_select(const ui_menu_event *menu_event);
43   void inkey_cancel(const ui_menu_event *menu_event);
44   void inkey_special(const ui_menu_event *menu_event);
45};
46
47#endif  /* __UI_SELGAME_H__ */


Previous 199869 Revisions Next


© 1997-2024 The MAME Team