Commit Graph

103 Commits

Author SHA1 Message Date
Xavier Del Campo Romero b4c08b585c net.h: Add missing extern "C" 2022-09-23 04:39:36 +02:00
Xavier Del Campo Romero e6ae88aa87 input.c: do not fail on input_render
Implementation is still incomplete, and should not crash the
application.
2022-09-23 04:38:33 +02:00
Xavier Del Campo Romero eed4687120 join_menu.c: Update serial/IPv4 GUI menus 2022-09-23 04:38:33 +02:00
Xavier Del Campo Romero 6f5058c584 ps1/net.c: return 0 on net_init
Even if the implementation is not finished yet, this will avoid the
program from crashing on startup.
2022-09-23 04:38:33 +02:00
Xavier Del Campo Romero 8435b3f5fd net: Implement net_available 2022-09-23 04:38:33 +02:00
Xavier Del Campo Romero b108afb6e7 net: Implement net_serial_devices
This function provides a platform-specific list of serial devices that
can be accessed.
2022-09-23 04:38:20 +02:00
Xavier Del Campo Romero 26692e8cb9 keyboard: Add KEYBOARD_KEY_SLASH 2022-09-23 04:20:57 +02:00
Xavier Del Campo Romero f8c74babda label.c: Set empty text by default
This will avoid crashing the application on rendering due to
uninitialized labels.
2022-09-23 04:20:13 +02:00
Xavier Del Campo Romero 9e308d97d9 gui.c: Remove unneeded condition
Even if neither hcentered or vcentered are used, GUI element position
must be determined by that of its parents.
2022-09-23 04:18:20 +02:00
Xavier Del Campo Romero 68ccd085fc gui.c: Fix minor const-correctness issues 2022-09-23 04:17:44 +02:00
Xavier Del Campo Romero d989dc6f49 gui: Allow elements to be hidden
When a GUI element is hidden, no rendering or updating is done to it or
its children. This can be useful to define a complex GUI tree structure
that changes under specific conditions, without redefining it.
2022-09-23 04:15:55 +02:00
Xavier Del Campo Romero d0089e7ddf gfx: Provide functions for fullscreen handling 2022-09-23 04:12:56 +02:00
Xavier Del Campo Romero 9d3e754f36 Implement checkbox GUI element 2022-09-23 04:12:07 +02:00
Xavier Del Campo Romero 467f09e952 net: Group events into struct 2022-09-21 18:27:58 +02:00
Xavier Del Campo Romero 85d4af0266 gui: fix wrong logic on update/render/deinit
The older implementation caused some elements to be
update/rendered/deinitialized more than once per call. For example,
considering the following tree of GUI elements:

A
    B
    C
        D
    E

The older implementation would update/render/deinitialize C and E more
than once, as shown below:

Update A
Update B
Update C
Update D
Update E
Update C

This was because a GUI element was acting on its siblings, but the
siblings would also act on theirs, causing the extra calls.

OTOH, as an additional improvement, no nested call is now required for
siblings.
2022-09-21 18:14:44 +02:00
Xavier Del Campo Romero 3eef29c327 menu: Implement join_menu 2022-09-20 17:34:25 +02:00
Xavier Del Campo Romero 8f9737b776 Implement GUI line edit 2022-09-20 17:34:25 +02:00
Xavier Del Campo Romero e3356fde2d gui: Implement gui_deinit 2022-09-20 17:34:25 +02:00
Xavier Del Campo Romero 84c834c000 Implement net component 2022-09-20 17:34:21 +02:00
Xavier Del Campo Romero 4c5630b0d4 Remap calls to pad/mouse/keyboard to input 2022-09-20 16:56:30 +02:00
Xavier Del Campo Romero 684587a3c3 Implement input component
It is required to redirect keyboard input (both physical or not) when
a GUI line edit is focused. This means other components cannot be
activated on key presses.

Therefore, this new component is meant as a higher-level abstraction
compared to the `keyboard`/`pad`/`mouse` components, which:

- Implements the same APIs provided by `keyboard`, `mouse` and `pad`.
- Returns the same results as the APIs above if no GUI element is
focused, no input otherwise.

Note: replacing calls to `keyboard`/`pad`/`mouse` with `input` will be
implemented in a future commit.
2022-09-20 13:52:14 +02:00
Xavier Del Campo Romero b8d3eff412 keyboard: Add new public functions
These will be used by future commits.
2022-09-20 13:52:14 +02:00
Xavier Del Campo Romero ade4a509e9 Minor code style fixes 2022-09-20 13:51:08 +02:00
Xavier Del Campo Romero a3f167ee04 sdl-1.2: Remap missing keyboard keys 2022-09-20 12:30:06 +02:00
Xavier Del Campo Romero 481a312e76 keyboard_key.h: add more keys 2022-09-20 12:29:45 +02:00
Xavier Del Campo Romero b8def012d5 sdl-1.2: Remap SDLK_ESCAPE to KEYBOARD_KEY_ESC 2022-09-16 20:35:04 +02:00
Xavier Del Campo Romero 76a49ba3d5 mouse.c: Reduce threshold 2022-09-16 20:33:39 +02:00
Xavier Del Campo Romero da22c8d922 Split CMakeLists.txt for src 2022-09-16 20:29:47 +02:00
Xavier Del Campo Romero 5829ef82c4 Use find_package for SDL libraries
CMake already distributes FindSDL*.cmake files for SDL and SDL_mixer,
which support custom prefixes via environment variables, removing the
need for ad-hoc logic in Win9x builds.

Also, according to FindSDL.cmake, #include <SDL.h> is the preferred way
for portability reasons, instead of #include <SDL/SDL.h>, which is the
option that has been used so far.
2022-07-23 04:23:05 +02:00
Xavier Del Campo Romero f9e46c950f ps1: Use exported target PSXSDK::PSXSDK 2022-07-23 04:23:05 +02:00
Xavier Del Campo Romero c37cd892a0 system/CMakeLists.txt: group common private dependencies into var 2022-07-23 04:23:05 +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 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