Merge pull request #449 from timakro/master

added auto game tile placer for hookthrough & show button to mapper when placing unused tiles
This commit is contained in:
Dennis Felsing 2016-05-01 18:18:30 +02:00
commit 07aa6c6d9b
4 changed files with 26 additions and 5 deletions

View file

@ -721,6 +721,7 @@ public:
m_SpeedupMaxSpeed = 0;
m_SpeedupAngle = 0;
m_LargeLayerWasWarned = false;
m_PreventUnusedTilesWasWarned = false;
m_AllowPlaceUnusedTiles = false;
}
@ -782,12 +783,14 @@ public:
POPEVENT_NEW,
POPEVENT_SAVE,
POPEVENT_LARGELAYER,
POPEVENT_PREVENTUNUSEDTILES
};
int m_PopupEventType;
int m_PopupEventActivated;
int m_PopupEventWasActivated;
bool m_LargeLayerWasWarned;
bool m_PreventUnusedTilesWasWarned;
bool m_AllowPlaceUnusedTiles;
enum

View file

@ -46,6 +46,11 @@ void CLayerGame::SetTile(int x, int y, CTile tile)
} else {
CTile air = {TILE_AIR};
CLayerTiles::SetTile(x, y, air);
if(!m_pEditor->m_PreventUnusedTilesWasWarned) {
m_pEditor->m_PopupEventType = m_pEditor->POPEVENT_PREVENTUNUSEDTILES;
m_pEditor->m_PopupEventActivated = true;
m_pEditor->m_PreventUnusedTilesWasWarned = true;
}
}
}
}

View file

@ -619,6 +619,8 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
case 9:
Result = TILE_TELECHECKINEVIL;
break;
case 10:
Result = TILE_THROUGH_CUT;
default:
break;
}
@ -632,8 +634,10 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
int h = min(gl->m_Height, m_Height);
for(int y = 0; y < h; y++)
for(int x = 0; x < w; x++)
if(m_pTiles[y*m_Width+x].m_Index)
gl->m_pTiles[y*gl->m_Width+x].m_Index = TILE_AIR+Result;
if(GetTile(x, y).m_Index) {
CTile result_tile = {(unsigned char)Result};
gl->SetTile(x, y, result_tile);
}
}
else if (m_pEditor->m_Map.m_pTeleLayer)
{
@ -1314,6 +1318,11 @@ void CLayerFront::SetTile(int x, int y, CTile tile)
} else {
CTile air = {TILE_AIR};
CLayerTiles::SetTile(x, y, air);
if(!m_pEditor->m_PreventUnusedTilesWasWarned) {
m_pEditor->m_PopupEventType = m_pEditor->POPEVENT_PREVENTUNUSEDTILES;
m_pEditor->m_PopupEventActivated = true;
m_pEditor->m_PreventUnusedTilesWasWarned = true;
}
}
}

View file

@ -1040,6 +1040,8 @@ int CEditor::PopupEvent(CEditor *pEditor, CUIRect View)
pEditor->UI()->DoLabel(&Label, "Save map", 20.0f, 0);
else if(pEditor->m_PopupEventType == POPEVENT_LARGELAYER)
pEditor->UI()->DoLabel(&Label, "Large layer", 20.0f, 0);
else if(pEditor->m_PopupEventType == POPEVENT_PREVENTUNUSEDTILES)
pEditor->UI()->DoLabel(&Label, "Unused tiles disabled", 20.0f, 0);
View.HSplitBottom(10.0f, &View, 0);
View.HSplitBottom(20.0f, &View, &ButtonBar);
@ -1058,6 +1060,8 @@ int CEditor::PopupEvent(CEditor *pEditor, CUIRect View)
pEditor->UI()->DoLabel(&Label, "The file already exists.\nDo you want to overwrite the map?", 10.0f, -1);
else if(pEditor->m_PopupEventType == POPEVENT_LARGELAYER)
pEditor->UI()->DoLabel(&Label, "You are trying to set the height or width of a layer to more than 1000 tiles. This is actually possible, but only rarely necessary. It may cause the editor to work slower, larger file size as well as higher memory usage for client and server.", 10.0f, -1, Label.w-10.0f);
else if(pEditor->m_PopupEventType == POPEVENT_PREVENTUNUSEDTILES)
pEditor->UI()->DoLabel(&Label, "Unused tiles can't be placed by default because they could get a use later and then destroy your map. If you are mapping for a different gametype you can activate the 'Unused' switch to be able to place every tile.", 10.0f, -1, Label.w-10.0f);
// button bar
ButtonBar.VSplitLeft(30.0f, 0, &ButtonBar);
@ -1081,7 +1085,7 @@ int CEditor::PopupEvent(CEditor *pEditor, CUIRect View)
}
ButtonBar.VSplitRight(30.0f, &ButtonBar, 0);
ButtonBar.VSplitRight(110.0f, &ButtonBar, &Label);
if(pEditor->m_PopupEventType != POPEVENT_LARGELAYER)
if(pEditor->m_PopupEventType != POPEVENT_LARGELAYER && pEditor->m_PopupEventType != POPEVENT_PREVENTUNUSEDTILES)
{
static int s_AbortButton = 0;
if(pEditor->DoButton_Editor(&s_AbortButton, "Abort", 0, &Label, 0, 0))
@ -1303,7 +1307,7 @@ static int s_GametileOpSelected = -1;
int CEditor::PopupSelectGametileOp(CEditor *pEditor, CUIRect View)
{
static const char *s_pButtonNames[] = { "Clear", "Collision", "Death", "Unhookable", "Freeze", "Unfreeze", "Deep Freeze", "Deep Unfreeze", "Check-Tele From", "Evil Check-Tele From" };
static const char *s_pButtonNames[] = { "Clear", "Collision", "Death", "Unhookable", "Freeze", "Unfreeze", "Deep Freeze", "Deep Unfreeze", "Check-Tele From", "Evil Check-Tele From", "Hookthrough" };
static unsigned s_NumButtons = sizeof(s_pButtonNames) / sizeof(char*);
CUIRect Button;
@ -1322,7 +1326,7 @@ void CEditor::PopupSelectGametileOpInvoke(float x, float y)
{
static int s_SelectGametileOpPopupId = 0;
s_GametileOpSelected = -1;
UiInvokePopupMenu(&s_SelectGametileOpPopupId, 0, x, y, 120.0f, 150.0f, PopupSelectGametileOp);
UiInvokePopupMenu(&s_SelectGametileOpPopupId, 0, x, y, 120.0f, 165.0f, PopupSelectGametileOp);
}
int CEditor::PopupSelectGameTileOpResult()