From: <sv...@op...> - 2024-12-27 13:32:06
|
Author: manx Date: Fri Dec 27 14:31:54 2024 New Revision: 22629 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22629 Log: [Ref] libopenmpt: Plugin GUI: Move About box to shared code. Modified: trunk/OpenMPT/libopenmpt/in_openmpt/in_openmpt.cpp trunk/OpenMPT/libopenmpt/plugin-common/libopenmpt_plugin_gui.cpp trunk/OpenMPT/libopenmpt/plugin-common/libopenmpt_plugin_gui.hpp trunk/OpenMPT/libopenmpt/xmp-openmpt/xmp-openmpt.cpp Modified: trunk/OpenMPT/libopenmpt/in_openmpt/in_openmpt.cpp ============================================================================== --- trunk/OpenMPT/libopenmpt/in_openmpt/in_openmpt.cpp Fri Dec 27 13:26:06 2024 (r22628) +++ trunk/OpenMPT/libopenmpt/in_openmpt/in_openmpt.cpp Fri Dec 27 14:31:54 2024 (r22629) @@ -212,11 +212,7 @@ } static void config( HWND hwndParent ) { -#if 1 libopenmpt::plugin::gui_edit_settings( &self->settings, hwndParent, TEXT(SHORT_TITLE) ); -#else - static_cast<void>(hwndParent); -#endif apply_options(); } @@ -227,18 +223,9 @@ about << " OpenMPT version " << openmpt::string::get( "core_version" ) << std::endl; about << std::endl; about << openmpt::string::get( "contact" ) << std::endl; - about << std::endl; - about << "Show full credits?" << std::endl; - if ( MessageBox( hwndParent, StringToWINAPI( StringDecode( about.str(), CP_UTF8 ) ).c_str(), TEXT(SHORT_TITLE), MB_ICONINFORMATION | MB_YESNOCANCEL | MB_DEFBUTTON1 ) != IDYES ) { - return; - } std::ostringstream credits; - credits << openmpt::string::get( "credits" ); -#if 1 - libopenmpt::plugin::gui_show_file_info( hwndParent, TEXT(SHORT_TITLE), StringToWINAPI( StringReplace( StringDecode( credits.str(), CP_UTF8 ), L"\n", L"\r\n" ) ) ); -#else - MessageBox( hwndParent, StringToWINAPI( StringReplace(StringDecode(credits.str(), CP_UTF8 ), L"\n", L"\r\n" ) ).c_str(), TEXT(SHORT_TITLE), MB_OK ); -#endif + credits << openmpt::string::get( "credits" ) << std::endl; + libopenmpt::plugin::gui_show_about( hwndParent, TEXT(SHORT_TITLE), StringReplace( StringToWINAPI( StringDecode( about.str(), CP_UTF8 ) ), TEXT("\n"), TEXT("\r\n") ), StringReplace( StringToWINAPI( StringDecode( credits.str(), CP_UTF8 ) ), TEXT("\n"), TEXT("\r\n") ) ); } static void init() { Modified: trunk/OpenMPT/libopenmpt/plugin-common/libopenmpt_plugin_gui.cpp ============================================================================== --- trunk/OpenMPT/libopenmpt/plugin-common/libopenmpt_plugin_gui.cpp Fri Dec 27 13:26:06 2024 (r22628) +++ trunk/OpenMPT/libopenmpt/plugin-common/libopenmpt_plugin_gui.cpp Fri Dec 27 14:31:54 2024 (r22629) @@ -365,6 +365,7 @@ #if defined(MPT_WITH_MFC) + void gui_edit_settings( libopenmpt_settings * s, HWND parent, std::wstring title ) { AFX_MANAGE_STATE( AfxGetStaticModuleState() ); CSettingsDialog dlg( s, title.c_str(), parent ? CWnd::FromHandle( parent ) : nullptr ); @@ -374,7 +375,25 @@ void gui_show_file_info( HWND parent, std::wstring title, std::wstring info ) { AFX_MANAGE_STATE( AfxGetStaticModuleState() ); - CInfoDialog dlg( title.c_str(), info.c_str(), parent ? CWnd::FromHandle( parent ) : nullptr); + CInfoDialog dlg( title.c_str(), info.c_str(), parent ? CWnd::FromHandle( parent ) : nullptr ); + dlg.DoModal(); +} + + +void gui_show_about( HWND parent, std::basic_string<TCHAR> title, std::basic_string<TCHAR> about, std::basic_string<TCHAR> credits ) { + AFX_MANAGE_STATE( AfxGetStaticModuleState() ); + about += TEXT("\r\n"); + about += TEXT("Show full credits?\r\n"); + if ( parent ) { + if ( CWnd::FromHandle( parent )->MessageBox( about.c_str(), title.c_str(), MB_ICONINFORMATION | MB_YESNOCANCEL | MB_DEFBUTTON1 ) != IDYES ) { + return; + } + } else { + if ( MessageBox( parent, about.c_str(), title.c_str(), MB_ICONINFORMATION | MB_YESNOCANCEL | MB_DEFBUTTON1 ) != IDYES ) { + return; + } + } + CInfoDialog dlg( title.c_str(), credits.c_str(), parent ? CWnd::FromHandle( parent ) : nullptr ); dlg.DoModal(); } @@ -469,6 +488,14 @@ } +void gui_show_about( HWND parent, std::basic_string<TCHAR> title, std::basic_string<TCHAR> about, std::basic_string<TCHAR> credits ) { + if ( MessageBox( parent, about.c_str(), title.c_str(), MB_ICONINFORMATION | MB_YESNOCANCEL | MB_DEFBUTTON1 ) != IDYES ) { + return; + } + gui_show_file_info( parent, title, credits ); +} + + #endif // MPT_WITH_MFC Modified: trunk/OpenMPT/libopenmpt/plugin-common/libopenmpt_plugin_gui.hpp ============================================================================== --- trunk/OpenMPT/libopenmpt/plugin-common/libopenmpt_plugin_gui.hpp Fri Dec 27 13:26:06 2024 (r22628) +++ trunk/OpenMPT/libopenmpt/plugin-common/libopenmpt_plugin_gui.hpp Fri Dec 27 14:31:54 2024 (r22629) @@ -30,6 +30,8 @@ void gui_show_file_info( HWND parent, std::basic_string<TCHAR> title, std::basic_string<TCHAR> info ); +void gui_show_about( HWND parent, std::basic_string<TCHAR> title, std::basic_string<TCHAR> about, std::basic_string<TCHAR> credits ); + } // namespace plugin } // namespace libopenmpt Modified: trunk/OpenMPT/libopenmpt/xmp-openmpt/xmp-openmpt.cpp ============================================================================== --- trunk/OpenMPT/libopenmpt/xmp-openmpt/xmp-openmpt.cpp Fri Dec 27 13:26:06 2024 (r22628) +++ trunk/OpenMPT/libopenmpt/xmp-openmpt/xmp-openmpt.cpp Fri Dec 27 14:31:54 2024 (r22629) @@ -483,30 +483,17 @@ about << " OpenMPT version " << openmpt::string::get( "core_version" ) << std::endl; about << std::endl; about << openmpt::string::get( "contact" ) << std::endl; - about << std::endl; - about << "Show full credits?" << std::endl; - if ( MessageBox( win, StringToWINAPI( StringDecode( about.str(), CP_UTF8 ) ).c_str(), TEXT(SHORT_TITLE), MB_ICONINFORMATION | MB_YESNOCANCEL | MB_DEFBUTTON1 ) != IDYES ) { - return; - } std::ostringstream credits; credits << openmpt::string::get( "credits" ); credits << "Additional thanks to:" << std::endl; credits << std::endl; credits << "Arseny Kapoulkine for pugixml" << std::endl; credits << "https://pugixml.org/" << std::endl; -#if 1 - libopenmpt::plugin::gui_show_file_info( win, TEXT(SHORT_TITLE), StringToWINAPI( StringReplace( StringDecode( credits.str(), CP_UTF8 ), L"\n", L"\r\n" ) ) ); -#else - MessageBox( win, StringToWINAPI( StringReplace( StringDecode( credits.str(), CP_UTF8 ), L"\n", L"\r\n" ) ).c_str(), TEXT(SHORT_TITLE), MB_OK ); -#endif + libopenmpt::plugin::gui_show_about( win, TEXT(SHORT_TITLE), StringReplace( StringToWINAPI( StringDecode( about.str(), CP_UTF8 ) ), TEXT("\n"), TEXT("\r\n") ), StringReplace( StringToWINAPI( StringDecode( credits.str(), CP_UTF8 ) ), TEXT("\n"), TEXT("\r\n") ) ); } static void WINAPI openmpt_Config( HWND win ) { -#if 1 libopenmpt::plugin::gui_edit_settings( &self->settings, win, TEXT(SHORT_TITLE) ); -#else - static_cast<void>(win); -#endif apply_and_save_options(); } |