Cockpit_active was latched inside ship_render_player_ship(), which only
runs when Viewer_obj is non-null. External, chase, warp-chase, topdown,
free-camera and dead views all null Viewer_obj, so the flag froze at its
last cockpit-view value and cockpitinactive HUD gauges vanished. It was
also read before being written each frame (by the show-ship check and the
shadow helpers), so those decisions lagged a frame on any transition.
Replace it with three functions computed on demand:
- ship_cockpit_enabled(sip): the ship has a cockpit model and cockpits
aren't disabled; used by the Show_ship_only_if_cockpits_enabled checks
- ship_render_player_cockpit(sip): the above, outside topdown view;
replaces three duplicated copies of that expression
- ship_render_player_cockpit_active(): whether the viewer's cockpit is
being rendered this frame; used by the HUD cockpit-view-choice checks
With the predicate correct, the VM_CHASE special cases added for #4804
are no longer needed and are removed. In chase view, cockpitinactive
gauges now also respect pop-up state, No_ets, and setRenderOverride,
which the early return in HudGauge::canRender() used to bypass.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Reset the selected item when we open a new menu. This keeps the display state and internal state in sync if the player mixes arrow presses and number presses. Follow-up to #7688.
Convert MsgItems from an array to a vector, and remove the associated limit value and counter.
* vectorize msgitems
* appeasement
* leave me alone clang
* remove optional
* cleanup
* changes requested
* clang
* clang what is WRONG with you
* feedback
* remove flag in .h
The game settings flag '$Hide main Rearm/Repair items in Comms Gauge:' hides the 'Rearm and Repair' lines in the HUD Comms menu from appearing, which is useful for mods that do not have repair ships and thus those lines confuse players. Unfortunately, the newer `COMMS_MENU_SELECT` control bindings do not properly account for hidden menu items, so using those controls on a comms menu with 'Rearm and Repair' hidden means the selection index gets off and also confuses the player.
This PR fixes that by allowing `hud_squadmsg_selection_move_down()` and `hud_squadmsg_selection_move_up()` to skip hidden menu items. Tested and works as expected.
For folks using the COMMS_MENU_SELECT controls, there is also a current UI confusion when the comms menu is first brought up because the first item is selected, but the `Display_selector` does not show. Thus, players are unsure what item is actively selected even though one is actively selected. In the original comms menu select PR this was set to on by default, but then switched to off by default by a different developer a bit later. This choice is especially useful for mods that have many players with gamepads such as Event Horizon. Alternatively, mods that already have many number keys utilized for other gameplay aspects seem to prefer to keep the comms menu visuals as is and only show the selection if the player uses those keys. Given there is clearly arguments for both reasons, ideally modders should be able to choose how it displays for their own mods (always or off for the first pop-up of the Comms menu). Thus, this PR adds that as a cleanup game option, too. This also was tested and works as expected.
* Fix C4709 Warnings on latest VS
* more
* suppress false positive
* Switch to using any/none_of
* Address Feedback
* Fix Line endings?
* Fix commits and strip out flag_combinator
* more fixes
* nolint
* add wing display names
Adds display name capability for wings, matching the pattern and infrastructure of display names for ships. As in #7234, wing display names take precedence over ship display names, if both are provided; because if ship display names took precedence, a ship would have the same display name in every wave.
All the relevant display locations are handled, including the HUD, escort list, message box, and mission log. Lua API support is provided as well.
Adds full support for both FRED and QtFRED, including the always-save-display-names setting.
Addresses #7189 and the last request from #1730.
* add help text from #7234
* use std::move() for local variables that are copied but not reused
Addresses ~140 Coverity "Variable copied when it could be moved"
defects across 74 files. Every std::move() targets a local variable
whose value is consumed by push_back, emplace, assignment, lambda
capture, or a function call and is never read again afterward.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
* clang: use std::make_shared
* clang: use std::make_unique
* address feedback
---------
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
Rewrite `force_fit_string` to be more robust and to remove the potential for memory access violations. Also audit all of the length parameters in the calling functions - some of them were the buffer size, not the length. This should fix the mysterious crash in the mission log screen.
* Prevent Potential Memory Problems with squadmsg hook function
Within `hud_squadmsg_run_order_issued_hook` it is possible for the calling code to pass `nullptr` as the target parameter, which would cause memory problems with the several instances of `Objects[target->objnum]`. This PR mitigates that potential while testing of `hud_squadmsg_run_order_issued_hook` still works as expected.
* add more safety
1. Don't display the selection arrows until the selection is actually moved, to avoid interfering with the standard selection feature
2. Use static variables and the new `TIMESTAMP` data type
3. Minor cleanup
Follow-up to #6736.
This PR adds two new localization strings, which allow modders to change how the numbers in the comms menu are displayed, and it incorporates styling for the comms selection controls from #6736, too.
Tested and works as expected.
* Added new keybinds, keycontrol handlers, hudsquadmsg methods for alternate communication menu control scheme
* .gitignore update. CMake in VStudio places builds in [Oo]ut/ folder by default
* Added support for menu pages
* Small formatting cleanup
* code cleanup
* removed unecessary variable
* Updates after code review
* Updated comments
* XSTR_SIZE correction
1. Allow "Stay near me" and "Stay near my target" to work even if the teams do not match
2. Allow "Stay near my target" to be issued regardless of team
3. Avoid divide-by-zero errors when running `ai_stay_near()`
* Wingmen and Squad Message QoL Updates
This PR adds a few assorted HUD updates/quality of life enhancements. FotG will be using these, though they relatively general and are likely useful to most other mods, too.
1) Adds a 'Ship Name Max Width:' to the Squad Message Gauge (following the same logic as the Escort Gauge). The Escort Gauge will truncate display names of ships if they are too long, that way all the text fits in the gauge without spilling over. It would also be very useful to do this with the Squad Message Gauge, as long display names can overflow out of the gauge's boundaries currently.
2) Adds `Wingname Align Mode:` to the Wingmen Gauge, which allows modders to set how the wingnames are aligned. Currently they are centered on the calculated x-position, though this PR also adds right and left justification options (which is useful especially if displaying the full wing names).
All options are tested and work as expected.
* appease clang
* whitespace
* more safety and error checking
* and extra error helpfulness
* use safer str copy
* Allow mods to hide main Rearm/Repair items in Message Gauge
Adds a game_settings option to hide/disable the Rearm/Repair commands in the Squad Message Gauge. FotG does not use repair ships, so it is somewhat confusing to players to always see the `Rearm/Repair` order options (IE 5. Rearm/Repair Subsys and 6. Abort Rearm) and never be able to use them.
I wanted to make this PR as surgical as possible, while still giving some degree of generality, thus I went with the solution to use `active` as a true integer instead of simply an old int in the bool style. Now -1 is hidden, 0 is greyed out, and 1 is bright.
Tested and works as expected.
* update comment
* update with better name
* add another clarifying comment
* lua access to the comm board menu
* On Order Issued Lua Hook
* Some cleanup and safety checks
* Add mn.sendBuiltinMessage and perform more cleanup
* Send the correct ship to the hook for Sender
* clang cleanup
* address feedback
* fix build errors introduced from upstream
* basic hook conditions
* properly link the condition and the oswpt struct
* some requested cleanup
* allow for sending custom built-in messages
* address more feedback
* more prefix
* base working version
* localization and minor tweaks
* add retail UI controls
* Add way to hide gauges from Config view
* convert hud config from index matching to id matching
* clang
* Add scaling for vfnts and scale multipler to gr_string
* nullptr
* Add scaling to a couple other string operations
* Add scaling features to additional bitmap drawing methods
* Implement framework for rendering hud gauges in config mode
* fix merge error
* address feedback
Make `SCP_vector`, `SCP_list`, `SCP_set`, and `SCP_multiset` subclasses of their STL counterparts. This allows helper functions to be added to each, including the `contains()` function which is not available until C++20. (This has minor effects on other parts of the codebase that treated `SCP_` and `std::` as synonyms.) Since there is now a nontrivial amount of code that needs to be in a .cpp file, create vmallocator.cpp.
Note that `SCP_string` truncation has been refactored to use length rather than C-string size to be consistent with other `std::basic_string` functions.
Also, remove some enum class hashing code which is no longer necessary now that the codebase is at C++17.
* Clean unneeded properties
* properly queue-ify keys
* Refactor key checking to use functions instead of globals
* Update hooks and cache checked-against key
* Documentation and Naming
* match tilde
* only remove control not debug
Rework `hud_support_find_closest()` slightly to do a quick out if the player is no longer a valid object. Fixes an assertion noticed by Darius that occurs if the player dies when a rearm is imminent.
Check the filenames used to initialize HUD gauges and mark the gauge as hi-res if the filename starts with 2_. Also add a script method to return this value.
Additionally, make accessor methods `const`.
Add "tactical" versions of disable and disarm goals which only perform the specific task without implying anything else. The target ship is not protected and attack goals are not cleared from other ships.
There is also a new AI profiles flag to make this the default hud squad message command instead of the classic disable/disarm.
* Fix intra-persona message borrowing logic
Closes#5299.
* Always assign personae for Support
Disabling the Auto_assign_personas flag had the side-effect of prohibiting support ships from ever speaking. Since a mod that wants this behavior (for whatever reason) can just not have a support persona, this commit makes an exception for them.
* Make Protect Target and Cover Me adaptive like Engage Enemy is
* Respect the allow subsitution flag