diff options
| author | oy <Tom_Adams@web.de> | 2011-07-09 01:09:06 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-07-09 01:09:06 +0200 |
| commit | 7bc07b613f9fed3dcef26f63332ea68db1e1f381 (patch) | |
| tree | d357af2b1d1db1dd6d5d62874326c739890402a4 /src/game/editor/popups.cpp | |
| parent | f44094490549a46781a7d85a137ddf748021d00f (diff) | |
| download | zcatch-7bc07b613f9fed3dcef26f63332ea68db1e1f381.tar.gz zcatch-7bc07b613f9fed3dcef26f63332ea68db1e1f381.zip | |
added auto mapping feature by LordSkelethom
Diffstat (limited to 'src/game/editor/popups.cpp')
| -rw-r--r-- | src/game/editor/popups.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index 3ae29725..0a691fdf 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -1,10 +1,14 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ + +#include <base/tl/array.h> + #include <engine/console.h> #include <engine/graphics.h> #include <engine/input.h> #include <engine/keys.h> #include <engine/storage.h> + #include "editor.h" @@ -737,3 +741,43 @@ int CEditor::PopupSelectGameTileOpResult() s_GametileOpSelected = -1; return Result; } + +static int s_AutoMapConfigSelected = -1; + +int CEditor::PopupSelectConfigAutoMap(CEditor *pEditor, CUIRect View) +{ + CLayerTiles *pLayer = static_cast<CLayerTiles*>(pEditor->GetSelectedLayer(0)); + CUIRect Button; + static int s_AutoMapperConfigButtons[256]; + CAutoMapper *pAutoMapper = &pEditor->m_Map.m_lImages[pLayer->m_Image]->m_AutoMapper; + + for(int i = 0; i < pAutoMapper->ConfigNamesNum(); ++i) + { + View.HSplitTop(2.0f, 0, &View); + View.HSplitTop(12.0f, &Button, &View); + if(pEditor->DoButton_Editor(&s_AutoMapperConfigButtons[i], pAutoMapper->GetConfigName(i), 0, &Button, 0, 0)) + s_AutoMapConfigSelected = i; + } + + return 0; +} + +void CEditor::PopupSelectConfigAutoMapInvoke(float x, float y) +{ + static int s_AutoMapConfigSelectID = 0; + s_AutoMapConfigSelected = -1; + CLayerTiles *pLayer = static_cast<CLayerTiles*>(GetSelectedLayer(0)); + if(pLayer && pLayer->m_Image >= 0 && pLayer->m_Image < m_Map.m_lImages.size() && + m_Map.m_lImages[pLayer->m_Image]->m_AutoMapper.ConfigNamesNum()) + UiInvokePopupMenu(&s_AutoMapConfigSelectID, 0, x, y, 120.0f, 12.0f+14.0f*m_Map.m_lImages[pLayer->m_Image]->m_AutoMapper.ConfigNamesNum(), PopupSelectConfigAutoMap); +} + +int CEditor::PopupSelectConfigAutoMapResult() +{ + if(s_AutoMapConfigSelected < 0) + return -1; + + int Result = s_AutoMapConfigSelected; + s_AutoMapConfigSelected = -1; + return Result; +} |