2883: Ask for confirmation before placing border tiles r=def- a=Fireball-Teeworlds

Fixes #2823 

Co-authored-by: Fireball <fireball.teeworlds@gmail.com>
This commit is contained in:
bors[bot] 2020-09-20 09:36:55 +00:00 committed by GitHub
commit d4c14505bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View file

@ -1298,9 +1298,10 @@ void CEditor::DoToolbar(CUIRect ToolBar)
if(pT)
{
TB_Bottom.VSplitLeft(60.0f, &Button, &TB_Bottom);
if(DoButton_Ex(&s_BorderBut, "Border", 0, &Button, 0, "Adds border tiles", CUI::CORNER_ALL))
if(DoButton_Ex(&s_BorderBut, "Border", 0, &Button, 0, "Place tiles in a 2-tile wide border at the edges of the layer", CUI::CORNER_ALL))
{
DoMapBorder();
m_PopupEventType = POPEVENT_PLACE_BORDER_TILES;
m_PopupEventActivated = true;
}
TB_Bottom.VSplitLeft(5.0f, &Button, &TB_Bottom);
}
@ -6401,7 +6402,7 @@ void CEditor::Init()
ms_PickerColor = ColorHSVA(1.0f, 0.0f, 0.0f);
}
void CEditor::DoMapBorder()
void CEditor::PlaceBorderTiles()
{
CLayerTiles *pT = (CLayerTiles *)GetSelectedLayerType(0, LAYERTYPE_TILES);

View file

@ -812,6 +812,7 @@ public:
POPEVENT_PREVENTUNUSEDTILES,
POPEVENT_IMAGEDIV16,
POPEVENT_IMAGE_MAX,
POPEVENT_PLACE_BORDER_TILES
};
int m_PopupEventType;
@ -934,7 +935,7 @@ public:
float m_CommandBox;
char m_aSettingsCommand[256];
void DoMapBorder();
void PlaceBorderTiles();
int DoButton_Editor_Common(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
int DoButton_Editor(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
int DoButton_Env(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pToolTip, ColorRGBA Color);

View file

@ -1100,6 +1100,8 @@ int CEditor::PopupEvent(CEditor *pEditor, CUIRect View, void *pContext)
pEditor->UI()->DoLabel(&Label, "Image width/height", 20.0f, 0);
else if(pEditor->m_PopupEventType == POPEVENT_IMAGE_MAX)
pEditor->UI()->DoLabel(&Label, "Max images", 20.0f, 0);
else if(pEditor->m_PopupEventType == POPEVENT_PLACE_BORDER_TILES)
pEditor->UI()->DoLabel(&Label, "Place border tiles", 20.0f, 0);
View.HSplitBottom(10.0f, &View, 0);
View.HSplitBottom(20.0f, &View, &ButtonBar);
@ -1125,6 +1127,8 @@ int CEditor::PopupEvent(CEditor *pEditor, CUIRect View, void *pContext)
pEditor->UI()->DoLabel(&Label, "The width or height of this image is not divisible by 16. This is required for images used in tile layers for Teeworlds 0.7 compatibility.", 10.0f, -1, Label.w - 10.0f);
else if(pEditor->m_PopupEventType == POPEVENT_IMAGE_MAX)
pEditor->UI()->DoLabel(&Label, "The client only allows a maximum of 64 images.", 10.0f, -1, Label.w - 10.0f);
else if(pEditor->m_PopupEventType == POPEVENT_PLACE_BORDER_TILES)
pEditor->UI()->DoLabel(&Label, "This is going to overwrite any existing tiles around the edges of the layer.\nContinue?", 10.0f, -1, Label.w - 10.0f);
// button bar
ButtonBar.VSplitLeft(30.0f, 0, &ButtonBar);
@ -1145,6 +1149,8 @@ int CEditor::PopupEvent(CEditor *pEditor, CUIRect View, void *pContext)
}
else if(pEditor->m_PopupEventType == POPEVENT_SAVE)
pEditor->CallbackSaveMap(pEditor->m_aFileSaveName, IStorage::TYPE_SAVE, pEditor);
else if(pEditor->m_PopupEventType == POPEVENT_PLACE_BORDER_TILES)
pEditor->PlaceBorderTiles();
pEditor->m_PopupEventWasActivated = false;
return 1;
}