mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-17 21:48:19 +00:00
Select previous layer after deletion
This commit is contained in:
parent
e5fffb0ab8
commit
6a2afb6f60
|
@ -738,6 +738,54 @@ std::pair<int, int> CEditor::EnvGetSelectedTimeAndValue() const
|
|||
return std::pair<int, int>{CurrentTime, CurrentValue};
|
||||
}
|
||||
|
||||
void CEditor::SelectNextLayer()
|
||||
{
|
||||
int CurrentLayer = 0;
|
||||
for(const auto &Selected : m_vSelectedLayers)
|
||||
CurrentLayer = maximum(Selected, CurrentLayer);
|
||||
SelectLayer(CurrentLayer);
|
||||
|
||||
if(m_vSelectedLayers[0] < (int)m_Map.m_vpGroups[m_SelectedGroup]->m_vpLayers.size() - 1)
|
||||
{
|
||||
SelectLayer(m_vSelectedLayers[0] + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(size_t Group = m_SelectedGroup + 1; Group < m_Map.m_vpGroups.size(); Group++)
|
||||
{
|
||||
if(!m_Map.m_vpGroups[Group]->m_vpLayers.empty())
|
||||
{
|
||||
SelectLayer(0, Group);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CEditor::SelectPreviousLayer()
|
||||
{
|
||||
int CurrentLayer = std::numeric_limits<int>::max();
|
||||
for(const auto &Selected : m_vSelectedLayers)
|
||||
CurrentLayer = minimum(Selected, CurrentLayer);
|
||||
SelectLayer(CurrentLayer);
|
||||
|
||||
if(m_vSelectedLayers[0] > 0)
|
||||
{
|
||||
SelectLayer(m_vSelectedLayers[0] - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int Group = m_SelectedGroup - 1; Group >= 0; Group--)
|
||||
{
|
||||
if(!m_Map.m_vpGroups[Group]->m_vpLayers.empty())
|
||||
{
|
||||
SelectLayer(m_Map.m_vpGroups[Group]->m_vpLayers.size() - 1, Group);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CEditor::CallbackOpenMap(const char *pFileName, int StorageType, void *pUser)
|
||||
{
|
||||
CEditor *pEditor = (CEditor *)pUser;
|
||||
|
@ -4195,26 +4243,7 @@ void CEditor::RenderLayers(CUIRect LayersBox)
|
|||
}
|
||||
else
|
||||
{
|
||||
int CurrentLayer = 0;
|
||||
for(const auto &Selected : m_vSelectedLayers)
|
||||
CurrentLayer = maximum(Selected, CurrentLayer);
|
||||
SelectLayer(CurrentLayer);
|
||||
|
||||
if(m_vSelectedLayers[0] < (int)m_Map.m_vpGroups[m_SelectedGroup]->m_vpLayers.size() - 1)
|
||||
{
|
||||
SelectLayer(m_vSelectedLayers[0] + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(size_t Group = m_SelectedGroup + 1; Group < m_Map.m_vpGroups.size(); Group++)
|
||||
{
|
||||
if(!m_Map.m_vpGroups[Group]->m_vpLayers.empty())
|
||||
{
|
||||
SelectLayer(0, Group);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
SelectNextLayer();
|
||||
}
|
||||
s_ScrollToSelectionNext = true;
|
||||
}
|
||||
|
@ -4227,27 +4256,9 @@ void CEditor::RenderLayers(CUIRect LayersBox)
|
|||
}
|
||||
else
|
||||
{
|
||||
int CurrentLayer = std::numeric_limits<int>::max();
|
||||
for(const auto &Selected : m_vSelectedLayers)
|
||||
CurrentLayer = minimum(Selected, CurrentLayer);
|
||||
SelectLayer(CurrentLayer);
|
||||
|
||||
if(m_vSelectedLayers[0] > 0)
|
||||
{
|
||||
SelectLayer(m_vSelectedLayers[0] - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int Group = m_SelectedGroup - 1; Group >= 0; Group--)
|
||||
{
|
||||
if(!m_Map.m_vpGroups[Group]->m_vpLayers.empty())
|
||||
{
|
||||
SelectLayer(m_Map.m_vpGroups[Group]->m_vpLayers.size() - 1, Group);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
SelectPreviousLayer();
|
||||
}
|
||||
|
||||
s_ScrollToSelectionNext = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -324,6 +324,9 @@ public:
|
|||
const CMapView *MapView() const { return &m_MapView; }
|
||||
CLayerSelector *LayerSelector() { return &m_LayerSelector; }
|
||||
|
||||
void SelectNextLayer();
|
||||
void SelectPreviousLayer();
|
||||
|
||||
void FillGameTiles(EGameTileOp FillTile) const;
|
||||
bool CanFillGameTiles() const;
|
||||
void AddQuadOrSound();
|
||||
|
|
|
@ -157,4 +157,6 @@ void CEditor::DeleteSelectedLayer()
|
|||
if(pCurrentLayer == m_Map.m_pTuneLayer)
|
||||
m_Map.m_pTuneLayer = nullptr;
|
||||
m_Map.m_vpGroups[m_SelectedGroup]->DeleteLayer(m_vSelectedLayers[0]);
|
||||
|
||||
SelectPreviousLayer();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue