Commit graph

11312 commits

Author SHA1 Message Date
Kp 76cbd11956 Make kmatrix_window::event_handler cancel menu inherit from newmenu 2020-12-27 22:03:09 +00:00
Kp 115c38cd77 Remove kmatrix_poll2
After the previous commit, its only purpose is to automatically dismiss
the window after 3 seconds.  Users may be surprised by this, and the
automatic dismissal has limited value.  Remove it and let the user
remain at the cancel dialog until a decision is made.
2020-12-27 22:03:09 +00:00
Kp 479005b769 Remove call to dispatch->do_protocol_frame in kmatrix_poll2
The menu operated by kmatrix_poll2 exists only when the containing
kmatrix menu is also open.  kmatrix has its own call to
do_protocol_frame, so there is no need for another one here.
2020-12-27 22:03:09 +00:00
Kp 907c69dcb7 Skip some kmatrix logic when not in the foreground
Closing the kmatrix window while it is not in the foreground may cause a
use-after-free when it is closed again later, since the event loop can
reenter kmatrix_window::event_handler.  Skip the exit logic if the
window is not in the foreground, so that it remains open until it times
out while in the foreground.
2020-12-27 22:03:09 +00:00
Kp 80fc124a63 Remove unnecessary definitions of static member variables
C++17 permits, but deprecates, this form.  Remove it to simplify the
code.
2020-12-27 22:03:09 +00:00
Kp e7629f35ee Move newmenu_item::saved_text into the two sub-types that need it 2020-12-27 22:03:09 +00:00
Kp e6875641c9 Move Newmenu_allowed_chars into individual newmenu_item
Allowed characters are more properly scoped to a specific text entry
field.  Move them there to eliminate a global.
2020-12-27 22:03:09 +00:00
Kp 40501fa31e Make PlayerFinishedLevel menu inherit from newmenu 2020-12-27 22:03:09 +00:00
Kp 421959643c Make get_level_name menu inherit from newmenu 2020-12-27 22:03:09 +00:00
Kp 3e210a9ceb Make do_screen_message menu inherit from newmenu 2020-12-27 22:03:09 +00:00
Kp 1f8c8e355b Allow newmenu callers to choose whether to use a background box
Previously, callers chose whether to use a fullscreen background image,
and the newmenu code inferred that callers without a background image
wanted a background box, while those with a background image wanted no
box.  Change newmenu_layout to take a parameter specifying the caller's
intent, so that a caller can choose to have any combination of a
background image and a background box.
2020-12-27 22:03:09 +00:00
Kp c9d5d3be02 Fix buffer overflow on ill-formed briefing picture filename 2020-12-27 22:03:09 +00:00
Kp 1b58b82e81 Convert debug briefing menu to inherit from newmenu 2020-12-27 22:03:09 +00:00
Kp 2b9c146ff2 Convert glitz menu to inherit from newmenu
Add a static method to block until the menu closes, so that the glitz
menu can continue to block its caller.
2020-12-27 22:03:09 +00:00
Kp c0601edde3 Move GammaLevel to CCfg 2020-12-27 22:03:09 +00:00
Kp 3cbae9df31 Reset cockpit on leaving graphics menu
Calling gr_set_mode invalidates loaded fonts.  Avoid a use-after-free by
forcing a cockpit reset, which will reinitialize canvases that reference
the unloaded fonts.
2020-12-27 22:03:09 +00:00
Kp ba49ddd073 Remove spurious descent.cfg
This does not need to be in the repository, and was only ever touched by
automated bulk changes.
2020-12-27 22:03:09 +00:00
Kp 17b3812ee3 Make more_game_options_menu inherit from newmenu 2020-12-27 22:03:09 +00:00
Kp 9be9f7ae64 Pass grs_font& to show_time 2020-12-27 22:03:09 +00:00
Kp 318ed5b684 Simplify info_display_default
Commit 8a437a759c made show_all always
true.
2020-12-27 22:03:09 +00:00
Kp c3e2d1841c Simplify info_display_segsize
Commit 8a437a759c made show_all always
true.
2020-12-27 22:03:09 +00:00
Kp 7fde0a00a0 Simplify info_display_object_placement
Commit 8a437a759c changed the logic to
always set show_all to 1.  This renders the short-circuit logic in
info_display_object_placement irrelevant, as show_all will always force
the information to draw.  Remove the variables that were used to decide
whether a redraw was required.
2020-12-27 22:03:09 +00:00
Kp aaf4629c05 Fix potential canvas.cv_font / cv_font inconsistency in gr_ustring
A prior conversion changed the actual rendering to use the argument
cv_font, but still picked which render function to use based on the
flags for the active font.  Switch to use only the supplied font.
2020-12-27 22:03:09 +00:00
Kp a4f41f8360 Pass grs_canvas& to print_clock 2020-12-27 22:03:09 +00:00
Kp 9dd3f0dbf4 Pass grs_font& to nm_rstring 2020-12-27 22:03:09 +00:00
Kp 135ba07db4 Pass grs_font& to nm_string_inputbox 2020-12-27 22:03:09 +00:00
Kp 8b7e5ba04d Pass grs_font& to nm_string 2020-12-27 22:03:09 +00:00
Kp 0fa2afb6a6 Pass grs_font& to nm_string_slider 2020-12-27 22:03:09 +00:00
Kp d11f5c0cab Simplify newmenu font setup 2020-12-27 22:03:09 +00:00
Kp c1d6150015 Pass grs_font& to gr_set_curfont 2020-12-27 22:03:09 +00:00
Kp 916eb7a0f9 Extend DXX_CHECK_VAR_IS_DEFINED to work in ASan mode
When AddressSanitizer is enabled, include code to read from the checked
variable, to force AddressSanitizer to perform an accessibility check.
2020-12-27 22:03:09 +00:00
Kp effa7435c2 Remove newmenu_listbox1
It is no longer used.
2020-12-27 22:03:09 +00:00
Kp 7f2df64649 Make mission_menu inherit from listbox 2020-12-27 22:03:09 +00:00
Kp df3f695023 Make menu.cpp:browser inherit from listbox 2020-12-27 22:03:09 +00:00
Kp e6f6bb68a0 Use enum class for browser::select_dir 2020-12-27 22:03:09 +00:00
Kp fcb3607ac4 Shrink browser::select_dir, browser::new_path to uint8_t
These are flag values.  There is no need to store an int.
2020-12-27 22:03:09 +00:00
Kp 0c77bee1d9 Change PHYSFS_removeFromSearchPath to PHYSFS_unmount
Per the documentation, PHYSFS_removeFromSearchPath is a deprecated
wrapper for PHYSFS_unmount.  Call PHYSFS_unmount directly.
2020-12-27 22:03:09 +00:00
Kp fa648075a9 Change PHYSFS_addToSearchPath to PHYSFS_mount
Per the documentation, PHYSFS_addToSearchPath is a deprecated wrapper
for PHYSFS_mount.  Call PHYSFS_mount directly.
2020-12-27 22:03:09 +00:00
Kp 0c53d3a34f Replace PHYSFSX_isNewPath with !PHYSFS_getMountPoint
PHYSFSX_isNewPath retrieves from PhysFS a list of all paths, then
searches them, and frees them at the end.  PhysFS can search its own
list without needing the allocations, so delegate the work to it.
2020-12-27 22:03:09 +00:00
Kp 6211fd029a Simplify menu.cpp:browser
->when_selected is always get_absolute_path.  Remove the pointer and
replace the indirect calls with a direct reference.

->userdata is always a pointer to the buffer for get_absolute_path to
fill.  Change the type from `void *` to an appropriate reference.
2020-12-27 22:03:09 +00:00
Kp ae5ee376f3 Move music file picking behind USE_SDLMIXER
None of these functions are used when sdlmixer=0, but the recursive
usage prevented the compiler from reporting this.
2020-12-27 22:03:09 +00:00
Kp 079602b91a Inline string_array_t::tidy comparator
There is only one call, so the target can be moved into the
implementation.  This removes use of a call-by-pointer.
2020-12-27 22:03:09 +00:00
Kp ac97d00698 Remove support for PhysFS 1, PhysFS 2
The last PhysFS 1 release was in March 2009.  The last PhysFS 2 release
was in August 2017, shortly before the release of PhysFS 3 in September
2017.  Most distributions have moved to PhysFS 3.  Drop support for
PhysFS 1 and PhysFS 2.  PhysFS 2 support could be restored if there is
interest.
2020-12-27 22:03:09 +00:00
Kp 165d8c9d1c Make demo_selection_listbox inherit from listbox 2020-12-27 22:03:09 +00:00
Kp c7f5e91007 Make pilot_selection_listbox inherit from listbox 2020-12-26 21:17:29 +00:00
Kp 8cc209b566 Simplify listing player files at startup
Remove the use of qsort, since PhysFS sorts the result.  The PhysFS sort
is case-sensitive rather than insensitive as the qsort was, but this is
unlikely to matter for most users.

Avoid an unnecessary strlen.  The required data can be obtained from the
strchr.

Suppress player files that do not end in `.plr`.  PhysFS should not
return such a file, and if it did, later code would likely become
confused.  Hide such files from the user.
2020-12-26 21:17:29 +00:00
Kp 095d660c55 Inline listbox_get_window
It is only used once.
2020-12-26 21:17:29 +00:00
Kp def7e03260 Move listbox callback handling to a derived class 2020-12-26 21:17:29 +00:00
Kp f43e98764a Move listbox to newmenu.h 2020-12-26 21:17:29 +00:00
Kp f01c29c779 Flatten newmenu_do* hierarchy
There is now a single caller for newmenu_do3.  Inline do3 into do2, so
that do2 calls do4.  Mark do4 as static.
2020-12-26 21:17:29 +00:00