News:

Simutrans Chat Room
Where cool people of Simutrans can meet up.

Simgraph refactor

Started by ceeac, April 25, 2020, 04:15:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ceeac

This WIP patch prefixes all functions declared in simgraph.h with "simgraph_" and groups similar functions together.
This is mostly for consistency, but also to make it immediately obvious where a function is defined (for example get_color_rgb vs. simgraph_get_color_rgb).
The patch is too large to attach here, but is availble here.

To make reviewing and discussing these changes easier, I made a table containing all old and new function names. Let me know what you think. :)


GroupNew nameOld nameRemarks
Generalsimgraph_initsimgraph_initNow returns bool to signal success/failure
simgraph_exitsimgraph_exit
simgraph_is_display_initis_display_init
simgraph_resizesimgraph_resize
simgraph_get_display_widthdisplay_get_width
simgraph_get_display_heightdisplay_get_height
simgraph_set_display_heightdisplay_set_height
simgraph_set_display_actualwidthdisplay_set_actual_width
simgraph_zoom_inzoom_factor_up
simgraph_zoom_outzoom_factor_down
simgraph_get_tile_raster_widthget_tile_raster_width
simgraph_get_current_tile_raster_widthget_current_tile_raster_width
simgraph_get_base_tile_raster_widthget_base_tile_raster_width
simgraph_set_base_raster_widthdisplay_set_base_raster_width
simgraph_take_screenshotdisplay_snapshot
simgraph_flush_bufferdisplay_flush_buffer
simgraph_set_show_pointerdisplay_show_pointerNow takes a parameter of type bool
simgraph_set_pointer_imagedisplay_set_pointerOnly used with USE_SOFTPOINTER
simgraph_set_show_load_pointerdisplay_show_load_pointerNow takes a parameter of type bool
Textsimgraph_load_fontdisplay_load_font
simgraph_get_char_widthdisplay_get_char_width
simgraph_font_has_characterhas_character
simgraph_get_next_charget_next_char
simgraph_get_prev_charget_prev_char
simgraph_get_next_char_with_metricsget_next_char_with_metrics
simgraph_get_prev_char_with_metricsget_prev_char_with_metrics
simgraph_get_widest_chardisplay_get_char_max_width
simgraph_get_text_fitdisplay_fit_proportional
simgraph_get_text_widthproportional_string_width
simgraph_calc_multiline_text_sizedisplay_calc_proportional_multiline_string_len_widthNow returns scr_size
simgraph_draw_text_rgbdisplay_proportional_rgb
simgraph_draw_text_clip_rgbdisplay_proportional_clip_rgb
simgraph_draw_multiline_text_rgbdisplay_multiline_text_rgb
simgraph_draw_text_ellipsis_rgbdisplay_proportional_ellipsis_rgb
simgraph_draw_textbox3d_clip_rgbdisplay_ddd_proportional_clip
simgraph_draw_text_outlined_rgbdisplay_outline_proportional_rgb
simgraph_draw_text_shadowed_rgbdisplay_shadow_proportional_rgb
Colorssimgraph_color_idx_to_rgbcolor_idx_to_rgb
simgraph_color_rgb_to_idxcolor_rgb_to_idx
simgraph_get_color_rgbget_color_rgb
simgraph_env_t_rgb_to_system_colorsenv_t_rgb_to_system_colors
simgraph_set_player_color_schemedisplay_set_player_color_scheme
simgraph_set_daynight_lightsn/anew function; replaces direct access of display_day_lights & display_night_lights; COLOUR_DEPTH != 0 only
simgraph_update_day_night_shiftdisplay_day_night_shiftCOLOUR_DEPTH != 0 only
Clipsimgraph_add_poly_clipadd_poly_clip
simgraph_clear_all_poly_clipclear_all_poly_clip
simgraph_activate_ribi_clipactivate_ribi_clip
simgraph_set_clip_whdisplay_set_clip_wh
simgraph_get_clip_whdisplay_get_clip_wh
simgraph_push_clip_whdisplay_push_clip_wh
simgraph_swap_clip_whdisplay_swap_clip_wh
simgraph_pop_clip_whdisplay_pop_clip_wh
Imagessimgraph_get_image_countget_image_count
simgraph_register_imageregister_image
simgraph_free_all_images_abovedisplay_free_all_images_above
simgraph_get_base_image_offsetdisplay_get_base_image_offset
simgraph_get_image_offsetdisplay_get_image_offset
simgraph_fit_img_to_widthdisplay_fit_img_to_width
Dirtysimgraph_mark_img_dirtydisplay_mark_img_dirty
simgraph_mark_rect_dirty_wcmark_rect_dirty_wc
simgraph_mark_rect_dirty_clipmark_rect_dirty_clip
simgraph_mark_screen_dirtymark_screen_dirty
Drawingsimgraph_draw_scroll_banddisplay_scroll_band
simgraph_draw_img_aligneddisplay_img_aligned
simgraph_draw_img_auxdisplay_img_aux
simgraph_draw_rezoomed_img_blenddisplay_rezoomed_img_blend
simgraph_draw_img_blenddisplay_img_blend
simgraph_draw_rezoomed_img_alphadisplay_rezoomed_img_alpha
simgraph_draw_img_alphadisplay_img_alpha
simgraph_draw_color_imgdisplay_color_img
simgraph_draw_base_imgdisplay_base_img
simgraph_draw_img_stretchdisplay_img_stretch
simgraph_draw_img_stretch_blenddisplay_img_stretch_blend
simgraph_draw_base_img_blenddisplay_base_img_blend
simgraph_draw_base_img_alphadisplay_base_img_alpha
simgraph_draw_box3d_rgbdisplay_ddd_box_rgb
simgraph_draw_box3d_clip_rgbdisplay_ddd_box_clip_rgb
simgraph_draw_line_solid_rgbdisplay_direct_line_rgb
simgraph_draw_line_dotted_rgbdisplay_direct_line_dotted_rgb
simgraph_draw_circle_rgbdisplay_circle_rgb
simgraph_draw_filled_circle_rgbdisplay_filled_circle_rgb
simgraph_draw_bezier_rgbdraw_bezier_rgb
simgraph_set_display_procsdisplay_set_image_proc
simgraph_blend_colorsdisplay_blend_colors
simgraph_blend_wh_rgbdisplay_blend_wh_rgb
simgraph_draw_fillbox_wh_rgbdisplay_fillbox_wh_rgb
simgraph_draw_fillbox_wh_clip_rgbdisplay_fillbox_wh_clip_rgb
simgraph_draw_vline_wh_clip_rgbdisplay_vline_wh_clip_rgb
simgraph_draw_array_whdisplay_array_wh

Dwachs

why all these sim_graph prefixes?
Parsley, sage, rosemary, and maggikraut.

Mariculous

Why do you prefix them instead of using namespaces or a class?
C++ will always be a mystery to me.

prissi

What is the purpose? I could understand to replace/add "display_" to simgraphe_ and other names. Moreover, such a renaming does not respect the "recommendation" of functions to start with either "get_", "set_", or "is_" if they are gettting, setting a value or query a boolean. So it should be "get_display_width" instead "display_get_width".

However, such a renaming will break still waiting on my harddisk. And it will make consistency between extended and standard harder to maintain, unless applied there too. But then the chyanges in the meantime will be hard too merge.

Ters

Longer names makes it more tedious to write stuff without an IDE to autocomplete, but with an IDE, one does not need prefixes to find out where things are defined.

I don't see any point in simgraph_init returning any failure state. There is nothing to do about it, so let it just call exit and be done with it.