mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Use std::shared_ptr
for editor resources, fix crashes with brush
Simplify memory management of groups, layers, images, sounds and envelopes by using `std::shared_ptr` for all of them. Clear brush when creating a new map to prevent crash due to unloaded textures being used in tile layer. Closes #6935. Also fix crash when restoring a saved brush after removing an image that is being used by it.
This commit is contained in:
parent
1f1cc80001
commit
6f03aabb34
File diff suppressed because it is too large
Load diff
|
@ -23,6 +23,7 @@
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -199,7 +200,6 @@ public:
|
||||||
m_Readonly = false;
|
m_Readonly = false;
|
||||||
m_Flags = 0;
|
m_Flags = 0;
|
||||||
m_pEditor = nullptr;
|
m_pEditor = nullptr;
|
||||||
m_BrushRefCount = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CLayer(const CLayer &Other)
|
CLayer(const CLayer &Other)
|
||||||
|
@ -208,7 +208,6 @@ public:
|
||||||
m_Flags = Other.m_Flags;
|
m_Flags = Other.m_Flags;
|
||||||
m_pEditor = Other.m_pEditor;
|
m_pEditor = Other.m_pEditor;
|
||||||
m_Type = Other.m_Type;
|
m_Type = Other.m_Type;
|
||||||
m_BrushRefCount = 0;
|
|
||||||
m_Visible = true;
|
m_Visible = true;
|
||||||
m_Readonly = false;
|
m_Readonly = false;
|
||||||
}
|
}
|
||||||
|
@ -218,10 +217,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void BrushSelecting(CUIRect Rect) {}
|
virtual void BrushSelecting(CUIRect Rect) {}
|
||||||
virtual int BrushGrab(CLayerGroup *pBrush, CUIRect Rect) { return 0; }
|
virtual int BrushGrab(std::shared_ptr<CLayerGroup> pBrush, CUIRect Rect) { return 0; }
|
||||||
virtual void FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect) {}
|
virtual void FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CUIRect Rect) {}
|
||||||
virtual void BrushDraw(CLayer *pBrush, float x, float y) {}
|
virtual void BrushDraw(std::shared_ptr<CLayer> pBrush, float x, float y) {}
|
||||||
virtual void BrushPlace(CLayer *pBrush, float x, float y) {}
|
virtual void BrushPlace(std::shared_ptr<CLayer> pBrush, float x, float y) {}
|
||||||
virtual void BrushFlipX() {}
|
virtual void BrushFlipX() {}
|
||||||
virtual void BrushFlipY() {}
|
virtual void BrushFlipY() {}
|
||||||
virtual void BrushRotate(float Amount) {}
|
virtual void BrushRotate(float Amount) {}
|
||||||
|
@ -235,7 +234,7 @@ public:
|
||||||
virtual void ModifyEnvelopeIndex(FIndexModifyFunction pfnFunc) {}
|
virtual void ModifyEnvelopeIndex(FIndexModifyFunction pfnFunc) {}
|
||||||
virtual void ModifySoundIndex(FIndexModifyFunction pfnFunc) {}
|
virtual void ModifySoundIndex(FIndexModifyFunction pfnFunc) {}
|
||||||
|
|
||||||
virtual CLayer *Duplicate() const = 0;
|
virtual std::shared_ptr<CLayer> Duplicate() const = 0;
|
||||||
|
|
||||||
virtual void GetSize(float *pWidth, float *pHeight)
|
virtual void GetSize(float *pWidth, float *pHeight)
|
||||||
{
|
{
|
||||||
|
@ -249,7 +248,6 @@ public:
|
||||||
|
|
||||||
bool m_Readonly;
|
bool m_Readonly;
|
||||||
bool m_Visible;
|
bool m_Visible;
|
||||||
int m_BrushRefCount;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CLayerGroup
|
class CLayerGroup
|
||||||
|
@ -257,7 +255,7 @@ class CLayerGroup
|
||||||
public:
|
public:
|
||||||
class CEditorMap *m_pMap;
|
class CEditorMap *m_pMap;
|
||||||
|
|
||||||
std::vector<CLayer *> m_vpLayers;
|
std::vector<std::shared_ptr<CLayer>> m_vpLayers;
|
||||||
|
|
||||||
int m_OffsetX;
|
int m_OffsetX;
|
||||||
int m_OffsetY;
|
int m_OffsetY;
|
||||||
|
@ -308,7 +306,7 @@ public:
|
||||||
m_vpLayers.clear();
|
m_vpLayers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddLayer(CLayer *pLayer);
|
void AddLayer(const std::shared_ptr<CLayer> &pLayer);
|
||||||
|
|
||||||
void ModifyImageIndex(FIndexModifyFunction Func)
|
void ModifyImageIndex(FIndexModifyFunction Func)
|
||||||
{
|
{
|
||||||
|
@ -384,8 +382,8 @@ public:
|
||||||
|
|
||||||
class CEditorMap
|
class CEditorMap
|
||||||
{
|
{
|
||||||
void MakeGameGroup(CLayerGroup *pGroup);
|
void MakeGameGroup(std::shared_ptr<CLayerGroup> pGroup);
|
||||||
void MakeGameLayer(CLayer *pLayer);
|
void MakeGameLayer(const std::shared_ptr<CLayer> &pLayer);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CEditor *m_pEditor;
|
CEditor *m_pEditor;
|
||||||
|
@ -407,10 +405,10 @@ public:
|
||||||
float m_LastAutosaveUpdateTime;
|
float m_LastAutosaveUpdateTime;
|
||||||
void OnModify();
|
void OnModify();
|
||||||
|
|
||||||
std::vector<CLayerGroup *> m_vpGroups;
|
std::vector<std::shared_ptr<CLayerGroup>> m_vpGroups;
|
||||||
std::vector<CEditorImage *> m_vpImages;
|
std::vector<std::shared_ptr<CEditorImage>> m_vpImages;
|
||||||
std::vector<CEnvelope *> m_vpEnvelopes;
|
std::vector<std::shared_ptr<CEnvelope>> m_vpEnvelopes;
|
||||||
std::vector<CEditorSound *> m_vpSounds;
|
std::vector<std::shared_ptr<CEditorSound>> m_vpSounds;
|
||||||
|
|
||||||
class CMapInfo
|
class CMapInfo
|
||||||
{
|
{
|
||||||
|
@ -450,13 +448,13 @@ public:
|
||||||
};
|
};
|
||||||
std::vector<CSetting> m_vSettings;
|
std::vector<CSetting> m_vSettings;
|
||||||
|
|
||||||
class CLayerGame *m_pGameLayer;
|
std::shared_ptr<class CLayerGame> m_pGameLayer;
|
||||||
CLayerGroup *m_pGameGroup;
|
std::shared_ptr<CLayerGroup> m_pGameGroup;
|
||||||
|
|
||||||
CEnvelope *NewEnvelope(int Channels)
|
std::shared_ptr<CEnvelope> NewEnvelope(int Channels)
|
||||||
{
|
{
|
||||||
OnModify();
|
OnModify();
|
||||||
CEnvelope *pEnv = new CEnvelope(Channels);
|
std::shared_ptr<CEnvelope> pEnv = std::make_shared<CEnvelope>(Channels);
|
||||||
m_vpEnvelopes.push_back(pEnv);
|
m_vpEnvelopes.push_back(pEnv);
|
||||||
return pEnv;
|
return pEnv;
|
||||||
}
|
}
|
||||||
|
@ -466,10 +464,10 @@ public:
|
||||||
template<typename F>
|
template<typename F>
|
||||||
void VisitEnvelopeReferences(F &&Visitor);
|
void VisitEnvelopeReferences(F &&Visitor);
|
||||||
|
|
||||||
CLayerGroup *NewGroup()
|
std::shared_ptr<CLayerGroup> NewGroup()
|
||||||
{
|
{
|
||||||
OnModify();
|
OnModify();
|
||||||
CLayerGroup *pGroup = new CLayerGroup;
|
std::shared_ptr<CLayerGroup> pGroup = std::make_shared<CLayerGroup>();
|
||||||
pGroup->m_pMap = this;
|
pGroup->m_pMap = this;
|
||||||
m_vpGroups.push_back(pGroup);
|
m_vpGroups.push_back(pGroup);
|
||||||
return pGroup;
|
return pGroup;
|
||||||
|
@ -493,7 +491,6 @@ public:
|
||||||
if(Index < 0 || Index >= (int)m_vpGroups.size())
|
if(Index < 0 || Index >= (int)m_vpGroups.size())
|
||||||
return;
|
return;
|
||||||
OnModify();
|
OnModify();
|
||||||
delete m_vpGroups[Index];
|
|
||||||
m_vpGroups.erase(m_vpGroups.begin() + Index);
|
m_vpGroups.erase(m_vpGroups.begin() + Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,16 +525,16 @@ public:
|
||||||
|
|
||||||
// DDRace
|
// DDRace
|
||||||
|
|
||||||
class CLayerTele *m_pTeleLayer;
|
std::shared_ptr<class CLayerTele> m_pTeleLayer;
|
||||||
class CLayerSpeedup *m_pSpeedupLayer;
|
std::shared_ptr<class CLayerSpeedup> m_pSpeedupLayer;
|
||||||
class CLayerFront *m_pFrontLayer;
|
std::shared_ptr<class CLayerFront> m_pFrontLayer;
|
||||||
class CLayerSwitch *m_pSwitchLayer;
|
std::shared_ptr<class CLayerSwitch> m_pSwitchLayer;
|
||||||
class CLayerTune *m_pTuneLayer;
|
std::shared_ptr<class CLayerTune> m_pTuneLayer;
|
||||||
void MakeTeleLayer(CLayer *pLayer);
|
void MakeTeleLayer(const std::shared_ptr<CLayer> &pLayer);
|
||||||
void MakeSpeedupLayer(CLayer *pLayer);
|
void MakeSpeedupLayer(const std::shared_ptr<CLayer> &pLayer);
|
||||||
void MakeFrontLayer(CLayer *pLayer);
|
void MakeFrontLayer(const std::shared_ptr<CLayer> &pLayer);
|
||||||
void MakeSwitchLayer(CLayer *pLayer);
|
void MakeSwitchLayer(const std::shared_ptr<CLayer> &pLayer);
|
||||||
void MakeTuneLayer(CLayer *pLayer);
|
void MakeTuneLayer(const std::shared_ptr<CLayer> &pLayer);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CProperty
|
struct CProperty
|
||||||
|
@ -665,16 +662,16 @@ public:
|
||||||
|
|
||||||
virtual bool IsEntitiesLayer() const override;
|
virtual bool IsEntitiesLayer() const override;
|
||||||
|
|
||||||
virtual bool IsEmpty(CLayerTiles *pLayer);
|
virtual bool IsEmpty(const std::shared_ptr<CLayerTiles> &pLayer);
|
||||||
void BrushSelecting(CUIRect Rect) override;
|
void BrushSelecting(CUIRect Rect) override;
|
||||||
int BrushGrab(CLayerGroup *pBrush, CUIRect Rect) override;
|
int BrushGrab(std::shared_ptr<CLayerGroup> pBrush, CUIRect Rect) override;
|
||||||
void FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect) override;
|
void FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CUIRect Rect) override;
|
||||||
void BrushDraw(CLayer *pBrush, float wx, float wy) override;
|
void BrushDraw(std::shared_ptr<CLayer> pBrush, float wx, float wy) override;
|
||||||
void BrushFlipX() override;
|
void BrushFlipX() override;
|
||||||
void BrushFlipY() override;
|
void BrushFlipY() override;
|
||||||
void BrushRotate(float Amount) override;
|
void BrushRotate(float Amount) override;
|
||||||
|
|
||||||
CLayer *Duplicate() const override;
|
std::shared_ptr<CLayer> Duplicate() const override;
|
||||||
|
|
||||||
virtual void ShowInfo();
|
virtual void ShowInfo();
|
||||||
CUI::EPopupMenuFunctionResult RenderProperties(CUIRect *pToolbox) override;
|
CUI::EPopupMenuFunctionResult RenderProperties(CUIRect *pToolbox) override;
|
||||||
|
@ -691,7 +688,7 @@ public:
|
||||||
int m_Height = -1;
|
int m_Height = -1;
|
||||||
int m_Color = 0;
|
int m_Color = 0;
|
||||||
};
|
};
|
||||||
static CUI::EPopupMenuFunctionResult RenderCommonProperties(SCommonPropState &State, CEditor *pEditor, CUIRect *pToolbox, std::vector<CLayerTiles *> &vpLayers);
|
static CUI::EPopupMenuFunctionResult RenderCommonProperties(SCommonPropState &State, CEditor *pEditor, CUIRect *pToolbox, std::vector<std::shared_ptr<CLayerTiles>> &vpLayers);
|
||||||
|
|
||||||
void ModifyImageIndex(FIndexModifyFunction pfnFunc) override;
|
void ModifyImageIndex(FIndexModifyFunction pfnFunc) override;
|
||||||
void ModifyEnvelopeIndex(FIndexModifyFunction pfnFunc) override;
|
void ModifyEnvelopeIndex(FIndexModifyFunction pfnFunc) override;
|
||||||
|
@ -707,7 +704,6 @@ public:
|
||||||
|
|
||||||
void FlagModified(int x, int y, int w, int h);
|
void FlagModified(int x, int y, int w, int h);
|
||||||
|
|
||||||
IGraphics::CTextureHandle m_Texture;
|
|
||||||
int m_Game;
|
int m_Game;
|
||||||
int m_Image;
|
int m_Image;
|
||||||
int m_Width;
|
int m_Width;
|
||||||
|
@ -742,8 +738,8 @@ public:
|
||||||
int SwapQuads(int Index0, int Index1);
|
int SwapQuads(int Index0, int Index1);
|
||||||
|
|
||||||
void BrushSelecting(CUIRect Rect) override;
|
void BrushSelecting(CUIRect Rect) override;
|
||||||
int BrushGrab(CLayerGroup *pBrush, CUIRect Rect) override;
|
int BrushGrab(std::shared_ptr<CLayerGroup> pBrush, CUIRect Rect) override;
|
||||||
void BrushPlace(CLayer *pBrush, float wx, float wy) override;
|
void BrushPlace(std::shared_ptr<CLayer> pBrush, float wx, float wy) override;
|
||||||
void BrushFlipX() override;
|
void BrushFlipX() override;
|
||||||
void BrushFlipY() override;
|
void BrushFlipY() override;
|
||||||
void BrushRotate(float Amount) override;
|
void BrushRotate(float Amount) override;
|
||||||
|
@ -754,7 +750,7 @@ public:
|
||||||
void ModifyEnvelopeIndex(FIndexModifyFunction pfnFunc) override;
|
void ModifyEnvelopeIndex(FIndexModifyFunction pfnFunc) override;
|
||||||
|
|
||||||
void GetSize(float *pWidth, float *pHeight) override;
|
void GetSize(float *pWidth, float *pHeight) override;
|
||||||
CLayer *Duplicate() const override;
|
std::shared_ptr<CLayer> Duplicate() const override;
|
||||||
|
|
||||||
int m_Image;
|
int m_Image;
|
||||||
std::vector<CQuad> m_vQuads;
|
std::vector<CQuad> m_vQuads;
|
||||||
|
@ -858,6 +854,8 @@ class CEditor : public IEditor
|
||||||
PREVIEW_ERROR,
|
PREVIEW_ERROR,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::shared_ptr<CLayerGroup> m_apSavedBrushes[10];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class IInput *Input() { return m_pInput; }
|
class IInput *Input() { return m_pInput; }
|
||||||
class IClient *Client() { return m_pClient; }
|
class IClient *Client() { return m_pClient; }
|
||||||
|
@ -874,8 +872,7 @@ public:
|
||||||
CEditor() :
|
CEditor() :
|
||||||
m_ZoomMapView(200.0f, 10.0f, 2000.0f, this),
|
m_ZoomMapView(200.0f, 10.0f, 2000.0f, this),
|
||||||
m_ZoomEnvelopeX(1.0f, 0.1f, 600.0f, this),
|
m_ZoomEnvelopeX(1.0f, 0.1f, 600.0f, this),
|
||||||
m_ZoomEnvelopeY(640.0f, 0.1f, 32000.0f, this),
|
m_ZoomEnvelopeY(640.0f, 0.1f, 32000.0f, this)
|
||||||
m_TilesetPicker(16, 16)
|
|
||||||
{
|
{
|
||||||
m_EntitiesTexture.Invalidate();
|
m_EntitiesTexture.Invalidate();
|
||||||
m_FrontTexture.Invalidate();
|
m_FrontTexture.Invalidate();
|
||||||
|
@ -996,8 +993,6 @@ public:
|
||||||
bool PerformAutosave();
|
bool PerformAutosave();
|
||||||
void HandleWriterFinishJobs();
|
void HandleWriterFinishJobs();
|
||||||
|
|
||||||
CLayerGroup *m_apSavedBrushes[10];
|
|
||||||
|
|
||||||
void RefreshFilteredFileList();
|
void RefreshFilteredFileList();
|
||||||
void FilelistPopulate(int StorageType, bool KeepSelection = false);
|
void FilelistPopulate(int StorageType, bool KeepSelection = false);
|
||||||
void InvokeFileDialog(int StorageType, int FileType, const char *pTitle, const char *pButtonText,
|
void InvokeFileDialog(int StorageType, int FileType, const char *pTitle, const char *pButtonText,
|
||||||
|
@ -1030,9 +1025,9 @@ public:
|
||||||
|
|
||||||
std::vector<CQuad *> GetSelectedQuads();
|
std::vector<CQuad *> GetSelectedQuads();
|
||||||
std::vector<std::pair<CQuad *, int>> GetSelectedQuadPoints();
|
std::vector<std::pair<CQuad *, int>> GetSelectedQuadPoints();
|
||||||
CLayer *GetSelectedLayerType(int Index, int Type) const;
|
std::shared_ptr<CLayer> GetSelectedLayerType(int Index, int Type) const;
|
||||||
CLayer *GetSelectedLayer(int Index) const;
|
std::shared_ptr<CLayer> GetSelectedLayer(int Index) const;
|
||||||
CLayerGroup *GetSelectedGroup() const;
|
std::shared_ptr<CLayerGroup> GetSelectedGroup() const;
|
||||||
CSoundSource *GetSelectedSource();
|
CSoundSource *GetSelectedSource();
|
||||||
void SelectLayer(int LayerIndex, int GroupIndex = -1);
|
void SelectLayer(int LayerIndex, int GroupIndex = -1);
|
||||||
void AddSelectedLayer(int LayerIndex);
|
void AddSelectedLayer(int LayerIndex);
|
||||||
|
@ -1314,9 +1309,9 @@ public:
|
||||||
|
|
||||||
IGraphics::CTextureHandle GetEntitiesTexture();
|
IGraphics::CTextureHandle GetEntitiesTexture();
|
||||||
|
|
||||||
CLayerGroup m_Brush;
|
std::shared_ptr<CLayerGroup> m_pBrush;
|
||||||
CLayerTiles m_TilesetPicker;
|
std::shared_ptr<CLayerTiles> m_pTilesetPicker;
|
||||||
CLayerQuads m_QuadsetPicker;
|
std::shared_ptr<CLayerQuads> m_pQuadsetPicker;
|
||||||
|
|
||||||
static const void *ms_pUiGotContext;
|
static const void *ms_pUiGotContext;
|
||||||
|
|
||||||
|
@ -1353,7 +1348,7 @@ public:
|
||||||
|
|
||||||
void RenderBackground(CUIRect View, IGraphics::CTextureHandle Texture, float Size, float Brightness);
|
void RenderBackground(CUIRect View, IGraphics::CTextureHandle Texture, float Size, float Brightness);
|
||||||
|
|
||||||
void RenderGrid(CLayerGroup *pGroup);
|
void RenderGrid(const std::shared_ptr<CLayerGroup> &pGroup);
|
||||||
void SnapToGrid(float &x, float &y);
|
void SnapToGrid(float &x, float &y);
|
||||||
|
|
||||||
int UiDoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, int Current, int Min, int Max, int Step, float Scale, const char *pToolTip, bool IsDegree = false, bool IsHex = false, int corners = IGraphics::CORNER_ALL, ColorRGBA *pColor = nullptr, bool ShowValue = true);
|
int UiDoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, int Current, int Min, int Max, int Step, float Scale, const char *pToolTip, bool IsDegree = false, bool IsHex = false, int corners = IGraphics::CORNER_ALL, ColorRGBA *pColor = nullptr, bool ShowValue = true);
|
||||||
|
@ -1365,7 +1360,7 @@ public:
|
||||||
struct SLayerPopupContext : public SPopupMenuId
|
struct SLayerPopupContext : public SPopupMenuId
|
||||||
{
|
{
|
||||||
CEditor *m_pEditor;
|
CEditor *m_pEditor;
|
||||||
std::vector<CLayerTiles *> m_vpLayers;
|
std::vector<std::shared_ptr<CLayerTiles>> m_vpLayers;
|
||||||
CLayerTiles::SCommonPropState m_CommonPropState;
|
CLayerTiles::SCommonPropState m_CommonPropState;
|
||||||
};
|
};
|
||||||
static CUI::EPopupMenuFunctionResult PopupLayer(void *pContext, CUIRect View, bool Active);
|
static CUI::EPopupMenuFunctionResult PopupLayer(void *pContext, CUIRect View, bool Active);
|
||||||
|
@ -1410,7 +1405,7 @@ public:
|
||||||
void DoQuadEnvelopes(const std::vector<CQuad> &vQuads, IGraphics::CTextureHandle Texture = IGraphics::CTextureHandle());
|
void DoQuadEnvelopes(const std::vector<CQuad> &vQuads, IGraphics::CTextureHandle Texture = IGraphics::CTextureHandle());
|
||||||
void DoQuadEnvPoint(const CQuad *pQuad, int QIndex, int pIndex);
|
void DoQuadEnvPoint(const CQuad *pQuad, int QIndex, int pIndex);
|
||||||
void DoQuadPoint(CQuad *pQuad, int QuadIndex, int v);
|
void DoQuadPoint(CQuad *pQuad, int QuadIndex, int v);
|
||||||
void SetHotQuadPoint(CLayerQuads *pLayer);
|
void SetHotQuadPoint(const std::shared_ptr<CLayerQuads> &pLayer);
|
||||||
|
|
||||||
float TriangleArea(vec2 A, vec2 B, vec2 C);
|
float TriangleArea(vec2 A, vec2 B, vec2 C);
|
||||||
bool IsInTriangle(vec2 Point, vec2 A, vec2 B, vec2 C);
|
bool IsInTriangle(vec2 Point, vec2 A, vec2 B, vec2 C);
|
||||||
|
@ -1449,7 +1444,7 @@ public:
|
||||||
|
|
||||||
void RenderExtraEditorDragBar(CUIRect View, CUIRect DragBar);
|
void RenderExtraEditorDragBar(CUIRect View, CUIRect DragBar);
|
||||||
|
|
||||||
void SetHotEnvelopePoint(const CUIRect &View, CEnvelope *pEnvelope);
|
void SetHotEnvelopePoint(const CUIRect &View, const std::shared_ptr<CEnvelope> &pEnvelope);
|
||||||
|
|
||||||
void RenderMenubar(CUIRect Menubar);
|
void RenderMenubar(CUIRect Menubar);
|
||||||
void RenderFileDialog();
|
void RenderFileDialog();
|
||||||
|
@ -1546,8 +1541,8 @@ public:
|
||||||
void ZoomAdaptOffsetY(float ZoomFactor, const CUIRect &View);
|
void ZoomAdaptOffsetY(float ZoomFactor, const CUIRect &View);
|
||||||
void UpdateZoomEnvelopeY(const CUIRect &View);
|
void UpdateZoomEnvelopeY(const CUIRect &View);
|
||||||
|
|
||||||
void ResetZoomEnvelope(CEnvelope *pEnvelope, int ActiveChannels);
|
void ResetZoomEnvelope(const std::shared_ptr<CEnvelope> &pEnvelope, int ActiveChannels);
|
||||||
void RemoveTimeOffsetEnvelope(CEnvelope *pEnvelope);
|
void RemoveTimeOffsetEnvelope(const std::shared_ptr<CEnvelope> &pEnvelope);
|
||||||
float ScreenToEnvelopeX(const CUIRect &View, float x) const;
|
float ScreenToEnvelopeX(const CUIRect &View, float x) const;
|
||||||
float EnvelopeToScreenX(const CUIRect &View, float x) const;
|
float EnvelopeToScreenX(const CUIRect &View, float x) const;
|
||||||
float ScreenToEnvelopeY(const CUIRect &View, float y) const;
|
float ScreenToEnvelopeY(const CUIRect &View, float y) const;
|
||||||
|
@ -1593,12 +1588,12 @@ public:
|
||||||
|
|
||||||
void Resize(int NewW, int NewH) override;
|
void Resize(int NewW, int NewH) override;
|
||||||
void Shift(int Direction) override;
|
void Shift(int Direction) override;
|
||||||
bool IsEmpty(CLayerTiles *pLayer) override;
|
bool IsEmpty(const std::shared_ptr<CLayerTiles> &pLayer) override;
|
||||||
void BrushDraw(CLayer *pBrush, float wx, float wy) override;
|
void BrushDraw(std::shared_ptr<CLayer> pBrush, float wx, float wy) override;
|
||||||
void BrushFlipX() override;
|
void BrushFlipX() override;
|
||||||
void BrushFlipY() override;
|
void BrushFlipY() override;
|
||||||
void BrushRotate(float Amount) override;
|
void BrushRotate(float Amount) override;
|
||||||
void FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect) override;
|
void FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CUIRect Rect) override;
|
||||||
virtual bool ContainsElementWithId(int Id);
|
virtual bool ContainsElementWithId(int Id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1615,12 +1610,12 @@ public:
|
||||||
|
|
||||||
void Resize(int NewW, int NewH) override;
|
void Resize(int NewW, int NewH) override;
|
||||||
void Shift(int Direction) override;
|
void Shift(int Direction) override;
|
||||||
bool IsEmpty(CLayerTiles *pLayer) override;
|
bool IsEmpty(const std::shared_ptr<CLayerTiles> &pLayer) override;
|
||||||
void BrushDraw(CLayer *pBrush, float wx, float wy) override;
|
void BrushDraw(std::shared_ptr<CLayer> pBrush, float wx, float wy) override;
|
||||||
void BrushFlipX() override;
|
void BrushFlipX() override;
|
||||||
void BrushFlipY() override;
|
void BrushFlipY() override;
|
||||||
void BrushRotate(float Amount) override;
|
void BrushRotate(float Amount) override;
|
||||||
void FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect) override;
|
void FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CUIRect Rect) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CLayerFront : public CLayerTiles
|
class CLayerFront : public CLayerTiles
|
||||||
|
@ -1644,12 +1639,12 @@ public:
|
||||||
|
|
||||||
void Resize(int NewW, int NewH) override;
|
void Resize(int NewW, int NewH) override;
|
||||||
void Shift(int Direction) override;
|
void Shift(int Direction) override;
|
||||||
bool IsEmpty(CLayerTiles *pLayer) override;
|
bool IsEmpty(const std::shared_ptr<CLayerTiles> &pLayer) override;
|
||||||
void BrushDraw(CLayer *pBrush, float wx, float wy) override;
|
void BrushDraw(std::shared_ptr<CLayer> pBrush, float wx, float wy) override;
|
||||||
void BrushFlipX() override;
|
void BrushFlipX() override;
|
||||||
void BrushFlipY() override;
|
void BrushFlipY() override;
|
||||||
void BrushRotate(float Amount) override;
|
void BrushRotate(float Amount) override;
|
||||||
void FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect) override;
|
void FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CUIRect Rect) override;
|
||||||
virtual bool ContainsElementWithId(int Id);
|
virtual bool ContainsElementWithId(int Id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1664,12 +1659,12 @@ public:
|
||||||
|
|
||||||
void Resize(int NewW, int NewH) override;
|
void Resize(int NewW, int NewH) override;
|
||||||
void Shift(int Direction) override;
|
void Shift(int Direction) override;
|
||||||
bool IsEmpty(CLayerTiles *pLayer) override;
|
bool IsEmpty(const std::shared_ptr<CLayerTiles> &pLayer) override;
|
||||||
void BrushDraw(CLayer *pBrush, float wx, float wy) override;
|
void BrushDraw(std::shared_ptr<CLayer> pBrush, float wx, float wy) override;
|
||||||
void BrushFlipX() override;
|
void BrushFlipX() override;
|
||||||
void BrushFlipY() override;
|
void BrushFlipY() override;
|
||||||
void BrushRotate(float Amount) override;
|
void BrushRotate(float Amount) override;
|
||||||
void FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect) override;
|
void FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CUIRect Rect) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CLayerSounds : public CLayer
|
class CLayerSounds : public CLayer
|
||||||
|
@ -1683,15 +1678,15 @@ public:
|
||||||
CSoundSource *NewSource(int x, int y);
|
CSoundSource *NewSource(int x, int y);
|
||||||
|
|
||||||
void BrushSelecting(CUIRect Rect) override;
|
void BrushSelecting(CUIRect Rect) override;
|
||||||
int BrushGrab(CLayerGroup *pBrush, CUIRect Rect) override;
|
int BrushGrab(std::shared_ptr<CLayerGroup> pBrush, CUIRect Rect) override;
|
||||||
void BrushPlace(CLayer *pBrush, float wx, float wy) override;
|
void BrushPlace(std::shared_ptr<CLayer> pBrush, float wx, float wy) override;
|
||||||
|
|
||||||
CUI::EPopupMenuFunctionResult RenderProperties(CUIRect *pToolbox) override;
|
CUI::EPopupMenuFunctionResult RenderProperties(CUIRect *pToolbox) override;
|
||||||
|
|
||||||
void ModifyEnvelopeIndex(FIndexModifyFunction pfnFunc) override;
|
void ModifyEnvelopeIndex(FIndexModifyFunction pfnFunc) override;
|
||||||
void ModifySoundIndex(FIndexModifyFunction pfnFunc) override;
|
void ModifySoundIndex(FIndexModifyFunction pfnFunc) override;
|
||||||
|
|
||||||
CLayer *Duplicate() const override;
|
std::shared_ptr<CLayer> Duplicate() const override;
|
||||||
|
|
||||||
int m_Sound;
|
int m_Sound;
|
||||||
std::vector<CSoundSource> m_vSources;
|
std::vector<CSoundSource> m_vSources;
|
||||||
|
|
|
@ -111,7 +111,7 @@ bool CEditorMap::Save(const char *pFileName)
|
||||||
// save images
|
// save images
|
||||||
for(size_t i = 0; i < m_vpImages.size(); i++)
|
for(size_t i = 0; i < m_vpImages.size(); i++)
|
||||||
{
|
{
|
||||||
CEditorImage *pImg = m_vpImages[i];
|
std::shared_ptr<CEditorImage> pImg = m_vpImages[i];
|
||||||
|
|
||||||
// analyse the image for when saving (should be done when we load the image)
|
// analyse the image for when saving (should be done when we load the image)
|
||||||
// TODO!
|
// TODO!
|
||||||
|
@ -156,7 +156,7 @@ bool CEditorMap::Save(const char *pFileName)
|
||||||
// save sounds
|
// save sounds
|
||||||
for(size_t i = 0; i < m_vpSounds.size(); i++)
|
for(size_t i = 0; i < m_vpSounds.size(); i++)
|
||||||
{
|
{
|
||||||
CEditorSound *pSound = m_vpSounds[i];
|
std::shared_ptr<CEditorSound> pSound = m_vpSounds[i];
|
||||||
|
|
||||||
CMapItemSound Item;
|
CMapItemSound Item;
|
||||||
Item.m_Version = 1;
|
Item.m_Version = 1;
|
||||||
|
@ -196,12 +196,12 @@ bool CEditorMap::Save(const char *pFileName)
|
||||||
GItemEx.m_Version = CMapItemGroupEx::CURRENT_VERSION;
|
GItemEx.m_Version = CMapItemGroupEx::CURRENT_VERSION;
|
||||||
GItemEx.m_ParallaxZoom = pGroup->m_ParallaxZoom;
|
GItemEx.m_ParallaxZoom = pGroup->m_ParallaxZoom;
|
||||||
|
|
||||||
for(CLayer *pLayer : pGroup->m_vpLayers)
|
for(const std::shared_ptr<CLayer> &pLayer : pGroup->m_vpLayers)
|
||||||
{
|
{
|
||||||
if(pLayer->m_Type == LAYERTYPE_TILES)
|
if(pLayer->m_Type == LAYERTYPE_TILES)
|
||||||
{
|
{
|
||||||
m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving tiles layer");
|
m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving tiles layer");
|
||||||
CLayerTiles *pLayerTiles = (CLayerTiles *)pLayer;
|
std::shared_ptr<CLayerTiles> pLayerTiles = std::static_pointer_cast<CLayerTiles>(pLayer);
|
||||||
pLayerTiles->PrepareForSave();
|
pLayerTiles->PrepareForSave();
|
||||||
|
|
||||||
CMapItemLayerTilemap Item;
|
CMapItemLayerTilemap Item;
|
||||||
|
@ -249,15 +249,15 @@ bool CEditorMap::Save(const char *pFileName)
|
||||||
free(pEmptyTiles);
|
free(pEmptyTiles);
|
||||||
|
|
||||||
if(pLayerTiles->m_Tele)
|
if(pLayerTiles->m_Tele)
|
||||||
Item.m_Tele = Writer.AddData((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CTeleTile), ((CLayerTele *)pLayerTiles)->m_pTeleTile);
|
Item.m_Tele = Writer.AddData((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CTeleTile), std::static_pointer_cast<CLayerTele>(pLayerTiles)->m_pTeleTile);
|
||||||
else if(pLayerTiles->m_Speedup)
|
else if(pLayerTiles->m_Speedup)
|
||||||
Item.m_Speedup = Writer.AddData((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CSpeedupTile), ((CLayerSpeedup *)pLayerTiles)->m_pSpeedupTile);
|
Item.m_Speedup = Writer.AddData((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CSpeedupTile), std::static_pointer_cast<CLayerSpeedup>(pLayerTiles)->m_pSpeedupTile);
|
||||||
else if(pLayerTiles->m_Front)
|
else if(pLayerTiles->m_Front)
|
||||||
Item.m_Front = Writer.AddData((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CTile), pLayerTiles->m_pTiles);
|
Item.m_Front = Writer.AddData((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CTile), pLayerTiles->m_pTiles);
|
||||||
else if(pLayerTiles->m_Switch)
|
else if(pLayerTiles->m_Switch)
|
||||||
Item.m_Switch = Writer.AddData((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CSwitchTile), ((CLayerSwitch *)pLayerTiles)->m_pSwitchTile);
|
Item.m_Switch = Writer.AddData((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CSwitchTile), std::static_pointer_cast<CLayerSwitch>(pLayerTiles)->m_pSwitchTile);
|
||||||
else if(pLayerTiles->m_Tune)
|
else if(pLayerTiles->m_Tune)
|
||||||
Item.m_Tune = Writer.AddData((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CTuneTile), ((CLayerTune *)pLayerTiles)->m_pTuneTile);
|
Item.m_Tune = Writer.AddData((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CTuneTile), std::static_pointer_cast<CLayerTune>(pLayerTiles)->m_pTuneTile);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Item.m_Data = Writer.AddData((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CTile), pLayerTiles->m_pTiles);
|
Item.m_Data = Writer.AddData((size_t)pLayerTiles->m_Width * pLayerTiles->m_Height * sizeof(CTile), pLayerTiles->m_pTiles);
|
||||||
|
@ -290,7 +290,7 @@ bool CEditorMap::Save(const char *pFileName)
|
||||||
else if(pLayer->m_Type == LAYERTYPE_QUADS)
|
else if(pLayer->m_Type == LAYERTYPE_QUADS)
|
||||||
{
|
{
|
||||||
m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving quads layer");
|
m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving quads layer");
|
||||||
CLayerQuads *pLayerQuads = (CLayerQuads *)pLayer;
|
std::shared_ptr<CLayerQuads> pLayerQuads = std::static_pointer_cast<CLayerQuads>(pLayer);
|
||||||
if(!pLayerQuads->m_vQuads.empty())
|
if(!pLayerQuads->m_vQuads.empty())
|
||||||
{
|
{
|
||||||
CMapItemLayerQuads Item;
|
CMapItemLayerQuads Item;
|
||||||
|
@ -309,9 +309,6 @@ bool CEditorMap::Save(const char *pFileName)
|
||||||
|
|
||||||
Writer.AddItem(MAPITEMTYPE_LAYER, LayerCount, sizeof(Item), &Item);
|
Writer.AddItem(MAPITEMTYPE_LAYER, LayerCount, sizeof(Item), &Item);
|
||||||
|
|
||||||
// clean up
|
|
||||||
//mem_free(quads);
|
|
||||||
|
|
||||||
GItem.m_NumLayers++;
|
GItem.m_NumLayers++;
|
||||||
LayerCount++;
|
LayerCount++;
|
||||||
}
|
}
|
||||||
|
@ -319,7 +316,7 @@ bool CEditorMap::Save(const char *pFileName)
|
||||||
else if(pLayer->m_Type == LAYERTYPE_SOUNDS)
|
else if(pLayer->m_Type == LAYERTYPE_SOUNDS)
|
||||||
{
|
{
|
||||||
m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving sounds layer");
|
m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving sounds layer");
|
||||||
CLayerSounds *pLayerSounds = (CLayerSounds *)pLayer;
|
std::shared_ptr<CLayerSounds> pLayerSounds = std::static_pointer_cast<CLayerSounds>(pLayer);
|
||||||
if(!pLayerSounds->m_vSources.empty())
|
if(!pLayerSounds->m_vSources.empty())
|
||||||
{
|
{
|
||||||
CMapItemLayerSounds Item;
|
CMapItemLayerSounds Item;
|
||||||
|
@ -518,7 +515,7 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
|
||||||
char *pName = (char *)DataFile.GetData(pItem->m_ImageName);
|
char *pName = (char *)DataFile.GetData(pItem->m_ImageName);
|
||||||
|
|
||||||
// copy base info
|
// copy base info
|
||||||
CEditorImage *pImg = new CEditorImage(m_pEditor);
|
std::shared_ptr<CEditorImage> pImg = std::make_shared<CEditorImage>(m_pEditor);
|
||||||
pImg->m_External = pItem->m_External;
|
pImg->m_External = pItem->m_External;
|
||||||
|
|
||||||
const int Format = pItem->m_Version < CMapItemImage_v2::CURRENT_VERSION ? CImageInfo::FORMAT_RGBA : pItem->m_Format;
|
const int Format = pItem->m_Version < CMapItemImage_v2::CURRENT_VERSION ? CImageInfo::FORMAT_RGBA : pItem->m_Format;
|
||||||
|
@ -582,7 +579,7 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
|
||||||
char *pName = (char *)DataFile.GetData(pItem->m_SoundName);
|
char *pName = (char *)DataFile.GetData(pItem->m_SoundName);
|
||||||
|
|
||||||
// copy base info
|
// copy base info
|
||||||
CEditorSound *pSound = new CEditorSound(m_pEditor);
|
std::shared_ptr<CEditorSound> pSound = std::make_shared<CEditorSound>(m_pEditor);
|
||||||
|
|
||||||
if(pItem->m_External)
|
if(pItem->m_External)
|
||||||
{
|
{
|
||||||
|
@ -638,7 +635,7 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
|
||||||
if(pGItem->m_Version < 1 || pGItem->m_Version > CMapItemGroup::CURRENT_VERSION)
|
if(pGItem->m_Version < 1 || pGItem->m_Version > CMapItemGroup::CURRENT_VERSION)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CLayerGroup *pGroup = NewGroup();
|
std::shared_ptr<CLayerGroup> pGroup = NewGroup();
|
||||||
pGroup->m_ParallaxX = pGItem->m_ParallaxX;
|
pGroup->m_ParallaxX = pGItem->m_ParallaxX;
|
||||||
pGroup->m_ParallaxY = pGItem->m_ParallaxY;
|
pGroup->m_ParallaxY = pGItem->m_ParallaxY;
|
||||||
pGroup->m_OffsetX = pGItem->m_OffsetX;
|
pGroup->m_OffsetX = pGItem->m_OffsetX;
|
||||||
|
@ -662,7 +659,6 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
|
||||||
|
|
||||||
for(int l = 0; l < pGItem->m_NumLayers; l++)
|
for(int l = 0; l < pGItem->m_NumLayers; l++)
|
||||||
{
|
{
|
||||||
CLayer *pLayer = nullptr;
|
|
||||||
CMapItemLayer *pLayerItem = (CMapItemLayer *)DataFile.GetItem(LayersStart + pGItem->m_StartLayer + l);
|
CMapItemLayer *pLayerItem = (CMapItemLayer *)DataFile.GetItem(LayersStart + pGItem->m_StartLayer + l);
|
||||||
if(!pLayerItem)
|
if(!pLayerItem)
|
||||||
continue;
|
continue;
|
||||||
|
@ -670,64 +666,64 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
|
||||||
if(pLayerItem->m_Type == LAYERTYPE_TILES)
|
if(pLayerItem->m_Type == LAYERTYPE_TILES)
|
||||||
{
|
{
|
||||||
CMapItemLayerTilemap *pTilemapItem = (CMapItemLayerTilemap *)pLayerItem;
|
CMapItemLayerTilemap *pTilemapItem = (CMapItemLayerTilemap *)pLayerItem;
|
||||||
CLayerTiles *pTiles = nullptr;
|
|
||||||
|
|
||||||
|
std::shared_ptr<CLayerTiles> pTiles;
|
||||||
if(pTilemapItem->m_Flags & TILESLAYERFLAG_GAME)
|
if(pTilemapItem->m_Flags & TILESLAYERFLAG_GAME)
|
||||||
{
|
{
|
||||||
pTiles = new CLayerGame(pTilemapItem->m_Width, pTilemapItem->m_Height);
|
pTiles = std::make_shared<CLayerGame>(pTilemapItem->m_Width, pTilemapItem->m_Height);
|
||||||
MakeGameLayer(pTiles);
|
MakeGameLayer(pTiles);
|
||||||
MakeGameGroup(pGroup);
|
MakeGameGroup(pGroup);
|
||||||
}
|
}
|
||||||
else if(pTilemapItem->m_Flags & TILESLAYERFLAG_TELE)
|
else if(pTilemapItem->m_Flags & TILESLAYERFLAG_TELE)
|
||||||
{
|
{
|
||||||
if(pTilemapItem->m_Version <= 2)
|
if(pTilemapItem->m_Version <= 2)
|
||||||
pTilemapItem->m_Tele = *((int *)(pTilemapItem) + 15);
|
pTilemapItem->m_Tele = *((const int *)(pTilemapItem) + 15);
|
||||||
|
|
||||||
pTiles = new CLayerTele(pTilemapItem->m_Width, pTilemapItem->m_Height);
|
pTiles = std::make_shared<CLayerTele>(pTilemapItem->m_Width, pTilemapItem->m_Height);
|
||||||
MakeTeleLayer(pTiles);
|
MakeTeleLayer(pTiles);
|
||||||
}
|
}
|
||||||
else if(pTilemapItem->m_Flags & TILESLAYERFLAG_SPEEDUP)
|
else if(pTilemapItem->m_Flags & TILESLAYERFLAG_SPEEDUP)
|
||||||
{
|
{
|
||||||
if(pTilemapItem->m_Version <= 2)
|
if(pTilemapItem->m_Version <= 2)
|
||||||
pTilemapItem->m_Speedup = *((int *)(pTilemapItem) + 16);
|
pTilemapItem->m_Speedup = *((const int *)(pTilemapItem) + 16);
|
||||||
|
|
||||||
pTiles = new CLayerSpeedup(pTilemapItem->m_Width, pTilemapItem->m_Height);
|
pTiles = std::make_shared<CLayerSpeedup>(pTilemapItem->m_Width, pTilemapItem->m_Height);
|
||||||
MakeSpeedupLayer(pTiles);
|
MakeSpeedupLayer(pTiles);
|
||||||
}
|
}
|
||||||
else if(pTilemapItem->m_Flags & TILESLAYERFLAG_FRONT)
|
else if(pTilemapItem->m_Flags & TILESLAYERFLAG_FRONT)
|
||||||
{
|
{
|
||||||
if(pTilemapItem->m_Version <= 2)
|
if(pTilemapItem->m_Version <= 2)
|
||||||
pTilemapItem->m_Front = *((int *)(pTilemapItem) + 17);
|
pTilemapItem->m_Front = *((const int *)(pTilemapItem) + 17);
|
||||||
|
|
||||||
pTiles = new CLayerFront(pTilemapItem->m_Width, pTilemapItem->m_Height);
|
pTiles = std::make_shared<CLayerFront>(pTilemapItem->m_Width, pTilemapItem->m_Height);
|
||||||
MakeFrontLayer(pTiles);
|
MakeFrontLayer(pTiles);
|
||||||
}
|
}
|
||||||
else if(pTilemapItem->m_Flags & TILESLAYERFLAG_SWITCH)
|
else if(pTilemapItem->m_Flags & TILESLAYERFLAG_SWITCH)
|
||||||
{
|
{
|
||||||
if(pTilemapItem->m_Version <= 2)
|
if(pTilemapItem->m_Version <= 2)
|
||||||
pTilemapItem->m_Switch = *((int *)(pTilemapItem) + 18);
|
pTilemapItem->m_Switch = *((const int *)(pTilemapItem) + 18);
|
||||||
|
|
||||||
pTiles = new CLayerSwitch(pTilemapItem->m_Width, pTilemapItem->m_Height);
|
pTiles = std::make_shared<CLayerSwitch>(pTilemapItem->m_Width, pTilemapItem->m_Height);
|
||||||
MakeSwitchLayer(pTiles);
|
MakeSwitchLayer(pTiles);
|
||||||
}
|
}
|
||||||
else if(pTilemapItem->m_Flags & TILESLAYERFLAG_TUNE)
|
else if(pTilemapItem->m_Flags & TILESLAYERFLAG_TUNE)
|
||||||
{
|
{
|
||||||
if(pTilemapItem->m_Version <= 2)
|
if(pTilemapItem->m_Version <= 2)
|
||||||
pTilemapItem->m_Tune = *((int *)(pTilemapItem) + 19);
|
pTilemapItem->m_Tune = *((const int *)(pTilemapItem) + 19);
|
||||||
|
|
||||||
pTiles = new CLayerTune(pTilemapItem->m_Width, pTilemapItem->m_Height);
|
pTiles = std::make_shared<CLayerTune>(pTilemapItem->m_Width, pTilemapItem->m_Height);
|
||||||
MakeTuneLayer(pTiles);
|
MakeTuneLayer(pTiles);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pTiles = new CLayerTiles(pTilemapItem->m_Width, pTilemapItem->m_Height);
|
pTiles = std::make_shared<CLayerTiles>(pTilemapItem->m_Width, pTilemapItem->m_Height);
|
||||||
pTiles->m_pEditor = m_pEditor;
|
pTiles->m_pEditor = m_pEditor;
|
||||||
pTiles->m_Color = pTilemapItem->m_Color;
|
pTiles->m_Color = pTilemapItem->m_Color;
|
||||||
pTiles->m_ColorEnv = pTilemapItem->m_ColorEnv;
|
pTiles->m_ColorEnv = pTilemapItem->m_ColorEnv;
|
||||||
pTiles->m_ColorEnvOffset = pTilemapItem->m_ColorEnvOffset;
|
pTiles->m_ColorEnvOffset = pTilemapItem->m_ColorEnvOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
pLayer = pTiles;
|
pTiles->m_Flags = pLayerItem->m_Flags;
|
||||||
|
|
||||||
pGroup->AddLayer(pTiles);
|
pGroup->AddLayer(pTiles);
|
||||||
pTiles->m_Image = pTilemapItem->m_Image;
|
pTiles->m_Image = pTilemapItem->m_Image;
|
||||||
|
@ -743,7 +739,7 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
|
||||||
unsigned int Size = DataFile.GetDataSize(pTilemapItem->m_Tele);
|
unsigned int Size = DataFile.GetDataSize(pTilemapItem->m_Tele);
|
||||||
if(Size >= (size_t)pTiles->m_Width * pTiles->m_Height * sizeof(CTeleTile))
|
if(Size >= (size_t)pTiles->m_Width * pTiles->m_Height * sizeof(CTeleTile))
|
||||||
{
|
{
|
||||||
CTeleTile *pLayerTeleTiles = ((CLayerTele *)pTiles)->m_pTeleTile;
|
CTeleTile *pLayerTeleTiles = std::static_pointer_cast<CLayerTele>(pTiles)->m_pTeleTile;
|
||||||
mem_copy(pLayerTeleTiles, pTeleData, (size_t)pTiles->m_Width * pTiles->m_Height * sizeof(CTeleTile));
|
mem_copy(pLayerTeleTiles, pTeleData, (size_t)pTiles->m_Width * pTiles->m_Height * sizeof(CTeleTile));
|
||||||
|
|
||||||
for(int i = 0; i < pTiles->m_Width * pTiles->m_Height; i++)
|
for(int i = 0; i < pTiles->m_Width * pTiles->m_Height; i++)
|
||||||
|
@ -763,7 +759,7 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
|
||||||
|
|
||||||
if(Size >= (size_t)pTiles->m_Width * pTiles->m_Height * sizeof(CSpeedupTile))
|
if(Size >= (size_t)pTiles->m_Width * pTiles->m_Height * sizeof(CSpeedupTile))
|
||||||
{
|
{
|
||||||
CSpeedupTile *pLayerSpeedupTiles = ((CLayerSpeedup *)pTiles)->m_pSpeedupTile;
|
CSpeedupTile *pLayerSpeedupTiles = std::static_pointer_cast<CLayerSpeedup>(pTiles)->m_pSpeedupTile;
|
||||||
mem_copy(pLayerSpeedupTiles, pSpeedupData, (size_t)pTiles->m_Width * pTiles->m_Height * sizeof(CSpeedupTile));
|
mem_copy(pLayerSpeedupTiles, pSpeedupData, (size_t)pTiles->m_Width * pTiles->m_Height * sizeof(CSpeedupTile));
|
||||||
|
|
||||||
for(int i = 0; i < pTiles->m_Width * pTiles->m_Height; i++)
|
for(int i = 0; i < pTiles->m_Width * pTiles->m_Height; i++)
|
||||||
|
@ -790,7 +786,7 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
|
||||||
unsigned int Size = DataFile.GetDataSize(pTilemapItem->m_Switch);
|
unsigned int Size = DataFile.GetDataSize(pTilemapItem->m_Switch);
|
||||||
if(Size >= (size_t)pTiles->m_Width * pTiles->m_Height * sizeof(CSwitchTile))
|
if(Size >= (size_t)pTiles->m_Width * pTiles->m_Height * sizeof(CSwitchTile))
|
||||||
{
|
{
|
||||||
CSwitchTile *pLayerSwitchTiles = ((CLayerSwitch *)pTiles)->m_pSwitchTile;
|
CSwitchTile *pLayerSwitchTiles = std::static_pointer_cast<CLayerSwitch>(pTiles)->m_pSwitchTile;
|
||||||
mem_copy(pLayerSwitchTiles, pSwitchData, (size_t)pTiles->m_Width * pTiles->m_Height * sizeof(CSwitchTile));
|
mem_copy(pLayerSwitchTiles, pSwitchData, (size_t)pTiles->m_Width * pTiles->m_Height * sizeof(CSwitchTile));
|
||||||
|
|
||||||
for(int i = 0; i < pTiles->m_Width * pTiles->m_Height; i++)
|
for(int i = 0; i < pTiles->m_Width * pTiles->m_Height; i++)
|
||||||
|
@ -819,7 +815,7 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
|
||||||
unsigned int Size = DataFile.GetDataSize(pTilemapItem->m_Tune);
|
unsigned int Size = DataFile.GetDataSize(pTilemapItem->m_Tune);
|
||||||
if(Size >= (size_t)pTiles->m_Width * pTiles->m_Height * sizeof(CTuneTile))
|
if(Size >= (size_t)pTiles->m_Width * pTiles->m_Height * sizeof(CTuneTile))
|
||||||
{
|
{
|
||||||
CTuneTile *pLayerTuneTiles = ((CLayerTune *)pTiles)->m_pTuneTile;
|
CTuneTile *pLayerTuneTiles = std::static_pointer_cast<CLayerTune>(pTiles)->m_pTuneTile;
|
||||||
mem_copy(pLayerTuneTiles, pTuneData, (size_t)pTiles->m_Width * pTiles->m_Height * sizeof(CTuneTile));
|
mem_copy(pLayerTuneTiles, pTuneData, (size_t)pTiles->m_Width * pTiles->m_Height * sizeof(CTuneTile));
|
||||||
|
|
||||||
for(int i = 0; i < pTiles->m_Width * pTiles->m_Height; i++)
|
for(int i = 0; i < pTiles->m_Width * pTiles->m_Height; i++)
|
||||||
|
@ -851,10 +847,11 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
|
||||||
}
|
}
|
||||||
else if(pLayerItem->m_Type == LAYERTYPE_QUADS)
|
else if(pLayerItem->m_Type == LAYERTYPE_QUADS)
|
||||||
{
|
{
|
||||||
CMapItemLayerQuads *pQuadsItem = (CMapItemLayerQuads *)pLayerItem;
|
const CMapItemLayerQuads *pQuadsItem = (CMapItemLayerQuads *)pLayerItem;
|
||||||
CLayerQuads *pQuads = new CLayerQuads;
|
|
||||||
|
std::shared_ptr<CLayerQuads> pQuads = std::make_shared<CLayerQuads>();
|
||||||
pQuads->m_pEditor = m_pEditor;
|
pQuads->m_pEditor = m_pEditor;
|
||||||
pLayer = pQuads;
|
pQuads->m_Flags = pLayerItem->m_Flags;
|
||||||
pQuads->m_Image = pQuadsItem->m_Image;
|
pQuads->m_Image = pQuadsItem->m_Image;
|
||||||
if(pQuads->m_Image < -1 || pQuads->m_Image >= (int)m_vpImages.size())
|
if(pQuads->m_Image < -1 || pQuads->m_Image >= (int)m_vpImages.size())
|
||||||
pQuads->m_Image = -1;
|
pQuads->m_Image = -1;
|
||||||
|
@ -871,13 +868,13 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
|
||||||
}
|
}
|
||||||
else if(pLayerItem->m_Type == LAYERTYPE_SOUNDS)
|
else if(pLayerItem->m_Type == LAYERTYPE_SOUNDS)
|
||||||
{
|
{
|
||||||
CMapItemLayerSounds *pSoundsItem = (CMapItemLayerSounds *)pLayerItem;
|
const CMapItemLayerSounds *pSoundsItem = (CMapItemLayerSounds *)pLayerItem;
|
||||||
if(pSoundsItem->m_Version < 1 || pSoundsItem->m_Version > CMapItemLayerSounds::CURRENT_VERSION)
|
if(pSoundsItem->m_Version < 1 || pSoundsItem->m_Version > CMapItemLayerSounds::CURRENT_VERSION)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CLayerSounds *pSounds = new CLayerSounds;
|
std::shared_ptr<CLayerSounds> pSounds = std::make_shared<CLayerSounds>();
|
||||||
pSounds->m_pEditor = m_pEditor;
|
pSounds->m_pEditor = m_pEditor;
|
||||||
pLayer = pSounds;
|
pSounds->m_Flags = pLayerItem->m_Flags;
|
||||||
pSounds->m_Sound = pSoundsItem->m_Sound;
|
pSounds->m_Sound = pSoundsItem->m_Sound;
|
||||||
|
|
||||||
// validate m_Sound
|
// validate m_Sound
|
||||||
|
@ -897,13 +894,13 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
|
||||||
else if(pLayerItem->m_Type == LAYERTYPE_SOUNDS_DEPRECATED)
|
else if(pLayerItem->m_Type == LAYERTYPE_SOUNDS_DEPRECATED)
|
||||||
{
|
{
|
||||||
// compatibility with old sound layers
|
// compatibility with old sound layers
|
||||||
CMapItemLayerSounds *pSoundsItem = (CMapItemLayerSounds *)pLayerItem;
|
const CMapItemLayerSounds *pSoundsItem = (CMapItemLayerSounds *)pLayerItem;
|
||||||
if(pSoundsItem->m_Version < 1 || pSoundsItem->m_Version > CMapItemLayerSounds::CURRENT_VERSION)
|
if(pSoundsItem->m_Version < 1 || pSoundsItem->m_Version > CMapItemLayerSounds::CURRENT_VERSION)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CLayerSounds *pSounds = new CLayerSounds;
|
std::shared_ptr<CLayerSounds> pSounds = std::make_shared<CLayerSounds>();
|
||||||
pSounds->m_pEditor = m_pEditor;
|
pSounds->m_pEditor = m_pEditor;
|
||||||
pLayer = pSounds;
|
pSounds->m_Flags = pLayerItem->m_Flags;
|
||||||
pSounds->m_Sound = pSoundsItem->m_Sound;
|
pSounds->m_Sound = pSoundsItem->m_Sound;
|
||||||
|
|
||||||
// validate m_Sound
|
// validate m_Sound
|
||||||
|
@ -940,9 +937,6 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
|
||||||
|
|
||||||
DataFile.UnloadData(pSoundsItem->m_Data);
|
DataFile.UnloadData(pSoundsItem->m_Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pLayer)
|
|
||||||
pLayer->m_Flags = pLayerItem->m_Flags;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -956,7 +950,7 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
|
||||||
for(int e = 0; e < EnvNum; e++)
|
for(int e = 0; e < EnvNum; e++)
|
||||||
{
|
{
|
||||||
CMapItemEnvelope *pItem = (CMapItemEnvelope *)DataFile.GetItem(EnvStart + e);
|
CMapItemEnvelope *pItem = (CMapItemEnvelope *)DataFile.GetItem(EnvStart + e);
|
||||||
CEnvelope *pEnv = new CEnvelope(pItem->m_Channels);
|
std::shared_ptr<CEnvelope> pEnv = std::make_shared<CEnvelope>(pItem->m_Channels);
|
||||||
pEnv->m_vPoints.resize(pItem->m_NumPoints);
|
pEnv->m_vPoints.resize(pItem->m_NumPoints);
|
||||||
for(int p = 0; p < pItem->m_NumPoints; p++)
|
for(int p = 0; p < pItem->m_NumPoints; p++)
|
||||||
{
|
{
|
||||||
|
@ -986,10 +980,10 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
|
||||||
if(pItem->m_GroupId >= 0 && (size_t)pItem->m_GroupId < m_vpGroups.size() &&
|
if(pItem->m_GroupId >= 0 && (size_t)pItem->m_GroupId < m_vpGroups.size() &&
|
||||||
pItem->m_LayerId >= 0 && (size_t)pItem->m_LayerId < m_vpGroups[pItem->m_GroupId]->m_vpLayers.size())
|
pItem->m_LayerId >= 0 && (size_t)pItem->m_LayerId < m_vpGroups[pItem->m_GroupId]->m_vpLayers.size())
|
||||||
{
|
{
|
||||||
CLayer *pLayer = m_vpGroups[pItem->m_GroupId]->m_vpLayers[pItem->m_LayerId];
|
std::shared_ptr<CLayer> pLayer = m_vpGroups[pItem->m_GroupId]->m_vpLayers[pItem->m_LayerId];
|
||||||
if(pLayer->m_Type == LAYERTYPE_TILES)
|
if(pLayer->m_Type == LAYERTYPE_TILES)
|
||||||
{
|
{
|
||||||
CLayerTiles *pTiles = (CLayerTiles *)m_vpGroups[pItem->m_GroupId]->m_vpLayers[pItem->m_LayerId];
|
std::shared_ptr<CLayerTiles> pTiles = std::static_pointer_cast<CLayerTiles>(m_vpGroups[pItem->m_GroupId]->m_vpLayers[pItem->m_LayerId]);
|
||||||
// only load auto mappers for tile layers (not physics layers)
|
// only load auto mappers for tile layers (not physics layers)
|
||||||
if(!(pTiles->m_Game || pTiles->m_Tele || pTiles->m_Speedup ||
|
if(!(pTiles->m_Game || pTiles->m_Tele || pTiles->m_Speedup ||
|
||||||
pTiles->m_Front || pTiles->m_Switch || pTiles->m_Tune))
|
pTiles->m_Front || pTiles->m_Switch || pTiles->m_Tune))
|
||||||
|
@ -1021,19 +1015,19 @@ void CEditorMap::PerformSanityChecks(const std::function<void(const char *pError
|
||||||
// Check if there are any images with a width or height that is not divisible by 16 which are
|
// Check if there are any images with a width or height that is not divisible by 16 which are
|
||||||
// used in tile layers. Reset the image for these layers, to prevent crashes with some drivers.
|
// used in tile layers. Reset the image for these layers, to prevent crashes with some drivers.
|
||||||
size_t ImageIndex = 0;
|
size_t ImageIndex = 0;
|
||||||
for(const CEditorImage *pImage : m_vpImages)
|
for(const std::shared_ptr<CEditorImage> &pImage : m_vpImages)
|
||||||
{
|
{
|
||||||
if(pImage->m_Width % 16 != 0 || pImage->m_Height % 16 != 0)
|
if(pImage->m_Width % 16 != 0 || pImage->m_Height % 16 != 0)
|
||||||
{
|
{
|
||||||
size_t GroupIndex = 0;
|
size_t GroupIndex = 0;
|
||||||
for(CLayerGroup *pGroup : m_vpGroups)
|
for(const std::shared_ptr<CLayerGroup> &pGroup : m_vpGroups)
|
||||||
{
|
{
|
||||||
size_t LayerIndex = 0;
|
size_t LayerIndex = 0;
|
||||||
for(CLayer *pLayer : pGroup->m_vpLayers)
|
for(const std::shared_ptr<CLayer> &pLayer : pGroup->m_vpLayers)
|
||||||
{
|
{
|
||||||
if(pLayer->m_Type == LAYERTYPE_TILES)
|
if(pLayer->m_Type == LAYERTYPE_TILES)
|
||||||
{
|
{
|
||||||
CLayerTiles *pLayerTiles = static_cast<CLayerTiles *>(pLayer);
|
std::shared_ptr<CLayerTiles> pLayerTiles = std::static_pointer_cast<CLayerTiles>(pLayer);
|
||||||
if(pLayerTiles->m_Image >= 0 && (size_t)pLayerTiles->m_Image == ImageIndex)
|
if(pLayerTiles->m_Image >= 0 && (size_t)pLayerTiles->m_Image == ImageIndex)
|
||||||
{
|
{
|
||||||
pLayerTiles->m_Image = -1;
|
pLayerTiles->m_Image = -1;
|
||||||
|
@ -1092,9 +1086,7 @@ bool CEditor::Append(const char *pFileName, int StorageType)
|
||||||
// transfer groups
|
// transfer groups
|
||||||
for(const auto &pGroup : NewMap.m_vpGroups)
|
for(const auto &pGroup : NewMap.m_vpGroups)
|
||||||
{
|
{
|
||||||
if(pGroup == NewMap.m_pGameGroup)
|
if(pGroup != NewMap.m_pGameGroup)
|
||||||
delete pGroup;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
pGroup->m_pMap = &m_Map;
|
pGroup->m_pMap = &m_Map;
|
||||||
m_Map.m_vpGroups.push_back(pGroup);
|
m_Map.m_vpGroups.push_back(pGroup);
|
||||||
|
|
|
@ -30,7 +30,7 @@ void CLayerGame::SetTile(int x, int y, CTile Tile)
|
||||||
{
|
{
|
||||||
if(!m_pEditor->m_Map.m_pFrontLayer)
|
if(!m_pEditor->m_Map.m_pFrontLayer)
|
||||||
{
|
{
|
||||||
CLayer *pLayerFront = new CLayerFront(m_Width, m_Height);
|
std::shared_ptr<CLayer> pLayerFront = std::make_shared<CLayerFront>(m_Width, m_Height);
|
||||||
m_pEditor->m_Map.MakeFrontLayer(pLayerFront);
|
m_pEditor->m_Map.MakeFrontLayer(pLayerFront);
|
||||||
m_pEditor->m_Map.m_pGameGroup->AddLayer(pLayerFront);
|
m_pEditor->m_Map.m_pGameGroup->AddLayer(pLayerFront);
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,10 +107,10 @@ void CLayerQuads::BrushSelecting(CUIRect Rect)
|
||||||
Graphics()->LinesEnd();
|
Graphics()->LinesEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CLayerQuads::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
int CLayerQuads::BrushGrab(std::shared_ptr<CLayerGroup> pBrush, CUIRect Rect)
|
||||||
{
|
{
|
||||||
// create new layers
|
// create new layers
|
||||||
CLayerQuads *pGrabbed = new CLayerQuads();
|
std::shared_ptr<CLayerQuads> pGrabbed = std::make_shared<CLayerQuads>();
|
||||||
pGrabbed->m_pEditor = m_pEditor;
|
pGrabbed->m_pEditor = m_pEditor;
|
||||||
pGrabbed->m_Image = m_Image;
|
pGrabbed->m_Image = m_Image;
|
||||||
pBrush->AddLayer(pGrabbed);
|
pBrush->AddLayer(pGrabbed);
|
||||||
|
@ -138,9 +138,9 @@ int CLayerQuads::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
||||||
return pGrabbed->m_vQuads.empty() ? 0 : 1;
|
return pGrabbed->m_vQuads.empty() ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLayerQuads::BrushPlace(CLayer *pBrush, float wx, float wy)
|
void CLayerQuads::BrushPlace(std::shared_ptr<CLayer> pBrush, float wx, float wy)
|
||||||
{
|
{
|
||||||
CLayerQuads *pQuadLayer = (CLayerQuads *)pBrush;
|
std::shared_ptr<CLayerQuads> pQuadLayer = std::static_pointer_cast<CLayerQuads>(pBrush);
|
||||||
for(const auto &Quad : pQuadLayer->m_vQuads)
|
for(const auto &Quad : pQuadLayer->m_vQuads)
|
||||||
{
|
{
|
||||||
CQuad n = Quad;
|
CQuad n = Quad;
|
||||||
|
@ -264,9 +264,9 @@ void CLayerQuads::ModifyEnvelopeIndex(FIndexModifyFunction Func)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CLayer *CLayerQuads::Duplicate() const
|
std::shared_ptr<CLayer> CLayerQuads::Duplicate() const
|
||||||
{
|
{
|
||||||
return new CLayerQuads(*this);
|
return std::make_shared<CLayerQuads>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CLayerQuads::SwapQuads(int Index0, int Index1)
|
int CLayerQuads::SwapQuads(int Index0, int Index1)
|
||||||
|
|
|
@ -140,10 +140,10 @@ void CLayerSounds::BrushSelecting(CUIRect Rect)
|
||||||
Graphics()->LinesEnd();
|
Graphics()->LinesEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CLayerSounds::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
int CLayerSounds::BrushGrab(std::shared_ptr<CLayerGroup> pBrush, CUIRect Rect)
|
||||||
{
|
{
|
||||||
// create new layer
|
// create new layer
|
||||||
CLayerSounds *pGrabbed = new CLayerSounds();
|
std::shared_ptr<CLayerSounds> pGrabbed = std::make_shared<CLayerSounds>();
|
||||||
pGrabbed->m_pEditor = m_pEditor;
|
pGrabbed->m_pEditor = m_pEditor;
|
||||||
pGrabbed->m_Sound = m_Sound;
|
pGrabbed->m_Sound = m_Sound;
|
||||||
pBrush->AddLayer(pGrabbed);
|
pBrush->AddLayer(pGrabbed);
|
||||||
|
@ -167,9 +167,9 @@ int CLayerSounds::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
||||||
return pGrabbed->m_vSources.empty() ? 0 : 1;
|
return pGrabbed->m_vSources.empty() ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLayerSounds::BrushPlace(CLayer *pBrush, float wx, float wy)
|
void CLayerSounds::BrushPlace(std::shared_ptr<CLayer> pBrush, float wx, float wy)
|
||||||
{
|
{
|
||||||
CLayerSounds *pSoundLayer = (CLayerSounds *)pBrush;
|
std::shared_ptr<CLayerSounds> pSoundLayer = std::static_pointer_cast<CLayerSounds>(pBrush);
|
||||||
for(const auto &Source : pSoundLayer->m_vSources)
|
for(const auto &Source : pSoundLayer->m_vSources)
|
||||||
{
|
{
|
||||||
CSoundSource n = Source;
|
CSoundSource n = Source;
|
||||||
|
@ -228,7 +228,7 @@ void CLayerSounds::ModifyEnvelopeIndex(FIndexModifyFunction Func)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CLayer *CLayerSounds::Duplicate() const
|
std::shared_ptr<CLayer> CLayerSounds::Duplicate() const
|
||||||
{
|
{
|
||||||
return new CLayerSounds(*this);
|
return std::make_shared<CLayerSounds>(*this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ CLayerTiles::CLayerTiles(int w, int h)
|
||||||
m_aName[0] = '\0';
|
m_aName[0] = '\0';
|
||||||
m_Width = w;
|
m_Width = w;
|
||||||
m_Height = h;
|
m_Height = h;
|
||||||
m_Texture.Invalidate();
|
|
||||||
m_Image = -1;
|
m_Image = -1;
|
||||||
m_Game = 0;
|
m_Game = 0;
|
||||||
m_Color.r = 255;
|
m_Color.r = 255;
|
||||||
|
@ -51,7 +50,6 @@ CLayerTiles::CLayerTiles(const CLayerTiles &Other) :
|
||||||
mem_copy(m_pTiles, Other.m_pTiles, (size_t)m_Width * m_Height * sizeof(CTile));
|
mem_copy(m_pTiles, Other.m_pTiles, (size_t)m_Width * m_Height * sizeof(CTile));
|
||||||
|
|
||||||
m_Image = Other.m_Image;
|
m_Image = Other.m_Image;
|
||||||
m_Texture = Other.m_Texture;
|
|
||||||
m_Game = Other.m_Game;
|
m_Game = Other.m_Game;
|
||||||
m_Color = Other.m_Color;
|
m_Color = Other.m_Color;
|
||||||
m_ColorEnv = Other.m_ColorEnv;
|
m_ColorEnv = Other.m_ColorEnv;
|
||||||
|
@ -116,9 +114,23 @@ void CLayerTiles::MakePalette()
|
||||||
|
|
||||||
void CLayerTiles::Render(bool Tileset)
|
void CLayerTiles::Render(bool Tileset)
|
||||||
{
|
{
|
||||||
|
IGraphics::CTextureHandle Texture;
|
||||||
if(m_Image >= 0 && (size_t)m_Image < m_pEditor->m_Map.m_vpImages.size())
|
if(m_Image >= 0 && (size_t)m_Image < m_pEditor->m_Map.m_vpImages.size())
|
||||||
m_Texture = m_pEditor->m_Map.m_vpImages[m_Image]->m_Texture;
|
Texture = m_pEditor->m_Map.m_vpImages[m_Image]->m_Texture;
|
||||||
Graphics()->TextureSet(m_Texture);
|
else if(m_Game)
|
||||||
|
Texture = m_pEditor->GetEntitiesTexture();
|
||||||
|
else if(m_Front)
|
||||||
|
Texture = m_pEditor->GetFrontTexture();
|
||||||
|
else if(m_Tele)
|
||||||
|
Texture = m_pEditor->GetTeleTexture();
|
||||||
|
else if(m_Speedup)
|
||||||
|
Texture = m_pEditor->GetSpeedupTexture();
|
||||||
|
else if(m_Switch)
|
||||||
|
Texture = m_pEditor->GetSwitchTexture();
|
||||||
|
else if(m_Tune)
|
||||||
|
Texture = m_pEditor->GetTuneTexture();
|
||||||
|
Graphics()->TextureSet(Texture);
|
||||||
|
|
||||||
ColorRGBA Color = ColorRGBA(m_Color.r / 255.0f, m_Color.g / 255.0f, m_Color.b / 255.0f, m_Color.a / 255.0f);
|
ColorRGBA Color = ColorRGBA(m_Color.r / 255.0f, m_Color.g / 255.0f, m_Color.b / 255.0f, m_Color.a / 255.0f);
|
||||||
Graphics()->BlendNone();
|
Graphics()->BlendNone();
|
||||||
m_pEditor->RenderTools()->RenderTilemap(m_pTiles, m_Width, m_Height, 32.0f, Color, LAYERRENDERFLAG_OPAQUE,
|
m_pEditor->RenderTools()->RenderTilemap(m_pTiles, m_Width, m_Height, 32.0f, Color, LAYERRENDERFLAG_OPAQUE,
|
||||||
|
@ -131,13 +143,13 @@ void CLayerTiles::Render(bool Tileset)
|
||||||
if(!Tileset)
|
if(!Tileset)
|
||||||
{
|
{
|
||||||
if(m_Tele)
|
if(m_Tele)
|
||||||
m_pEditor->RenderTools()->RenderTeleOverlay(((CLayerTele *)this)->m_pTeleTile, m_Width, m_Height, 32.0f);
|
m_pEditor->RenderTools()->RenderTeleOverlay(static_cast<CLayerTele *>(this)->m_pTeleTile, m_Width, m_Height, 32.0f);
|
||||||
if(m_Speedup)
|
if(m_Speedup)
|
||||||
m_pEditor->RenderTools()->RenderSpeedupOverlay(((CLayerSpeedup *)this)->m_pSpeedupTile, m_Width, m_Height, 32.0f);
|
m_pEditor->RenderTools()->RenderSpeedupOverlay(static_cast<CLayerSpeedup *>(this)->m_pSpeedupTile, m_Width, m_Height, 32.0f);
|
||||||
if(m_Switch)
|
if(m_Switch)
|
||||||
m_pEditor->RenderTools()->RenderSwitchOverlay(((CLayerSwitch *)this)->m_pSwitchTile, m_Width, m_Height, 32.0f);
|
m_pEditor->RenderTools()->RenderSwitchOverlay(static_cast<CLayerSwitch *>(this)->m_pSwitchTile, m_Width, m_Height, 32.0f);
|
||||||
if(m_Tune)
|
if(m_Tune)
|
||||||
m_pEditor->RenderTools()->RenderTuneOverlay(((CLayerTune *)this)->m_pTuneTile, m_Width, m_Height, 32.0f);
|
m_pEditor->RenderTools()->RenderTuneOverlay(static_cast<CLayerTune *>(this)->m_pTuneTile, m_Width, m_Height, 32.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,12 +202,13 @@ void CLayerTiles::Clamp(RECTi *pRect)
|
||||||
|
|
||||||
bool CLayerTiles::IsEntitiesLayer() const
|
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;
|
return m_pEditor->m_Map.m_pGameLayer.get() == this || m_pEditor->m_Map.m_pTeleLayer.get() == this || m_pEditor->m_Map.m_pSpeedupLayer.get() == this || m_pEditor->m_Map.m_pFrontLayer.get() == this || m_pEditor->m_Map.m_pSwitchLayer.get() == this || m_pEditor->m_Map.m_pTuneLayer.get() == this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CLayerTiles::IsEmpty(CLayerTiles *pLayer)
|
bool CLayerTiles::IsEmpty(const std::shared_ptr<CLayerTiles> &pLayer)
|
||||||
{
|
{
|
||||||
for(int y = 0; y < pLayer->m_Height; y++)
|
for(int y = 0; y < pLayer->m_Height; y++)
|
||||||
|
{
|
||||||
for(int x = 0; x < pLayer->m_Width; x++)
|
for(int x = 0; x < pLayer->m_Width; x++)
|
||||||
{
|
{
|
||||||
int Index = pLayer->GetTile(x, y).m_Index;
|
int Index = pLayer->GetTile(x, y).m_Index;
|
||||||
|
@ -215,6 +228,7 @@ bool CLayerTiles::IsEmpty(CLayerTiles *pLayer)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -233,7 +247,25 @@ void CLayerTiles::BrushSelecting(CUIRect Rect)
|
||||||
TextRender()->Text(Rect.x + 3.0f, Rect.y + 3.0f, m_pEditor->m_ShowPicker ? 15.0f : 15.0f * m_pEditor->m_WorldZoom, aBuf, -1.0f);
|
TextRender()->Text(Rect.x + 3.0f, Rect.y + 3.0f, m_pEditor->m_ShowPicker ? 15.0f : 15.0f * m_pEditor->m_WorldZoom, aBuf, -1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
template<typename T>
|
||||||
|
static void InitGrabbedLayer(std::shared_ptr<T> pLayer, CLayerTiles *pThisLayer)
|
||||||
|
{
|
||||||
|
pLayer->m_pEditor = pThisLayer->m_pEditor;
|
||||||
|
pLayer->m_Image = pThisLayer->m_Image;
|
||||||
|
pLayer->m_Game = pThisLayer->m_Game;
|
||||||
|
pLayer->m_Front = pThisLayer->m_Front;
|
||||||
|
pLayer->m_Tele = pThisLayer->m_Tele;
|
||||||
|
pLayer->m_Speedup = pThisLayer->m_Speedup;
|
||||||
|
pLayer->m_Switch = pThisLayer->m_Switch;
|
||||||
|
pLayer->m_Tune = pThisLayer->m_Tune;
|
||||||
|
if(pThisLayer->m_pEditor->m_BrushColorEnabled)
|
||||||
|
{
|
||||||
|
pLayer->m_Color = pThisLayer->m_Color;
|
||||||
|
pLayer->m_Color.a = 255;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int CLayerTiles::BrushGrab(std::shared_ptr<CLayerGroup> pBrush, CUIRect Rect)
|
||||||
{
|
{
|
||||||
RECTi r;
|
RECTi r;
|
||||||
Convert(Rect, &r);
|
Convert(Rect, &r);
|
||||||
|
@ -245,16 +277,8 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
||||||
// create new layers
|
// create new layers
|
||||||
if(this->m_Tele)
|
if(this->m_Tele)
|
||||||
{
|
{
|
||||||
CLayerTele *pGrabbed = new CLayerTele(r.w, r.h);
|
std::shared_ptr<CLayerTele> pGrabbed = std::make_shared<CLayerTele>(r.w, r.h);
|
||||||
pGrabbed->m_pEditor = m_pEditor;
|
InitGrabbedLayer(pGrabbed, this);
|
||||||
pGrabbed->m_Texture = m_Texture;
|
|
||||||
pGrabbed->m_Image = m_Image;
|
|
||||||
pGrabbed->m_Game = m_Game;
|
|
||||||
if(m_pEditor->m_BrushColorEnabled)
|
|
||||||
{
|
|
||||||
pGrabbed->m_Color = m_Color;
|
|
||||||
pGrabbed->m_Color.a = 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
pBrush->AddLayer(pGrabbed);
|
pBrush->AddLayer(pGrabbed);
|
||||||
|
|
||||||
|
@ -268,7 +292,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
||||||
for(int y = 0; y < r.h; y++)
|
for(int y = 0; y < r.h; y++)
|
||||||
for(int x = 0; x < r.w; x++)
|
for(int x = 0; x < r.w; x++)
|
||||||
{
|
{
|
||||||
pGrabbed->m_pTeleTile[y * pGrabbed->m_Width + x] = ((CLayerTele *)this)->m_pTeleTile[(r.y + y) * m_Width + (r.x + x)];
|
pGrabbed->m_pTeleTile[y * pGrabbed->m_Width + x] = static_cast<CLayerTele *>(this)->m_pTeleTile[(r.y + y) * m_Width + (r.x + x)];
|
||||||
if(IsValidTeleTile(pGrabbed->m_pTeleTile[y * pGrabbed->m_Width + x].m_Type) && IsTeleTileNumberUsed(pGrabbed->m_pTeleTile[y * pGrabbed->m_Width + x].m_Type))
|
if(IsValidTeleTile(pGrabbed->m_pTeleTile[y * pGrabbed->m_Width + x].m_Type) && IsTeleTileNumberUsed(pGrabbed->m_pTeleTile[y * pGrabbed->m_Width + x].m_Type))
|
||||||
{
|
{
|
||||||
m_pEditor->m_TeleNumber = pGrabbed->m_pTeleTile[y * pGrabbed->m_Width + x].m_Number;
|
m_pEditor->m_TeleNumber = pGrabbed->m_pTeleTile[y * pGrabbed->m_Width + x].m_Number;
|
||||||
|
@ -279,16 +303,8 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
||||||
}
|
}
|
||||||
else if(this->m_Speedup)
|
else if(this->m_Speedup)
|
||||||
{
|
{
|
||||||
CLayerSpeedup *pGrabbed = new CLayerSpeedup(r.w, r.h);
|
std::shared_ptr<CLayerSpeedup> pGrabbed = std::make_shared<CLayerSpeedup>(r.w, r.h);
|
||||||
pGrabbed->m_pEditor = m_pEditor;
|
InitGrabbedLayer(pGrabbed, this);
|
||||||
pGrabbed->m_Texture = m_Texture;
|
|
||||||
pGrabbed->m_Image = m_Image;
|
|
||||||
pGrabbed->m_Game = m_Game;
|
|
||||||
if(m_pEditor->m_BrushColorEnabled)
|
|
||||||
{
|
|
||||||
pGrabbed->m_Color = m_Color;
|
|
||||||
pGrabbed->m_Color.a = 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
pBrush->AddLayer(pGrabbed);
|
pBrush->AddLayer(pGrabbed);
|
||||||
|
|
||||||
|
@ -302,7 +318,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
||||||
for(int y = 0; y < r.h; y++)
|
for(int y = 0; y < r.h; y++)
|
||||||
for(int x = 0; x < r.w; x++)
|
for(int x = 0; x < r.w; x++)
|
||||||
{
|
{
|
||||||
pGrabbed->m_pSpeedupTile[y * pGrabbed->m_Width + x] = ((CLayerSpeedup *)this)->m_pSpeedupTile[(r.y + y) * m_Width + (r.x + x)];
|
pGrabbed->m_pSpeedupTile[y * pGrabbed->m_Width + x] = static_cast<CLayerSpeedup *>(this)->m_pSpeedupTile[(r.y + y) * m_Width + (r.x + x)];
|
||||||
if(IsValidSpeedupTile(pGrabbed->m_pSpeedupTile[y * pGrabbed->m_Width + x].m_Type))
|
if(IsValidSpeedupTile(pGrabbed->m_pSpeedupTile[y * pGrabbed->m_Width + x].m_Type))
|
||||||
{
|
{
|
||||||
m_pEditor->m_SpeedupAngle = pGrabbed->m_pSpeedupTile[y * pGrabbed->m_Width + x].m_Angle;
|
m_pEditor->m_SpeedupAngle = pGrabbed->m_pSpeedupTile[y * pGrabbed->m_Width + x].m_Angle;
|
||||||
|
@ -317,16 +333,8 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
||||||
}
|
}
|
||||||
else if(this->m_Switch)
|
else if(this->m_Switch)
|
||||||
{
|
{
|
||||||
CLayerSwitch *pGrabbed = new CLayerSwitch(r.w, r.h);
|
std::shared_ptr<CLayerSwitch> pGrabbed = std::make_shared<CLayerSwitch>(r.w, r.h);
|
||||||
pGrabbed->m_pEditor = m_pEditor;
|
InitGrabbedLayer(pGrabbed, this);
|
||||||
pGrabbed->m_Texture = m_Texture;
|
|
||||||
pGrabbed->m_Image = m_Image;
|
|
||||||
pGrabbed->m_Game = m_Game;
|
|
||||||
if(m_pEditor->m_BrushColorEnabled)
|
|
||||||
{
|
|
||||||
pGrabbed->m_Color = m_Color;
|
|
||||||
pGrabbed->m_Color.a = 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
pBrush->AddLayer(pGrabbed);
|
pBrush->AddLayer(pGrabbed);
|
||||||
|
|
||||||
|
@ -340,7 +348,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
||||||
for(int y = 0; y < r.h; y++)
|
for(int y = 0; y < r.h; y++)
|
||||||
for(int x = 0; x < r.w; x++)
|
for(int x = 0; x < r.w; x++)
|
||||||
{
|
{
|
||||||
pGrabbed->m_pSwitchTile[y * pGrabbed->m_Width + x] = ((CLayerSwitch *)this)->m_pSwitchTile[(r.y + y) * m_Width + (r.x + x)];
|
pGrabbed->m_pSwitchTile[y * pGrabbed->m_Width + x] = static_cast<CLayerSwitch *>(this)->m_pSwitchTile[(r.y + y) * m_Width + (r.x + x)];
|
||||||
if(IsValidSwitchTile(pGrabbed->m_pSwitchTile[y * pGrabbed->m_Width + x].m_Type))
|
if(IsValidSwitchTile(pGrabbed->m_pSwitchTile[y * pGrabbed->m_Width + x].m_Type))
|
||||||
{
|
{
|
||||||
m_pEditor->m_SwitchNum = pGrabbed->m_pSwitchTile[y * pGrabbed->m_Width + x].m_Number;
|
m_pEditor->m_SwitchNum = pGrabbed->m_pSwitchTile[y * pGrabbed->m_Width + x].m_Number;
|
||||||
|
@ -354,16 +362,8 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
||||||
|
|
||||||
else if(this->m_Tune)
|
else if(this->m_Tune)
|
||||||
{
|
{
|
||||||
CLayerTune *pGrabbed = new CLayerTune(r.w, r.h);
|
std::shared_ptr<CLayerTune> pGrabbed = std::make_shared<CLayerTune>(r.w, r.h);
|
||||||
pGrabbed->m_pEditor = m_pEditor;
|
InitGrabbedLayer(pGrabbed, this);
|
||||||
pGrabbed->m_Texture = m_Texture;
|
|
||||||
pGrabbed->m_Image = m_Image;
|
|
||||||
pGrabbed->m_Game = m_Game;
|
|
||||||
if(m_pEditor->m_BrushColorEnabled)
|
|
||||||
{
|
|
||||||
pGrabbed->m_Color = m_Color;
|
|
||||||
pGrabbed->m_Color.a = 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
pBrush->AddLayer(pGrabbed);
|
pBrush->AddLayer(pGrabbed);
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
||||||
for(int y = 0; y < r.h; y++)
|
for(int y = 0; y < r.h; y++)
|
||||||
for(int x = 0; x < r.w; x++)
|
for(int x = 0; x < r.w; x++)
|
||||||
{
|
{
|
||||||
pGrabbed->m_pTuneTile[y * pGrabbed->m_Width + x] = ((CLayerTune *)this)->m_pTuneTile[(r.y + y) * m_Width + (r.x + x)];
|
pGrabbed->m_pTuneTile[y * pGrabbed->m_Width + x] = static_cast<CLayerTune *>(this)->m_pTuneTile[(r.y + y) * m_Width + (r.x + x)];
|
||||||
if(IsValidTuneTile(pGrabbed->m_pTuneTile[y * pGrabbed->m_Width + x].m_Type))
|
if(IsValidTuneTile(pGrabbed->m_pTuneTile[y * pGrabbed->m_Width + x].m_Type))
|
||||||
{
|
{
|
||||||
m_pEditor->m_TuningNum = pGrabbed->m_pTuneTile[y * pGrabbed->m_Width + x].m_Number;
|
m_pEditor->m_TuningNum = pGrabbed->m_pTuneTile[y * pGrabbed->m_Width + x].m_Number;
|
||||||
|
@ -388,16 +388,8 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
||||||
}
|
}
|
||||||
else if(this->m_Front)
|
else if(this->m_Front)
|
||||||
{
|
{
|
||||||
CLayerFront *pGrabbed = new CLayerFront(r.w, r.h);
|
std::shared_ptr<CLayerFront> pGrabbed = std::make_shared<CLayerFront>(r.w, r.h);
|
||||||
pGrabbed->m_pEditor = m_pEditor;
|
InitGrabbedLayer(pGrabbed, this);
|
||||||
pGrabbed->m_Texture = m_Texture;
|
|
||||||
pGrabbed->m_Image = m_Image;
|
|
||||||
pGrabbed->m_Game = m_Game;
|
|
||||||
if(m_pEditor->m_BrushColorEnabled)
|
|
||||||
{
|
|
||||||
pGrabbed->m_Color = m_Color;
|
|
||||||
pGrabbed->m_Color.a = 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
pBrush->AddLayer(pGrabbed);
|
pBrush->AddLayer(pGrabbed);
|
||||||
|
|
||||||
|
@ -409,16 +401,8 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLayerTiles *pGrabbed = new CLayerTiles(r.w, r.h);
|
std::shared_ptr<CLayerTiles> pGrabbed = std::make_shared<CLayerFront>(r.w, r.h);
|
||||||
pGrabbed->m_pEditor = m_pEditor;
|
InitGrabbedLayer(pGrabbed, this);
|
||||||
pGrabbed->m_Texture = m_Texture;
|
|
||||||
pGrabbed->m_Image = m_Image;
|
|
||||||
pGrabbed->m_Game = m_Game;
|
|
||||||
if(m_pEditor->m_BrushColorEnabled)
|
|
||||||
{
|
|
||||||
pGrabbed->m_Color = m_Color;
|
|
||||||
pGrabbed->m_Color.a = 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
pBrush->AddLayer(pGrabbed);
|
pBrush->AddLayer(pGrabbed);
|
||||||
|
|
||||||
|
@ -432,7 +416,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLayerTiles::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
void CLayerTiles::FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CUIRect Rect)
|
||||||
{
|
{
|
||||||
if(m_Readonly || (!Empty && pBrush->m_Type != LAYERTYPE_TILES))
|
if(m_Readonly || (!Empty && pBrush->m_Type != LAYERTYPE_TILES))
|
||||||
return;
|
return;
|
||||||
|
@ -444,7 +428,7 @@ void CLayerTiles::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
||||||
int w = ConvertX(Rect.w);
|
int w = ConvertX(Rect.w);
|
||||||
int h = ConvertY(Rect.h);
|
int h = ConvertY(Rect.h);
|
||||||
|
|
||||||
CLayerTiles *pLt = static_cast<CLayerTiles *>(pBrush);
|
std::shared_ptr<CLayerTiles> pLt = std::static_pointer_cast<CLayerTiles>(pBrush);
|
||||||
|
|
||||||
bool Destructive = m_pEditor->m_BrushDrawDestructive || Empty || IsEmpty(pLt);
|
bool Destructive = m_pEditor->m_BrushDrawDestructive || Empty || IsEmpty(pLt);
|
||||||
|
|
||||||
|
@ -480,13 +464,13 @@ void CLayerTiles::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
||||||
FlagModified(sx, sy, w, h);
|
FlagModified(sx, sy, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLayerTiles::BrushDraw(CLayer *pBrush, float wx, float wy)
|
void CLayerTiles::BrushDraw(std::shared_ptr<CLayer> pBrush, float wx, float wy)
|
||||||
{
|
{
|
||||||
if(m_Readonly)
|
if(m_Readonly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//
|
//
|
||||||
CLayerTiles *pTileLayer = (CLayerTiles *)pBrush;
|
std::shared_ptr<CLayerTiles> pTileLayer = std::static_pointer_cast<CLayerTiles>(pBrush);
|
||||||
int sx = ConvertX(wx);
|
int sx = ConvertX(wx);
|
||||||
int sy = ConvertY(wy);
|
int sy = ConvertY(wy);
|
||||||
|
|
||||||
|
@ -593,9 +577,9 @@ void CLayerTiles::BrushRotate(float Amount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CLayer *CLayerTiles::Duplicate() const
|
std::shared_ptr<CLayer> CLayerTiles::Duplicate() const
|
||||||
{
|
{
|
||||||
return new CLayerTiles(*this);
|
return std::make_shared<CLayerTiles>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLayerTiles::Resize(int NewW, int NewH)
|
void CLayerTiles::Resize(int NewW, int NewH)
|
||||||
|
@ -680,7 +664,7 @@ CUI::EPopupMenuFunctionResult CLayerTiles::RenderProperties(CUIRect *pToolBox)
|
||||||
|
|
||||||
const bool EntitiesLayer = IsEntitiesLayer();
|
const bool EntitiesLayer = IsEntitiesLayer();
|
||||||
|
|
||||||
CLayerGroup *pGroup = m_pEditor->m_Map.m_vpGroups[m_pEditor->m_SelectedGroup];
|
std::shared_ptr<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
|
// Game tiles can only be constructed if the layer is relative to the game layer
|
||||||
if(!EntitiesLayer && !(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)
|
||||||
|
@ -730,7 +714,7 @@ CUI::EPopupMenuFunctionResult CLayerTiles::RenderProperties(CUIRect *pToolBox)
|
||||||
|
|
||||||
if(Result != TILE_TELECHECKIN && Result != TILE_TELECHECKINEVIL)
|
if(Result != TILE_TELECHECKIN && Result != TILE_TELECHECKINEVIL)
|
||||||
{
|
{
|
||||||
CLayerTiles *pGLayer = m_pEditor->m_Map.m_pGameLayer;
|
std::shared_ptr<CLayerTiles> pGLayer = m_pEditor->m_Map.m_pGameLayer;
|
||||||
|
|
||||||
if(pGLayer->m_Width < m_Width + OffsetX || pGLayer->m_Height < m_Height + OffsetY)
|
if(pGLayer->m_Width < m_Width + OffsetX || pGLayer->m_Height < m_Height + OffsetY)
|
||||||
{
|
{
|
||||||
|
@ -755,12 +739,12 @@ CUI::EPopupMenuFunctionResult CLayerTiles::RenderProperties(CUIRect *pToolBox)
|
||||||
{
|
{
|
||||||
if(!m_pEditor->m_Map.m_pTeleLayer)
|
if(!m_pEditor->m_Map.m_pTeleLayer)
|
||||||
{
|
{
|
||||||
CLayer *pLayer = new CLayerTele(m_Width, m_Height);
|
std::shared_ptr<CLayer> pLayer = std::make_shared<CLayerTele>(m_Width, m_Height);
|
||||||
m_pEditor->m_Map.MakeTeleLayer(pLayer);
|
m_pEditor->m_Map.MakeTeleLayer(pLayer);
|
||||||
m_pEditor->m_Map.m_pGameGroup->AddLayer(pLayer);
|
m_pEditor->m_Map.m_pGameGroup->AddLayer(pLayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLayerTele *pTLayer = m_pEditor->m_Map.m_pTeleLayer;
|
std::shared_ptr<CLayerTele> pTLayer = m_pEditor->m_Map.m_pTeleLayer;
|
||||||
|
|
||||||
if(pTLayer->m_Width < m_Width + OffsetX || pTLayer->m_Height < m_Height + OffsetY)
|
if(pTLayer->m_Width < m_Width + OffsetX || pTLayer->m_Height < m_Height + OffsetY)
|
||||||
{
|
{
|
||||||
|
@ -785,7 +769,7 @@ CUI::EPopupMenuFunctionResult CLayerTiles::RenderProperties(CUIRect *pToolBox)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_pEditor->m_Map.m_pGameLayer != this)
|
if(m_pEditor->m_Map.m_pGameLayer.get() != this)
|
||||||
{
|
{
|
||||||
if(m_Image >= 0 && (size_t)m_Image < m_pEditor->m_Map.m_vpImages.size() && m_pEditor->m_Map.m_vpImages[m_Image]->m_AutoMapper.IsLoaded() && m_AutoMapperConfig != -1)
|
if(m_Image >= 0 && (size_t)m_Image < m_pEditor->m_Map.m_vpImages.size() && m_pEditor->m_Map.m_vpImages[m_Image]->m_AutoMapper.IsLoaded() && m_AutoMapperConfig != -1)
|
||||||
{
|
{
|
||||||
|
@ -897,7 +881,6 @@ CUI::EPopupMenuFunctionResult CLayerTiles::RenderProperties(CUIRect *pToolBox)
|
||||||
m_Image = NewVal;
|
m_Image = NewVal;
|
||||||
if(NewVal == -1)
|
if(NewVal == -1)
|
||||||
{
|
{
|
||||||
m_Texture.Invalidate();
|
|
||||||
m_Image = -1;
|
m_Image = -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -909,8 +892,6 @@ CUI::EPopupMenuFunctionResult CLayerTiles::RenderProperties(CUIRect *pToolBox)
|
||||||
{
|
{
|
||||||
m_pEditor->m_PopupEventType = CEditor::POPEVENT_IMAGEDIV16;
|
m_pEditor->m_PopupEventType = CEditor::POPEVENT_IMAGEDIV16;
|
||||||
m_pEditor->m_PopupEventActivated = true;
|
m_pEditor->m_PopupEventActivated = true;
|
||||||
|
|
||||||
m_Texture.Invalidate();
|
|
||||||
m_Image = -1;
|
m_Image = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -962,7 +943,7 @@ CUI::EPopupMenuFunctionResult CLayerTiles::RenderProperties(CUIRect *pToolBox)
|
||||||
return CUI::POPUP_KEEP_OPEN;
|
return CUI::POPUP_KEEP_OPEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
CUI::EPopupMenuFunctionResult CLayerTiles::RenderCommonProperties(SCommonPropState &State, CEditor *pEditor, CUIRect *pToolbox, std::vector<CLayerTiles *> &vpLayers)
|
CUI::EPopupMenuFunctionResult CLayerTiles::RenderCommonProperties(SCommonPropState &State, CEditor *pEditor, CUIRect *pToolbox, std::vector<std::shared_ptr<CLayerTiles>> &vpLayers)
|
||||||
{
|
{
|
||||||
if(State.m_Modified)
|
if(State.m_Modified)
|
||||||
{
|
{
|
||||||
|
@ -1093,10 +1074,7 @@ void CLayerTiles::FlagModified(int x, int y, int w, int h)
|
||||||
|
|
||||||
void CLayerTiles::ModifyImageIndex(FIndexModifyFunction Func)
|
void CLayerTiles::ModifyImageIndex(FIndexModifyFunction Func)
|
||||||
{
|
{
|
||||||
const auto ImgBefore = m_Image;
|
|
||||||
Func(&m_Image);
|
Func(&m_Image);
|
||||||
if(m_Image != ImgBefore)
|
|
||||||
m_Texture.Invalidate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLayerTiles::ModifyEnvelopeIndex(FIndexModifyFunction Func)
|
void CLayerTiles::ModifyEnvelopeIndex(FIndexModifyFunction Func)
|
||||||
|
@ -1147,7 +1125,7 @@ void CLayerTele::Shift(int Direction)
|
||||||
ShiftImpl(m_pTeleTile, Direction, m_pEditor->m_ShiftBy);
|
ShiftImpl(m_pTeleTile, Direction, m_pEditor->m_ShiftBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CLayerTele::IsEmpty(CLayerTiles *pLayer)
|
bool CLayerTele::IsEmpty(const std::shared_ptr<CLayerTiles> &pLayer)
|
||||||
{
|
{
|
||||||
for(int y = 0; y < pLayer->m_Height; y++)
|
for(int y = 0; y < pLayer->m_Height; y++)
|
||||||
for(int x = 0; x < pLayer->m_Width; x++)
|
for(int x = 0; x < pLayer->m_Width; x++)
|
||||||
|
@ -1157,12 +1135,12 @@ bool CLayerTele::IsEmpty(CLayerTiles *pLayer)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLayerTele::BrushDraw(CLayer *pBrush, float wx, float wy)
|
void CLayerTele::BrushDraw(std::shared_ptr<CLayer> pBrush, float wx, float wy)
|
||||||
{
|
{
|
||||||
if(m_Readonly)
|
if(m_Readonly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CLayerTele *pTeleLayer = (CLayerTele *)pBrush;
|
std::shared_ptr<CLayerTele> pTeleLayer = std::static_pointer_cast<CLayerTele>(pBrush);
|
||||||
int sx = ConvertX(wx);
|
int sx = ConvertX(wx);
|
||||||
int sy = ConvertY(wy);
|
int sy = ConvertY(wy);
|
||||||
if(str_comp(pTeleLayer->m_aFileName, m_pEditor->m_aFileName))
|
if(str_comp(pTeleLayer->m_aFileName, m_pEditor->m_aFileName))
|
||||||
|
@ -1270,7 +1248,7 @@ void CLayerTele::BrushRotate(float Amount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLayerTele::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
void CLayerTele::FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CUIRect Rect)
|
||||||
{
|
{
|
||||||
if(m_Readonly || (!Empty && pBrush->m_Type != LAYERTYPE_TILES))
|
if(m_Readonly || (!Empty && pBrush->m_Type != LAYERTYPE_TILES))
|
||||||
return;
|
return;
|
||||||
|
@ -1284,7 +1262,7 @@ void CLayerTele::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
||||||
int w = ConvertX(Rect.w);
|
int w = ConvertX(Rect.w);
|
||||||
int h = ConvertY(Rect.h);
|
int h = ConvertY(Rect.h);
|
||||||
|
|
||||||
CLayerTele *pLt = static_cast<CLayerTele *>(pBrush);
|
std::shared_ptr<CLayerTele> pLt = std::static_pointer_cast<CLayerTele>(pBrush);
|
||||||
|
|
||||||
bool Destructive = m_pEditor->m_BrushDrawDestructive || Empty || IsEmpty(pLt);
|
bool Destructive = m_pEditor->m_BrushDrawDestructive || Empty || IsEmpty(pLt);
|
||||||
|
|
||||||
|
@ -1393,7 +1371,7 @@ void CLayerSpeedup::Shift(int Direction)
|
||||||
ShiftImpl(m_pSpeedupTile, Direction, m_pEditor->m_ShiftBy);
|
ShiftImpl(m_pSpeedupTile, Direction, m_pEditor->m_ShiftBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CLayerSpeedup::IsEmpty(CLayerTiles *pLayer)
|
bool CLayerSpeedup::IsEmpty(const std::shared_ptr<CLayerTiles> &pLayer)
|
||||||
{
|
{
|
||||||
for(int y = 0; y < pLayer->m_Height; y++)
|
for(int y = 0; y < pLayer->m_Height; y++)
|
||||||
for(int x = 0; x < pLayer->m_Width; x++)
|
for(int x = 0; x < pLayer->m_Width; x++)
|
||||||
|
@ -1403,12 +1381,12 @@ bool CLayerSpeedup::IsEmpty(CLayerTiles *pLayer)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLayerSpeedup::BrushDraw(CLayer *pBrush, float wx, float wy)
|
void CLayerSpeedup::BrushDraw(std::shared_ptr<CLayer> pBrush, float wx, float wy)
|
||||||
{
|
{
|
||||||
if(m_Readonly)
|
if(m_Readonly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CLayerSpeedup *pSpeedupLayer = (CLayerSpeedup *)pBrush;
|
std::shared_ptr<CLayerSpeedup> pSpeedupLayer = std::static_pointer_cast<CLayerSpeedup>(pBrush);
|
||||||
int sx = ConvertX(wx);
|
int sx = ConvertX(wx);
|
||||||
int sy = ConvertY(wy);
|
int sy = ConvertY(wy);
|
||||||
if(str_comp(pSpeedupLayer->m_aFileName, m_pEditor->m_aFileName))
|
if(str_comp(pSpeedupLayer->m_aFileName, m_pEditor->m_aFileName))
|
||||||
|
@ -1525,7 +1503,7 @@ void CLayerSpeedup::BrushRotate(float Amount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLayerSpeedup::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
void CLayerSpeedup::FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CUIRect Rect)
|
||||||
{
|
{
|
||||||
if(m_Readonly || (!Empty && pBrush->m_Type != LAYERTYPE_TILES))
|
if(m_Readonly || (!Empty && pBrush->m_Type != LAYERTYPE_TILES))
|
||||||
return;
|
return;
|
||||||
|
@ -1539,7 +1517,7 @@ void CLayerSpeedup::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
||||||
int w = ConvertX(Rect.w);
|
int w = ConvertX(Rect.w);
|
||||||
int h = ConvertY(Rect.h);
|
int h = ConvertY(Rect.h);
|
||||||
|
|
||||||
CLayerSpeedup *pLt = static_cast<CLayerSpeedup *>(pBrush);
|
std::shared_ptr<CLayerSpeedup> pLt = std::static_pointer_cast<CLayerSpeedup>(pBrush);
|
||||||
|
|
||||||
bool Destructive = m_pEditor->m_BrushDrawDestructive || Empty || IsEmpty(pLt);
|
bool Destructive = m_pEditor->m_BrushDrawDestructive || Empty || IsEmpty(pLt);
|
||||||
|
|
||||||
|
@ -1682,7 +1660,7 @@ void CLayerSwitch::Shift(int Direction)
|
||||||
ShiftImpl(m_pSwitchTile, Direction, m_pEditor->m_ShiftBy);
|
ShiftImpl(m_pSwitchTile, Direction, m_pEditor->m_ShiftBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CLayerSwitch::IsEmpty(CLayerTiles *pLayer)
|
bool CLayerSwitch::IsEmpty(const std::shared_ptr<CLayerTiles> &pLayer)
|
||||||
{
|
{
|
||||||
for(int y = 0; y < pLayer->m_Height; y++)
|
for(int y = 0; y < pLayer->m_Height; y++)
|
||||||
for(int x = 0; x < pLayer->m_Width; x++)
|
for(int x = 0; x < pLayer->m_Width; x++)
|
||||||
|
@ -1692,12 +1670,12 @@ bool CLayerSwitch::IsEmpty(CLayerTiles *pLayer)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLayerSwitch::BrushDraw(CLayer *pBrush, float wx, float wy)
|
void CLayerSwitch::BrushDraw(std::shared_ptr<CLayer> pBrush, float wx, float wy)
|
||||||
{
|
{
|
||||||
if(m_Readonly)
|
if(m_Readonly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CLayerSwitch *pSwitchLayer = (CLayerSwitch *)pBrush;
|
std::shared_ptr<CLayerSwitch> pSwitchLayer = std::static_pointer_cast<CLayerSwitch>(pBrush);
|
||||||
int sx = ConvertX(wx);
|
int sx = ConvertX(wx);
|
||||||
int sy = ConvertY(wy);
|
int sy = ConvertY(wy);
|
||||||
if(str_comp(pSwitchLayer->m_aFileName, m_pEditor->m_aFileName))
|
if(str_comp(pSwitchLayer->m_aFileName, m_pEditor->m_aFileName))
|
||||||
|
@ -1820,7 +1798,7 @@ void CLayerSwitch::BrushRotate(float Amount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLayerSwitch::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
void CLayerSwitch::FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CUIRect Rect)
|
||||||
{
|
{
|
||||||
if(m_Readonly || (!Empty && pBrush->m_Type != LAYERTYPE_TILES))
|
if(m_Readonly || (!Empty && pBrush->m_Type != LAYERTYPE_TILES))
|
||||||
return;
|
return;
|
||||||
|
@ -1834,7 +1812,7 @@ void CLayerSwitch::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
||||||
int w = ConvertX(Rect.w);
|
int w = ConvertX(Rect.w);
|
||||||
int h = ConvertY(Rect.h);
|
int h = ConvertY(Rect.h);
|
||||||
|
|
||||||
CLayerSwitch *pLt = static_cast<CLayerSwitch *>(pBrush);
|
std::shared_ptr<CLayerSwitch> pLt = std::static_pointer_cast<CLayerSwitch>(pBrush);
|
||||||
|
|
||||||
bool Destructive = m_pEditor->m_BrushDrawDestructive || Empty || IsEmpty(pLt);
|
bool Destructive = m_pEditor->m_BrushDrawDestructive || Empty || IsEmpty(pLt);
|
||||||
|
|
||||||
|
@ -1953,7 +1931,7 @@ void CLayerTune::Shift(int Direction)
|
||||||
ShiftImpl(m_pTuneTile, Direction, m_pEditor->m_ShiftBy);
|
ShiftImpl(m_pTuneTile, Direction, m_pEditor->m_ShiftBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CLayerTune::IsEmpty(CLayerTiles *pLayer)
|
bool CLayerTune::IsEmpty(const std::shared_ptr<CLayerTiles> &pLayer)
|
||||||
{
|
{
|
||||||
for(int y = 0; y < pLayer->m_Height; y++)
|
for(int y = 0; y < pLayer->m_Height; y++)
|
||||||
for(int x = 0; x < pLayer->m_Width; x++)
|
for(int x = 0; x < pLayer->m_Width; x++)
|
||||||
|
@ -1963,12 +1941,12 @@ bool CLayerTune::IsEmpty(CLayerTiles *pLayer)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLayerTune::BrushDraw(CLayer *pBrush, float wx, float wy)
|
void CLayerTune::BrushDraw(std::shared_ptr<CLayer> pBrush, float wx, float wy)
|
||||||
{
|
{
|
||||||
if(m_Readonly)
|
if(m_Readonly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CLayerTune *pTuneLayer = (CLayerTune *)pBrush;
|
std::shared_ptr<CLayerTune> pTuneLayer = std::static_pointer_cast<CLayerTune>(pBrush);
|
||||||
int sx = ConvertX(wx);
|
int sx = ConvertX(wx);
|
||||||
int sy = ConvertY(wy);
|
int sy = ConvertY(wy);
|
||||||
if(str_comp(pTuneLayer->m_aFileName, m_pEditor->m_aFileName))
|
if(str_comp(pTuneLayer->m_aFileName, m_pEditor->m_aFileName))
|
||||||
|
@ -2070,7 +2048,7 @@ void CLayerTune::BrushRotate(float Amount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLayerTune::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
void CLayerTune::FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CUIRect Rect)
|
||||||
{
|
{
|
||||||
if(m_Readonly || (!Empty && pBrush->m_Type != LAYERTYPE_TILES))
|
if(m_Readonly || (!Empty && pBrush->m_Type != LAYERTYPE_TILES))
|
||||||
return;
|
return;
|
||||||
|
@ -2082,7 +2060,7 @@ void CLayerTune::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
||||||
int w = ConvertX(Rect.w);
|
int w = ConvertX(Rect.w);
|
||||||
int h = ConvertY(Rect.h);
|
int h = ConvertY(Rect.h);
|
||||||
|
|
||||||
CLayerTune *pLt = static_cast<CLayerTune *>(pBrush);
|
std::shared_ptr<CLayerTune> pLt = std::static_pointer_cast<CLayerTune>(pBrush);
|
||||||
|
|
||||||
bool Destructive = m_pEditor->m_BrushDrawDestructive || Empty || IsEmpty(pLt);
|
bool Destructive = m_pEditor->m_BrushDrawDestructive || Empty || IsEmpty(pLt);
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupMenuTools(void *pContext, CUIRect Vi
|
||||||
View.HSplitTop(12.0f, &Slot, &View);
|
View.HSplitTop(12.0f, &Slot, &View);
|
||||||
if(pEditor->DoButton_MenuItem(&s_BorderButton, "Place Border", 0, &Slot, 0, "Place tiles in a 2-tile wide border at the edges of the layer"))
|
if(pEditor->DoButton_MenuItem(&s_BorderButton, "Place Border", 0, &Slot, 0, "Place tiles in a 2-tile wide border at the edges of the layer"))
|
||||||
{
|
{
|
||||||
CLayerTiles *pT = (CLayerTiles *)pEditor->GetSelectedLayerType(0, LAYERTYPE_TILES);
|
std::shared_ptr<CLayerTiles> pT = std::static_pointer_cast<CLayerTiles>(pEditor->GetSelectedLayerType(0, LAYERTYPE_TILES));
|
||||||
if(pT && !pT->m_Tele && !pT->m_Speedup && !pT->m_Switch && !pT->m_Front && !pT->m_Tune)
|
if(pT && !pT->m_Tele && !pT->m_Speedup && !pT->m_Switch && !pT->m_Front && !pT->m_Tune)
|
||||||
{
|
{
|
||||||
pEditor->m_PopupEventType = POPEVENT_PLACE_BORDER_TILES;
|
pEditor->m_PopupEventType = POPEVENT_PLACE_BORDER_TILES;
|
||||||
|
@ -337,15 +337,15 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
|
||||||
if(pEditor->DoButton_Editor(&s_DeleteButton, "Clean up game tiles", 0, &Button, 0, "Removes game tiles that aren't based on a layer"))
|
if(pEditor->DoButton_Editor(&s_DeleteButton, "Clean up game tiles", 0, &Button, 0, "Removes game tiles that aren't based on a layer"))
|
||||||
{
|
{
|
||||||
// gather all tile layers
|
// gather all tile layers
|
||||||
std::vector<CLayerTiles *> vpLayers;
|
std::vector<std::shared_ptr<CLayerTiles>> vpLayers;
|
||||||
for(auto &pLayer : pEditor->m_Map.m_pGameGroup->m_vpLayers)
|
for(auto &pLayer : pEditor->m_Map.m_pGameGroup->m_vpLayers)
|
||||||
{
|
{
|
||||||
if(pLayer != pEditor->m_Map.m_pGameLayer && pLayer->m_Type == LAYERTYPE_TILES)
|
if(pLayer != pEditor->m_Map.m_pGameLayer && pLayer->m_Type == LAYERTYPE_TILES)
|
||||||
vpLayers.push_back(static_cast<CLayerTiles *>(pLayer));
|
vpLayers.push_back(std::static_pointer_cast<CLayerTiles>(pLayer));
|
||||||
}
|
}
|
||||||
|
|
||||||
// search for unneeded game tiles
|
// search for unneeded game tiles
|
||||||
CLayerTiles *pGameLayer = pEditor->m_Map.m_pGameLayer;
|
std::shared_ptr<CLayerTiles> pGameLayer = pEditor->m_Map.m_pGameLayer;
|
||||||
for(int y = 0; y < pGameLayer->m_Height; ++y)
|
for(int y = 0; y < pGameLayer->m_Height; ++y)
|
||||||
{
|
{
|
||||||
for(int x = 0; x < pGameLayer->m_Width; ++x)
|
for(int x = 0; x < pGameLayer->m_Width; ++x)
|
||||||
|
@ -383,11 +383,11 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
|
||||||
static int s_NewTeleLayerButton = 0;
|
static int s_NewTeleLayerButton = 0;
|
||||||
if(pEditor->DoButton_Editor(&s_NewTeleLayerButton, "Add tele layer", 0, &Button, 0, "Creates a new tele layer"))
|
if(pEditor->DoButton_Editor(&s_NewTeleLayerButton, "Add tele layer", 0, &Button, 0, "Creates a new tele layer"))
|
||||||
{
|
{
|
||||||
CLayer *pTeleLayer = new 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->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
|
||||||
pEditor->m_Map.MakeTeleLayer(pTeleLayer);
|
pEditor->m_Map.MakeTeleLayer(pTeleLayer);
|
||||||
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(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);
|
pEditor->SelectLayer(pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_vpLayers.size() - 1);
|
||||||
pEditor->m_Brush.Clear();
|
pEditor->m_pBrush->Clear();
|
||||||
return CUI::POPUP_CLOSE_CURRENT;
|
return CUI::POPUP_CLOSE_CURRENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -400,11 +400,11 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
|
||||||
static int s_NewSpeedupLayerButton = 0;
|
static int s_NewSpeedupLayerButton = 0;
|
||||||
if(pEditor->DoButton_Editor(&s_NewSpeedupLayerButton, "Add speedup layer", 0, &Button, 0, "Creates a new speedup layer"))
|
if(pEditor->DoButton_Editor(&s_NewSpeedupLayerButton, "Add speedup layer", 0, &Button, 0, "Creates a new speedup layer"))
|
||||||
{
|
{
|
||||||
CLayer *pSpeedupLayer = new 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->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
|
||||||
pEditor->m_Map.MakeSpeedupLayer(pSpeedupLayer);
|
pEditor->m_Map.MakeSpeedupLayer(pSpeedupLayer);
|
||||||
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(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);
|
pEditor->SelectLayer(pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_vpLayers.size() - 1);
|
||||||
pEditor->m_Brush.Clear();
|
pEditor->m_pBrush->Clear();
|
||||||
return CUI::POPUP_CLOSE_CURRENT;
|
return CUI::POPUP_CLOSE_CURRENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -417,11 +417,11 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
|
||||||
static int s_NewTuneLayerButton = 0;
|
static int s_NewTuneLayerButton = 0;
|
||||||
if(pEditor->DoButton_Editor(&s_NewTuneLayerButton, "Add tune layer", 0, &Button, 0, "Creates a new tuning layer"))
|
if(pEditor->DoButton_Editor(&s_NewTuneLayerButton, "Add tune layer", 0, &Button, 0, "Creates a new tuning layer"))
|
||||||
{
|
{
|
||||||
CLayer *pTuneLayer = new 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->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
|
||||||
pEditor->m_Map.MakeTuneLayer(pTuneLayer);
|
pEditor->m_Map.MakeTuneLayer(pTuneLayer);
|
||||||
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(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);
|
pEditor->SelectLayer(pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_vpLayers.size() - 1);
|
||||||
pEditor->m_Brush.Clear();
|
pEditor->m_pBrush->Clear();
|
||||||
return CUI::POPUP_CLOSE_CURRENT;
|
return CUI::POPUP_CLOSE_CURRENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -434,11 +434,11 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
|
||||||
static int s_NewFrontLayerButton = 0;
|
static int s_NewFrontLayerButton = 0;
|
||||||
if(pEditor->DoButton_Editor(&s_NewFrontLayerButton, "Add front layer", 0, &Button, 0, "Creates a new item layer"))
|
if(pEditor->DoButton_Editor(&s_NewFrontLayerButton, "Add front layer", 0, &Button, 0, "Creates a new item layer"))
|
||||||
{
|
{
|
||||||
CLayer *pFrontLayer = new 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->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
|
||||||
pEditor->m_Map.MakeFrontLayer(pFrontLayer);
|
pEditor->m_Map.MakeFrontLayer(pFrontLayer);
|
||||||
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(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);
|
pEditor->SelectLayer(pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_vpLayers.size() - 1);
|
||||||
pEditor->m_Brush.Clear();
|
pEditor->m_pBrush->Clear();
|
||||||
return CUI::POPUP_CLOSE_CURRENT;
|
return CUI::POPUP_CLOSE_CURRENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -451,11 +451,11 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
|
||||||
static int s_NewSwitchLayerButton = 0;
|
static int s_NewSwitchLayerButton = 0;
|
||||||
if(pEditor->DoButton_Editor(&s_NewSwitchLayerButton, "Add switch layer", 0, &Button, 0, "Creates a new switch layer"))
|
if(pEditor->DoButton_Editor(&s_NewSwitchLayerButton, "Add switch layer", 0, &Button, 0, "Creates a new switch layer"))
|
||||||
{
|
{
|
||||||
CLayer *pSwitchLayer = new 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->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
|
||||||
pEditor->m_Map.MakeSwitchLayer(pSwitchLayer);
|
pEditor->m_Map.MakeSwitchLayer(pSwitchLayer);
|
||||||
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(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);
|
pEditor->SelectLayer(pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_vpLayers.size() - 1);
|
||||||
pEditor->m_Brush.Clear();
|
pEditor->m_pBrush->Clear();
|
||||||
return CUI::POPUP_CLOSE_CURRENT;
|
return CUI::POPUP_CLOSE_CURRENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -466,7 +466,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
|
||||||
static int s_NewQuadLayerButton = 0;
|
static int s_NewQuadLayerButton = 0;
|
||||||
if(pEditor->DoButton_Editor(&s_NewQuadLayerButton, "Add quads layer", 0, &Button, 0, "Creates a new quad layer"))
|
if(pEditor->DoButton_Editor(&s_NewQuadLayerButton, "Add quads layer", 0, &Button, 0, "Creates a new quad layer"))
|
||||||
{
|
{
|
||||||
CLayer *pQuadLayer = new CLayerQuads;
|
std::shared_ptr<CLayer> pQuadLayer = std::make_shared<CLayerQuads>();
|
||||||
pQuadLayer->m_pEditor = pEditor;
|
pQuadLayer->m_pEditor = pEditor;
|
||||||
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(pQuadLayer);
|
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->SelectLayer(pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_vpLayers.size() - 1);
|
||||||
|
@ -480,7 +480,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
|
||||||
static int s_NewTileLayerButton = 0;
|
static int s_NewTileLayerButton = 0;
|
||||||
if(pEditor->DoButton_Editor(&s_NewTileLayerButton, "Add tile layer", 0, &Button, 0, "Creates a new tile layer"))
|
if(pEditor->DoButton_Editor(&s_NewTileLayerButton, "Add tile layer", 0, &Button, 0, "Creates a new tile layer"))
|
||||||
{
|
{
|
||||||
CLayer *pTileLayer = new 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->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
|
||||||
pTileLayer->m_pEditor = pEditor;
|
pTileLayer->m_pEditor = pEditor;
|
||||||
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(pTileLayer);
|
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(pTileLayer);
|
||||||
pEditor->SelectLayer(pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_vpLayers.size() - 1);
|
pEditor->SelectLayer(pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_vpLayers.size() - 1);
|
||||||
|
@ -494,7 +494,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
|
||||||
static int s_NewSoundLayerButton = 0;
|
static int s_NewSoundLayerButton = 0;
|
||||||
if(pEditor->DoButton_Editor(&s_NewSoundLayerButton, "Add sound layer", 0, &Button, 0, "Creates a new sound layer"))
|
if(pEditor->DoButton_Editor(&s_NewSoundLayerButton, "Add sound layer", 0, &Button, 0, "Creates a new sound layer"))
|
||||||
{
|
{
|
||||||
CLayer *pSoundLayer = new CLayerSounds;
|
std::shared_ptr<CLayer> pSoundLayer = std::make_shared<CLayerSounds>();
|
||||||
pSoundLayer->m_pEditor = pEditor;
|
pSoundLayer->m_pEditor = pEditor;
|
||||||
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(pSoundLayer);
|
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->SelectLayer(pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_vpLayers.size() - 1);
|
||||||
|
@ -625,8 +625,8 @@ CUI::EPopupMenuFunctionResult CEditor::PopupLayer(void *pContext, CUIRect View,
|
||||||
SLayerPopupContext *pPopup = (SLayerPopupContext *)pContext;
|
SLayerPopupContext *pPopup = (SLayerPopupContext *)pContext;
|
||||||
CEditor *pEditor = pPopup->m_pEditor;
|
CEditor *pEditor = pPopup->m_pEditor;
|
||||||
|
|
||||||
CLayerGroup *pCurrentGroup = pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup];
|
std::shared_ptr<CLayerGroup> pCurrentGroup = pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup];
|
||||||
CLayer *pCurrentLayer = pEditor->GetSelectedLayer(0);
|
std::shared_ptr<CLayer> pCurrentLayer = pEditor->GetSelectedLayer(0);
|
||||||
|
|
||||||
if(pPopup->m_vpLayers.size() > 1)
|
if(pPopup->m_vpLayers.size() > 1)
|
||||||
{
|
{
|
||||||
|
@ -751,7 +751,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupQuad(void *pContext, CUIRect View, b
|
||||||
CEditor *pEditor = static_cast<CEditor *>(pContext);
|
CEditor *pEditor = static_cast<CEditor *>(pContext);
|
||||||
std::vector<CQuad *> vpQuads = pEditor->GetSelectedQuads();
|
std::vector<CQuad *> vpQuads = pEditor->GetSelectedQuads();
|
||||||
CQuad *pCurrentQuad = vpQuads[pEditor->m_SelectedQuadIndex];
|
CQuad *pCurrentQuad = vpQuads[pEditor->m_SelectedQuadIndex];
|
||||||
CLayerQuads *pLayer = static_cast<CLayerQuads *>(pEditor->GetSelectedLayerType(0, LAYERTYPE_QUADS));
|
std::shared_ptr<CLayerQuads> pLayer = std::static_pointer_cast<CLayerQuads>(pEditor->GetSelectedLayerType(0, LAYERTYPE_QUADS));
|
||||||
|
|
||||||
CUIRect Button;
|
CUIRect Button;
|
||||||
|
|
||||||
|
@ -985,7 +985,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupSource(void *pContext, CUIRect View,
|
||||||
static int s_DeleteButton = 0;
|
static int s_DeleteButton = 0;
|
||||||
if(pEditor->DoButton_Editor(&s_DeleteButton, "Delete", 0, &Button, 0, "Deletes the current source"))
|
if(pEditor->DoButton_Editor(&s_DeleteButton, "Delete", 0, &Button, 0, "Deletes the current source"))
|
||||||
{
|
{
|
||||||
CLayerSounds *pLayer = (CLayerSounds *)pEditor->GetSelectedLayerType(0, LAYERTYPE_SOUNDS);
|
std::shared_ptr<CLayerSounds> pLayer = std::static_pointer_cast<CLayerSounds>(pEditor->GetSelectedLayerType(0, LAYERTYPE_SOUNDS));
|
||||||
if(pLayer)
|
if(pLayer)
|
||||||
{
|
{
|
||||||
pEditor->m_Map.OnModify();
|
pEditor->m_Map.OnModify();
|
||||||
|
@ -1296,7 +1296,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupEnvPoint(void *pContext, CUIRect Vie
|
||||||
static CLineInputNumber s_CurValueInput;
|
static CLineInputNumber s_CurValueInput;
|
||||||
static CLineInputNumber s_CurTimeInput;
|
static CLineInputNumber s_CurTimeInput;
|
||||||
|
|
||||||
CEnvelope *pEnvelope = pEditor->m_Map.m_vpEnvelopes[pEditor->m_SelectedEnvelope];
|
std::shared_ptr<CEnvelope> pEnvelope = pEditor->m_Map.m_vpEnvelopes[pEditor->m_SelectedEnvelope];
|
||||||
if(pEditor->m_UpdateEnvPointInfo)
|
if(pEditor->m_UpdateEnvPointInfo)
|
||||||
{
|
{
|
||||||
pEditor->m_UpdateEnvPointInfo = false;
|
pEditor->m_UpdateEnvPointInfo = false;
|
||||||
|
@ -1448,7 +1448,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupImage(void *pContext, CUIRect View,
|
||||||
|
|
||||||
CUIRect Slot;
|
CUIRect Slot;
|
||||||
View.HSplitTop(12.0f, &Slot, &View);
|
View.HSplitTop(12.0f, &Slot, &View);
|
||||||
CEditorImage *pImg = pEditor->m_Map.m_vpImages[pEditor->m_SelectedImage];
|
std::shared_ptr<CEditorImage> pImg = pEditor->m_Map.m_vpImages[pEditor->m_SelectedImage];
|
||||||
|
|
||||||
static int s_ExternalButton = 0;
|
static int s_ExternalButton = 0;
|
||||||
if(pImg->m_External)
|
if(pImg->m_External)
|
||||||
|
@ -1519,7 +1519,6 @@ CUI::EPopupMenuFunctionResult CEditor::PopupImage(void *pContext, CUIRect View,
|
||||||
View.HSplitTop(12.0f, &Slot, &View);
|
View.HSplitTop(12.0f, &Slot, &View);
|
||||||
if(pEditor->DoButton_MenuItem(&s_RemoveButton, "Remove", 0, &Slot, 0, "Removes the image from the map"))
|
if(pEditor->DoButton_MenuItem(&s_RemoveButton, "Remove", 0, &Slot, 0, "Removes the image from the map"))
|
||||||
{
|
{
|
||||||
delete pImg;
|
|
||||||
pEditor->m_Map.m_vpImages.erase(pEditor->m_Map.m_vpImages.begin() + pEditor->m_SelectedImage);
|
pEditor->m_Map.m_vpImages.erase(pEditor->m_Map.m_vpImages.begin() + pEditor->m_SelectedImage);
|
||||||
pEditor->m_Map.ModifyImageIndex(gs_ModifyIndexDeleted(pEditor->m_SelectedImage));
|
pEditor->m_Map.ModifyImageIndex(gs_ModifyIndexDeleted(pEditor->m_SelectedImage));
|
||||||
return CUI::POPUP_CLOSE_CURRENT;
|
return CUI::POPUP_CLOSE_CURRENT;
|
||||||
|
@ -1538,7 +1537,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupSound(void *pContext, CUIRect View,
|
||||||
|
|
||||||
CUIRect Slot;
|
CUIRect Slot;
|
||||||
View.HSplitTop(12.0f, &Slot, &View);
|
View.HSplitTop(12.0f, &Slot, &View);
|
||||||
CEditorSound *pSound = pEditor->m_Map.m_vpSounds[pEditor->m_SelectedSound];
|
std::shared_ptr<CEditorSound> pSound = pEditor->m_Map.m_vpSounds[pEditor->m_SelectedSound];
|
||||||
|
|
||||||
static CUI::SSelectionPopupContext s_SelectionPopupContext;
|
static CUI::SSelectionPopupContext s_SelectionPopupContext;
|
||||||
static CScrollRegion s_SelectionPopupScrollRegion;
|
static CScrollRegion s_SelectionPopupScrollRegion;
|
||||||
|
@ -1585,7 +1584,6 @@ CUI::EPopupMenuFunctionResult CEditor::PopupSound(void *pContext, CUIRect View,
|
||||||
View.HSplitTop(12.0f, &Slot, &View);
|
View.HSplitTop(12.0f, &Slot, &View);
|
||||||
if(pEditor->DoButton_MenuItem(&s_RemoveButton, "Remove", 0, &Slot, 0, "Removes the sound from the map"))
|
if(pEditor->DoButton_MenuItem(&s_RemoveButton, "Remove", 0, &Slot, 0, "Removes the sound from the map"))
|
||||||
{
|
{
|
||||||
delete pSound;
|
|
||||||
pEditor->m_Map.m_vpSounds.erase(pEditor->m_Map.m_vpSounds.begin() + pEditor->m_SelectedSound);
|
pEditor->m_Map.m_vpSounds.erase(pEditor->m_Map.m_vpSounds.begin() + pEditor->m_SelectedSound);
|
||||||
pEditor->m_Map.ModifySoundIndex(gs_ModifyIndexDeleted(pEditor->m_SelectedSound));
|
pEditor->m_Map.ModifySoundIndex(gs_ModifyIndexDeleted(pEditor->m_SelectedSound));
|
||||||
return CUI::POPUP_CLOSE_CURRENT;
|
return CUI::POPUP_CLOSE_CURRENT;
|
||||||
|
@ -2034,7 +2032,7 @@ static int s_AutoMapConfigCurrent = -100;
|
||||||
CUI::EPopupMenuFunctionResult CEditor::PopupSelectConfigAutoMap(void *pContext, CUIRect View, bool Active)
|
CUI::EPopupMenuFunctionResult CEditor::PopupSelectConfigAutoMap(void *pContext, CUIRect View, bool Active)
|
||||||
{
|
{
|
||||||
CEditor *pEditor = static_cast<CEditor *>(pContext);
|
CEditor *pEditor = static_cast<CEditor *>(pContext);
|
||||||
CLayerTiles *pLayer = static_cast<CLayerTiles *>(pEditor->GetSelectedLayer(0));
|
std::shared_ptr<CLayerTiles> pLayer = std::static_pointer_cast<CLayerTiles>(pEditor->GetSelectedLayer(0));
|
||||||
CAutoMapper *pAutoMapper = &pEditor->m_Map.m_vpImages[pLayer->m_Image]->m_AutoMapper;
|
CAutoMapper *pAutoMapper = &pEditor->m_Map.m_vpImages[pLayer->m_Image]->m_AutoMapper;
|
||||||
|
|
||||||
const float ButtonHeight = 12.0f;
|
const float ButtonHeight = 12.0f;
|
||||||
|
@ -2072,7 +2070,7 @@ void CEditor::PopupSelectConfigAutoMapInvoke(int Current, float x, float y)
|
||||||
static SPopupMenuId s_PopupSelectConfigAutoMapId;
|
static SPopupMenuId s_PopupSelectConfigAutoMapId;
|
||||||
s_AutoMapConfigSelected = -100;
|
s_AutoMapConfigSelected = -100;
|
||||||
s_AutoMapConfigCurrent = Current;
|
s_AutoMapConfigCurrent = Current;
|
||||||
CLayerTiles *pLayer = static_cast<CLayerTiles *>(GetSelectedLayer(0));
|
std::shared_ptr<CLayerTiles> pLayer = std::static_pointer_cast<CLayerTiles>(GetSelectedLayer(0));
|
||||||
const int ItemCount = minimum(m_Map.m_vpImages[pLayer->m_Image]->m_AutoMapper.ConfigNamesNum(), 10);
|
const int ItemCount = minimum(m_Map.m_vpImages[pLayer->m_Image]->m_AutoMapper.ConfigNamesNum(), 10);
|
||||||
// Width for buttons is 120, 15 is the scrollbar width, 2 is the margin between both.
|
// Width for buttons is 120, 15 is the scrollbar width, 2 is the margin between both.
|
||||||
UI()->DoPopupMenu(&s_PopupSelectConfigAutoMapId, x, y, 120.0f + 15.0f + 2.0f, 26.0f + 14.0f * ItemCount, this, PopupSelectConfigAutoMap);
|
UI()->DoPopupMenu(&s_PopupSelectConfigAutoMapId, x, y, 120.0f + 15.0f + 2.0f, 26.0f + 14.0f * ItemCount, this, PopupSelectConfigAutoMap);
|
||||||
|
|
Loading…
Reference in a new issue