4801 |
|
|
4802 |
ScriptGroup::~ScriptGroup() { |
ScriptGroup::~ScriptGroup() { |
4803 |
if (pScripts) { |
if (pScripts) { |
4804 |
std::list<Script*>::iterator iter = pScripts->begin(); |
std::vector<Script*>::iterator iter = pScripts->begin(); |
4805 |
std::list<Script*>::iterator end = pScripts->end(); |
std::vector<Script*>::iterator end = pScripts->end(); |
4806 |
while (iter != end) { |
while (iter != end) { |
4807 |
delete *iter; |
delete *iter; |
4808 |
++iter; |
++iter; |
4840 |
// now store the name of this group as <LSNM> chunk as subchunk of the <RTIS> list chunk |
// now store the name of this group as <LSNM> chunk as subchunk of the <RTIS> list chunk |
4841 |
::SaveString(CHUNK_ID_LSNM, NULL, pList, Name, String("Unnamed Group"), true, 64); |
::SaveString(CHUNK_ID_LSNM, NULL, pList, Name, String("Unnamed Group"), true, 64); |
4842 |
|
|
4843 |
for (std::list<Script*>::iterator it = pScripts->begin(); |
for (std::vector<Script*>::iterator it = pScripts->begin(); |
4844 |
it != pScripts->end(); ++it) |
it != pScripts->end(); ++it) |
4845 |
{ |
{ |
4846 |
(*it)->UpdateChunks(pProgress); |
(*it)->UpdateChunks(pProgress); |
4855 |
* @param index - number of the sought script (0..n) |
* @param index - number of the sought script (0..n) |
4856 |
* @returns sought script or NULL if there's no such script |
* @returns sought script or NULL if there's no such script |
4857 |
*/ |
*/ |
4858 |
Script* ScriptGroup::GetScript(uint index) { |
Script* ScriptGroup::GetScript(size_t index) { |
4859 |
if (!pScripts) LoadScripts(); |
if (!pScripts) LoadScripts(); |
4860 |
std::list<Script*>::iterator it = pScripts->begin(); |
if (index >= pScripts->size()) return NULL; |
4861 |
for (uint i = 0; it != pScripts->end(); ++i, ++it) |
return (*pScripts)[index]; |
|
if (i == index) return *it; |
|
|
return NULL; |
|
4862 |
} |
} |
4863 |
|
|
4864 |
/** @brief Add new instrument script. |
/** @brief Add new instrument script. |
4891 |
*/ |
*/ |
4892 |
void ScriptGroup::DeleteScript(Script* pScript) { |
void ScriptGroup::DeleteScript(Script* pScript) { |
4893 |
if (!pScripts) LoadScripts(); |
if (!pScripts) LoadScripts(); |
4894 |
std::list<Script*>::iterator iter = |
std::vector<Script*>::iterator iter = |
4895 |
find(pScripts->begin(), pScripts->end(), pScript); |
find(pScripts->begin(), pScripts->end(), pScript); |
4896 |
if (iter == pScripts->end()) |
if (iter == pScripts->end()) |
4897 |
throw gig::Exception("Could not delete script, could not find given script"); |
throw gig::Exception("Could not delete script, could not find given script"); |
4904 |
|
|
4905 |
void ScriptGroup::LoadScripts() { |
void ScriptGroup::LoadScripts() { |
4906 |
if (pScripts) return; |
if (pScripts) return; |
4907 |
pScripts = new std::list<Script*>; |
pScripts = new std::vector<Script*>; |
4908 |
if (!pList) return; |
if (!pList) return; |
4909 |
|
|
4910 |
size_t i = 0; |
size_t i = 0; |
5501 |
File* pFile = (File*) GetParent(); |
File* pFile = (File*) GetParent(); |
5502 |
for (uint k = 0; k < scriptPoolFileOffsets.size(); ++k) { |
for (uint k = 0; k < scriptPoolFileOffsets.size(); ++k) { |
5503 |
uint32_t soughtOffset = scriptPoolFileOffsets[k].fileOffset; |
uint32_t soughtOffset = scriptPoolFileOffsets[k].fileOffset; |
5504 |
for (uint i = 0; pFile->GetScriptGroup(i); ++i) { |
for (size_t i = 0; pFile->GetScriptGroup(i); ++i) { |
5505 |
ScriptGroup* group = pFile->GetScriptGroup(i); |
ScriptGroup* group = pFile->GetScriptGroup(i); |
5506 |
for (uint s = 0; group->GetScript(s); ++s) { |
for (uint s = 0; group->GetScript(s); ++s) { |
5507 |
Script* script = group->GetScript(s); |
Script* script = group->GetScript(s); |
6303 |
delete pGroups; |
delete pGroups; |
6304 |
} |
} |
6305 |
if (pScriptGroups) { |
if (pScriptGroups) { |
6306 |
std::list<ScriptGroup*>::iterator iter = pScriptGroups->begin(); |
std::vector<ScriptGroup*>::iterator iter = pScriptGroups->begin(); |
6307 |
std::list<ScriptGroup*>::iterator end = pScriptGroups->end(); |
std::vector<ScriptGroup*>::iterator end = pScriptGroups->end(); |
6308 |
while (iter != end) { |
while (iter != end) { |
6309 |
delete *iter; |
delete *iter; |
6310 |
++iter; |
++iter; |
6711 |
} |
} |
6712 |
|
|
6713 |
// clone script groups and their scripts |
// clone script groups and their scripts |
6714 |
for (int iGroup = 0; pFile->GetScriptGroup(iGroup); ++iGroup) { |
for (size_t iGroup = 0; pFile->GetScriptGroup(iGroup); ++iGroup) { |
6715 |
ScriptGroup* sg = pFile->GetScriptGroup(iGroup); |
ScriptGroup* sg = pFile->GetScriptGroup(iGroup); |
6716 |
ScriptGroup* dg = AddScriptGroup(); |
ScriptGroup* dg = AddScriptGroup(); |
6717 |
dg->Name = "COPY" + ToString(iCallCount) + "_" + sg->Name; |
dg->Name = "COPY" + ToString(iCallCount) + "_" + sg->Name; |
7103 |
* @param index - number of the sought group (0..n) |
* @param index - number of the sought group (0..n) |
7104 |
* @returns sought script group or NULL if there's no such group |
* @returns sought script group or NULL if there's no such group |
7105 |
*/ |
*/ |
7106 |
ScriptGroup* File::GetScriptGroup(uint index) { |
ScriptGroup* File::GetScriptGroup(size_t index) { |
7107 |
if (!pScriptGroups) LoadScriptGroups(); |
if (!pScriptGroups) LoadScriptGroups(); |
7108 |
std::list<ScriptGroup*>::iterator it = pScriptGroups->begin(); |
if (index >= pScriptGroups->size()) return NULL; |
7109 |
for (uint i = 0; it != pScriptGroups->end(); ++i, ++it) |
return (*pScriptGroups)[index]; |
|
if (i == index) return *it; |
|
|
return NULL; |
|
7110 |
} |
} |
7111 |
|
|
7112 |
/** @brief Get instrument script group (by name). |
/** @brief Get instrument script group (by name). |
7119 |
*/ |
*/ |
7120 |
ScriptGroup* File::GetScriptGroup(const String& name) { |
ScriptGroup* File::GetScriptGroup(const String& name) { |
7121 |
if (!pScriptGroups) LoadScriptGroups(); |
if (!pScriptGroups) LoadScriptGroups(); |
7122 |
std::list<ScriptGroup*>::iterator it = pScriptGroups->begin(); |
for (size_t i = 0; i < pScriptGroups->size(); ++i) { |
7123 |
for (uint i = 0; it != pScriptGroups->end(); ++i, ++it) |
ScriptGroup* pGroup = (*pScriptGroups)[i]; |
7124 |
if ((*it)->Name == name) return *it; |
if (pGroup->Name == name) return pGroup; |
7125 |
|
} |
7126 |
return NULL; |
return NULL; |
7127 |
} |
} |
7128 |
|
|
7155 |
*/ |
*/ |
7156 |
void File::DeleteScriptGroup(ScriptGroup* pScriptGroup) { |
void File::DeleteScriptGroup(ScriptGroup* pScriptGroup) { |
7157 |
if (!pScriptGroups) LoadScriptGroups(); |
if (!pScriptGroups) LoadScriptGroups(); |
7158 |
std::list<ScriptGroup*>::iterator iter = |
std::vector<ScriptGroup*>::iterator iter = |
7159 |
find(pScriptGroups->begin(), pScriptGroups->end(), pScriptGroup); |
find(pScriptGroups->begin(), pScriptGroups->end(), pScriptGroup); |
7160 |
if (iter == pScriptGroups->end()) |
if (iter == pScriptGroups->end()) |
7161 |
throw gig::Exception("Could not delete script group, could not find given script group"); |
throw gig::Exception("Could not delete script group, could not find given script group"); |
7170 |
|
|
7171 |
void File::LoadScriptGroups() { |
void File::LoadScriptGroups() { |
7172 |
if (pScriptGroups) return; |
if (pScriptGroups) return; |
7173 |
pScriptGroups = new std::list<ScriptGroup*>; |
pScriptGroups = new std::vector<ScriptGroup*>; |
7174 |
RIFF::List* lstLS = pRIFF->GetSubList(LIST_TYPE_3LS); |
RIFF::List* lstLS = pRIFF->GetSubList(LIST_TYPE_3LS); |
7175 |
if (lstLS) { |
if (lstLS) { |
7176 |
size_t i = 0; |
size_t i = 0; |
7215 |
// of the respective instrument script chunk as reference. |
// of the respective instrument script chunk as reference. |
7216 |
if (pScriptGroups) { |
if (pScriptGroups) { |
7217 |
// Update instrument script (group) chunks. |
// Update instrument script (group) chunks. |
7218 |
for (std::list<ScriptGroup*>::iterator it = pScriptGroups->begin(); |
for (std::vector<ScriptGroup*>::iterator it = pScriptGroups->begin(); |
7219 |
it != pScriptGroups->end(); ++it) |
it != pScriptGroups->end(); ++it) |
7220 |
{ |
{ |
7221 |
(*it)->UpdateChunks(pProgress); |
(*it)->UpdateChunks(pProgress); |