diff options
| author | oy <Tom_Adams@web.de> | 2010-08-06 20:18:53 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2010-08-06 20:18:53 +0200 |
| commit | 2967c57ddcaf00f3a1fc1688b7f7fa974c1d2b9d (patch) | |
| tree | 6c283c37ca7552887c3f83972e5e1684a7277584 | |
| parent | 05f3757491abbca38dd789574951d46c28ce746c (diff) | |
| download | zcatch-2967c57ddcaf00f3a1fc1688b7f7fa974c1d2b9d.tar.gz zcatch-2967c57ddcaf00f3a1fc1688b7f7fa974c1d2b9d.zip | |
added possibility to delete envelopes and to save their names within a map by sushitee
| -rw-r--r-- | src/game/editor/ed_editor.cpp | 68 | ||||
| -rw-r--r-- | src/game/editor/ed_editor.h | 2 | ||||
| -rw-r--r-- | src/game/editor/ed_io.cpp | 5 | ||||
| -rw-r--r-- | src/game/mapitems.h | 2 |
4 files changed, 61 insertions, 16 deletions
diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 015b9946..c75ff238 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -2286,31 +2286,18 @@ void CEditor::RenderStatusbar(CUIRect View) void CEditor::RenderEnvelopeEditor(CUIRect View) { if(m_SelectedEnvelope < 0) m_SelectedEnvelope = 0; - if(m_SelectedEnvelope >= m_Map.m_lEnvelopes.size()) m_SelectedEnvelope--; + if(m_SelectedEnvelope >= m_Map.m_lEnvelopes.size()) m_SelectedEnvelope = m_Map.m_lEnvelopes.size()-1; CEnvelope *pEnvelope = 0; if(m_SelectedEnvelope >= 0 && m_SelectedEnvelope < m_Map.m_lEnvelopes.size()) pEnvelope = m_Map.m_lEnvelopes[m_SelectedEnvelope]; - bool ShowColorBar = false; - if(pEnvelope && pEnvelope->m_Channels == 4) - ShowColorBar = true; - CUIRect ToolBar, CurveBar, ColorBar; View.HSplitTop(15.0f, &ToolBar, &View); View.HSplitTop(15.0f, &CurveBar, &View); ToolBar.Margin(2.0f, &ToolBar); CurveBar.Margin(2.0f, &CurveBar); - if(ShowColorBar) - { - View.HSplitTop(20.0f, &ColorBar, &View); - ColorBar.Margin(2.0f, &ColorBar); - RenderBackground(ColorBar, ms_CheckerTexture, 16.0f, 1.0f); - } - - RenderBackground(View, ms_CheckerTexture, 32.0f, 0.1f); - // do the toolbar { CUIRect Button; @@ -2327,6 +2314,21 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) if(DoButton_Editor(&s_New2dButton, Localize("Pos.+"), 0, &Button, 0, Localize("Creates a new pos envelope"))) pNewEnv = m_Map.NewEnvelope(3); + // Delete button + if(m_SelectedEnvelope >= 0) + { + ToolBar.VSplitRight(10.0f, &ToolBar, &Button); + ToolBar.VSplitRight(50.0f, &ToolBar, &Button); + static int s_DelButton = 0; + if(DoButton_Editor(&s_DelButton, Localize("Delete"), 0, &Button, 0, Localize("Delete this envelope"))) + { + m_Map.DeleteEnvelope(m_SelectedEnvelope); + if(m_SelectedEnvelope >= m_Map.m_lEnvelopes.size()) + m_SelectedEnvelope = m_Map.m_lEnvelopes.size()-1; + pEnvelope = m_SelectedEnvelope >= 0 ? m_Map.m_lEnvelopes[m_SelectedEnvelope] : 0; + } + } + if(pNewEnv) // add the default points { if(pNewEnv->m_Channels == 4) @@ -2371,6 +2373,17 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) } } + bool ShowColorBar = false; + if(pEnvelope && pEnvelope->m_Channels == 4) + { + ShowColorBar = true; + View.HSplitTop(20.0f, &ColorBar, &View); + ColorBar.Margin(2.0f, &ColorBar); + RenderBackground(ColorBar, ms_CheckerTexture, 16.0f, 1.0f); + } + + RenderBackground(View, ms_CheckerTexture, 32.0f, 0.1f); + if(pEnvelope) { static array<int> Selection; @@ -2900,6 +2913,33 @@ void CEditor::Reset(bool CreateDefault) m_MouseDeltaWy = 0; } +void CEditorMap::DeleteEnvelope(int Index) +{ + if(Index < 0 || Index >= m_lEnvelopes.size()) + return; + + // fix links between envelopes and quads + for(int i = 0; i < m_lGroups.size(); ++i) + for(int j = 0; j < m_lGroups[i]->m_lLayers.size(); ++j) + if(m_lGroups[i]->m_lLayers[j]->m_Type == LAYERTYPE_QUADS) + { + CLayerQuads *Layer = static_cast<CLayerQuads *>(m_lGroups[i]->m_lLayers[j]); + for(int k = 0; k < Layer->m_lQuads.size(); ++k) + { + if(Layer->m_lQuads[k].m_PosEnv == Index) + Layer->m_lQuads[k].m_PosEnv = -1; + else if(Layer->m_lQuads[k].m_PosEnv > Index) + Layer->m_lQuads[k].m_PosEnv--; + if(Layer->m_lQuads[k].m_ColorEnv == Index) + Layer->m_lQuads[k].m_ColorEnv = -1; + else if(Layer->m_lQuads[k].m_ColorEnv > Index) + Layer->m_lQuads[k].m_ColorEnv--; + } + } + + m_lEnvelopes.remove_index(Index); +} + void CEditorMap::MakeGameLayer(CLayer *pLayer) { m_pGameLayer = (CLayerGame *)pLayer; diff --git a/src/game/editor/ed_editor.h b/src/game/editor/ed_editor.h index a7d742a8..e459e70f 100644 --- a/src/game/editor/ed_editor.h +++ b/src/game/editor/ed_editor.h @@ -272,6 +272,8 @@ public: m_lEnvelopes.add(e); return e; } + + void DeleteEnvelope(int Index); CLayerGroup *NewGroup() { diff --git a/src/game/editor/ed_io.cpp b/src/game/editor/ed_io.cpp index c2666138..4d514051 100644 --- a/src/game/editor/ed_io.cpp +++ b/src/game/editor/ed_io.cpp @@ -1,5 +1,6 @@ #include <engine/graphics.h> #include <engine/storage.h> +#include <game/gamecore.h> #include "ed_editor.h" template<typename T> @@ -323,7 +324,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName) Item.m_Channels = m_lEnvelopes[e]->m_Channels; Item.m_StartPoint = PointCount; Item.m_NumPoints = m_lEnvelopes[e]->m_lPoints.size(); - Item.m_Name = -1; + StrToInts(Item.m_aName, sizeof(Item.m_aName)/sizeof(int), m_lEnvelopes[e]->m_aName); df.AddItem(MAPITEMTYPE_ENVELOPE, e, sizeof(Item), &Item); PointCount += Item.m_NumPoints; @@ -552,6 +553,8 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName) CEnvelope *pEnv = new CEnvelope(pItem->m_Channels); pEnv->m_lPoints.set_size(pItem->m_NumPoints); mem_copy(pEnv->m_lPoints.base_ptr(), &pPoints[pItem->m_StartPoint], sizeof(CEnvPoint)*pItem->m_NumPoints); + if(pItem->m_aName[0] != -1) // compatibility with old maps + IntsToStr(pItem->m_aName, sizeof(pItem->m_aName)/sizeof(int), pEnv->m_aName); m_lEnvelopes.add(pEnv); } } diff --git a/src/game/mapitems.h b/src/game/mapitems.h index 4fe4c159..06ceab4e 100644 --- a/src/game/mapitems.h +++ b/src/game/mapitems.h @@ -174,7 +174,7 @@ struct CMapItemEnvelope int m_Channels; int m_StartPoint; int m_NumPoints; - int m_Name; + int m_aName[8]; } ; #endif |