Moved the error handling functions from xuni.c into the new file error.c, and re-wrote them, and re-wrote them again. The latest error handling interface is contained in one public function, log_message(). log_message() is quite flexible and takes a variable number of arguments, so that error messages can be much more specific. It takes different error types and flags to customize the errors.
Translated all calls to print_warning() and fatal_error() into calls to log_message(), making many of the error messages more specific in the process.
Added support for using the 8x8 hard-coded monospace SDL_gfx font when no external fonts could be loaded. There are still some issues with it -- for example, the created text surfaces have to be semi-transparent with an annoying background, since stringColor() and stringRGBA() (SDL_gfx functions) use their alpha component as an existing percentage of the existing alpha channel -- e.g., the background has to be at least as opaque as the text.
Added new_surface(), which is required for the built-in font support, since the SDL_gfx text functions blit to an existing surface rather than returning a new one, as SDL_ttf does.
Added font_string_width(), which is just like TTF_FontWidth(), but works for the built-in font as well. The code which uses this could be a lot more efficient, though.
xuni now runs with no external resources, just the executable -- though it doesn't look very good.
Got rid of the SDL_EnableUNICODE(-1) checks and just set the UNICODE translation directly; examining the SDL source code showed that this was more efficient.
Ran xuni through splint, which resulted in a few minor changes to the source code -- like some casts to (int).
Changed the return type of render_restricted_text() from int to size_t.
Fixed a bug in load_theme(), where the scrollbar resizing code was using the dimensions of the cursor -- and crashed when the cursor could not be loaded.
Spaced out the system header files from the library header files from my own header files with a single newline.
Modified TODO slightly.
Removed some commented-out code.
Some of the gui code messes up in screen modes with extreme ratios -- very tall or very wide. The fault lies mainly with paint_box().
21 files changed: