Skip to content

Commit

Permalink
[Imp] On Vista and Wine 3.13 and newer, use Task Dialog for message b…
Browse files Browse the repository at this point in the history
…oxes with "don't show again" checkbox.

[Reg] On older systems, these messages are now always shown only once.

git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@22143 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
sagamusix committed Nov 10, 2024
1 parent 392b4b0 commit 28fde84
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 73 deletions.
83 changes: 31 additions & 52 deletions mptrack/dlg_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#include "../soundlib/mod_specifications.h"
#include "../soundlib/plugins/PlugInterface.h"

#if MPT_WINNT_AT_LEAST(MPT_WIN_VISTA)
#include <afxtaskdialog.h>
#endif


OPENMPT_NAMESPACE_BEGIN

Expand Down Expand Up @@ -1549,33 +1553,20 @@ void CInputDlg::OnOK()
///////////////////////////////////////////////////////////////////////////////////////
// Messagebox with 'don't show again'-option.

class CMsgBoxHidable : public DialogBase
{
public:
CMsgBoxHidable(const TCHAR *strMsg, bool checkStatus = true, CWnd* pParent = NULL);
enum { IDD = IDD_MSGBOX_HIDABLE };

const TCHAR *m_StrMsg;
int m_nCheckStatus;
protected:
void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support
BOOL OnInitDialog() override;
};


struct MsgBoxHidableMessage
{
const TCHAR *mainTitle;
const TCHAR *message;
uint32 mask;
bool defaultDontShowAgainStatus; // true for don't show again, false for show again.
const uint32 mask;
const bool defaultDontShowAgainStatus; // true for don't show again, false for show again.
};

static constexpr MsgBoxHidableMessage HidableMessages[] =
{
{ _T("Note: First two bytes of oneshot samples are silenced for ProTracker compatibility."), 1, true },
{ _T("Hint: To create IT-files without MPT-specific extensions included, try compatibility export from File-menu."), 1 << 1, true },
{ _T("Hint: To create XM-files without MPT-specific extensions included, try compatibility export from File-menu."), 1 << 3, true },
{ _T("Warning: The exported file will not contain any of MPT's file format hacks."), 1 << 4, true },
{ _T("Compatibility Notice"), _T("The first two bytes of oneshot samples are silenced for ProTracker compatibility."), 1, true },
{ _T("Compatibility Hint"), _T("To create IT files without OpenMPT-specific extensions included, try compatibility export from File menu."), 1 << 1, true },
{ _T("Compatibility Hint"), _T("To create XM files without OpenMPT-specific extensions included, try compatibility export from File menu."), 1 << 3, true },
{ _T("Compatibility Notice"), _T("The exported file will not contain any of OpenMPT's file format hacks."), 1 << 4, true },
};

static_assert(mpt::array_size<decltype(HidableMessages)>::size == enMsgBoxHidableMessage_count);
Expand All @@ -1585,41 +1576,29 @@ static_assert(mpt::array_size<decltype(HidableMessages)>::size == enMsgBoxHidabl
// controls the show/don't show-flags.
void MsgBoxHidable(enMsgBoxHidableMessage enMsg)
{
// Check whether the message should be shown.
if((TrackerSettings::Instance().gnMsgBoxVisiblityFlags & HidableMessages[enMsg].mask) == 0)
const auto &msg = HidableMessages[enMsg];
if((TrackerSettings::Instance().gnMsgBoxVisiblityFlags & msg.mask) == 0)
return;

// Show dialog.
CMsgBoxHidable dlg(HidableMessages[enMsg].message, HidableMessages[enMsg].defaultDontShowAgainStatus);
dlg.DoModal();

// Update visibility flags.
const uint32 mask = HidableMessages[enMsg].mask;
if(dlg.m_nCheckStatus == BST_CHECKED)
TrackerSettings::Instance().gnMsgBoxVisiblityFlags &= ~mask;
else
TrackerSettings::Instance().gnMsgBoxVisiblityFlags |= mask;
}


CMsgBoxHidable::CMsgBoxHidable(const TCHAR *strMsg, bool checkStatus, CWnd* pParent)
: DialogBase(CMsgBoxHidable::IDD, pParent)
, m_StrMsg(strMsg)
, m_nCheckStatus((checkStatus) ? BST_CHECKED : BST_UNCHECKED)
{}

BOOL CMsgBoxHidable::OnInitDialog()
{
DialogBase::OnInitDialog();
SetDlgItemText(IDC_MESSAGETEXT, m_StrMsg);
SetWindowText(AfxGetAppName());
return TRUE;
}
#if MPT_WINNT_AT_LEAST(MPT_WIN_VISTA)
if(CTaskDialog::IsSupported()
&& !(mpt::OS::Windows::IsWine() && theApp.GetWineVersion()->Version().IsBefore(mpt::OS::Wine::Version(3, 13, 0))))
{
CTaskDialog taskDialog(msg.message, msg.mainTitle ? CString{msg.mainTitle} : CString{}, AfxGetAppName(), TDCBF_OK_BUTTON);
taskDialog.SetVerificationCheckboxText(_T("Do not show this message again"));
taskDialog.SetVerificationCheckbox(msg.defaultDontShowAgainStatus);
taskDialog.DoModal();

void CMsgBoxHidable::DoDataExchange(CDataExchange* pDX)
{
DialogBase::DoDataExchange(pDX);
DDX_Check(pDX, IDC_DONTSHOWAGAIN, m_nCheckStatus);
if(taskDialog.GetVerificationCheckboxState())
TrackerSettings::Instance().gnMsgBoxVisiblityFlags &= ~msg.mask;
else
TrackerSettings::Instance().gnMsgBoxVisiblityFlags |= msg.mask;
} else
#endif
{
Reporting::Information(msg.message, msg.mainTitle ? CString{msg.mainTitle} : CString{});
TrackerSettings::Instance().gnMsgBoxVisiblityFlags |= msg.mask;
}
}


Expand Down
18 changes: 0 additions & 18 deletions mptrack/mptrack.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3339,16 +3339,6 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
// Dialog
//

IDD_MSGBOX_HIDABLE DIALOGEX 0, 0, 187, 71
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,150,50,30,14
PUSHBUTTON "Cancel",IDCANCEL,111,49,30,14,NOT WS_VISIBLE
CONTROL "Don't show this again.",IDC_DONTSHOWAGAIN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,54,90,10
LTEXT "Static",IDC_MESSAGETEXT,7,7,173,40
END

IDD_MIDIPARAMCONTROL DIALOGEX 0, 0, 413, 247
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "MIDI Mapping"
Expand Down Expand Up @@ -3492,14 +3482,6 @@ END
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_MSGBOX_HIDABLE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 180
TOPMARGIN, 7
BOTTOMMARGIN, 64
END

IDD_MIDIPARAMCONTROL, DIALOG
BEGIN
RIGHTMARGIN, 409
Expand Down
3 changes: 0 additions & 3 deletions mptrack/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
#define IDD_MIXSAMPLES 513
#define IDS_ERR_TUNING_SERIALISATION 514
#define IDD_MIDIPARAMCONTROL 515
#define IDD_MSGBOX_HIDABLE 516
#define IDD_ADDSILENCE 517
#define IDD_OPLEXPORT 518
#define IDD_OPL_PARAMS 520
Expand Down Expand Up @@ -802,8 +801,6 @@
#define IDC_EDIT_STRETCHPARAMS 2338
#define IDC_MIDI_MACRO_CONTROL 2339
#define IDC_MIDIPLAYPATTERNONMIDIIN 2340
#define IDC_DONTSHOWAGAIN 2341
#define IDC_MESSAGETEXT 2342
#define IDC_SAMPLE_DCOFFSET 2343
#define IDC_OPTIONS_DIR_MODS 2344
#define IDC_OPTIONS_DIR_SAMPS 2345
Expand Down

0 comments on commit 28fde84

Please sign in to comment.