From 4ee2f625bb1c3b52fce4be9a259200d4eb6a8d93 Mon Sep 17 00:00:00 2001 From: hap Date: Fri, 10 Jul 2020 00:22:58 +0200 Subject: ui: able to show emulation warnings from tab menu --- src/frontend/mame/ui/info.cpp | 39 +++++++++++++++++++++++++++++---------- src/frontend/mame/ui/info.h | 12 ++++++++++++ src/frontend/mame/ui/mainmenu.cpp | 7 +++++++ src/frontend/mame/ui/menu.h | 1 + src/frontend/mame/ui/ui.cpp | 11 +++++++---- src/frontend/mame/ui/ui.h | 4 +++- 6 files changed, 59 insertions(+), 15 deletions(-) diff --git a/src/frontend/mame/ui/info.cpp b/src/frontend/mame/ui/info.cpp index 4ed48005057..ec0c6e72700 100644 --- a/src/frontend/mame/ui/info.cpp +++ b/src/frontend/mame/ui/info.cpp @@ -293,10 +293,6 @@ std::string machine_info::warnings_string() const buf << '\n'; } - // add the 'press OK' string - if (!buf.str().empty()) - buf << _("\n\nPress any key to continue"); - return buf.str(); } @@ -451,9 +447,8 @@ std::string machine_info::get_screen_desc(screen_device &screen) const /*------------------------------------------------- - menu_game_info - handle the game information - menu - -------------------------------------------------*/ + menu_game_info - handle the game information menu +-------------------------------------------------*/ menu_game_info::menu_game_info(mame_ui_manager &mui, render_container &container) : menu(mui, container) { @@ -477,9 +472,33 @@ void menu_game_info::handle() /*------------------------------------------------- - menu_image_info - handle the image information - menu - -------------------------------------------------*/ + menu_warn_info - handle the emulation warnings menu +-------------------------------------------------*/ + +menu_warn_info::menu_warn_info(mame_ui_manager &mui, render_container &container) : menu(mui, container) +{ +} + +menu_warn_info::~menu_warn_info() +{ +} + +void menu_warn_info::populate(float &customtop, float &custombottom) +{ + std::string tempstring = ui().machine_info().warnings_string(); + item_append(std::move(tempstring), "", FLAG_MULTILINE, nullptr); +} + +void menu_warn_info::handle() +{ + // process the menu + process(0); +} + + +/*------------------------------------------------- + menu_image_info - handle the image information menu +-------------------------------------------------*/ menu_image_info::menu_image_info(mame_ui_manager &mui, render_container &container) : menu(mui, container) { diff --git a/src/frontend/mame/ui/info.h b/src/frontend/mame/ui/info.h index a3746ce6b03..0e6fd7815cd 100644 --- a/src/frontend/mame/ui/info.h +++ b/src/frontend/mame/ui/info.h @@ -96,6 +96,18 @@ private: }; +class menu_warn_info : public menu +{ +public: + menu_warn_info(mame_ui_manager &mui, render_container &container); + virtual ~menu_warn_info() override; + +private: + virtual void populate(float &customtop, float &custombottom) override; + virtual void handle() override; +}; + + class menu_image_info : public menu { public: diff --git a/src/frontend/mame/ui/mainmenu.cpp b/src/frontend/mame/ui/mainmenu.cpp index 9ad99639879..beca0b10a6e 100644 --- a/src/frontend/mame/ui/mainmenu.cpp +++ b/src/frontend/mame/ui/mainmenu.cpp @@ -75,6 +75,9 @@ void menu_main::populate(float &customtop, float &custombottom) item_append(_("Machine Information"), "", 0, (void *)GAME_INFO); + if (ui().found_machine_warnings()) + item_append(_("Warning Information"), "", 0, (void *)WARN_INFO); + for (device_image_interface &image : image_interface_iterator(machine().root_device())) { if (image.user_loadable()) @@ -184,6 +187,10 @@ void menu_main::handle() menu::stack_push(ui(), container()); break; + case WARN_INFO: + menu::stack_push(ui(), container()); + break; + case IMAGE_MENU_IMAGE_INFO: menu::stack_push(ui(), container()); break; diff --git a/src/frontend/mame/ui/menu.h b/src/frontend/mame/ui/menu.h index e6861e03ee0..800b0b6ca7b 100644 --- a/src/frontend/mame/ui/menu.h +++ b/src/frontend/mame/ui/menu.h @@ -57,6 +57,7 @@ public: ANALOG, BOOKKEEPING, GAME_INFO, + WARN_INFO, IMAGE_MENU_IMAGE_INFO, IMAGE_MENU_FILE_MANAGER, TAPE_CONTROL, diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp index 225c908f066..e1b0990193b 100644 --- a/src/frontend/mame/ui/ui.cpp +++ b/src/frontend/mame/ui/ui.cpp @@ -166,7 +166,9 @@ mame_ui_manager::mame_ui_manager(running_machine &machine) , m_mouse_bitmap(32, 32) , m_mouse_arrow_texture(nullptr) , m_mouse_show(false) - , m_target_font_height(0) {} + , m_target_font_height(0) + , m_has_warnings(false) +{ } mame_ui_manager::~mame_ui_manager() { @@ -329,10 +331,11 @@ void mame_ui_manager::display_startup_screens(bool first_time) switch (state) { case 0: - if (show_warnings) - messagebox_text = machine_info().warnings_string(); - if (!messagebox_text.empty()) + messagebox_text = machine_info().warnings_string(); + m_has_warnings = !messagebox_text.empty(); + if (m_has_warnings && show_warnings) { + messagebox_text.append("\n\nPress any key to continue"); set_handler(ui_callback_type::MODAL, std::bind(&mame_ui_manager::handler_messagebox_anykey, this, _1)); messagebox_backcolor = machine_info().warnings_color(); } diff --git a/src/frontend/mame/ui/ui.h b/src/frontend/mame/ui/ui.h index 71f6a5ab8b8..9f32bd470a2 100644 --- a/src/frontend/mame/ui/ui.h +++ b/src/frontend/mame/ui/ui.h @@ -223,6 +223,7 @@ public: void show_mouse(bool status); virtual bool is_menu_active() override; bool can_paste(); + bool found_machine_warnings() const { return m_has_warnings; } void image_handler_ingame(); void increase_frameskip(); void decrease_frameskip(); @@ -261,7 +262,7 @@ private: render_font * m_font; std::function m_handler_callback; ui_callback_type m_handler_callback_type; - uint32_t m_handler_param; + uint32_t m_handler_param; bool m_single_step; bool m_showfps; osd_ticks_t m_showfps_end; @@ -274,6 +275,7 @@ private: ui_options m_ui_options; ui_colors m_ui_colors; float m_target_font_height; + bool m_has_warnings; std::unique_ptr m_machine_info; -- cgit v1.2.3