mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 05:58:19 +00:00
Differentiate between normal and checkpoint teles
This commit is contained in:
parent
7f5aaec50f
commit
84c2168650
|
@ -581,7 +581,7 @@ void CMapLayers::OnMapLoad()
|
|||
Flags = 0;
|
||||
if(CurOverlay == 1)
|
||||
{
|
||||
if(IsTeleTileNumberUsed(Index))
|
||||
if(IsTeleTileNumberUsedAny(Index))
|
||||
Index = ((CTeleTile *)pTiles)[y * pTMap->m_Width + x].m_Number;
|
||||
else
|
||||
Index = 0;
|
||||
|
|
|
@ -746,7 +746,7 @@ void CRenderTools::RenderTeleOverlay(CTeleTile *pTele, int w, int h, float Scale
|
|||
int c = mx + my * w;
|
||||
|
||||
unsigned char Index = pTele[c].m_Number;
|
||||
if(Index && IsTeleTileNumberUsed(pTele[c].m_Type))
|
||||
if(Index && IsTeleTileNumberUsedAny(pTele[c].m_Type))
|
||||
{
|
||||
str_from_int(Index, aBuf);
|
||||
// Auto-resize text to fit inside the tile
|
||||
|
|
|
@ -330,7 +330,7 @@ void CEditor::RenderBackground(CUIRect View, IGraphics::CTextureHandle Texture,
|
|||
Graphics()->QuadsEnd();
|
||||
}
|
||||
|
||||
SEditResult<int> CEditor::UiDoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, int Current, int Min, int Max, int Step, float Scale, const char *pToolTip, bool IsDegree, bool IsHex, int Corners, ColorRGBA *pColor, bool ShowValue)
|
||||
SEditResult<int> CEditor::UiDoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, int Current, int Min, int Max, int Step, float Scale, const char *pToolTip, bool IsDegree, bool IsHex, int Corners, const ColorRGBA *pColor, bool ShowValue)
|
||||
{
|
||||
// logic
|
||||
static float s_Value;
|
||||
|
@ -1326,7 +1326,7 @@ void CEditor::DoToolbarLayers(CUIRect ToolBar)
|
|||
{
|
||||
pButtonName = "Tele";
|
||||
pfnPopupFunc = PopupTele;
|
||||
Rows = 1;
|
||||
Rows = 2;
|
||||
}
|
||||
|
||||
if(pButtonName != nullptr)
|
||||
|
@ -8929,7 +8929,8 @@ void CEditor::AdjustBrushSpecialTiles(bool UseNextFree, int Adjust)
|
|||
// Only handle tele, switch and tune layers
|
||||
if(pLayerTiles->m_Tele)
|
||||
{
|
||||
int NextFreeNumber = FindNextFreeTileNumber(LAYERTYPE_TELE);
|
||||
int NextFreeTeleNumber = FindNextFreeTeleNumber();
|
||||
int NextFreeCPNumber = FindNextFreeTeleNumber(true);
|
||||
|
||||
std::shared_ptr<CLayerTele> pTeleLayer = std::static_pointer_cast<CLayerTele>(pLayer);
|
||||
for(int y = 0; y < pTeleLayer->m_Height; y++)
|
||||
|
@ -8941,7 +8942,12 @@ void CEditor::AdjustBrushSpecialTiles(bool UseNextFree, int Adjust)
|
|||
continue;
|
||||
|
||||
if(UseNextFree)
|
||||
pTeleLayer->m_pTeleTile[i].m_Number = NextFreeNumber;
|
||||
{
|
||||
if(IsTeleTileCheckpoint(pTeleLayer->m_pTiles[i].m_Index))
|
||||
pTeleLayer->m_pTeleTile[i].m_Number = NextFreeCPNumber;
|
||||
else
|
||||
pTeleLayer->m_pTeleTile[i].m_Number = NextFreeTeleNumber;
|
||||
}
|
||||
else
|
||||
AdjustNumber(pTeleLayer->m_pTeleTile[i].m_Number);
|
||||
}
|
||||
|
@ -8967,7 +8973,7 @@ void CEditor::AdjustBrushSpecialTiles(bool UseNextFree, int Adjust)
|
|||
}
|
||||
else if(pLayerTiles->m_Switch)
|
||||
{
|
||||
int NextFreeNumber = FindNextFreeTileNumber(LAYERTYPE_SWITCH);
|
||||
int NextFreeNumber = FindNextFreeSwitchNumber();
|
||||
|
||||
std::shared_ptr<CLayerSwitch> pSwitchLayer = std::static_pointer_cast<CLayerSwitch>(pLayer);
|
||||
for(int y = 0; y < pSwitchLayer->m_Height; y++)
|
||||
|
@ -8988,22 +8994,10 @@ void CEditor::AdjustBrushSpecialTiles(bool UseNextFree, int Adjust)
|
|||
}
|
||||
}
|
||||
|
||||
int CEditor::FindNextFreeTileNumber(int Type)
|
||||
int CEditor::FindNextFreeSwitchNumber()
|
||||
{
|
||||
int Number = -1;
|
||||
if(Type == LAYERTYPE_TELE)
|
||||
{
|
||||
for(int i = 1; i <= 255; i++)
|
||||
{
|
||||
if(!m_Map.m_pTeleLayer->ContainsElementWithId(i))
|
||||
{
|
||||
Number = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(Type == LAYERTYPE_SWITCH)
|
||||
{
|
||||
|
||||
for(int i = 1; i <= 255; i++)
|
||||
{
|
||||
if(!m_Map.m_pSwitchLayer->ContainsElementWithId(i))
|
||||
|
@ -9012,6 +9006,19 @@ int CEditor::FindNextFreeTileNumber(int Type)
|
|||
break;
|
||||
}
|
||||
}
|
||||
return Number;
|
||||
}
|
||||
|
||||
int CEditor::FindNextFreeTeleNumber(bool IsCheckpoint)
|
||||
{
|
||||
int Number = -1;
|
||||
for(int i = 1; i <= 255; i++)
|
||||
{
|
||||
if(!m_Map.m_pTeleLayer->ContainsElementWithId(i, IsCheckpoint))
|
||||
{
|
||||
Number = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return Number;
|
||||
}
|
||||
|
|
|
@ -300,6 +300,7 @@ class CEditor : public IEditor
|
|||
};
|
||||
|
||||
std::shared_ptr<CLayerGroup> m_apSavedBrushes[10];
|
||||
static const ColorRGBA ms_DefaultPropColor;
|
||||
|
||||
public:
|
||||
class IInput *Input() { return m_pInput; }
|
||||
|
@ -403,6 +404,7 @@ public:
|
|||
// DDRace
|
||||
|
||||
m_TeleNumber = 1;
|
||||
m_TeleCheckpointNumber = 1;
|
||||
m_SwitchNum = 1;
|
||||
m_TuningNum = 1;
|
||||
m_SwitchDelay = 0;
|
||||
|
@ -499,8 +501,8 @@ public:
|
|||
std::pair<int, int> EnvGetSelectedTimeAndValue() const;
|
||||
|
||||
template<typename E>
|
||||
SEditResult<E> DoPropertiesWithState(CUIRect *pToolbox, CProperty *pProps, int *pIDs, int *pNewVal, ColorRGBA Color = ColorRGBA(1, 1, 1, 0.5f));
|
||||
int DoProperties(CUIRect *pToolbox, CProperty *pProps, int *pIDs, int *pNewVal, ColorRGBA Color = ColorRGBA(1, 1, 1, 0.5f));
|
||||
SEditResult<E> DoPropertiesWithState(CUIRect *pToolbox, CProperty *pProps, int *pIDs, int *pNewVal, const std::vector<ColorRGBA> &vColors = {});
|
||||
int DoProperties(CUIRect *pToolbox, CProperty *pProps, int *pIDs, int *pNewVal, const std::vector<ColorRGBA> &vColors = {});
|
||||
|
||||
CUI::SColorPickerPopupContext m_ColorPickerPopupContext;
|
||||
const void *m_pColorPickerPopupActiveID = nullptr;
|
||||
|
@ -785,7 +787,7 @@ public:
|
|||
|
||||
void RenderBackground(CUIRect View, IGraphics::CTextureHandle Texture, float Size, float Brightness);
|
||||
|
||||
SEditResult<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);
|
||||
SEditResult<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, const ColorRGBA *pColor = nullptr, bool ShowValue = true);
|
||||
|
||||
static CUI::EPopupMenuFunctionResult PopupMenuFile(void *pContext, CUIRect View, bool Active);
|
||||
static CUI::EPopupMenuFunctionResult PopupMenuTools(void *pContext, CUIRect View, bool Active);
|
||||
|
@ -1051,6 +1053,7 @@ public:
|
|||
IGraphics::CTextureHandle GetTuneTexture();
|
||||
|
||||
unsigned char m_TeleNumber;
|
||||
unsigned char m_TeleCheckpointNumber;
|
||||
|
||||
unsigned char m_TuningNum;
|
||||
|
||||
|
@ -1062,7 +1065,8 @@ public:
|
|||
unsigned char m_SwitchDelay;
|
||||
|
||||
void AdjustBrushSpecialTiles(bool UseNextFree, int Adjust = 0);
|
||||
int FindNextFreeTileNumber(int Type);
|
||||
int FindNextFreeSwitchNumber();
|
||||
int FindNextFreeTeleNumber(bool IsCheckpoint = false);
|
||||
|
||||
public:
|
||||
// Undo/Redo
|
||||
|
|
|
@ -3,20 +3,24 @@
|
|||
#include <game/editor/mapitems/image.h>
|
||||
#include <game/editor/mapitems/sound.h>
|
||||
|
||||
int CEditor::DoProperties(CUIRect *pToolbox, CProperty *pProps, int *pIDs, int *pNewVal, ColorRGBA Color)
|
||||
const ColorRGBA CEditor::ms_DefaultPropColor = ColorRGBA(1, 1, 1, 0.5f);
|
||||
|
||||
int CEditor::DoProperties(CUIRect *pToolbox, CProperty *pProps, int *pIDs, int *pNewVal, const std::vector<ColorRGBA> &vColors)
|
||||
{
|
||||
auto Res = DoPropertiesWithState<int>(pToolbox, pProps, pIDs, pNewVal, Color);
|
||||
auto Res = DoPropertiesWithState<int>(pToolbox, pProps, pIDs, pNewVal, vColors);
|
||||
return Res.m_Value;
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
SEditResult<E> CEditor::DoPropertiesWithState(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int *pNewVal, ColorRGBA Color)
|
||||
SEditResult<E> CEditor::DoPropertiesWithState(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int *pNewVal, const std::vector<ColorRGBA> &vColors)
|
||||
{
|
||||
int Change = -1;
|
||||
EEditState State = EEditState::EDITING;
|
||||
|
||||
for(int i = 0; pProps[i].m_pName; i++)
|
||||
{
|
||||
const ColorRGBA *pColor = i >= (int)vColors.size() ? &ms_DefaultPropColor : &vColors[i];
|
||||
|
||||
CUIRect Slot;
|
||||
pToolBox->HSplitTop(13.0f, &Slot, pToolBox);
|
||||
CUIRect Label, Shifter;
|
||||
|
@ -32,7 +36,7 @@ SEditResult<E> CEditor::DoPropertiesWithState(CUIRect *pToolBox, CProperty *pPro
|
|||
Shifter.VSplitRight(10.0f, &Shifter, &Inc);
|
||||
Shifter.VSplitLeft(10.0f, &Dec, &Shifter);
|
||||
str_from_int(pProps[i].m_Value, aBuf);
|
||||
auto NewValueRes = UiDoValueSelector((char *)&pIDs[i], &Shifter, "", pProps[i].m_Value, pProps[i].m_Min, pProps[i].m_Max, 1, 1.0f, "Use left mouse button to drag and change the value. Hold shift to be more precise. Rightclick to edit as text.", false, false, 0, &Color);
|
||||
auto NewValueRes = UiDoValueSelector((char *)&pIDs[i], &Shifter, "", pProps[i].m_Value, pProps[i].m_Min, pProps[i].m_Max, 1, 1.0f, "Use left mouse button to drag and change the value. Hold shift to be more precise. Rightclick to edit as text.", false, false, 0, pColor);
|
||||
int NewValue = NewValueRes.m_Value;
|
||||
if(NewValue != pProps[i].m_Value || NewValueRes.m_State != EEditState::EDITING)
|
||||
{
|
||||
|
@ -269,14 +273,14 @@ SEditResult<E> CEditor::DoPropertiesWithState(CUIRect *pToolBox, CProperty *pPro
|
|||
return SEditResult<E>{State, static_cast<E>(Change)};
|
||||
}
|
||||
|
||||
template SEditResult<ECircleShapeProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, ColorRGBA);
|
||||
template SEditResult<ERectangleShapeProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, ColorRGBA);
|
||||
template SEditResult<EGroupProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, ColorRGBA);
|
||||
template SEditResult<ELayerProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, ColorRGBA);
|
||||
template SEditResult<ELayerQuadsProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, ColorRGBA);
|
||||
template SEditResult<ETilesProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, ColorRGBA);
|
||||
template SEditResult<ETilesCommonProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, ColorRGBA);
|
||||
template SEditResult<ELayerSoundsProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, ColorRGBA);
|
||||
template SEditResult<EQuadProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, ColorRGBA);
|
||||
template SEditResult<EQuadPointProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, ColorRGBA);
|
||||
template SEditResult<ESoundProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, ColorRGBA);
|
||||
template SEditResult<ECircleShapeProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, const std::vector<ColorRGBA> &);
|
||||
template SEditResult<ERectangleShapeProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, const std::vector<ColorRGBA> &);
|
||||
template SEditResult<EGroupProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, const std::vector<ColorRGBA> &);
|
||||
template SEditResult<ELayerProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, const std::vector<ColorRGBA> &);
|
||||
template SEditResult<ELayerQuadsProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, const std::vector<ColorRGBA> &);
|
||||
template SEditResult<ETilesProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, const std::vector<ColorRGBA> &);
|
||||
template SEditResult<ETilesCommonProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, const std::vector<ColorRGBA> &);
|
||||
template SEditResult<ELayerSoundsProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, const std::vector<ColorRGBA> &);
|
||||
template SEditResult<EQuadProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, const std::vector<ColorRGBA> &);
|
||||
template SEditResult<EQuadPointProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, const std::vector<ColorRGBA> &);
|
||||
template SEditResult<ESoundProp> CEditor::DoPropertiesWithState(CUIRect *, CProperty *, int *, int *, const std::vector<ColorRGBA> &);
|
||||
|
|
|
@ -98,23 +98,28 @@ void CLayerTele::BrushDraw(std::shared_ptr<CLayer> pBrush, float wx, float wy)
|
|||
|
||||
if((m_pEditor->m_AllowPlaceUnusedTiles || IsValidTeleTile(pTeleLayer->m_pTiles[y * pTeleLayer->m_Width + x].m_Index)) && pTeleLayer->m_pTiles[y * pTeleLayer->m_Width + x].m_Index != TILE_AIR)
|
||||
{
|
||||
if(!IsTeleTileNumberUsed(pTeleLayer->m_pTiles[y * pTeleLayer->m_Width + x].m_Index))
|
||||
bool IsCheckpoint = IsTeleTileCheckpoint(pTeleLayer->m_pTiles[y * pTeleLayer->m_Width + x].m_Index);
|
||||
if(!IsCheckpoint && !IsTeleTileNumberUsed(pTeleLayer->m_pTiles[y * pTeleLayer->m_Width + x].m_Index, false))
|
||||
{
|
||||
// Tele tile number is unused. Set a known value which is not 0,
|
||||
// as tiles with number 0 would be ignored by previous versions.
|
||||
m_pTeleTile[Index].m_Number = 255;
|
||||
}
|
||||
else if(m_pEditor->m_TeleNumber != pTeleLayer->m_TeleNum)
|
||||
else if(!IsCheckpoint && m_pEditor->m_TeleNumber != pTeleLayer->m_TeleNum)
|
||||
{
|
||||
m_pTeleTile[Index].m_Number = m_pEditor->m_TeleNumber;
|
||||
}
|
||||
else if(IsCheckpoint && m_pEditor->m_TeleCheckpointNumber != pTeleLayer->m_TeleCheckpointNum)
|
||||
{
|
||||
m_pTeleTile[Index].m_Number = m_pEditor->m_TeleCheckpointNumber;
|
||||
}
|
||||
else if(pTeleLayer->m_pTeleTile[y * pTeleLayer->m_Width + x].m_Number)
|
||||
{
|
||||
m_pTeleTile[Index].m_Number = pTeleLayer->m_pTeleTile[y * pTeleLayer->m_Width + x].m_Number;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!m_pEditor->m_TeleNumber)
|
||||
if((!IsCheckpoint && !m_pEditor->m_TeleNumber) || (IsCheckpoint && !m_pEditor->m_TeleCheckpointNumber))
|
||||
{
|
||||
m_pTeleTile[Index].m_Number = 0;
|
||||
m_pTeleTile[Index].m_Type = 0;
|
||||
|
@ -130,7 +135,7 @@ void CLayerTele::BrushDraw(std::shared_ptr<CLayer> pBrush, float wx, float wy)
|
|||
}
|
||||
else
|
||||
{
|
||||
m_pTeleTile[Index].m_Number = m_pEditor->m_TeleNumber;
|
||||
m_pTeleTile[Index].m_Number = IsCheckpoint ? m_pEditor->m_TeleCheckpointNumber : m_pEditor->m_TeleNumber;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,15 +272,18 @@ void CLayerTele::FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CUIRe
|
|||
if(pLt->m_Tele && m_pTiles[TgtIndex].m_Index > 0)
|
||||
{
|
||||
m_pTeleTile[TgtIndex].m_Type = m_pTiles[TgtIndex].m_Index;
|
||||
bool IsCheckpoint = IsTeleTileCheckpoint(m_pTiles[TgtIndex].m_Index);
|
||||
|
||||
if(!IsTeleTileNumberUsed(m_pTeleTile[TgtIndex].m_Type))
|
||||
if(!IsCheckpoint && !IsTeleTileNumberUsed(m_pTeleTile[TgtIndex].m_Type, false))
|
||||
{
|
||||
// Tele tile number is unused. Set a known value which is not 0,
|
||||
// as tiles with number 0 would be ignored by previous versions.
|
||||
m_pTeleTile[TgtIndex].m_Number = 255;
|
||||
}
|
||||
else if((pLt->m_pTeleTile[SrcIndex].m_Number == 0 && m_pEditor->m_TeleNumber) || m_pEditor->m_TeleNumber != pLt->m_TeleNum)
|
||||
else if(!IsCheckpoint && ((pLt->m_pTeleTile[SrcIndex].m_Number == 0 && m_pEditor->m_TeleNumber) || m_pEditor->m_TeleNumber != pLt->m_TeleNum))
|
||||
m_pTeleTile[TgtIndex].m_Number = m_pEditor->m_TeleNumber;
|
||||
else if(IsCheckpoint && ((pLt->m_pTeleTile[SrcIndex].m_Number == 0 && m_pEditor->m_TeleCheckpointNumber) || m_pEditor->m_TeleCheckpointNumber != pLt->m_TeleCheckpointNum))
|
||||
m_pTeleTile[TgtIndex].m_Number = m_pEditor->m_TeleCheckpointNumber;
|
||||
else
|
||||
m_pTeleTile[TgtIndex].m_Number = pLt->m_pTeleTile[SrcIndex].m_Number;
|
||||
}
|
||||
|
@ -292,13 +300,13 @@ void CLayerTele::FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CUIRe
|
|||
FlagModified(sx, sy, w, h);
|
||||
}
|
||||
|
||||
bool CLayerTele::ContainsElementWithId(int Id)
|
||||
bool CLayerTele::ContainsElementWithId(int Id, bool Checkpoint)
|
||||
{
|
||||
for(int y = 0; y < m_Height; ++y)
|
||||
{
|
||||
for(int x = 0; x < m_Width; ++x)
|
||||
{
|
||||
if(IsTeleTileNumberUsed(m_pTeleTile[y * m_Width + x].m_Type) && m_pTeleTile[y * m_Width + x].m_Number == Id)
|
||||
if(IsTeleTileNumberUsed(m_pTeleTile[y * m_Width + x].m_Type, Checkpoint) && m_pTeleTile[y * m_Width + x].m_Number == Id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ public:
|
|||
|
||||
CTeleTile *m_pTeleTile;
|
||||
unsigned char m_TeleNum;
|
||||
unsigned char m_TeleCheckpointNum;
|
||||
|
||||
void Resize(int NewW, int NewH) override;
|
||||
void Shift(int Direction) override;
|
||||
|
@ -32,7 +33,7 @@ public:
|
|||
void BrushFlipY() override;
|
||||
void BrushRotate(float Amount) override;
|
||||
void FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CUIRect Rect) override;
|
||||
virtual bool ContainsElementWithId(int Id);
|
||||
virtual bool ContainsElementWithId(int Id, bool Checkpoint);
|
||||
|
||||
EditorTileStateChangeHistory<STeleTileStateChange> m_History;
|
||||
inline void ClearHistory() override
|
||||
|
|
|
@ -308,12 +308,18 @@ int CLayerTiles::BrushGrab(std::shared_ptr<CLayerGroup> pBrush, CUIRect Rect)
|
|||
for(int x = 0; x < r.w; 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))
|
||||
{
|
||||
if(IsTeleTileNumberUsed(pGrabbed->m_pTeleTile[y * pGrabbed->m_Width + x].m_Type, false))
|
||||
m_pEditor->m_TeleNumber = pGrabbed->m_pTeleTile[y * pGrabbed->m_Width + x].m_Number;
|
||||
else if(IsTeleTileNumberUsed(pGrabbed->m_pTeleTile[y * pGrabbed->m_Width + x].m_Type, true))
|
||||
m_pEditor->m_TeleCheckpointNumber = pGrabbed->m_pTeleTile[y * pGrabbed->m_Width + x].m_Number;
|
||||
}
|
||||
}
|
||||
|
||||
pGrabbed->m_TeleNum = m_pEditor->m_TeleNumber;
|
||||
pGrabbed->m_TeleCheckpointNum = m_pEditor->m_TeleCheckpointNumber;
|
||||
|
||||
str_copy(pGrabbed->m_aFileName, m_pEditor->m_aFileName);
|
||||
}
|
||||
else if(this->m_Speedup)
|
||||
|
|
|
@ -2415,58 +2415,82 @@ CUI::EPopupMenuFunctionResult CEditor::PopupTele(void *pContext, CUIRect View, b
|
|||
{
|
||||
CEditor *pEditor = static_cast<CEditor *>(pContext);
|
||||
|
||||
static int s_PreviousNumber = -1;
|
||||
static int s_PreviousTeleNumber;
|
||||
static int s_PreviousCheckpointNumber;
|
||||
|
||||
CUIRect NumberPicker;
|
||||
CUIRect FindEmptySlot;
|
||||
CUIRect FindFreeTeleSlot, FindFreeCheckpointSlot;
|
||||
|
||||
View.VSplitRight(15.f, &NumberPicker, &FindEmptySlot);
|
||||
NumberPicker.VSplitRight(2.f, &NumberPicker, nullptr);
|
||||
FindEmptySlot.HSplitTop(13.0f, &FindEmptySlot, nullptr);
|
||||
FindEmptySlot.HMargin(1.0f, &FindEmptySlot);
|
||||
|
||||
// find empty number button
|
||||
{
|
||||
static int s_EmptySlotPid = 0;
|
||||
if(pEditor->DoButton_Editor(&s_EmptySlotPid, "F", 0, &FindEmptySlot, 0, "[ctrl+f] Find empty slot") || (Active && pEditor->Input()->ModifierIsPressed() && pEditor->Input()->KeyPress(KEY_F)))
|
||||
{
|
||||
int Number = pEditor->FindNextFreeTileNumber(LAYERTYPE_TELE);
|
||||
FindEmptySlot.HSplitTop(13.0f, &FindFreeTeleSlot, &FindEmptySlot);
|
||||
FindEmptySlot.HSplitTop(13.0f, &FindFreeCheckpointSlot, &FindEmptySlot);
|
||||
|
||||
if(Number != -1)
|
||||
pEditor->m_TeleNumber = Number;
|
||||
FindFreeTeleSlot.HMargin(1.0f, &FindFreeTeleSlot);
|
||||
FindFreeCheckpointSlot.HMargin(1.0f, &FindFreeCheckpointSlot);
|
||||
|
||||
// find next free numbers buttons
|
||||
{
|
||||
// Pressing ctrl+f will find next free numbers for both tele and checkpoints
|
||||
|
||||
static int s_NextFreeTelePid = 0;
|
||||
if(pEditor->DoButton_Editor(&s_NextFreeTelePid, "F", 0, &FindFreeTeleSlot, 0, "[ctrl+f] Find next free tele number") || (Active && pEditor->Input()->ModifierIsPressed() && pEditor->Input()->KeyPress(KEY_F)))
|
||||
{
|
||||
int TeleNumber = pEditor->FindNextFreeTeleNumber();
|
||||
|
||||
if(TeleNumber != -1)
|
||||
pEditor->m_TeleNumber = TeleNumber;
|
||||
}
|
||||
|
||||
static int s_NextFreeCheckpointPid = 0;
|
||||
if(pEditor->DoButton_Editor(&s_NextFreeCheckpointPid, "F", 0, &FindFreeCheckpointSlot, 0, "[ctrl+f] Find next free checkpoint number") || (Active && pEditor->Input()->ModifierIsPressed() && pEditor->Input()->KeyPress(KEY_F)))
|
||||
{
|
||||
int CPNumber = pEditor->FindNextFreeTeleNumber(true);
|
||||
|
||||
if(CPNumber != -1)
|
||||
pEditor->m_TeleCheckpointNumber = CPNumber;
|
||||
}
|
||||
}
|
||||
|
||||
// number picker
|
||||
{
|
||||
static ColorRGBA s_Color = ColorRGBA(0.5f, 1, 0.5f, 0.5f);
|
||||
static std::vector<ColorRGBA> s_vColors = {
|
||||
ColorRGBA(0.5f, 1, 0.5f, 0.5f),
|
||||
ColorRGBA(0.5f, 1, 0.5f, 0.5f),
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_TELE = 0,
|
||||
PROP_TELE_CP = 1,
|
||||
NUM_PROPS,
|
||||
};
|
||||
CProperty aProps[] = {
|
||||
{"Number", pEditor->m_TeleNumber, PROPTYPE_INT_STEP, 1, 255},
|
||||
{"Checkpoint", pEditor->m_TeleCheckpointNumber, PROPTYPE_INT_STEP, 1, 255},
|
||||
{nullptr},
|
||||
};
|
||||
|
||||
static int s_aIds[NUM_PROPS] = {0};
|
||||
|
||||
static int NewVal = 0;
|
||||
int Prop = pEditor->DoProperties(&NumberPicker, aProps, s_aIds, &NewVal, s_Color);
|
||||
int Prop = pEditor->DoProperties(&NumberPicker, aProps, s_aIds, &NewVal, s_vColors);
|
||||
if(Prop == PROP_TELE)
|
||||
{
|
||||
pEditor->m_TeleNumber = (NewVal - 1 + 255) % 255 + 1;
|
||||
else if(Prop == PROP_TELE_CP)
|
||||
pEditor->m_TeleCheckpointNumber = (NewVal - 1 + 255) % 255 + 1;
|
||||
|
||||
if(s_PreviousTeleNumber == 1 || s_PreviousTeleNumber != pEditor->m_TeleNumber)
|
||||
s_vColors[PROP_TELE] = pEditor->m_Map.m_pTeleLayer->ContainsElementWithId(pEditor->m_TeleNumber, false) ? ColorRGBA(1, 0.5f, 0.5f, 0.5f) : ColorRGBA(0.5f, 1, 0.5f, 0.5f);
|
||||
|
||||
if(s_PreviousCheckpointNumber == 1 || s_PreviousCheckpointNumber != pEditor->m_TeleCheckpointNumber)
|
||||
s_vColors[PROP_TELE_CP] = pEditor->m_Map.m_pTeleLayer->ContainsElementWithId(pEditor->m_TeleCheckpointNumber, true) ? ColorRGBA(1, 0.5f, 0.5f, 0.5f) : ColorRGBA(0.5f, 1, 0.5f, 0.5f);
|
||||
}
|
||||
|
||||
if(s_PreviousNumber == 1 || s_PreviousNumber != pEditor->m_TeleNumber)
|
||||
{
|
||||
s_Color = pEditor->m_Map.m_pTeleLayer->ContainsElementWithId(pEditor->m_TeleNumber) ? ColorRGBA(1, 0.5f, 0.5f, 0.5f) : ColorRGBA(0.5f, 1, 0.5f, 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
s_PreviousNumber = pEditor->m_TeleNumber;
|
||||
s_PreviousTeleNumber = pEditor->m_TeleNumber;
|
||||
s_PreviousCheckpointNumber = pEditor->m_TeleCheckpointNumber;
|
||||
|
||||
return CUI::POPUP_KEEP_OPEN;
|
||||
}
|
||||
|
@ -2526,7 +2550,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupSwitch(void *pContext, CUIRect View,
|
|||
static int s_EmptySlotPid = 0;
|
||||
if(pEditor->DoButton_Editor(&s_EmptySlotPid, "F", 0, &FindEmptySlot, 0, "[ctrl+f] Find empty slot") || (Active && pEditor->Input()->ModifierIsPressed() && pEditor->Input()->KeyPress(KEY_F)))
|
||||
{
|
||||
int Number = pEditor->FindNextFreeTileNumber(LAYERTYPE_SWITCH);
|
||||
int Number = pEditor->FindNextFreeSwitchNumber();
|
||||
|
||||
if(Number != -1)
|
||||
pEditor->m_SwitchNum = Number;
|
||||
|
@ -2536,7 +2560,9 @@ CUI::EPopupMenuFunctionResult CEditor::PopupSwitch(void *pContext, CUIRect View,
|
|||
// number picker
|
||||
static int s_PreviousNumber = -1;
|
||||
{
|
||||
static ColorRGBA s_Color = ColorRGBA(1, 1, 1, 0.5f);
|
||||
static std::vector<ColorRGBA> s_vColors = {
|
||||
ColorRGBA(1, 1, 1, 0.5f),
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -2553,7 +2579,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupSwitch(void *pContext, CUIRect View,
|
|||
|
||||
static int s_aIds[NUM_PROPS] = {0};
|
||||
int NewVal = 0;
|
||||
int Prop = pEditor->DoProperties(&NumberPicker, aProps, s_aIds, &NewVal, s_Color);
|
||||
int Prop = pEditor->DoProperties(&NumberPicker, aProps, s_aIds, &NewVal, s_vColors);
|
||||
|
||||
if(Prop == PROP_SWITCH_NUMBER)
|
||||
{
|
||||
|
@ -2565,9 +2591,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupSwitch(void *pContext, CUIRect View,
|
|||
}
|
||||
|
||||
if(s_PreviousNumber == 1 || s_PreviousNumber != pEditor->m_SwitchNum)
|
||||
{
|
||||
s_Color = pEditor->m_Map.m_pSwitchLayer->ContainsElementWithId(pEditor->m_SwitchNum) ? ColorRGBA(1, 0.5f, 0.5f, 0.5f) : ColorRGBA(0.5f, 1, 0.5f, 0.5f);
|
||||
}
|
||||
s_vColors[PROP_SWITCH_NUMBER] = pEditor->m_Map.m_pSwitchLayer->ContainsElementWithId(pEditor->m_SwitchNum) ? ColorRGBA(1, 0.5f, 0.5f, 0.5f) : ColorRGBA(0.5f, 1, 0.5f, 0.5f);
|
||||
}
|
||||
|
||||
s_PreviousNumber = pEditor->m_SwitchNum;
|
||||
|
@ -2622,7 +2646,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGoto(void *pContext, CUIRect View, b
|
|||
|
||||
static int s_aIds[NUM_PROPS] = {0};
|
||||
int NewVal = 0;
|
||||
int Prop = pEditor->DoProperties(&View, aProps, s_aIds, &NewVal, ColorRGBA(1, 1, 1, 0.5f));
|
||||
int Prop = pEditor->DoProperties(&View, aProps, s_aIds, &NewVal);
|
||||
|
||||
if(Prop == PROP_COORD_X)
|
||||
{
|
||||
|
|
|
@ -57,7 +57,20 @@ bool IsValidTeleTile(int Index)
|
|||
Index == TILE_TELECHECKINEVIL);
|
||||
}
|
||||
|
||||
bool IsTeleTileNumberUsed(int Index)
|
||||
bool IsTeleTileCheckpoint(int Index)
|
||||
{
|
||||
return Index == TILE_TELECHECK || Index == TILE_TELECHECKOUT;
|
||||
}
|
||||
|
||||
bool IsTeleTileNumberUsed(int Index, bool Checkpoint)
|
||||
{
|
||||
if(Checkpoint)
|
||||
return IsTeleTileCheckpoint(Index);
|
||||
return !IsTeleTileCheckpoint(Index) && Index != TILE_TELECHECKIN &&
|
||||
Index != TILE_TELECHECKINEVIL;
|
||||
}
|
||||
|
||||
bool IsTeleTileNumberUsedAny(int Index)
|
||||
{
|
||||
return Index != TILE_TELECHECKIN &&
|
||||
Index != TILE_TELECHECKINEVIL;
|
||||
|
|
|
@ -571,7 +571,9 @@ public:
|
|||
bool IsValidGameTile(int Index);
|
||||
bool IsValidFrontTile(int Index);
|
||||
bool IsValidTeleTile(int Index);
|
||||
bool IsTeleTileNumberUsed(int Index); // Assumes that Index is a valid tele tile index
|
||||
bool IsTeleTileCheckpoint(int Index); // Assumes that Index is a valid tele tile index
|
||||
bool IsTeleTileNumberUsed(int Index, bool Checkpoint); // Assumes that Index is a valid tele tile index
|
||||
bool IsTeleTileNumberUsedAny(int Index); // Does not check for checkpoint only
|
||||
bool IsValidSpeedupTile(int Index);
|
||||
bool IsValidSwitchTile(int Index);
|
||||
bool IsSwitchTileFlagsUsed(int Index); // Assumes that Index is a valid switch tile index
|
||||
|
|
Loading…
Reference in a new issue