I haven't done much this time. Lot of stuff going on and I was playing with some side projects I don't plan to write about here. I wasn't sure if I should write this now, or wait til I have more stuff done, but I feel like writing today, sooo...
I have started work on the menu items. A lot of them will display text on the screen in a box of sorts.
First of all, I decided that there should be one abstraction over drawing screens like this. For this reason, I created the TextPageContent class. This class holds everything that is on the screen.
I have noticed that I enjoy some planning before coding. Like, I first declare a bunch of types and classes and function headers, basically all the main things I will need, and then move to the actual implementation.
I also might be getting the hang of the whole OOP thing, but I might also be doing it all wrong, who knows.
So, how will I handle drawing the textboxes? Well, I have decided that each textbox will draw itself onto a Image, that will then be drawn on the actual screen.
I started by drawing the box border. This would not be problematic, but I decided to make the textboxes shaped like this:
------------------ | some text here \ | \ | and some more text| | here | | | | | | | | | | | | | | | \ | \__________________|
I tried to draw the border with a bunch of lines, but they do not connect nicely and there are gaps in the angles. I will probably rework it later, but I'd call that good enough for the time being.
Now to writing text. First, Raylib can draw multi-line strings, but keeps too big gaps between the lines. For this reason, I'd recommend to handle splitting strings into lines manually. Pascal has the SplitString function, but you have to include 'strutils' and 'types'. I'm actually not sure if you can make one unit export something included from another unit, but it sounds like a useful feature...
With this, I have the power to write text onto my texture, but now the text overflows the cut corners. I don't want to keep padding the size of the cutout, as that would look ugly. Raylib itself does not have any nice way to do masks like some other libraries have, so I will have to get creative.
My mind immediately went to doom and the like. Doom texture files do not have any transparency. Instead, they just fill all pixels that should be transparent with a special shade of purple (RGBA: 255, 0, 255, 255) that is then not rendered. Welp, I already have an alpha discard shader, so why not add a purple discard one?
And so I did!
Now I just have to draw purple triangles in the areas of the texture that should be transparent t and I have nice cut corners.
For now, only the 'WIKI' entry displays something, but hey, it's at least some progress.
Well, you know how I said that this is not supposed to be a game, but an experiment? Well, it still stands. I mainly wanted to try out Pascal and write some things I have not written before. I would still like to do some more things, but I will allow myself to get distracted from this project if I feel like it.
There is still a lot of going on and there are other things I would like to try, so the development of this project will get sacrificed a bit.