take pointer to editor in CLayer constructor

This commit is contained in:
marmare314 2023-09-05 15:16:41 +02:00
parent d400687876
commit ac6f6bd28e
25 changed files with 64 additions and 72 deletions

View file

@ -404,7 +404,7 @@ void CAutoMapper::ProceedLocalized(CLayerTiles *pLayer, int ConfigID, int Seed,
int UpdateToX = clamp(X + Width + 3 * pConf->m_EndX, 0, pLayer->m_Width);
int UpdateToY = clamp(Y + Height + 3 * pConf->m_EndY, 0, pLayer->m_Height);
CLayerTiles *pUpdateLayer = new CLayerTiles(UpdateToX - UpdateFromX, UpdateToY - UpdateFromY);
CLayerTiles *pUpdateLayer = new CLayerTiles(Editor(), UpdateToX - UpdateFromX, UpdateToY - UpdateFromY);
for(int y = UpdateFromY; y < UpdateToY; y++)
{
@ -452,7 +452,7 @@ void CAutoMapper::Proceed(CLayerTiles *pLayer, int ConfigID, int Seed, int SeedO
CLayerTiles *pReadLayer;
if(pRun->m_AutomapCopy)
{
pReadLayer = new CLayerTiles(pLayer->m_Width, pLayer->m_Height);
pReadLayer = new CLayerTiles(Editor(), pLayer->m_Width, pLayer->m_Height);
for(int y = 0; y < pLayer->m_Height; y++)
{

View file

@ -7542,13 +7542,11 @@ void CEditor::Init()
m_BackgroundTexture = Graphics()->LoadTexture("editor/background.png", IStorage::TYPE_ALL);
m_CursorTexture = Graphics()->LoadTexture("editor/cursor.png", IStorage::TYPE_ALL);
m_pTilesetPicker = std::make_shared<CLayerTiles>(16, 16);
m_pTilesetPicker->m_pEditor = this;
m_pTilesetPicker = std::make_shared<CLayerTiles>(this, 16, 16);
m_pTilesetPicker->MakePalette();
m_pTilesetPicker->m_Readonly = true;
m_pQuadsetPicker = std::make_shared<CLayerQuads>();
m_pQuadsetPicker->m_pEditor = this;
m_pQuadsetPicker = std::make_shared<CLayerQuads>(this);
m_pQuadsetPicker->NewQuad(0, 0, 64, 64);
m_pQuadsetPicker->m_Readonly = true;

View file

@ -19,14 +19,14 @@ public:
class IGraphics *Graphics();
class ITextRender *TextRender();
CLayer()
explicit CLayer(CEditor *pEditor)
{
m_Type = LAYERTYPE_INVALID;
str_copy(m_aName, "(invalid)");
m_Visible = true;
m_Readonly = false;
m_Flags = 0;
m_pEditor = nullptr;
m_pEditor = pEditor;
}
CLayer(const CLayer &Other)

View file

@ -1,7 +1,7 @@
#include <game/editor/editor.h>
CLayerFront::CLayerFront(int w, int h) :
CLayerTiles(w, h)
CLayerFront::CLayerFront(CEditor *pEditor, int w, int h) :
CLayerTiles(pEditor, w, h)
{
str_copy(m_aName, "Front");
m_Front = 1;

View file

@ -6,7 +6,7 @@
class CLayerFront : public CLayerTiles
{
public:
CLayerFront(int w, int h);
CLayerFront(CEditor *pEditor, int w, int h);
void Resize(int NewW, int NewH) override;
void SetTile(int x, int y, CTile Tile) override;

View file

@ -4,8 +4,8 @@
#include <game/editor/editor.h>
CLayerGame::CLayerGame(int w, int h) :
CLayerTiles(w, h)
CLayerGame::CLayerGame(CEditor *pEditor, int w, int h) :
CLayerTiles(pEditor, w, h)
{
str_copy(m_aName, "Game");
m_Game = 1;
@ -32,7 +32,7 @@ void CLayerGame::SetTile(int x, int y, CTile Tile)
{
if(!m_pEditor->m_Map.m_pFrontLayer)
{
std::shared_ptr<CLayer> pLayerFront = std::make_shared<CLayerFront>(m_Width, m_Height);
std::shared_ptr<CLayer> pLayerFront = std::make_shared<CLayerFront>(m_pEditor, m_Width, m_Height);
m_pEditor->m_Map.MakeFrontLayer(pLayerFront);
m_pEditor->m_Map.m_pGameGroup->AddLayer(pLayerFront);
}

View file

@ -6,7 +6,7 @@
class CLayerGame : public CLayerTiles
{
public:
CLayerGame(int w, int h);
CLayerGame(CEditor *pEditor, int w, int h);
~CLayerGame();
CTile GetTile(int x, int y) override;

View file

@ -6,7 +6,8 @@
#include "image.h"
CLayerQuads::CLayerQuads()
CLayerQuads::CLayerQuads(CEditor *pEditor) :
CLayer(pEditor)
{
m_Type = LAYERTYPE_QUADS;
m_aName[0] = '\0';
@ -109,8 +110,7 @@ void CLayerQuads::BrushSelecting(CUIRect Rect)
int CLayerQuads::BrushGrab(std::shared_ptr<CLayerGroup> pBrush, CUIRect Rect)
{
// create new layers
std::shared_ptr<CLayerQuads> pGrabbed = std::make_shared<CLayerQuads>();
pGrabbed->m_pEditor = m_pEditor;
std::shared_ptr<CLayerQuads> pGrabbed = std::make_shared<CLayerQuads>(m_pEditor);
pGrabbed->m_Image = m_Image;
pBrush->AddLayer(pGrabbed);

View file

@ -6,7 +6,7 @@
class CLayerQuads : public CLayer
{
public:
CLayerQuads();
explicit CLayerQuads(CEditor *pEditor);
CLayerQuads(const CLayerQuads &Other);
~CLayerQuads();

View file

@ -6,7 +6,8 @@
static const float s_SourceVisualSize = 32.0f;
CLayerSounds::CLayerSounds()
CLayerSounds::CLayerSounds(CEditor *pEditor) :
CLayer(pEditor)
{
m_Type = LAYERTYPE_SOUNDS;
m_aName[0] = '\0';
@ -144,8 +145,7 @@ void CLayerSounds::BrushSelecting(CUIRect Rect)
int CLayerSounds::BrushGrab(std::shared_ptr<CLayerGroup> pBrush, CUIRect Rect)
{
// create new layer
std::shared_ptr<CLayerSounds> pGrabbed = std::make_shared<CLayerSounds>();
pGrabbed->m_pEditor = m_pEditor;
std::shared_ptr<CLayerSounds> pGrabbed = std::make_shared<CLayerSounds>(m_pEditor);
pGrabbed->m_Sound = m_Sound;
pBrush->AddLayer(pGrabbed);

View file

@ -6,7 +6,7 @@
class CLayerSounds : public CLayer
{
public:
CLayerSounds();
explicit CLayerSounds(CEditor *pEditor);
CLayerSounds(const CLayerSounds &Other);
~CLayerSounds();

View file

@ -2,8 +2,8 @@
#include <game/editor/editor.h>
CLayerSpeedup::CLayerSpeedup(int w, int h) :
CLayerTiles(w, h)
CLayerSpeedup::CLayerSpeedup(CEditor *pEditor, int w, int h) :
CLayerTiles(pEditor, w, h)
{
str_copy(m_aName, "Speedup");
m_Speedup = 1;

View file

@ -6,7 +6,7 @@
class CLayerSpeedup : public CLayerTiles
{
public:
CLayerSpeedup(int w, int h);
CLayerSpeedup(CEditor *pEditor, int w, int h);
~CLayerSpeedup();
CSpeedupTile *m_pSpeedupTile;

View file

@ -2,8 +2,8 @@
#include <game/editor/editor.h>
CLayerSwitch::CLayerSwitch(int w, int h) :
CLayerTiles(w, h)
CLayerSwitch::CLayerSwitch(CEditor *pEditor, int w, int h) :
CLayerTiles(pEditor, w, h)
{
str_copy(m_aName, "Switch");
m_Switch = 1;

View file

@ -6,7 +6,7 @@
class CLayerSwitch : public CLayerTiles
{
public:
CLayerSwitch(int w, int h);
CLayerSwitch(CEditor *pEditor, int w, int h);
~CLayerSwitch();
CSwitchTile *m_pSwitchTile;

View file

@ -2,8 +2,8 @@
#include <game/editor/editor.h>
CLayerTele::CLayerTele(int w, int h) :
CLayerTiles(w, h)
CLayerTele::CLayerTele(CEditor *pEditor, int w, int h) :
CLayerTiles(pEditor, w, h)
{
str_copy(m_aName, "Tele");
m_Tele = 1;

View file

@ -6,7 +6,7 @@
class CLayerTele : public CLayerTiles
{
public:
CLayerTele(int w, int h);
CLayerTele(CEditor *pEditor, int w, int h);
~CLayerTele();
CTeleTile *m_pTeleTile;

View file

@ -9,7 +9,8 @@
#include "image.h"
CLayerTiles::CLayerTiles(int w, int h)
CLayerTiles::CLayerTiles(CEditor *pEditor, int w, int h) :
CLayer(pEditor)
{
m_Type = LAYERTYPE_TILES;
m_aName[0] = '\0';
@ -273,7 +274,7 @@ int CLayerTiles::BrushGrab(std::shared_ptr<CLayerGroup> pBrush, CUIRect Rect)
// create new layers
if(this->m_Tele)
{
std::shared_ptr<CLayerTele> pGrabbed = std::make_shared<CLayerTele>(r.w, r.h);
std::shared_ptr<CLayerTele> pGrabbed = std::make_shared<CLayerTele>(m_pEditor, r.w, r.h);
InitGrabbedLayer(pGrabbed, this);
pBrush->AddLayer(pGrabbed);
@ -299,7 +300,7 @@ int CLayerTiles::BrushGrab(std::shared_ptr<CLayerGroup> pBrush, CUIRect Rect)
}
else if(this->m_Speedup)
{
std::shared_ptr<CLayerSpeedup> pGrabbed = std::make_shared<CLayerSpeedup>(r.w, r.h);
std::shared_ptr<CLayerSpeedup> pGrabbed = std::make_shared<CLayerSpeedup>(m_pEditor, r.w, r.h);
InitGrabbedLayer(pGrabbed, this);
pBrush->AddLayer(pGrabbed);
@ -329,7 +330,7 @@ int CLayerTiles::BrushGrab(std::shared_ptr<CLayerGroup> pBrush, CUIRect Rect)
}
else if(this->m_Switch)
{
std::shared_ptr<CLayerSwitch> pGrabbed = std::make_shared<CLayerSwitch>(r.w, r.h);
std::shared_ptr<CLayerSwitch> pGrabbed = std::make_shared<CLayerSwitch>(m_pEditor, r.w, r.h);
InitGrabbedLayer(pGrabbed, this);
pBrush->AddLayer(pGrabbed);
@ -358,7 +359,7 @@ int CLayerTiles::BrushGrab(std::shared_ptr<CLayerGroup> pBrush, CUIRect Rect)
else if(this->m_Tune)
{
std::shared_ptr<CLayerTune> pGrabbed = std::make_shared<CLayerTune>(r.w, r.h);
std::shared_ptr<CLayerTune> pGrabbed = std::make_shared<CLayerTune>(m_pEditor, r.w, r.h);
InitGrabbedLayer(pGrabbed, this);
pBrush->AddLayer(pGrabbed);
@ -384,7 +385,7 @@ int CLayerTiles::BrushGrab(std::shared_ptr<CLayerGroup> pBrush, CUIRect Rect)
}
else if(this->m_Front)
{
std::shared_ptr<CLayerFront> pGrabbed = std::make_shared<CLayerFront>(r.w, r.h);
std::shared_ptr<CLayerFront> pGrabbed = std::make_shared<CLayerFront>(m_pEditor, r.w, r.h);
InitGrabbedLayer(pGrabbed, this);
pBrush->AddLayer(pGrabbed);
@ -397,7 +398,7 @@ int CLayerTiles::BrushGrab(std::shared_ptr<CLayerGroup> pBrush, CUIRect Rect)
}
else
{
std::shared_ptr<CLayerTiles> pGrabbed = std::make_shared<CLayerFront>(r.w, r.h);
std::shared_ptr<CLayerTiles> pGrabbed = std::make_shared<CLayerFront>(m_pEditor, r.w, r.h);
InitGrabbedLayer(pGrabbed, this);
pBrush->AddLayer(pGrabbed);
@ -743,7 +744,7 @@ CUI::EPopupMenuFunctionResult CLayerTiles::RenderProperties(CUIRect *pToolBox)
{
if(!m_pEditor->m_Map.m_pTeleLayer)
{
std::shared_ptr<CLayer> pLayer = std::make_shared<CLayerTele>(m_Width, m_Height);
std::shared_ptr<CLayer> pLayer = std::make_shared<CLayerTele>(m_pEditor, m_Width, m_Height);
m_pEditor->m_Map.MakeTeleLayer(pLayer);
m_pEditor->m_Map.m_pGameGroup->AddLayer(pLayer);
}

View file

@ -83,7 +83,7 @@ protected:
}
public:
CLayerTiles(int w, int h);
CLayerTiles(CEditor *pEditor, int w, int h);
CLayerTiles(const CLayerTiles &Other);
~CLayerTiles();

View file

@ -2,8 +2,8 @@
#include <game/editor/editor.h>
CLayerTune::CLayerTune(int w, int h) :
CLayerTiles(w, h)
CLayerTune::CLayerTune(CEditor *pEditor, int w, int h) :
CLayerTiles(pEditor, w, h)
{
str_copy(m_aName, "Tune");
m_Tune = 1;

View file

@ -6,7 +6,7 @@
class CLayerTune : public CLayerTiles
{
public:
CLayerTune(int w, int h);
CLayerTune(CEditor *pEditor, int w, int h);
~CLayerTune();
CTuneTile *m_pTuneTile;

View file

@ -127,8 +127,7 @@ void CEditorMap::CreateDefault(IGraphics::CTextureHandle EntitiesTexture)
pGroup->m_ParallaxY = 0;
pGroup->m_CustomParallaxZoom = 0;
pGroup->m_ParallaxZoom = 0;
std::shared_ptr<CLayerQuads> pLayer = std::make_shared<CLayerQuads>();
pLayer->m_pEditor = m_pEditor;
std::shared_ptr<CLayerQuads> pLayer = std::make_shared<CLayerQuads>(m_pEditor);
CQuad *pQuad = pLayer->NewQuad(0, 0, 1600, 1200);
pQuad->m_aColors[0].r = pQuad->m_aColors[1].r = 94;
pQuad->m_aColors[0].g = pQuad->m_aColors[1].g = 132;
@ -140,7 +139,7 @@ void CEditorMap::CreateDefault(IGraphics::CTextureHandle EntitiesTexture)
// add game layer and reset front, tele, speedup, tune and switch layer pointers
MakeGameGroup(NewGroup());
MakeGameLayer(std::make_shared<CLayerGame>(50, 50));
MakeGameLayer(std::make_shared<CLayerGame>(m_pEditor, 50, 50));
m_pGameGroup->AddLayer(m_pGameLayer);
m_pFrontLayer = nullptr;

View file

@ -640,7 +640,7 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
std::shared_ptr<CLayerTiles> pTiles;
if(pTilemapItem->m_Flags & TILESLAYERFLAG_GAME)
{
pTiles = std::make_shared<CLayerGame>(pTilemapItem->m_Width, pTilemapItem->m_Height);
pTiles = std::make_shared<CLayerGame>(m_pEditor, pTilemapItem->m_Width, pTilemapItem->m_Height);
MakeGameLayer(pTiles);
MakeGameGroup(pGroup);
}
@ -649,7 +649,7 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
if(pTilemapItem->m_Version <= 2)
pTilemapItem->m_Tele = *((const int *)(pTilemapItem) + 15);
pTiles = std::make_shared<CLayerTele>(pTilemapItem->m_Width, pTilemapItem->m_Height);
pTiles = std::make_shared<CLayerTele>(m_pEditor, pTilemapItem->m_Width, pTilemapItem->m_Height);
MakeTeleLayer(pTiles);
}
else if(pTilemapItem->m_Flags & TILESLAYERFLAG_SPEEDUP)
@ -657,7 +657,7 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
if(pTilemapItem->m_Version <= 2)
pTilemapItem->m_Speedup = *((const int *)(pTilemapItem) + 16);
pTiles = std::make_shared<CLayerSpeedup>(pTilemapItem->m_Width, pTilemapItem->m_Height);
pTiles = std::make_shared<CLayerSpeedup>(m_pEditor, pTilemapItem->m_Width, pTilemapItem->m_Height);
MakeSpeedupLayer(pTiles);
}
else if(pTilemapItem->m_Flags & TILESLAYERFLAG_FRONT)
@ -665,7 +665,7 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
if(pTilemapItem->m_Version <= 2)
pTilemapItem->m_Front = *((const int *)(pTilemapItem) + 17);
pTiles = std::make_shared<CLayerFront>(pTilemapItem->m_Width, pTilemapItem->m_Height);
pTiles = std::make_shared<CLayerFront>(m_pEditor, pTilemapItem->m_Width, pTilemapItem->m_Height);
MakeFrontLayer(pTiles);
}
else if(pTilemapItem->m_Flags & TILESLAYERFLAG_SWITCH)
@ -673,7 +673,7 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
if(pTilemapItem->m_Version <= 2)
pTilemapItem->m_Switch = *((const int *)(pTilemapItem) + 18);
pTiles = std::make_shared<CLayerSwitch>(pTilemapItem->m_Width, pTilemapItem->m_Height);
pTiles = std::make_shared<CLayerSwitch>(m_pEditor, pTilemapItem->m_Width, pTilemapItem->m_Height);
MakeSwitchLayer(pTiles);
}
else if(pTilemapItem->m_Flags & TILESLAYERFLAG_TUNE)
@ -681,12 +681,12 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
if(pTilemapItem->m_Version <= 2)
pTilemapItem->m_Tune = *((const int *)(pTilemapItem) + 19);
pTiles = std::make_shared<CLayerTune>(pTilemapItem->m_Width, pTilemapItem->m_Height);
pTiles = std::make_shared<CLayerTune>(m_pEditor, pTilemapItem->m_Width, pTilemapItem->m_Height);
MakeTuneLayer(pTiles);
}
else
{
pTiles = std::make_shared<CLayerTiles>(pTilemapItem->m_Width, pTilemapItem->m_Height);
pTiles = std::make_shared<CLayerTiles>(m_pEditor, pTilemapItem->m_Width, pTilemapItem->m_Height);
pTiles->m_pEditor = m_pEditor;
pTiles->m_Color = pTilemapItem->m_Color;
pTiles->m_ColorEnv = pTilemapItem->m_ColorEnv;
@ -819,8 +819,7 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
{
const CMapItemLayerQuads *pQuadsItem = (CMapItemLayerQuads *)pLayerItem;
std::shared_ptr<CLayerQuads> pQuads = std::make_shared<CLayerQuads>();
pQuads->m_pEditor = m_pEditor;
std::shared_ptr<CLayerQuads> pQuads = std::make_shared<CLayerQuads>(m_pEditor);
pQuads->m_Flags = pLayerItem->m_Flags;
pQuads->m_Image = pQuadsItem->m_Image;
if(pQuads->m_Image < -1 || pQuads->m_Image >= (int)m_vpImages.size())
@ -842,8 +841,7 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
if(pSoundsItem->m_Version < 1 || pSoundsItem->m_Version > CMapItemLayerSounds::CURRENT_VERSION)
continue;
std::shared_ptr<CLayerSounds> pSounds = std::make_shared<CLayerSounds>();
pSounds->m_pEditor = m_pEditor;
std::shared_ptr<CLayerSounds> pSounds = std::make_shared<CLayerSounds>(m_pEditor);
pSounds->m_Flags = pLayerItem->m_Flags;
pSounds->m_Sound = pSoundsItem->m_Sound;
@ -868,8 +866,7 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
if(pSoundsItem->m_Version < 1 || pSoundsItem->m_Version > CMapItemLayerSounds::CURRENT_VERSION)
continue;
std::shared_ptr<CLayerSounds> pSounds = std::make_shared<CLayerSounds>();
pSounds->m_pEditor = m_pEditor;
std::shared_ptr<CLayerSounds> pSounds = std::make_shared<CLayerSounds>(m_pEditor);
pSounds->m_Flags = pLayerItem->m_Flags;
pSounds->m_Sound = pSoundsItem->m_Sound;

View file

@ -394,7 +394,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
static int s_NewTeleLayerButton = 0;
if(pEditor->DoButton_Editor(&s_NewTeleLayerButton, "Add tele layer", 0, &Button, 0, "Creates a new tele layer"))
{
std::shared_ptr<CLayer> pTeleLayer = std::make_shared<CLayerTele>(pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
std::shared_ptr<CLayer> pTeleLayer = std::make_shared<CLayerTele>(pEditor, pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
pEditor->m_Map.MakeTeleLayer(pTeleLayer);
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(pTeleLayer);
pEditor->SelectLayer(pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_vpLayers.size() - 1);
@ -411,7 +411,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
static int s_NewSpeedupLayerButton = 0;
if(pEditor->DoButton_Editor(&s_NewSpeedupLayerButton, "Add speedup layer", 0, &Button, 0, "Creates a new speedup layer"))
{
std::shared_ptr<CLayer> pSpeedupLayer = std::make_shared<CLayerSpeedup>(pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
std::shared_ptr<CLayer> pSpeedupLayer = std::make_shared<CLayerSpeedup>(pEditor, pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
pEditor->m_Map.MakeSpeedupLayer(pSpeedupLayer);
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(pSpeedupLayer);
pEditor->SelectLayer(pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_vpLayers.size() - 1);
@ -428,7 +428,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
static int s_NewTuneLayerButton = 0;
if(pEditor->DoButton_Editor(&s_NewTuneLayerButton, "Add tune layer", 0, &Button, 0, "Creates a new tuning layer"))
{
std::shared_ptr<CLayer> pTuneLayer = std::make_shared<CLayerTune>(pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
std::shared_ptr<CLayer> pTuneLayer = std::make_shared<CLayerTune>(pEditor, pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
pEditor->m_Map.MakeTuneLayer(pTuneLayer);
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(pTuneLayer);
pEditor->SelectLayer(pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_vpLayers.size() - 1);
@ -445,7 +445,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
static int s_NewFrontLayerButton = 0;
if(pEditor->DoButton_Editor(&s_NewFrontLayerButton, "Add front layer", 0, &Button, 0, "Creates a new item layer"))
{
std::shared_ptr<CLayer> pFrontLayer = std::make_shared<CLayerFront>(pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
std::shared_ptr<CLayer> pFrontLayer = std::make_shared<CLayerFront>(pEditor, pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
pEditor->m_Map.MakeFrontLayer(pFrontLayer);
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(pFrontLayer);
pEditor->SelectLayer(pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_vpLayers.size() - 1);
@ -462,7 +462,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
static int s_NewSwitchLayerButton = 0;
if(pEditor->DoButton_Editor(&s_NewSwitchLayerButton, "Add switch layer", 0, &Button, 0, "Creates a new switch layer"))
{
std::shared_ptr<CLayer> pSwitchLayer = std::make_shared<CLayerSwitch>(pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
std::shared_ptr<CLayer> pSwitchLayer = std::make_shared<CLayerSwitch>(pEditor, pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
pEditor->m_Map.MakeSwitchLayer(pSwitchLayer);
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(pSwitchLayer);
pEditor->SelectLayer(pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_vpLayers.size() - 1);
@ -477,8 +477,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
static int s_NewQuadLayerButton = 0;
if(pEditor->DoButton_Editor(&s_NewQuadLayerButton, "Add quads layer", 0, &Button, 0, "Creates a new quad layer"))
{
std::shared_ptr<CLayer> pQuadLayer = std::make_shared<CLayerQuads>();
pQuadLayer->m_pEditor = pEditor;
std::shared_ptr<CLayer> pQuadLayer = std::make_shared<CLayerQuads>(pEditor);
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(pQuadLayer);
pEditor->SelectLayer(pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_vpLayers.size() - 1);
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_Collapse = false;
@ -491,7 +490,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
static int s_NewTileLayerButton = 0;
if(pEditor->DoButton_Editor(&s_NewTileLayerButton, "Add tile layer", 0, &Button, 0, "Creates a new tile layer"))
{
std::shared_ptr<CLayer> pTileLayer = std::make_shared<CLayerTiles>(pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
std::shared_ptr<CLayer> pTileLayer = std::make_shared<CLayerTiles>(pEditor, pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
pTileLayer->m_pEditor = pEditor;
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(pTileLayer);
pEditor->SelectLayer(pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_vpLayers.size() - 1);
@ -505,8 +504,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
static int s_NewSoundLayerButton = 0;
if(pEditor->DoButton_Editor(&s_NewSoundLayerButton, "Add sound layer", 0, &Button, 0, "Creates a new sound layer"))
{
std::shared_ptr<CLayer> pSoundLayer = std::make_shared<CLayerSounds>();
pSoundLayer->m_pEditor = pEditor;
std::shared_ptr<CLayer> pSoundLayer = std::make_shared<CLayerSounds>(pEditor);
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(pSoundLayer);
pEditor->SelectLayer(pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_vpLayers.size() - 1);
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_Collapse = false;

View file

@ -167,9 +167,8 @@ static std::shared_ptr<CLayerTiles> AddLayerWithImage(CEditor *pEditor, const st
std::shared_ptr<CEditorImage> pEditorImage = ImageInfoToEditorImage(pEditor, Image, pName);
pEditor->m_Map.m_vpImages.push_back(pEditorImage);
std::shared_ptr<CLayerTiles> pLayer = std::make_shared<CLayerTiles>(Width, Height);
std::shared_ptr<CLayerTiles> pLayer = std::make_shared<CLayerTiles>(pEditor, Width, Height);
str_copy(pLayer->m_aName, pName);
pLayer->m_pEditor = pEditor;
pLayer->m_Image = pEditor->m_Map.m_vpImages.size() - 1;
pGroup->AddLayer(pLayer);