There are long or level messages in Teemu when you enter a level theme that has it. You have an option to turn them off so I thought it would be good to be able to view last five messages just as regular message buffer. Storing the messages to a list was the easy part, since it's just a std::list in World class.
Programming the display routine took more time. First I had to solve how the window size knows its height, because each long message has different amount of lines. The "formatted" text output routine Write_F actually returns the amount of lines, but the routine to count lines was inside it. Of course you could always detach that part to independent routine, but it's not always that easy when you have local variables. So what I did was just call Write_F for each message and store the amount of lines. Write_F doesn't show the messages unless update is called, so it didn't matter. After that I knew the amount of lines, displayed the window and then displayed messages again on top of that window. Done!
It took about an hour or possibly more to write that routine. A perfect example why roguelike programming is slow. A roguelike can have hundreds of features, all of them waiting for implementation. And not only that, you can break the underlying framework if you need something new for a feature. It can then break some other features. The framework is extremely important, but sometimes it doesn't support something you need and changing how the engine works can be really difficult. This already has happened in Teemu with events that were carelessly mixed in.
No comments:
Post a Comment