diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 06758f592..3cdf8af10 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -184,12 +184,29 @@ void CLayerGroup::Render() for(int i = 0; i < m_lLayers.size(); i++) { - if(m_lLayers[i]->m_Visible && m_lLayers[i] != m_pMap->m_pGameLayer + if(m_lLayers[i]->m_Visible) + { + if(m_lLayers[i]->m_Type == LAYERTYPE_TILES) { + CLayerTiles *pTiles = static_cast(m_lLayers[i]); + if(pTiles->m_Game || pTiles->m_Front || pTiles->m_Tele || pTiles->m_Speedup || pTiles->m_Tune || pTiles->m_Switch) + continue; + } + if(m_pMap->m_pEditor->m_ShowDetail || !(m_lLayers[i]->m_Flags&LAYERFLAG_DETAIL)) + m_lLayers[i]->Render(); + } + } + + for(int i = 0; i < m_lLayers.size(); i++) + { + if(m_lLayers[i]->m_Visible && m_lLayers[i]->m_Type == LAYERTYPE_TILES && m_lLayers[i] != m_pMap->m_pGameLayer && m_lLayers[i] != m_pMap->m_pFrontLayer && m_lLayers[i] != m_pMap->m_pTeleLayer && m_lLayers[i] != m_pMap->m_pSpeedupLayer && m_lLayers[i] != m_pMap->m_pSwitchLayer && m_lLayers[i] != m_pMap->m_pTuneLayer) { - if(m_pMap->m_pEditor->m_ShowDetail || !(m_lLayers[i]->m_Flags&LAYERFLAG_DETAIL)) + CLayerTiles *pTiles = static_cast(m_lLayers[i]); + if(pTiles->m_Game || pTiles->m_Front || pTiles->m_Tele || pTiles->m_Speedup || pTiles->m_Tune || pTiles->m_Switch) + { m_lLayers[i]->Render(); + } } } @@ -841,9 +858,14 @@ CLayer *CEditor::GetSelectedLayer(int Index) CLayerGroup *pGroup = GetSelectedGroup(); if(!pGroup) return 0x0; + + if(Index < 0 || Index >= m_lSelectedLayers.size()) + return 0x0; + + int LayerIndex = m_lSelectedLayers[Index]; - if(m_SelectedLayer >= 0 && m_SelectedLayer < m_Map.m_lGroups[m_SelectedGroup]->m_lLayers.size()) - return pGroup->m_lLayers[m_SelectedLayer]; + if(LayerIndex >= 0 && LayerIndex < m_Map.m_lGroups[m_SelectedGroup]->m_lLayers.size()) + return pGroup->m_lLayers[LayerIndex]; return 0x0; } @@ -875,6 +897,12 @@ CSoundSource *CEditor::GetSelectedSource() return 0; } +void CEditor::SelectLayer(int Index) +{ + m_lSelectedLayers.clear(); + m_lSelectedLayers.add(Index); +} + void CEditor::CallbackOpenMap(const char *pFileName, int StorageType, void *pUser) { CEditor *pEditor = (CEditor*)pUser; @@ -2199,7 +2227,7 @@ void CEditor::DoMapEditor(CUIRect View) }; // remap the screen so it can display the whole tileset - if(m_ShowPicker) + if(m_ShowPicker && m_lSelectedLayers.size() == 1) { CUIRect Screen = *UI()->Screen(); float Size = 32.0*16.0f; @@ -2243,25 +2271,27 @@ void CEditor::DoMapEditor(CUIRect View) static int s_Operation = OP_NONE; // draw layer borders - CLayer *pEditLayers[16]; + CLayer *pEditLayers[128]; int NumEditLayers = 0; - NumEditLayers = 0; - if(m_ShowPicker && GetSelectedLayer(0) && GetSelectedLayer(0)->m_Type == LAYERTYPE_TILES) + if(m_ShowPicker && GetSelectedLayer(0) && GetSelectedLayer(0)->m_Type == LAYERTYPE_TILES && m_lSelectedLayers.size() == 1) { pEditLayers[0] = &m_TilesetPicker; NumEditLayers++; } - else if(m_ShowPicker) + else if(m_ShowPicker && m_lSelectedLayers.size() == 1) { pEditLayers[0] = &m_QuadsetPicker; NumEditLayers++; } else { - pEditLayers[0] = GetSelectedLayer(0); - if(pEditLayers[0]) - NumEditLayers++; + for (int i = 0; i < m_lSelectedLayers.size() && NumEditLayers < 128; i++) + { + pEditLayers[NumEditLayers] = GetSelectedLayer(i); + if(pEditLayers[NumEditLayers]) + NumEditLayers++; + } CLayerGroup *g = GetSelectedGroup(); if(g) @@ -2347,8 +2377,10 @@ void CEditor::DoMapEditor(CUIRect View) // draw with brush for(int k = 0; k < NumEditLayers; k++) { - if(pEditLayers[k]->m_Type == m_Brush.m_lLayers[0]->m_Type) - pEditLayers[k]->BrushDraw(m_Brush.m_lLayers[0], wx, wy); + int BrushIndex = k; + if(m_Brush.m_lLayers.size() != NumEditLayers) BrushIndex = 0; + if(pEditLayers[k]->m_Type == m_Brush.m_lLayers[BrushIndex]->m_Type) + pEditLayers[k]->BrushDraw(m_Brush.m_lLayers[BrushIndex], wx, wy); } } } @@ -2381,7 +2413,11 @@ void CEditor::DoMapEditor(CUIRect View) if(!UI()->MouseButton(0)) { for(int k = 0; k < NumEditLayers; k++) - pEditLayers[k]->FillSelection(m_Brush.IsEmpty(), m_Brush.m_lLayers[0], r); + { + int BrushIndex = k; + if(m_Brush.m_lLayers.size() != NumEditLayers) BrushIndex = 0; + pEditLayers[k]->FillSelection(m_Brush.IsEmpty(), m_Brush.m_lLayers[BrushIndex], r); + } } else { @@ -2408,8 +2444,10 @@ void CEditor::DoMapEditor(CUIRect View) s_Operation = OP_BRUSH_DRAW; for(int k = 0; k < NumEditLayers; k++) { - if(pEditLayers[k]->m_Type == m_Brush.m_lLayers[0]->m_Type) - pEditLayers[k]->BrushPlace(m_Brush.m_lLayers[0], wx, wy); + int BrushIndex = k; + if(m_Brush.m_lLayers.size() != NumEditLayers) BrushIndex = 0; + if(pEditLayers[k]->m_Type == m_Brush.m_lLayers[BrushIndex]->m_Type) + pEditLayers[k]->BrushPlace(m_Brush.m_lLayers[BrushIndex], wx, wy); } } @@ -2998,10 +3036,17 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect View) while(TextRender()->TextWidth(0, FontSize, aBuf, -1) > Slot.w) FontSize--; if(int Result = DoButton_Ex(&m_Map.m_lGroups[g], aBuf, g==m_SelectedGroup, &Slot, - BUTTON_CONTEXT, m_Map.m_lGroups[g]->m_Collapse ? "Select group. Double click to expand." : "Select group. Double click to collapse.", 0, FontSize)) + BUTTON_CONTEXT, m_Map.m_lGroups[g]->m_Collapse ? "Select group. Shift click to select all layers. Double click to expand." : "Select group. Shift click to select all layers. Double click to collapse.", 0, FontSize)) { m_SelectedGroup = g; - m_SelectedLayer = 0; + SelectLayer(0); + if ((Input()->KeyIsPressed(KEY_LSHIFT) || Input()->KeyIsPressed(KEY_RSHIFT)) && m_SelectedGroup == g) + { + for(int i = 1; i < m_Map.m_lGroups[g]->m_lLayers.size(); i++) + { + m_lSelectedLayers.add(i); + } + } static int s_GroupPopupId = 0; if(Result == 2) @@ -3050,7 +3095,18 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect View) float FontSize = 10.0f; while(TextRender()->TextWidth(0, FontSize, aBuf, -1) > Button.w) FontSize--; - int Checked = g == m_SelectedGroup && i == m_SelectedLayer; + int Checked = 0; + if (g == m_SelectedGroup) + { + for(int j = 0; j < m_lSelectedLayers.size(); j++) + { + if (m_lSelectedLayers[j] == i) + { + Checked = 1; + } + } + } + if(m_Map.m_lGroups[g]->m_lLayers[i] == m_Map.m_pGameLayer || m_Map.m_lGroups[g]->m_lLayers[i] == m_Map.m_pFrontLayer || m_Map.m_lGroups[g]->m_lLayers[i] == m_Map.m_pSwitchLayer || @@ -3061,10 +3117,18 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect View) Checked += 6; } if(int Result = DoButton_Ex(m_Map.m_lGroups[g]->m_lLayers[i], aBuf, Checked, &Button, - BUTTON_CONTEXT, "Select layer.", 0, FontSize)) + BUTTON_CONTEXT, "Select layer. Shift click to select multiple.", 0, FontSize)) { - m_SelectedLayer = i; - m_SelectedGroup = g; + if ((Input()->KeyIsPressed(KEY_LSHIFT) || Input()->KeyIsPressed(KEY_RSHIFT)) && m_SelectedGroup == g) + { + if(!m_lSelectedLayers.remove(i)) + m_lSelectedLayers.add(i); + } + else + { + m_SelectedGroup = g; + SelectLayer(i); + } static int s_LayerPopupID = 0; if(Result == 2) UiInvokePopupMenu(&s_LayerPopupID, 0, UI()->MouseX(), UI()->MouseY(), 120, 280, PopupLayer); @@ -5322,7 +5386,7 @@ void CEditor::Reset(bool CreateDefault) if(CreateDefault) m_Map.CreateDefault(ms_EntitiesTexture); - m_SelectedLayer = 0; + SelectLayer(0); m_SelectedGroup = 0; m_SelectedQuad = -1; m_SelectedPoints = 0; diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index f89e2e122..f74b6ba45 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -767,6 +767,7 @@ public: CLayer *GetSelectedLayer(int Index); CLayerGroup *GetSelectedGroup(); CSoundSource *GetSelectedSource(); + void SelectLayer(int Index); int DoProperties(CUIRect *pToolbox, CProperty *pProps, int *pIDs, int *pNewVal, vec4 Color = vec4(1,1,1,0.5f)); @@ -877,7 +878,7 @@ public: bool m_ShowServerSettingsEditor; bool m_ShowPicker; - int m_SelectedLayer; + array m_lSelectedLayers; int m_SelectedGroup; int m_SelectedQuad; int m_SelectedPoints; diff --git a/src/game/editor/layer_tiles.cpp b/src/game/editor/layer_tiles.cpp index a10668d01..908b5f299 100644 --- a/src/game/editor/layer_tiles.cpp +++ b/src/game/editor/layer_tiles.cpp @@ -172,7 +172,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect) return 0; // create new layers - if(m_pEditor->GetSelectedLayer(0) == m_pEditor->m_Map.m_pTeleLayer) + if(this == m_pEditor->m_Map.m_pTeleLayer) { CLayerTele *pGrabbed = new CLayerTele(r.w, r.h); pGrabbed->m_pEditor = m_pEditor; @@ -199,7 +199,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect) pGrabbed->m_TeleNum = m_pEditor->m_TeleNumber; str_copy(pGrabbed->m_aFileName, m_pEditor->m_aFileName, sizeof(pGrabbed->m_aFileName)); } - else if(m_pEditor->GetSelectedLayer(0) == m_pEditor->m_Map.m_pSpeedupLayer) + else if(this == m_pEditor->m_Map.m_pSpeedupLayer) { CLayerSpeedup *pGrabbed = new CLayerSpeedup(r.w, r.h); pGrabbed->m_pEditor = m_pEditor; @@ -232,7 +232,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect) pGrabbed->m_SpeedupAngle = m_pEditor->m_SpeedupAngle; str_copy(pGrabbed->m_aFileName, m_pEditor->m_aFileName, sizeof(pGrabbed->m_aFileName)); } - else if(m_pEditor->GetSelectedLayer(0) == m_pEditor->m_Map.m_pSwitchLayer) + else if(this == m_pEditor->m_Map.m_pSwitchLayer) { CLayerSwitch *pGrabbed = new CLayerSwitch(r.w, r.h); pGrabbed->m_pEditor = m_pEditor; @@ -264,7 +264,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect) str_copy(pGrabbed->m_aFileName, m_pEditor->m_aFileName, sizeof(pGrabbed->m_aFileName)); } - else if(m_pEditor->GetSelectedLayer(0) == m_pEditor->m_Map.m_pTuneLayer) + else if(this == m_pEditor->m_Map.m_pTuneLayer) { CLayerTune *pGrabbed = new CLayerTune(r.w, r.h); pGrabbed->m_pEditor = m_pEditor; @@ -292,7 +292,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect) pGrabbed->m_TuningNumber = m_pEditor->m_TuningNum; str_copy(pGrabbed->m_aFileName, m_pEditor->m_aFileName, sizeof(pGrabbed->m_aFileName)); } - else if(m_pEditor->GetSelectedLayer(0) == m_pEditor->m_Map.m_pFrontLayer) + else if(this == m_pEditor->m_Map.m_pFrontLayer) { CLayerFront *pGrabbed = new CLayerFront(r.w, r.h); pGrabbed->m_pEditor = m_pEditor; @@ -1576,7 +1576,7 @@ void CLayerSwitch::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect) CLayerTune::CLayerTune(int w, int h) : CLayerTiles(w, h) { - //m_Type = LAYERTYPE_SWITCH; + //m_Type = LAYERTYPE_TUNE; str_copy(m_aName, "Tune", sizeof(m_aName)); m_Tune = 1; diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index 45c7f6a0e..ec3633a86 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -168,7 +168,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View) CLayer *l = new CLayerTele(pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height); pEditor->m_Map.MakeTeleLayer(l); pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(l); - pEditor->m_SelectedLayer = pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1; + pEditor->SelectLayer(pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1); pEditor->m_Brush.Clear(); return 1; } @@ -185,7 +185,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View) CLayer *l = new CLayerSpeedup(pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height); pEditor->m_Map.MakeSpeedupLayer(l); pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(l); - pEditor->m_SelectedLayer = pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1; + pEditor->SelectLayer(pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1); pEditor->m_Brush.Clear(); return 1; } @@ -202,7 +202,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View) CLayer *l = new CLayerTune(pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height); pEditor->m_Map.MakeTuneLayer(l); pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(l); - pEditor->m_SelectedLayer = pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1; + pEditor->SelectLayer(pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1); pEditor->m_Brush.Clear(); return 1; } @@ -219,7 +219,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View) CLayer *l = new CLayerFront(pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height); pEditor->m_Map.MakeFrontLayer(l); pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(l); - pEditor->m_SelectedLayer = pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1; + pEditor->SelectLayer(pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1); pEditor->m_Brush.Clear(); return 1; } @@ -236,7 +236,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View) CLayer *l = new CLayerSwitch(pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height); pEditor->m_Map.MakeSwitchLayer(l); pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(l); - pEditor->m_SelectedLayer = pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1; + pEditor->SelectLayer(pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1); pEditor->m_Brush.Clear(); return 1; } @@ -251,7 +251,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View) CLayer *l = new CLayerQuads; l->m_pEditor = pEditor; pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(l); - pEditor->m_SelectedLayer = pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1; + pEditor->SelectLayer(pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1); pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_Collapse = false; return 1; } @@ -265,7 +265,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View) CLayer *l = new CLayerTiles(pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height); l->m_pEditor = pEditor; pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(l); - pEditor->m_SelectedLayer = pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1; + pEditor->SelectLayer(pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1); pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_Collapse = false; return 1; } @@ -279,7 +279,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View) CLayer *l = new CLayerSounds; l->m_pEditor = pEditor; pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(l); - pEditor->m_SelectedLayer = pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1; + pEditor->SelectLayer(pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1); pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_Collapse = false; return 1; } @@ -378,7 +378,7 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View) pEditor->m_Map.m_pSwitchLayer = 0x0; if(pEditor->GetSelectedLayer(0) == pEditor->m_Map.m_pTuneLayer) pEditor->m_Map.m_pTuneLayer = 0x0; - pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->DeleteLayer(pEditor->m_SelectedLayer); + pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->DeleteLayer(pEditor->m_lSelectedLayers[0]); return 1; } @@ -410,7 +410,7 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View) CProperty aProps[] = { {"Group", pEditor->m_SelectedGroup, PROPTYPE_INT_STEP, 0, pEditor->m_Map.m_lGroups.size()-1}, - {"Order", pEditor->m_SelectedLayer, PROPTYPE_INT_STEP, 0, pCurrentGroup->m_lLayers.size()}, + {"Order", pEditor->m_lSelectedLayers[0], PROPTYPE_INT_STEP, 0, pCurrentGroup->m_lLayers.size()}, {"Detail", pCurrentLayer->m_Flags&LAYERFLAG_DETAIL, PROPTYPE_BOOL, 0, 1}, {0}, }; @@ -429,7 +429,7 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View) pEditor->m_Map.m_Modified = true; if(Prop == PROP_ORDER) - pEditor->m_SelectedLayer = pCurrentGroup->SwapLayers(pEditor->m_SelectedLayer, NewVal); + pEditor->SelectLayer(pCurrentGroup->SwapLayers(pEditor->m_lSelectedLayers[0], NewVal)); else if(Prop == PROP_GROUP && pCurrentLayer->m_Type != LAYERTYPE_GAME) { if(NewVal >= 0 && NewVal < pEditor->m_Map.m_lGroups.size()) @@ -437,7 +437,7 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View) pCurrentGroup->m_lLayers.remove(pCurrentLayer); pEditor->m_Map.m_lGroups[NewVal]->m_lLayers.add(pCurrentLayer); pEditor->m_SelectedGroup = NewVal; - pEditor->m_SelectedLayer = pEditor->m_Map.m_lGroups[NewVal]->m_lLayers.size()-1; + pEditor->SelectLayer(pEditor->m_Map.m_lGroups[NewVal]->m_lLayers.size()-1); } } else if(Prop == PROP_HQ)