Drastic modifications:
commit50f386d8254fa59a0023f3d0623968fc552b6c87
authordwk <dwk@b022f027-f587-4676-bc72-f0cf7b603704>
Sun, 6 Jan 2008 01:57:26 +0000 (6 01:57 +0000)
committerdwk <dwk@b022f027-f587-4676-bc72-f0cf7b603704>
Sun, 6 Jan 2008 01:57:26 +0000 (6 01:57 +0000)
treeff9ba69023140fa42f57ab88cecc02f073442b76
parent8bf785d86f60f83f593284b0e9a262c0139a6cbb
Drastic modifications:
- Introduced a new widget type: panel. Everything a now a widget, and data/gui.xml reflects this: there is no longer a <panel> tag, only <widget>s. struct gui_t now contains a single panel instead of an array of them, because that single panel can contain other panels. Panels do not have a union member in widget_t::p -- rather, they use widget_t::compose instead.
- Removed  widget IDs entirely. Widgets are now referenced by name, strings, although click-detection is still in progress. The way options.c has it (and gui.c's supporting code) works but is rather inefficient.
- Added a base member to widget_t, which points up the widget tree. This allows the gui data structure to be traversed in reverse, useful, for example, for discovering the listbox that a scrollbar belongs to.
- Added another new member to widget_t, selable. If selable is 0, the widget cannot be selected. Useful for text that never needs to be selected, or for buttons -- the text on the button can be set to un-selable, allowing the button underneath, completely covered by the label, to be selected instead.
- Added another new widget type, label. Labels come in three flavours: pointers to SDL_Surfaces which are not resized, like the main menu's clouds; images (resize_image_t) which are resized; and text which is generated from a string in the right point size when necessary. These three might be broken up into separate widget types in the future.
- Made buttons a composite widget. Rather than having their own fonts and strings and SDL_Surfaces, buttons now contain a label widget.
- Made widget_t::pos and widget_t::compose pointers to dynamically allocated structures rather than component structures. It's likely that widget_t::pos will be changed back to a structure, since it is present in every widget; but making widget_t::compose a pointer has likely reduced memory consumption significantly.
- Eliminated allocate_widget_p(). init_*() (like init_button()) now have most of the code that was in this function. For example, the init_*() functions now allocate the widget_t::p structures.

Supporting changes:
- Made load_resource_widgets() recursive, as it needs to be to handle nested widgets. It's recursive directly and indirectly (via add_resource_widget()). This function is also only called once now (from xuni.c); all panels found are automatically loaded. The panel_type_t structure now has a real chance of not being the same as the actual data, and ought to be replaced with string lookups.
- Made the fontsample of options.c external, in gui/data.xml. It doesn't work exactly the same yet, however, because label widgets always have centred text, and fontsample is not supposed to.

Minor changes:
- Screenshot saving via the printscreen key: see save_screenshot().
- Added temporary code to loop.c to fix the bug where when the window is resized, xuni sometimes think it has lost focus when it in fact has not.
- Made the options:graphics textbox work properly. Before, it wasn't being updated when its text changed.
- Made resource.c use fread() instead of fgets(). It's a bit more efficient now, since fgets() only reads a line at a time, but this fread() call reads BUFSIZ characters. Many (actually, all!) XML files are read in one call to this function, with BUFSIZ as 8192. (It can be as low as 512, but that's still better than fgets().)

Maintenence and refactoring:
- Made render_white_text() handle NULL parameters.
- Removed some commented-out code in error.h.
- Moved some functions from graphics.c to gui.c.
- Tried to optimise blit_surface_repeat_area().
- Changed the large switch statement in rescale_widget() into a function call from an array of function pointers.
- Modified src/Makefile (without updating src/Makewin!), mostly to make the "clean" and "wc" targets work properly.
- Replaced some printf() error messages with calls to log_message().
- Added some free() calls to resource.c -- it had some memory leaks, which Valgrind detected.

Miscellaneous:
- Modified TODO somewhat.
- Modified the properties of ./ and dist/.
- Created unusual_screen_ratio(), free_smode(), allocate_panel(), init_panel(), etc.
- The source code for xuni is now over 6100 lines long! (And this commit message is over 4 KB . . . .)
21 files changed:
TODO
gui/data.xml
src/Makefile
src/Makewin
src/error.h
src/font.c
src/game.c
src/game.h
src/graphics.c
src/graphics.h
src/gui.c
src/gui.h
src/loop.c
src/loop.h
src/menu.c
src/menu.h
src/options.c
src/options.h
src/resource.c
src/resource.h
src/xuni.c