Previous 199869 Revisions Next

r44685 Friday 5th February, 2016 at 13:24:17 UTC by Miodrag Milanović
Keep ui options separate from emulator ini file. (nw)
TODO: Need fixing saving of some core settings that could be changed by UI
[src/emu]emuopts.cpp emuopts.h machine.cpp
[src/emu/ui]auditmenu.cpp custmenu.cpp custui.cpp datfile.cpp dirmenu.cpp inifile.cpp mainmenu.cpp menu.cpp optsmenu.cpp optsmenu.h selgame.cpp selsoft.cpp ui.cpp ui.h

trunk/src/emu/emuopts.cpp
r253196r253197
202202//-------------------------------------------------
203203
204204emu_options::emu_options()
205: ui_options()
205: core_options()
206206, m_coin_impulse(0)
207207, m_joystick_contradictory(false)
208208, m_sleep(true)
trunk/src/emu/emuopts.h
r253196r253197
1313#ifndef __EMUOPTS_H__
1414#define __EMUOPTS_H__
1515
16#include "ui/moptions.h"
16#include "options.h"
1717
18
1918//**************************************************************************
2019//  CONSTANTS
2120//**************************************************************************
r253196r253197
2726   OPTION_PRIORITY_CMDLINE = OPTION_PRIORITY_HIGH,
2827
2928   // INI-based options are NORMAL priority, in increasing order:
30   OPTION_PRIORITY_MAME_INI = OPTION_PRIORITY_NORMAL,
29   OPTION_PRIORITY_INI = OPTION_PRIORITY_NORMAL,
30   OPTION_PRIORITY_MAME_INI,
3131   OPTION_PRIORITY_DEBUG_INI,
3232   OPTION_PRIORITY_ORIENTATION_INI,
3333   OPTION_PRIORITY_SYSTYPE_INI,
r253196r253197
3535   OPTION_PRIORITY_SOURCE_INI,
3636   OPTION_PRIORITY_GPARENT_INI,
3737   OPTION_PRIORITY_PARENT_INI,
38   OPTION_PRIORITY_DRIVER_INI,
39   OPTION_PRIORITY_INI
38   OPTION_PRIORITY_DRIVER_INI
4039};
4140
4241// core options
r253196r253197
202201class software_part;
203202
204203
205class emu_options : public ui_options
204class emu_options : public core_options
206205{
207206   static const UINT32 OPTION_FLAG_DEVICE = 0x80000000;
208207
trunk/src/emu/machine.cpp
r253196r253197
231231   // init the osd layer
232232   m_manager.osd().init(*this);
233233
234   // start the inifile manager
235   m_inifile = std::make_unique<inifile_manager>(*this);
236
237234   // create the video manager
238235   m_video = std::make_unique<video_manager>(*this);
239236   m_ui = std::make_unique<ui_manager>(*this);
237   m_ui->init();
240238
239   // start the inifile manager
240   m_inifile = std::make_unique<inifile_manager>(*this);
241
241242   // initialize the base time (needed for doing record/playback)
242243   ::time(&m_base_time);
243244
trunk/src/emu/ui/auditmenu.cpp
r253196r253197
173173void ui_menu_audit::save_available_machines()
174174{
175175   // attempt to open the output file
176   emu_file file(machine().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
176   emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
177177   if (file.open(emulator_info::get_configname(), "_avail.ini") == FILERR_NONE)
178178   {
179179      // generate header
trunk/src/emu/ui/custmenu.cpp
r253196r253197
272272void ui_menu_custom_filter::save_custom_filters()
273273{
274274   // attempt to open the output file
275   emu_file file(machine().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
275   emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
276276   if (file.open("custom_", emulator_info::get_configname(), "_filter.ini") == FILERR_NONE)
277277   {
278278      // generate custom filters info
r253196r253197
587587void ui_menu_swcustom_filter::save_sw_custom_filters()
588588{
589589   // attempt to open the output file
590   emu_file file(machine().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
590   emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
591591   if (file.open("custom_", m_driver->name, "_filter.ini") == FILERR_NONE)
592592   {
593593      // generate custom filters info
trunk/src/emu/ui/custui.cpp
r253196r253197
140140
141141ui_menu_font_ui::ui_menu_font_ui(running_machine &machine, render_container *container) : ui_menu(machine, container)
142142{
143   emu_options &moptions = machine.options();
143   ui_options &moptions = machine.ui().options();
144144#ifdef UI_WINDOWS
145145
146   std::string name(moptions.ui_font());
146   std::string name(machine.options().ui_font());
147147   list();
148148
149149   m_bold = (strreplace(name, "[B]", "") + strreplace(name, "[b]", "") > 0);
r253196r253197
163163   m_info_size = moptions.infos_size();
164164   m_font_size = moptions.font_rows();
165165
166   for (emu_options::entry *f_entry = moptions.first(); f_entry != nullptr; f_entry = f_entry->next())
166   for (ui_options::entry *f_entry = moptions.first(); f_entry != nullptr; f_entry = f_entry->next())
167167   {
168168      const char *name = f_entry->name();
169169      if (name && strlen(name) && !strcmp(OPTION_INFOS_SIZE, f_entry->name()))
r253196r253197
225225ui_menu_font_ui::~ui_menu_font_ui()
226226{
227227   std::string error_string;
228   emu_options &moptions = machine().options();
228   ui_options &moptions = machine().ui().options();
229229
230230#ifdef UI_WINDOWS
231231   std::string name(m_fonts[m_actual]);
r253196r253197
655655
656656void ui_menu_colors_ui::restore_colors()
657657{
658   emu_options options;
658   ui_options options;
659659   for (int index = 1; index < MUI_RESTORE; index++)
660660      m_color_table[index].color = rgb_t((UINT32)strtoul(options.value(m_color_table[index].option), nullptr, 16));
661661}
trunk/src/emu/ui/datfile.cpp
r253196r253197
1010
1111#include "emu.h"
1212#include "drivenum.h"
13#include "ui/ui.h"
1314#include "ui/datfile.h"
1415#include "ui/utils.h"
1516
r253196r253197
5657//-------------------------------------------------
5758datfile_manager::datfile_manager(running_machine &machine) : m_machine(machine)
5859{
59   if (machine.options().enabled_dats() && first_run)
60   if (machine.ui().options().enabled_dats() && first_run)
6061   {
6162      first_run = false;
6263      if (parseopen("mameinfo.dat"))
r253196r253197
539540   // MAME core file parsing functions fail in recognizing UNICODE chars in UTF-8 without BOM,
540541   // so it's better and faster use standard C fileio functions.
541542
542   emu_file file(machine().options().history_path(), OPEN_FLAG_READ);
543   emu_file file(machine().ui().options().history_path(), OPEN_FLAG_READ);
543544   if (file.open(filename) != FILERR_NONE)
544545      return false;
545546
trunk/src/emu/ui/dirmenu.cpp
r253196r253197
326326
327327ui_menu_directory::~ui_menu_directory()
328328{
329   save_game_options(machine());
329   save_ui_options(machine());
330330   ui_globals::reset = true;
331331}
332332
trunk/src/emu/ui/inifile.cpp
r253196r253197
99***************************************************************************/
1010
1111#include "emu.h"
12#include "ui/ui.h"
1213#include "ui/inifile.h"
1314#include "softlist.h"
1415#include "drivenum.h"
r253196r253197
3839void inifile_manager::directory_scan()
3940{
4041   // open extra INIs folder
41   file_enumerator path(machine().options().extraini_path());
42   file_enumerator path(machine().ui().options().extraini_path());
4243   const osd_directory_entry *dir;
4344
4445   // loop into folder's file
r253196r253197
149150   // MAME core file parsing functions fail in recognizing UNICODE chars in UTF-8 without BOM,
150151   // so it's better and faster use standard C fileio functions.
151152
152   emu_file file(machine().options().extraini_path(), OPEN_FLAG_READ);
153   emu_file file(machine().ui().options().extraini_path(), OPEN_FLAG_READ);
153154   if (file.open(filename) != FILERR_NONE)
154155      return false;
155156
r253196r253197
357358
358359void favorite_manager::parse_favorite()
359360{
360   emu_file file(machine().options().ui_path(), OPEN_FLAG_READ);
361   emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_READ);
361362   if (file.open(favorite_filename) == FILERR_NONE)
362363   {
363364      char readbuf[1024];
r253196r253197
416417void favorite_manager::save_favorite_games()
417418{
418419   // attempt to open the output file
419   emu_file file(machine().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
420   emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
420421   if (file.open(favorite_filename) == FILERR_NONE)
421422   {
422423      if (m_list.empty())
trunk/src/emu/ui/mainmenu.cpp
r253196r253197
137137      item_append("Cheat", nullptr, 0, (void *)CHEAT);
138138
139139   /* add history menu */
140   if (machine().options().enabled_dats())
140   if (machine().ui().options().enabled_dats())
141141      item_append("History Info", nullptr, 0, (void *)HISTORY);
142142
143143   // add software history menu
144   if ((machine().system().flags & MACHINE_TYPE_ARCADE) == 0 && machine().options().enabled_dats())
144   if ((machine().system().flags & MACHINE_TYPE_ARCADE) == 0 && machine().ui().options().enabled_dats())
145145   {
146146      image_interface_iterator iter(machine().root_device());
147147      for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
r253196r253197
156156   }
157157
158158   /* add mameinfo / messinfo menu */
159   if (machine().options().enabled_dats())
159   if (machine().ui().options().enabled_dats())
160160   {
161161      if ((machine().system().flags & MACHINE_TYPE_ARCADE) != 0)
162162         item_append("MameInfo", nullptr, 0, (void *)MAMEINFO);
r253196r253197
165165   }
166166
167167   /* add sysinfo menu */
168   if ((machine().system().flags & MACHINE_TYPE_ARCADE) == 0 && machine().options().enabled_dats())
168   if ((machine().system().flags & MACHINE_TYPE_ARCADE) == 0 && machine().ui().options().enabled_dats())
169169      item_append("SysInfo", nullptr, 0, (void *)SYSINFO);
170170
171171   /* add command list menu */
172   if ((machine().system().flags & MACHINE_TYPE_ARCADE) != 0 && machine().options().enabled_dats())
172   if ((machine().system().flags & MACHINE_TYPE_ARCADE) != 0 && machine().ui().options().enabled_dats())
173173      item_append("Commands Info", nullptr, 0, (void *)COMMAND);
174174
175175   /* add story menu */
176   if ((machine().system().flags & MACHINE_TYPE_ARCADE) != 0 && machine().options().enabled_dats())
176   if ((machine().system().flags & MACHINE_TYPE_ARCADE) != 0 && machine().ui().options().enabled_dats())
177177      item_append("Mamescores", nullptr, 0, (void *)STORYINFO);
178178
179179   item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr);
trunk/src/emu/ui/menu.cpp
r253196r253197
465465   float mouse_x = -1, mouse_y = -1;
466466   bool history_flag = ((item[0].flags & MENU_FLAG_UI_HISTORY) != 0);
467467
468   if (machine().options().use_background_image() && &machine().system() == &GAME_NAME(___empty) && bgrnd_bitmap->valid() && !noimage)
468   if (machine().ui().options().use_background_image() && &machine().system() == &GAME_NAME(___empty) && bgrnd_bitmap->valid() && !noimage)
469469      container->add_quad(0.0f, 0.0f, 1.0f, 1.0f, ARGB_WHITE, bgrnd_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
470470
471471   // compute the width and height of the full menu
r253196r253197
13051305   bgrnd_bitmap = std::make_unique<bitmap_argb32>(0, 0);
13061306   bgrnd_texture = mrender.texture_alloc(render_texture::hq_scale);
13071307
1308   emu_options &mopt = machine.options();
1308   ui_options &mopt = machine.ui().options();
13091309   if (mopt.use_background_image() && &machine.system() == &GAME_NAME(___empty))
13101310   {
13111311      emu_file backgroundfile(".", OPEN_FLAG_READ);
r253196r253197
13721372   ui_manager &mui = machine().ui();
13731373
13741374   // draw background image if available
1375   if (machine().options().use_background_image() && bgrnd_bitmap->valid())
1375   if (machine().ui().options().use_background_image() && bgrnd_bitmap->valid())
13761376      container->add_quad(0.0f, 0.0f, 1.0f, 1.0f, ARGB_WHITE, bgrnd_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
13771377
13781378   hover = item.size() + 1;
r253196r253197
22072207      int dest_yPixel = tmp_bitmap->height();
22082208
22092209      // force 4:3 ratio min
2210      if (machine().options().forced_4x3_snapshot() && ratioI < 0.75f && ui_globals::curimage_view == SNAPSHOT_VIEW)
2210      if (machine().ui().options().forced_4x3_snapshot() && ratioI < 0.75f && ui_globals::curimage_view == SNAPSHOT_VIEW)
22112211      {
22122212         // smaller ratio will ensure that the image fits in the view
22132213         dest_yPixel = tmp_bitmap->width() * 0.75f;
r253196r253197
22172217         dest_yPixel *= ratio;
22182218      }
22192219      // resize the bitmap if necessary
2220      else if (ratioW < 1 || ratioH < 1 || (machine().options().enlarge_snaps() && !no_available))
2220      else if (ratioW < 1 || ratioH < 1 || (machine().ui().options().enlarge_snaps() && !no_available))
22212221      {
22222222         // smaller ratio will ensure that the image fits in the view
22232223         ratio = MIN(ratioW, ratioH);
r253196r253197
23362336      }
23372337
23382338      // get search path
2339      path_iterator path(machine().options().icons_directory());
2339      path_iterator path(machine().ui().options().icons_directory());
23402340      std::string curpath;
2341      std::string searchstr(machine().options().icons_directory());
2341      std::string searchstr(machine().ui().options().icons_directory());
23422342
23432343      // iterate over path and add path for zipped formats
23442344      while (path.next(curpath))
r253196r253197
24462446   float gutter_width = lr_arrow_width * 1.3f;
24472447   int itemnum, linenum;
24482448
2449   if (machine().options().use_background_image() && machine().options().system() == nullptr && bgrnd_bitmap->valid())
2449   if (machine().ui().options().use_background_image() && machine().options().system() == nullptr && bgrnd_bitmap->valid())
24502450      container->add_quad(0.0f, 0.0f, 1.0f, 1.0f, ARGB_WHITE, bgrnd_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
24512451
24522452   // compute the width and height of the full menu
trunk/src/emu/ui/optsmenu.cpp
r253196r253197
3939ui_menu_game_options::~ui_menu_game_options()
4040{
4141   ui_menu::menu_stack->reset(UI_MENU_RESET_SELECT_FIRST);
42   save_game_options(machine());
42   save_ui_options(machine());
4343   ui_globals::switch_image = true;
4444}
4545
r253196r253197
323323}
324324
325325//-------------------------------------------------
326//  save game options
326//  save ui options
327327//-------------------------------------------------
328328
329void save_game_options(running_machine &machine)
329void save_ui_options(running_machine &machine)
330330{
331331   // attempt to open the output file
332332   emu_file file(machine.options().ini_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
333   if (file.open(emulator_info::get_configname(), ".ini") == FILERR_NONE)
333   if (file.open("ui.ini") == FILERR_NONE)
334334   {
335335      // generate the updated INI
336      std::string initext = machine.options().output_ini();
336      std::string initext = machine.ui().options().output_ini();
337337      file.puts(initext.c_str());
338338      file.close();
339339   }
340340   else
341      machine.popmessage("**Error to save %s.ini**", emulator_info::get_configname());
341      machine.popmessage("**Error to save ui.ini**", emulator_info::get_configname());
342342}
trunk/src/emu/ui/optsmenu.h
r253196r253197
4343};
4444
4545// save options to file
46void save_game_options(running_machine &machine);
46void save_ui_options(running_machine &machine);
4747
4848#endif /* __UI_OPTSMENU_H__ */
trunk/src/emu/ui/selgame.cpp
r253196r253197
108108ui_menu_select_game::ui_menu_select_game(running_machine &machine, render_container *container, const char *gamename) : ui_menu(machine, container)
109109{
110110   std::string error_string, last_filter, sub_filter;
111   emu_options &moptions = machine.options();
111   ui_options &moptions = machine.ui().options();
112112
113113   // load drivers cache
114114   load_cache_info();
r253196r253197
185185   std::string error_string, last_driver;
186186   const game_driver *driver = nullptr;
187187   ui_software_info *swinfo = nullptr;
188   emu_options &mopt = machine().options();
188   ui_options &mopt = machine().ui().options();
189189   if (main_filters::actual == FILTER_FAVORITE_GAME)
190190      swinfo = (selected >= 0 && selected < item.size()) ? (ui_software_info *)item[selected].ref : nullptr;
191191   else
r253196r253197
208208   mopt.set_value(OPTION_LAST_USED_FILTER, filter.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
209209   mopt.set_value(OPTION_LAST_USED_MACHINE, last_driver.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
210210   mopt.set_value(OPTION_HIDE_PANELS, ui_globals::panels_status, OPTION_PRIORITY_CMDLINE, error_string);
211   save_game_options(machine());
211   save_ui_options(machine());
212212}
213213
214214//-------------------------------------------------
r253196r253197
218218void ui_menu_select_game::handle()
219219{
220220   bool check_filter = false;
221   bool enabled_dats = machine().options().enabled_dats();
221   bool enabled_dats = machine().ui().options().enabled_dats();
222222
223223   // if i have to load datfile, performe an hard reset
224224   if (ui_globals::reset)
r253196r253197
10231023         }
10241024
10251025         std::vector<s_bios> biosname;
1026         if (!machine().options().skip_bios_menu() && has_multiple_bios(driver, biosname))
1026         if (!machine().ui().options().skip_bios_menu() && has_multiple_bios(driver, biosname))
10271027            ui_menu::stack_push(global_alloc_clear<ui_bios_selection>(machine(), container, biosname, (void *)driver, false, false));
10281028         else
10291029         {
r253196r253197
10511051void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event)
10521052{
10531053   ui_software_info *ui_swinfo = (ui_software_info *)m_event->itemref;
1054   emu_options &mopt = machine().options();
1054   ui_options &mopt = machine().ui().options();
10551055
10561056   // special case for configure options
10571057   if ((FPTR)ui_swinfo == 1)
r253196r253197
10641064   else if (ui_swinfo->startempty == 1)
10651065   {
10661066      // audit the game first to see if we're going to work
1067      driver_enumerator enumerator(mopt, *ui_swinfo->driver);
1067      driver_enumerator enumerator(machine().options(), *ui_swinfo->driver);
10681068      enumerator.next();
10691069      media_auditor auditor(enumerator);
10701070      media_auditor::summary summary = auditor.audit_media(AUDIT_VALIDATE_FAST);
r253196r253197
10971097   else
10981098   {
10991099      // first validate
1100      driver_enumerator drv(mopt, *ui_swinfo->driver);
1100      driver_enumerator drv(machine().options(), *ui_swinfo->driver);
11011101      media_auditor auditor(drv);
11021102      drv.next();
11031103      software_list_device *swlist = software_list_device::find_by_name(drv.config(), ui_swinfo->listname.c_str());
r253196r253197
15411541   strcatprintf(buffer, "Requires CHD: %s\n", (driver_cache[idx].b_chd ? "Yes" : "No"));
15421542
15431543   // audit the game first to see if we're going to work
1544   if (machine().options().info_audit())
1544   if (machine().ui().options().info_audit())
15451545   {
15461546      driver_enumerator enumerator(machine().options(), *driver);
15471547      enumerator.next();
r253196r253197
15691569void ui_menu_select_game::inkey_export()
15701570{
15711571   std::string filename("exported");
1572   emu_file infile(machine().options().ui_path(), OPEN_FLAG_READ);
1572   emu_file infile(machine().ui().options().ui_path(), OPEN_FLAG_READ);
15731573   if (infile.open(filename.c_str(), ".xml") == FILERR_NONE)
15741574      for (int seq = 0; ; ++seq)
15751575      {
r253196r253197
15831583      }
15841584
15851585   // attempt to open the output file
1586   emu_file file(machine().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
1586   emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
15871587   if (file.open(filename.c_str(), ".xml") == FILERR_NONE)
15881588   {
15891589      FILE *pfile;
r253196r253197
16251625void ui_menu_select_game::save_cache_info()
16261626{
16271627   // attempt to open the output file
1628   emu_file file(machine().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
1628   emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
16291629
16301630   if (file.open("info_", emulator_info::get_configname(), ".ini") == FILERR_NONE)
16311631   {
r253196r253197
17161716   driver_cache.resize(driver_list::total() + 1);
17171717
17181718   // try to load driver cache
1719   emu_file file(machine().options().ui_path(), OPEN_FLAG_READ);
1719   emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_READ);
17201720   if (file.open("info_", emulator_info::get_configname(), ".ini") != FILERR_NONE)
17211721   {
17221722      save_cache_info();
r253196r253197
17881788bool ui_menu_select_game::load_available_machines()
17891789{
17901790   // try to load available drivers from file
1791   emu_file file(machine().options().ui_path(), OPEN_FLAG_READ);
1791   emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_READ);
17921792   if (file.open(emulator_info::get_configname(), "_avail.ini") != FILERR_NONE)
17931793      return false;
17941794
r253196r253197
18401840void ui_menu_select_game::load_custom_filters()
18411841{
18421842   // attempt to open the output file
1843   emu_file file(machine().options().ui_path(), OPEN_FLAG_READ);
1843   emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_READ);
18441844   if (file.open("custom_", emulator_info::get_configname(), "_filter.ini") == FILERR_NONE)
18451845   {
18461846      char buffer[MAX_CHAR_INFO];
r253196r253197
20662066   static std::string buffer;
20672067   std::vector<int> xstart;
20682068   std::vector<int> xend;
2069   float text_size = machine().options().infos_size();
2069   float text_size = machine().ui().options().infos_size();
20702070   const game_driver *driver = nullptr;
20712071   ui_software_info *soft = nullptr;
20722072   bool is_favorites = ((item[0].flags & MENU_FLAG_UI_FAVORITE) != 0);
trunk/src/emu/ui/selsoft.cpp
r253196r253197
213213      }
214214
215215      // handle UI_HISTORY
216      else if (m_event->iptkey == IPT_UI_HISTORY && machine().options().enabled_dats())
216      else if (m_event->iptkey == IPT_UI_HISTORY && machine().ui().options().enabled_dats())
217217      {
218218         ui_software_info *ui_swinfo = (ui_software_info *)m_event->itemref;
219219
r253196r253197
817817void ui_menu_select_software::inkey_select(const ui_menu_event *m_event)
818818{
819819   ui_software_info *ui_swinfo = (ui_software_info *)m_event->itemref;
820   emu_options &mopt = machine().options();
820   ui_options &mopt = machine().ui().options();
821821
822822   if (ui_swinfo->startempty == 1)
823823   {
r253196r253197
925925void ui_menu_select_software::load_sw_custom_filters()
926926{
927927   // attempt to open the output file
928   emu_file file(machine().options().ui_path(), OPEN_FLAG_READ);
928   emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_READ);
929929   if (file.open("custom_", m_driver->name, "_filter.ini") == FILERR_NONE)
930930   {
931931      char buffer[MAX_CHAR_INFO];
r253196r253197
14171417   static std::string buffer;
14181418   std::vector<int> xstart;
14191419   std::vector<int> xend;
1420   float text_size = machine().options().infos_size();
1420   float text_size = machine().ui().options().infos_size();
14211421   ui_software_info *soft = ((FPTR)selectedref > 2) ? (ui_software_info *)selectedref : nullptr;
14221422   static ui_software_info *oldsoft = nullptr;
14231423   static int old_sw_view = -1;
r253196r253197
18761876{
18771877   // process the menu
18781878   const ui_menu_event *event = process(0);
1879   emu_options &moptions = machine().options();
1879   ui_options &moptions = machine().ui().options();
18801880   if (event != nullptr && event->iptkey == IPT_UI_SELECT && event->itemref != nullptr)
18811881      for (auto & elem : m_bios)
18821882         if ((void*)&elem.name == event->itemref)
r253196r253197
19051905               ui_software_info *ui_swinfo = (ui_software_info *)m_driver;
19061906               std::string error;
19071907               machine().options().set_value("bios", elem.id, OPTION_PRIORITY_CMDLINE, error);
1908               driver_enumerator drivlist(moptions, *ui_swinfo->driver);
1908               driver_enumerator drivlist(machine().options(), *ui_swinfo->driver);
19091909               drivlist.next();
19101910               software_list_device *swlist = software_list_device::find_by_name(drivlist.config(), ui_swinfo->listname.c_str());
19111911               software_info *swinfo = swlist->find(ui_swinfo->shortname.c_str());
trunk/src/emu/ui/ui.cpp
r253196r253197
160160***************************************************************************/
161161
162162//-------------------------------------------------
163//  load ui options
164//-------------------------------------------------
165
166static void load_ui_options(running_machine &machine)
167{
168   // parse the file
169   std::string error;
170   // attempt to open the output file
171   emu_file file(machine.options().ini_path(), OPEN_FLAG_READ);
172   if (file.open("ui.ini") == FILERR_NONE)
173   {
174      bool result = machine.ui().options().parse_ini_file((core_file&)file, OPTION_PRIORITY_MAME_INI, OPTION_PRIORITY_DRIVER_INI, error);
175      if (!result)
176         osd_printf_error("**Error to load ui.ini**");
177   }
178}
179
180//-------------------------------------------------
163181//  is_breakable_char - is a given unicode
164182//  character a possible line break?
165183//-------------------------------------------------
r253196r253197
248266ui_manager::ui_manager(running_machine &machine)
249267   : m_machine(machine)
250268{
269}
270
271void ui_manager::init()
272{
273   load_ui_options(machine());
251274   // initialize the other UI bits
252   ui_menu::init(machine);
253   ui_gfx_init(machine);
275   ui_menu::init(machine());
276   ui_gfx_init(machine());
254277
255278   // reset instance variables
256279   m_font = nullptr;
r253196r253197
265288   m_mouse_arrow_texture = nullptr;
266289   m_load_save_hold = false;
267290
268   get_font_rows(&machine);
269   decode_ui_color(0, &machine);
291   get_font_rows(&machine());
292   decode_ui_color(0, &machine());
270293
271294   // more initialization
272295   set_handler(handler_messagebox, 0);
273296   m_non_char_keys_down = std::make_unique<UINT8[]>((ARRAY_LENGTH(non_char_keys) + 7) / 8);
274   m_mouse_show = machine.system().flags & MACHINE_CLICKABLE_ARTWORK ? true : false;
297   m_mouse_show = machine().system().flags & MACHINE_CLICKABLE_ARTWORK ? true : false;
275298
276299   // request a callback upon exiting
277   machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(ui_manager::exit), this));
300   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(ui_manager::exit), this));
278301
279302   // retrieve options
280   m_use_natural_keyboard = machine.options().natural_keyboard();
281   bitmap_argb32 *ui_mouse_bitmap = auto_alloc(machine, bitmap_argb32(32, 32));
303   m_use_natural_keyboard = machine().options().natural_keyboard();
304   bitmap_argb32 *ui_mouse_bitmap = auto_alloc(machine(), bitmap_argb32(32, 32));
282305   UINT32 *dst = &ui_mouse_bitmap->pix32(0);
283306   memcpy(dst,mouse_bitmap,32*32*sizeof(UINT32));
284   m_mouse_arrow_texture = machine.render().texture_alloc();
307   m_mouse_arrow_texture = machine().render().texture_alloc();
285308   m_mouse_arrow_texture->set_bitmap(*ui_mouse_bitmap, ui_mouse_bitmap->cliprect(), TEXFORMAT_ARGB32);
286309}
287310
r253196r253197
27292752   static rgb_t color[ARRAY_LENGTH(s_color_list)];
27302753
27312754   if (machine != nullptr) {
2732      emu_options option;
2755      ui_options option;
27332756      for (int x = 0; x < ARRAY_LENGTH(s_color_list); x++) {
27342757         const char *o_default = option.value(s_color_list[x]);
2735         const char *s_option = machine->options().value(s_color_list[x]);
2758         const char *s_option = machine->ui().options().value(s_color_list[x]);
27362759         int len = strlen(s_option);
27372760         if (len != 8)
27382761            color[x] = rgb_t((UINT32)strtoul(o_default, nullptr, 16));
r253196r253197
27512774{
27522775   static int value;
27532776
2754   return ((machine != nullptr) ? value = machine->options().font_rows() : value);
2777   return ((machine != nullptr) ? value = machine->ui().options().font_rows() : value);
27552778}
trunk/src/emu/ui/ui.h
r253196r253197
1414#define __USRINTRF_H__
1515
1616#include "render.h"
17#include "moptions.h"
1718
18
1919/***************************************************************************
2020    CONSTANTS
2121***************************************************************************/
r253196r253197
116116    // construction/destruction
117117    ui_manager(running_machine &machine);
118118
119   void init();
120
119121    // getters
120122    running_machine &machine() const { return m_machine; }
121123    bool single_step() const { return m_single_step; }
122
124   ui_options &options() { return m_ui_options; }
125   
123126    // setters
124127    void set_single_step(bool single_step) { m_single_step = single_step; }
125128
r253196r253197
193196    render_texture *        m_mouse_arrow_texture;
194197    bool                    m_mouse_show;
195198   bool                    m_load_save_hold;
199   ui_options              m_ui_options;
196200
197201    // text generators
198202    std::string &disclaimer_string(std::string &buffer);


Previous 199869 Revisions Next


© 1997-2024 The MAME Team