From 2bd9df2626b124a325cc6c0b37e9b2490b4f2985 Mon Sep 17 00:00:00 2001 From: BeaR Date: Thu, 9 Oct 2014 11:28:02 +0200 Subject: [PATCH] Adding support for saving/loading sound layers --- src/game/editor/editor.cpp | 1 + src/game/editor/io.cpp | 40 ++++++++++++++++++++++++++++++++++++++ src/game/mapitems.h | 11 +++++++++++ 3 files changed, 52 insertions(+) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 00923ead3..4d62a0fce 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -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(); diff --git a/src/game/editor/io.cpp b/src/game/editor/io.cpp index 390c7461d..2d45b440e 100644 --- a/src/game/editor/io.cpp +++ b/src/game/editor/io.cpp @@ -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; diff --git a/src/game/mapitems.h b/src/game/mapitems.h index 107a4c342..0cb6351a2 100644 --- a/src/game/mapitems.h +++ b/src/game/mapitems.h @@ -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