From e61456f381626d1021044c4c53813410d034eb21 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sun, 1 May 2016 17:44:02 +0200 Subject: [PATCH 1/2] added auto game tile placer for hookthrough --- src/game/editor/layer_tiles.cpp | 8 ++++++-- src/game/editor/popups.cpp | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/game/editor/layer_tiles.cpp b/src/game/editor/layer_tiles.cpp index 7b933653b..98aef0617 100644 --- a/src/game/editor/layer_tiles.cpp +++ b/src/game/editor/layer_tiles.cpp @@ -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) { diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index 2a5632756..8e5b400fc 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -1303,7 +1303,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 +1322,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() From aeea3777a31cf042865c962d3a3a706ff9bba1b5 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sun, 1 May 2016 18:08:07 +0200 Subject: [PATCH 2/2] show button to mapper when placing unused tiles --- src/game/editor/editor.h | 3 +++ src/game/editor/layer_game.cpp | 5 +++++ src/game/editor/layer_tiles.cpp | 5 +++++ src/game/editor/popups.cpp | 6 +++++- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index cce9cd74f..73a35414d 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -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 diff --git a/src/game/editor/layer_game.cpp b/src/game/editor/layer_game.cpp index 1116c7e55..6bab7f82d 100644 --- a/src/game/editor/layer_game.cpp +++ b/src/game/editor/layer_game.cpp @@ -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; + } } } } diff --git a/src/game/editor/layer_tiles.cpp b/src/game/editor/layer_tiles.cpp index 98aef0617..8e09ef6f8 100644 --- a/src/game/editor/layer_tiles.cpp +++ b/src/game/editor/layer_tiles.cpp @@ -1318,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; + } } } diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index 8e5b400fc..2d77028cc 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -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))