File indexing completed on 2024-12-01 06:51:42
0001 /*************************************************************************** 0002 cmapcmdlevelcreate.cpp 0003 ------------------- 0004 begin : Wed Mar 6 2002 0005 copyright : (C) 2002 by Kmud Developer Team 0006 email : kmud-devel@kmud.de 0007 ***************************************************************************/ 0008 0009 /*************************************************************************** 0010 * * 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either version 2 of the License, or * 0014 * (at your option) any later version. * 0015 * * 0016 ***************************************************************************/ 0017 0018 #include "cmapcmdlevelcreate.h" 0019 0020 #include "cmapmanager.h" 0021 #include "cmaplevel.h" 0022 #include "cmapview.h" 0023 0024 CMapCmdLevelCreate::CMapCmdLevelCreate(CMapManager *manager,QString name,int index) : CMapCommand(name) 0025 { 0026 m_mapManager = manager; 0027 m_index = index; 0028 m_levelID = -1; 0029 m_level = nullptr; 0030 } 0031 0032 CMapCmdLevelCreate::~CMapCmdLevelCreate() 0033 { 0034 } 0035 0036 void CMapCmdLevelCreate::redo() 0037 { 0038 m_level = new CMapLevel(m_mapManager, m_index); 0039 m_mapManager->getActiveView()->showPosition(m_level, false); 0040 0041 if (m_levelID == -1) 0042 { 0043 m_levelID = m_level->getLevelID(); 0044 } 0045 else 0046 { 0047 m_level->setLevelID(m_levelID); 0048 } 0049 } 0050 0051 void CMapCmdLevelCreate::undo() 0052 { 0053 CMapLevel *level = m_mapManager->findLevel(m_levelID); 0054 delete level; 0055 } 0056 0057 CMapLevel *CMapCmdLevelCreate::getLevel(void) 0058 { 0059 return m_level; 0060 }