Skip to content

Commit

Permalink
Snapshots: Add option to not prompt for deleting abandoned items when…
Browse files Browse the repository at this point in the history
… recalling snapshots which contain deleted tracks

closes reaper-oss#1073, closes reaper-oss#949
  • Loading branch information
nofishonfriday committed Feb 26, 2019
1 parent 6963f75 commit 64e9ebe
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 9 deletions.
3 changes: 2 additions & 1 deletion Snapshots/SnapshotClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,8 @@ bool Snapshot::UpdateReaper(int mask, bool bSelOnly, bool bHideNewVis)
if (fxErr)
n += sprintf(errString + n, __LOCALIZE_VERFMT("%s%d FX from snapshot not found.","sws_DLG_101"), n ? "\n" : "", fxErr);
sprintf(errString + n, "%s", __LOCALIZE("\nDelete abandonded items from snapshot? (You cannot undo this operation!)","sws_DLG_101"));
if (MessageBox(g_hwndParent, errString, __LOCALIZE("Snapshot recall error","sws_DLG_101"), MB_YESNO) == IDYES)
bool prompt = SWS_SnapshotsWnd::GetPromptOnDeleted();
if ((prompt && MessageBox(g_hwndParent, errString, __LOCALIZE("Snapshot recall error","sws_DLG_101"), MB_YESNO) == IDYES) || !prompt)
{
for (int i = 0; i < m_tracks.GetSize(); i++)
if (m_tracks.Get(i)->Cleanup())
Expand Down
19 changes: 16 additions & 3 deletions Snapshots/Snapshots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ static bool g_bHideNewOnRecall = true;
static bool g_bPromptOnNew = false;
static bool g_bHideOptions = false;
static bool g_bShowSelOnly = false;
static bool g_bPromptOnDeleted = true;

void UpdateSnapshotsDialog(bool bSelChange)
{
Expand Down Expand Up @@ -360,7 +361,7 @@ SWS_SnapshotsWnd::SWS_SnapshotsWnd()
{
// Restore state
char str[32];
GetPrivateProfileString(SWS_INI, SNAP_OPTIONS_KEY, "559 0 0 0 1 0 0 0 0", str, 32, get_ini_file());
GetPrivateProfileString(SWS_INI, SNAP_OPTIONS_KEY, "559 0 0 0 1 0 0 0 0 1", str, 32, get_ini_file());
LineParser lp(false);
if (!lp.parse(str))
{
Expand All @@ -373,6 +374,7 @@ SWS_SnapshotsWnd::SWS_SnapshotsWnd()
m_iSelType = lp.gettoken_int(6);
g_bSelOnly_OnRecall = lp.gettoken_int(7) ? true : false;
g_bShowSelOnly = lp.gettoken_int(8) ? true : false;
g_bPromptOnDeleted = lp.gettoken_int(9) ? true : false;
}
// Remove deprecated FXATM
if (g_iMask & FXATM_MASK)
Expand Down Expand Up @@ -413,6 +415,7 @@ void SWS_SnapshotsWnd::Update()
CheckDlgButton(m_hwnd, IDC_NAMEPROMPT, g_bPromptOnNew ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(m_hwnd, IDC_HIDENEW, g_bHideNewOnRecall ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(m_hwnd, IDC_SHOWSELONLY, g_bShowSelOnly ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(m_hwnd, IDC_DELTRACKSPROMPT, g_bPromptOnDeleted ? BST_CHECKED : BST_UNCHECKED);
for (int i = 0; i < MASK_CTRLS; i++)
{
CheckDlgButton(m_hwnd, cSSCtrls[i], g_iMask & cSSMasks[i] ? BST_CHECKED : BST_UNCHECKED);
Expand All @@ -435,6 +438,11 @@ void SWS_SnapshotsWnd::RenameCurrent()
m_pLists.Get(0)->EditListItem((SWS_ListItem*)g_ss.Get()->m_snapshots.Get(i), 1);
}

bool SWS_SnapshotsWnd::GetPromptOnDeleted()
{
return g_bPromptOnDeleted;
}

void SWS_SnapshotsWnd::OnInitDlg()
{
m_resize.init_item(IDC_LIST, 0.0, 0.0, 1.0, 1.0);
Expand All @@ -456,6 +464,7 @@ void SWS_SnapshotsWnd::OnInitDlg()
m_resize.init_item(IDC_APPLYRECALL, 1.0, 0.0, 1.0, 0.0);
m_resize.init_item(IDC_NAMEPROMPT, 1.0, 0.0, 1.0, 0.0);
m_resize.init_item(IDC_HIDENEW, 1.0, 0.0, 1.0, 0.0);
m_resize.init_item(IDC_DELTRACKSPROMPT, 1.0, 0.0, 1.0, 0.0);
#ifndef _SNAP_TINY_BUTTONS
m_resize.init_item(IDC_OPTIONS, 1.0, 1.0, 1.0, 1.0);
#endif
Expand Down Expand Up @@ -667,6 +676,7 @@ void SWS_SnapshotsWnd::OnCommand(WPARAM wParam, LPARAM lParam)
case IDC_NAMEPROMPT:
case IDC_HIDENEW:
case IDC_SHOWSELONLY:
case IDC_DELTRACKSPROMPT:
// Filter controls are handled in the default case
GetOptions();
Update();
Expand Down Expand Up @@ -774,7 +784,7 @@ void SWS_SnapshotsWnd::OnDestroy()
char str[256];

// Save window state
sprintf(str, "%d %d %d %d %d %d %d %d %d",
sprintf(str, "%d %d %d %d %d %d %d %d %d %d",
g_iMask,
g_bApplyFilterOnRecall ? 1 : 0,
g_bHideOptions ? 1 : 0,
Expand All @@ -783,7 +793,8 @@ void SWS_SnapshotsWnd::OnDestroy()
g_bSelOnly_OnSave ? 1 : 0,
m_iSelType,
g_bSelOnly_OnRecall ? 1 : 0,
g_bShowSelOnly ? 1 : 0);
g_bShowSelOnly ? 1 : 0,
g_bPromptOnDeleted ? 1 : 0);
WritePrivateProfileString(SWS_INI, SNAP_OPTIONS_KEY, str, get_ini_file());

#ifdef _SNAP_TINY_BUTTONS
Expand Down Expand Up @@ -841,6 +852,7 @@ void SWS_SnapshotsWnd::GetOptions()
g_bShowSelOnly = IsDlgButtonChecked(m_hwnd, IDC_SHOWSELONLY) == BST_CHECKED;
g_bApplyFilterOnRecall = IsDlgButtonChecked(m_hwnd, IDC_APPLYRECALL) == BST_CHECKED;
g_bPromptOnNew = IsDlgButtonChecked(m_hwnd, IDC_NAMEPROMPT) == BST_CHECKED;
g_bPromptOnDeleted = IsDlgButtonChecked(m_hwnd, IDC_DELTRACKSPROMPT) == BST_CHECKED;
}

void SWS_SnapshotsWnd::ShowControls(bool bShow)
Expand All @@ -863,6 +875,7 @@ void SWS_SnapshotsWnd::ShowControls(bool bShow)
ShowWindow(GetDlgItem(m_hwnd, IDC_APPLYRECALL), bShow);
ShowWindow(GetDlgItem(m_hwnd, IDC_NAMEPROMPT), bShow);
ShowWindow(GetDlgItem(m_hwnd, IDC_HIDENEW), bShow);
ShowWindow(GetDlgItem(m_hwnd, IDC_DELTRACKSPROMPT), bShow);
}

#ifdef _SNAP_TINY_BUTTONS
Expand Down
1 change: 1 addition & 0 deletions Snapshots/Snapshots.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class SWS_SnapshotsWnd : public SWS_DockWnd
void RenameCurrent();
void SetFilterType(int iType) { m_iSelType = iType; }
int GetFilterType() { return m_iSelType; }
static bool GetPromptOnDeleted(); // NF: #1073

protected:
void OnInitDlg();
Expand Down
3 changes: 2 additions & 1 deletion resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,15 @@
#define IDC_ALL_POS_H_COMBO 1356
#define IDC_ALL_POS_V_COMBO 1357
#define IDC_ALL_FOREGROUND 1358
#define IDC_DELTRACKSPROMPT 1359

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 189
#define _APS_NEXT_COMMAND_VALUE 40000
#define _APS_NEXT_CONTROL_VALUE 1359
#define _APS_NEXT_CONTROL_VALUE 1360
#define _APS_NEXT_SYMED_VALUE 100
#endif
#endif
9 changes: 5 additions & 4 deletions sws_extension.rc
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL "",IDC_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,5,3,125,221
PUSHBUTTON "&New",IDC_SAVE,136,3,27,13
PUSHBUTTON "Previous",IDC_PREVIOUS,140,212,41,13
PUSHBUTTON "Next",IDC_NEXT,182,212,41,13
PUSHBUTTON "Move Up",IDC_SWAP_UP,140,225,41,13
PUSHBUTTON "Move Down",IDC_SWAP_DOWN,182,225,41,13
PUSHBUTTON "Previous",IDC_PREVIOUS,140,212 + 17,41,13
PUSHBUTTON "Next",IDC_NEXT,182,212 + 17,41,13
PUSHBUTTON "Move Up",IDC_SWAP_UP,140,225 + 17,41,13
PUSHBUTTON "Move Down",IDC_SWAP_DOWN,182,225 + 17,41,13
LTEXT "Del: Alt-click\nSave: Ctrl-click",IDC_HELPTEXT,171,3,54,18
GROUPBOX "Filter",IDC_FILTERGROUP,135,18,88,99
CONTROL "Full Track Mix",IDC_MIX,"Button",BS_AUTORADIOBUTTON | WS_GROUP,140,29,70,10
Expand All @@ -145,6 +145,7 @@ BEGIN
"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,140,160,81,17
CONTROL "Prompt for Name",IDC_NAMEPROMPT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,179,70,10
CONTROL "Hide New Tracks\non Vis Recall",IDC_HIDENEW,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,140,192,78,14
CONTROL "Prompt on recalling\ndeleted tracks", IDC_DELTRACKSPROMPT, "Button", BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP, 140, 211, 78, 14
PUSHBUTTON "<- Hide Options",IDC_OPTIONS,136,212,85,13,NOT WS_VISIBLE
EDITTEXT IDC_EDIT,45,28,40,12,ES_AUTOHSCROLL | NOT WS_VISIBLE | NOT WS_BORDER
END
Expand Down
3 changes: 3 additions & 0 deletions whatsnew.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
New features:
+Snapshots: Add option to (not) prompt for deleting abandoned items when recalling snapshots which contain deleted tracks (snapshots will be recalled and abandoned items deleted without confirmation with this option disabled) (Issue 1073)

!v2.10.0 #1 Featured build (February 6, 2019)
Mega thanks to nofish and cfillion for their many contributions, and X-Raym for doing the tedious work of merging everything into a release.
Recommended use of REAPER 5.965.
Expand Down

0 comments on commit 64e9ebe

Please sign in to comment.