-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDRHYCOND.CPP
executable file
·122 lines (105 loc) · 3.17 KB
/
DRHYCOND.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
_CLASSDEF(TDlgCondRhythm)
// Control dialog box for editing Song Settings
class TDlgCondRhythm : public TDialog
{
PTEdit pTERhythm[ MAX_RHYTHM ] [ MAX_RHYTHM ]; // static text for sb's
BYTE rhythm [ MAX_RHYTHM ] [ MAX_RHYTHM ]; // temp values for prob sets
public:
TDlgCondRhythm(PTWindowsObject pwParent, int nResourceID);
~TDlgCondRhythm()
{
WinHelp(this->HWindow, "alcomp.hlp", HELP_QUIT, 0L);
}
virtual void SetupWindow();
virtual void Ok(RTMessage Msg) = [ID_FIRST + IDOK];
virtual void Help(RTMessage Msg) = [ID_FIRST + IDHELP];
virtual BOOL CanClose();
// handy function to show all prob settings
void ShowProbs(/*int* value*/);
void SetTempRhythms(); // set this up before pass rhythms
};
// setup scroll bars for random rhythms
TDlgCondRhythm::TDlgCondRhythm(PTWindowsObject pwParent, int nResourceID)
: TDialog(pwParent, nResourceID)
{
for (int i=0; i<MAX_RHYTHM; i++)
for (int j=0; j<MAX_RHYTHM; j++) {
pTERhythm[i][j] = new TEdit(this, TX_WW + 6*i + j, 3); // setup static text
rhythm[i][j] = 0;
}
// fill the array with values from tempNote (non-zero values only)
for (i=0; i<tempTrack.Rhythm.count(); i++)
rhythm[ tempTrack.Rhythm[i].From ][ tempTrack.Rhythm[i].To ]
= tempTrack.Rhythm[i].Prob;
}
void TDlgCondRhythm::ShowProbs(/*int* value*/)
{
char buf3[3];
// setup initial rhythms and text strings
for (int i=0; i<MAX_RHYTHM; i++)
for (int j=0; j<MAX_RHYTHM; j++) {
sprintf(buf3, "%2d", rhythm[i][j] );
pTERhythm[i][j]->SetText(buf3);
}
}
void TDlgCondRhythm::SetupWindow()
{
TDialog::SetupWindow();
ShowProbs();
}
void TDlgCondRhythm::SetTempRhythms()
{
char buf2[3];
for (int i=0; i<MAX_RHYTHM; i++)
for (int j=0; j<MAX_RHYTHM; j++) {
pTERhythm[i][j]->GetText(buf2, 3);
rhythm[i][j] = atoi( buf2 );
}
}
BOOL TDlgCondRhythm::CanClose()
{
int sumrhythm = 0;
BOOL check = TRUE;
SetTempRhythms();
for (int i=0; i<MAX_RHYTHM; i++)
for (int j=0; j<MAX_RHYTHM; j++)
if ( rhythm[i][j] > 99 ) {
BWCCMessageBox(NULL, "Invalid Rhythm. Please Correct.", "Error!", MB_OK|MB_ICONEXCLAMATION);
check = FALSE;
break;
}
else
sumrhythm += rhythm[i][j];
if ( ! sumrhythm ) {
check = FALSE;
BWCCMessageBox(NULL, "No Rhythm's Assigned!", "Error!", MB_OK|MB_ICONEXCLAMATION);
}
return check;
}
void TDlgCondRhythm::Ok(RTMessage Msg)
{
if( Msg.LP.Hi == BN_CLICKED && CanClose() )
{
TDialog::Ok(Msg);
// detach all objects
tempTrack.Rhythm.flush(TRUE);
SetTempRhythms();
StrNote tn;
// detached all tempNote.Rhythm's, now add non-zero rhythm[]
for (int i = 0; i < MAX_RHYTHM; i++)
for (int j = 0; j < MAX_RHYTHM; j++)
if ( rhythm[i][j] ) {
// non-zero value, add to array
tn.From = i;
tn.To = j;
tn.Prob = rhythm[i][j];
tempTrack.Rhythm.add( tn );
}
}
}
void TDlgCondRhythm::Help(RTMessage Msg)
{
if ( Msg.LP.Hi == BN_CLICKED )
if (! WinHelp(this->HWindow, "alcomp.hlp", HELP_CONTEXT, RHYTHM_CONDITIONAL ))
BWCCMessageBox(this->HWindow, "Help File Not Found", "Error!", MB_OK|MB_ICONEXCLAMATION);
}