Wednesday, April 18, 2007

Hello Arrakis!!

I added some more features to the Windowing system, and I think I'm done for now with the system. All that remains are the controls to be written, and I'll write those as soon as I need them.

Features I've added:
- Complete rendering of the borders and title bar
- Client rectangles(Client Rectangle = Window - borders)
- Dragging of windows
- Move event for when the window is being dragged around

The dragging of the window was quite some work, as I needed to change quite a lot of code. It wasn't very difficult, just required a lot of code changing, since I never wrote the code to be able to drag the windows around, nor intend to have borders around it them(Pretty stupid).

This initially ended up with the Control class drawing itself on the wrong position while being dragged, and the derived class draw on the correct position. Pretty weird, and I still have no idea why this happened. The image below shows this in action(I had to place my fingers in a really uncomfortable position to be able to get this pic. My left hand pink and ring finger held down the FN + ALT key, while my thumb help down the L-mouse on my touchpad, my index finger drew circles on the touchpad and my right hand was used to pressed Print Screen).

Dragging bug in action, nearly lost my fingers while obtaining this image

After I fixed the dragging bug, I'd figured I'd make a standard dialog window(Not yet written, but the code needed for it is ready, just need to be moved into another class). This is what it looks like:
Standard dialog with label and button

How does the dragging system work?
When the L mouse down event is catched, it checks if the mouse is over a window. If this is true, it will check if the mouse is within the ClientRectangle. If this isn't the case, it checks if the Y is within the bounds of the TitleBar. If this is true, it will record the state as Dragging for the LMouse button, and which control it is dragging.

On every mousemove, it checks if the LMouse is down, and when this is the case AND the state is dragging, it takes the Delta X and Y and substracts this from the position of the window. It then forces to update all the client rectangles and voila, done.

New control
I added a Label control. Not very special, it took like 2 minutes to create...

Todo for now:
- Create a MessageBox class.
- Add support for modal windows
- Incorporate UI into existing game class.
- Build CreditCounter control(Dune specific)
- Layout new todo list for building, techtree, etc.

Also, to answer a previously asked question about open-sourceness:
For now, I will keep the source closed. This is a personal project, and I don't take kindly to people changing my code while I'm still working on the game. However, after the game is completed, I might open-source it. However, I might, might release my UI system, in case people want to take a look at it, and perhaps improve it. It's not the best system out there, there are MUCH better UI systems out there, but it works for a small amount of controls.

No comments: