Limegarden.net Personal site of Wouter Lindenhof

25Aug/100

Story editor

The Story Editor is slowly but steady making progress. The reason why it goes so slow is because I'm trying to ensure that the GUI will be of high quality. So I take special care and you might have done one thing fairly different that most text editors or story writers: There is only a little bit of text.

The reason why I want so little text is because Dutch is my native language although the majority of the time I working in English. From time to time I also try to write English stories and I have noticed that when I see something in a foreign language I also start thinking in that language. That is cool except the fact that I'm trying to write a story in another language. "It's a huge pain in the ass wanneer je opeens in het Nederlands ga schrijven" (translated: It's a pain in the ass when you suddenly start to write in Dutch). So I take special care of that. I'm still not certain what to do with words like "Chapter" or "Scene", or even "File" but for some reason I don't find those not that intrusive. At the same time however I think that localization (L10n) will be implemented as soon as I'm able.
The other thing I take special care of is the outline editor (what you see on the right). I have experimented with various forms (Tree Lists, zooming in and out) but I found out that this method is most likely the best way to do it. Tree Lists didn't format nicely and zooming in and out would have mean you could only see one chapter at the time.

Also I have finally implemented the ability to load and save. I mean I can understand that you don't want to write your story completely in one go. Saving is also cool. For starters there are multiple files (each scene, chapter, character, location, item et cetera) is put in a different file. However I don't like multiple files. I like one file so what it does is combine everything in one zip archive. This is cool, because if you have a custom tool (spell checker for example) you can just extract the file and run the tool. No need for a propriety format. Although zipping things in can be rather slow. Microsoft Office 2007 docx files have that problem as well, although now that I think about, it remains fast enough and if need be I can always move it to a thread or allow it to be saved without zipping it in (thus a collection of folders and files).

The last thing I want to mention is skinning. Personally I don't really care about it, but I know people who like it, so I have added that as well. Thanks to DevExpress there are already 31 skins in it. And here are a few examples:

Default skin

Pumpkin


Sharp plus

Office 2007 pink

So what is left?
Well first of all the Outline (chapters and scenes) needs to be finished. I want to be able to add chapters and scenes, remove them as well. And the last thing is actually being able to write. Oh before I forget it again: I want to be able to output the entire story in one document.

19Aug/100

Extending exceptions

Sometimes you have a function which needs to communicate back on failure through special exceptions as you want to program have the option to fix certain functions. For example a formula whose input parameter is bad (example: begin date is after the end date) or when the database throws up or anything.

Now you could do the following:


public class EndDateBeforeBeginDateException : Exception 	{ }

class example
{
	void SomethingWithTime(DateTime begin, DateTime end)
	{
		if (begin > end) throw new EndDateBeforeBeginDateException();
		// ... do something with time ....
	}

	void DemonstrateFunctionTriesToCorrectInsteadOfFail()
	{
		DateTime input_begin = new DateTime();
		DateTime input_end = input_begin.AddDays(-1); // WRONG DATE ON PURPOSE!
		do
		{
			try
			{
				SomethingWithTime(input_begin, input_end);
			}
			catch (EndDateBeforeBeginDateException)
			{
				// Date was most likely wrong ask user
				var r = MessageBox.Show("The end date was before the begin date."
					+ "Do you want to switch them and try again?",
					"Switch dates?",
					MessageBoxButtons.YesNo);

				if (r != DialogResult.No) { return; } // quit function
				var temp = input_begin;
				input_begin = input_end;
				input_end = temp;
				continue; // Try again now
			}
		} while (false);
	}
}

But what if you have a lot of parameters. You don't want to create thousands of exceptions. Well, you can try using tagged exceptions which looks like this.


public class TaggedException<T> : Exception { }

struct _EndDateBeforeBeginDateTag{}
struct _SameDateTag {}
struct _TimeDoesNotExistTag {}
struct _ThinkOfATagOnYourOwn {}

class example
{
	void SomethingWithTime(DateTime begin, DateTime end)
	{
		if (begin > end)  throw new TaggedException<_EndDateBeforeBeginDateTag>();
		if (begin == end) throw new TaggedException<_SameDateTag>();
		// ... do something with time ....
	}

	void DemonstrateFunctionTriesToCorrectInsteadOfFail()
	{
		DateTime input_begin = new DateTime();
		DateTime input_end = input_begin.AddDays(-1); // WRONG DATE ON PURPOSE!
		do
		{
			try
			{
				SomethingWithTime(input_begin, input_end);
			}
			catch (TaggedException<_EndDateBeforeBeginDateTag>)
			{
				// Date was most likely wrong ask user
				var r = MessageBox.Show("The end date was before the begin date."
					+ "Do you want to switch them and try again?",
					"Switch dates?",
					MessageBoxButtons.YesNo);

				if (r != DialogResult.No) { return; } // quit function
				var temp = input_begin;
				input_begin = input_end;
				input_end = temp;
				continue; // Try again now
			}catch (TaggedException<_SameDateTag>)
			{
				// Force the user to change one date
			}catch (TaggedException<_ThinkOfATagOnYourOwn>)
			{
				// Tag seems obvious enough *wink*
			}
		} while (false);
	}
}

Now you only have one Exception in your code though you can quickly and without having to write much code.
(And if you are smart you store extra info the tag which is stored in the exception).

The same trick also works in C++ using templates.

16Aug/100

I’m born in 1910

The age check as was displayed on the Bioware Dragon age siteYes, it's true I'm a hundred years old, now please move over and let me read what I came to read.

Of course, I'm not that old, but I have always wondered about the need for an age check. In the past I always filled them in correctly (2 years in the past) but now I see no need for it. The reason for an age check was because content distributors could keep someone away from certain content unless they were old enough. As if physical age should have been a determining factor.

Besides that it easy to work around (see screenshot, it's called lying, just so you know) couldn't they have just asked in what age group I fall? Am I or am I older than 21/18/15/13 et cetera. It would be one click instead of four clicks. And if they could also allow me to change my age after a wrong input, that would be nice. I once was 5 years old and could not correct it to 24, the solution was to delete the cookies and try again.

Please drop this system and use something more mature...

But the problem is that they use that information as marketing material to answer the question "What should be our focus group?". Since I'm not the only one who 'cheats' his way around I guess that some people are still wondering what a bunch of 100 year old guys and girls are interested in games (and various other age limited stuff).

Tagged as: No Comments
15Aug/100

Story editor

I like writing stories. They are a form of entertainment to me and as such I enjoy spending my time in writing something else then code. However I have never found a tool that met my requirements. In my opinion an application for creative story writing should be focused on allowing you to write as comfortable as possible without any distraction, which often means you turn off the automatic spell-checker and more.

Now Microsoft Word would have been a great tool were it not that I need to keep track of all kinds of things in my story. I used to do this with an Excel file but that didn't work. I have tried some of the creative story writing software out there (open-source, free and commercial) but they either provided too much, miss certain features or required me to work in a way I thought was cumbersome (I don't want a pop-up when I look at details of a person).

So I have decided to write my very own story editor.
A key feature will be that it uses a dynamic data format. In most applications you can add and edit your characters but then you only a few predefined fields available, like name, birthday, bio and notes. If you are writing a deep space story which involves many alien races you would need to define that for each character in the bio. In my story editor I want to be able to just add an extra field.

Another feature I'm going to put in for certain is that everything can have transient properties, which is fancy way of saying that some properties might not last forever. In the Lord of the Rings we see that the one ring switches quite a bit from owner. Having one field to track information about the owner would be insufficient as I want to know the owner of the ring at a certain point in time. Of course, this system is a bit cumbersome when you want to keep track of the owner of the a ball in a football match. ;)

The first release will be when the editing of files and the outline editor fully works.

9Aug/100

Driving in foreign country

Yesterday I drove back from Belgium and I was surprised about the amount of cars overtaking me from the wrong side (some people were actually zigzagging through the traffic!), the amount of people who kept driving in the fast lane (rule is that you use the fast lane when overtaking) and speeding (I have seen Ferrari and Porsches passing me in an instant while was I was already at (and a bit over) the speed limit) .

In the Netherlands we sometimes joke that the 'belgen' (Belgians) get their drivers license with a pack of coffee, but with what I have seen yesterday I can only hope that those people (excluding all normal, correct, driving Belgians) got their license with a pack of coffee.

Two weeks earlier I was on vacation in Ireland on a car vacation. There they don't have a formal institution for driving licenses (at least that is what I thought I heard on the radio) but in that week that I was driving there it didn't even come close to the number of traffic violations that I saw on a single day in Belgium.

I'm curious about what others think about drivers from other countries.

Tagged as: No Comments
6Jul/102

Comments

This part is almost straight from my programming style document.

This might sound stupid, but try to comment every other line (unless you have a lot of repeating or similar tasks). By doing so you get two advantages:

  1. Someone unskilled in programming or unfamiliar with what you are doing is able to read your code.
  2. You know what you are doing

The first advantage is important unless you are working alone and never expect to see your code again. In that case you should really ask yourself if you should even be writing that code.

The second one is important even if you have no trouble reading code. Let's take a look at the following example.

for(int index_person = 0; index_person < persons.size(); ++index_person)
{
    for(int index_kids = 0; index_kids < persons[index_person].kids.size(); ++index_kids)
    {
        /* ... */
    }
}

And then take a look at this example:

/* Iterating through the persons in the lists */
for(int index_person = 0; index_person < persons.size(); ++index_person)
{
    /* Iterating through the kids of the persons in the list */
    for(int index_kids = 0; index_kids < persons[index_person].kids.size(); ++index_kids)
    {
        /* checking if any of the persons in the list have a kid who is dead */
        /* ... */
    }
}

In the last example I only have to track back to the first comment prior to my line of code to know what I'm doing here. It's a pain to write so many comments but it makes code a whole lot easier to read.

29Jun/102

Lady luck is using a loaded dice…

The one thing that I didn't backup was Outlook. My email is handled by GMail and since Outlook also syncs with my mobile phone, I already had a backup of my mail and my contacts.

So being the adventurous type I decided against wasting my time and do a proper backup. Well, today, when I wanted to call someone, I found out that all my contacts had been wiped from my mobile phone and as a result my backup was gone.
I suspect that it has been my own fault, but based on the bad luck I'm having lately I'm suspecting Lady Luck to uses loaded dice to decide my chances...

Tagged as: , , 2 Comments
25Jun/100

Wierd evening

Today went well, as far days go, that was until it hit 11 o'clock (I had been watching the football match between the Netherlands and Cameroon, which we won ;) ). I went up to my room to see if my laptop had completed some maintenance work and was surprised to find "The computer has been recovered"-message which is signal that something has gone horribly wrong. Clicking 'Ok' caused it to reboot and after swiping my finger (gotta love the fingerprint protection system) the computer logged in and Bang! Blue Screen followed by a reboot after which the computer tried to recover again.
I decided to let the computer have another try before I would try and find out what was wrong, but needless to say, this rant is not about how happy I am that it has been fixed but that I didn't complete it.

To make a long story short I decided that it was quicker to just reinstall everything so as I was busy back up, my mom asked me to pick up my brother who had gone party. It was already the next day (it's now almost two in the morning) and to my suprise I found out that my bike (who he borrowed) was suddenly a folding bike and I'm prety sure that was not possible when he left. Apperantly he had to evade something which caused him to ride in to a low wall. The result: Bike broken and my favorite brother had a few scratches.

So now I'm reinstalling my system for the first time I bought it (almost four years ago, which is a record) and I'm without a bike. If the sky would drop on my head right now I wouldn't even be suprised. :-D

Tagged as: No Comments
24Jun/100

Splash screens

I always have my doubts about splash screens. As far as I know the majority of the splash screens have no function. A minority does have a function (they do background loading).

The main purpose of splash screen is, in my opinion, advertising. For a few second the user sees the name of the application and the company behind it. I admit that you can use it to load things in the background, but showing a splash screen also takes time. In that case you are better off loading the application and showing a progress bar. At that point the user sees it as the application is loading content. If you are using a splash screen for that (and I'm going to assume it makes no difference in performance or time that it requires) than the users perceives it as an annoyance.
This is a weird thing. Because showing a splash screen that does nothing but is only showed for a 2 seconds after which the application starts loading is seemed to be less intrusive than a splash screen that takes longer but actually causes the application to load faster (it doesn't require two useless seconds).

So how do you create a splash screen?
First of all start with a small image (take the dimensions of the office 2007 splash screens), add some abstract art (not something complex). Then create a form without borders in C# that closes after a few seconds and then modify the program.cs so that it looks like this.


using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace Client
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new SplashScreen()); // load the splash screen
            Application.Run(new MainWindow()); // load the application
        }
    }
}

I know it's a cheap trick, but it looks nice if you do it well. And most customers care a lot about appearance.

22Jun/100

Only one more day

Tomorrow I will be defending my graduation work and if all goes well (it must be a strange turn of events if doesn't go well) I will know if I have completed my graduation.

Only one more day :)