Allow multiple layers to be selected and edited at the same time.

This commit is contained in:
Bojidar Marinov 2018-07-25 23:57:58 +03:00
parent 0336b662c5
commit aa091bb8f7
No known key found for this signature in database
GPG key ID: 4D546A8F1E091856
4 changed files with 108 additions and 43 deletions

View file

@ -184,12 +184,29 @@ void CLayerGroup::Render()
for(int i = 0; i < m_lLayers.size(); i++) 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<CLayerTiles *>(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_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) && 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<CLayerTiles *>(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(); m_lLayers[i]->Render();
}
} }
} }
@ -842,8 +859,13 @@ CLayer *CEditor::GetSelectedLayer(int Index)
if(!pGroup) if(!pGroup)
return 0x0; return 0x0;
if(m_SelectedLayer >= 0 && m_SelectedLayer < m_Map.m_lGroups[m_SelectedGroup]->m_lLayers.size()) if(Index < 0 || Index >= m_lSelectedLayers.size())
return pGroup->m_lLayers[m_SelectedLayer]; return 0x0;
int LayerIndex = m_lSelectedLayers[Index];
if(LayerIndex >= 0 && LayerIndex < m_Map.m_lGroups[m_SelectedGroup]->m_lLayers.size())
return pGroup->m_lLayers[LayerIndex];
return 0x0; return 0x0;
} }
@ -875,6 +897,12 @@ CSoundSource *CEditor::GetSelectedSource()
return 0; return 0;
} }
void CEditor::SelectLayer(int Index)
{
m_lSelectedLayers.clear();
m_lSelectedLayers.add(Index);
}
void CEditor::CallbackOpenMap(const char *pFileName, int StorageType, void *pUser) void CEditor::CallbackOpenMap(const char *pFileName, int StorageType, void *pUser)
{ {
CEditor *pEditor = (CEditor*)pUser; CEditor *pEditor = (CEditor*)pUser;
@ -2199,7 +2227,7 @@ void CEditor::DoMapEditor(CUIRect View)
}; };
// remap the screen so it can display the whole tileset // remap the screen so it can display the whole tileset
if(m_ShowPicker) if(m_ShowPicker && m_lSelectedLayers.size() == 1)
{ {
CUIRect Screen = *UI()->Screen(); CUIRect Screen = *UI()->Screen();
float Size = 32.0*16.0f; float Size = 32.0*16.0f;
@ -2243,25 +2271,27 @@ void CEditor::DoMapEditor(CUIRect View)
static int s_Operation = OP_NONE; static int s_Operation = OP_NONE;
// draw layer borders // draw layer borders
CLayer *pEditLayers[16]; CLayer *pEditLayers[128];
int NumEditLayers = 0; 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; pEditLayers[0] = &m_TilesetPicker;
NumEditLayers++; NumEditLayers++;
} }
else if(m_ShowPicker) else if(m_ShowPicker && m_lSelectedLayers.size() == 1)
{ {
pEditLayers[0] = &m_QuadsetPicker; pEditLayers[0] = &m_QuadsetPicker;
NumEditLayers++; NumEditLayers++;
} }
else else
{ {
pEditLayers[0] = GetSelectedLayer(0); for (int i = 0; i < m_lSelectedLayers.size() && NumEditLayers < 128; i++)
if(pEditLayers[0]) {
NumEditLayers++; pEditLayers[NumEditLayers] = GetSelectedLayer(i);
if(pEditLayers[NumEditLayers])
NumEditLayers++;
}
CLayerGroup *g = GetSelectedGroup(); CLayerGroup *g = GetSelectedGroup();
if(g) if(g)
@ -2347,8 +2377,10 @@ void CEditor::DoMapEditor(CUIRect View)
// draw with brush // draw with brush
for(int k = 0; k < NumEditLayers; k++) for(int k = 0; k < NumEditLayers; k++)
{ {
if(pEditLayers[k]->m_Type == m_Brush.m_lLayers[0]->m_Type) int BrushIndex = k;
pEditLayers[k]->BrushDraw(m_Brush.m_lLayers[0], wx, wy); 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)) if(!UI()->MouseButton(0))
{ {
for(int k = 0; k < NumEditLayers; k++) 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 else
{ {
@ -2408,8 +2444,10 @@ void CEditor::DoMapEditor(CUIRect View)
s_Operation = OP_BRUSH_DRAW; s_Operation = OP_BRUSH_DRAW;
for(int k = 0; k < NumEditLayers; k++) for(int k = 0; k < NumEditLayers; k++)
{ {
if(pEditLayers[k]->m_Type == m_Brush.m_lLayers[0]->m_Type) int BrushIndex = k;
pEditLayers[k]->BrushPlace(m_Brush.m_lLayers[0], wx, wy); 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) while(TextRender()->TextWidth(0, FontSize, aBuf, -1) > Slot.w)
FontSize--; FontSize--;
if(int Result = DoButton_Ex(&m_Map.m_lGroups[g], aBuf, g==m_SelectedGroup, &Slot, 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_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; static int s_GroupPopupId = 0;
if(Result == 2) if(Result == 2)
@ -3050,7 +3095,18 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect View)
float FontSize = 10.0f; float FontSize = 10.0f;
while(TextRender()->TextWidth(0, FontSize, aBuf, -1) > Button.w) while(TextRender()->TextWidth(0, FontSize, aBuf, -1) > Button.w)
FontSize--; 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 || 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_pFrontLayer ||
m_Map.m_lGroups[g]->m_lLayers[i] == m_Map.m_pSwitchLayer || 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; Checked += 6;
} }
if(int Result = DoButton_Ex(m_Map.m_lGroups[g]->m_lLayers[i], aBuf, Checked, &Button, 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; if ((Input()->KeyIsPressed(KEY_LSHIFT) || Input()->KeyIsPressed(KEY_RSHIFT)) && m_SelectedGroup == g)
m_SelectedGroup = g; {
if(!m_lSelectedLayers.remove(i))
m_lSelectedLayers.add(i);
}
else
{
m_SelectedGroup = g;
SelectLayer(i);
}
static int s_LayerPopupID = 0; static int s_LayerPopupID = 0;
if(Result == 2) if(Result == 2)
UiInvokePopupMenu(&s_LayerPopupID, 0, UI()->MouseX(), UI()->MouseY(), 120, 280, PopupLayer); UiInvokePopupMenu(&s_LayerPopupID, 0, UI()->MouseX(), UI()->MouseY(), 120, 280, PopupLayer);
@ -5322,7 +5386,7 @@ void CEditor::Reset(bool CreateDefault)
if(CreateDefault) if(CreateDefault)
m_Map.CreateDefault(ms_EntitiesTexture); m_Map.CreateDefault(ms_EntitiesTexture);
m_SelectedLayer = 0; SelectLayer(0);
m_SelectedGroup = 0; m_SelectedGroup = 0;
m_SelectedQuad = -1; m_SelectedQuad = -1;
m_SelectedPoints = 0; m_SelectedPoints = 0;

View file

@ -767,6 +767,7 @@ public:
CLayer *GetSelectedLayer(int Index); CLayer *GetSelectedLayer(int Index);
CLayerGroup *GetSelectedGroup(); CLayerGroup *GetSelectedGroup();
CSoundSource *GetSelectedSource(); CSoundSource *GetSelectedSource();
void SelectLayer(int Index);
int DoProperties(CUIRect *pToolbox, CProperty *pProps, int *pIDs, int *pNewVal, vec4 Color = vec4(1,1,1,0.5f)); 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_ShowServerSettingsEditor;
bool m_ShowPicker; bool m_ShowPicker;
int m_SelectedLayer; array<int> m_lSelectedLayers;
int m_SelectedGroup; int m_SelectedGroup;
int m_SelectedQuad; int m_SelectedQuad;
int m_SelectedPoints; int m_SelectedPoints;

View file

@ -172,7 +172,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
return 0; return 0;
// create new layers // 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); CLayerTele *pGrabbed = new CLayerTele(r.w, r.h);
pGrabbed->m_pEditor = m_pEditor; pGrabbed->m_pEditor = m_pEditor;
@ -199,7 +199,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
pGrabbed->m_TeleNum = m_pEditor->m_TeleNumber; pGrabbed->m_TeleNum = m_pEditor->m_TeleNumber;
str_copy(pGrabbed->m_aFileName, m_pEditor->m_aFileName, sizeof(pGrabbed->m_aFileName)); 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); CLayerSpeedup *pGrabbed = new CLayerSpeedup(r.w, r.h);
pGrabbed->m_pEditor = m_pEditor; pGrabbed->m_pEditor = m_pEditor;
@ -232,7 +232,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
pGrabbed->m_SpeedupAngle = m_pEditor->m_SpeedupAngle; pGrabbed->m_SpeedupAngle = m_pEditor->m_SpeedupAngle;
str_copy(pGrabbed->m_aFileName, m_pEditor->m_aFileName, sizeof(pGrabbed->m_aFileName)); 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); CLayerSwitch *pGrabbed = new CLayerSwitch(r.w, r.h);
pGrabbed->m_pEditor = m_pEditor; 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)); 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); CLayerTune *pGrabbed = new CLayerTune(r.w, r.h);
pGrabbed->m_pEditor = m_pEditor; pGrabbed->m_pEditor = m_pEditor;
@ -292,7 +292,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
pGrabbed->m_TuningNumber = m_pEditor->m_TuningNum; pGrabbed->m_TuningNumber = m_pEditor->m_TuningNum;
str_copy(pGrabbed->m_aFileName, m_pEditor->m_aFileName, sizeof(pGrabbed->m_aFileName)); 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); CLayerFront *pGrabbed = new CLayerFront(r.w, r.h);
pGrabbed->m_pEditor = m_pEditor; pGrabbed->m_pEditor = m_pEditor;
@ -1576,7 +1576,7 @@ void CLayerSwitch::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
CLayerTune::CLayerTune(int w, int h) CLayerTune::CLayerTune(int w, int h)
: CLayerTiles(w, h) : CLayerTiles(w, h)
{ {
//m_Type = LAYERTYPE_SWITCH; //m_Type = LAYERTYPE_TUNE;
str_copy(m_aName, "Tune", sizeof(m_aName)); str_copy(m_aName, "Tune", sizeof(m_aName));
m_Tune = 1; m_Tune = 1;

View file

@ -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); 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.MakeTeleLayer(l);
pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(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(); pEditor->m_Brush.Clear();
return 1; 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); 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.MakeSpeedupLayer(l);
pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(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(); pEditor->m_Brush.Clear();
return 1; 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); 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.MakeTuneLayer(l);
pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(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(); pEditor->m_Brush.Clear();
return 1; 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); 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.MakeFrontLayer(l);
pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(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(); pEditor->m_Brush.Clear();
return 1; 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); 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.MakeSwitchLayer(l);
pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(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(); pEditor->m_Brush.Clear();
return 1; return 1;
} }
@ -251,7 +251,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View)
CLayer *l = new CLayerQuads; CLayer *l = new CLayerQuads;
l->m_pEditor = pEditor; l->m_pEditor = pEditor;
pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(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_Map.m_lGroups[pEditor->m_SelectedGroup]->m_Collapse = false; pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_Collapse = false;
return 1; 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); CLayer *l = new CLayerTiles(pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
l->m_pEditor = pEditor; l->m_pEditor = pEditor;
pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(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_Map.m_lGroups[pEditor->m_SelectedGroup]->m_Collapse = false; pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_Collapse = false;
return 1; return 1;
} }
@ -279,7 +279,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View)
CLayer *l = new CLayerSounds; CLayer *l = new CLayerSounds;
l->m_pEditor = pEditor; l->m_pEditor = pEditor;
pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(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_Map.m_lGroups[pEditor->m_SelectedGroup]->m_Collapse = false; pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_Collapse = false;
return 1; return 1;
} }
@ -378,7 +378,7 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View)
pEditor->m_Map.m_pSwitchLayer = 0x0; pEditor->m_Map.m_pSwitchLayer = 0x0;
if(pEditor->GetSelectedLayer(0) == pEditor->m_Map.m_pTuneLayer) if(pEditor->GetSelectedLayer(0) == pEditor->m_Map.m_pTuneLayer)
pEditor->m_Map.m_pTuneLayer = 0x0; 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; return 1;
} }
@ -410,7 +410,7 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View)
CProperty aProps[] = { CProperty aProps[] = {
{"Group", pEditor->m_SelectedGroup, PROPTYPE_INT_STEP, 0, pEditor->m_Map.m_lGroups.size()-1}, {"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}, {"Detail", pCurrentLayer->m_Flags&LAYERFLAG_DETAIL, PROPTYPE_BOOL, 0, 1},
{0}, {0},
}; };
@ -429,7 +429,7 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View)
pEditor->m_Map.m_Modified = true; pEditor->m_Map.m_Modified = true;
if(Prop == PROP_ORDER) 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) else if(Prop == PROP_GROUP && pCurrentLayer->m_Type != LAYERTYPE_GAME)
{ {
if(NewVal >= 0 && NewVal < pEditor->m_Map.m_lGroups.size()) 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); pCurrentGroup->m_lLayers.remove(pCurrentLayer);
pEditor->m_Map.m_lGroups[NewVal]->m_lLayers.add(pCurrentLayer); pEditor->m_Map.m_lGroups[NewVal]->m_lLayers.add(pCurrentLayer);
pEditor->m_SelectedGroup = NewVal; 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) else if(Prop == PROP_HQ)