Commit graph

3788 commits

Author SHA1 Message Date
Kp 8eafbe6197 Shrink window::w_modal to uint8_t 2021-11-01 03:37:18 +00:00
Kp 3cca690728 Assign weakly-typed symbolic names to ogl_ubitmapm_cs special cases 2021-11-01 03:37:18 +00:00
Kp 961aae074a Remove unused ogl_ubitmapm_cs argument scale
Every caller passes `F1_0`.  Remove the argument, and propagate its
results through the function.
2021-11-01 03:37:18 +00:00
Kp 1a08ecc8c6 Remove window subfunction types
These were type safety mechanisms, which are obsolete now that all
window handlers are implemented through virtual function dispatch.
2021-10-13 02:37:51 +00:00
Kp 192988b004 Use enum class for weapon_info::persistent 2021-09-19 10:53:48 +00:00
Kp 21c530a3e2 Use enumerated_array for difficulty-level-specific arrays 2021-09-19 10:53:48 +00:00
Kp 7fc8c736b3 Pass Powerup_info to multi_prep_level_objects, filter_objects_from_level 2021-09-19 10:53:48 +00:00
Kp 4e75f8a933 Pass canvas to scores_view_menu 2021-09-19 10:53:48 +00:00
Kp 855697bf5d Make font scaling constructors explicit 2021-09-19 10:53:48 +00:00
Kp b05905ab4d Delegate score comma handling to std::locale 2021-09-19 10:53:48 +00:00
Kp e618851449 Pass canvas to savegame_chooser_newmenu 2021-09-19 10:53:48 +00:00
Kp aba5fce3a9 Use enum class for gr fade_level 2021-09-19 10:53:48 +00:00
Kp 5caa4755b1 Shrink gr_blend to uint8_t
Larger values are not needed.
2021-09-19 10:53:48 +00:00
Kp 07c52f14f9 Save parent canvas in listbox_layout 2021-09-12 16:20:52 +00:00
Kp 8d67bcddb0 Record parent canvas in newmenu
Use it to avoid resetting to the screen canvas when preparing the
layout.
2021-09-12 16:20:52 +00:00
Kp bb29e6fca8 Propagate canvas through more layers 2021-09-12 16:20:52 +00:00
Kp 8623ce3c6a Pass canvas to ogl_draw_vertex_reticle 2021-09-12 16:20:52 +00:00
Kp 3c37552e5b Use enum class bm_mode for grs_bitmap::type 2021-09-12 16:20:52 +00:00
Kp e7aa9855e0 Compute menu border widths from screen canvas instead of screen
In practice, this should be the same result.  However, this allows the
flexibility to use a canvas other than the screen.
2021-09-12 16:20:52 +00:00
Kp 21241471c6 Return string width/height from gr_get_string_size
Use structured bindings to capture the values on return, so that they
can be declared as `const` if they are immutable after initial
computation.
2021-09-12 16:20:52 +00:00
Kp 0750046bc1 Move retrieval of font average width out of gr_get_string_size
Most callers do not need it, and it is only vaguely related to the
purpose of measuring a particular string.  For those callers that need
it, lift it out.
2021-09-12 16:20:52 +00:00
Kp 2fef4cddec Pass canvas to do_cockpit_window_view 2021-09-12 16:20:52 +00:00
Kp 5881af50dd Use __builtin_FILE,LINE for canvas location debugging
This avoids declaring macros for gr_set_default_canvas,
gr_set_current_canvas.
2021-09-12 16:20:52 +00:00
Kp 3aa1140700 Optimize out warn_printf on some targets
Some targets only ever use GUI warn functions.  On those targets:
- initialize `warn_func` to `msgbox_warning` at compile time
- remove the runtime initialize of warn_func in main

On targets which do not call `clear_warn_func`, preprocess out its
declaration and definition.

Taken together, these changes allow some targets not to define
`warn_printf`.
2021-09-12 16:20:52 +00:00
Kp bd6612a86b Pass canvas to render_gauges 2021-09-12 16:20:52 +00:00
Kp 4b60205b2f Propagate up show_boxed_message RenderFlag
It is always constant.  Explicitly propagate its effects into callers,
then remove the argument.
2021-09-12 16:20:52 +00:00
Kp df6777c632 Expand game_init_render_buffers inline
It is a single function, to add 2 arguments.  Using a wrapper obfuscates
the logic.
2021-09-12 16:20:52 +00:00
Kp 98f2578293 Pass Game_mode as a parameter to gauges functions
Avoid reloading it from the global.
2021-09-12 16:20:52 +00:00
Kp 2b718da343 Use enum class for Game_mode, Newdemo_game_mode 2021-09-12 16:20:52 +00:00
Kp 48a3ac2c53 Lift ogl_start_frame eye handling into caller 2021-09-12 16:20:52 +00:00
Kp 7f51fa3ac5 Use enum class for VR StereoFormat 2021-09-12 16:20:52 +00:00
Kp 233f31893b Only prepare pause time if it will be shown
Demo playback does not show time data, so there is no need to format it
when it will be hidden.
2021-09-12 16:20:52 +00:00
Kp 211f4ea274 Use window_rendered_data constructor to initialize time 2021-09-12 16:20:52 +00:00
Kp 2afe2f428f Remove write-only member window_rendered_data::viewer 2021-09-12 16:20:52 +00:00
Kp fdf5836031 Move g3 instance contexts onto the stack 2021-09-04 12:17:14 +00:00
Kp 6172b69329 Convert more font.cpp sites to use xrange 2021-09-04 12:17:14 +00:00
Kp c99b67e359 Switch callers to unchecked_partial_range(range) where possible
Use unchecked_partial_range(range) instead of
unchecked_partial_range(iterator), since the range form can preserve the
underlying index_type.
2021-09-04 12:17:14 +00:00
Kp b6bebcf6b8 Propagate T::index_type through partial_range
When partial_range is used on a container that defines index_type,
define that same index_type on the partial_range.  This allows other
callers, such as enumerate(), to maintain the correct index type.
2021-09-04 12:17:14 +00:00
Kp 16aa554c0e Remove anonymous namespace in partial_range
All the affected symbols are templates, so duplicate instantiations will
not cause duplicate definition errors.  Removing the anonymous namespace
wrapper will allow equivalent definitions from different source files to
be folded together, reducing the size of the executable.
2021-09-04 12:17:14 +00:00
Kp ef1c3d20c6 Compute required_buffer_size earlier in partial_range call tree
Push the computation up, so that invocations that differ only in the
length of their expression strings will resolve to the same template.

Rework unchecked_partial_range not to take expression strings if they
will not be used.
2021-09-04 12:17:14 +00:00
Kp 45d72183ce Rename type/var for partial_range begin/end
- UO -> index_begin_type
- o -> index_begin
- UL -> index_end_type
- l -> index_end
- I -> range_exception

The original names were picked because `l` was the length of the
subrange.  Rename these to more closely follow STL's begin/end
nomenclature.

`I` was used variously for an iterator type and for the exception type
thrown on error.  Rename the latter to be descriptive.
2021-09-04 12:17:14 +00:00
Kp 23f03d0a5e Add unit tests for partial_range 2021-09-04 12:17:14 +00:00
Kp ae3dc7f934 Simplify computed color reset
gr_find_closest_color did not need it.  Remove it.  For the others,
resetting the count is sufficient.  There is no need to reset the
individual elements.
2021-09-04 12:17:14 +00:00
Kp fb3c2a4808 Narrow grs_canvas fg/bg color fields 2021-09-04 12:17:14 +00:00
Kp 2c2ef3fa33 Factor out common logic in rle conditionals 2021-09-04 12:17:14 +00:00
Kp 3697aabcdd RLE processing: use varying pointer types instead of multiplication 2021-09-04 12:17:14 +00:00
Kp 5bd093b3cb Rework gr_rle_getsize
- Add a limiter to let it return early when the result is predictable.
  The first caller checks only whether the returned value is above a
  threshold.  Once the value goes above that threshold, its precise
  value will not matter, so stop counting and return early.
- Add comments explaining some of the logic.
2021-09-04 12:17:14 +00:00
Kp 15f944b0b6 Skip trying to rle compress a paged-out bitmap
This would crash if it ever happened, so skip such bitmaps.
2021-09-04 12:17:14 +00:00
Kp 99e14b4100 Factor out common paths in gr_rle_encode 2021-09-04 12:17:14 +00:00
Kp 21f736ec37 Require grs_subcanvas for gr_init_sub_canvas
Prevent passing a canvas that is not specifically typed as a
grs_subcanvas.
2021-09-04 12:17:14 +00:00