void HistoryElementRemoveWarp::redo() { if(!m_scene) return; LvlScene* lvlScene; if(!(lvlScene = qobject_cast<LvlScene*>(m_scene))) return; lvlScene->doorPointsSync( m_removedDoor.meta.array_id, true); for(int i=0;i<lvlScene->m_data->doors.size();i++) { if(lvlScene->m_data->doors[i].meta.array_id==m_removedDoor.meta.array_id) { lvlScene->m_data->doors.removeAt(i); break; } } QComboBox* warplist = MainWinConnect::pMainWin->dock_LvlWarpProps->getWarpList(); for(int i = 0; i < warplist->count(); i++){ if((unsigned int)warplist->itemData(i).toInt() == m_removedDoor.meta.array_id){ warplist->removeItem(i); break; } } if(warplist->count()<=0) MainWinConnect::pMainWin->dock_LvlWarpProps->setWarpRemoveButtonEnabled(false); MainWinConnect::pMainWin->dock_LvlWarpProps->setDoorData(-2); }
void HistoryElementAddWarp::undo() { if(!m_scene) return; LvlScene* lvlScene; if(!(lvlScene = qobject_cast<LvlScene*>(m_scene))) return; lvlScene->doorPointsSync((unsigned int)m_array_id,true); for(int i = 0; i < lvlScene->m_data->doors.size(); i++) { if(lvlScene->m_data->doors[i].meta.array_id==(unsigned int)m_array_id) { lvlScene->m_data->doors.removeAt(i); break; } } bool found = false; QComboBox* warplist = MainWinConnect::pMainWin->dock_LvlWarpProps->getWarpList(); if((warplist->currentIndex()==m_listindex)&&(warplist->count()>2)) { warplist->setCurrentIndex(warplist->currentIndex()-1); } LogDebug("HistoryManager -> check index"); if(m_listindex < warplist->count()){ if(m_array_id == warplist->itemData(m_listindex).toInt()){ found = true; warplist->removeItem(m_listindex); } } LogDebug(QString("HistoryManager -> found = %1").arg(found)); if(!found) { found=false; for(int i = 0; i < warplist->count(); i++) { if(m_array_id == warplist->itemData(i).toInt()) { warplist->removeItem(i); found=true; break; } } } LogDebug(QString("HistoryManager -> found and removed = %1").arg(found)); if(warplist->count()<=0) MainWinConnect::pMainWin->dock_LvlWarpProps->setWarpRemoveButtonEnabled(false); MainWinConnect::pMainWin->dock_LvlWarpProps->setDoorData(-2); //warplist->update(); //warplist->repaint(); }