add File>Reload Project
This commit is contained in:
parent
ca5a0247f7
commit
6026266afd
5 changed files with 46 additions and 4 deletions
|
@ -561,7 +561,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>545</width>
|
||||
<width>542</width>
|
||||
<height>628</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -767,7 +767,7 @@
|
|||
<rect>
|
||||
<x>8</x>
|
||||
<y>0</y>
|
||||
<width>221</width>
|
||||
<width>224</width>
|
||||
<height>324</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -1118,7 +1118,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>231</width>
|
||||
<width>234</width>
|
||||
<height>83</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -2886,6 +2886,7 @@
|
|||
<string>File</string>
|
||||
</property>
|
||||
<addaction name="action_Open_Project"/>
|
||||
<addaction name="action_Reload_Project"/>
|
||||
<addaction name="action_Save"/>
|
||||
<addaction name="action_Save_Project"/>
|
||||
<addaction name="separator"/>
|
||||
|
@ -3172,6 +3173,11 @@
|
|||
<string>Themes...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_Reload_Project">
|
||||
<property name="text">
|
||||
<string>Reload Project</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
|
|
|
@ -42,6 +42,7 @@ public slots:
|
|||
|
||||
private slots:
|
||||
void on_action_Open_Project_triggered();
|
||||
void on_action_Reload_Project_triggered();
|
||||
void on_mapList_activated(const QModelIndex &index);
|
||||
void on_action_Save_Project_triggered();
|
||||
void openWarpMap(QString map_name, QString warp_num);
|
||||
|
|
|
@ -64,6 +64,9 @@ public:
|
|||
|
||||
void set_root(QString);
|
||||
|
||||
void clearMapCache();
|
||||
void clearTilesetCache();
|
||||
|
||||
struct DataQualifiers
|
||||
{
|
||||
bool isStatic;
|
||||
|
|
|
@ -306,7 +306,10 @@ bool MainWindow::openProject(QString dir) {
|
|||
&& populateMapList()
|
||||
&& setMap(getDefaultMap(), true);
|
||||
} else {
|
||||
success = loadDataStructures() && populateMapList() && setMap(editor->map->name, true);
|
||||
QString open_map = editor->map->name;
|
||||
editor->project->clearMapCache();
|
||||
editor->project->clearTilesetCache();
|
||||
success = loadDataStructures() && populateMapList() && setMap(open_map, true);
|
||||
}
|
||||
|
||||
if (success) {
|
||||
|
@ -373,6 +376,19 @@ void MainWindow::on_action_Open_Project_triggered()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_action_Reload_Project_triggered() {
|
||||
// TODO: when undo history is complete show only if has unsaved changes
|
||||
QMessageBox warning(this);
|
||||
warning.setText("WARNING");
|
||||
warning.setInformativeText("Reloading this project will discard any unsaved changes.");
|
||||
warning.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
||||
warning.setIcon(QMessageBox::Warning);
|
||||
|
||||
if (warning.exec() == QMessageBox::Ok) {
|
||||
openProject(editor->project->root);
|
||||
}
|
||||
}
|
||||
|
||||
bool MainWindow::setMap(QString map_name, bool scrollTreeView) {
|
||||
logInfo(QString("Setting map to '%1'").arg(map_name));
|
||||
if (map_name.isEmpty()) {
|
||||
|
|
|
@ -77,7 +77,9 @@ Project::~Project()
|
|||
delete this->mapConstantsToMapNames;
|
||||
delete this->mapNamesToMapConstants;
|
||||
|
||||
clearMapCache();
|
||||
delete this->mapCache;
|
||||
clearTilesetCache();
|
||||
delete this->tilesetCache;
|
||||
}
|
||||
|
||||
|
@ -94,6 +96,20 @@ QString Project::getProjectTitle() {
|
|||
}
|
||||
}
|
||||
|
||||
void Project::clearMapCache() {
|
||||
for (QString mapName : mapCache->keys()) {
|
||||
Map *map = mapCache->take(mapName);
|
||||
if (map) delete map;
|
||||
}
|
||||
}
|
||||
|
||||
void Project::clearTilesetCache() {
|
||||
for (QString tilesetName : tilesetCache->keys()) {
|
||||
Tileset *tileset = tilesetCache->take(tilesetName);
|
||||
if (tileset) delete tileset;
|
||||
}
|
||||
}
|
||||
|
||||
Map* Project::loadMap(QString map_name) {
|
||||
Map *map;
|
||||
if (mapCache->contains(map_name)) {
|
||||
|
|
Loading…
Reference in a new issue