Crea sito

Beltham's Lair Content Editor, First Steps

(50% of readers found this post not so interesting)

(2013, may 30) As I said, I moved my efforts on the development of a content editor to manage (create, edit, delete) various contents for Beltham's Lair.

Well, a couple of days are passed away, and I have the first version of the editor ready and working. Up to now, it is able to manage potions.

How it works?

Pretty simple: a .NET windows form lets you handle the data and then save to file. These files can then be loaded in a second time to continue the work.

I choosed a binary format for the data file, since .NET has a bunch of friendly class to deal with binary data. Here is, for example, how I write an integer value:

FileStream fs = File.Create(filename);
byte[] buffer= System.BitConverter.GetBytes(intValue);
int size = buffer.Length;
fs.Write(buffer, 0, size);

The real code is all a bit more refactored, obviously, having some nice functions to retrieve the buffer byte array from primitive data, so that I really write something like this:

fs.Write(GetBytes(intValue, out size), 0, size);

When it comes to deserialize, the process is quite similar, using the Read method of FileStream class.

Strings, as usual, are a bit more complicated, since I have to write the length of the string before, and then the actual string, so that at deserialize time I am able to know how many bytes I have to read to rebuild the right string data.

Well, nothing too overwhelming, for sure, and probably this post is full of obviusness, but that's all.

Please rank this post

    Not so interesting
    Nice!
    Very interesting

Latest flash games


A Life
A Life

Avoid the obstacles that life throws to you.
Play!


Runk!
Runk

A run tank game. Penetrate through enemy lines with your tank!
Play!