mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Add CLayer::IsEntitiesLayer
to reduce duplicate code
This commit is contained in:
parent
cd13871053
commit
50ecfb178f
|
@ -153,6 +153,8 @@ public:
|
|||
virtual void BrushFlipY() {}
|
||||
virtual void BrushRotate(float Amount) {}
|
||||
|
||||
virtual bool IsEntitiesLayer() const { return false; }
|
||||
|
||||
virtual void Render(bool Tileset = false) {}
|
||||
virtual int RenderProperties(CUIRect *pToolbox) { return 0; }
|
||||
|
||||
|
@ -608,6 +610,8 @@ public:
|
|||
void Snap(CUIRect *pRect);
|
||||
void Clamp(RECTi *pRect);
|
||||
|
||||
virtual bool IsEntitiesLayer() const override;
|
||||
|
||||
virtual bool IsEmpty(CLayerTiles *pLayer);
|
||||
void BrushSelecting(CUIRect Rect) override;
|
||||
int BrushGrab(CLayerGroup *pBrush, CUIRect Rect) override;
|
||||
|
|
|
@ -177,6 +177,11 @@ void CLayerTiles::Clamp(RECTi *pRect)
|
|||
pRect->w = 0;
|
||||
}
|
||||
|
||||
bool CLayerTiles::IsEntitiesLayer() const
|
||||
{
|
||||
return m_pEditor->m_Map.m_pGameLayer == this || m_pEditor->m_Map.m_pTeleLayer == this || m_pEditor->m_Map.m_pSpeedupLayer == this || m_pEditor->m_Map.m_pFrontLayer == this || m_pEditor->m_Map.m_pSwitchLayer == this || m_pEditor->m_Map.m_pTuneLayer == this;
|
||||
}
|
||||
|
||||
bool CLayerTiles::IsEmpty(CLayerTiles *pLayer)
|
||||
{
|
||||
for(int y = 0; y < pLayer->m_Height; y++)
|
||||
|
@ -683,12 +688,12 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
|
|||
{
|
||||
CUIRect Button;
|
||||
|
||||
bool IsGameLayer = (m_pEditor->m_Map.m_pGameLayer == this || m_pEditor->m_Map.m_pTeleLayer == this || m_pEditor->m_Map.m_pSpeedupLayer == this || m_pEditor->m_Map.m_pFrontLayer == this || m_pEditor->m_Map.m_pSwitchLayer == this || m_pEditor->m_Map.m_pTuneLayer == this);
|
||||
const bool EntitiesLayer = IsEntitiesLayer();
|
||||
|
||||
CLayerGroup *pGroup = m_pEditor->m_Map.m_vpGroups[m_pEditor->m_SelectedGroup];
|
||||
|
||||
// Game tiles can only be constructed if the layer is relative to the game layer
|
||||
if(!IsGameLayer && !(pGroup->m_OffsetX % 32) && !(pGroup->m_OffsetY % 32) && pGroup->m_ParallaxX == 100 && pGroup->m_ParallaxY == 100)
|
||||
if(!EntitiesLayer && !(pGroup->m_OffsetX % 32) && !(pGroup->m_OffsetY % 32) && pGroup->m_ParallaxX == 100 && pGroup->m_ParallaxY == 100)
|
||||
{
|
||||
pToolBox->HSplitBottom(12.0f, pToolBox, &Button);
|
||||
static int s_ColclButton = 0;
|
||||
|
@ -847,7 +852,7 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
|
|||
{nullptr},
|
||||
};
|
||||
|
||||
if(IsGameLayer) // remove the image and color properties if this is a game layer
|
||||
if(EntitiesLayer) // remove the image and color properties if this is a game layer
|
||||
{
|
||||
aProps[PROP_IMAGE].m_pName = nullptr;
|
||||
aProps[PROP_COLOR].m_pName = nullptr;
|
||||
|
|
|
@ -479,8 +479,8 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
{nullptr},
|
||||
};
|
||||
|
||||
// if(pEditor->m_Map.m_pGameLayer == pEditor->GetSelectedLayer(0)) // don't use Group and Detail from the selection if this is the game layer
|
||||
if(pEditor->m_Map.m_pGameLayer == pEditor->GetSelectedLayer(0) || pEditor->m_Map.m_pTeleLayer == pEditor->GetSelectedLayer(0) || pEditor->m_Map.m_pSpeedupLayer == pEditor->GetSelectedLayer(0) || pEditor->m_Map.m_pFrontLayer == pEditor->GetSelectedLayer(0) || pEditor->m_Map.m_pSwitchLayer == pEditor->GetSelectedLayer(0) || pEditor->m_Map.m_pTuneLayer == pEditor->GetSelectedLayer(0)) // don't use Group and Detail from the selection if this is the game layer
|
||||
// don't use Group and Detail from the selection if this is an entities layer
|
||||
if(pEditor->GetSelectedLayer(0)->IsEntitiesLayer())
|
||||
{
|
||||
aProps[0].m_Type = PROPTYPE_NULL;
|
||||
aProps[2].m_Type = PROPTYPE_NULL;
|
||||
|
|
Loading…
Reference in a new issue