Commit Graph

146 Commits

Author SHA1 Message Date
Xavier Del Campo Romero 251bd41c44 Allow multiple button types 2022-07-07 02:37:25 +02:00
Xavier Del Campo Romero a0363cef85 button.c: fix wrong function call 2022-07-07 02:37:25 +02:00
Xavier Del Campo Romero 4f714af054 rounded_rect.h: fix typo 2022-07-07 02:37:25 +02:00
Xavier Del Campo Romero bebf6d6b5f font.c: set null dimensions on null str 2022-07-02 04:50:50 +02:00
Xavier Del Campo Romero 7bc58ab0e6 human_player_gui.c: use gui_container for top gui_bar 2022-07-02 04:47:50 +02:00
Xavier Del Campo Romero 7325906351 gui/container: support spacing between GUI elements 2022-07-02 04:42:41 +02:00
Xavier Del Campo Romero 93d2c39b1b gui/bar: support arbitrary x/y and width 2022-07-02 04:41:22 +02:00
Xavier Del Campo Romero b0eb562b9b gui: reuse callback data
There is no need to allocate memory for these callbacks for each single
GUI element. Instead, a single, statically-allocated instance can be
shared among all GUI elements of a given type.
2022-07-02 04:08:35 +02:00
Xavier Del Campo Romero a71ce37929 menu: implement main menu using new GUI improvements 2022-07-02 00:58:50 +02:00
Xavier Del Campo Romero e68c2fb4be gui: implement container
Containers, somewhat inspired by GtkBox, allow to packed other GUI
elements into a single row or column.
2022-07-02 00:53:03 +02:00
Xavier Del Campo Romero 04b9219ee5 button.c: h/v-center child label by default 2022-07-02 00:50:26 +02:00
Xavier Del Campo Romero 033ed5fb94 gui.c: fix wrong logic on gui_coords
The older logic would iterate for all parents, where each parent would
again iterate for all of its parents, until no more parents found.
This is however not needed, since only inspecting the closest parent
will already cause the (recursive) algorithm to iterate for all parents.
2022-07-02 00:49:36 +02:00
Xavier Del Campo Romero ec9f41f1ab gui: allow custom add_child callback 2022-07-02 00:45:51 +02:00
Xavier Del Campo Romero d55fb31e21 host.cmake, win9x.cmake: fetch libfixmath if missing 2022-06-30 22:49:35 +02:00
Xavier Del Campo Romero c4a24800b8 menu.c: center play button on screen 2022-06-29 01:01:31 +02:00
Xavier Del Campo Romero 391c8958b1 button.c: fail on negative width 2022-06-29 01:01:03 +02:00
Xavier Del Campo Romero cff35e88f5 gui: implement {h,v}centered 2022-06-29 00:39:06 +02:00
Xavier Del Campo Romero 23f24016da font: implement font_dim 2022-06-29 00:27:33 +02:00
Xavier Del Campo Romero 6d5aa57e6d Deprecate memset(3) for zero-init 2022-06-27 21:56:43 +02:00
Xavier Del Campo Romero a746ecd0b6 human_player_gui.c: fix segfault when selecting one unit
Checking against `sel` is just plain wrong, since it always expected to
be non-NULL, since `h->sel` is an array defined in `struct
human_player`. Instead, `sel->d.i` is the pointer that should be
checked.
2022-06-27 21:43:32 +02:00
Xavier Del Campo Romero e869bfd0f6 human_player: deprecate memset(3) for zero-init 2022-06-26 23:42:48 +02:00
Xavier Del Campo Romero 4305732e0a human_player.c: reset deselected instances 2022-06-26 23:42:48 +02:00
Xavier Del Campo Romero 7196c6a0cc Fix hp bar not being displayed when carrying 2022-06-26 23:42:34 +02:00
Xavier Del Campo Romero afc554167e ps1/heap.c: bump heap size 2022-06-26 21:51:51 +02:00
Xavier Del Campo Romero c401b7663d Implement main menu 2022-06-26 21:51:47 +02:00
Xavier Del Campo Romero 70bc98f96c terrain: fix wrong rendering
The older implementation would leave empty areas on the right side of
the screen.
2022-06-26 20:00:27 +02:00
Xavier Del Campo Romero ad1d6b1f66 font: deprecate font_printf
This function is no longer needed since `gui` was revamped.
2022-06-26 20:00:27 +02:00
Xavier Del Campo Romero 7c75118429 Revamp gui component
`gui` was tighly coupled to game logic, and could not be extended for
other purposes. Therefore, a generic GUI implementation, loosely
inspired by well-known GUI frameworks such as GTK, is now provided, with
the following properties:

- Does not depend on dynamic or static memory allocation, only automatic
(i.e., stack) memory allocation required.
- Portable among existing implementations.
- Simple to extend.
- Tiny memory footprint.

`gui` is now composed by GUI elements that can be chained to form a tree
structure. This is useful e.g.: to calculate X/Y coordinates for a given
GUI element given its parent(s).

This commit also refactors the older implementation, moving
game-specific logic into `player` and making use of the new component.
2022-06-26 20:00:27 +02:00
Xavier Del Campo Romero f17c76c400 font: add font_puts 2022-06-26 20:00:27 +02:00
Xavier Del Campo Romero 2c5973ee7e peripheral.c: initialize common members only
Other members will be initialized according to peripheral configuration.
2022-06-26 20:00:27 +02:00
Xavier Del Campo Romero f938bb790e Deprecate memset(3) over C99 compound literals for zero-init
Using memset(3) does not ensure pointers are assigned to NULL for all
platforms.
2022-06-26 20:00:27 +02:00
Xavier Del Campo Romero eee1205446 player: limit data sizes for resources and population
- All platforms should allow for the same resources.
- Population is not expected to exceed UCHAR_MAX on any platform.
2022-06-26 19:58:46 +02:00
Xavier Del Campo Romero 9da37c198e camera: implement fixed cursor movement
On platforms with PERIPHERAL_TYPE_PAD, navigating through menus and
options can be cumbersome if moving the cursor freely around the
screen.

Therefore, this commit instead defines a list of (X, Y) coordinates that
the cursor can jump to. The implementation also attempts to guess which
direction the cursor should jump to for the previous/next point, and
hence determine which button should be pressed by the user.
2022-06-24 17:45:50 +02:00
Xavier Del Campo Romero 8ddea5eef5 camera.c: refactor cursor_init
So that uninitialized members are set to 0.
2022-06-24 17:45:14 +02:00
Xavier Del Campo Romero 992e7fb935 peripheral: provide common actions
Whereas some actions are context-specific (e.g.: selecting a player),
some are context-independent and can be executed for all screens
(e.g.: exiting the game).
2022-06-24 17:28:38 +02:00
Xavier Del Campo Romero 5ac01ff845 README.md: add copyright notice 2022-06-24 17:20:05 +02:00
Xavier Del Campo Romero d140dcd278 README.md: update according to current status 2022-06-24 17:19:27 +02:00
Xavier Del Campo Romero c831272f29 cmake/ps1.cmake: use add_library for libpsx.a 2022-06-19 03:51:36 +02:00
Xavier Del Campo Romero 7c1795401b Deprecate <TARGET>_BUILD in favor of CMAKE_TOOLCHAIN_FILE 2022-06-19 03:09:28 +02:00
Xavier Del Campo Romero 3cb276b19f camera: remove dependency against terrain
This will allow using camera for purposes other than showing the game
map.
2022-06-12 23:19:03 +02:00
Xavier Del Campo Romero 0f9e2d8958 Split peripheral-related logic into its own component
This has several advantages:

- `camera` no longer needs to define public functions for each
peripheral type.
- Peripheral-related is now no longer tighly coupled to human_player,
so peripheral logic can be reused elsewhere e.g.: on menus.
- Makes camera_update_touch consistent compared to equivalent functions,
since now `pan` has now been moved to `camera` (as it should be).
2022-06-12 23:18:57 +02:00
Xavier Del Campo Romero 5794dbf403 CMakeLists.txt: limit libraries linked to by ${PROJECT_NAME}
Old behaviour was linking to all components, but main.c currently only
needs a few of them.
2022-06-12 00:00:56 +02:00
Xavier Del Campo Romero a826c2364d sdl-1.2/sound.c: use SDL_WasInit 2022-06-11 23:42:30 +02:00
Xavier Del Campo Romero 3f6bf6aa1a sdl-1.2: return to original dimensions on fullscreen exit 2022-06-11 23:42:30 +02:00
Xavier Del Campo Romero a84a55aa25 Implement button component 2022-06-11 23:42:27 +02:00
Xavier Del Campo Romero 9b75ff3c2e res: add btn_{left,mid,right} 2022-06-11 23:41:56 +02:00
Xavier Del Campo Romero c8362184ee res/CMakeLists.txt: do not use transparency for sel_mid_v 2022-06-11 23:11:49 +02:00
Xavier Del Campo Romero 5464a50f96 README.md: reflect current status 2022-06-08 01:00:32 +02:00
Xavier Del Campo Romero 0517c897c5 win9x.cmake: remove unneeded dependencies 2022-06-08 00:36:26 +02:00
Xavier Del Campo Romero 99bb23e194 win9x.cmake: use target commands for SDL and SDL_mixer
Since libSDL.a and libSDL_mixer.a are compiled separately from this
project, some hacks had been used to get the build running. However,
this approach did not make proper use of target-level properties, which
are encouraged according to modern CMake standards over global-level
commands such as include_directories() or link_libraries().

OTOH, Win32 dependencies were being imported using link_libraries(), but
they in fact are SDL dependencies, so target_link_libraries() can be
used instead.
2022-06-08 00:36:26 +02:00