Commit Graph

107 Commits

Author SHA1 Message Date
Xavier Del Campo Romero 79c0164c21 Create cdroot directory on common CMakeLists.txt 2022-07-23 04:23:05 +02:00
Xavier Del Campo Romero 7a6f5cd2e6 README.md: Document dependencies for Ubuntu builds 2022-07-23 04:16:57 +02:00
Xavier Del Campo Romero 6b46057728 CMakeLists.txt: Define rts as a C-only project
While it is true "extern C" is used on all headers, there is no need for
CMake to check the C++ compiler.
2022-07-23 04:16:57 +02:00
Xavier Del Campo Romero f753ede740 SDL-1.2: Implement X mirroring for quads 2022-07-15 01:35:46 +02:00
Xavier Del Campo Romero 2d22b88695 Import SDL_gfx 2022-07-15 01:03:36 +02:00
Xavier Del Campo Romero 360ea710e0 Implement FindSDL_gfx.cmake
Surprisingly, as of today (July 2022) CMake ships with FindSDL*.cmake
files for several SDL libraries such as SDL_mixer or SDL_image, but not
for SDL_gfx, so one was created, based on FindSDL_mixer.cmake.

Reference:
8a3004d5c2/Modules/FindSDL_mixer.cmake
2022-07-15 01:03:36 +02:00
Xavier Del Campo Romero 96dbdea21e gui: Update elements in reverse order
This allows to calculate dimensions for containers with children
containers in it.
2022-07-15 01:03:36 +02:00
Xavier Del Campo Romero 1ea5a4d4a4 Deprecate memset(3) in favour of C99 compound literals 2022-07-15 01:03:31 +02:00
Xavier Del Campo Romero e636accfd5 Allow children of gui_container be resized anytime
So far, their position inside the container was determined when
initializing the interface. However, if a child were resized
afterwards, the container would not adjust its elements accordingly.
Moreover, the implementation for gui_container relied on hacking the
children's X/Y coordinates, which could only be done once.

Now, two additional members have been added to gui_common so that
specific X/Y offset can be determined by the parent, additionally to the
traditional rules followed by gui_coords. Despite the extra memory
footprint, it now allows containers to set specific X/Y offsets for
their children on every game cycle.
2022-07-10 00:26:48 +02:00
Xavier Del Campo Romero 08951d4af5 Implement join/host and game cfg menus 2022-07-07 02:45:23 +02:00
Xavier Del Campo Romero c9dee333fe Implement system_can_exit 2022-07-07 02:45:23 +02:00
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