Log in

No account? Create an account
Menu Systems - Silicon Rose [entries|archive|friends|userinfo]
Silicon Rose

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Menu Systems [Feb. 1st, 2007|09:55 pm]
Silicon Rose
[Current Mood |cheerfulcheerful]

So, task for today was to try and construct a menu that emerges out of the side of the screen. Of course, I don't like to make it easy (and I prefer to do things which I expect to use later), so I wanted a transparent menu.

If you're going to draw 2D things, you have to have a Texture2D hanging around. I could swear that I did a SetData on a Texture2D before, but the all the format types I tried which contained alpha channels caused the construction of the Texture2D object to fail, citing a conflict between the format and the ResourceUsage type (which is required to be Dynamic in order to use Set/GetData). Well, if you can't use SetData, the only way to set a Texture2D object is to use LoadContent, which requires content to load - a .png file.

Unfortunately MS Paint doesn't support authoring transparent .png files as far as I can tell. Since I didn't know of a freeware .png authoring tool, and all I needed was a 1x1 partially transparent image, I figured I might be able to create my own using a hex editor. (Yes, I specialize in making my own life difficult.) Well, the hex editors I could find either a) didn't work, or b) looked like hassleware. I could technically write a program to stream bytes to a file, but after skimming the file format further, I decided it'd probably be even more trouble, so I went searching for a .png editor again.

I found Paint.NET, which is pretty cool. I messed up a bit with it at first, but eventually I managed to get a mini-transparent image. After that, the code was almost perfect (I mixed up height and width, so the menu ending up emerging from half of the top of the screen instead of the side), and now I have a scroll out window.

I'm going to have to refactor this mess pretty soon, though. ~sigh~ I was leaning towards a kind of MVC setup, but I'm not sure that's going to work for this, or I may be misunderstanding how to use the pattern. Ah well. I'm certain I will be able to come up with something clean and functional.