The Edit Grind, NaNoE Upgrades

Spread the love

Because of the time spent on the editing, I’m honestly not close enough to completing Accidental Distance yet. That is, at the time of starting writing what will be shared today.

You will note, firstly, that I adjusted NaNoE. I’ve added a few things that would make me feel a lot better about it, coming from the Computer Science studies I’ve gone through.

NaNoE: Swap to DB

To begin, we need to make a few classes we can use for ourselves.

We should move to an object-oriented structure. While they are functional, the way we work with them has logical flaws:

        /// <summary>
        /// Stored Novel Data
        /// </summary>
        Dictionary<string, List<string>> _helpers = new Dictionary<string, List<string>>();
        Dictionary<string, List<string>> _plot = new Dictionary<string, List<string>>();
        List<string> _novel = new List<string>();

This happens to be very simple, we can just wrap the ideas of what already exists into these classes:

    class NNote
    {
        public string Value { get; set; }
        public NNote(string val)
        {
            Value = val;
        }
    }

    class NParagraph
    {
        public string Value { get; set; }
        public NParagraph(string val)
        {
            Value = val;
        }
    }

    class NPlot
    {
        public string Name { get; set; }
        public NPlot(string name)
        {
            Name = name;
        }

        public List<NNote> Notes = new List<NNote>();
    }

    class NHelper
    {
        public string Name { get; set; }
        public NHelper(string name)
        {
            Name = name;
        }

        public List<NNote> Notes = new List<NNote>();
    }

The simple flaw should have been quite easy to see above.

Strings. Lists of Strings. That worked for when I made NaNoE, it just cuts corners and makes it slightly difficult to work with nne files. When you reach 55k words with tons in the Helpers and Plot, you would have most likely noticed depending on where you save(d) it there is a delay.

Lists of strings for a novel that can grow into quite a long story can slowly, but surely, knock the performance of NaNoE. That is the reason why using a database would actually work a lot better for us.

This has a simple flaw. I am not a great UI designer, you would have no doubt seen that NaNoE is the simple quick “oh well, that should work” options.

There we go, despite what you will see in the commits, we brought SQLite into the project for ourselves.

    class ObjectiveDB
    {
        public static SQLiteConnection Connection { get; private set; }
        public ObjectiveDB(string fileName)
        {
            if (!File.Exists(fileName))
            {
                SQLiteConnection.CreateFile(fileName);
            }

            if (Connection != null)
            {
                Connection.Close();
            }

            Connection = new SQLiteConnection("Data Source=" + fileName +"; Version=3;");
            Connection.Open();
        }
    }

You may note, I am definitely cutting corners again, just in a simpler way. We will now put reliance on the database itself. The ObjectiveDB became quite simple and easy for you to understand:

    class ObjectiveDB
    {
        public static SQLiteConnection Connection { get; private set; }
        public static string Name { get; private set; }
        public ObjectiveDB(string fileName)
        {
            if (!File.Exists(fileName))
            {
                SQLiteConnection.CreateFile(fileName);
            }

            if (Connection != null)
            {
                Connection.Close();
            }

            Connection = new SQLiteConnection("Data Source=" + fileName +"; Version=3;");
            Connection.Open();

            Name = fileName;
        }

        public static void TestNew()
        {
            if (!RunCMD("SELECT name FROM sqlite_master WHERE type='table';").HasRows)
            {
                // Create tables
                RunCMD("CREATE TABLE notes (id int primary key, val varchar(600));");
                RunCMD("CREATE TABLE paragraphs (id int primary key, para varchar(100000))"); // <- may be low?
                RunCMD("CREATE TABLE helpers (id int primary key, name varchar(200))");
                RunCMD("CREATE TABLE plots (id int primary key, name varchar(200))");

                RunCMD("CREATE TABLE plotsjoint (id int primary key, plotid int, noteid int)");
                RunCMD("CREATE TABLE helpersjoint (id int primary key, helperid int, noteid int)");
            }
        }

        public static SQLiteDataReader RunCMD(string sql)
        {
            if (Connection == null) return null;

            SQLiteCommand cmd = new SQLiteCommand(sql, Connection);
            var reader = cmd.ExecuteReader();

            return reader;
        }
    }

As you may note, I always cut corners, we can write things more efficiently in the future.

The lists we shared above in code? That is the next thing to tackle. This ended in a lot of helping code, though it wasn’t in the perfect form. You will see on NaNoE Github, it took quite a few adjustments, fixes, and more.

UI Revamp

That is the last image of the tons of changes to show off, just note there are quite a few fundamental changes.

First, if you used NaNoE and have nne files you can convert them through File > Import NNE.

Second, you can load the sqlite files, or create a new one.

I hope there aren’t many bugs, though I might have missed a few things. It is definitely a messy project. I will try to clean it up in the near future. I ignored the classes shared above, unfortunately, since it would take more time. It is back to the editing grind for me.

You can get NaNoE v1.5.1 for yourself.

It may be bugged, please just let me know any you find. I found bugs and fixed them as I edited. Yes, I know I swapped the versions for myself, I would love to know what to do for making it better!

The Edit Grind

Since I want to release Accidental Distances soon I figured I should rather spend the time moving through it completely.

  • Day 1: I started again after editing NaNoE to swap to the database. I got from paragraph 0 to 57 out of 1649 paragraphs in roughly 4 hours with most of it being coding.
  • Day 2: Today is the blog post day, starting at paragraph 58 I will edit from 7:50 am until 8:50 am – this should show how it will go finally. I got to paragraph 64.

I did less work during the week than expected, I didn’t get through editing at all. On the awkward side, the Day 2 listed here was while I kept being distracted to watch the 6th day of the DotA 2 International.

Essentially, this shows I can now get through the better editing at roughly 6 chapters and hour. So, that, unfortunately, means for the 1649 chapters I will take ~275 hours. Yeah, no matter how long I spend, this could be extremely slow still.

This doesn’t mean it would take that long. I will get used to the editing more, that should make it quicker. Some parts will also have less editing, I can imagine I got better at writing as I got through writing the novel.