Save settings and give nicer names to some
diff --git a/common/project.cc b/common/project.cc
index 949f687..8ee78c4 100644
--- a/common/project.cc
+++ b/common/project.cc
@@ -18,6 +18,7 @@
  */
 
 #include "project.h"
+#include <algorithm>
 #include <boost/filesystem/convenience.hpp>
 #include <boost/property_tree/json_parser.hpp>
 #include <fstream>
@@ -64,11 +65,18 @@
         root.put("project.name", boost::filesystem::basename(filename));
         root.put("project.arch.name", ctx->archId().c_str(ctx));
         root.put("project.arch.type", ctx->archArgsToId(ctx->archArgs()).c_str(ctx));
-        std::string fn = ctx->settings[ctx->id("project/input/json")];
+        std::string fn = ctx->settings[ctx->id("input/json")];
         root.put("project.input.json", make_relative(fn, proj.parent_path()).string());
         root.put("project.params.freq", int(ctx->target_freq / 1e6));
         root.put("project.params.seed", ctx->rngstate);
         saveArch(ctx, root, proj.parent_path().string());
+        for(auto const &item : ctx->settings)
+        {
+            std::string path = "project.settings.";
+            path += item.first.c_str(ctx);
+            std::replace(path.begin(), path.end(), '/', '.');
+            root.put(path, item.second);
+        }
         pt::write_json(f, root);
     } catch (...) {
         log_error("Error saving project file.\n");
diff --git a/gui/basewindow.cc b/gui/basewindow.cc
index 66df3ca..4444c8e 100644
--- a/gui/basewindow.cc
+++ b/gui/basewindow.cc
@@ -420,7 +420,7 @@
     actionNew->setEnabled(true);

     actionOpen->setEnabled(true);

 

-    if (ctx->settings.find(ctx->id("project/input/json")) != ctx->settings.end())

+    if (ctx->settings.find(ctx->id("input/json")) != ctx->settings.end())

         actionSave->setEnabled(true);

     else

         actionSave->setEnabled(false);

diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc
index 9fe8071..f270b11 100644
--- a/gui/ice40/mainwindow.cc
+++ b/gui/ice40/mainwindow.cc
@@ -191,7 +191,7 @@
 

 void MainWindow::onProjectLoaded()

 {

-    if (ctx->settings.find(ctx->id("project/input/pcf")) != ctx->settings.end())

+    if (ctx->settings.find(ctx->id("input/pcf")) != ctx->settings.end())

         actionLoadPCF->setEnabled(false);

 }

 

diff --git a/ice40/pcf.cc b/ice40/pcf.cc
index d9fc4e6..af5b3e1 100644
--- a/ice40/pcf.cc
+++ b/ice40/pcf.cc
@@ -66,7 +66,7 @@
                 log_error("unsupported pcf command '%s'\n", cmd.c_str());
             }
         }
-        ctx->settings.emplace(ctx->id("project/input/pcf"), filename);
+        ctx->settings.emplace(ctx->id("input/pcf"), filename);
         return true;
     } catch (log_execution_error_exception) {
         return false;
diff --git a/ice40/project.cc b/ice40/project.cc
index 8ca10e3..47c0903 100644
--- a/ice40/project.cc
+++ b/ice40/project.cc
@@ -28,8 +28,8 @@
 void ProjectHandler::saveArch(Context *ctx, pt::ptree &root, std::string path)
 {
     root.put("project.arch.package", ctx->archArgs().package);
-    if (ctx->settings.find(ctx->id("project/input/pcf")) != ctx->settings.end()) {
-        std::string fn = ctx->settings[ctx->id("project/input/pcf")];
+    if (ctx->settings.find(ctx->id("input/pcf")) != ctx->settings.end()) {
+        std::string fn = ctx->settings[ctx->id("input/pcf")];
         root.put("project.input.pcf", make_relative(fn, path).string());
     }
 }
diff --git a/json/jsonparse.cc b/json/jsonparse.cc
index 9e86f93..d73525b 100644
--- a/json/jsonparse.cc
+++ b/json/jsonparse.cc
@@ -754,7 +754,7 @@
 
         log_info("Checksum: 0x%08x\n", ctx->checksum());
         log_break();
-        ctx->settings.emplace(ctx->id("project/input/json"), filename);
+        ctx->settings.emplace(ctx->id("input/json"), filename);
         return true;
     } catch (log_execution_error_exception) {
         return false;