Commit Graph

118 Commits

Author SHA1 Message Date
Bill Currie 99e12872e5 [console] Get menu rendering working again
For certain values of working. The whole thing needs a rewrite but it's
nice that using an ECS doesn't force everything to conform to that
model.
2022-11-04 10:38:07 +09:00
Bill Currie 817aeb334e [ui] Convert view_t to an ECS entity
Much of the nq/qw HUD system is quite broken, but the basic status bar
seems to be working nicely. As is the console (both client and server).
Possibly the biggest benefit is separating the rendering of HUD elements
from the updating of them, and much less traversing of invisible views
whose only purpose is to control the positioning of the visible views.

The view flow tests are currently disabled until I adapt the flow code
to ECS.

There seems to be a problem with view resizing in that some gravities
don't follow resizing correctly.
2022-11-01 00:40:52 +09:00
Bill Currie 48e5848a41 [console] Rework con_buffer ring buffers to have gaps
I really don't know why I tried to do ring-buffers without gaps, the
code complication is just not worth the tiny savings in memory. In fact,
just the switch from pointers to 32-bit offsets saves more memory than
not having gaps (on 64-bit systems, no change on 32-bit).
2022-09-18 11:35:09 +09:00
Bill Currie 12c84046f3 [cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.

As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.

The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).

While not used yet (partly due to working out the design), cvars can
have a validation function.

Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.

nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-24 19:15:22 +09:00
Bill Currie 63e5655f68 Clean up some enum sanity checks
It seems clang defaults to unsigned for enums. Interestingly, gcc was ok
with the checks being either way. I guess gcc treats enums that *can* be
unsigned as DWIM.
2022-03-31 00:18:53 +09:00
Bill Currie ee51d06aa3 [renderer] Clean up a lot of recalc_refdef use
I think the widespread use of recalc_refdef (and force_fullscreen) was
the result of a rushed merge of the renderer and video code (I do seem
to remember sprinkling them around). This cleans the two out of the
client code.
2022-03-19 00:56:30 +09:00
Bill Currie db8cf68ef3 [gamecode] Pass registered data pointer to builtins
This is the bulk of the work for recording the resource pointer with
with builtin data. I don't know how much of a difference it makes for
most things, but it's probably pretty big for qwaq-curses due to the
very high number of calls to the curses builtins.

Closes #26
2022-02-14 12:28:38 +09:00
Bill Currie 01345ba675 [gamecode] Wrap most uses of PR_RESET_PARAMS with push/pop frame
rua_obj was skipped because that looks to be a bit more work and should
be a separate commit.

This is to avoid the stack getting mangled when calling progs functions
with parameters.
2022-02-05 10:26:47 +09:00
Bill Currie 2a8fca80a0 [nq,qw] Give the menu and server progs stacks
They're going to need them :P
2022-02-04 21:53:37 +09:00
Bill Currie 9c51c3d2e1 [gamecode] Add a data pointer passed to builtin functions
This is part of the work for #26 (Record resource pointer with builtin
function data). Currently, the data pointer gets as far as the
per-instance VM function table (I don't feel like tackling the job of
converting all the builtin functions tonight). All the builtin modules
that register a resources data block pass that block on to
PR_RegisterBuiltins.
2022-01-24 00:20:05 +09:00
Bill Currie a6b932025c [gamecode] Provide builtins with information about their parameters
This will make it possible for the engine to set up their parameter
pointers when running Ruamoko progs. At this stage, it doesn't matter
*too* much, except for varargs functions, because no builtin yet takes
anything larger than a float quaternion, but it will be critical when
double or long vec3 and vec4 values are passed.
2022-01-23 22:27:27 +09:00
Bill Currie e9e54d08c0 [gamecode] Rename func_t to pr_func_t
Even more consistency.
2022-01-18 15:36:58 +09:00
Bill Currie 2b82533526 [gamecode] Add double time state instructions
This has been a long-held wishlist item, really, and I thought I might
as well take the opportunity to add the instructions. The double
versions of STATE require both the nextthink field and time global to be
double (but they're not resolved properly yet: marked with
"FIXME double time" comments).

Also, the frame number for double time state is integer rather than
float.
2022-01-16 21:27:49 +09:00
Bill Currie 33e48025dd [ruamoko] Replace rua_key with rua_input
And create rua_game to coordinate other game builtins.

Menus are broken for key handling, but have been since the input rewrite
anyway. rua_input adds the ability to create buttons and axes (but not
destroy them). More work needs to be done to flesh things out, though.
2021-12-24 06:45:13 +09:00
Bill Currie b0447c1cf1 [console] Get message modes and menus working again
I'm not at all happy with con_message and con_menu, but fixing them
properly will take a rework of the menus (planned, though). Also, the
Menu_ console command implementations are a bit iffy and could also do
with a rewrite (probably part of the rest of the menu rework) or just
nuking (they were part of Johnny on Flame's work, so I suspect had
something to do with joystick bindings).
2021-11-28 23:21:55 +09:00
Bill Currie 4898a44263 [console] Hook up new input system
This has smashed the keydest handling for many things, and bindings, but
seems to be a good start with the new input system: the console in
qw-client-x11 is usable (keyboard-only).

The button and axis values have been removed from the knum_t enum as
mouse events are separate from key events, and other button and axis
inputs will be handled separately.

keys.c has been disabled in the build as it is obsolute (thus much of
the breakage).
2021-11-08 11:20:04 +09:00
Bill Currie 632d2cb79c [console] Plug another escape handler leak 2021-07-24 00:28:49 +09:00
Bill Currie fbbf83e696 [console] Pop menu escape in forced close menu
Fixes loss of access to the menu after selecting a new game via the menu.
2021-07-23 21:15:01 +09:00
Bill Currie 3b586fc0a6 [console] Untangle console and menu toggling
The recent changes to key handling broke using escape to get out of the
console (escape would toggle between console and menu). Thus take care
of the menu (escape) part of the coupling FIXME by implementing a
callback for the escape key (and removing key_togglemenu) and sorting
out the escape key handling in console. Seems to work nicely
2021-07-23 02:28:37 +09:00
Bill Currie e81d690b51 [input] Create QF input library using keys.c
This refactors (as such) keys.c so that it no longer depends on console
or gib, and pulls keys out of video targets. The eventual plan is to
move all high-level general input handling into libQFinput, and probably
low-level (eg, /dev/input handling for joysticks etc on Linux).

Fixes #8
2021-07-05 16:26:07 +09:00
Bill Currie 813497a1aa [ui] Create library for UI support code
Currently this has text buffer, input line, vrect and view code.
2021-06-12 22:50:51 +09:00
Bill Currie dac9166339 [nq] Sort out some of the issues with keydest
Switches to "game" properly when starting a new game after playing
menus. Of course, basic bindings are still broken in "demo".
2021-03-29 22:39:43 +09:00
Bill Currie df89e37afc [console] Call PR_RunPostLoadFuncs
This fixes the segfault when loading the menu progs. I had forgotten
that the menu code doesn't use PR_LoadProgs (I don't remember why.
Obsolete reason?).
2020-06-24 22:47:12 +09:00
Bill Currie 4cef9792f4 [util] Make hash-tables semi-thread-safe
They take a pointer to a free-list used for hashlinks so the hashlink
pools can be per-thread. However, hash tables that are not updated are
always thread-safe, so this affects only updates. progs_t has been set
up such that it is easy for multiple progs within one thread can share
hashlinks.
2020-03-25 15:43:16 +09:00
Bill Currie a55b9544ac Improve handling of pr_argc
It is now set to 0 when progs are loaded and every time
PR_ExecuteProgram() returns. This takes care of the default case, but
when setting parameters, pr_argc needs to be set correctly in case a
vararg function is called.
2020-02-25 17:36:29 +09:00
Bill Currie 4b7ecdf74a Make PR_Init take an instance to initialize
This allows internal sub-systems to do per-instance initializations
without other engine systems having to know about them.
2020-02-23 18:32:16 +09:00
Bill Currie 81083698a8 Move to using an in-memory form of ddef_t
This allows the VM to work with extended ddefs transparently. It seems
to have uncovered a typedef alias relocation bug, though.
2020-02-22 22:33:44 +09:00
Bill Currie c296514b95 Make pr.load_file 'return' the file size 2020-02-21 21:17:28 +09:00
Bill Currie 82809eb856 Simplify the call to PR_LoadProgsFile.
I've decided that setting pr.max_edicts and pr.zone_size as part of the
local progs initialization rather than in PR_LoadProgsFile makes more
sense. For one, it is unlikely for the limits to change every time progs is
reloaded. Also, they seem to be a property of the VM rather than the progs.
However, there is nothing stopping the caller from updating max_edicts and
zone_size every call.
2018-10-11 10:06:48 +09:00
Bill Currie 3efb0c538f Separate file search from loading.
QFS_LoadFile (and its wrappers) now  take a file handle rather than a
path. This will make vpath usage a little cleaner to implement.
2014-01-28 16:22:05 +09:00
Johnny on Flame e3e0d6aaa9 Add menu commands + fixes 2013-01-27 13:17:13 +09:00
Bill Currie 8975dd95fe Recalculate the refdef when leaving a menu.
A tad brute force, but this should fix the status bar not refreshing when
exiting the menus.
2013-01-16 15:40:47 +09:00
Bill Currie cf5a3d805b Ensure menu is valid before doing anything. 2013-01-13 21:49:43 +09:00
Bill Currie e8450f6c97 Add builtins to handle menu next/prev/enter. 2013-01-13 18:53:21 +09:00
Bill Currie ec42bde527 Make hash tables more const correct.
And clean up the resulting mess :/
2012-10-27 11:44:31 +09:00
Bill Currie bc1b483525 Nuke the rcsid stuff.
It's pretty useless in git.
2012-04-22 10:56:32 +09:00
Bill Currie ab486dcdf6 Unregister the quit command before registering it.
This fixes the quit menu not working.
2012-04-12 15:07:28 +09:00
Bill Currie 6ff658afe4 Use r_funcs in the client console plugin.
Getting the sw renderer's functions when running gl was nasty.
2012-04-11 16:38:15 +09:00
Bill Currie ce6ab908a5 Don't include the specific plugin headers in plugin.h.
This lets files that use plugins not depend on plugins they don't use.
2012-02-13 22:02:07 +09:00
Bill Currie c3d41326b3 Do key dest changing properly.
key_demo wasn't so well thought out. This seems to be much better (and nq
is known to be working nicely).
2011-12-10 16:14:25 +09:00
Bill Currie 84afc458fa Allow the menus to overide the Escape key. 2011-03-25 18:02:59 +09:00
Bill Currie bc0cffc9c6 Fix handling of autorelease pools in the menu code.
Create a "menu_pre" function that creates the autorelease pool, change
menu_post() to release the pool correctly, and make the menu internal code
require and call menu_pre.
2011-03-21 13:14:14 +09:00
Bill Currie 4518e6af91 First stab at implementing autorelease.
It's probably nowhere near right, but probably ok for now (I need to study
the GNUStep code). I'm unhappy with the menu code hook, but it will have
to do for now.
2010-11-24 17:01:18 +09:00
Bill Currie d66934942d nuke Con_Printf and Con_DPrintf and use Sys_* instead 2007-11-06 10:17:14 +00:00
Bill Currie d996c364b8 massively speedup savegame scanning (and bump the menu progs memory size again :/) 2007-05-13 03:56:08 +00:00
Bill Currie 72daa2fd2b add some sounds to the menus (not yet finished) 2007-05-07 12:17:12 +00:00
Bill Currie d8b701608c various cleanups (ow, my eyes hurt) 2007-04-07 05:06:42 +00:00
Bill Currie 4a421dbb49 scaning the new save files needs a lot more memory 2007-03-25 02:00:38 +00:00
Bill Currie 3fb03fc2be hah, should have been using __attribute__((used)) all that time (rather
than __attribute__((unused))). fixes the missing console in -x11
2005-08-04 15:27:09 +00:00
Bill Currie 762aefc9b1 implement Raven's calling convention (rcall: first 2 params in opb and
opc). should give a general speedup to most progs.
2005-06-12 09:54:01 +00:00