Adding support for saving/loading sound layers

This commit is contained in:
BeaR 2014-10-09 11:28:02 +02:00
parent d968b42f2f
commit 2bd9df2626
3 changed files with 52 additions and 0 deletions

View file

@ -4572,6 +4572,7 @@ void CEditorMap::Clean()
m_lGroups.delete_all();
m_lEnvelopes.delete_all();
m_lImages.delete_all();
m_lSounds.delete_all();
m_MapInfo.Reset();

View file

@ -415,6 +415,28 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
LayerCount++;
}
}
else if(pGroup->m_lLayers[l]->m_Type == LAYERTYPE_SOUNDS)
{
m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving sounds layer");
CLayerSounds *pLayer = (CLayerSounds *)pGroup->m_lLayers[l];
//if(pLayer->m_lSoundSources.size())
{
CMapItemLayerSounds Item;
Item.m_Version = CMapItemLayerSounds::CURRENT_VERSION;
Item.m_Layer.m_Flags = pLayer->m_Flags;
Item.m_Layer.m_Type = pLayer->m_Type;
Item.m_Sound = pLayer->m_Sound;
// TODO: add the data
// save layer name
StrToInts(Item.m_aName, sizeof(Item.m_aName)/sizeof(int), pLayer->m_aName);
df.AddItem(MAPITEMTYPE_LAYER, LayerCount, sizeof(Item), &Item);
GItem.m_NumLayers++;
LayerCount++;
}
}
}
df.AddItem(MAPITEMTYPE_GROUP, GroupCount++, sizeof(GItem), &GItem);
@ -885,6 +907,24 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
mem_copy(pQuads->m_lQuads.base_ptr(), pData, sizeof(CQuad)*pQuadsItem->m_NumQuads);
DataFile.UnloadData(pQuadsItem->m_Data);
}
else if(pLayerItem->m_Type == LAYERTYPE_SOUNDS)
{
CMapItemLayerSounds *pSoundsItem = (CMapItemLayerSounds *)pLayerItem;
CLayerSounds *pSounds = new CLayerSounds;
pSounds->m_pEditor = m_pEditor;
pLayer = pSounds;
pSounds->m_Sound = pSoundsItem->m_Sound;
// TODO: validate m_Sound
// load layer name
if(pSoundsItem->m_Version >= 1)
IntsToStr(pSoundsItem->m_aName, sizeof(pSounds->m_aName)/sizeof(int), pSounds->m_aName);
// TODO: load data
pGroup->AddLayer(pSounds);
}
if(pLayer)
pLayer->m_Flags = pLayerItem->m_Flags;

View file

@ -328,6 +328,17 @@ struct CMapItemEnvelope : public CMapItemEnvelope_v1
int m_Synchronized;
};
struct CMapItemLayerSounds
{
enum { CURRENT_VERSION=1 };
CMapItemLayer m_Layer;
int m_Version;
int m_Sound;
int m_aName[3];
};
// DDRace