save / load from the config
This commit is contained in:
parent
e82ff92b2b
commit
4334e5b2e9
2 changed files with 15 additions and 10 deletions
|
@ -31,7 +31,6 @@ public:
|
||||||
|
|
||||||
bool load();
|
bool load();
|
||||||
bool loadCityMaps();
|
bool loadCityMaps();
|
||||||
void setCurrentSquareOptions();
|
|
||||||
|
|
||||||
void onRegionMapTileSelectorSelectedTileChanged(unsigned id);
|
void onRegionMapTileSelectorSelectedTileChanged(unsigned id);
|
||||||
void onCityMapTileSelectorSelectedTileChanged(unsigned id);
|
void onCityMapTileSelectorSelectedTileChanged(unsigned id);
|
||||||
|
|
|
@ -385,7 +385,7 @@ poryjson::Json RegionMapEditor::getJsonFromAlias(QString alias) {
|
||||||
|
|
||||||
bool RegionMapEditor::load() {
|
bool RegionMapEditor::load() {
|
||||||
// check for config json file
|
// check for config json file
|
||||||
QString jsonConfigFilepath = this->project->root + "/src/data/region_map/region_map_config.json";
|
QString jsonConfigFilepath = this->project->root + "/src/data/region_map/porymap_config.json";
|
||||||
if (!QFile::exists(jsonConfigFilepath)) {
|
if (!QFile::exists(jsonConfigFilepath)) {
|
||||||
logWarn("Region Map config file not found.");
|
logWarn("Region Map config file not found.");
|
||||||
|
|
||||||
|
@ -410,8 +410,10 @@ bool RegionMapEditor::load() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logInfo("Region map configuration file found.");
|
logInfo("Region map configuration file found.");
|
||||||
|
ParseUtil parser;
|
||||||
// TODO: load rmConfigJson from the config file, and verify it
|
OrderedJson::object obj;
|
||||||
|
parser.tryParseOrderedJsonFile(&obj, jsonConfigFilepath);
|
||||||
|
this->rmConfigJson = OrderedJson(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if all has gone well, this->rmConfigJson should be populated
|
// if all has gone well, this->rmConfigJson should be populated
|
||||||
|
@ -460,18 +462,23 @@ bool RegionMapEditor::loadCityMaps() {
|
||||||
|
|
||||||
void RegionMapEditor::on_action_RegionMap_Save_triggered() {
|
void RegionMapEditor::on_action_RegionMap_Save_triggered() {
|
||||||
// TODO: add "Save All" to save all region maps
|
// TODO: add "Save All" to save all region maps
|
||||||
// TODO: save the config json as well
|
|
||||||
this->region_map->save();
|
this->region_map->save();
|
||||||
|
|
||||||
// save entries
|
// save entries
|
||||||
saveRegionMapEntries();
|
saveRegionMapEntries();
|
||||||
|
|
||||||
// save config
|
// save config
|
||||||
}
|
QString filepath = QString("%1/src/data/region_map/porymap_config.json").arg(this->project->root);
|
||||||
|
QFile file(filepath);
|
||||||
void RegionMapEditor::setCurrentSquareOptions() {
|
if (!file.open(QIODevice::WriteOnly)) {
|
||||||
// TODO
|
logError(QString("Error: Could not open %1 for writing").arg(filepath));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
OrderedJsonDoc jsonDoc(&(this->rmConfigJson));
|
||||||
|
jsonDoc.dump(&file);
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
this->hasUnsavedChanges = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::displayRegionMap() {
|
void RegionMapEditor::displayRegionMap() {
|
||||||
|
@ -848,7 +855,6 @@ void RegionMapEditor::onRegionMapEntryDragged(int new_x, int new_y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::onRegionMapLayoutSelectedTileChanged(int index) {
|
void RegionMapEditor::onRegionMapLayoutSelectedTileChanged(int index) {
|
||||||
setCurrentSquareOptions();
|
|
||||||
QString message = QString();
|
QString message = QString();
|
||||||
this->currIndex = index;
|
this->currIndex = index;
|
||||||
this->region_map_layout_item->highlightedTile = index;
|
this->region_map_layout_item->highlightedTile = index;
|
||||||
|
|
Loading…
Reference in a new issue