diff options
author | couriersud <couriersud@arcor.de> | 2015-03-04 01:39:52 +0100 |
---|---|---|
committer | couriersud <couriersud@arcor.de> | 2015-03-04 01:39:52 +0100 |
commit | 98a6781c271b004174052bbd1750351149bf91ce (patch) | |
tree | aea69d555669dfacd6eb94ff0dd84d02a9443fd8 /src/osd/windows/winmain.c | |
parent | c5deacfe57571bdcfdfb7bec9a3033be1f78fda7 (diff) |
First step to move osd_printf_* into osd again. Callbacks are now
implemented using an interface and use a push/pop approach where the pop
can happen out of order of pushes. [Couriersud]
Diffstat (limited to 'src/osd/windows/winmain.c')
-rw-r--r-- | src/osd/windows/winmain.c | 63 |
1 files changed, 37 insertions, 26 deletions
diff --git a/src/osd/windows/winmain.c b/src/osd/windows/winmain.c index ffda737bfbd..8a52feb921a 100644 --- a/src/osd/windows/winmain.c +++ b/src/osd/windows/winmain.c @@ -198,6 +198,31 @@ private: FPTR * m_buffer_end; }; +//============================================================ +// winui_output_error +//============================================================ + +class winui_output_error : public osd_output +{ +public: + virtual void output_callback(osd_output_channel channel, const char *msg, va_list args) + { + if (channel == OSD_OUTPUT_CHANNEL_ERROR) + { + char buffer[1024]; + + // if we are in fullscreen mode, go to windowed mode + if ((video_config.windowed == 0) && (win_window_list != NULL)) + winwindow_toggle_full_screen(); + + vsnprintf(buffer, ARRAY_LENGTH(buffer), msg, args); + win_message_box_utf8(win_window_list ? win_window_list->m_hwnd : NULL, buffer, emulator_info::get_appname(), MB_OK); + } + else + chain_output(channel, msg, args); + } +}; + @@ -237,7 +262,6 @@ static BOOL WINAPI control_handler(DWORD type); static int is_double_click_start(int argc); static DWORD WINAPI watchdog_thread_entry(LPVOID lpParameter); static LONG WINAPI exception_filter(struct _EXCEPTION_POINTERS *info); -static void winui_output_error(delegate_late_bind *__dummy, const char *format, va_list argptr); @@ -391,24 +415,27 @@ int main(int argc, char *argv[]) extern void (*s_debugger_stack_crawler)(); s_debugger_stack_crawler = winmain_dump_stack; - // if we're a GUI app, out errors to message boxes - if (win_is_gui_application() || is_double_click_start(argc)) - { - // if we are a GUI app, output errors to message boxes - osd_set_output_channel(OSD_OUTPUT_CHANNEL_ERROR, output_delegate(FUNC(winui_output_error), (delegate_late_bind *)0)); - - // make sure any console window that opened on our behalf is nuked - FreeConsole(); - } // parse config and cmdline options DWORD result = 0; { windows_options options; windows_osd_interface osd(options); + // if we're a GUI app, out errors to message boxes + // Initialize this after the osd interface so that we are first in the + // output order + winui_output_error winerror; + if (win_is_gui_application() || is_double_click_start(argc)) + { + // if we are a GUI app, output errors to message boxes + osd_output::push(&winerror); + // make sure any console window that opened on our behalf is nuked + FreeConsole(); + } osd.register_options(); cli_frontend frontend(options, osd); result = frontend.execute(argc, argv); + osd_output::pop(&winerror); } // free symbols symbols = NULL; @@ -464,22 +491,6 @@ static BOOL WINAPI control_handler(DWORD type) } -//============================================================ -// winui_output_error -//============================================================ - -static void winui_output_error(delegate_late_bind *param, const char *format, va_list argptr) -{ - char buffer[1024]; - - // if we are in fullscreen mode, go to windowed mode - if ((video_config.windowed == 0) && (win_window_list != NULL)) - winwindow_toggle_full_screen(); - - vsnprintf(buffer, ARRAY_LENGTH(buffer), format, argptr); - win_message_box_utf8(win_window_list ? win_window_list->m_hwnd : NULL, buffer, emulator_info::get_appname(), MB_OK); -} - //============================================================ |