Skip to content

Commit 59a1faa

Browse files
author
larspalo
committed
Fixed file modified notifications. Added option to copy (replace) odf loops to other attacks in rank coming from same directory.
1 parent 0841e3a commit 59a1faa

File tree

5 files changed

+62
-8
lines changed

5 files changed

+62
-8
lines changed

src/AttackDialog.cpp

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ BEGIN_EVENT_TABLE(AttackDialog, wxDialog)
4343
EVT_BUTTON(ID_ATK_DIALOG_DELETE_LOOP_BTN, AttackDialog::OnRemoveLoopBtn)
4444
EVT_SPINCTRL(ID_ATK_DIALOG_LOOP_START_SPIN, AttackDialog::OnLoopStartSpin)
4545
EVT_SPINCTRL(ID_ATK_DIALOG_LOOP_END_SPIN, AttackDialog::OnLoopEndSpin)
46+
EVT_CHECKBOX(ID_RANK_COPY_REPLACE_ODF_LOOPS, AttackDialog::OnCopyReplaceLoopCheck)
4647
END_EVENT_TABLE()
4748

4849
AttackDialog::AttackDialog(std::list<Attack>& attack_list, unsigned selected_attack) : m_attacklist(attack_list) {
@@ -395,12 +396,13 @@ void AttackDialog::CreateControls() {
395396
wxT("A loop must be selected in the listbox to the left to enable.")
396397
);
397398
loopPropertiesContainer->Add(commentText1, 0, wxGROW|wxALL, 5);
398-
wxStaticText *commentText2 = new wxStaticText (
399+
m_copyReplaceLoopsCheck = new wxCheckBox(
399400
loopPropertiesContainer->GetStaticBox(),
400-
wxID_STATIC,
401-
wxT("Also please note that no loops will be copied to other attacks!")
401+
ID_RANK_COPY_REPLACE_ODF_LOOPS,
402+
wxT("Copy/replace loops to other attacks too!")
402403
);
403-
loopPropertiesContainer->Add(commentText2, 0, wxGROW|wxALL, 5);
404+
m_copyReplaceLoopsCheck->SetValue(false);
405+
loopPropertiesContainer->Add(m_copyReplaceLoopsCheck, 0, wxGROW|wxALL, 5);
404406
sixthRow->Add(loopPropertiesContainer, 1, wxEXPAND|wxALL, 5);
405407
mainSizer->Add(sixthRow, 1, wxGROW);
406408

@@ -436,6 +438,10 @@ unsigned AttackDialog::GetSelectedAttackIndex() {
436438
return m_selectedAttackIndex;
437439
}
438440

441+
bool AttackDialog::GetCopyReplaceLoops() {
442+
return m_copyReplaceLoopsCheck->IsChecked();
443+
}
444+
439445
std::list<Attack>::iterator AttackDialog::GetAttackIterator(unsigned index) {
440446
auto iterator = std::next(m_attacklist.begin(), index);
441447
return iterator;
@@ -473,44 +479,52 @@ void AttackDialog::OnLoadReleaseSelection(wxCommandEvent& event) {
473479
m_currentAttack->loadRelease = false;
474480
}
475481
m_copyPropertiesBtn->Enable();
482+
::wxGetApp().m_frame->m_organ->setModified(true);
476483
}
477484

478485
void AttackDialog::OnAttackVelocitySpin(wxSpinEvent& WXUNUSED(event)) {
479486
m_currentAttack->attackVelocity = m_attackVelocitySpin->GetValue();
480487
m_copyPropertiesBtn->Enable();
488+
::wxGetApp().m_frame->m_organ->setModified(true);
481489
}
482490

483491
void AttackDialog::OnMaxTimeSinceLastSpin(wxSpinEvent& WXUNUSED(event)) {
484492
m_currentAttack->maxTimeSinceLastRelease = m_maxTimeSinceLastSpin->GetValue();
485493
m_copyPropertiesBtn->Enable();
494+
::wxGetApp().m_frame->m_organ->setModified(true);
486495
}
487496

488497
void AttackDialog::OnTremulantChoice(wxCommandEvent& WXUNUSED(event)) {
489498
if (m_isTremulantChoice->GetSelection() != wxNOT_FOUND) {
490499
int tremChoice = m_isTremulantChoice->GetSelection() - 1;
491500
m_currentAttack->isTremulant = tremChoice;
492501
m_copyPropertiesBtn->Enable();
502+
::wxGetApp().m_frame->m_organ->setModified(true);
493503
}
494504
}
495505

496506
void AttackDialog::OnMaxKeyPressTimeSpin(wxSpinEvent& WXUNUSED(event)) {
497507
m_currentAttack->maxKeyPressTime = m_maxKeyPressTime->GetValue();
498508
m_copyPropertiesBtn->Enable();
509+
::wxGetApp().m_frame->m_organ->setModified(true);
499510
}
500511

501512
void AttackDialog::OnAttackStartSpin(wxSpinEvent& WXUNUSED(event)) {
502513
m_currentAttack->attackStart = m_attackStartSpin->GetValue();
503514
m_copyPropertiesBtn->Enable();
515+
::wxGetApp().m_frame->m_organ->setModified(true);
504516
}
505517

506518
void AttackDialog::OnCuePointSpin(wxSpinEvent& WXUNUSED(event)) {
507519
m_currentAttack->cuePoint = m_cuePointSpin->GetValue();
508520
m_copyPropertiesBtn->Enable();
521+
::wxGetApp().m_frame->m_organ->setModified(true);
509522
}
510523

511524
void AttackDialog::OnReleaseEndSpin(wxSpinEvent& WXUNUSED(event)) {
512525
m_currentAttack->releaseEnd = m_releaseEndSpin->GetValue();
513526
m_copyPropertiesBtn->Enable();
527+
::wxGetApp().m_frame->m_organ->setModified(true);
514528
}
515529

516530
void AttackDialog::OnLoopListSelection(wxCommandEvent& WXUNUSED(event)) {
@@ -538,6 +552,8 @@ void AttackDialog::OnAddLoopBtn(wxCommandEvent& WXUNUSED(event)) {
538552
m_loopsList->SetSelection(lastLoopIndex);
539553
m_selectedLoop = m_currentAttack->getLoopAt(lastLoopIndex);
540554
LoopInListSelected();
555+
if (GetCopyReplaceLoops())
556+
m_copyPropertiesBtn->Enable();
541557
}
542558

543559
void AttackDialog::OnRemoveLoopBtn(wxCommandEvent& WXUNUSED(event)) {
@@ -556,6 +572,8 @@ void AttackDialog::OnRemoveLoopBtn(wxCommandEvent& WXUNUSED(event)) {
556572
m_selectedLoop = m_currentAttack->getLoopAt(lastLoopIndex);
557573
LoopInListSelected();
558574
}
575+
if (GetCopyReplaceLoops())
576+
m_copyPropertiesBtn->Enable();
559577
}
560578
}
561579

@@ -567,6 +585,9 @@ void AttackDialog::OnLoopStartSpin(wxSpinEvent& WXUNUSED(event)) {
567585
}
568586
m_selectedLoop->start = value;
569587
SetLoopStartAndEndRanges();
588+
::wxGetApp().m_frame->m_organ->setModified(true);
589+
if (GetCopyReplaceLoops())
590+
m_copyPropertiesBtn->Enable();
570591
}
571592

572593
void AttackDialog::OnLoopEndSpin(wxSpinEvent& WXUNUSED(event)) {
@@ -577,6 +598,14 @@ void AttackDialog::OnLoopEndSpin(wxSpinEvent& WXUNUSED(event)) {
577598
}
578599
m_selectedLoop->end = value;
579600
SetLoopStartAndEndRanges();
601+
::wxGetApp().m_frame->m_organ->setModified(true);
602+
if (GetCopyReplaceLoops())
603+
m_copyPropertiesBtn->Enable();
604+
}
605+
606+
void AttackDialog::OnCopyReplaceLoopCheck(wxCommandEvent& WXUNUSED(event)) {
607+
if (GetCopyReplaceLoops())
608+
m_copyPropertiesBtn->Enable();
580609
}
581610

582611
void AttackDialog::SetButtonState() {
@@ -598,7 +627,7 @@ void AttackDialog::TransferAttackValuesToWindow() {
598627
m_attackName->SetLabel(m_currentAttack->fileName);
599628
m_attackPath->SetLabel(m_currentAttack->fullPath);
600629
if (m_currentAttack->fullPath.IsSameAs(wxT("DUMMY"))) {
601-
// almoast everything should be set to default and disabled
630+
// almost everything should be set to default and disabled
602631
m_loadReleaseYes->SetValue(true);
603632
m_loadReleaseNo->SetValue(false);
604633
m_attackVelocitySpin->SetValue(m_currentAttack->attackVelocity);

src/AttackDialog.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include <wx/wx.h>
2525
#include <wx/spinctrl.h>
26+
#include <wx/checkbox.h>
2627
#include "GOODFDef.h"
2728
#include "Attack.h"
2829

@@ -66,6 +67,7 @@ class AttackDialog : public wxDialog {
6667

6768
// Accessor
6869
unsigned GetSelectedAttackIndex();
70+
bool GetCopyReplaceLoops();
6971

7072
private:
7173
unsigned m_firstSelectedAttack;
@@ -95,6 +97,7 @@ class AttackDialog : public wxDialog {
9597
wxSpinCtrl *m_loopStartSpin;
9698
wxSpinCtrl *m_loopEndSpin;
9799
wxButton *m_copyPropertiesBtn;
100+
wxCheckBox *m_copyReplaceLoopsCheck;
98101

99102
// Event methods
100103
void OnPrevAttackBtn(wxCommandEvent& event);
@@ -112,7 +115,8 @@ class AttackDialog : public wxDialog {
112115
void OnRemoveLoopBtn(wxCommandEvent& event);
113116
void OnLoopStartSpin(wxSpinEvent& event);
114117
void OnLoopEndSpin(wxSpinEvent& event);
115-
void OnCopyProperties(wxCommandEvent& event);
118+
// void OnCopyProperties(wxCommandEvent& event);
119+
void OnCopyReplaceLoopCheck(wxCommandEvent& event);
116120

117121
std::list<Attack>::iterator GetAttackIterator(unsigned index);
118122
void SetButtonState();

src/GOODFDef.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ enum {
613613
ID_GLOBAL_SHOW_TOOLTIPS_OPTION = wxID_HIGHEST + 588,
614614
ID_CLEAR_HISTORY = wxID_HIGHEST + 589,
615615
ID_ENCLOSURE_MIDI_INPUT_NBR_SPIN = wxID_HIGHEST + 590,
616+
ID_RANK_COPY_REPLACE_ODF_LOOPS = wxID_HIGHEST + 591,
616617
};
617618

618619
// Get version number from cmake

src/OrganPanel.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,14 +619,16 @@ void OrganPanel::getDataFromOrgan() {
619619
}
620620

621621
void OrganPanel::OnBrowseForOrganPath(wxCommandEvent& WXUNUSED(event)) {
622+
wxString oldOdfPath = m_odfPath;
622623
m_odfPath = GetDirectoryPath();
623624
m_odfPathField->SetValue(m_odfPath);
624625
m_currentOrgan->setOdfRoot(m_odfPath);
625626
m_currentOrgan->updateRelativePipePaths();
626627
if (!m_infoPathField->IsEmpty()) {
627628
m_infoPathField->SetValue(GOODF_functions::removeBaseOdfPath(m_currentOrgan->getInfoFilename()));
628629
}
629-
::wxGetApp().m_frame->m_organ->setModified(true);
630+
if (!m_odfPath.IsSameAs(oldOdfPath))
631+
::wxGetApp().m_frame->m_organ->setModified(true);
630632
}
631633

632634
wxString OrganPanel::GetDirectoryPath() {
@@ -639,7 +641,7 @@ wxString OrganPanel::GetDirectoryPath() {
639641

640642
wxDirDialog dirDialog(
641643
this,
642-
wxT("Pick a directory"),
644+
wxT("Pick a directory (Cancel will empty the field!)"),
643645
defaultPath,
644646
wxDD_DIR_MUST_EXIST
645647
);

src/RankPanel.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "PipeCopyOffsetDialog.h"
3535
#include "PipeLoadingDialog.h"
3636
#include <algorithm>
37+
#include "WAVfileParser.h"
3738

3839
// Event table
3940
BEGIN_EVENT_TABLE(RankPanel, wxPanel)
@@ -1313,6 +1314,23 @@ void RankPanel::OnEditAttack() {
13131314
atk->maxKeyPressTime = sourceAttack->maxKeyPressTime;
13141315
atk->maxTimeSinceLastRelease = sourceAttack->maxTimeSinceLastRelease;
13151316
atk->releaseEnd = sourceAttack->releaseEnd;
1317+
1318+
if (atk_dlg.GetCopyReplaceLoops()) {
1319+
atk->m_loops.clear();
1320+
1321+
// need a way to check that loop end point won't be larger than actual attack samples
1322+
unsigned maxSampleFrames = 0;
1323+
WAVfileParser sample(atk->fullPath);
1324+
if (sample.isWavOk()) {
1325+
maxSampleFrames = sample.getNumberOfFrames();
1326+
}
1327+
if (sourceAttack->m_loops.size()) {
1328+
for (Loop l: sourceAttack->m_loops) {
1329+
if ((unsigned) l.end < maxSampleFrames)
1330+
atk->m_loops.push_back(l);
1331+
}
1332+
}
1333+
}
13161334
}
13171335
}
13181336
}

0 commit comments

Comments
 (0)