Scrolling boxes

It’s badly coded and needs some fixing up; but it works:

Scrollbars working
Scrollbars working

I’ve also been working on documentation of the UI system and need to complete that. It took far too long to complete the above because I had to keep going back over code to figure out what it was meant for.

Table Layout 99% Complete

It can never truly be 100% complete; but it’s pretty close. Cellpadding and cellspacing are in place as well as options to draw the borders. Elements are also positioned within their cell.

Table Layout 99% complete
Table Layout 99% complete

Now that I’ve got some way to position elements I can start working on text boxes; then the very tricky scrollbars.

I haven’t planned these out; but I think scrollbars need to handle a single…. Box, or Cell element. Every frame, the contents of the box or cell will need to be drawn to a texture, and then only the visible part of the texture is drawn to the destination; the scrollbar would adjust the region drawn. I can’t think of another way to hide the parts that are “offscreen”.

Table Layout 80% done

I spent the bulk of my available time this weekend writing the code for the Table Layout. It ended up quite a bit different from the design; chiefly because I found there was no need for an abstract row. The TableLayout class itself handles all the row…ing.

I just need to add some things like cellpadding, cellspacing, rowspan and colspan. Maybe some method to draw borders; though I might use a specialised DataTable class for that.

TableLayout is working
TableLayout is working

UI System Overview

I’m now about 60% done on the UI system code. I’m also only about 80% complete with the design though (I was tired of design and needed to code).

I have to admit that designing everything first was something I haven’t done before and it helped immensely. I don’t know why I never did it before but I will definitely be doing this for future systems in the game.


UI Progress

I’ve made some more progress on the UI; it’s now possible to have it textured. The textures are variable dimensions and there’s a few different options on how to handle resizing (stretching textures or repeating them etc).

EDIT: I’ve got some performance problems doing this because a single texture for like the border needs to be repeated a whole heap of times. It seems like resizeable windows may not be doable, instead I will need to use statically sized windows. I’m sure there’s another way…

Still working on a UI

I’m not surprised, but I am a little dismayed, about the amount of effort that goes into even the simplest UI. I’m using a sort of event queue to process input and hope to detach the input handling from the main loop soon.

The actual elements themselves are easy enough to program but the designing part of it is a little tricky. I’ve been playing and studying a few UI intensive games the last few weeks to see what works and what doesn’t.  If I’m honest, ive been wasting time.

UI + Glow

The UI is coming along nicely (I need to work out how to do animated gifs to show stuff off). It’s widget based with a good input handling system, I just need to work on using several textured quads so that the windows can be styled nicely.

UI with transparency
UI with transparency

I’ve also done a bit of work with post-processing effect shaders to produce a glow on the more luminous areas. Here’s a couple of screenshots showing the sun from the perspective of an Earth and the result of the reflection of sunlight over the desert (it’s not quite right over the ocean yet, so still need to work on that).

Continue reading “UI + Glow”

Displaying Text + UI

I’ve spent quite some time investigating the various Text/Font libraries for both SDL and OpenGL. I first looked at SDL_ttf which seemed like the most obvious choice. Unfortunately I could either not get it to compile, or when I did it just threw errors when I tried to use it. I also took a look at a whole slew of OpenGL based ones, however out of the 4 or so I found, only one appeared to be compatible with OpenGL 3.3+; but it lacked some features I wanted to use. In the end I decided to roll my own using FreeType2. I didn’t want two additional dependencies, so this way I only need one. And everyone uses FreeType2, you’d be insane not to. Here’s some pretty straight-forward results.

Continue reading “Displaying Text + UI”