AeBankEditor.c++
2.91 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include <assert.h>
#include <Xm/Xm.h>
#include "Matrix.h"
#include "GList.h"
#include "AeBankEditor.h"
#include "AeBankWindow.h"
#include "AeAssetBase.h"
#include "AeAssetBin.h"
#include "AeAssetBinUI.h"
#include "AeAssetUI.h"
#include "AeFieldUI.h"
#include "AeBinView.h"
AeBankEditor::AeBankEditor (void) : AeBinEditor ()
{
fBank = NULL;
fWindow = NULL;
}
AeBankEditor::~AeBankEditor (void)
{
if (fWindow)
delete fWindow;
}
void
AeBankEditor::SetBankAsset (AeBankAsset * bank)
{
assert (bank); // must be non-NULL
fBank = bank;
// create and init the UI objects for this editor
createBinUIs ();
initBinUIs ();
createAssetUIs ();
initChildBinUIs ();
// default to editing the first bin in the list
fBinUI = (*fBinUIList)[0];
// now that we have data, create a window to display it
// note that we create the window with a constant title and
// then set it to the bank's name. this avoids a bug that
// occurs if the bank's name has a '.' in it which causes
// the resources based on the instance name to get messed up.
fWindow = new AeBankWindow("Bank Editor", this);
fWindow->show();
fWindow->setTitle (fBank->GetName ());
fView = fWindow->GetView ();
fView->TabSetLabels (); // update the view's bin labels
}
void
AeBankEditor::createAssetUIs (void)
{
createAssetUI (fBank);
createAssetUIsRecurse (fBank->GetChildList ());
}
void
AeBankEditor::createAssetUIsRecurse (GList<AeAsset *> * assetList)
{
AeAssetBinUI * binUI = NULL;
AeAssetUI * assetUI;
AeAsset * asset;
int i;
assetList->Start (i);
while (assetList->Next (i, asset))
{
if (createAssetUI (asset) == NULL)
break;
createRefAssetUIs (asset);
if (asset->CanContain ())
createAssetUIsRecurse (((AeContainerAsset *)asset)->GetChildList ());
}
}
//
// This routine takes care of creating assetUIs for any
// assets that are referenced by another asset.
//
// Note we don't have to create an UIs for loop or
// book assets since they are displayed as part of a
// wave's ui.
//
void
AeBankEditor::createRefAssetUIs (AeAsset * asset)
{
AeAsset * refAsset;
switch (asset->GetType ())
{
case kBankType:
if (refAsset = (AeAsset *)((AeBankAsset *)asset)->GetPercussion ())
{
createAssetUI (refAsset);
createAssetUIsRecurse (((AeContainerAsset *)refAsset)->GetChildList ());
}
break;
case kSoundType:
if (refAsset = (AeAsset *)((AeSoundAsset *)asset)->GetEnvelope ())
createAssetUI (refAsset);
if (refAsset = (AeAsset *)((AeSoundAsset *)asset)->GetKeymap ())
createAssetUI (refAsset);
if (refAsset = (AeAsset *)((AeSoundAsset *)asset)->GetWave ())
createAssetUI (refAsset);
break;
}
}
Boolean
AeBankEditor::binHasUI (AeAssetBin * bin)
{
switch (bin->GetType ())
{
case kBankFileType:
case kLoopType:
case kADPCMBookType:
return False;
}
return True;
}