File indexing completed on 2024-10-13 03:44:14

0001 /***************************************************************************
0002                                cmapcmdleveldelete.cpp
0003                              -------------------
0004     begin                : Mon Mar 4 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 "cmapcmdleveldelete.h"
0019 
0020 #include "cmapmanager.h"
0021 #include "cmaplevel.h"
0022 
0023 CMapCmdLevelDelete::CMapCmdLevelDelete(CMapManager *manager,QString name, CMapLevel *level) : CMapCommand(name)
0024 {
0025     m_mapManager = manager;
0026     m_levelID = level->getLevelID();
0027     m_index = -1;
0028 }
0029 
0030 CMapCmdLevelDelete::~CMapCmdLevelDelete()
0031 {
0032 }
0033 
0034 void CMapCmdLevelDelete::redo()
0035 {
0036   CMapLevel *level = m_mapManager->findLevel(m_levelID);
0037   m_index = level->getZone()->levelIndex(level);
0038   delete level;
0039 }
0040 
0041 void CMapCmdLevelDelete::undo()
0042 {
0043   CMapLevel *level = new CMapLevel(m_mapManager, m_index);
0044   level->setLevelID(m_levelID);
0045 }