From 7910b91dd908348253365ff4c33cb32d05cb138c Mon Sep 17 00:00:00 2001 From: NoahJCross Date: Tue, 7 Jan 2025 00:25:25 +1100 Subject: [PATCH 1/6] Update to splashkit ffi and source files --- clang++/include/circle_geometry.h | 3 + clang++/include/interface.h | 28 +- clang++/include/music.h | 6 +- clang++/include/sound.h | 8 +- clang++/include/vector_2d.h | 2 +- clang++/src/splashkit.cpp | 170 +-- dotnet/SplashKit.cs | 298 +++-- fpc/SplashKit.pas | 292 +++-- g++/include/circle_geometry.h | 3 + g++/include/interface.h | 28 +- g++/include/music.h | 6 +- g++/include/sound.h | 8 +- g++/include/vector_2d.h | 2 +- g++/src/splashkit.cpp | 170 +-- python3/splashkit.py | 174 +-- source/audio_driver.cpp | 12 +- source/basics.cpp | 3 + source/circle_geometry.cpp | 32 +- source/clipping.cpp | 4 +- source/include/audio_driver.h | 8 +- source/include/circle_geometry.h | 36 + source/include/graphics_driver.h | 1 + source/include/input_driver.h | 1 + source/include/interface.h | 54 +- source/include/interface_driver.h | 8 +- source/include/logging.h | 2 +- source/include/music.h | 6 +- source/include/sk_clib.h | 47 +- source/include/sound.h | 8 +- source/include/timers.h | 18 +- source/include/triangle_geometry.h | 2 +- source/include/utility_functions.h | 5 +- source/include/vector_2d.h | 2 +- source/interface.cpp | 46 +- source/interface_driver.cpp | 1844 ++++++++++++++-------------- source/keyboard_input.cpp | 1 + source/line_geometry.cpp | 7 +- source/logging.cpp | 12 +- source/music.cpp | 6 +- source/point_geometry.cpp | 2 +- source/quad_geometry.cpp | 2 +- source/random.cpp | 16 +- source/sk_clib.cpp | 134 +- source/sound.cpp | 8 +- source/sprites.cpp | 10 +- source/terminal.cpp | 5 + source/text_driver.cpp | 1 + source/text_input.cpp | 2 +- source/utils.cpp | 2 +- source/vector_2d.cpp | 4 +- source/window_manager.cpp | 1 + 51 files changed, 1912 insertions(+), 1638 deletions(-) diff --git a/clang++/include/circle_geometry.h b/clang++/include/circle_geometry.h index 1fc086b..cfa80d8 100644 --- a/clang++/include/circle_geometry.h +++ b/clang++/include/circle_geometry.h @@ -17,6 +17,8 @@ point_2d center_point(const circle &c); circle circle_at(const point_2d &pt, double radius); circle circle_at(double x, double y, double radius); float circle_radius(const circle c); +bool circle_triangle_intersect(const circle &c, const triangle &tri); +bool circle_triangle_intersect(const circle &c, const triangle &tri, point_2d &p); float circle_x(const circle &c); float circle_y(const circle &c); bool circles_intersect(circle c1, circle c2); @@ -24,6 +26,7 @@ bool circles_intersect(double c1_x, double c1_y, double c1_radius, double c2_x, point_2d closest_point_on_circle(const point_2d &from_pt, const circle &c); point_2d closest_point_on_line_from_circle(const circle &c, const line &l); point_2d closest_point_on_rect_from_circle(const circle &c, const rectangle &rect); +point_2d closest_point_on_triangle_from_circle(const circle &c, const triangle &tri); point_2d distant_point_on_circle(const point_2d &pt, const circle &c); bool distant_point_on_circle_heading(const point_2d &pt, const circle &c, const vector_2d &heading, point_2d &opposite_pt); float ray_circle_intersect_distance(const point_2d &ray_origin, const vector_2d &ray_heading, const circle &c); diff --git a/clang++/include/interface.h b/clang++/include/interface.h index 5dd1a7d..d8c9567 100644 --- a/clang++/include/interface.h +++ b/clang++/include/interface.h @@ -19,40 +19,40 @@ bool bitmap_button(bitmap bmp); bool bitmap_button(bitmap bmp, const rectangle &rect); bool bitmap_button(bitmap bmp, const rectangle &rect, drawing_options opts); bool bitmap_button(bitmap bmp, drawing_options opts); -bool bitmap_button(const string &label, bitmap bmp); -bool bitmap_button(const string &label, bitmap bmp, drawing_options opts); +bool bitmap_button(const string &label_text, bitmap bmp); +bool bitmap_button(const string &label_text, bitmap bmp, drawing_options opts); bool button(const string &text, const rectangle &rect); bool button(const string &text); -bool button(const string &label, const string &text); +bool button(const string &label_text, const string &text); bool checkbox(const string &text, const bool &value, const rectangle &rect); bool checkbox(const string &text, const bool &value); -bool checkbox(const string &label, const string &text, const bool &value); +bool checkbox(const string &label_text, const string &text, const bool &value); color color_slider(const color &clr, const rectangle &rect); color color_slider(const color &clr); -color color_slider(const string &label, const color &clr); +color color_slider(const string &label_text, const color &clr); void disable_interface(); void draw_interface(); void enable_interface(); void end_inset(const string &name); void end_panel(const string &name); void end_popup(const string &name); -void end_treenode(const string &label); +void end_treenode(const string &label_text); void enter_column(); int get_interface_label_width(); -bool header(const string &label); +bool header(const string &label_text); color hsb_color_slider(const color &clr, const rectangle &rect); color hsb_color_slider(const color &clr); -color hsb_color_slider(const string &label, const color &clr); +color hsb_color_slider(const string &label_text, const color &clr); bool interface_enabled(); void interface_style_panel(const rectangle &initial_rectangle); -void label(const string &text); -void label(const string &text, const rectangle &rect); +void label_element(const string &text); +void label_element(const string &text, const rectangle &rect); bool last_element_changed(); bool last_element_confirmed(); void leave_column(); float number_box(const float &value, float step, const rectangle &rect); float number_box(const float &value, float step); -float number_box(const string &label, const float &value, float step); +float number_box(const string &label_text, const float &value, float step); void open_popup(const string &name); void paragraph(const string &text); void paragraph(const string &text, const rectangle &rect); @@ -77,7 +77,7 @@ void set_layout_height(int height); void single_line_layout(); float slider(const float &value, float min_value, float max_value, const rectangle &rect); float slider(const float &value, float min_value, float max_value); -float slider(const string &label, const float &value, float min_value, float max_value); +float slider(const string &label_text, const float &value, float min_value, float max_value); void split_into_columns(int count); void split_into_columns(int count, int last_width); void split_into_columns_relative(int count, double last_width); @@ -86,9 +86,9 @@ void start_inset(const string &name, const rectangle &rect); void start_inset(const string &name, int height); bool start_panel(const string &name, rectangle initial_rectangle); bool start_popup(const string &name); -bool start_treenode(const string &label); +bool start_treenode(const string &label_text); string text_box(const string &value); string text_box(const string &value, const rectangle &rect); -string text_box(const string &label, const string &value); +string text_box(const string &label_text, const string &value); #endif /* __interface_h */ diff --git a/clang++/include/music.h b/clang++/include/music.h index 09dece8..0622756 100644 --- a/clang++/include/music.h +++ b/clang++/include/music.h @@ -28,15 +28,15 @@ string music_name(music data); music music_named(const string &name); bool music_playing(); bool music_valid(music m); -float music_volume(); +double music_volume(); void pause_music(); void play_music(const string &name); void play_music(const string &name, int times); void play_music(music data); void play_music(music data, int times); -void play_music(music data, int times, float volume); +void play_music(music data, int times, double volume); void resume_music(); -void set_music_volume(float volume); +void set_music_volume(double volume); void stop_music(); #endif /* __music_h */ diff --git a/clang++/include/sound.h b/clang++/include/sound.h index 42ef914..fa205d1 100644 --- a/clang++/include/sound.h +++ b/clang++/include/sound.h @@ -21,13 +21,13 @@ void free_sound_effect(sound_effect effect); bool has_sound_effect(const string &name); sound_effect load_sound_effect(const string &name, const string &filename); void play_sound_effect(const string &name); -void play_sound_effect(const string &name, float volume); +void play_sound_effect(const string &name, double volume); void play_sound_effect(const string &name, int times); -void play_sound_effect(const string &name, int times, float volume); +void play_sound_effect(const string &name, int times, double volume); void play_sound_effect(sound_effect effect); -void play_sound_effect(sound_effect effect, float volume); +void play_sound_effect(sound_effect effect, double volume); void play_sound_effect(sound_effect effect, int times); -void play_sound_effect(sound_effect effect, int times, float volume); +void play_sound_effect(sound_effect effect, int times, double volume); string sound_effect_filename(sound_effect effect); string sound_effect_name(sound_effect effect); sound_effect sound_effect_named(const string &name); diff --git a/clang++/include/vector_2d.h b/clang++/include/vector_2d.h index 19a064c..937491f 100644 --- a/clang++/include/vector_2d.h +++ b/clang++/include/vector_2d.h @@ -27,7 +27,7 @@ bool vector_in_rect(const vector_2d &v, const rectangle &rect); vector_2d vector_invert(const vector_2d &v); vector_2d vector_limit(const vector_2d &v, double limit); double vector_magnitude(const vector_2d &v); -double vector_magnitude_sqared(const vector_2d &v); +double vector_magnitude_squared(const vector_2d &v); vector_2d vector_multiply(const vector_2d &v1, double s); vector_2d vector_normal(const vector_2d &v); vector_2d vector_out_of_circle_from_circle(const circle &src, const circle &bounds, const vector_2d &velocity); diff --git a/clang++/src/splashkit.cpp b/clang++/src/splashkit.cpp index 7a12254..8588c70 100644 --- a/clang++/src/splashkit.cpp +++ b/clang++/src/splashkit.cpp @@ -614,6 +614,20 @@ float circle_radius(const circle c) { float __skreturn = __sklib__circle_radius__circle(__skparam__c); return __skadapter__to_float(__skreturn); } +bool circle_triangle_intersect(const circle &c, const triangle &tri) { + const __sklib_circle __skparam__c = __skadapter__to_sklib_circle(c); + const __sklib_triangle __skparam__tri = __skadapter__to_sklib_triangle(tri); + int __skreturn = __sklib__circle_triangle_intersect__circle_ref__triangle_ref(__skparam__c, __skparam__tri); + return __skadapter__to_bool(__skreturn); +} +bool circle_triangle_intersect(const circle &c, const triangle &tri, point_2d &p) { + const __sklib_circle __skparam__c = __skadapter__to_sklib_circle(c); + const __sklib_triangle __skparam__tri = __skadapter__to_sklib_triangle(tri); + __sklib_point_2d __skparam__p = __skadapter__to_sklib_point_2d(p); + int __skreturn = __sklib__circle_triangle_intersect__circle_ref__triangle_ref__point_2d_ref(__skparam__c, __skparam__tri, &__skparam__p); + p = __skadapter__to_point_2d(__skparam__p); + return __skadapter__to_bool(__skreturn); +} float circle_x(const circle &c) { const __sklib_circle __skparam__c = __skadapter__to_sklib_circle(c); float __skreturn = __sklib__circle_x__circle_ref(__skparam__c); @@ -658,6 +672,12 @@ point_2d closest_point_on_rect_from_circle(const circle &c, const rectangle &rec __sklib_point_2d __skreturn = __sklib__closest_point_on_rect_from_circle__circle_ref__rectangle_ref(__skparam__c, __skparam__rect); return __skadapter__to_point_2d(__skreturn); } +point_2d closest_point_on_triangle_from_circle(const circle &c, const triangle &tri) { + const __sklib_circle __skparam__c = __skadapter__to_sklib_circle(c); + const __sklib_triangle __skparam__tri = __skadapter__to_sklib_triangle(tri); + __sklib_point_2d __skreturn = __sklib__closest_point_on_triangle_from_circle__circle_ref__triangle_ref(__skparam__c, __skparam__tri); + return __skadapter__to_point_2d(__skreturn); +} point_2d distant_point_on_circle(const point_2d &pt, const circle &c) { const __sklib_point_2d __skparam__pt = __skadapter__to_sklib_point_2d(pt); const __sklib_circle __skparam__c = __skadapter__to_sklib_circle(c); @@ -2412,19 +2432,19 @@ bool bitmap_button(bitmap bmp, drawing_options opts) { int __skreturn = __sklib__bitmap_button__bitmap__drawing_options(__skparam__bmp, __skparam__opts); return __skadapter__to_bool(__skreturn); } -bool bitmap_button(const string &label, bitmap bmp) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); +bool bitmap_button(const string &label_text, bitmap bmp) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); __sklib_bitmap __skparam__bmp = __skadapter__to_sklib_bitmap(bmp); - int __skreturn = __sklib__bitmap_button__string_ref__bitmap(__skparam__label, __skparam__bmp); - __skadapter__free__sklib_string(__skparam__label); + int __skreturn = __sklib__bitmap_button__string_ref__bitmap(__skparam__label_text, __skparam__bmp); + __skadapter__free__sklib_string(__skparam__label_text); return __skadapter__to_bool(__skreturn); } -bool bitmap_button(const string &label, bitmap bmp, drawing_options opts) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); +bool bitmap_button(const string &label_text, bitmap bmp, drawing_options opts) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); __sklib_bitmap __skparam__bmp = __skadapter__to_sklib_bitmap(bmp); __sklib_drawing_options __skparam__opts = __skadapter__to_sklib_drawing_options(opts); - int __skreturn = __sklib__bitmap_button__string_ref__bitmap__drawing_options(__skparam__label, __skparam__bmp, __skparam__opts); - __skadapter__free__sklib_string(__skparam__label); + int __skreturn = __sklib__bitmap_button__string_ref__bitmap__drawing_options(__skparam__label_text, __skparam__bmp, __skparam__opts); + __skadapter__free__sklib_string(__skparam__label_text); return __skadapter__to_bool(__skreturn); } bool button(const string &text, const rectangle &rect) { @@ -2440,11 +2460,11 @@ bool button(const string &text) { __skadapter__free__sklib_string(__skparam__text); return __skadapter__to_bool(__skreturn); } -bool button(const string &label, const string &text) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); +bool button(const string &label_text, const string &text) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); const __sklib_string __skparam__text = __skadapter__to_sklib_string(text); - int __skreturn = __sklib__button__string_ref__string_ref(__skparam__label, __skparam__text); - __skadapter__free__sklib_string(__skparam__label); + int __skreturn = __sklib__button__string_ref__string_ref(__skparam__label_text, __skparam__text); + __skadapter__free__sklib_string(__skparam__label_text); __skadapter__free__sklib_string(__skparam__text); return __skadapter__to_bool(__skreturn); } @@ -2463,12 +2483,12 @@ bool checkbox(const string &text, const bool &value) { __skadapter__free__sklib_string(__skparam__text); return __skadapter__to_bool(__skreturn); } -bool checkbox(const string &label, const string &text, const bool &value) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); +bool checkbox(const string &label_text, const string &text, const bool &value) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); const __sklib_string __skparam__text = __skadapter__to_sklib_string(text); const int __skparam__value = __skadapter__to_int(value); - int __skreturn = __sklib__checkbox__string_ref__string_ref__bool_ref(__skparam__label, __skparam__text, __skparam__value); - __skadapter__free__sklib_string(__skparam__label); + int __skreturn = __sklib__checkbox__string_ref__string_ref__bool_ref(__skparam__label_text, __skparam__text, __skparam__value); + __skadapter__free__sklib_string(__skparam__label_text); __skadapter__free__sklib_string(__skparam__text); return __skadapter__to_bool(__skreturn); } @@ -2483,11 +2503,11 @@ color color_slider(const color &clr) { __sklib_color __skreturn = __sklib__color_slider__color_ref(__skparam__clr); return __skadapter__to_color(__skreturn); } -color color_slider(const string &label, const color &clr) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); +color color_slider(const string &label_text, const color &clr) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); const __sklib_color __skparam__clr = __skadapter__to_sklib_color(clr); - __sklib_color __skreturn = __sklib__color_slider__string_ref__color_ref(__skparam__label, __skparam__clr); - __skadapter__free__sklib_string(__skparam__label); + __sklib_color __skreturn = __sklib__color_slider__string_ref__color_ref(__skparam__label_text, __skparam__clr); + __skadapter__free__sklib_string(__skparam__label_text); return __skadapter__to_color(__skreturn); } void disable_interface() { @@ -2514,10 +2534,10 @@ void end_popup(const string &name) { __sklib__end_popup__string_ref(__skparam__name); __skadapter__free__sklib_string(__skparam__name); } -void end_treenode(const string &label) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); - __sklib__end_treenode__string_ref(__skparam__label); - __skadapter__free__sklib_string(__skparam__label); +void end_treenode(const string &label_text) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); + __sklib__end_treenode__string_ref(__skparam__label_text); + __skadapter__free__sklib_string(__skparam__label_text); } void enter_column() { __sklib__enter_column(); @@ -2526,10 +2546,10 @@ int get_interface_label_width() { int __skreturn = __sklib__get_interface_label_width(); return __skadapter__to_int(__skreturn); } -bool header(const string &label) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); - int __skreturn = __sklib__header__string_ref(__skparam__label); - __skadapter__free__sklib_string(__skparam__label); +bool header(const string &label_text) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); + int __skreturn = __sklib__header__string_ref(__skparam__label_text); + __skadapter__free__sklib_string(__skparam__label_text); return __skadapter__to_bool(__skreturn); } color hsb_color_slider(const color &clr, const rectangle &rect) { @@ -2543,11 +2563,11 @@ color hsb_color_slider(const color &clr) { __sklib_color __skreturn = __sklib__hsb_color_slider__color_ref(__skparam__clr); return __skadapter__to_color(__skreturn); } -color hsb_color_slider(const string &label, const color &clr) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); +color hsb_color_slider(const string &label_text, const color &clr) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); const __sklib_color __skparam__clr = __skadapter__to_sklib_color(clr); - __sklib_color __skreturn = __sklib__hsb_color_slider__string_ref__color_ref(__skparam__label, __skparam__clr); - __skadapter__free__sklib_string(__skparam__label); + __sklib_color __skreturn = __sklib__hsb_color_slider__string_ref__color_ref(__skparam__label_text, __skparam__clr); + __skadapter__free__sklib_string(__skparam__label_text); return __skadapter__to_color(__skreturn); } bool interface_enabled() { @@ -2558,15 +2578,15 @@ void interface_style_panel(const rectangle &initial_rectangle) { const __sklib_rectangle __skparam__initial_rectangle = __skadapter__to_sklib_rectangle(initial_rectangle); __sklib__interface_style_panel__rectangle_ref(__skparam__initial_rectangle); } -void label(const string &text) { +void label_element(const string &text) { const __sklib_string __skparam__text = __skadapter__to_sklib_string(text); - __sklib__label__string_ref(__skparam__text); + __sklib__label_element__string_ref(__skparam__text); __skadapter__free__sklib_string(__skparam__text); } -void label(const string &text, const rectangle &rect) { +void label_element(const string &text, const rectangle &rect) { const __sklib_string __skparam__text = __skadapter__to_sklib_string(text); const __sklib_rectangle __skparam__rect = __skadapter__to_sklib_rectangle(rect); - __sklib__label__string_ref__rectangle_ref(__skparam__text, __skparam__rect); + __sklib__label_element__string_ref__rectangle_ref(__skparam__text, __skparam__rect); __skadapter__free__sklib_string(__skparam__text); } bool last_element_changed() { @@ -2593,12 +2613,12 @@ float number_box(const float &value, float step) { float __skreturn = __sklib__number_box__float_ref__float(__skparam__value, __skparam__step); return __skadapter__to_float(__skreturn); } -float number_box(const string &label, const float &value, float step) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); +float number_box(const string &label_text, const float &value, float step) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); const float __skparam__value = __skadapter__to_float(value); float __skparam__step = __skadapter__to_float(step); - float __skreturn = __sklib__number_box__string_ref__float_ref__float(__skparam__label, __skparam__value, __skparam__step); - __skadapter__free__sklib_string(__skparam__label); + float __skreturn = __sklib__number_box__string_ref__float_ref__float(__skparam__label_text, __skparam__value, __skparam__step); + __skadapter__free__sklib_string(__skparam__label_text); return __skadapter__to_float(__skreturn); } void open_popup(const string &name) { @@ -2721,13 +2741,13 @@ float slider(const float &value, float min_value, float max_value) { float __skreturn = __sklib__slider__float_ref__float__float(__skparam__value, __skparam__min_value, __skparam__max_value); return __skadapter__to_float(__skreturn); } -float slider(const string &label, const float &value, float min_value, float max_value) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); +float slider(const string &label_text, const float &value, float min_value, float max_value) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); const float __skparam__value = __skadapter__to_float(value); float __skparam__min_value = __skadapter__to_float(min_value); float __skparam__max_value = __skadapter__to_float(max_value); - float __skreturn = __sklib__slider__string_ref__float_ref__float__float(__skparam__label, __skparam__value, __skparam__min_value, __skparam__max_value); - __skadapter__free__sklib_string(__skparam__label); + float __skreturn = __sklib__slider__string_ref__float_ref__float__float(__skparam__label_text, __skparam__value, __skparam__min_value, __skparam__max_value); + __skadapter__free__sklib_string(__skparam__label_text); return __skadapter__to_float(__skreturn); } void split_into_columns(int count) { @@ -2772,10 +2792,10 @@ bool start_popup(const string &name) { __skadapter__free__sklib_string(__skparam__name); return __skadapter__to_bool(__skreturn); } -bool start_treenode(const string &label) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); - int __skreturn = __sklib__start_treenode__string_ref(__skparam__label); - __skadapter__free__sklib_string(__skparam__label); +bool start_treenode(const string &label_text) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); + int __skreturn = __sklib__start_treenode__string_ref(__skparam__label_text); + __skadapter__free__sklib_string(__skparam__label_text); return __skadapter__to_bool(__skreturn); } string text_box(const string &value) { @@ -2791,11 +2811,11 @@ string text_box(const string &value, const rectangle &rect) { __skadapter__free__sklib_string(__skparam__value); return __skadapter__to_string(__skreturn); } -string text_box(const string &label, const string &value) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); +string text_box(const string &label_text, const string &value) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); const __sklib_string __skparam__value = __skadapter__to_sklib_string(value); - __sklib_string __skreturn = __sklib__text_box__string_ref__string_ref(__skparam__label, __skparam__value); - __skadapter__free__sklib_string(__skparam__label); + __sklib_string __skreturn = __sklib__text_box__string_ref__string_ref(__skparam__label_text, __skparam__value); + __skadapter__free__sklib_string(__skparam__label_text); __skadapter__free__sklib_string(__skparam__value); return __skadapter__to_string(__skreturn); } @@ -3553,9 +3573,9 @@ bool music_valid(music m) { int __skreturn = __sklib__music_valid__music(__skparam__m); return __skadapter__to_bool(__skreturn); } -float music_volume() { - float __skreturn = __sklib__music_volume(); - return __skadapter__to_float(__skreturn); +double music_volume() { + double __skreturn = __sklib__music_volume(); + return __skadapter__to_double(__skreturn); } void pause_music() { __sklib__pause_music(); @@ -3580,18 +3600,18 @@ void play_music(music data, int times) { int __skparam__times = __skadapter__to_int(times); __sklib__play_music__music__int(__skparam__data, __skparam__times); } -void play_music(music data, int times, float volume) { +void play_music(music data, int times, double volume) { __sklib_music __skparam__data = __skadapter__to_sklib_music(data); int __skparam__times = __skadapter__to_int(times); - float __skparam__volume = __skadapter__to_float(volume); - __sklib__play_music__music__int__float(__skparam__data, __skparam__times, __skparam__volume); + double __skparam__volume = __skadapter__to_double(volume); + __sklib__play_music__music__int__double(__skparam__data, __skparam__times, __skparam__volume); } void resume_music() { __sklib__resume_music(); } -void set_music_volume(float volume) { - float __skparam__volume = __skadapter__to_float(volume); - __sklib__set_music_volume__float(__skparam__volume); +void set_music_volume(double volume) { + double __skparam__volume = __skadapter__to_double(volume); + __sklib__set_music_volume__double(__skparam__volume); } void stop_music() { __sklib__stop_music(); @@ -4789,10 +4809,10 @@ void play_sound_effect(const string &name) { __sklib__play_sound_effect__string_ref(__skparam__name); __skadapter__free__sklib_string(__skparam__name); } -void play_sound_effect(const string &name, float volume) { +void play_sound_effect(const string &name, double volume) { const __sklib_string __skparam__name = __skadapter__to_sklib_string(name); - float __skparam__volume = __skadapter__to_float(volume); - __sklib__play_sound_effect__string_ref__float(__skparam__name, __skparam__volume); + double __skparam__volume = __skadapter__to_double(volume); + __sklib__play_sound_effect__string_ref__double(__skparam__name, __skparam__volume); __skadapter__free__sklib_string(__skparam__name); } void play_sound_effect(const string &name, int times) { @@ -4801,32 +4821,32 @@ void play_sound_effect(const string &name, int times) { __sklib__play_sound_effect__string_ref__int(__skparam__name, __skparam__times); __skadapter__free__sklib_string(__skparam__name); } -void play_sound_effect(const string &name, int times, float volume) { +void play_sound_effect(const string &name, int times, double volume) { const __sklib_string __skparam__name = __skadapter__to_sklib_string(name); int __skparam__times = __skadapter__to_int(times); - float __skparam__volume = __skadapter__to_float(volume); - __sklib__play_sound_effect__string_ref__int__float(__skparam__name, __skparam__times, __skparam__volume); + double __skparam__volume = __skadapter__to_double(volume); + __sklib__play_sound_effect__string_ref__int__double(__skparam__name, __skparam__times, __skparam__volume); __skadapter__free__sklib_string(__skparam__name); } void play_sound_effect(sound_effect effect) { __sklib_sound_effect __skparam__effect = __skadapter__to_sklib_sound_effect(effect); __sklib__play_sound_effect__sound_effect(__skparam__effect); } -void play_sound_effect(sound_effect effect, float volume) { +void play_sound_effect(sound_effect effect, double volume) { __sklib_sound_effect __skparam__effect = __skadapter__to_sklib_sound_effect(effect); - float __skparam__volume = __skadapter__to_float(volume); - __sklib__play_sound_effect__sound_effect__float(__skparam__effect, __skparam__volume); + double __skparam__volume = __skadapter__to_double(volume); + __sklib__play_sound_effect__sound_effect__double(__skparam__effect, __skparam__volume); } void play_sound_effect(sound_effect effect, int times) { __sklib_sound_effect __skparam__effect = __skadapter__to_sklib_sound_effect(effect); int __skparam__times = __skadapter__to_int(times); __sklib__play_sound_effect__sound_effect__int(__skparam__effect, __skparam__times); } -void play_sound_effect(sound_effect effect, int times, float volume) { +void play_sound_effect(sound_effect effect, int times, double volume) { __sklib_sound_effect __skparam__effect = __skadapter__to_sklib_sound_effect(effect); int __skparam__times = __skadapter__to_int(times); - float __skparam__volume = __skadapter__to_float(volume); - __sklib__play_sound_effect__sound_effect__int__float(__skparam__effect, __skparam__times, __skparam__volume); + double __skparam__volume = __skadapter__to_double(volume); + __sklib__play_sound_effect__sound_effect__int__double(__skparam__effect, __skparam__times, __skparam__volume); } string sound_effect_filename(sound_effect effect) { __sklib_sound_effect __skparam__effect = __skadapter__to_sklib_sound_effect(effect); @@ -6490,9 +6510,9 @@ double vector_magnitude(const vector_2d &v) { double __skreturn = __sklib__vector_magnitude__vector_2d_ref(__skparam__v); return __skadapter__to_double(__skreturn); } -double vector_magnitude_sqared(const vector_2d &v) { +double vector_magnitude_squared(const vector_2d &v) { const __sklib_vector_2d __skparam__v = __skadapter__to_sklib_vector_2d(v); - double __skreturn = __sklib__vector_magnitude_sqared__vector_2d_ref(__skparam__v); + double __skreturn = __sklib__vector_magnitude_squared__vector_2d_ref(__skparam__v); return __skadapter__to_double(__skreturn); } vector_2d vector_multiply(const vector_2d &v1, double s) { diff --git a/dotnet/SplashKit.cs b/dotnet/SplashKit.cs index 773299e..cd701e8 100644 --- a/dotnet/SplashKit.cs +++ b/dotnet/SplashKit.cs @@ -1341,6 +1341,12 @@ private static void __skadapter__update_from_vector_bool(ref __sklib_vector_bool [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__circle_radius__circle", CharSet=CharSet.Ansi)] private static extern float __sklib__circle_radius__circle(__sklib_circle c); + [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__circle_triangle_intersect__circle_ref__triangle_ref", CharSet=CharSet.Ansi)] + private static extern int __sklib__circle_triangle_intersect__circle_ref__triangle_ref(__sklib_circle c, __sklib_triangle tri); + + [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__circle_triangle_intersect__circle_ref__triangle_ref__point_2d_ref", CharSet=CharSet.Ansi)] + private static extern int __sklib__circle_triangle_intersect__circle_ref__triangle_ref__point_2d_ref(__sklib_circle c, __sklib_triangle tri, ref __sklib_point_2d p); + [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__circle_x__circle_ref", CharSet=CharSet.Ansi)] private static extern float __sklib__circle_x__circle_ref(__sklib_circle c); @@ -1362,6 +1368,9 @@ private static void __skadapter__update_from_vector_bool(ref __sklib_vector_bool [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__closest_point_on_rect_from_circle__circle_ref__rectangle_ref", CharSet=CharSet.Ansi)] private static extern __sklib_point_2d __sklib__closest_point_on_rect_from_circle__circle_ref__rectangle_ref(__sklib_circle c, __sklib_rectangle rect); + [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__closest_point_on_triangle_from_circle__circle_ref__triangle_ref", CharSet=CharSet.Ansi)] + private static extern __sklib_point_2d __sklib__closest_point_on_triangle_from_circle__circle_ref__triangle_ref(__sklib_circle c, __sklib_triangle tri); + [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__distant_point_on_circle__point_2d_ref__circle_ref", CharSet=CharSet.Ansi)] private static extern __sklib_point_2d __sklib__distant_point_on_circle__point_2d_ref__circle_ref(__sklib_point_2d pt, __sklib_circle c); @@ -2368,10 +2377,10 @@ private static void __skadapter__update_from_vector_bool(ref __sklib_vector_bool private static extern int __sklib__bitmap_button__bitmap__drawing_options(__sklib_ptr bmp, __sklib_drawing_options opts); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__bitmap_button__string_ref__bitmap", CharSet=CharSet.Ansi)] - private static extern int __sklib__bitmap_button__string_ref__bitmap(__sklib_string label, __sklib_ptr bmp); + private static extern int __sklib__bitmap_button__string_ref__bitmap(__sklib_string labelText, __sklib_ptr bmp); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__bitmap_button__string_ref__bitmap__drawing_options", CharSet=CharSet.Ansi)] - private static extern int __sklib__bitmap_button__string_ref__bitmap__drawing_options(__sklib_string label, __sklib_ptr bmp, __sklib_drawing_options opts); + private static extern int __sklib__bitmap_button__string_ref__bitmap__drawing_options(__sklib_string labelText, __sklib_ptr bmp, __sklib_drawing_options opts); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__button__string_ref__rectangle_ref", CharSet=CharSet.Ansi)] private static extern int __sklib__button__string_ref__rectangle_ref(__sklib_string text, __sklib_rectangle rect); @@ -2380,7 +2389,7 @@ private static void __skadapter__update_from_vector_bool(ref __sklib_vector_bool private static extern int __sklib__button__string_ref(__sklib_string text); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__button__string_ref__string_ref", CharSet=CharSet.Ansi)] - private static extern int __sklib__button__string_ref__string_ref(__sklib_string label, __sklib_string text); + private static extern int __sklib__button__string_ref__string_ref(__sklib_string labelText, __sklib_string text); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__checkbox__string_ref__bool_ref__rectangle_ref", CharSet=CharSet.Ansi)] private static extern int __sklib__checkbox__string_ref__bool_ref__rectangle_ref(__sklib_string text, int value, __sklib_rectangle rect); @@ -2389,7 +2398,7 @@ private static void __skadapter__update_from_vector_bool(ref __sklib_vector_bool private static extern int __sklib__checkbox__string_ref__bool_ref(__sklib_string text, int value); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__checkbox__string_ref__string_ref__bool_ref", CharSet=CharSet.Ansi)] - private static extern int __sklib__checkbox__string_ref__string_ref__bool_ref(__sklib_string label, __sklib_string text, int value); + private static extern int __sklib__checkbox__string_ref__string_ref__bool_ref(__sklib_string labelText, __sklib_string text, int value); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__color_slider__color_ref__rectangle_ref", CharSet=CharSet.Ansi)] private static extern __sklib_color __sklib__color_slider__color_ref__rectangle_ref(__sklib_color clr, __sklib_rectangle rect); @@ -2398,7 +2407,7 @@ private static void __skadapter__update_from_vector_bool(ref __sklib_vector_bool private static extern __sklib_color __sklib__color_slider__color_ref(__sklib_color clr); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__color_slider__string_ref__color_ref", CharSet=CharSet.Ansi)] - private static extern __sklib_color __sklib__color_slider__string_ref__color_ref(__sklib_string label, __sklib_color clr); + private static extern __sklib_color __sklib__color_slider__string_ref__color_ref(__sklib_string labelText, __sklib_color clr); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__disable_interface", CharSet=CharSet.Ansi)] private static extern void __sklib__disable_interface(); @@ -2419,7 +2428,7 @@ private static void __skadapter__update_from_vector_bool(ref __sklib_vector_bool private static extern void __sklib__end_popup__string_ref(__sklib_string name); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__end_treenode__string_ref", CharSet=CharSet.Ansi)] - private static extern void __sklib__end_treenode__string_ref(__sklib_string label); + private static extern void __sklib__end_treenode__string_ref(__sklib_string labelText); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__enter_column", CharSet=CharSet.Ansi)] private static extern void __sklib__enter_column(); @@ -2428,7 +2437,7 @@ private static void __skadapter__update_from_vector_bool(ref __sklib_vector_bool private static extern int __sklib__get_interface_label_width(); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__header__string_ref", CharSet=CharSet.Ansi)] - private static extern int __sklib__header__string_ref(__sklib_string label); + private static extern int __sklib__header__string_ref(__sklib_string labelText); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__hsb_color_slider__color_ref__rectangle_ref", CharSet=CharSet.Ansi)] private static extern __sklib_color __sklib__hsb_color_slider__color_ref__rectangle_ref(__sklib_color clr, __sklib_rectangle rect); @@ -2437,7 +2446,7 @@ private static void __skadapter__update_from_vector_bool(ref __sklib_vector_bool private static extern __sklib_color __sklib__hsb_color_slider__color_ref(__sklib_color clr); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__hsb_color_slider__string_ref__color_ref", CharSet=CharSet.Ansi)] - private static extern __sklib_color __sklib__hsb_color_slider__string_ref__color_ref(__sklib_string label, __sklib_color clr); + private static extern __sklib_color __sklib__hsb_color_slider__string_ref__color_ref(__sklib_string labelText, __sklib_color clr); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__interface_enabled", CharSet=CharSet.Ansi)] private static extern int __sklib__interface_enabled(); @@ -2445,11 +2454,11 @@ private static void __skadapter__update_from_vector_bool(ref __sklib_vector_bool [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__interface_style_panel__rectangle_ref", CharSet=CharSet.Ansi)] private static extern void __sklib__interface_style_panel__rectangle_ref(__sklib_rectangle initialRectangle); - [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__label__string_ref", CharSet=CharSet.Ansi)] - private static extern void __sklib__label__string_ref(__sklib_string text); + [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__label_element__string_ref", CharSet=CharSet.Ansi)] + private static extern void __sklib__label_element__string_ref(__sklib_string text); - [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__label__string_ref__rectangle_ref", CharSet=CharSet.Ansi)] - private static extern void __sklib__label__string_ref__rectangle_ref(__sklib_string text, __sklib_rectangle rect); + [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__label_element__string_ref__rectangle_ref", CharSet=CharSet.Ansi)] + private static extern void __sklib__label_element__string_ref__rectangle_ref(__sklib_string text, __sklib_rectangle rect); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__last_element_changed", CharSet=CharSet.Ansi)] private static extern int __sklib__last_element_changed(); @@ -2467,7 +2476,7 @@ private static void __skadapter__update_from_vector_bool(ref __sklib_vector_bool private static extern float __sklib__number_box__float_ref__float(float value, float step); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__number_box__string_ref__float_ref__float", CharSet=CharSet.Ansi)] - private static extern float __sklib__number_box__string_ref__float_ref__float(__sklib_string label, float value, float step); + private static extern float __sklib__number_box__string_ref__float_ref__float(__sklib_string labelText, float value, float step); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__open_popup__string_ref", CharSet=CharSet.Ansi)] private static extern void __sklib__open_popup__string_ref(__sklib_string name); @@ -2542,7 +2551,7 @@ private static void __skadapter__update_from_vector_bool(ref __sklib_vector_bool private static extern float __sklib__slider__float_ref__float__float(float value, float minValue, float maxValue); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__slider__string_ref__float_ref__float__float", CharSet=CharSet.Ansi)] - private static extern float __sklib__slider__string_ref__float_ref__float__float(__sklib_string label, float value, float minValue, float maxValue); + private static extern float __sklib__slider__string_ref__float_ref__float__float(__sklib_string labelText, float value, float minValue, float maxValue); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__split_into_columns__int", CharSet=CharSet.Ansi)] private static extern void __sklib__split_into_columns__int(int count); @@ -2569,7 +2578,7 @@ private static void __skadapter__update_from_vector_bool(ref __sklib_vector_bool private static extern int __sklib__start_popup__string_ref(__sklib_string name); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__start_treenode__string_ref", CharSet=CharSet.Ansi)] - private static extern int __sklib__start_treenode__string_ref(__sklib_string label); + private static extern int __sklib__start_treenode__string_ref(__sklib_string labelText); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__text_box__string_ref", CharSet=CharSet.Ansi)] private static extern __sklib_string __sklib__text_box__string_ref(__sklib_string value); @@ -2578,7 +2587,7 @@ private static void __skadapter__update_from_vector_bool(ref __sklib_vector_bool private static extern __sklib_string __sklib__text_box__string_ref__rectangle_ref(__sklib_string value, __sklib_rectangle rect); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__text_box__string_ref__string_ref", CharSet=CharSet.Ansi)] - private static extern __sklib_string __sklib__text_box__string_ref__string_ref(__sklib_string label, __sklib_string value); + private static extern __sklib_string __sklib__text_box__string_ref__string_ref(__sklib_string labelText, __sklib_string value); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__create_json", CharSet=CharSet.Ansi)] private static extern __sklib_ptr __sklib__create_json(); @@ -2968,7 +2977,7 @@ private static void __skadapter__update_from_vector_bool(ref __sklib_vector_bool private static extern int __sklib__music_valid__music(__sklib_ptr m); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__music_volume", CharSet=CharSet.Ansi)] - private static extern float __sklib__music_volume(); + private static extern double __sklib__music_volume(); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__pause_music", CharSet=CharSet.Ansi)] private static extern void __sklib__pause_music(); @@ -2985,14 +2994,14 @@ private static void __skadapter__update_from_vector_bool(ref __sklib_vector_bool [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__play_music__music__int", CharSet=CharSet.Ansi)] private static extern void __sklib__play_music__music__int(__sklib_ptr data, int times); - [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__play_music__music__int__float", CharSet=CharSet.Ansi)] - private static extern void __sklib__play_music__music__int__float(__sklib_ptr data, int times, float volume); + [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__play_music__music__int__double", CharSet=CharSet.Ansi)] + private static extern void __sklib__play_music__music__int__double(__sklib_ptr data, int times, double volume); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__resume_music", CharSet=CharSet.Ansi)] private static extern void __sklib__resume_music(); - [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__set_music_volume__float", CharSet=CharSet.Ansi)] - private static extern void __sklib__set_music_volume__float(float volume); + [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__set_music_volume__double", CharSet=CharSet.Ansi)] + private static extern void __sklib__set_music_volume__double(double volume); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__stop_music", CharSet=CharSet.Ansi)] private static extern void __sklib__stop_music(); @@ -3609,26 +3618,26 @@ private static void __skadapter__update_from_vector_bool(ref __sklib_vector_bool [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__play_sound_effect__string_ref", CharSet=CharSet.Ansi)] private static extern void __sklib__play_sound_effect__string_ref(__sklib_string name); - [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__play_sound_effect__string_ref__float", CharSet=CharSet.Ansi)] - private static extern void __sklib__play_sound_effect__string_ref__float(__sklib_string name, float volume); + [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__play_sound_effect__string_ref__double", CharSet=CharSet.Ansi)] + private static extern void __sklib__play_sound_effect__string_ref__double(__sklib_string name, double volume); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__play_sound_effect__string_ref__int", CharSet=CharSet.Ansi)] private static extern void __sklib__play_sound_effect__string_ref__int(__sklib_string name, int times); - [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__play_sound_effect__string_ref__int__float", CharSet=CharSet.Ansi)] - private static extern void __sklib__play_sound_effect__string_ref__int__float(__sklib_string name, int times, float volume); + [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__play_sound_effect__string_ref__int__double", CharSet=CharSet.Ansi)] + private static extern void __sklib__play_sound_effect__string_ref__int__double(__sklib_string name, int times, double volume); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__play_sound_effect__sound_effect", CharSet=CharSet.Ansi)] private static extern void __sklib__play_sound_effect__sound_effect(__sklib_ptr effect); - [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__play_sound_effect__sound_effect__float", CharSet=CharSet.Ansi)] - private static extern void __sklib__play_sound_effect__sound_effect__float(__sklib_ptr effect, float volume); + [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__play_sound_effect__sound_effect__double", CharSet=CharSet.Ansi)] + private static extern void __sklib__play_sound_effect__sound_effect__double(__sklib_ptr effect, double volume); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__play_sound_effect__sound_effect__int", CharSet=CharSet.Ansi)] private static extern void __sklib__play_sound_effect__sound_effect__int(__sklib_ptr effect, int times); - [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__play_sound_effect__sound_effect__int__float", CharSet=CharSet.Ansi)] - private static extern void __sklib__play_sound_effect__sound_effect__int__float(__sklib_ptr effect, int times, float volume); + [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__play_sound_effect__sound_effect__int__double", CharSet=CharSet.Ansi)] + private static extern void __sklib__play_sound_effect__sound_effect__int__double(__sklib_ptr effect, int times, double volume); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__sound_effect_filename__sound_effect", CharSet=CharSet.Ansi)] private static extern __sklib_string __sklib__sound_effect_filename__sound_effect(__sklib_ptr effect); @@ -4458,8 +4467,8 @@ private static void __skadapter__update_from_vector_bool(ref __sklib_vector_bool [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__vector_magnitude__vector_2d_ref", CharSet=CharSet.Ansi)] private static extern double __sklib__vector_magnitude__vector_2d_ref(__sklib_vector_2d v); - [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__vector_magnitude_sqared__vector_2d_ref", CharSet=CharSet.Ansi)] - private static extern double __sklib__vector_magnitude_sqared__vector_2d_ref(__sklib_vector_2d v); + [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__vector_magnitude_squared__vector_2d_ref", CharSet=CharSet.Ansi)] + private static extern double __sklib__vector_magnitude_squared__vector_2d_ref(__sklib_vector_2d v); [DllImport("SplashKit", CallingConvention=CallingConvention.Cdecl, EntryPoint="__sklib__vector_multiply__vector_2d_ref__double", CharSet=CharSet.Ansi)] private static extern __sklib_vector_2d __sklib__vector_multiply__vector_2d_ref__double(__sklib_vector_2d v1, double s); @@ -5751,6 +5760,29 @@ public static float CircleRadius(Circle c) __skreturn = __sklib__circle_radius__circle(__skparam__c); return __skadapter__to_float(__skreturn); } + public static bool CircleTriangleIntersect(Circle c, Triangle tri) + { + __sklib_circle __skparam__c; + __sklib_triangle __skparam__tri; + int __skreturn; + __skparam__c = __skadapter__to_sklib_circle(c); + __skparam__tri = __skadapter__to_sklib_triangle(tri); + __skreturn = __sklib__circle_triangle_intersect__circle_ref__triangle_ref(__skparam__c, __skparam__tri); + return __skadapter__to_bool(__skreturn); + } + public static bool CircleTriangleIntersect(Circle c, Triangle tri, ref Point2D p) + { + __sklib_circle __skparam__c; + __sklib_triangle __skparam__tri; + __sklib_point_2d __skparam__p; + int __skreturn; + __skparam__c = __skadapter__to_sklib_circle(c); + __skparam__tri = __skadapter__to_sklib_triangle(tri); + __skparam__p = __skadapter__to_sklib_point_2d(p); + __skreturn = __sklib__circle_triangle_intersect__circle_ref__triangle_ref__point_2d_ref(__skparam__c, __skparam__tri, ref __skparam__p); + p = __skadapter__to_point_2d(__skparam__p); + return __skadapter__to_bool(__skreturn); + } public static float CircleX(Circle c) { __sklib_circle __skparam__c; @@ -5825,6 +5857,16 @@ public static Point2D ClosestPointOnRectFromCircle(Circle c, Rectangle rect) __skreturn = __sklib__closest_point_on_rect_from_circle__circle_ref__rectangle_ref(__skparam__c, __skparam__rect); return __skadapter__to_point_2d(__skreturn); } + public static Point2D ClosestPointOnTriangleFromCircle(Circle c, Triangle tri) + { + __sklib_circle __skparam__c; + __sklib_triangle __skparam__tri; + __sklib_point_2d __skreturn; + __skparam__c = __skadapter__to_sklib_circle(c); + __skparam__tri = __skadapter__to_sklib_triangle(tri); + __skreturn = __sklib__closest_point_on_triangle_from_circle__circle_ref__triangle_ref(__skparam__c, __skparam__tri); + return __skadapter__to_point_2d(__skreturn); + } public static Point2D DistantPointOnCircle(Point2D pt, Circle c) { __sklib_point_2d __skparam__pt; @@ -8644,28 +8686,28 @@ public static bool BitmapButton(Bitmap bmp, DrawingOptions opts) __skreturn = __sklib__bitmap_button__bitmap__drawing_options(__skparam__bmp, __skparam__opts); return __skadapter__to_bool(__skreturn); } - public static bool BitmapButton(string label, Bitmap bmp) + public static bool BitmapButton(string labelText, Bitmap bmp) { - __sklib_string __skparam__label; + __sklib_string __skparam__label_text; __sklib_ptr __skparam__bmp; int __skreturn; - __skparam__label = __skadapter__to_sklib_string(label); + __skparam__label_text = __skadapter__to_sklib_string(labelText); __skparam__bmp = __skadapter__to_sklib_bitmap(bmp); - __skreturn = __sklib__bitmap_button__string_ref__bitmap(__skparam__label, __skparam__bmp); - __skadapter__free__sklib_string(ref __skparam__label); + __skreturn = __sklib__bitmap_button__string_ref__bitmap(__skparam__label_text, __skparam__bmp); + __skadapter__free__sklib_string(ref __skparam__label_text); return __skadapter__to_bool(__skreturn); } - public static bool BitmapButton(string label, Bitmap bmp, DrawingOptions opts) + public static bool BitmapButton(string labelText, Bitmap bmp, DrawingOptions opts) { - __sklib_string __skparam__label; + __sklib_string __skparam__label_text; __sklib_ptr __skparam__bmp; __sklib_drawing_options __skparam__opts; int __skreturn; - __skparam__label = __skadapter__to_sklib_string(label); + __skparam__label_text = __skadapter__to_sklib_string(labelText); __skparam__bmp = __skadapter__to_sklib_bitmap(bmp); __skparam__opts = __skadapter__to_sklib_drawing_options(opts); - __skreturn = __sklib__bitmap_button__string_ref__bitmap__drawing_options(__skparam__label, __skparam__bmp, __skparam__opts); - __skadapter__free__sklib_string(ref __skparam__label); + __skreturn = __sklib__bitmap_button__string_ref__bitmap__drawing_options(__skparam__label_text, __skparam__bmp, __skparam__opts); + __skadapter__free__sklib_string(ref __skparam__label_text); return __skadapter__to_bool(__skreturn); } public static bool Button(string text, Rectangle rect) @@ -8688,15 +8730,15 @@ public static bool Button(string text) __skadapter__free__sklib_string(ref __skparam__text); return __skadapter__to_bool(__skreturn); } - public static bool Button(string label, string text) + public static bool Button(string labelText, string text) { - __sklib_string __skparam__label; + __sklib_string __skparam__label_text; __sklib_string __skparam__text; int __skreturn; - __skparam__label = __skadapter__to_sklib_string(label); + __skparam__label_text = __skadapter__to_sklib_string(labelText); __skparam__text = __skadapter__to_sklib_string(text); - __skreturn = __sklib__button__string_ref__string_ref(__skparam__label, __skparam__text); - __skadapter__free__sklib_string(ref __skparam__label); + __skreturn = __sklib__button__string_ref__string_ref(__skparam__label_text, __skparam__text); + __skadapter__free__sklib_string(ref __skparam__label_text); __skadapter__free__sklib_string(ref __skparam__text); return __skadapter__to_bool(__skreturn); } @@ -8724,17 +8766,17 @@ public static bool Checkbox(string text, bool value) __skadapter__free__sklib_string(ref __skparam__text); return __skadapter__to_bool(__skreturn); } - public static bool Checkbox(string label, string text, bool value) + public static bool Checkbox(string labelText, string text, bool value) { - __sklib_string __skparam__label; + __sklib_string __skparam__label_text; __sklib_string __skparam__text; int __skparam__value; int __skreturn; - __skparam__label = __skadapter__to_sklib_string(label); + __skparam__label_text = __skadapter__to_sklib_string(labelText); __skparam__text = __skadapter__to_sklib_string(text); __skparam__value = __skadapter__to_sklib_bool(value); - __skreturn = __sklib__checkbox__string_ref__string_ref__bool_ref(__skparam__label, __skparam__text, __skparam__value); - __skadapter__free__sklib_string(ref __skparam__label); + __skreturn = __sklib__checkbox__string_ref__string_ref__bool_ref(__skparam__label_text, __skparam__text, __skparam__value); + __skadapter__free__sklib_string(ref __skparam__label_text); __skadapter__free__sklib_string(ref __skparam__text); return __skadapter__to_bool(__skreturn); } @@ -8756,15 +8798,15 @@ public static Color ColorSlider(Color clr) __skreturn = __sklib__color_slider__color_ref(__skparam__clr); return __skadapter__to_color(__skreturn); } - public static Color ColorSlider(string label, Color clr) + public static Color ColorSlider(string labelText, Color clr) { - __sklib_string __skparam__label; + __sklib_string __skparam__label_text; __sklib_color __skparam__clr; __sklib_color __skreturn; - __skparam__label = __skadapter__to_sklib_string(label); + __skparam__label_text = __skadapter__to_sklib_string(labelText); __skparam__clr = __skadapter__to_sklib_color(clr); - __skreturn = __sklib__color_slider__string_ref__color_ref(__skparam__label, __skparam__clr); - __skadapter__free__sklib_string(ref __skparam__label); + __skreturn = __sklib__color_slider__string_ref__color_ref(__skparam__label_text, __skparam__clr); + __skadapter__free__sklib_string(ref __skparam__label_text); return __skadapter__to_color(__skreturn); } public static void DisableInterface() @@ -8800,12 +8842,12 @@ public static void EndPopup(string name) __sklib__end_popup__string_ref(__skparam__name); __skadapter__free__sklib_string(ref __skparam__name); } - public static void EndTreenode(string label) + public static void EndTreenode(string labelText) { - __sklib_string __skparam__label; - __skparam__label = __skadapter__to_sklib_string(label); - __sklib__end_treenode__string_ref(__skparam__label); - __skadapter__free__sklib_string(ref __skparam__label); + __sklib_string __skparam__label_text; + __skparam__label_text = __skadapter__to_sklib_string(labelText); + __sklib__end_treenode__string_ref(__skparam__label_text); + __skadapter__free__sklib_string(ref __skparam__label_text); } public static void EnterColumn() { @@ -8817,13 +8859,13 @@ public static int GetInterfaceLabelWidth() __skreturn = __sklib__get_interface_label_width(); return __skadapter__to_int(__skreturn); } - public static bool Header(string label) + public static bool Header(string labelText) { - __sklib_string __skparam__label; + __sklib_string __skparam__label_text; int __skreturn; - __skparam__label = __skadapter__to_sklib_string(label); - __skreturn = __sklib__header__string_ref(__skparam__label); - __skadapter__free__sklib_string(ref __skparam__label); + __skparam__label_text = __skadapter__to_sklib_string(labelText); + __skreturn = __sklib__header__string_ref(__skparam__label_text); + __skadapter__free__sklib_string(ref __skparam__label_text); return __skadapter__to_bool(__skreturn); } public static Color HSBColorSlider(Color clr, Rectangle rect) @@ -8844,15 +8886,15 @@ public static Color HSBColorSlider(Color clr) __skreturn = __sklib__hsb_color_slider__color_ref(__skparam__clr); return __skadapter__to_color(__skreturn); } - public static Color HSBColorSlider(string label, Color clr) + public static Color HSBColorSlider(string labelText, Color clr) { - __sklib_string __skparam__label; + __sklib_string __skparam__label_text; __sklib_color __skparam__clr; __sklib_color __skreturn; - __skparam__label = __skadapter__to_sklib_string(label); + __skparam__label_text = __skadapter__to_sklib_string(labelText); __skparam__clr = __skadapter__to_sklib_color(clr); - __skreturn = __sklib__hsb_color_slider__string_ref__color_ref(__skparam__label, __skparam__clr); - __skadapter__free__sklib_string(ref __skparam__label); + __skreturn = __sklib__hsb_color_slider__string_ref__color_ref(__skparam__label_text, __skparam__clr); + __skadapter__free__sklib_string(ref __skparam__label_text); return __skadapter__to_color(__skreturn); } public static bool InterfaceEnabled() @@ -8867,20 +8909,20 @@ public static void InterfaceStylePanel(Rectangle initialRectangle) __skparam__initial_rectangle = __skadapter__to_sklib_rectangle(initialRectangle); __sklib__interface_style_panel__rectangle_ref(__skparam__initial_rectangle); } - public static void Label(string text) + public static void LabelElement(string text) { __sklib_string __skparam__text; __skparam__text = __skadapter__to_sklib_string(text); - __sklib__label__string_ref(__skparam__text); + __sklib__label_element__string_ref(__skparam__text); __skadapter__free__sklib_string(ref __skparam__text); } - public static void Label(string text, Rectangle rect) + public static void LabelElement(string text, Rectangle rect) { __sklib_string __skparam__text; __sklib_rectangle __skparam__rect; __skparam__text = __skadapter__to_sklib_string(text); __skparam__rect = __skadapter__to_sklib_rectangle(rect); - __sklib__label__string_ref__rectangle_ref(__skparam__text, __skparam__rect); + __sklib__label_element__string_ref__rectangle_ref(__skparam__text, __skparam__rect); __skadapter__free__sklib_string(ref __skparam__text); } public static bool LastElementChanged() @@ -8921,17 +8963,17 @@ public static float NumberBox(float value, float step) __skreturn = __sklib__number_box__float_ref__float(__skparam__value, __skparam__step); return __skadapter__to_float(__skreturn); } - public static float NumberBox(string label, float value, float step) + public static float NumberBox(string labelText, float value, float step) { - __sklib_string __skparam__label; + __sklib_string __skparam__label_text; float __skparam__value; float __skparam__step; float __skreturn; - __skparam__label = __skadapter__to_sklib_string(label); + __skparam__label_text = __skadapter__to_sklib_string(labelText); __skparam__value = __skadapter__to_sklib_float(value); __skparam__step = __skadapter__to_sklib_float(step); - __skreturn = __sklib__number_box__string_ref__float_ref__float(__skparam__label, __skparam__value, __skparam__step); - __skadapter__free__sklib_string(ref __skparam__label); + __skreturn = __sklib__number_box__string_ref__float_ref__float(__skparam__label_text, __skparam__value, __skparam__step); + __skadapter__free__sklib_string(ref __skparam__label_text); return __skadapter__to_float(__skreturn); } public static void OpenPopup(string name) @@ -9122,19 +9164,19 @@ public static float Slider(float value, float minValue, float maxValue) __skreturn = __sklib__slider__float_ref__float__float(__skparam__value, __skparam__min_value, __skparam__max_value); return __skadapter__to_float(__skreturn); } - public static float Slider(string label, float value, float minValue, float maxValue) + public static float Slider(string labelText, float value, float minValue, float maxValue) { - __sklib_string __skparam__label; + __sklib_string __skparam__label_text; float __skparam__value; float __skparam__min_value; float __skparam__max_value; float __skreturn; - __skparam__label = __skadapter__to_sklib_string(label); + __skparam__label_text = __skadapter__to_sklib_string(labelText); __skparam__value = __skadapter__to_sklib_float(value); __skparam__min_value = __skadapter__to_sklib_float(minValue); __skparam__max_value = __skadapter__to_sklib_float(maxValue); - __skreturn = __sklib__slider__string_ref__float_ref__float__float(__skparam__label, __skparam__value, __skparam__min_value, __skparam__max_value); - __skadapter__free__sklib_string(ref __skparam__label); + __skreturn = __sklib__slider__string_ref__float_ref__float__float(__skparam__label_text, __skparam__value, __skparam__min_value, __skparam__max_value); + __skadapter__free__sklib_string(ref __skparam__label_text); return __skadapter__to_float(__skreturn); } public static void SplitIntoColumns(int count) @@ -9201,13 +9243,13 @@ public static bool StartPopup(string name) __skadapter__free__sklib_string(ref __skparam__name); return __skadapter__to_bool(__skreturn); } - public static bool StartTreenode(string label) + public static bool StartTreenode(string labelText) { - __sklib_string __skparam__label; + __sklib_string __skparam__label_text; int __skreturn; - __skparam__label = __skadapter__to_sklib_string(label); - __skreturn = __sklib__start_treenode__string_ref(__skparam__label); - __skadapter__free__sklib_string(ref __skparam__label); + __skparam__label_text = __skadapter__to_sklib_string(labelText); + __skreturn = __sklib__start_treenode__string_ref(__skparam__label_text); + __skadapter__free__sklib_string(ref __skparam__label_text); return __skadapter__to_bool(__skreturn); } public static string TextBox(string value) @@ -9230,15 +9272,15 @@ public static string TextBox(string value, Rectangle rect) __skadapter__free__sklib_string(ref __skparam__value); return __skadapter__to_string(__skreturn); } - public static string TextBox(string label, string value) + public static string TextBox(string labelText, string value) { - __sklib_string __skparam__label; + __sklib_string __skparam__label_text; __sklib_string __skparam__value; __sklib_string __skreturn; - __skparam__label = __skadapter__to_sklib_string(label); + __skparam__label_text = __skadapter__to_sklib_string(labelText); __skparam__value = __skadapter__to_sklib_string(value); - __skreturn = __sklib__text_box__string_ref__string_ref(__skparam__label, __skparam__value); - __skadapter__free__sklib_string(ref __skparam__label); + __skreturn = __sklib__text_box__string_ref__string_ref(__skparam__label_text, __skparam__value); + __skadapter__free__sklib_string(ref __skparam__label_text); __skadapter__free__sklib_string(ref __skparam__value); return __skadapter__to_string(__skreturn); } @@ -10440,11 +10482,11 @@ public static bool MusicValid(Music m) __skreturn = __sklib__music_valid__music(__skparam__m); return __skadapter__to_bool(__skreturn); } - public static float MusicVolume() + public static double MusicVolume() { - float __skreturn; + double __skreturn; __skreturn = __sklib__music_volume(); - return __skadapter__to_float(__skreturn); + return __skadapter__to_double(__skreturn); } public static void PauseMusic() { @@ -10480,25 +10522,25 @@ public static void PlayMusic(Music data, int times) __skparam__times = __skadapter__to_sklib_int(times); __sklib__play_music__music__int(__skparam__data, __skparam__times); } - public static void PlayMusic(Music data, int times, float volume) + public static void PlayMusic(Music data, int times, double volume) { __sklib_ptr __skparam__data; int __skparam__times; - float __skparam__volume; + double __skparam__volume; __skparam__data = __skadapter__to_sklib_music(data); __skparam__times = __skadapter__to_sklib_int(times); - __skparam__volume = __skadapter__to_sklib_float(volume); - __sklib__play_music__music__int__float(__skparam__data, __skparam__times, __skparam__volume); + __skparam__volume = __skadapter__to_sklib_double(volume); + __sklib__play_music__music__int__double(__skparam__data, __skparam__times, __skparam__volume); } public static void ResumeMusic() { __sklib__resume_music(); } - public static void SetMusicVolume(float volume) + public static void SetMusicVolume(double volume) { - float __skparam__volume; - __skparam__volume = __skadapter__to_sklib_float(volume); - __sklib__set_music_volume__float(__skparam__volume); + double __skparam__volume; + __skparam__volume = __skadapter__to_sklib_double(volume); + __sklib__set_music_volume__double(__skparam__volume); } public static void StopMusic() { @@ -12438,13 +12480,13 @@ public static void PlaySoundEffect(string name) __sklib__play_sound_effect__string_ref(__skparam__name); __skadapter__free__sklib_string(ref __skparam__name); } - public static void PlaySoundEffect(string name, float volume) + public static void PlaySoundEffect(string name, double volume) { __sklib_string __skparam__name; - float __skparam__volume; + double __skparam__volume; __skparam__name = __skadapter__to_sklib_string(name); - __skparam__volume = __skadapter__to_sklib_float(volume); - __sklib__play_sound_effect__string_ref__float(__skparam__name, __skparam__volume); + __skparam__volume = __skadapter__to_sklib_double(volume); + __sklib__play_sound_effect__string_ref__double(__skparam__name, __skparam__volume); __skadapter__free__sklib_string(ref __skparam__name); } public static void PlaySoundEffect(string name, int times) @@ -12456,15 +12498,15 @@ public static void PlaySoundEffect(string name, int times) __sklib__play_sound_effect__string_ref__int(__skparam__name, __skparam__times); __skadapter__free__sklib_string(ref __skparam__name); } - public static void PlaySoundEffect(string name, int times, float volume) + public static void PlaySoundEffect(string name, int times, double volume) { __sklib_string __skparam__name; int __skparam__times; - float __skparam__volume; + double __skparam__volume; __skparam__name = __skadapter__to_sklib_string(name); __skparam__times = __skadapter__to_sklib_int(times); - __skparam__volume = __skadapter__to_sklib_float(volume); - __sklib__play_sound_effect__string_ref__int__float(__skparam__name, __skparam__times, __skparam__volume); + __skparam__volume = __skadapter__to_sklib_double(volume); + __sklib__play_sound_effect__string_ref__int__double(__skparam__name, __skparam__times, __skparam__volume); __skadapter__free__sklib_string(ref __skparam__name); } public static void PlaySoundEffect(SoundEffect effect) @@ -12473,13 +12515,13 @@ public static void PlaySoundEffect(SoundEffect effect) __skparam__effect = __skadapter__to_sklib_sound_effect(effect); __sklib__play_sound_effect__sound_effect(__skparam__effect); } - public static void PlaySoundEffect(SoundEffect effect, float volume) + public static void PlaySoundEffect(SoundEffect effect, double volume) { __sklib_ptr __skparam__effect; - float __skparam__volume; + double __skparam__volume; __skparam__effect = __skadapter__to_sklib_sound_effect(effect); - __skparam__volume = __skadapter__to_sklib_float(volume); - __sklib__play_sound_effect__sound_effect__float(__skparam__effect, __skparam__volume); + __skparam__volume = __skadapter__to_sklib_double(volume); + __sklib__play_sound_effect__sound_effect__double(__skparam__effect, __skparam__volume); } public static void PlaySoundEffect(SoundEffect effect, int times) { @@ -12489,15 +12531,15 @@ public static void PlaySoundEffect(SoundEffect effect, int times) __skparam__times = __skadapter__to_sklib_int(times); __sklib__play_sound_effect__sound_effect__int(__skparam__effect, __skparam__times); } - public static void PlaySoundEffect(SoundEffect effect, int times, float volume) + public static void PlaySoundEffect(SoundEffect effect, int times, double volume) { __sklib_ptr __skparam__effect; int __skparam__times; - float __skparam__volume; + double __skparam__volume; __skparam__effect = __skadapter__to_sklib_sound_effect(effect); __skparam__times = __skadapter__to_sklib_int(times); - __skparam__volume = __skadapter__to_sklib_float(volume); - __sklib__play_sound_effect__sound_effect__int__float(__skparam__effect, __skparam__times, __skparam__volume); + __skparam__volume = __skadapter__to_sklib_double(volume); + __sklib__play_sound_effect__sound_effect__int__double(__skparam__effect, __skparam__times, __skparam__volume); } public static string SoundEffectFilename(SoundEffect effect) { @@ -15180,12 +15222,12 @@ public static double VectorMagnitude(Vector2D v) __skreturn = __sklib__vector_magnitude__vector_2d_ref(__skparam__v); return __skadapter__to_double(__skreturn); } - public static double VectorMagnitudeSqared(Vector2D v) + public static double VectorMagnitudeSquared(Vector2D v) { __sklib_vector_2d __skparam__v; double __skreturn; __skparam__v = __skadapter__to_sklib_vector_2d(v); - __skreturn = __sklib__vector_magnitude_sqared__vector_2d_ref(__skparam__v); + __skreturn = __sklib__vector_magnitude_squared__vector_2d_ref(__skparam__v); return __skadapter__to_double(__skreturn); } public static Vector2D VectorMultiply(Vector2D v1, double s) @@ -17680,7 +17722,7 @@ public void Play(int times) } - public void Play(int times, float volume) + public void Play(int times, double volume) { SplashKit.PlayMusic(this, times, volume); } @@ -17963,7 +18005,7 @@ public void Play() } - public void Play(float volume) + public void Play(double volume) { SplashKit.PlaySoundEffect(this, volume); } @@ -17975,7 +18017,7 @@ public void Play(int times) } - public void Play(int times, float volume) + public void Play(int times, double volume) { SplashKit.PlaySoundEffect(this, times, volume); } @@ -20215,7 +20257,7 @@ public static bool Playing { get { return SplashKit.MusicPlaying(); } } - public static float Volume + public static double Volume { get { return SplashKit.MusicVolume(); } set { SplashKit.SetMusicVolume(value); } diff --git a/fpc/SplashKit.pas b/fpc/SplashKit.pas index 51ee6db..d5bb9be 100644 --- a/fpc/SplashKit.pas +++ b/fpc/SplashKit.pas @@ -493,6 +493,8 @@ function CenterPoint(const c: Circle): Point2D; function CircleAt(const pt: Point2D; radius: Double): Circle; function CircleAt(x: Double; y: Double; radius: Double): Circle; function CircleRadius(c: Circle): Single; +function CircleTriangleIntersect(const c: Circle; const tri: Triangle): Boolean; +function CircleTriangleIntersect(const c: Circle; const tri: Triangle; var p: Point2D): Boolean; function CircleX(const c: Circle): Single; function CircleY(const c: Circle): Single; function CirclesIntersect(c1: Circle; c2: Circle): Boolean; @@ -500,6 +502,7 @@ function CirclesIntersect(c1X: Double; c1Y: Double; c1Radius: Double; c2X: Doubl function ClosestPointOnCircle(const fromPt: Point2D; const c: Circle): Point2D; function ClosestPointOnLineFromCircle(const c: Circle; const l: Line): Point2D; function ClosestPointOnRectFromCircle(const c: Circle; const rect: Rectangle): Point2D; +function ClosestPointOnTriangleFromCircle(const c: Circle; const tri: Triangle): Point2D; function DistantPointOnCircle(const pt: Point2D; const c: Circle): Point2D; function DistantPointOnCircleHeading(const pt: Point2D; const c: Circle; const heading: Vector2D; var oppositePt: Point2D): Boolean; function RayCircleIntersectDistance(const rayOrigin: Point2D; const rayHeading: Vector2D; const c: Circle): Single; @@ -835,40 +838,40 @@ function BitmapButton(bmp: Bitmap): Boolean; function BitmapButton(bmp: Bitmap; const rect: Rectangle): Boolean; function BitmapButton(bmp: Bitmap; const rect: Rectangle; opts: DrawingOptions): Boolean; function BitmapButton(bmp: Bitmap; opts: DrawingOptions): Boolean; -function BitmapButton(const label: String; bmp: Bitmap): Boolean; -function BitmapButton(const label: String; bmp: Bitmap; opts: DrawingOptions): Boolean; +function BitmapButton(const labelText: String; bmp: Bitmap): Boolean; +function BitmapButton(const labelText: String; bmp: Bitmap; opts: DrawingOptions): Boolean; function Button(const text: String; const rect: Rectangle): Boolean; function Button(const text: String): Boolean; -function Button(const label: String; const text: String): Boolean; +function Button(const labelText: String; const text: String): Boolean; function Checkbox(const text: String; const value: Boolean; const rect: Rectangle): Boolean; function Checkbox(const text: String; const value: Boolean): Boolean; -function Checkbox(const label: String; const text: String; const value: Boolean): Boolean; +function Checkbox(const labelText: String; const text: String; const value: Boolean): Boolean; function ColorSlider(const clr: Color; const rect: Rectangle): Color; function ColorSlider(const clr: Color): Color; -function ColorSlider(const label: String; const clr: Color): Color; +function ColorSlider(const labelText: String; const clr: Color): Color; procedure DisableInterface(); procedure DrawInterface(); procedure EnableInterface(); procedure EndInset(const name: String); procedure EndPanel(const name: String); procedure EndPopup(const name: String); -procedure EndTreenode(const label: String); +procedure EndTreenode(const labelText: String); procedure EnterColumn(); function GetInterfaceLabelWidth(): Integer; -function Header(const label: String): Boolean; +function Header(const labelText: String): Boolean; function HSBColorSlider(const clr: Color; const rect: Rectangle): Color; function HSBColorSlider(const clr: Color): Color; -function HSBColorSlider(const label: String; const clr: Color): Color; +function HSBColorSlider(const labelText: String; const clr: Color): Color; function InterfaceEnabled(): Boolean; procedure InterfaceStylePanel(const initialRectangle: Rectangle); -procedure Label(const text: String); -procedure Label(const text: String; const rect: Rectangle); +procedure LabelElement(const text: String); +procedure LabelElement(const text: String; const rect: Rectangle); function LastElementChanged(): Boolean; function LastElementConfirmed(): Boolean; procedure LeaveColumn(); function NumberBox(const value: Single; step: Single; const rect: Rectangle): Single; function NumberBox(const value: Single; step: Single): Single; -function NumberBox(const label: String; const value: Single; step: Single): Single; +function NumberBox(const labelText: String; const value: Single; step: Single): Single; procedure OpenPopup(const name: String); procedure Paragraph(const text: String); procedure Paragraph(const text: String; const rect: Rectangle); @@ -893,7 +896,7 @@ procedure SetLayoutHeight(height: Integer); procedure SingleLineLayout(); function Slider(const value: Single; minValue: Single; maxValue: Single; const rect: Rectangle): Single; function Slider(const value: Single; minValue: Single; maxValue: Single): Single; -function Slider(const label: String; const value: Single; minValue: Single; maxValue: Single): Single; +function Slider(const labelText: String; const value: Single; minValue: Single; maxValue: Single): Single; procedure SplitIntoColumns(count: Integer); procedure SplitIntoColumns(count: Integer; lastWidth: Integer); procedure SplitIntoColumnsRelative(count: Integer; lastWidth: Double); @@ -902,10 +905,10 @@ procedure StartInset(const name: String; const rect: Rectangle); procedure StartInset(const name: String; height: Integer); function StartPanel(const name: String; initialRectangle: Rectangle): Boolean; function StartPopup(const name: String): Boolean; -function StartTreenode(const label: String): Boolean; +function StartTreenode(const labelText: String): Boolean; function TextBox(const value: String): String; function TextBox(const value: String; const rect: Rectangle): String; -function TextBox(const label: String; const value: String): String; +function TextBox(const labelText: String; const value: String): String; function CreateJson(): Json; function CreateJson(jsonString: String): Json; procedure FreeAllJson(); @@ -1035,15 +1038,15 @@ function MusicName(data: Music): String; function MusicNamed(const name: String): Music; function MusicPlaying(): Boolean; function MusicValid(m: Music): Boolean; -function MusicVolume(): Single; +function MusicVolume(): Double; procedure PauseMusic(); procedure PlayMusic(const name: String); procedure PlayMusic(const name: String; times: Integer); procedure PlayMusic(data: Music); procedure PlayMusic(data: Music; times: Integer); -procedure PlayMusic(data: Music; times: Integer; volume: Single); +procedure PlayMusic(data: Music; times: Integer; volume: Double); procedure ResumeMusic(); -procedure SetMusicVolume(volume: Single); +procedure SetMusicVolume(volume: Double); procedure StopMusic(); function AcceptAllNewConnections(): Boolean; function AcceptNewConnection(server: ServerSocket): Boolean; @@ -1249,13 +1252,13 @@ procedure FreeSoundEffect(effect: SoundEffect); function HasSoundEffect(const name: String): Boolean; function LoadSoundEffect(const name: String; const filename: String): SoundEffect; procedure PlaySoundEffect(const name: String); -procedure PlaySoundEffect(const name: String; volume: Single); +procedure PlaySoundEffect(const name: String; volume: Double); procedure PlaySoundEffect(const name: String; times: Integer); -procedure PlaySoundEffect(const name: String; times: Integer; volume: Single); +procedure PlaySoundEffect(const name: String; times: Integer; volume: Double); procedure PlaySoundEffect(effect: SoundEffect); -procedure PlaySoundEffect(effect: SoundEffect; volume: Single); +procedure PlaySoundEffect(effect: SoundEffect; volume: Double); procedure PlaySoundEffect(effect: SoundEffect; times: Integer); -procedure PlaySoundEffect(effect: SoundEffect; times: Integer; volume: Single); +procedure PlaySoundEffect(effect: SoundEffect; times: Integer; volume: Double); function SoundEffectFilename(effect: SoundEffect): String; function SoundEffectName(effect: SoundEffect): String; function SoundEffectNamed(const name: String): SoundEffect; @@ -1532,7 +1535,7 @@ function VectorInRect(const v: Vector2D; const rect: Rectangle): Boolean; function VectorInvert(const v: Vector2D): Vector2D; function VectorLimit(const v: Vector2D; limit: Double): Vector2D; function VectorMagnitude(const v: Vector2D): Double; -function VectorMagnitudeSqared(const v: Vector2D): Double; +function VectorMagnitudeSquared(const v: Vector2D): Double; function VectorMultiply(const v1: Vector2D; s: Double): Vector2D; function VectorNormal(const v: Vector2D): Vector2D; function VectorOutOfCircleFromCircle(const src: Circle; const bounds: Circle; const velocity: Vector2D): Vector2D; @@ -2705,6 +2708,8 @@ function __sklib__center_point__circle_ref(const c: __sklib_circle): __sklib_poi function __sklib__circle_at__point_2d_ref__double(const pt: __sklib_point_2d; radius: Double): __sklib_circle; cdecl; external; function __sklib__circle_at__double__double__double(x: Double; y: Double; radius: Double): __sklib_circle; cdecl; external; function __sklib__circle_radius__circle(c: __sklib_circle): Single; cdecl; external; +function __sklib__circle_triangle_intersect__circle_ref__triangle_ref(const c: __sklib_circle; const tri: __sklib_triangle): LongInt; cdecl; external; +function __sklib__circle_triangle_intersect__circle_ref__triangle_ref__point_2d_ref(const c: __sklib_circle; const tri: __sklib_triangle; var p: __sklib_point_2d): LongInt; cdecl; external; function __sklib__circle_x__circle_ref(const c: __sklib_circle): Single; cdecl; external; function __sklib__circle_y__circle_ref(const c: __sklib_circle): Single; cdecl; external; function __sklib__circles_intersect__circle__circle(c1: __sklib_circle; c2: __sklib_circle): LongInt; cdecl; external; @@ -2712,6 +2717,7 @@ function __sklib__circles_intersect__double__double__double__double__double__dou function __sklib__closest_point_on_circle__point_2d_ref__circle_ref(const fromPt: __sklib_point_2d; const c: __sklib_circle): __sklib_point_2d; cdecl; external; function __sklib__closest_point_on_line_from_circle__circle_ref__line_ref(const c: __sklib_circle; const l: __sklib_line): __sklib_point_2d; cdecl; external; function __sklib__closest_point_on_rect_from_circle__circle_ref__rectangle_ref(const c: __sklib_circle; const rect: __sklib_rectangle): __sklib_point_2d; cdecl; external; +function __sklib__closest_point_on_triangle_from_circle__circle_ref__triangle_ref(const c: __sklib_circle; const tri: __sklib_triangle): __sklib_point_2d; cdecl; external; function __sklib__distant_point_on_circle__point_2d_ref__circle_ref(const pt: __sklib_point_2d; const c: __sklib_circle): __sklib_point_2d; cdecl; external; function __sklib__distant_point_on_circle_heading__point_2d_ref__circle_ref__vector_2d_ref__point_2d_ref(const pt: __sklib_point_2d; const c: __sklib_circle; const heading: __sklib_vector_2d; var oppositePt: __sklib_point_2d): LongInt; cdecl; external; function __sklib__ray_circle_intersect_distance__point_2d_ref__vector_2d_ref__circle_ref(const rayOrigin: __sklib_point_2d; const rayHeading: __sklib_vector_2d; const c: __sklib_circle): Single; cdecl; external; @@ -3047,40 +3053,40 @@ function __sklib__bitmap_button__bitmap(bmp: __sklib_ptr): LongInt; cdecl; exter function __sklib__bitmap_button__bitmap__rectangle_ref(bmp: __sklib_ptr; const rect: __sklib_rectangle): LongInt; cdecl; external; function __sklib__bitmap_button__bitmap__rectangle_ref__drawing_options(bmp: __sklib_ptr; const rect: __sklib_rectangle; opts: __sklib_drawing_options): LongInt; cdecl; external; function __sklib__bitmap_button__bitmap__drawing_options(bmp: __sklib_ptr; opts: __sklib_drawing_options): LongInt; cdecl; external; -function __sklib__bitmap_button__string_ref__bitmap(const label: __sklib_string; bmp: __sklib_ptr): LongInt; cdecl; external; -function __sklib__bitmap_button__string_ref__bitmap__drawing_options(const label: __sklib_string; bmp: __sklib_ptr; opts: __sklib_drawing_options): LongInt; cdecl; external; +function __sklib__bitmap_button__string_ref__bitmap(const labelText: __sklib_string; bmp: __sklib_ptr): LongInt; cdecl; external; +function __sklib__bitmap_button__string_ref__bitmap__drawing_options(const labelText: __sklib_string; bmp: __sklib_ptr; opts: __sklib_drawing_options): LongInt; cdecl; external; function __sklib__button__string_ref__rectangle_ref(const text: __sklib_string; const rect: __sklib_rectangle): LongInt; cdecl; external; function __sklib__button__string_ref(const text: __sklib_string): LongInt; cdecl; external; -function __sklib__button__string_ref__string_ref(const label: __sklib_string; const text: __sklib_string): LongInt; cdecl; external; +function __sklib__button__string_ref__string_ref(const labelText: __sklib_string; const text: __sklib_string): LongInt; cdecl; external; function __sklib__checkbox__string_ref__bool_ref__rectangle_ref(const text: __sklib_string; const value: LongInt; const rect: __sklib_rectangle): LongInt; cdecl; external; function __sklib__checkbox__string_ref__bool_ref(const text: __sklib_string; const value: LongInt): LongInt; cdecl; external; -function __sklib__checkbox__string_ref__string_ref__bool_ref(const label: __sklib_string; const text: __sklib_string; const value: LongInt): LongInt; cdecl; external; +function __sklib__checkbox__string_ref__string_ref__bool_ref(const labelText: __sklib_string; const text: __sklib_string; const value: LongInt): LongInt; cdecl; external; function __sklib__color_slider__color_ref__rectangle_ref(const clr: __sklib_color; const rect: __sklib_rectangle): __sklib_color; cdecl; external; function __sklib__color_slider__color_ref(const clr: __sklib_color): __sklib_color; cdecl; external; -function __sklib__color_slider__string_ref__color_ref(const label: __sklib_string; const clr: __sklib_color): __sklib_color; cdecl; external; +function __sklib__color_slider__string_ref__color_ref(const labelText: __sklib_string; const clr: __sklib_color): __sklib_color; cdecl; external; procedure __sklib__disable_interface(); cdecl; external; procedure __sklib__draw_interface(); cdecl; external; procedure __sklib__enable_interface(); cdecl; external; procedure __sklib__end_inset__string_ref(const name: __sklib_string); cdecl; external; procedure __sklib__end_panel__string_ref(const name: __sklib_string); cdecl; external; procedure __sklib__end_popup__string_ref(const name: __sklib_string); cdecl; external; -procedure __sklib__end_treenode__string_ref(const label: __sklib_string); cdecl; external; +procedure __sklib__end_treenode__string_ref(const labelText: __sklib_string); cdecl; external; procedure __sklib__enter_column(); cdecl; external; function __sklib__get_interface_label_width(): Integer; cdecl; external; -function __sklib__header__string_ref(const label: __sklib_string): LongInt; cdecl; external; +function __sklib__header__string_ref(const labelText: __sklib_string): LongInt; cdecl; external; function __sklib__hsb_color_slider__color_ref__rectangle_ref(const clr: __sklib_color; const rect: __sklib_rectangle): __sklib_color; cdecl; external; function __sklib__hsb_color_slider__color_ref(const clr: __sklib_color): __sklib_color; cdecl; external; -function __sklib__hsb_color_slider__string_ref__color_ref(const label: __sklib_string; const clr: __sklib_color): __sklib_color; cdecl; external; +function __sklib__hsb_color_slider__string_ref__color_ref(const labelText: __sklib_string; const clr: __sklib_color): __sklib_color; cdecl; external; function __sklib__interface_enabled(): LongInt; cdecl; external; procedure __sklib__interface_style_panel__rectangle_ref(const initialRectangle: __sklib_rectangle); cdecl; external; -procedure __sklib__label__string_ref(const text: __sklib_string); cdecl; external; -procedure __sklib__label__string_ref__rectangle_ref(const text: __sklib_string; const rect: __sklib_rectangle); cdecl; external; +procedure __sklib__label_element__string_ref(const text: __sklib_string); cdecl; external; +procedure __sklib__label_element__string_ref__rectangle_ref(const text: __sklib_string; const rect: __sklib_rectangle); cdecl; external; function __sklib__last_element_changed(): LongInt; cdecl; external; function __sklib__last_element_confirmed(): LongInt; cdecl; external; procedure __sklib__leave_column(); cdecl; external; function __sklib__number_box__float_ref__float__rectangle_ref(const value: Single; step: Single; const rect: __sklib_rectangle): Single; cdecl; external; function __sklib__number_box__float_ref__float(const value: Single; step: Single): Single; cdecl; external; -function __sklib__number_box__string_ref__float_ref__float(const label: __sklib_string; const value: Single; step: Single): Single; cdecl; external; +function __sklib__number_box__string_ref__float_ref__float(const labelText: __sklib_string; const value: Single; step: Single): Single; cdecl; external; procedure __sklib__open_popup__string_ref(const name: __sklib_string); cdecl; external; procedure __sklib__paragraph__string_ref(const text: __sklib_string); cdecl; external; procedure __sklib__paragraph__string_ref__rectangle_ref(const text: __sklib_string; const rect: __sklib_rectangle); cdecl; external; @@ -3105,7 +3111,7 @@ procedure __sklib__set_layout_height__int(height: Integer); cdecl; external; procedure __sklib__single_line_layout(); cdecl; external; function __sklib__slider__float_ref__float__float__rectangle_ref(const value: Single; minValue: Single; maxValue: Single; const rect: __sklib_rectangle): Single; cdecl; external; function __sklib__slider__float_ref__float__float(const value: Single; minValue: Single; maxValue: Single): Single; cdecl; external; -function __sklib__slider__string_ref__float_ref__float__float(const label: __sklib_string; const value: Single; minValue: Single; maxValue: Single): Single; cdecl; external; +function __sklib__slider__string_ref__float_ref__float__float(const labelText: __sklib_string; const value: Single; minValue: Single; maxValue: Single): Single; cdecl; external; procedure __sklib__split_into_columns__int(count: Integer); cdecl; external; procedure __sklib__split_into_columns__int__int(count: Integer; lastWidth: Integer); cdecl; external; procedure __sklib__split_into_columns_relative__int__double(count: Integer; lastWidth: Double); cdecl; external; @@ -3114,10 +3120,10 @@ procedure __sklib__start_inset__string_ref__rectangle_ref(const name: __sklib_st procedure __sklib__start_inset__string_ref__int(const name: __sklib_string; height: Integer); cdecl; external; function __sklib__start_panel__string_ref__rectangle(const name: __sklib_string; initialRectangle: __sklib_rectangle): LongInt; cdecl; external; function __sklib__start_popup__string_ref(const name: __sklib_string): LongInt; cdecl; external; -function __sklib__start_treenode__string_ref(const label: __sklib_string): LongInt; cdecl; external; +function __sklib__start_treenode__string_ref(const labelText: __sklib_string): LongInt; cdecl; external; function __sklib__text_box__string_ref(const value: __sklib_string): __sklib_string; cdecl; external; function __sklib__text_box__string_ref__rectangle_ref(const value: __sklib_string; const rect: __sklib_rectangle): __sklib_string; cdecl; external; -function __sklib__text_box__string_ref__string_ref(const label: __sklib_string; const value: __sklib_string): __sklib_string; cdecl; external; +function __sklib__text_box__string_ref__string_ref(const labelText: __sklib_string; const value: __sklib_string): __sklib_string; cdecl; external; function __sklib__create_json(): __sklib_ptr; cdecl; external; function __sklib__create_json__string(jsonString: __sklib_string): __sklib_ptr; cdecl; external; procedure __sklib__free_all_json(); cdecl; external; @@ -3247,15 +3253,15 @@ function __sklib__music_name__music(data: __sklib_ptr): __sklib_string; cdecl; e function __sklib__music_named__string_ref(const name: __sklib_string): __sklib_ptr; cdecl; external; function __sklib__music_playing(): LongInt; cdecl; external; function __sklib__music_valid__music(m: __sklib_ptr): LongInt; cdecl; external; -function __sklib__music_volume(): Single; cdecl; external; +function __sklib__music_volume(): Double; cdecl; external; procedure __sklib__pause_music(); cdecl; external; procedure __sklib__play_music__string_ref(const name: __sklib_string); cdecl; external; procedure __sklib__play_music__string_ref__int(const name: __sklib_string; times: Integer); cdecl; external; procedure __sklib__play_music__music(data: __sklib_ptr); cdecl; external; procedure __sklib__play_music__music__int(data: __sklib_ptr; times: Integer); cdecl; external; -procedure __sklib__play_music__music__int__float(data: __sklib_ptr; times: Integer; volume: Single); cdecl; external; +procedure __sklib__play_music__music__int__double(data: __sklib_ptr; times: Integer; volume: Double); cdecl; external; procedure __sklib__resume_music(); cdecl; external; -procedure __sklib__set_music_volume__float(volume: Single); cdecl; external; +procedure __sklib__set_music_volume__double(volume: Double); cdecl; external; procedure __sklib__stop_music(); cdecl; external; function __sklib__accept_all_new_connections(): LongInt; cdecl; external; function __sklib__accept_new_connection__server_socket(server: __sklib_ptr): LongInt; cdecl; external; @@ -3461,13 +3467,13 @@ procedure __sklib__free_sound_effect__sound_effect(effect: __sklib_ptr); cdecl; function __sklib__has_sound_effect__string_ref(const name: __sklib_string): LongInt; cdecl; external; function __sklib__load_sound_effect__string_ref__string_ref(const name: __sklib_string; const filename: __sklib_string): __sklib_ptr; cdecl; external; procedure __sklib__play_sound_effect__string_ref(const name: __sklib_string); cdecl; external; -procedure __sklib__play_sound_effect__string_ref__float(const name: __sklib_string; volume: Single); cdecl; external; +procedure __sklib__play_sound_effect__string_ref__double(const name: __sklib_string; volume: Double); cdecl; external; procedure __sklib__play_sound_effect__string_ref__int(const name: __sklib_string; times: Integer); cdecl; external; -procedure __sklib__play_sound_effect__string_ref__int__float(const name: __sklib_string; times: Integer; volume: Single); cdecl; external; +procedure __sklib__play_sound_effect__string_ref__int__double(const name: __sklib_string; times: Integer; volume: Double); cdecl; external; procedure __sklib__play_sound_effect__sound_effect(effect: __sklib_ptr); cdecl; external; -procedure __sklib__play_sound_effect__sound_effect__float(effect: __sklib_ptr; volume: Single); cdecl; external; +procedure __sklib__play_sound_effect__sound_effect__double(effect: __sklib_ptr; volume: Double); cdecl; external; procedure __sklib__play_sound_effect__sound_effect__int(effect: __sklib_ptr; times: Integer); cdecl; external; -procedure __sklib__play_sound_effect__sound_effect__int__float(effect: __sklib_ptr; times: Integer; volume: Single); cdecl; external; +procedure __sklib__play_sound_effect__sound_effect__int__double(effect: __sklib_ptr; times: Integer; volume: Double); cdecl; external; function __sklib__sound_effect_filename__sound_effect(effect: __sklib_ptr): __sklib_string; cdecl; external; function __sklib__sound_effect_name__sound_effect(effect: __sklib_ptr): __sklib_string; cdecl; external; function __sklib__sound_effect_named__string_ref(const name: __sklib_string): __sklib_ptr; cdecl; external; @@ -3744,7 +3750,7 @@ function __sklib__vector_in_rect__vector_2d_ref__rectangle_ref(const v: __sklib_ function __sklib__vector_invert__vector_2d_ref(const v: __sklib_vector_2d): __sklib_vector_2d; cdecl; external; function __sklib__vector_limit__vector_2d_ref__double(const v: __sklib_vector_2d; limit: Double): __sklib_vector_2d; cdecl; external; function __sklib__vector_magnitude__vector_2d_ref(const v: __sklib_vector_2d): Double; cdecl; external; -function __sklib__vector_magnitude_sqared__vector_2d_ref(const v: __sklib_vector_2d): Double; cdecl; external; +function __sklib__vector_magnitude_squared__vector_2d_ref(const v: __sklib_vector_2d): Double; cdecl; external; function __sklib__vector_multiply__vector_2d_ref__double(const v1: __sklib_vector_2d; s: Double): __sklib_vector_2d; cdecl; external; function __sklib__vector_normal__vector_2d_ref(const v: __sklib_vector_2d): __sklib_vector_2d; cdecl; external; function __sklib__vector_out_of_circle_from_circle__circle_ref__circle_ref__vector_2d_ref(const src: __sklib_circle; const bounds: __sklib_circle; const velocity: __sklib_vector_2d): __sklib_vector_2d; cdecl; external; @@ -4877,6 +4883,31 @@ function CircleRadius(c: Circle): Single; __skreturn := __sklib__circle_radius__circle(__skparam__c); result := __skadapter__to_float(__skreturn); end; +function CircleTriangleIntersect(const c: Circle; const tri: Triangle): Boolean; +var + __skparam__c: __sklib_circle; + __skparam__tri: __sklib_triangle; + __skreturn: LongInt; +begin + __skparam__c := __skadapter__to_sklib_circle(c); + __skparam__tri := __skadapter__to_sklib_triangle(tri); + __skreturn := __sklib__circle_triangle_intersect__circle_ref__triangle_ref(__skparam__c, __skparam__tri); + result := __skadapter__to_bool(__skreturn); +end; +function CircleTriangleIntersect(const c: Circle; const tri: Triangle; var p: Point2D): Boolean; +var + __skparam__c: __sklib_circle; + __skparam__tri: __sklib_triangle; + __skparam__p: __sklib_point_2d; + __skreturn: LongInt; +begin + __skparam__c := __skadapter__to_sklib_circle(c); + __skparam__tri := __skadapter__to_sklib_triangle(tri); + __skparam__p := __skadapter__to_sklib_point_2d(p); + __skreturn := __sklib__circle_triangle_intersect__circle_ref__triangle_ref__point_2d_ref(__skparam__c, __skparam__tri, __skparam__p); + p := __skadapter__to_point_2d(__skparam__p); + result := __skadapter__to_bool(__skreturn); +end; function CircleX(const c: Circle): Single; var __skparam__c: __sklib_circle; @@ -4958,6 +4989,17 @@ function ClosestPointOnRectFromCircle(const c: Circle; const rect: Rectangle): P __skreturn := __sklib__closest_point_on_rect_from_circle__circle_ref__rectangle_ref(__skparam__c, __skparam__rect); result := __skadapter__to_point_2d(__skreturn); end; +function ClosestPointOnTriangleFromCircle(const c: Circle; const tri: Triangle): Point2D; +var + __skparam__c: __sklib_circle; + __skparam__tri: __sklib_triangle; + __skreturn: __sklib_point_2d; +begin + __skparam__c := __skadapter__to_sklib_circle(c); + __skparam__tri := __skadapter__to_sklib_triangle(tri); + __skreturn := __sklib__closest_point_on_triangle_from_circle__circle_ref__triangle_ref(__skparam__c, __skparam__tri); + result := __skadapter__to_point_2d(__skreturn); +end; function DistantPointOnCircle(const pt: Point2D; const c: Circle): Point2D; var __skparam__pt: __sklib_point_2d; @@ -8091,28 +8133,28 @@ function BitmapButton(bmp: Bitmap; opts: DrawingOptions): Boolean; __skreturn := __sklib__bitmap_button__bitmap__drawing_options(__skparam__bmp, __skparam__opts); result := __skadapter__to_bool(__skreturn); end; -function BitmapButton(const label: String; bmp: Bitmap): Boolean; +function BitmapButton(const labelText: String; bmp: Bitmap): Boolean; var - __skparam__label: __sklib_string; + __skparam__label_text: __sklib_string; __skparam__bmp: __sklib_ptr; __skreturn: LongInt; begin - __skparam__label := __skadapter__to_sklib_string(label); + __skparam__label_text := __skadapter__to_sklib_string(labelText); __skparam__bmp := __skadapter__to_sklib_bitmap(bmp); - __skreturn := __sklib__bitmap_button__string_ref__bitmap(__skparam__label, __skparam__bmp); + __skreturn := __sklib__bitmap_button__string_ref__bitmap(__skparam__label_text, __skparam__bmp); result := __skadapter__to_bool(__skreturn); end; -function BitmapButton(const label: String; bmp: Bitmap; opts: DrawingOptions): Boolean; +function BitmapButton(const labelText: String; bmp: Bitmap; opts: DrawingOptions): Boolean; var - __skparam__label: __sklib_string; + __skparam__label_text: __sklib_string; __skparam__bmp: __sklib_ptr; __skparam__opts: __sklib_drawing_options; __skreturn: LongInt; begin - __skparam__label := __skadapter__to_sklib_string(label); + __skparam__label_text := __skadapter__to_sklib_string(labelText); __skparam__bmp := __skadapter__to_sklib_bitmap(bmp); __skparam__opts := __skadapter__to_sklib_drawing_options(opts); - __skreturn := __sklib__bitmap_button__string_ref__bitmap__drawing_options(__skparam__label, __skparam__bmp, __skparam__opts); + __skreturn := __sklib__bitmap_button__string_ref__bitmap__drawing_options(__skparam__label_text, __skparam__bmp, __skparam__opts); result := __skadapter__to_bool(__skreturn); end; function Button(const text: String; const rect: Rectangle): Boolean; @@ -8135,15 +8177,15 @@ function Button(const text: String): Boolean; __skreturn := __sklib__button__string_ref(__skparam__text); result := __skadapter__to_bool(__skreturn); end; -function Button(const label: String; const text: String): Boolean; +function Button(const labelText: String; const text: String): Boolean; var - __skparam__label: __sklib_string; + __skparam__label_text: __sklib_string; __skparam__text: __sklib_string; __skreturn: LongInt; begin - __skparam__label := __skadapter__to_sklib_string(label); + __skparam__label_text := __skadapter__to_sklib_string(labelText); __skparam__text := __skadapter__to_sklib_string(text); - __skreturn := __sklib__button__string_ref__string_ref(__skparam__label, __skparam__text); + __skreturn := __sklib__button__string_ref__string_ref(__skparam__label_text, __skparam__text); result := __skadapter__to_bool(__skreturn); end; function Checkbox(const text: String; const value: Boolean; const rect: Rectangle): Boolean; @@ -8170,17 +8212,17 @@ function Checkbox(const text: String; const value: Boolean): Boolean; __skreturn := __sklib__checkbox__string_ref__bool_ref(__skparam__text, __skparam__value); result := __skadapter__to_bool(__skreturn); end; -function Checkbox(const label: String; const text: String; const value: Boolean): Boolean; +function Checkbox(const labelText: String; const text: String; const value: Boolean): Boolean; var - __skparam__label: __sklib_string; + __skparam__label_text: __sklib_string; __skparam__text: __sklib_string; __skparam__value: LongInt; __skreturn: LongInt; begin - __skparam__label := __skadapter__to_sklib_string(label); + __skparam__label_text := __skadapter__to_sklib_string(labelText); __skparam__text := __skadapter__to_sklib_string(text); __skparam__value := __skadapter__to_sklib_bool(value); - __skreturn := __sklib__checkbox__string_ref__string_ref__bool_ref(__skparam__label, __skparam__text, __skparam__value); + __skreturn := __sklib__checkbox__string_ref__string_ref__bool_ref(__skparam__label_text, __skparam__text, __skparam__value); result := __skadapter__to_bool(__skreturn); end; function ColorSlider(const clr: Color; const rect: Rectangle): Color; @@ -8203,15 +8245,15 @@ function ColorSlider(const clr: Color): Color; __skreturn := __sklib__color_slider__color_ref(__skparam__clr); result := __skadapter__to_color(__skreturn); end; -function ColorSlider(const label: String; const clr: Color): Color; +function ColorSlider(const labelText: String; const clr: Color): Color; var - __skparam__label: __sklib_string; + __skparam__label_text: __sklib_string; __skparam__clr: __sklib_color; __skreturn: __sklib_color; begin - __skparam__label := __skadapter__to_sklib_string(label); + __skparam__label_text := __skadapter__to_sklib_string(labelText); __skparam__clr := __skadapter__to_sklib_color(clr); - __skreturn := __sklib__color_slider__string_ref__color_ref(__skparam__label, __skparam__clr); + __skreturn := __sklib__color_slider__string_ref__color_ref(__skparam__label_text, __skparam__clr); result := __skadapter__to_color(__skreturn); end; procedure DisableInterface(); @@ -8247,12 +8289,12 @@ procedure EndPopup(const name: String); __skparam__name := __skadapter__to_sklib_string(name); __sklib__end_popup__string_ref(__skparam__name); end; -procedure EndTreenode(const label: String); +procedure EndTreenode(const labelText: String); var - __skparam__label: __sklib_string; + __skparam__label_text: __sklib_string; begin - __skparam__label := __skadapter__to_sklib_string(label); - __sklib__end_treenode__string_ref(__skparam__label); + __skparam__label_text := __skadapter__to_sklib_string(labelText); + __sklib__end_treenode__string_ref(__skparam__label_text); end; procedure EnterColumn(); begin @@ -8265,13 +8307,13 @@ function GetInterfaceLabelWidth(): Integer; __skreturn := __sklib__get_interface_label_width(); result := __skadapter__to_int(__skreturn); end; -function Header(const label: String): Boolean; +function Header(const labelText: String): Boolean; var - __skparam__label: __sklib_string; + __skparam__label_text: __sklib_string; __skreturn: LongInt; begin - __skparam__label := __skadapter__to_sklib_string(label); - __skreturn := __sklib__header__string_ref(__skparam__label); + __skparam__label_text := __skadapter__to_sklib_string(labelText); + __skreturn := __sklib__header__string_ref(__skparam__label_text); result := __skadapter__to_bool(__skreturn); end; function HSBColorSlider(const clr: Color; const rect: Rectangle): Color; @@ -8294,15 +8336,15 @@ function HSBColorSlider(const clr: Color): Color; __skreturn := __sklib__hsb_color_slider__color_ref(__skparam__clr); result := __skadapter__to_color(__skreturn); end; -function HSBColorSlider(const label: String; const clr: Color): Color; +function HSBColorSlider(const labelText: String; const clr: Color): Color; var - __skparam__label: __sklib_string; + __skparam__label_text: __sklib_string; __skparam__clr: __sklib_color; __skreturn: __sklib_color; begin - __skparam__label := __skadapter__to_sklib_string(label); + __skparam__label_text := __skadapter__to_sklib_string(labelText); __skparam__clr := __skadapter__to_sklib_color(clr); - __skreturn := __sklib__hsb_color_slider__string_ref__color_ref(__skparam__label, __skparam__clr); + __skreturn := __sklib__hsb_color_slider__string_ref__color_ref(__skparam__label_text, __skparam__clr); result := __skadapter__to_color(__skreturn); end; function InterfaceEnabled(): Boolean; @@ -8319,21 +8361,21 @@ procedure InterfaceStylePanel(const initialRectangle: Rectangle); __skparam__initial_rectangle := __skadapter__to_sklib_rectangle(initialRectangle); __sklib__interface_style_panel__rectangle_ref(__skparam__initial_rectangle); end; -procedure Label(const text: String); +procedure LabelElement(const text: String); var __skparam__text: __sklib_string; begin __skparam__text := __skadapter__to_sklib_string(text); - __sklib__label__string_ref(__skparam__text); + __sklib__label_element__string_ref(__skparam__text); end; -procedure Label(const text: String; const rect: Rectangle); +procedure LabelElement(const text: String; const rect: Rectangle); var __skparam__text: __sklib_string; __skparam__rect: __sklib_rectangle; begin __skparam__text := __skadapter__to_sklib_string(text); __skparam__rect := __skadapter__to_sklib_rectangle(rect); - __sklib__label__string_ref__rectangle_ref(__skparam__text, __skparam__rect); + __sklib__label_element__string_ref__rectangle_ref(__skparam__text, __skparam__rect); end; function LastElementChanged(): Boolean; var @@ -8377,17 +8419,17 @@ function NumberBox(const value: Single; step: Single): Single; __skreturn := __sklib__number_box__float_ref__float(__skparam__value, __skparam__step); result := __skadapter__to_float(__skreturn); end; -function NumberBox(const label: String; const value: Single; step: Single): Single; +function NumberBox(const labelText: String; const value: Single; step: Single): Single; var - __skparam__label: __sklib_string; + __skparam__label_text: __sklib_string; __skparam__value: Single; __skparam__step: Single; __skreturn: Single; begin - __skparam__label := __skadapter__to_sklib_string(label); + __skparam__label_text := __skadapter__to_sklib_string(labelText); __skparam__value := __skadapter__to_sklib_float(value); __skparam__step := __skadapter__to_sklib_float(step); - __skreturn := __sklib__number_box__string_ref__float_ref__float(__skparam__label, __skparam__value, __skparam__step); + __skreturn := __sklib__number_box__string_ref__float_ref__float(__skparam__label_text, __skparam__value, __skparam__step); result := __skadapter__to_float(__skreturn); end; procedure OpenPopup(const name: String); @@ -8596,19 +8638,19 @@ function Slider(const value: Single; minValue: Single; maxValue: Single): Single __skreturn := __sklib__slider__float_ref__float__float(__skparam__value, __skparam__min_value, __skparam__max_value); result := __skadapter__to_float(__skreturn); end; -function Slider(const label: String; const value: Single; minValue: Single; maxValue: Single): Single; +function Slider(const labelText: String; const value: Single; minValue: Single; maxValue: Single): Single; var - __skparam__label: __sklib_string; + __skparam__label_text: __sklib_string; __skparam__value: Single; __skparam__min_value: Single; __skparam__max_value: Single; __skreturn: Single; begin - __skparam__label := __skadapter__to_sklib_string(label); + __skparam__label_text := __skadapter__to_sklib_string(labelText); __skparam__value := __skadapter__to_sklib_float(value); __skparam__min_value := __skadapter__to_sklib_float(minValue); __skparam__max_value := __skadapter__to_sklib_float(maxValue); - __skreturn := __sklib__slider__string_ref__float_ref__float__float(__skparam__label, __skparam__value, __skparam__min_value, __skparam__max_value); + __skreturn := __sklib__slider__string_ref__float_ref__float__float(__skparam__label_text, __skparam__value, __skparam__min_value, __skparam__max_value); result := __skadapter__to_float(__skreturn); end; procedure SplitIntoColumns(count: Integer); @@ -8678,13 +8720,13 @@ function StartPopup(const name: String): Boolean; __skreturn := __sklib__start_popup__string_ref(__skparam__name); result := __skadapter__to_bool(__skreturn); end; -function StartTreenode(const label: String): Boolean; +function StartTreenode(const labelText: String): Boolean; var - __skparam__label: __sklib_string; + __skparam__label_text: __sklib_string; __skreturn: LongInt; begin - __skparam__label := __skadapter__to_sklib_string(label); - __skreturn := __sklib__start_treenode__string_ref(__skparam__label); + __skparam__label_text := __skadapter__to_sklib_string(labelText); + __skreturn := __sklib__start_treenode__string_ref(__skparam__label_text); result := __skadapter__to_bool(__skreturn); end; function TextBox(const value: String): String; @@ -8707,15 +8749,15 @@ function TextBox(const value: String; const rect: Rectangle): String; __skreturn := __sklib__text_box__string_ref__rectangle_ref(__skparam__value, __skparam__rect); result := __skadapter__to_string(__skreturn); end; -function TextBox(const label: String; const value: String): String; +function TextBox(const labelText: String; const value: String): String; var - __skparam__label: __sklib_string; + __skparam__label_text: __sklib_string; __skparam__value: __sklib_string; __skreturn: __sklib_string; begin - __skparam__label := __skadapter__to_sklib_string(label); + __skparam__label_text := __skadapter__to_sklib_string(labelText); __skparam__value := __skadapter__to_sklib_string(value); - __skreturn := __sklib__text_box__string_ref__string_ref(__skparam__label, __skparam__value); + __skreturn := __sklib__text_box__string_ref__string_ref(__skparam__label_text, __skparam__value); result := __skadapter__to_string(__skreturn); end; function CreateJson(): Json; @@ -9996,12 +10038,12 @@ function MusicValid(m: Music): Boolean; __skreturn := __sklib__music_valid__music(__skparam__m); result := __skadapter__to_bool(__skreturn); end; -function MusicVolume(): Single; +function MusicVolume(): Double; var - __skreturn: Single; + __skreturn: Double; begin __skreturn := __sklib__music_volume(); - result := __skadapter__to_float(__skreturn); + result := __skadapter__to_double(__skreturn); end; procedure PauseMusic(); begin @@ -10039,27 +10081,27 @@ procedure PlayMusic(data: Music; times: Integer); __skparam__times := __skadapter__to_sklib_int(times); __sklib__play_music__music__int(__skparam__data, __skparam__times); end; -procedure PlayMusic(data: Music; times: Integer; volume: Single); +procedure PlayMusic(data: Music; times: Integer; volume: Double); var __skparam__data: __sklib_ptr; __skparam__times: Integer; - __skparam__volume: Single; + __skparam__volume: Double; begin __skparam__data := __skadapter__to_sklib_music(data); __skparam__times := __skadapter__to_sklib_int(times); - __skparam__volume := __skadapter__to_sklib_float(volume); - __sklib__play_music__music__int__float(__skparam__data, __skparam__times, __skparam__volume); + __skparam__volume := __skadapter__to_sklib_double(volume); + __sklib__play_music__music__int__double(__skparam__data, __skparam__times, __skparam__volume); end; procedure ResumeMusic(); begin __sklib__resume_music(); end; -procedure SetMusicVolume(volume: Single); +procedure SetMusicVolume(volume: Double); var - __skparam__volume: Single; + __skparam__volume: Double; begin - __skparam__volume := __skadapter__to_sklib_float(volume); - __sklib__set_music_volume__float(__skparam__volume); + __skparam__volume := __skadapter__to_sklib_double(volume); + __sklib__set_music_volume__double(__skparam__volume); end; procedure StopMusic(); begin @@ -12153,14 +12195,14 @@ procedure PlaySoundEffect(const name: String); __skparam__name := __skadapter__to_sklib_string(name); __sklib__play_sound_effect__string_ref(__skparam__name); end; -procedure PlaySoundEffect(const name: String; volume: Single); +procedure PlaySoundEffect(const name: String; volume: Double); var __skparam__name: __sklib_string; - __skparam__volume: Single; + __skparam__volume: Double; begin __skparam__name := __skadapter__to_sklib_string(name); - __skparam__volume := __skadapter__to_sklib_float(volume); - __sklib__play_sound_effect__string_ref__float(__skparam__name, __skparam__volume); + __skparam__volume := __skadapter__to_sklib_double(volume); + __sklib__play_sound_effect__string_ref__double(__skparam__name, __skparam__volume); end; procedure PlaySoundEffect(const name: String; times: Integer); var @@ -12171,16 +12213,16 @@ procedure PlaySoundEffect(const name: String; times: Integer); __skparam__times := __skadapter__to_sklib_int(times); __sklib__play_sound_effect__string_ref__int(__skparam__name, __skparam__times); end; -procedure PlaySoundEffect(const name: String; times: Integer; volume: Single); +procedure PlaySoundEffect(const name: String; times: Integer; volume: Double); var __skparam__name: __sklib_string; __skparam__times: Integer; - __skparam__volume: Single; + __skparam__volume: Double; begin __skparam__name := __skadapter__to_sklib_string(name); __skparam__times := __skadapter__to_sklib_int(times); - __skparam__volume := __skadapter__to_sklib_float(volume); - __sklib__play_sound_effect__string_ref__int__float(__skparam__name, __skparam__times, __skparam__volume); + __skparam__volume := __skadapter__to_sklib_double(volume); + __sklib__play_sound_effect__string_ref__int__double(__skparam__name, __skparam__times, __skparam__volume); end; procedure PlaySoundEffect(effect: SoundEffect); var @@ -12189,14 +12231,14 @@ procedure PlaySoundEffect(effect: SoundEffect); __skparam__effect := __skadapter__to_sklib_sound_effect(effect); __sklib__play_sound_effect__sound_effect(__skparam__effect); end; -procedure PlaySoundEffect(effect: SoundEffect; volume: Single); +procedure PlaySoundEffect(effect: SoundEffect; volume: Double); var __skparam__effect: __sklib_ptr; - __skparam__volume: Single; + __skparam__volume: Double; begin __skparam__effect := __skadapter__to_sklib_sound_effect(effect); - __skparam__volume := __skadapter__to_sklib_float(volume); - __sklib__play_sound_effect__sound_effect__float(__skparam__effect, __skparam__volume); + __skparam__volume := __skadapter__to_sklib_double(volume); + __sklib__play_sound_effect__sound_effect__double(__skparam__effect, __skparam__volume); end; procedure PlaySoundEffect(effect: SoundEffect; times: Integer); var @@ -12207,16 +12249,16 @@ procedure PlaySoundEffect(effect: SoundEffect; times: Integer); __skparam__times := __skadapter__to_sklib_int(times); __sklib__play_sound_effect__sound_effect__int(__skparam__effect, __skparam__times); end; -procedure PlaySoundEffect(effect: SoundEffect; times: Integer; volume: Single); +procedure PlaySoundEffect(effect: SoundEffect; times: Integer; volume: Double); var __skparam__effect: __sklib_ptr; __skparam__times: Integer; - __skparam__volume: Single; + __skparam__volume: Double; begin __skparam__effect := __skadapter__to_sklib_sound_effect(effect); __skparam__times := __skadapter__to_sklib_int(times); - __skparam__volume := __skadapter__to_sklib_float(volume); - __sklib__play_sound_effect__sound_effect__int__float(__skparam__effect, __skparam__times, __skparam__volume); + __skparam__volume := __skadapter__to_sklib_double(volume); + __sklib__play_sound_effect__sound_effect__int__double(__skparam__effect, __skparam__times, __skparam__volume); end; function SoundEffectFilename(effect: SoundEffect): String; var @@ -15078,13 +15120,13 @@ function VectorMagnitude(const v: Vector2D): Double; __skreturn := __sklib__vector_magnitude__vector_2d_ref(__skparam__v); result := __skadapter__to_double(__skreturn); end; -function VectorMagnitudeSqared(const v: Vector2D): Double; +function VectorMagnitudeSquared(const v: Vector2D): Double; var __skparam__v: __sklib_vector_2d; __skreturn: Double; begin __skparam__v := __skadapter__to_sklib_vector_2d(v); - __skreturn := __sklib__vector_magnitude_sqared__vector_2d_ref(__skparam__v); + __skreturn := __sklib__vector_magnitude_squared__vector_2d_ref(__skparam__v); result := __skadapter__to_double(__skreturn); end; function VectorMultiply(const v1: Vector2D; s: Double): Vector2D; diff --git a/g++/include/circle_geometry.h b/g++/include/circle_geometry.h index 1fc086b..cfa80d8 100644 --- a/g++/include/circle_geometry.h +++ b/g++/include/circle_geometry.h @@ -17,6 +17,8 @@ point_2d center_point(const circle &c); circle circle_at(const point_2d &pt, double radius); circle circle_at(double x, double y, double radius); float circle_radius(const circle c); +bool circle_triangle_intersect(const circle &c, const triangle &tri); +bool circle_triangle_intersect(const circle &c, const triangle &tri, point_2d &p); float circle_x(const circle &c); float circle_y(const circle &c); bool circles_intersect(circle c1, circle c2); @@ -24,6 +26,7 @@ bool circles_intersect(double c1_x, double c1_y, double c1_radius, double c2_x, point_2d closest_point_on_circle(const point_2d &from_pt, const circle &c); point_2d closest_point_on_line_from_circle(const circle &c, const line &l); point_2d closest_point_on_rect_from_circle(const circle &c, const rectangle &rect); +point_2d closest_point_on_triangle_from_circle(const circle &c, const triangle &tri); point_2d distant_point_on_circle(const point_2d &pt, const circle &c); bool distant_point_on_circle_heading(const point_2d &pt, const circle &c, const vector_2d &heading, point_2d &opposite_pt); float ray_circle_intersect_distance(const point_2d &ray_origin, const vector_2d &ray_heading, const circle &c); diff --git a/g++/include/interface.h b/g++/include/interface.h index 5dd1a7d..d8c9567 100644 --- a/g++/include/interface.h +++ b/g++/include/interface.h @@ -19,40 +19,40 @@ bool bitmap_button(bitmap bmp); bool bitmap_button(bitmap bmp, const rectangle &rect); bool bitmap_button(bitmap bmp, const rectangle &rect, drawing_options opts); bool bitmap_button(bitmap bmp, drawing_options opts); -bool bitmap_button(const string &label, bitmap bmp); -bool bitmap_button(const string &label, bitmap bmp, drawing_options opts); +bool bitmap_button(const string &label_text, bitmap bmp); +bool bitmap_button(const string &label_text, bitmap bmp, drawing_options opts); bool button(const string &text, const rectangle &rect); bool button(const string &text); -bool button(const string &label, const string &text); +bool button(const string &label_text, const string &text); bool checkbox(const string &text, const bool &value, const rectangle &rect); bool checkbox(const string &text, const bool &value); -bool checkbox(const string &label, const string &text, const bool &value); +bool checkbox(const string &label_text, const string &text, const bool &value); color color_slider(const color &clr, const rectangle &rect); color color_slider(const color &clr); -color color_slider(const string &label, const color &clr); +color color_slider(const string &label_text, const color &clr); void disable_interface(); void draw_interface(); void enable_interface(); void end_inset(const string &name); void end_panel(const string &name); void end_popup(const string &name); -void end_treenode(const string &label); +void end_treenode(const string &label_text); void enter_column(); int get_interface_label_width(); -bool header(const string &label); +bool header(const string &label_text); color hsb_color_slider(const color &clr, const rectangle &rect); color hsb_color_slider(const color &clr); -color hsb_color_slider(const string &label, const color &clr); +color hsb_color_slider(const string &label_text, const color &clr); bool interface_enabled(); void interface_style_panel(const rectangle &initial_rectangle); -void label(const string &text); -void label(const string &text, const rectangle &rect); +void label_element(const string &text); +void label_element(const string &text, const rectangle &rect); bool last_element_changed(); bool last_element_confirmed(); void leave_column(); float number_box(const float &value, float step, const rectangle &rect); float number_box(const float &value, float step); -float number_box(const string &label, const float &value, float step); +float number_box(const string &label_text, const float &value, float step); void open_popup(const string &name); void paragraph(const string &text); void paragraph(const string &text, const rectangle &rect); @@ -77,7 +77,7 @@ void set_layout_height(int height); void single_line_layout(); float slider(const float &value, float min_value, float max_value, const rectangle &rect); float slider(const float &value, float min_value, float max_value); -float slider(const string &label, const float &value, float min_value, float max_value); +float slider(const string &label_text, const float &value, float min_value, float max_value); void split_into_columns(int count); void split_into_columns(int count, int last_width); void split_into_columns_relative(int count, double last_width); @@ -86,9 +86,9 @@ void start_inset(const string &name, const rectangle &rect); void start_inset(const string &name, int height); bool start_panel(const string &name, rectangle initial_rectangle); bool start_popup(const string &name); -bool start_treenode(const string &label); +bool start_treenode(const string &label_text); string text_box(const string &value); string text_box(const string &value, const rectangle &rect); -string text_box(const string &label, const string &value); +string text_box(const string &label_text, const string &value); #endif /* __interface_h */ diff --git a/g++/include/music.h b/g++/include/music.h index 09dece8..0622756 100644 --- a/g++/include/music.h +++ b/g++/include/music.h @@ -28,15 +28,15 @@ string music_name(music data); music music_named(const string &name); bool music_playing(); bool music_valid(music m); -float music_volume(); +double music_volume(); void pause_music(); void play_music(const string &name); void play_music(const string &name, int times); void play_music(music data); void play_music(music data, int times); -void play_music(music data, int times, float volume); +void play_music(music data, int times, double volume); void resume_music(); -void set_music_volume(float volume); +void set_music_volume(double volume); void stop_music(); #endif /* __music_h */ diff --git a/g++/include/sound.h b/g++/include/sound.h index 42ef914..fa205d1 100644 --- a/g++/include/sound.h +++ b/g++/include/sound.h @@ -21,13 +21,13 @@ void free_sound_effect(sound_effect effect); bool has_sound_effect(const string &name); sound_effect load_sound_effect(const string &name, const string &filename); void play_sound_effect(const string &name); -void play_sound_effect(const string &name, float volume); +void play_sound_effect(const string &name, double volume); void play_sound_effect(const string &name, int times); -void play_sound_effect(const string &name, int times, float volume); +void play_sound_effect(const string &name, int times, double volume); void play_sound_effect(sound_effect effect); -void play_sound_effect(sound_effect effect, float volume); +void play_sound_effect(sound_effect effect, double volume); void play_sound_effect(sound_effect effect, int times); -void play_sound_effect(sound_effect effect, int times, float volume); +void play_sound_effect(sound_effect effect, int times, double volume); string sound_effect_filename(sound_effect effect); string sound_effect_name(sound_effect effect); sound_effect sound_effect_named(const string &name); diff --git a/g++/include/vector_2d.h b/g++/include/vector_2d.h index 19a064c..937491f 100644 --- a/g++/include/vector_2d.h +++ b/g++/include/vector_2d.h @@ -27,7 +27,7 @@ bool vector_in_rect(const vector_2d &v, const rectangle &rect); vector_2d vector_invert(const vector_2d &v); vector_2d vector_limit(const vector_2d &v, double limit); double vector_magnitude(const vector_2d &v); -double vector_magnitude_sqared(const vector_2d &v); +double vector_magnitude_squared(const vector_2d &v); vector_2d vector_multiply(const vector_2d &v1, double s); vector_2d vector_normal(const vector_2d &v); vector_2d vector_out_of_circle_from_circle(const circle &src, const circle &bounds, const vector_2d &velocity); diff --git a/g++/src/splashkit.cpp b/g++/src/splashkit.cpp index 7a12254..8588c70 100644 --- a/g++/src/splashkit.cpp +++ b/g++/src/splashkit.cpp @@ -614,6 +614,20 @@ float circle_radius(const circle c) { float __skreturn = __sklib__circle_radius__circle(__skparam__c); return __skadapter__to_float(__skreturn); } +bool circle_triangle_intersect(const circle &c, const triangle &tri) { + const __sklib_circle __skparam__c = __skadapter__to_sklib_circle(c); + const __sklib_triangle __skparam__tri = __skadapter__to_sklib_triangle(tri); + int __skreturn = __sklib__circle_triangle_intersect__circle_ref__triangle_ref(__skparam__c, __skparam__tri); + return __skadapter__to_bool(__skreturn); +} +bool circle_triangle_intersect(const circle &c, const triangle &tri, point_2d &p) { + const __sklib_circle __skparam__c = __skadapter__to_sklib_circle(c); + const __sklib_triangle __skparam__tri = __skadapter__to_sklib_triangle(tri); + __sklib_point_2d __skparam__p = __skadapter__to_sklib_point_2d(p); + int __skreturn = __sklib__circle_triangle_intersect__circle_ref__triangle_ref__point_2d_ref(__skparam__c, __skparam__tri, &__skparam__p); + p = __skadapter__to_point_2d(__skparam__p); + return __skadapter__to_bool(__skreturn); +} float circle_x(const circle &c) { const __sklib_circle __skparam__c = __skadapter__to_sklib_circle(c); float __skreturn = __sklib__circle_x__circle_ref(__skparam__c); @@ -658,6 +672,12 @@ point_2d closest_point_on_rect_from_circle(const circle &c, const rectangle &rec __sklib_point_2d __skreturn = __sklib__closest_point_on_rect_from_circle__circle_ref__rectangle_ref(__skparam__c, __skparam__rect); return __skadapter__to_point_2d(__skreturn); } +point_2d closest_point_on_triangle_from_circle(const circle &c, const triangle &tri) { + const __sklib_circle __skparam__c = __skadapter__to_sklib_circle(c); + const __sklib_triangle __skparam__tri = __skadapter__to_sklib_triangle(tri); + __sklib_point_2d __skreturn = __sklib__closest_point_on_triangle_from_circle__circle_ref__triangle_ref(__skparam__c, __skparam__tri); + return __skadapter__to_point_2d(__skreturn); +} point_2d distant_point_on_circle(const point_2d &pt, const circle &c) { const __sklib_point_2d __skparam__pt = __skadapter__to_sklib_point_2d(pt); const __sklib_circle __skparam__c = __skadapter__to_sklib_circle(c); @@ -2412,19 +2432,19 @@ bool bitmap_button(bitmap bmp, drawing_options opts) { int __skreturn = __sklib__bitmap_button__bitmap__drawing_options(__skparam__bmp, __skparam__opts); return __skadapter__to_bool(__skreturn); } -bool bitmap_button(const string &label, bitmap bmp) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); +bool bitmap_button(const string &label_text, bitmap bmp) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); __sklib_bitmap __skparam__bmp = __skadapter__to_sklib_bitmap(bmp); - int __skreturn = __sklib__bitmap_button__string_ref__bitmap(__skparam__label, __skparam__bmp); - __skadapter__free__sklib_string(__skparam__label); + int __skreturn = __sklib__bitmap_button__string_ref__bitmap(__skparam__label_text, __skparam__bmp); + __skadapter__free__sklib_string(__skparam__label_text); return __skadapter__to_bool(__skreturn); } -bool bitmap_button(const string &label, bitmap bmp, drawing_options opts) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); +bool bitmap_button(const string &label_text, bitmap bmp, drawing_options opts) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); __sklib_bitmap __skparam__bmp = __skadapter__to_sklib_bitmap(bmp); __sklib_drawing_options __skparam__opts = __skadapter__to_sklib_drawing_options(opts); - int __skreturn = __sklib__bitmap_button__string_ref__bitmap__drawing_options(__skparam__label, __skparam__bmp, __skparam__opts); - __skadapter__free__sklib_string(__skparam__label); + int __skreturn = __sklib__bitmap_button__string_ref__bitmap__drawing_options(__skparam__label_text, __skparam__bmp, __skparam__opts); + __skadapter__free__sklib_string(__skparam__label_text); return __skadapter__to_bool(__skreturn); } bool button(const string &text, const rectangle &rect) { @@ -2440,11 +2460,11 @@ bool button(const string &text) { __skadapter__free__sklib_string(__skparam__text); return __skadapter__to_bool(__skreturn); } -bool button(const string &label, const string &text) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); +bool button(const string &label_text, const string &text) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); const __sklib_string __skparam__text = __skadapter__to_sklib_string(text); - int __skreturn = __sklib__button__string_ref__string_ref(__skparam__label, __skparam__text); - __skadapter__free__sklib_string(__skparam__label); + int __skreturn = __sklib__button__string_ref__string_ref(__skparam__label_text, __skparam__text); + __skadapter__free__sklib_string(__skparam__label_text); __skadapter__free__sklib_string(__skparam__text); return __skadapter__to_bool(__skreturn); } @@ -2463,12 +2483,12 @@ bool checkbox(const string &text, const bool &value) { __skadapter__free__sklib_string(__skparam__text); return __skadapter__to_bool(__skreturn); } -bool checkbox(const string &label, const string &text, const bool &value) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); +bool checkbox(const string &label_text, const string &text, const bool &value) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); const __sklib_string __skparam__text = __skadapter__to_sklib_string(text); const int __skparam__value = __skadapter__to_int(value); - int __skreturn = __sklib__checkbox__string_ref__string_ref__bool_ref(__skparam__label, __skparam__text, __skparam__value); - __skadapter__free__sklib_string(__skparam__label); + int __skreturn = __sklib__checkbox__string_ref__string_ref__bool_ref(__skparam__label_text, __skparam__text, __skparam__value); + __skadapter__free__sklib_string(__skparam__label_text); __skadapter__free__sklib_string(__skparam__text); return __skadapter__to_bool(__skreturn); } @@ -2483,11 +2503,11 @@ color color_slider(const color &clr) { __sklib_color __skreturn = __sklib__color_slider__color_ref(__skparam__clr); return __skadapter__to_color(__skreturn); } -color color_slider(const string &label, const color &clr) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); +color color_slider(const string &label_text, const color &clr) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); const __sklib_color __skparam__clr = __skadapter__to_sklib_color(clr); - __sklib_color __skreturn = __sklib__color_slider__string_ref__color_ref(__skparam__label, __skparam__clr); - __skadapter__free__sklib_string(__skparam__label); + __sklib_color __skreturn = __sklib__color_slider__string_ref__color_ref(__skparam__label_text, __skparam__clr); + __skadapter__free__sklib_string(__skparam__label_text); return __skadapter__to_color(__skreturn); } void disable_interface() { @@ -2514,10 +2534,10 @@ void end_popup(const string &name) { __sklib__end_popup__string_ref(__skparam__name); __skadapter__free__sklib_string(__skparam__name); } -void end_treenode(const string &label) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); - __sklib__end_treenode__string_ref(__skparam__label); - __skadapter__free__sklib_string(__skparam__label); +void end_treenode(const string &label_text) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); + __sklib__end_treenode__string_ref(__skparam__label_text); + __skadapter__free__sklib_string(__skparam__label_text); } void enter_column() { __sklib__enter_column(); @@ -2526,10 +2546,10 @@ int get_interface_label_width() { int __skreturn = __sklib__get_interface_label_width(); return __skadapter__to_int(__skreturn); } -bool header(const string &label) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); - int __skreturn = __sklib__header__string_ref(__skparam__label); - __skadapter__free__sklib_string(__skparam__label); +bool header(const string &label_text) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); + int __skreturn = __sklib__header__string_ref(__skparam__label_text); + __skadapter__free__sklib_string(__skparam__label_text); return __skadapter__to_bool(__skreturn); } color hsb_color_slider(const color &clr, const rectangle &rect) { @@ -2543,11 +2563,11 @@ color hsb_color_slider(const color &clr) { __sklib_color __skreturn = __sklib__hsb_color_slider__color_ref(__skparam__clr); return __skadapter__to_color(__skreturn); } -color hsb_color_slider(const string &label, const color &clr) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); +color hsb_color_slider(const string &label_text, const color &clr) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); const __sklib_color __skparam__clr = __skadapter__to_sklib_color(clr); - __sklib_color __skreturn = __sklib__hsb_color_slider__string_ref__color_ref(__skparam__label, __skparam__clr); - __skadapter__free__sklib_string(__skparam__label); + __sklib_color __skreturn = __sklib__hsb_color_slider__string_ref__color_ref(__skparam__label_text, __skparam__clr); + __skadapter__free__sklib_string(__skparam__label_text); return __skadapter__to_color(__skreturn); } bool interface_enabled() { @@ -2558,15 +2578,15 @@ void interface_style_panel(const rectangle &initial_rectangle) { const __sklib_rectangle __skparam__initial_rectangle = __skadapter__to_sklib_rectangle(initial_rectangle); __sklib__interface_style_panel__rectangle_ref(__skparam__initial_rectangle); } -void label(const string &text) { +void label_element(const string &text) { const __sklib_string __skparam__text = __skadapter__to_sklib_string(text); - __sklib__label__string_ref(__skparam__text); + __sklib__label_element__string_ref(__skparam__text); __skadapter__free__sklib_string(__skparam__text); } -void label(const string &text, const rectangle &rect) { +void label_element(const string &text, const rectangle &rect) { const __sklib_string __skparam__text = __skadapter__to_sklib_string(text); const __sklib_rectangle __skparam__rect = __skadapter__to_sklib_rectangle(rect); - __sklib__label__string_ref__rectangle_ref(__skparam__text, __skparam__rect); + __sklib__label_element__string_ref__rectangle_ref(__skparam__text, __skparam__rect); __skadapter__free__sklib_string(__skparam__text); } bool last_element_changed() { @@ -2593,12 +2613,12 @@ float number_box(const float &value, float step) { float __skreturn = __sklib__number_box__float_ref__float(__skparam__value, __skparam__step); return __skadapter__to_float(__skreturn); } -float number_box(const string &label, const float &value, float step) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); +float number_box(const string &label_text, const float &value, float step) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); const float __skparam__value = __skadapter__to_float(value); float __skparam__step = __skadapter__to_float(step); - float __skreturn = __sklib__number_box__string_ref__float_ref__float(__skparam__label, __skparam__value, __skparam__step); - __skadapter__free__sklib_string(__skparam__label); + float __skreturn = __sklib__number_box__string_ref__float_ref__float(__skparam__label_text, __skparam__value, __skparam__step); + __skadapter__free__sklib_string(__skparam__label_text); return __skadapter__to_float(__skreturn); } void open_popup(const string &name) { @@ -2721,13 +2741,13 @@ float slider(const float &value, float min_value, float max_value) { float __skreturn = __sklib__slider__float_ref__float__float(__skparam__value, __skparam__min_value, __skparam__max_value); return __skadapter__to_float(__skreturn); } -float slider(const string &label, const float &value, float min_value, float max_value) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); +float slider(const string &label_text, const float &value, float min_value, float max_value) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); const float __skparam__value = __skadapter__to_float(value); float __skparam__min_value = __skadapter__to_float(min_value); float __skparam__max_value = __skadapter__to_float(max_value); - float __skreturn = __sklib__slider__string_ref__float_ref__float__float(__skparam__label, __skparam__value, __skparam__min_value, __skparam__max_value); - __skadapter__free__sklib_string(__skparam__label); + float __skreturn = __sklib__slider__string_ref__float_ref__float__float(__skparam__label_text, __skparam__value, __skparam__min_value, __skparam__max_value); + __skadapter__free__sklib_string(__skparam__label_text); return __skadapter__to_float(__skreturn); } void split_into_columns(int count) { @@ -2772,10 +2792,10 @@ bool start_popup(const string &name) { __skadapter__free__sklib_string(__skparam__name); return __skadapter__to_bool(__skreturn); } -bool start_treenode(const string &label) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); - int __skreturn = __sklib__start_treenode__string_ref(__skparam__label); - __skadapter__free__sklib_string(__skparam__label); +bool start_treenode(const string &label_text) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); + int __skreturn = __sklib__start_treenode__string_ref(__skparam__label_text); + __skadapter__free__sklib_string(__skparam__label_text); return __skadapter__to_bool(__skreturn); } string text_box(const string &value) { @@ -2791,11 +2811,11 @@ string text_box(const string &value, const rectangle &rect) { __skadapter__free__sklib_string(__skparam__value); return __skadapter__to_string(__skreturn); } -string text_box(const string &label, const string &value) { - const __sklib_string __skparam__label = __skadapter__to_sklib_string(label); +string text_box(const string &label_text, const string &value) { + const __sklib_string __skparam__label_text = __skadapter__to_sklib_string(label_text); const __sklib_string __skparam__value = __skadapter__to_sklib_string(value); - __sklib_string __skreturn = __sklib__text_box__string_ref__string_ref(__skparam__label, __skparam__value); - __skadapter__free__sklib_string(__skparam__label); + __sklib_string __skreturn = __sklib__text_box__string_ref__string_ref(__skparam__label_text, __skparam__value); + __skadapter__free__sklib_string(__skparam__label_text); __skadapter__free__sklib_string(__skparam__value); return __skadapter__to_string(__skreturn); } @@ -3553,9 +3573,9 @@ bool music_valid(music m) { int __skreturn = __sklib__music_valid__music(__skparam__m); return __skadapter__to_bool(__skreturn); } -float music_volume() { - float __skreturn = __sklib__music_volume(); - return __skadapter__to_float(__skreturn); +double music_volume() { + double __skreturn = __sklib__music_volume(); + return __skadapter__to_double(__skreturn); } void pause_music() { __sklib__pause_music(); @@ -3580,18 +3600,18 @@ void play_music(music data, int times) { int __skparam__times = __skadapter__to_int(times); __sklib__play_music__music__int(__skparam__data, __skparam__times); } -void play_music(music data, int times, float volume) { +void play_music(music data, int times, double volume) { __sklib_music __skparam__data = __skadapter__to_sklib_music(data); int __skparam__times = __skadapter__to_int(times); - float __skparam__volume = __skadapter__to_float(volume); - __sklib__play_music__music__int__float(__skparam__data, __skparam__times, __skparam__volume); + double __skparam__volume = __skadapter__to_double(volume); + __sklib__play_music__music__int__double(__skparam__data, __skparam__times, __skparam__volume); } void resume_music() { __sklib__resume_music(); } -void set_music_volume(float volume) { - float __skparam__volume = __skadapter__to_float(volume); - __sklib__set_music_volume__float(__skparam__volume); +void set_music_volume(double volume) { + double __skparam__volume = __skadapter__to_double(volume); + __sklib__set_music_volume__double(__skparam__volume); } void stop_music() { __sklib__stop_music(); @@ -4789,10 +4809,10 @@ void play_sound_effect(const string &name) { __sklib__play_sound_effect__string_ref(__skparam__name); __skadapter__free__sklib_string(__skparam__name); } -void play_sound_effect(const string &name, float volume) { +void play_sound_effect(const string &name, double volume) { const __sklib_string __skparam__name = __skadapter__to_sklib_string(name); - float __skparam__volume = __skadapter__to_float(volume); - __sklib__play_sound_effect__string_ref__float(__skparam__name, __skparam__volume); + double __skparam__volume = __skadapter__to_double(volume); + __sklib__play_sound_effect__string_ref__double(__skparam__name, __skparam__volume); __skadapter__free__sklib_string(__skparam__name); } void play_sound_effect(const string &name, int times) { @@ -4801,32 +4821,32 @@ void play_sound_effect(const string &name, int times) { __sklib__play_sound_effect__string_ref__int(__skparam__name, __skparam__times); __skadapter__free__sklib_string(__skparam__name); } -void play_sound_effect(const string &name, int times, float volume) { +void play_sound_effect(const string &name, int times, double volume) { const __sklib_string __skparam__name = __skadapter__to_sklib_string(name); int __skparam__times = __skadapter__to_int(times); - float __skparam__volume = __skadapter__to_float(volume); - __sklib__play_sound_effect__string_ref__int__float(__skparam__name, __skparam__times, __skparam__volume); + double __skparam__volume = __skadapter__to_double(volume); + __sklib__play_sound_effect__string_ref__int__double(__skparam__name, __skparam__times, __skparam__volume); __skadapter__free__sklib_string(__skparam__name); } void play_sound_effect(sound_effect effect) { __sklib_sound_effect __skparam__effect = __skadapter__to_sklib_sound_effect(effect); __sklib__play_sound_effect__sound_effect(__skparam__effect); } -void play_sound_effect(sound_effect effect, float volume) { +void play_sound_effect(sound_effect effect, double volume) { __sklib_sound_effect __skparam__effect = __skadapter__to_sklib_sound_effect(effect); - float __skparam__volume = __skadapter__to_float(volume); - __sklib__play_sound_effect__sound_effect__float(__skparam__effect, __skparam__volume); + double __skparam__volume = __skadapter__to_double(volume); + __sklib__play_sound_effect__sound_effect__double(__skparam__effect, __skparam__volume); } void play_sound_effect(sound_effect effect, int times) { __sklib_sound_effect __skparam__effect = __skadapter__to_sklib_sound_effect(effect); int __skparam__times = __skadapter__to_int(times); __sklib__play_sound_effect__sound_effect__int(__skparam__effect, __skparam__times); } -void play_sound_effect(sound_effect effect, int times, float volume) { +void play_sound_effect(sound_effect effect, int times, double volume) { __sklib_sound_effect __skparam__effect = __skadapter__to_sklib_sound_effect(effect); int __skparam__times = __skadapter__to_int(times); - float __skparam__volume = __skadapter__to_float(volume); - __sklib__play_sound_effect__sound_effect__int__float(__skparam__effect, __skparam__times, __skparam__volume); + double __skparam__volume = __skadapter__to_double(volume); + __sklib__play_sound_effect__sound_effect__int__double(__skparam__effect, __skparam__times, __skparam__volume); } string sound_effect_filename(sound_effect effect) { __sklib_sound_effect __skparam__effect = __skadapter__to_sklib_sound_effect(effect); @@ -6490,9 +6510,9 @@ double vector_magnitude(const vector_2d &v) { double __skreturn = __sklib__vector_magnitude__vector_2d_ref(__skparam__v); return __skadapter__to_double(__skreturn); } -double vector_magnitude_sqared(const vector_2d &v) { +double vector_magnitude_squared(const vector_2d &v) { const __sklib_vector_2d __skparam__v = __skadapter__to_sklib_vector_2d(v); - double __skreturn = __sklib__vector_magnitude_sqared__vector_2d_ref(__skparam__v); + double __skreturn = __sklib__vector_magnitude_squared__vector_2d_ref(__skparam__v); return __skadapter__to_double(__skreturn); } vector_2d vector_multiply(const vector_2d &v1, double s) { diff --git a/python3/splashkit.py b/python3/splashkit.py index 9427a36..483bd5b 100644 --- a/python3/splashkit.py +++ b/python3/splashkit.py @@ -2,7 +2,6 @@ from enum import Enum from platform import system import os -import sys search_paths = [] @@ -14,7 +13,7 @@ search_paths = ["/usr/local/lib/libSplashKit.so", os.path.expanduser("~") + "/.splashkit/lib/linux/libSplashKit.so"] else: # Windows uses .dll extension - search_paths = [sys.prefix + "/lib/SplashKit.dll", "C:/msys64/home/" + os.getlogin() + "/.splashkit/lib/win64/SplashKit.dll"] + search_paths = ["C:/msys64/mingw64/lib/SplashKit.dll", "C:/msys64/home/" + os.getlogin() + "/.splashkit/lib/win64/SplashKit.dll"] # find path to use -> format above is: ["global/path", ".splashkit/path"] for path in search_paths: @@ -1599,6 +1598,10 @@ def __skadapter__to_sklib_window(v): sklib.__sklib__circle_at__double__double__double.restype = _sklib_circle sklib.__sklib__circle_radius__circle.argtypes = [ _sklib_circle ] sklib.__sklib__circle_radius__circle.restype = c_float +sklib.__sklib__circle_triangle_intersect__circle_ref__triangle_ref.argtypes = [ _sklib_circle, _sklib_triangle ] +sklib.__sklib__circle_triangle_intersect__circle_ref__triangle_ref.restype = c_bool +sklib.__sklib__circle_triangle_intersect__circle_ref__triangle_ref__point_2d_ref.argtypes = [ _sklib_circle, _sklib_triangle, POINTER(_sklib_point_2d) ] +sklib.__sklib__circle_triangle_intersect__circle_ref__triangle_ref__point_2d_ref.restype = c_bool sklib.__sklib__circle_x__circle_ref.argtypes = [ _sklib_circle ] sklib.__sklib__circle_x__circle_ref.restype = c_float sklib.__sklib__circle_y__circle_ref.argtypes = [ _sklib_circle ] @@ -1613,6 +1616,8 @@ def __skadapter__to_sklib_window(v): sklib.__sklib__closest_point_on_line_from_circle__circle_ref__line_ref.restype = _sklib_point_2d sklib.__sklib__closest_point_on_rect_from_circle__circle_ref__rectangle_ref.argtypes = [ _sklib_circle, _sklib_rectangle ] sklib.__sklib__closest_point_on_rect_from_circle__circle_ref__rectangle_ref.restype = _sklib_point_2d +sklib.__sklib__closest_point_on_triangle_from_circle__circle_ref__triangle_ref.argtypes = [ _sklib_circle, _sklib_triangle ] +sklib.__sklib__closest_point_on_triangle_from_circle__circle_ref__triangle_ref.restype = _sklib_point_2d sklib.__sklib__distant_point_on_circle__point_2d_ref__circle_ref.argtypes = [ _sklib_point_2d, _sklib_circle ] sklib.__sklib__distant_point_on_circle__point_2d_ref__circle_ref.restype = _sklib_point_2d sklib.__sklib__distant_point_on_circle_heading__point_2d_ref__circle_ref__vector_2d_ref__point_2d_ref.argtypes = [ _sklib_point_2d, _sklib_circle, _sklib_vector_2d, POINTER(_sklib_point_2d) ] @@ -2335,10 +2340,10 @@ def __skadapter__to_sklib_window(v): sklib.__sklib__interface_enabled.restype = c_bool sklib.__sklib__interface_style_panel__rectangle_ref.argtypes = [ _sklib_rectangle ] sklib.__sklib__interface_style_panel__rectangle_ref.restype = None -sklib.__sklib__label__string_ref.argtypes = [ _sklib_string ] -sklib.__sklib__label__string_ref.restype = None -sklib.__sklib__label__string_ref__rectangle_ref.argtypes = [ _sklib_string, _sklib_rectangle ] -sklib.__sklib__label__string_ref__rectangle_ref.restype = None +sklib.__sklib__label_element__string_ref.argtypes = [ _sklib_string ] +sklib.__sklib__label_element__string_ref.restype = None +sklib.__sklib__label_element__string_ref__rectangle_ref.argtypes = [ _sklib_string, _sklib_rectangle ] +sklib.__sklib__label_element__string_ref__rectangle_ref.restype = None sklib.__sklib__last_element_changed.argtypes = [ ] sklib.__sklib__last_element_changed.restype = c_bool sklib.__sklib__last_element_confirmed.argtypes = [ ] @@ -2684,7 +2689,7 @@ def __skadapter__to_sklib_window(v): sklib.__sklib__music_valid__music.argtypes = [ c_void_p ] sklib.__sklib__music_valid__music.restype = c_bool sklib.__sklib__music_volume.argtypes = [ ] -sklib.__sklib__music_volume.restype = c_float +sklib.__sklib__music_volume.restype = c_double sklib.__sklib__pause_music.argtypes = [ ] sklib.__sklib__pause_music.restype = None sklib.__sklib__play_music__string_ref.argtypes = [ _sklib_string ] @@ -2695,12 +2700,12 @@ def __skadapter__to_sklib_window(v): sklib.__sklib__play_music__music.restype = None sklib.__sklib__play_music__music__int.argtypes = [ c_void_p, c_int ] sklib.__sklib__play_music__music__int.restype = None -sklib.__sklib__play_music__music__int__float.argtypes = [ c_void_p, c_int, c_float ] -sklib.__sklib__play_music__music__int__float.restype = None +sklib.__sklib__play_music__music__int__double.argtypes = [ c_void_p, c_int, c_double ] +sklib.__sklib__play_music__music__int__double.restype = None sklib.__sklib__resume_music.argtypes = [ ] sklib.__sklib__resume_music.restype = None -sklib.__sklib__set_music_volume__float.argtypes = [ c_float ] -sklib.__sklib__set_music_volume__float.restype = None +sklib.__sklib__set_music_volume__double.argtypes = [ c_double ] +sklib.__sklib__set_music_volume__double.restype = None sklib.__sklib__stop_music.argtypes = [ ] sklib.__sklib__stop_music.restype = None sklib.__sklib__accept_all_new_connections.argtypes = [ ] @@ -3111,20 +3116,20 @@ def __skadapter__to_sklib_window(v): sklib.__sklib__load_sound_effect__string_ref__string_ref.restype = c_void_p sklib.__sklib__play_sound_effect__string_ref.argtypes = [ _sklib_string ] sklib.__sklib__play_sound_effect__string_ref.restype = None -sklib.__sklib__play_sound_effect__string_ref__float.argtypes = [ _sklib_string, c_float ] -sklib.__sklib__play_sound_effect__string_ref__float.restype = None +sklib.__sklib__play_sound_effect__string_ref__double.argtypes = [ _sklib_string, c_double ] +sklib.__sklib__play_sound_effect__string_ref__double.restype = None sklib.__sklib__play_sound_effect__string_ref__int.argtypes = [ _sklib_string, c_int ] sklib.__sklib__play_sound_effect__string_ref__int.restype = None -sklib.__sklib__play_sound_effect__string_ref__int__float.argtypes = [ _sklib_string, c_int, c_float ] -sklib.__sklib__play_sound_effect__string_ref__int__float.restype = None +sklib.__sklib__play_sound_effect__string_ref__int__double.argtypes = [ _sklib_string, c_int, c_double ] +sklib.__sklib__play_sound_effect__string_ref__int__double.restype = None sklib.__sklib__play_sound_effect__sound_effect.argtypes = [ c_void_p ] sklib.__sklib__play_sound_effect__sound_effect.restype = None -sklib.__sklib__play_sound_effect__sound_effect__float.argtypes = [ c_void_p, c_float ] -sklib.__sklib__play_sound_effect__sound_effect__float.restype = None +sklib.__sklib__play_sound_effect__sound_effect__double.argtypes = [ c_void_p, c_double ] +sklib.__sklib__play_sound_effect__sound_effect__double.restype = None sklib.__sklib__play_sound_effect__sound_effect__int.argtypes = [ c_void_p, c_int ] sklib.__sklib__play_sound_effect__sound_effect__int.restype = None -sklib.__sklib__play_sound_effect__sound_effect__int__float.argtypes = [ c_void_p, c_int, c_float ] -sklib.__sklib__play_sound_effect__sound_effect__int__float.restype = None +sklib.__sklib__play_sound_effect__sound_effect__int__double.argtypes = [ c_void_p, c_int, c_double ] +sklib.__sklib__play_sound_effect__sound_effect__int__double.restype = None sklib.__sklib__sound_effect_filename__sound_effect.argtypes = [ c_void_p ] sklib.__sklib__sound_effect_filename__sound_effect.restype = _sklib_string sklib.__sklib__sound_effect_name__sound_effect.argtypes = [ c_void_p ] @@ -3677,8 +3682,8 @@ def __skadapter__to_sklib_window(v): sklib.__sklib__vector_limit__vector_2d_ref__double.restype = _sklib_vector_2d sklib.__sklib__vector_magnitude__vector_2d_ref.argtypes = [ _sklib_vector_2d ] sklib.__sklib__vector_magnitude__vector_2d_ref.restype = c_double -sklib.__sklib__vector_magnitude_sqared__vector_2d_ref.argtypes = [ _sklib_vector_2d ] -sklib.__sklib__vector_magnitude_sqared__vector_2d_ref.restype = c_double +sklib.__sklib__vector_magnitude_squared__vector_2d_ref.argtypes = [ _sklib_vector_2d ] +sklib.__sklib__vector_magnitude_squared__vector_2d_ref.restype = c_double sklib.__sklib__vector_multiply__vector_2d_ref__double.argtypes = [ _sklib_vector_2d, c_double ] sklib.__sklib__vector_multiply__vector_2d_ref__double.restype = _sklib_vector_2d sklib.__sklib__vector_normal__vector_2d_ref.argtypes = [ _sklib_vector_2d ] @@ -4358,6 +4363,18 @@ def circle_radius ( c ): __skparam__c = __skadapter__to_sklib_circle(c) __skreturn = sklib.__sklib__circle_radius__circle(__skparam__c) return __skadapter__to_float(__skreturn) +def circle_triangle_intersect ( c, tri ): + __skparam__c = __skadapter__to_sklib_circle(c) + __skparam__tri = __skadapter__to_sklib_triangle(tri) + __skreturn = sklib.__sklib__circle_triangle_intersect__circle_ref__triangle_ref(__skparam__c, __skparam__tri) + return __skadapter__to_bool(__skreturn) +def circle_triangle_intersect_get_closest_point ( c, tri, p ): + __skparam__c = __skadapter__to_sklib_circle(c) + __skparam__tri = __skadapter__to_sklib_triangle(tri) + __skparam__p = __skadapter__to_sklib_point_2d(p) + __skreturn = sklib.__sklib__circle_triangle_intersect__circle_ref__triangle_ref__point_2d_ref(__skparam__c, __skparam__tri, byref(__skparam__p)) + p = __skadapter__to_point_2d(__skparam__p) + return __skadapter__to_bool(__skreturn) def circle_x ( c ): __skparam__c = __skadapter__to_sklib_circle(c) __skreturn = sklib.__sklib__circle_x__circle_ref(__skparam__c) @@ -4395,6 +4412,11 @@ def closest_point_on_rect_from_circle ( c, rect ): __skparam__rect = __skadapter__to_sklib_rectangle(rect) __skreturn = sklib.__sklib__closest_point_on_rect_from_circle__circle_ref__rectangle_ref(__skparam__c, __skparam__rect) return __skadapter__to_point_2d(__skreturn) +def closest_point_on_triangle_from_circle ( c, tri ): + __skparam__c = __skadapter__to_sklib_circle(c) + __skparam__tri = __skadapter__to_sklib_triangle(tri) + __skreturn = sklib.__sklib__closest_point_on_triangle_from_circle__circle_ref__triangle_ref(__skparam__c, __skparam__tri) + return __skadapter__to_point_2d(__skreturn) def distant_point_on_circle ( pt, c ): __skparam__pt = __skadapter__to_sklib_point_2d(pt) __skparam__c = __skadapter__to_sklib_circle(c) @@ -5800,16 +5822,16 @@ def bitmap_button_with_options ( bmp, opts ): __skparam__opts = __skadapter__to_sklib_drawing_options(opts) __skreturn = sklib.__sklib__bitmap_button__bitmap__drawing_options(__skparam__bmp, __skparam__opts) return __skadapter__to_bool(__skreturn) -def bitmap_button_labeled ( label, bmp ): - __skparam__label = __skadapter__to_sklib_string(label) +def bitmap_button_labeled ( label_text, bmp ): + __skparam__label_text = __skadapter__to_sklib_string(label_text) __skparam__bmp = __skadapter__to_sklib_bitmap(bmp) - __skreturn = sklib.__sklib__bitmap_button__string_ref__bitmap(__skparam__label, __skparam__bmp) + __skreturn = sklib.__sklib__bitmap_button__string_ref__bitmap(__skparam__label_text, __skparam__bmp) return __skadapter__to_bool(__skreturn) -def bitmap_button_labeled_with_options ( label, bmp, opts ): - __skparam__label = __skadapter__to_sklib_string(label) +def bitmap_button_labeled_with_options ( label_text, bmp, opts ): + __skparam__label_text = __skadapter__to_sklib_string(label_text) __skparam__bmp = __skadapter__to_sklib_bitmap(bmp) __skparam__opts = __skadapter__to_sklib_drawing_options(opts) - __skreturn = sklib.__sklib__bitmap_button__string_ref__bitmap__drawing_options(__skparam__label, __skparam__bmp, __skparam__opts) + __skreturn = sklib.__sklib__bitmap_button__string_ref__bitmap__drawing_options(__skparam__label_text, __skparam__bmp, __skparam__opts) return __skadapter__to_bool(__skreturn) def button_at_position ( text, rect ): __skparam__text = __skadapter__to_sklib_string(text) @@ -5820,10 +5842,10 @@ def button ( text ): __skparam__text = __skadapter__to_sklib_string(text) __skreturn = sklib.__sklib__button__string_ref(__skparam__text) return __skadapter__to_bool(__skreturn) -def button_labeled ( label, text ): - __skparam__label = __skadapter__to_sklib_string(label) +def button_labeled ( label_text, text ): + __skparam__label_text = __skadapter__to_sklib_string(label_text) __skparam__text = __skadapter__to_sklib_string(text) - __skreturn = sklib.__sklib__button__string_ref__string_ref(__skparam__label, __skparam__text) + __skreturn = sklib.__sklib__button__string_ref__string_ref(__skparam__label_text, __skparam__text) return __skadapter__to_bool(__skreturn) def checkbox_at_position ( text, value, rect ): __skparam__text = __skadapter__to_sklib_string(text) @@ -5836,11 +5858,11 @@ def checkbox ( text, value ): __skparam__value = __skadapter__to_sklib_bool(value) __skreturn = sklib.__sklib__checkbox__string_ref__bool_ref(__skparam__text, __skparam__value) return __skadapter__to_bool(__skreturn) -def checkbox_labeled ( label, text, value ): - __skparam__label = __skadapter__to_sklib_string(label) +def checkbox_labeled ( label_text, text, value ): + __skparam__label_text = __skadapter__to_sklib_string(label_text) __skparam__text = __skadapter__to_sklib_string(text) __skparam__value = __skadapter__to_sklib_bool(value) - __skreturn = sklib.__sklib__checkbox__string_ref__string_ref__bool_ref(__skparam__label, __skparam__text, __skparam__value) + __skreturn = sklib.__sklib__checkbox__string_ref__string_ref__bool_ref(__skparam__label_text, __skparam__text, __skparam__value) return __skadapter__to_bool(__skreturn) def color_slider_at_position ( clr, rect ): __skparam__clr = __skadapter__to_sklib_color(clr) @@ -5851,10 +5873,10 @@ def color_slider ( clr ): __skparam__clr = __skadapter__to_sklib_color(clr) __skreturn = sklib.__sklib__color_slider__color_ref(__skparam__clr) return __skadapter__to_color(__skreturn) -def color_slider_labeled ( label, clr ): - __skparam__label = __skadapter__to_sklib_string(label) +def color_slider_labeled ( label_text, clr ): + __skparam__label_text = __skadapter__to_sklib_string(label_text) __skparam__clr = __skadapter__to_sklib_color(clr) - __skreturn = sklib.__sklib__color_slider__string_ref__color_ref(__skparam__label, __skparam__clr) + __skreturn = sklib.__sklib__color_slider__string_ref__color_ref(__skparam__label_text, __skparam__clr) return __skadapter__to_color(__skreturn) def disable_interface ( ): sklib.__sklib__disable_interface() @@ -5871,17 +5893,17 @@ def end_panel ( name ): def end_popup ( name ): __skparam__name = __skadapter__to_sklib_string(name) sklib.__sklib__end_popup__string_ref(__skparam__name) -def end_treenode ( label ): - __skparam__label = __skadapter__to_sklib_string(label) - sklib.__sklib__end_treenode__string_ref(__skparam__label) +def end_treenode ( label_text ): + __skparam__label_text = __skadapter__to_sklib_string(label_text) + sklib.__sklib__end_treenode__string_ref(__skparam__label_text) def enter_column ( ): sklib.__sklib__enter_column() def get_interface_label_width ( ): __skreturn = sklib.__sklib__get_interface_label_width() return __skadapter__to_int(__skreturn) -def header ( label ): - __skparam__label = __skadapter__to_sklib_string(label) - __skreturn = sklib.__sklib__header__string_ref(__skparam__label) +def header ( label_text ): + __skparam__label_text = __skadapter__to_sklib_string(label_text) + __skreturn = sklib.__sklib__header__string_ref(__skparam__label_text) return __skadapter__to_bool(__skreturn) def hsb_color_slider_at_position ( clr, rect ): __skparam__clr = __skadapter__to_sklib_color(clr) @@ -5892,10 +5914,10 @@ def hsb_color_slider ( clr ): __skparam__clr = __skadapter__to_sklib_color(clr) __skreturn = sklib.__sklib__hsb_color_slider__color_ref(__skparam__clr) return __skadapter__to_color(__skreturn) -def hsb_color_slider_labeled ( label, clr ): - __skparam__label = __skadapter__to_sklib_string(label) +def hsb_color_slider_labeled ( label_text, clr ): + __skparam__label_text = __skadapter__to_sklib_string(label_text) __skparam__clr = __skadapter__to_sklib_color(clr) - __skreturn = sklib.__sklib__hsb_color_slider__string_ref__color_ref(__skparam__label, __skparam__clr) + __skreturn = sklib.__sklib__hsb_color_slider__string_ref__color_ref(__skparam__label_text, __skparam__clr) return __skadapter__to_color(__skreturn) def interface_enabled ( ): __skreturn = sklib.__sklib__interface_enabled() @@ -5903,13 +5925,13 @@ def interface_enabled ( ): def interface_style_panel ( initial_rectangle ): __skparam__initial_rectangle = __skadapter__to_sklib_rectangle(initial_rectangle) sklib.__sklib__interface_style_panel__rectangle_ref(__skparam__initial_rectangle) -def label ( text ): +def label_element ( text ): __skparam__text = __skadapter__to_sklib_string(text) - sklib.__sklib__label__string_ref(__skparam__text) -def label_at_position ( text, rect ): + sklib.__sklib__label_element__string_ref(__skparam__text) +def label_element_at_position ( text, rect ): __skparam__text = __skadapter__to_sklib_string(text) __skparam__rect = __skadapter__to_sklib_rectangle(rect) - sklib.__sklib__label__string_ref__rectangle_ref(__skparam__text, __skparam__rect) + sklib.__sklib__label_element__string_ref__rectangle_ref(__skparam__text, __skparam__rect) def last_element_changed ( ): __skreturn = sklib.__sklib__last_element_changed() return __skadapter__to_bool(__skreturn) @@ -5929,11 +5951,11 @@ def number_box ( value, step ): __skparam__step = __skadapter__to_sklib_float(step) __skreturn = sklib.__sklib__number_box__float_ref__float(__skparam__value, __skparam__step) return __skadapter__to_float(__skreturn) -def number_box_labeled ( label, value, step ): - __skparam__label = __skadapter__to_sklib_string(label) +def number_box_labeled ( label_text, value, step ): + __skparam__label_text = __skadapter__to_sklib_string(label_text) __skparam__value = __skadapter__to_sklib_float(value) __skparam__step = __skadapter__to_sklib_float(step) - __skreturn = sklib.__sklib__number_box__string_ref__float_ref__float(__skparam__label, __skparam__value, __skparam__step) + __skreturn = sklib.__sklib__number_box__string_ref__float_ref__float(__skparam__label_text, __skparam__value, __skparam__step) return __skadapter__to_float(__skreturn) def open_popup ( name ): __skparam__name = __skadapter__to_sklib_string(name) @@ -6027,12 +6049,12 @@ def slider ( value, min_value, max_value ): __skparam__max_value = __skadapter__to_sklib_float(max_value) __skreturn = sklib.__sklib__slider__float_ref__float__float(__skparam__value, __skparam__min_value, __skparam__max_value) return __skadapter__to_float(__skreturn) -def slider_labeled ( label, value, min_value, max_value ): - __skparam__label = __skadapter__to_sklib_string(label) +def slider_labeled ( label_text, value, min_value, max_value ): + __skparam__label_text = __skadapter__to_sklib_string(label_text) __skparam__value = __skadapter__to_sklib_float(value) __skparam__min_value = __skadapter__to_sklib_float(min_value) __skparam__max_value = __skadapter__to_sklib_float(max_value) - __skreturn = sklib.__sklib__slider__string_ref__float_ref__float__float(__skparam__label, __skparam__value, __skparam__min_value, __skparam__max_value) + __skreturn = sklib.__sklib__slider__string_ref__float_ref__float__float(__skparam__label_text, __skparam__value, __skparam__min_value, __skparam__max_value) return __skadapter__to_float(__skreturn) def split_into_columns ( count ): __skparam__count = __skadapter__to_sklib_int(count) @@ -6064,9 +6086,9 @@ def start_popup ( name ): __skparam__name = __skadapter__to_sklib_string(name) __skreturn = sklib.__sklib__start_popup__string_ref(__skparam__name) return __skadapter__to_bool(__skreturn) -def start_treenode ( label ): - __skparam__label = __skadapter__to_sklib_string(label) - __skreturn = sklib.__sklib__start_treenode__string_ref(__skparam__label) +def start_treenode ( label_text ): + __skparam__label_text = __skadapter__to_sklib_string(label_text) + __skreturn = sklib.__sklib__start_treenode__string_ref(__skparam__label_text) return __skadapter__to_bool(__skreturn) def text_box ( value ): __skparam__value = __skadapter__to_sklib_string(value) @@ -6077,10 +6099,10 @@ def text_box_at_position ( value, rect ): __skparam__rect = __skadapter__to_sklib_rectangle(rect) __skreturn = sklib.__sklib__text_box__string_ref__rectangle_ref(__skparam__value, __skparam__rect) return __skadapter__to_string(__skreturn) -def text_box_labeled ( label, value ): - __skparam__label = __skadapter__to_sklib_string(label) +def text_box_labeled ( label_text, value ): + __skparam__label_text = __skadapter__to_sklib_string(label_text) __skparam__value = __skadapter__to_sklib_string(value) - __skreturn = sklib.__sklib__text_box__string_ref__string_ref(__skparam__label, __skparam__value) + __skreturn = sklib.__sklib__text_box__string_ref__string_ref(__skparam__label_text, __skparam__value) return __skadapter__to_string(__skreturn) def create_json ( ): __skreturn = sklib.__sklib__create_json() @@ -6665,7 +6687,7 @@ def music_valid ( m ): return __skadapter__to_bool(__skreturn) def music_volume ( ): __skreturn = sklib.__sklib__music_volume() - return __skadapter__to_float(__skreturn) + return __skadapter__to_double(__skreturn) def pause_music ( ): sklib.__sklib__pause_music() def play_music_named ( name ): @@ -6685,13 +6707,13 @@ def play_music_with_times ( data, times ): def play_music_with_times_and_volume ( data, times, volume ): __skparam__data = __skadapter__to_sklib_music(data) __skparam__times = __skadapter__to_sklib_int(times) - __skparam__volume = __skadapter__to_sklib_float(volume) - sklib.__sklib__play_music__music__int__float(__skparam__data, __skparam__times, __skparam__volume) + __skparam__volume = __skadapter__to_sklib_double(volume) + sklib.__sklib__play_music__music__int__double(__skparam__data, __skparam__times, __skparam__volume) def resume_music ( ): sklib.__sklib__resume_music() def set_music_volume ( volume ): - __skparam__volume = __skadapter__to_sklib_float(volume) - sklib.__sklib__set_music_volume__float(__skparam__volume) + __skparam__volume = __skadapter__to_sklib_double(volume) + sklib.__sklib__set_music_volume__double(__skparam__volume) def stop_music ( ): sklib.__sklib__stop_music() def accept_all_new_connections ( ): @@ -7642,8 +7664,8 @@ def play_sound_effect_named ( name ): sklib.__sklib__play_sound_effect__string_ref(__skparam__name) def play_sound_effect_named_with_volume ( name, volume ): __skparam__name = __skadapter__to_sklib_string(name) - __skparam__volume = __skadapter__to_sklib_float(volume) - sklib.__sklib__play_sound_effect__string_ref__float(__skparam__name, __skparam__volume) + __skparam__volume = __skadapter__to_sklib_double(volume) + sklib.__sklib__play_sound_effect__string_ref__double(__skparam__name, __skparam__volume) def play_sound_effect_named_with_times ( name, times ): __skparam__name = __skadapter__to_sklib_string(name) __skparam__times = __skadapter__to_sklib_int(times) @@ -7651,15 +7673,15 @@ def play_sound_effect_named_with_times ( name, times ): def play_sound_effect_named_with_times_and_volume ( name, times, volume ): __skparam__name = __skadapter__to_sklib_string(name) __skparam__times = __skadapter__to_sklib_int(times) - __skparam__volume = __skadapter__to_sklib_float(volume) - sklib.__sklib__play_sound_effect__string_ref__int__float(__skparam__name, __skparam__times, __skparam__volume) + __skparam__volume = __skadapter__to_sklib_double(volume) + sklib.__sklib__play_sound_effect__string_ref__int__double(__skparam__name, __skparam__times, __skparam__volume) def play_sound_effect ( effect ): __skparam__effect = __skadapter__to_sklib_sound_effect(effect) sklib.__sklib__play_sound_effect__sound_effect(__skparam__effect) def play_sound_effect_with_volume ( effect, volume ): __skparam__effect = __skadapter__to_sklib_sound_effect(effect) - __skparam__volume = __skadapter__to_sklib_float(volume) - sklib.__sklib__play_sound_effect__sound_effect__float(__skparam__effect, __skparam__volume) + __skparam__volume = __skadapter__to_sklib_double(volume) + sklib.__sklib__play_sound_effect__sound_effect__double(__skparam__effect, __skparam__volume) def play_sound_effect_with_times ( effect, times ): __skparam__effect = __skadapter__to_sklib_sound_effect(effect) __skparam__times = __skadapter__to_sklib_int(times) @@ -7667,8 +7689,8 @@ def play_sound_effect_with_times ( effect, times ): def play_sound_effect_with_times_and_volume ( effect, times, volume ): __skparam__effect = __skadapter__to_sklib_sound_effect(effect) __skparam__times = __skadapter__to_sklib_int(times) - __skparam__volume = __skadapter__to_sklib_float(volume) - sklib.__sklib__play_sound_effect__sound_effect__int__float(__skparam__effect, __skparam__times, __skparam__volume) + __skparam__volume = __skadapter__to_sklib_double(volume) + sklib.__sklib__play_sound_effect__sound_effect__int__double(__skparam__effect, __skparam__times, __skparam__volume) def sound_effect_filename ( effect ): __skparam__effect = __skadapter__to_sklib_sound_effect(effect) __skreturn = sklib.__sklib__sound_effect_filename__sound_effect(__skparam__effect) @@ -8965,9 +8987,9 @@ def vector_magnitude ( v ): __skparam__v = __skadapter__to_sklib_vector_2d(v) __skreturn = sklib.__sklib__vector_magnitude__vector_2d_ref(__skparam__v) return __skadapter__to_double(__skreturn) -def vector_magnitude_sqared ( v ): +def vector_magnitude_squared ( v ): __skparam__v = __skadapter__to_sklib_vector_2d(v) - __skreturn = sklib.__sklib__vector_magnitude_sqared__vector_2d_ref(__skparam__v) + __skreturn = sklib.__sklib__vector_magnitude_squared__vector_2d_ref(__skparam__v) return __skadapter__to_double(__skreturn) def vector_multiply ( v1, s ): __skparam__v1 = __skadapter__to_sklib_vector_2d(v1) diff --git a/source/audio_driver.cpp b/source/audio_driver.cpp index a4e9ff7..b638ea5 100644 --- a/source/audio_driver.cpp +++ b/source/audio_driver.cpp @@ -274,19 +274,19 @@ namespace splashkit_lib _current_music = NULL; } - void sk_set_music_vol(float vol) + void sk_set_music_vol(double vol) { internal_sk_init(); Mix_VolumeMusic( static_cast(MIX_MAX_VOLUME * vol) ); } - float sk_music_vol() + double sk_music_vol() { internal_sk_init(); - return Mix_VolumeMusic(-1) / static_cast(MIX_MAX_VOLUME); + return Mix_VolumeMusic(-1) / static_cast(MIX_MAX_VOLUME); } - float sk_sound_volume(sk_sound_data *sound) + double sk_sound_volume(sk_sound_data *sound) { if ( ! sound ) return 0.0f; @@ -296,7 +296,7 @@ namespace splashkit_lib if ( _current_music == sound ) return sk_music_vol(); break; case SGSD_SOUND_EFFECT: - return Mix_VolumeChunk(static_cast(sound->_data), -1) / static_cast(MIX_MAX_VOLUME); + return Mix_VolumeChunk(static_cast(sound->_data), -1) / static_cast(MIX_MAX_VOLUME); case SGSD_UNKNOWN: break; } @@ -304,7 +304,7 @@ namespace splashkit_lib return 0.0f; } - void sk_set_sound_volume(sk_sound_data *sound, float vol) + void sk_set_sound_volume(sk_sound_data *sound, double vol) { if ( !sound ) return; diff --git a/source/basics.cpp b/source/basics.cpp index 7716f04..1a5967a 100644 --- a/source/basics.cpp +++ b/source/basics.cpp @@ -76,6 +76,9 @@ namespace splashkit_lib string replace_all(const string &text, const string &substr, const string &replacement) { + if (substr.empty()) + return text; + string result = text; size_t pos = 0; while ((pos = result.find(substr, pos)) != string::npos) diff --git a/source/circle_geometry.cpp b/source/circle_geometry.cpp index ea78a97..696e18e 100644 --- a/source/circle_geometry.cpp +++ b/source/circle_geometry.cpp @@ -108,6 +108,36 @@ namespace splashkit_lib return point_point_distance(point_at(c1_x, c1_y), point_at(c2_x, c2_y)) < c1_radius + c2_radius; } + bool circle_triangle_intersect(const circle &c, const triangle &tri) + { + point_2d p; + return circle_triangle_intersect(c, tri, p); + } + + bool circle_triangle_intersect(const circle &c, const triangle &tri, point_2d &p) + { + // Check if the sphere center is inside the triangle + if (point_in_triangle(c.center, tri)) + { + p = c.center; + return true; + } + + int idx; + // Find the closest point on the triangle to the sphere center + p = closest_point_on_lines(c.center, lines_from(tri), idx); + + // Circle and triangle intersect if the squared distance from circle + // center to point p is less than the squared circle radius + return vector_magnitude_squared(vector_point_to_point(c.center, p)) < c.radius * c.radius; + } + + point_2d closest_point_on_triangle_from_circle(const circle &c, const triangle &tri) + { + point_2d p; + circle_triangle_intersect(c, tri, p); + return p; + } float circle_radius(const circle c) { @@ -144,7 +174,7 @@ namespace splashkit_lib { vector_2d pm_c = vector_point_to_point(from_pt, c.center); - double sqr_len = vector_magnitude_sqared(pm_c); + double sqr_len = vector_magnitude_squared(pm_c); double r_sqr = c.radius * c.radius; // Quick check for P inside the circle, return False if so diff --git a/source/clipping.cpp b/source/clipping.cpp index dbe480f..d26c48f 100644 --- a/source/clipping.cpp +++ b/source/clipping.cpp @@ -119,7 +119,7 @@ namespace splashkit_lib if ( img.clip_stack.size() > 0 ) { - rectangle clip_rect = *img.clip_stack.end(); + rectangle clip_rect = *img.clip_stack.back(); sk_set_clip_rect(&img.surface, clip_rect.x, clip_rect.y, clip_rect.width, clip_rect.height); } else @@ -158,7 +158,7 @@ namespace splashkit_lib rectangle _current_clip(const image_data &img) { if (img.clip_stack.size() > 0) - return *img.clip_stack.end(); + return *img.clip_stack.back(); else return rectangle_from(0, 0, img.surface.width, img.surface.height); } diff --git a/source/include/audio_driver.h b/source/include/audio_driver.h index 27997f3..36f4527 100644 --- a/source/include/audio_driver.h +++ b/source/include/audio_driver.h @@ -56,13 +56,13 @@ namespace splashkit_lib void sk_fade_music_out(int ms); - void sk_set_music_vol(float vol); + void sk_set_music_vol(double vol); - float sk_music_vol(); + double sk_music_vol(); - float sk_sound_volume(sk_sound_data *sound); + double sk_sound_volume(sk_sound_data *sound); - void sk_set_sound_volume(sk_sound_data *sound, float vol); + void sk_set_sound_volume(sk_sound_data *sound, double vol); void sk_pause_music(); diff --git a/source/include/circle_geometry.h b/source/include/circle_geometry.h index 336416b..8da2bb9 100644 --- a/source/include/circle_geometry.h +++ b/source/include/circle_geometry.h @@ -58,6 +58,42 @@ namespace splashkit_lib */ bool circles_intersect(double c1_x, double c1_y, double c1_radius, double c2_x, double c2_y, double c2_radius); + /** + * Detects if a circle intersects with a triangle. + * + * @param c The circle to test + * @param tri The triangle to test + * @returns True if the circle and triangle intersect + */ + bool circle_triangle_intersect(const circle &c, const triangle &tri); + + /** + * Detects if a circle intersects with a triangle. The closest point on the + * triangle to the circle is assigned to p, even if the circle and triangle do not + * intersect. If the centre of the circle is inside the triangle, + * the point assigned to p is the centre of the circle. + * + * @param c The circle to test + * @param tri The triangle to test + * @param p The point to set to the closest point on the triangle to the circle + * @returns True if the circle and triangle intersect + * + * @attribute suffix get_closest_point + */ + bool circle_triangle_intersect(const circle &c, const triangle &tri, point_2d &p); + + /** + * Calculates the closest point on a triangle to a circle. If the circle and + * triangle do not intersect, the closest point on the triangle to the circle + * is returned. If the circle and triangle do intersect, the center of the + * circle is returned. + * + * @param c The circle to test + * @param tri The triangle to test + * @returns The closest point on the triangle to the circle + */ + point_2d closest_point_on_triangle_from_circle(const circle &c, const triangle &tri); + /** * Returns the center point of the circle. * diff --git a/source/include/graphics_driver.h b/source/include/graphics_driver.h index cfac601..5e2af82 100644 --- a/source/include/graphics_driver.h +++ b/source/include/graphics_driver.h @@ -104,6 +104,7 @@ namespace splashkit_lib sk_window_be *_sk_get_window_with_id(unsigned int window_id); sk_window_be *_sk_get_window_with_pointer(pointer p); + void _sk_destroy_initial_window(); unsigned int _sk_renderer_count(sk_drawing_surface *surface); diff --git a/source/include/input_driver.h b/source/include/input_driver.h index da1382d..e4a325a 100644 --- a/source/include/input_driver.h +++ b/source/include/input_driver.h @@ -59,6 +59,7 @@ namespace splashkit_lib void sk_move_window(sk_drawing_surface *surface, int x, int y); void sk_start_reading_text(window wind, double x, double y, double width, double height, string initial_text); + string sk_end_reading_text(); void sk_mouse_position(double &x, double &y); void sk_mouse_movement(double &x, double &y); diff --git a/source/include/interface.h b/source/include/interface.h index d90ce9e..50f65f6 100644 --- a/source/include/interface.h +++ b/source/include/interface.h @@ -166,17 +166,17 @@ namespace splashkit_lib * The function **must** be accompanied by a call to `end_treenode` * with the same name. * - * @param label The name of the node + * @param label_text The name of the node * @return Whether the tree node is expanded or not */ - bool start_treenode(const string& label); + bool start_treenode(const string& label_text); /** * Finishes the creation of a tree node. * - * @param label The node's name - must match with `start_treenode` + * @param label_text The node's name - must match with `start_treenode` */ - void end_treenode(const string& label); + void end_treenode(const string& label_text); /** * Makes the popup named `name` open/popup at the cursor's position. @@ -281,27 +281,27 @@ namespace splashkit_lib * } * ``` * - * @param label The label to show in the header + * @param label_text The label to show in the header * @return Whether the header is expanded or not */ - bool header(const string& label); + bool header(const string& label_text); /** * Creates a label with the given text. * * @param text The label to show */ - void label(const string& text); + void label_element(const string& text); /** * Creates a label at a specific position on screen. * * @param text The label to show - * @param rect The rectangle to display the label in + * @param rect The rectangle to display the label in * * @attribute suffix at_position */ - void label(const string& text, const rectangle& rect); + void label_element(const string& text, const rectangle& rect); /** * Creates a paragraph of text that auto-wraps. @@ -333,13 +333,13 @@ namespace splashkit_lib * } * ``` * - * @param label The label to show in front of the button + * @param label_text The label to show in front of the button * @param text The text to show inside the button * @return Whether the button was clicked * * @attribute suffix labeled */ - bool button(const string& label, const string& text); + bool button(const string& label_text, const string& text); /** * Creates a button without a label. @@ -366,26 +366,26 @@ namespace splashkit_lib * Creates a button with a bitmap in it and a label. * Returns whether the button was clicked. * - * @param label The label to show in front of the button + * @param label_text The label to show in front of the button * @param bmp The bitmap to show inside the button * @return Whether the button was clicked * * @attribute suffix labeled */ - bool bitmap_button(const string& label, bitmap bmp); + bool bitmap_button(const string& label_text, bitmap bmp); /** * Creates a button with a bitmap in it and a label. * Returns whether the button was clicked. * - * @param label The label to show in front of the button + * @param label_text The label to show in front of the button * @param bmp The bitmap to show inside the button * @param opts The drawing options * @return Whether the button was clicked * * @attribute suffix labeled_with_options */ - bool bitmap_button(const string& label, bitmap bmp, drawing_options opts); + bool bitmap_button(const string& label_text, bitmap bmp, drawing_options opts); /** * Creates a button with a bitmap in it, and no label. @@ -443,14 +443,14 @@ namespace splashkit_lib * my_bool = checkbox("Checkbox 1", "Enabled?", my_bool); * ``` * - * @param label The label to show in front of the checkbox + * @param label_text The label to show in front of the checkbox * @param text The text to show next to the checkbox * @param value The current value of the checkbox * @return The updated value of the checkbox * * @attribute suffix labeled */ - bool checkbox(const string& label, const string& text, const bool& value); + bool checkbox(const string& label_text, const string& text, const bool& value); /** * Creates a checkbox. @@ -484,7 +484,7 @@ namespace splashkit_lib * my_float = slider("Percentage", my_float, 0, 100); * ``` * - * @param label The label to show in front of the slider + * @param label_text The label to show in front of the slider * @param value The current value of the slider * @param min_value The minimum value of the slider * @param max_value The maximum value of the slider @@ -492,7 +492,7 @@ namespace splashkit_lib * * @attribute suffix labeled */ - float slider(const string& label, const float& value, float min_value, float max_value); + float slider(const string& label_text, const float& value, float min_value, float max_value); /** * Creates a slider without a label. @@ -528,13 +528,13 @@ namespace splashkit_lib * my_color = color_slider("Player Color", my_color); * ``` * - * @param label The label to show in front of the slider + * @param label_text The label to show in front of the slider * @param clr The current value of the color slider * @return The updated value of the slider * * @attribute suffix labeled */ - color color_slider(const string& label, const color& clr); + color color_slider(const string& label_text, const color& clr); /** * Creates a set of RGBA sliders to adjust a color. @@ -566,13 +566,13 @@ namespace splashkit_lib * my_color = hsb_color_slider("Player Color", my_color); * ``` * - * @param label The label to show in front of the slider + * @param label_text The label to show in front of the slider * @param clr The current value of the color slider * @return The updated value of the slider * * @attribute suffix labeled */ - color hsb_color_slider(const string& label, const color& clr); + color hsb_color_slider(const string& label_text, const color& clr); /** * Creates a set of HSBA (hue, saturation, brightness, alpha) sliders to adjust a color. @@ -604,14 +604,14 @@ namespace splashkit_lib * my_float = number_box("Percentage", my_float, 1); * ``` * - * @param label The label to show in front of the number box + * @param label_text The label to show in front of the number box * @param value The current value of the number box * @param step The amount incremented when dragging on the box * @return The updated value of the slider * * @attribute suffix labeled */ - float number_box(const string& label, const float& value, float step); + float number_box(const string& label_text, const float& value, float step); /** * Creates a number entry box with a label. @@ -645,13 +645,13 @@ namespace splashkit_lib * my_string = text_box("Name", my_string); * ``` * - * @param label The label to show in front of the text box + * @param label_text The label to show in front of the text box * @param value The current value of the text box * @return The updated value of the text box * * @attribute suffix labeled */ - string text_box(const string& label, const string& value); + string text_box(const string& label_text, const string& value); /** * Creates a text entry box at a specific position on screen. diff --git a/source/include/interface_driver.h b/source/include/interface_driver.h index c334070..f1c1e0d 100644 --- a/source/include/interface_driver.h +++ b/source/include/interface_driver.h @@ -54,11 +54,11 @@ namespace splashkit_lib void sk_interface_push_ptr_id(void* ptr); void sk_interface_pop_id(); - bool sk_interface_header(const string& label); - void sk_interface_label(const string& label); + bool sk_interface_header(const string& label_text); + void sk_interface_label(const string& label_text); void sk_interface_text(const string& text); - bool sk_interface_button(const string& label, int icon); - bool sk_interface_checkbox(const string& label, const bool& value); + bool sk_interface_button(const string& label_text, int icon); + bool sk_interface_checkbox(const string& label_text, const bool& value); float sk_interface_slider(const float& value, float min_value, float max_value); float sk_interface_number(const float& value, float step); std::string sk_interface_text_box(const std::string& value); diff --git a/source/include/logging.h b/source/include/logging.h index 7997cdc..60ebd78 100644 --- a/source/include/logging.h +++ b/source/include/logging.h @@ -66,7 +66,7 @@ namespace splashkit_lib * @param override_prev_log Determines whether or not a new logging session should override the existing file, if any. Set this to false if you want new log messages to be appended to the bottom of the file; otherwise set it to true if you would like a new file to be created on top of the old one. * @param mode The mode of log output i.e. whether there should be output to the console, a text file, or both. Pass your choice of mode variable in by reference. * - * @attribute suffix _name_override_mode + * @attribute suffix name_override_mode */ void init_custom_logger (string app_name, bool override_prev_log, log_mode mode); diff --git a/source/include/music.h b/source/include/music.h index bc99b5d..a51051b 100644 --- a/source/include/music.h +++ b/source/include/music.h @@ -103,7 +103,7 @@ namespace splashkit_lib * * @attribute suffix with_times_and_volume */ - void play_music(music data, int times, float volume); + void play_music(music data, int times, double volume); /** * Plays a music file once at full volume. @@ -251,7 +251,7 @@ namespace splashkit_lib * @attribute static music * @attribute setter volume */ - void set_music_volume(float volume); + void set_music_volume(double volume); /** * Returns the volume of the currently playing `music`. @@ -261,7 +261,7 @@ namespace splashkit_lib * @attribute static music * @attribute getter volume */ - float music_volume(); + double music_volume(); /** * Returns the name that SplashKit uses to refer to this music data diff --git a/source/include/sk_clib.h b/source/include/sk_clib.h index 19443da..a03baf9 100644 --- a/source/include/sk_clib.h +++ b/source/include/sk_clib.h @@ -274,6 +274,8 @@ __sklib_point_2d __sklib__center_point__circle_ref(const __sklib_circle c); __sklib_circle __sklib__circle_at__point_2d_ref__double(const __sklib_point_2d pt, double radius); __sklib_circle __sklib__circle_at__double__double__double(double x, double y, double radius); float __sklib__circle_radius__circle(const __sklib_circle c); +int __sklib__circle_triangle_intersect__circle_ref__triangle_ref(const __sklib_circle c, const __sklib_triangle tri); +int __sklib__circle_triangle_intersect__circle_ref__triangle_ref__point_2d_ref(const __sklib_circle c, const __sklib_triangle tri, __sklib_point_2d *p); float __sklib__circle_x__circle_ref(const __sklib_circle c); float __sklib__circle_y__circle_ref(const __sklib_circle c); int __sklib__circles_intersect__circle__circle(__sklib_circle c1, __sklib_circle c2); @@ -281,6 +283,7 @@ int __sklib__circles_intersect__double__double__double__double__double__double(d __sklib_point_2d __sklib__closest_point_on_circle__point_2d_ref__circle_ref(const __sklib_point_2d from_pt, const __sklib_circle c); __sklib_point_2d __sklib__closest_point_on_line_from_circle__circle_ref__line_ref(const __sklib_circle c, const __sklib_line l); __sklib_point_2d __sklib__closest_point_on_rect_from_circle__circle_ref__rectangle_ref(const __sklib_circle c, const __sklib_rectangle rect); +__sklib_point_2d __sklib__closest_point_on_triangle_from_circle__circle_ref__triangle_ref(const __sklib_circle c, const __sklib_triangle tri); __sklib_point_2d __sklib__distant_point_on_circle__point_2d_ref__circle_ref(const __sklib_point_2d pt, const __sklib_circle c); int __sklib__distant_point_on_circle_heading__point_2d_ref__circle_ref__vector_2d_ref__point_2d_ref(const __sklib_point_2d pt, const __sklib_circle c, const __sklib_vector_2d heading, __sklib_point_2d *opposite_pt); float __sklib__ray_circle_intersect_distance__point_2d_ref__vector_2d_ref__circle_ref(const __sklib_point_2d ray_origin, const __sklib_vector_2d ray_heading, const __sklib_circle c); @@ -616,40 +619,40 @@ int __sklib__bitmap_button__bitmap(__sklib_bitmap bmp); int __sklib__bitmap_button__bitmap__rectangle_ref(__sklib_bitmap bmp, const __sklib_rectangle rect); int __sklib__bitmap_button__bitmap__rectangle_ref__drawing_options(__sklib_bitmap bmp, const __sklib_rectangle rect, __sklib_drawing_options opts); int __sklib__bitmap_button__bitmap__drawing_options(__sklib_bitmap bmp, __sklib_drawing_options opts); -int __sklib__bitmap_button__string_ref__bitmap(const __sklib_string label, __sklib_bitmap bmp); -int __sklib__bitmap_button__string_ref__bitmap__drawing_options(const __sklib_string label, __sklib_bitmap bmp, __sklib_drawing_options opts); +int __sklib__bitmap_button__string_ref__bitmap(const __sklib_string label_text, __sklib_bitmap bmp); +int __sklib__bitmap_button__string_ref__bitmap__drawing_options(const __sklib_string label_text, __sklib_bitmap bmp, __sklib_drawing_options opts); int __sklib__button__string_ref__rectangle_ref(const __sklib_string text, const __sklib_rectangle rect); int __sklib__button__string_ref(const __sklib_string text); -int __sklib__button__string_ref__string_ref(const __sklib_string label, const __sklib_string text); +int __sklib__button__string_ref__string_ref(const __sklib_string label_text, const __sklib_string text); int __sklib__checkbox__string_ref__bool_ref__rectangle_ref(const __sklib_string text, const int value, const __sklib_rectangle rect); int __sklib__checkbox__string_ref__bool_ref(const __sklib_string text, const int value); -int __sklib__checkbox__string_ref__string_ref__bool_ref(const __sklib_string label, const __sklib_string text, const int value); +int __sklib__checkbox__string_ref__string_ref__bool_ref(const __sklib_string label_text, const __sklib_string text, const int value); __sklib_color __sklib__color_slider__color_ref__rectangle_ref(const __sklib_color clr, const __sklib_rectangle rect); __sklib_color __sklib__color_slider__color_ref(const __sklib_color clr); -__sklib_color __sklib__color_slider__string_ref__color_ref(const __sklib_string label, const __sklib_color clr); +__sklib_color __sklib__color_slider__string_ref__color_ref(const __sklib_string label_text, const __sklib_color clr); void __sklib__disable_interface(); void __sklib__draw_interface(); void __sklib__enable_interface(); void __sklib__end_inset__string_ref(const __sklib_string name); void __sklib__end_panel__string_ref(const __sklib_string name); void __sklib__end_popup__string_ref(const __sklib_string name); -void __sklib__end_treenode__string_ref(const __sklib_string label); +void __sklib__end_treenode__string_ref(const __sklib_string label_text); void __sklib__enter_column(); int __sklib__get_interface_label_width(); -int __sklib__header__string_ref(const __sklib_string label); +int __sklib__header__string_ref(const __sklib_string label_text); __sklib_color __sklib__hsb_color_slider__color_ref__rectangle_ref(const __sklib_color clr, const __sklib_rectangle rect); __sklib_color __sklib__hsb_color_slider__color_ref(const __sklib_color clr); -__sklib_color __sklib__hsb_color_slider__string_ref__color_ref(const __sklib_string label, const __sklib_color clr); +__sklib_color __sklib__hsb_color_slider__string_ref__color_ref(const __sklib_string label_text, const __sklib_color clr); int __sklib__interface_enabled(); void __sklib__interface_style_panel__rectangle_ref(const __sklib_rectangle initial_rectangle); -void __sklib__label__string_ref(const __sklib_string text); -void __sklib__label__string_ref__rectangle_ref(const __sklib_string text, const __sklib_rectangle rect); +void __sklib__label_element__string_ref(const __sklib_string text); +void __sklib__label_element__string_ref__rectangle_ref(const __sklib_string text, const __sklib_rectangle rect); int __sklib__last_element_changed(); int __sklib__last_element_confirmed(); void __sklib__leave_column(); float __sklib__number_box__float_ref__float__rectangle_ref(const float value, float step, const __sklib_rectangle rect); float __sklib__number_box__float_ref__float(const float value, float step); -float __sklib__number_box__string_ref__float_ref__float(const __sklib_string label, const float value, float step); +float __sklib__number_box__string_ref__float_ref__float(const __sklib_string label_text, const float value, float step); void __sklib__open_popup__string_ref(const __sklib_string name); void __sklib__paragraph__string_ref(const __sklib_string text); void __sklib__paragraph__string_ref__rectangle_ref(const __sklib_string text, const __sklib_rectangle rect); @@ -674,7 +677,7 @@ void __sklib__set_layout_height__int(int height); void __sklib__single_line_layout(); float __sklib__slider__float_ref__float__float__rectangle_ref(const float value, float min_value, float max_value, const __sklib_rectangle rect); float __sklib__slider__float_ref__float__float(const float value, float min_value, float max_value); -float __sklib__slider__string_ref__float_ref__float__float(const __sklib_string label, const float value, float min_value, float max_value); +float __sklib__slider__string_ref__float_ref__float__float(const __sklib_string label_text, const float value, float min_value, float max_value); void __sklib__split_into_columns__int(int count); void __sklib__split_into_columns__int__int(int count, int last_width); void __sklib__split_into_columns_relative__int__double(int count, double last_width); @@ -683,10 +686,10 @@ void __sklib__start_inset__string_ref__rectangle_ref(const __sklib_string name, void __sklib__start_inset__string_ref__int(const __sklib_string name, int height); int __sklib__start_panel__string_ref__rectangle(const __sklib_string name, __sklib_rectangle initial_rectangle); int __sklib__start_popup__string_ref(const __sklib_string name); -int __sklib__start_treenode__string_ref(const __sklib_string label); +int __sklib__start_treenode__string_ref(const __sklib_string label_text); __sklib_string __sklib__text_box__string_ref(const __sklib_string value); __sklib_string __sklib__text_box__string_ref__rectangle_ref(const __sklib_string value, const __sklib_rectangle rect); -__sklib_string __sklib__text_box__string_ref__string_ref(const __sklib_string label, const __sklib_string value); +__sklib_string __sklib__text_box__string_ref__string_ref(const __sklib_string label_text, const __sklib_string value); __sklib_json __sklib__create_json(); __sklib_json __sklib__create_json__string(__sklib_string json_string); void __sklib__free_all_json(); @@ -816,15 +819,15 @@ __sklib_string __sklib__music_name__music(__sklib_music data); __sklib_music __sklib__music_named__string_ref(const __sklib_string name); int __sklib__music_playing(); int __sklib__music_valid__music(__sklib_music m); -float __sklib__music_volume(); +double __sklib__music_volume(); void __sklib__pause_music(); void __sklib__play_music__string_ref(const __sklib_string name); void __sklib__play_music__string_ref__int(const __sklib_string name, int times); void __sklib__play_music__music(__sklib_music data); void __sklib__play_music__music__int(__sklib_music data, int times); -void __sklib__play_music__music__int__float(__sklib_music data, int times, float volume); +void __sklib__play_music__music__int__double(__sklib_music data, int times, double volume); void __sklib__resume_music(); -void __sklib__set_music_volume__float(float volume); +void __sklib__set_music_volume__double(double volume); void __sklib__stop_music(); int __sklib__accept_all_new_connections(); int __sklib__accept_new_connection__server_socket(__sklib_server_socket server); @@ -1030,13 +1033,13 @@ void __sklib__free_sound_effect__sound_effect(__sklib_sound_effect effect); int __sklib__has_sound_effect__string_ref(const __sklib_string name); __sklib_sound_effect __sklib__load_sound_effect__string_ref__string_ref(const __sklib_string name, const __sklib_string filename); void __sklib__play_sound_effect__string_ref(const __sklib_string name); -void __sklib__play_sound_effect__string_ref__float(const __sklib_string name, float volume); +void __sklib__play_sound_effect__string_ref__double(const __sklib_string name, double volume); void __sklib__play_sound_effect__string_ref__int(const __sklib_string name, int times); -void __sklib__play_sound_effect__string_ref__int__float(const __sklib_string name, int times, float volume); +void __sklib__play_sound_effect__string_ref__int__double(const __sklib_string name, int times, double volume); void __sklib__play_sound_effect__sound_effect(__sklib_sound_effect effect); -void __sklib__play_sound_effect__sound_effect__float(__sklib_sound_effect effect, float volume); +void __sklib__play_sound_effect__sound_effect__double(__sklib_sound_effect effect, double volume); void __sklib__play_sound_effect__sound_effect__int(__sklib_sound_effect effect, int times); -void __sklib__play_sound_effect__sound_effect__int__float(__sklib_sound_effect effect, int times, float volume); +void __sklib__play_sound_effect__sound_effect__int__double(__sklib_sound_effect effect, int times, double volume); __sklib_string __sklib__sound_effect_filename__sound_effect(__sklib_sound_effect effect); __sklib_string __sklib__sound_effect_name__sound_effect(__sklib_sound_effect effect); __sklib_sound_effect __sklib__sound_effect_named__string_ref(const __sklib_string name); @@ -1313,7 +1316,7 @@ int __sklib__vector_in_rect__vector_2d_ref__rectangle_ref(const __sklib_vector_2 __sklib_vector_2d __sklib__vector_invert__vector_2d_ref(const __sklib_vector_2d v); __sklib_vector_2d __sklib__vector_limit__vector_2d_ref__double(const __sklib_vector_2d v, double limit); double __sklib__vector_magnitude__vector_2d_ref(const __sklib_vector_2d v); -double __sklib__vector_magnitude_sqared__vector_2d_ref(const __sklib_vector_2d v); +double __sklib__vector_magnitude_squared__vector_2d_ref(const __sklib_vector_2d v); __sklib_vector_2d __sklib__vector_multiply__vector_2d_ref__double(const __sklib_vector_2d v1, double s); __sklib_vector_2d __sklib__vector_normal__vector_2d_ref(const __sklib_vector_2d v); __sklib_vector_2d __sklib__vector_out_of_circle_from_circle__circle_ref__circle_ref__vector_2d_ref(const __sklib_circle src, const __sklib_circle bounds, const __sklib_vector_2d velocity); diff --git a/source/include/sound.h b/source/include/sound.h index 23e72e1..a9f33da 100644 --- a/source/include/sound.h +++ b/source/include/sound.h @@ -177,7 +177,7 @@ namespace splashkit_lib * @attribute suffix with_times_and_volume * @attribute self effect */ - void play_sound_effect(sound_effect effect, int times, float volume); + void play_sound_effect(sound_effect effect, int times, double volume); /** * Plays a sound effect once at full volume. @@ -217,7 +217,7 @@ namespace splashkit_lib * * @attribute suffix with_volume */ - void play_sound_effect(sound_effect effect, float volume); + void play_sound_effect(sound_effect effect, double volume); /** * Plays a sound effect for a specified number of times and playback volume. @@ -229,7 +229,7 @@ namespace splashkit_lib * * @attribute suffix named_with_times_and_volume */ - void play_sound_effect(const string &name, int times, float volume); + void play_sound_effect(const string &name, int times, double volume); /** * Plays a sound effect for a specified number of times at full volume. @@ -258,7 +258,7 @@ namespace splashkit_lib * * @attribute suffix named_with_volume */ - void play_sound_effect(const string &name, float volume); + void play_sound_effect(const string &name, double volume); /** * Stops the `sound_effect` if it is currently playing diff --git a/source/include/timers.h b/source/include/timers.h index f4d1945..c4233b1 100644 --- a/source/include/timers.h +++ b/source/include/timers.h @@ -65,7 +65,7 @@ namespace splashkit_lib * @param name The name of the timer * @return True if SplashKit has created a timer with that name. * - * @attribute suffix _named + * @attribute suffix named */ bool has_timer(string name); @@ -88,7 +88,7 @@ namespace splashkit_lib * * @param name The name of the timer * - * @attribute suffix _named + * @attribute suffix named */ void start_timer(string name); @@ -109,7 +109,7 @@ namespace splashkit_lib * * @param name The name of the timer * - * @attribute suffix _named + * @attribute suffix named */ void stop_timer(string name); @@ -130,7 +130,7 @@ namespace splashkit_lib * * @param name The name of the timer * - * @attribute suffix _named + * @attribute suffix named */ void pause_timer(string name); @@ -149,7 +149,7 @@ namespace splashkit_lib * * @param name The name of the timer * - * @attribute suffix _named + * @attribute suffix named */ void resume_timer(string name); @@ -168,7 +168,7 @@ namespace splashkit_lib * * @param name The name of the timer * - * @attribute suffix _named + * @attribute suffix named */ void reset_timer(string name); @@ -197,7 +197,7 @@ namespace splashkit_lib * timer was created (excluding the time the timer was * paused) * - * @attribute suffix _named + * @attribute suffix named */ unsigned int timer_ticks(string name); @@ -218,7 +218,7 @@ namespace splashkit_lib * @param name The name of the timer * @return True if the timer is paused * - * @attribute suffix _named + * @attribute suffix named */ bool timer_paused(string name); @@ -239,7 +239,7 @@ namespace splashkit_lib * @param name The name of the timer * @return True if the timer has been started * - * @attribute suffix _named + * @attribute suffix named */ bool timer_started(string name); } diff --git a/source/include/triangle_geometry.h b/source/include/triangle_geometry.h index 51abd9e..08fb739 100644 --- a/source/include/triangle_geometry.h +++ b/source/include/triangle_geometry.h @@ -23,7 +23,7 @@ namespace splashkit_lib * @param y3 The y coordinate for the third point * @return A triangle at the indicated points * - * @attribute suffix _from_coordinates + * @attribute suffix from_coordinates */ triangle triangle_from(double x1, double y1, double x2, double y2, double x3, double y3); diff --git a/source/include/utility_functions.h b/source/include/utility_functions.h index e0760f5..6ae0f11 100644 --- a/source/include/utility_functions.h +++ b/source/include/utility_functions.h @@ -94,8 +94,7 @@ namespace splashkit_lib } #define FREE_ALL_FROM_MAP(collection, ptr_kind, fn )\ -size_t sz = collection.size();\ -for(size_t i = 0; i < sz; i++)\ +while(!collection.empty())\ {\ auto resource = collection.begin()->second;\ if (VALID_PTR(resource, ptr_kind))\ @@ -104,7 +103,7 @@ fn(resource);\ }\ else\ {\ -LOG(WARNING) << "Splashkit contains invalid ##ptr_kind !";\ +LOG(WARNING) << "Splashkit contains invalid " #ptr_kind "!";\ collection.erase(collection.begin());\ }\ } diff --git a/source/include/vector_2d.h b/source/include/vector_2d.h index 37ae13d..57f82f5 100644 --- a/source/include/vector_2d.h +++ b/source/include/vector_2d.h @@ -166,7 +166,7 @@ namespace splashkit_lib * @param v The vector * @return Its squared magnitude */ - double vector_magnitude_sqared(const vector_2d &v); + double vector_magnitude_squared(const vector_2d &v); /** * Returns the magnitude (or "length") of the vector. diff --git a/source/interface.cpp b/source/interface.cpp index 270086c..e1c08a7 100644 --- a/source/interface.cpp +++ b/source/interface.cpp @@ -730,16 +730,16 @@ namespace splashkit_lib _pop_container_stack(panel_type::column, ""); } - bool header(const string& label) + bool header(const string& label_text) { _interface_sanity_check(); - bool open = sk_interface_header(label); + bool open = sk_interface_header(label_text); return open; } - void label(const string& text) + void label_element(const string& text) { _interface_sanity_check(); @@ -748,13 +748,13 @@ namespace splashkit_lib _update_text_style(); } - void label(const string& text, const rectangle& rect) + void label_element(const string& text, const rectangle& rect) { _interface_sanity_check(); sk_interface_set_layout_next(rect, true); - label(text); + label_element(text); } void paragraph(const string& text, const rectangle& rect) @@ -774,14 +774,14 @@ namespace splashkit_lib _update_text_style(); } - bool button(const string& label, const string& text) + bool button(const string& label_text, const string& text) { _interface_sanity_check(); enter_column(); _two_column_layout(); - splashkit_lib::label(label); + splashkit_lib::label_element(label_text); bool res = button(text); leave_column(); @@ -889,14 +889,14 @@ namespace splashkit_lib return bitmap_button(bmp, option_defaults()); } - bool bitmap_button(const string& label, bitmap bmp, drawing_options opts) + bool bitmap_button(const string& label_text, bitmap bmp, drawing_options opts) { _interface_sanity_check(); enter_column(); _two_column_layout(); - splashkit_lib::label(label); + splashkit_lib::label_element(label_text); bool res = _bitmap_button_internal(bmp, nullptr, opts); @@ -905,9 +905,9 @@ namespace splashkit_lib return res; } - bool bitmap_button(const string& label, bitmap bmp) + bool bitmap_button(const string& label_text, bitmap bmp) { - return bitmap_button(label, bmp, option_defaults()); + return bitmap_button(label_text, bmp, option_defaults()); } bool bitmap_button(bitmap bmp, const rectangle& rect, drawing_options opts) @@ -920,14 +920,14 @@ namespace splashkit_lib return bitmap_button(bmp, rect, option_defaults()); } - bool checkbox(const string& label, const string& text, const bool& value) + bool checkbox(const string& label_text, const string& text, const bool& value) { _interface_sanity_check(); enter_column(); _two_column_layout(); - splashkit_lib::label(label); + splashkit_lib::label_element(label_text); bool res = checkbox(text, value); leave_column(); @@ -954,14 +954,14 @@ namespace splashkit_lib return checkbox(text, value); } - float slider(const string& label, const float& value, float min_value, float max_value) + float slider(const string& label_text, const float& value, float min_value, float max_value) { _interface_sanity_check(); enter_column(); _two_column_layout(); - splashkit_lib::label(label); + splashkit_lib::label_element(label_text); float res = slider(value, min_value, max_value); leave_column(); @@ -1046,14 +1046,14 @@ namespace splashkit_lib return temp_value; } - color color_slider(const string& label, const color& clr) + color color_slider(const string& label_text, const color& clr) { _interface_sanity_check(); enter_column(); _two_column_layout(); - splashkit_lib::label(label); + splashkit_lib::label_element(label_text); color res = color_slider(clr); leave_column(); @@ -1074,14 +1074,14 @@ namespace splashkit_lib return _color_slider(clr, false); } - color hsb_color_slider(const string& label, const color& clr) + color hsb_color_slider(const string& label_text, const color& clr) { _interface_sanity_check(); enter_column(); _two_column_layout(); - splashkit_lib::label(label); + splashkit_lib::label_element(label_text); color res = hsb_color_slider(clr); leave_column(); @@ -1102,14 +1102,14 @@ namespace splashkit_lib return _color_slider(clr, true); } - float number_box(const string& label, const float& value, float step) + float number_box(const string& label_text, const float& value, float step) { _interface_sanity_check(); enter_column(); _two_column_layout(); - splashkit_lib::label(label); + splashkit_lib::label_element(label_text); float res = number_box(value, step); leave_column(); @@ -1132,14 +1132,14 @@ namespace splashkit_lib return number_box(value, step); } - std::string text_box(const string& label, const std::string& value) + std::string text_box(const string& label_text, const std::string& value) { _interface_sanity_check(); enter_column(); _two_column_layout(); - splashkit_lib::label(label); + splashkit_lib::label_element(label_text); std::string res = text_box(value); leave_column(); diff --git a/source/interface_driver.cpp b/source/interface_driver.cpp index 2fa9762..bafcb06 100644 --- a/source/interface_driver.cpp +++ b/source/interface_driver.cpp @@ -1,290 +1,290 @@ -// interface_driver.cpp -// This file is part of the SplashKit Core Library. -// Copyright (©) 2024 Sean Boettger. All Rights Reserved. - -#include "interface_driver.h" -#include "input_driver.h" -#include "graphics_driver.h" -#include "text_driver.h" -#include "utility_functions.h" -#include "text.h" - -#include -#include -#include -#include - -using namespace std; - -extern "C" { -#include "microui.h" -} - -namespace splashkit_lib -{ - #include "interface_driver_atlas.h" - - static mu_Context *ctx = nullptr; - bool ctx_started = false; - - static mu_Id focused_text_box = 0; - - static bool element_changed = false; - static bool element_confirmed = false; - - static char button_map[256]; - static char key_map[256]; - - void _initialize_button_and_key_map() - { - button_map[ SDL_BUTTON_LEFT & 0xff ] = MU_MOUSE_LEFT; - button_map[ SDL_BUTTON_RIGHT & 0xff ] = MU_MOUSE_RIGHT; - button_map[ SDL_BUTTON_MIDDLE & 0xff ] = MU_MOUSE_MIDDLE; - - key_map[ SDLK_LSHIFT & 0xff ] = MU_KEY_SHIFT; - key_map[ SDLK_RSHIFT & 0xff ] = MU_KEY_SHIFT; - key_map[ SDLK_LCTRL & 0xff ] = MU_KEY_CTRL; - key_map[ SDLK_RCTRL & 0xff ] = MU_KEY_CTRL; - key_map[ SDLK_LALT & 0xff ] = MU_KEY_ALT; - key_map[ SDLK_RALT & 0xff ] = MU_KEY_ALT; - key_map[ SDLK_RETURN & 0xff ] = MU_KEY_RETURN; - key_map[ SDLK_BACKSPACE & 0xff ] = MU_KEY_BACKSPACE; - } - - // Style cache - - static mu_Style default_style; - - struct shadow_style - { - color clr; - int radius; - point_2d offset; - }; - - static shadow_style panel_shadow_style; - static shadow_style element_shadow_style; - - // Font handling - static font current_font = nullptr; - static int current_font_size = 13; - - // Store font/size pairs inside a set. - // - // Iterators stay valid while inserting, - // so this is used as a stable place to - // store these pairs, which can then be assigned - // to MicroUI's font void* and used later on - typedef std::pair font_size_pair; - static std::set fonts_this_frame; - - // Adds a pair to the set and returns a void* to it - void* _add_font_size_pair(font fnt, int size) - { - return (void*)&*fonts_this_frame.insert({fnt, size}).first; - } - - // Returns the font/size pair from a pointer - font_size_pair* _get_font_size_pair(void* ptr) - { - return (font_size_pair*)ptr; - } - - int _text_width(mu_Font font, const char *text, int len) - { - if (len == -1) { len = strlen(text); } - - font_size_pair* font_info = _get_font_size_pair(font); - - if (!font_info || !font_info->first) return 8 * len; - - int w,h; - sk_text_size(font_info->first, font_info->second, std::string(text, len), &w, &h); - return w; - } - - int _text_height(mu_Font font) - { - font_size_pair* font_info = _get_font_size_pair(font); - - if (!font_info || !font_info->first) return 8; - - return sk_text_height(font_info->first, font_info->second); - } - - // Icon Handling - // MicroUI only allows us to pass an int (not even a void*!) for the icon, so we store - // all the bitmap data in a vector that can be referenced using that int. - struct registered_icon - { - sk_drawing_surface* src; - double src_data[4]; - double dst_data[7]; - sk_renderer_flip flip; - }; - - std::vector registered_icons_this_frame; - - // returns registered icon's index, with +MU_ICON_MAX offset - int sk_interface_register_icon(sk_drawing_surface* src, const double (&src_data)[4], const double (&dst_data)[7], sk_renderer_flip flip) - { - registered_icons_this_frame.push_back({ - src, - {src_data[0],src_data[1],src_data[2],src_data[3]}, - {dst_data[0],dst_data[1],dst_data[2],dst_data[3],dst_data[4],dst_data[5],dst_data[6]}, - flip - }); - - return registered_icons_this_frame.size()-1 + MU_ICON_MAX; - } - - registered_icon* _get_registered_icon(int icon) - { - icon -= MU_ICON_MAX; - - if (icon < 0 || icon > registered_icons_this_frame.size()) - return nullptr; - - return ®istered_icons_this_frame[icon]; - } - - - // conversion util functions - mu_Rect to_mu(rectangle rect) - { - return {(int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height}; - } - - mu_Color to_mu(color col) - { - return { - (unsigned char)(col.r * 255), - (unsigned char)(col.g * 255), - (unsigned char)(col.b * 255), - (unsigned char)(col.a * 255) - }; - } - - rectangle from_mu(mu_Rect rect) - { - return {(double)rect.x, (double)rect.y, (double)rect.w, (double)rect.h}; - } - - color from_mu(mu_Color col) - { - return {col.r / 255.0f, col.g / 255.0f, col.b / 255.0f, col.a / 255.0f}; - } - - // static utility functions straight from microui.c - used for consistency - static mu_Rect expand_rect(mu_Rect rect, int n) { - return mu_rect(rect.x - n, rect.y - n, rect.w + n * 2, rect.h + n * 2); - } - static mu_Rect intersect_rects(mu_Rect r1, mu_Rect r2) { - int x1 = mu_max(r1.x, r2.x); - int y1 = mu_max(r1.y, r2.y); - int x2 = mu_min(r1.x + r1.w, r2.x + r2.w); - int y2 = mu_min(r1.y + r1.h, r2.y + r2.h); - if (x2 < x1) { x2 = x1; } - if (y2 < y1) { y2 = y1; } - return mu_rect(x1, y1, x2 - x1, y2 - y1); - } - static mu_Rect unclipped_rect = { 0, 0, 0x1000000, 0x1000000 }; - - // custom microui commands - #define MU_COMMAND_BLUR_RECT (MU_COMMAND_MAX+1) - - typedef struct { mu_BaseCommand base; mu_Rect rect; mu_Color color; int radius;} mu_BlurredRectCommand; - - - // custom drawning commands - void draw_blurred_rect(mu_Context *ctx, mu_Rect rect, mu_Color color, int blur_radius){ - rect = intersect_rects(rect, expand_rect(mu_get_clip_rect(ctx), blur_radius)); - - if (rect.w > 0 && rect.h > 0) { - int clipped = mu_check_clip(ctx, rect); - if (clipped) { mu_set_clip(ctx, mu_get_clip_rect(ctx)); } - - mu_BlurredRectCommand* cmd = (mu_BlurredRectCommand*)mu_push_command(ctx, MU_COMMAND_BLUR_RECT, sizeof(mu_BlurredRectCommand)); - cmd->rect = rect; - cmd->color = color; - cmd->radius = blur_radius; - - if (clipped) { mu_set_clip(ctx, unclipped_rect); } - } - } - - static void draw_frame(mu_Context *ctx, mu_Rect rect, int colorid) { - shadow_style& shadow = colorid==MU_COLOR_WINDOWBG?panel_shadow_style:element_shadow_style; - - // draw shadow if the right element type - if (shadow.clr.a>0.f && ( - colorid == MU_COLOR_WINDOWBG || - colorid == MU_COLOR_SCROLLTHUMB || - colorid == MU_COLOR_BUTTON || - colorid == MU_COLOR_BUTTONHOVER || - colorid == MU_COLOR_BUTTONFOCUS || - colorid == MU_COLOR_BASE || - colorid == MU_COLOR_BASEHOVER || - colorid == MU_COLOR_BASEFOCUS - )){ - mu_Rect shadow_rect = rect; - shadow_rect.x += shadow.offset.x; - shadow_rect.y += shadow.offset.y; - draw_blurred_rect(ctx, shadow_rect, to_mu(shadow.clr), shadow.radius); - } - - // draw main frame - if (ctx->style->colors[colorid].a) - mu_draw_rect(ctx, rect, ctx->style->colors[colorid]); - - if (colorid == MU_COLOR_SCROLLBASE || - colorid == MU_COLOR_TITLEBG) { return; } - - // draw border - if (ctx->style->colors[MU_COLOR_BORDER].a) - mu_draw_box(ctx, expand_rect(rect, 1), ctx->style->colors[MU_COLOR_BORDER]); - } - - // Delay loading of the ui atlas until it's actually needed - // otherwise we'll trigger creating the 'initial window' unnecessarily - sk_drawing_surface* get_ui_atlas() - { - static sk_drawing_surface ui_atlas; - static bool ui_atlas_loaded = false; - - if (!ui_atlas_loaded) - { - ui_atlas = sk_create_bitmap(ATLAS_WIDTH, ATLAS_HEIGHT); - - // Fill the bitmap with values from atlas_texture - for(int y = 0; y < ATLAS_HEIGHT; y++) - for(int x = 0; x < ATLAS_WIDTH; x++) - sk_set_bitmap_pixel(&ui_atlas, {1.f, 1.f, 1.f, atlas_texture[y * ATLAS_WIDTH + x]/255.f}, x, y); - - sk_refresh_bitmap(&ui_atlas); - ui_atlas_loaded = true; - } - - return &ui_atlas; - } - - static void(*style_init_callback)() = nullptr; - void sk_interface_init() - { - _initialize_button_and_key_map(); - _initialize_atlas_map(); - - ctx = (mu_Context*)malloc(sizeof(mu_Context)); - mu_init(ctx); - ctx->text_width = _text_width; - ctx->text_height = _text_height; - ctx->draw_frame = &draw_frame; - - default_style = *ctx->style; - sk_interface_style_reset(); - - if (style_init_callback) - style_init_callback(); +// interface_driver.cpp +// This file is part of the SplashKit Core Library. +// Copyright (©) 2024 Sean Boettger. All Rights Reserved. + +#include "interface_driver.h" +#include "input_driver.h" +#include "graphics_driver.h" +#include "text_driver.h" +#include "utility_functions.h" +#include "text.h" + +#include +#include +#include +#include + +using namespace std; + +extern "C" { +#include "microui.h" +} + +namespace splashkit_lib +{ + #include "interface_driver_atlas.h" + + static mu_Context *ctx = nullptr; + bool ctx_started = false; + + static mu_Id focused_text_box = 0; + + static bool element_changed = false; + static bool element_confirmed = false; + + static char button_map[256]; + static char key_map[256]; + + void _initialize_button_and_key_map() + { + button_map[ SDL_BUTTON_LEFT & 0xff ] = MU_MOUSE_LEFT; + button_map[ SDL_BUTTON_RIGHT & 0xff ] = MU_MOUSE_RIGHT; + button_map[ SDL_BUTTON_MIDDLE & 0xff ] = MU_MOUSE_MIDDLE; + + key_map[ SDLK_LSHIFT & 0xff ] = MU_KEY_SHIFT; + key_map[ SDLK_RSHIFT & 0xff ] = MU_KEY_SHIFT; + key_map[ SDLK_LCTRL & 0xff ] = MU_KEY_CTRL; + key_map[ SDLK_RCTRL & 0xff ] = MU_KEY_CTRL; + key_map[ SDLK_LALT & 0xff ] = MU_KEY_ALT; + key_map[ SDLK_RALT & 0xff ] = MU_KEY_ALT; + key_map[ SDLK_RETURN & 0xff ] = MU_KEY_RETURN; + key_map[ SDLK_BACKSPACE & 0xff ] = MU_KEY_BACKSPACE; + } + + // Style cache + + static mu_Style default_style; + + struct shadow_style + { + color clr; + int radius; + point_2d offset; + }; + + static shadow_style panel_shadow_style; + static shadow_style element_shadow_style; + + // Font handling + static font current_font = nullptr; + static int current_font_size = 13; + + // Store font/size pairs inside a set. + // + // Iterators stay valid while inserting, + // so this is used as a stable place to + // store these pairs, which can then be assigned + // to MicroUI's font void* and used later on + typedef std::pair font_size_pair; + static std::set fonts_this_frame; + + // Adds a pair to the set and returns a void* to it + void* _add_font_size_pair(font fnt, int size) + { + return (void*)&*fonts_this_frame.insert({fnt, size}).first; + } + + // Returns the font/size pair from a pointer + font_size_pair* _get_font_size_pair(void* ptr) + { + return (font_size_pair*)ptr; + } + + int _text_width(mu_Font font, const char *text, int len) + { + if (len == -1) { len = strlen(text); } + + font_size_pair* font_info = _get_font_size_pair(font); + + if (!font_info || !font_info->first) return 8 * len; + + int w,h; + sk_text_size(font_info->first, font_info->second, std::string(text, len), &w, &h); + return w; + } + + int _text_height(mu_Font font) + { + font_size_pair* font_info = _get_font_size_pair(font); + + if (!font_info || !font_info->first) return 8; + + return sk_text_height(font_info->first, font_info->second); + } + + // Icon Handling + // MicroUI only allows us to pass an int (not even a void*!) for the icon, so we store + // all the bitmap data in a vector that can be referenced using that int. + struct registered_icon + { + sk_drawing_surface* src; + double src_data[4]; + double dst_data[7]; + sk_renderer_flip flip; + }; + + std::vector registered_icons_this_frame; + + // returns registered icon's index, with +MU_ICON_MAX offset + int sk_interface_register_icon(sk_drawing_surface* src, const double (&src_data)[4], const double (&dst_data)[7], sk_renderer_flip flip) + { + registered_icons_this_frame.push_back({ + src, + {src_data[0],src_data[1],src_data[2],src_data[3]}, + {dst_data[0],dst_data[1],dst_data[2],dst_data[3],dst_data[4],dst_data[5],dst_data[6]}, + flip + }); + + return registered_icons_this_frame.size()-1 + MU_ICON_MAX; + } + + registered_icon* _get_registered_icon(int icon) + { + icon -= MU_ICON_MAX; + + if (icon < 0 || icon > registered_icons_this_frame.size()) + return nullptr; + + return ®istered_icons_this_frame[icon]; + } + + + // conversion util functions + mu_Rect to_mu(rectangle rect) + { + return {(int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height}; + } + + mu_Color to_mu(color col) + { + return { + (unsigned char)(col.r * 255), + (unsigned char)(col.g * 255), + (unsigned char)(col.b * 255), + (unsigned char)(col.a * 255) + }; + } + + rectangle from_mu(mu_Rect rect) + { + return {(double)rect.x, (double)rect.y, (double)rect.w, (double)rect.h}; + } + + color from_mu(mu_Color col) + { + return {col.r / 255.0f, col.g / 255.0f, col.b / 255.0f, col.a / 255.0f}; + } + + // static utility functions straight from microui.c - used for consistency + static mu_Rect expand_rect(mu_Rect rect, int n) { + return mu_rect(rect.x - n, rect.y - n, rect.w + n * 2, rect.h + n * 2); + } + static mu_Rect intersect_rects(mu_Rect r1, mu_Rect r2) { + int x1 = mu_max(r1.x, r2.x); + int y1 = mu_max(r1.y, r2.y); + int x2 = mu_min(r1.x + r1.w, r2.x + r2.w); + int y2 = mu_min(r1.y + r1.h, r2.y + r2.h); + if (x2 < x1) { x2 = x1; } + if (y2 < y1) { y2 = y1; } + return mu_rect(x1, y1, x2 - x1, y2 - y1); + } + static mu_Rect unclipped_rect = { 0, 0, 0x1000000, 0x1000000 }; + + // custom microui commands + #define MU_COMMAND_BLUR_RECT (MU_COMMAND_MAX+1) + + typedef struct { mu_BaseCommand base; mu_Rect rect; mu_Color color; int radius;} mu_BlurredRectCommand; + + + // custom drawning commands + void draw_blurred_rect(mu_Context *ctx, mu_Rect rect, mu_Color color, int blur_radius){ + rect = intersect_rects(rect, expand_rect(mu_get_clip_rect(ctx), blur_radius)); + + if (rect.w > 0 && rect.h > 0) { + int clipped = mu_check_clip(ctx, rect); + if (clipped) { mu_set_clip(ctx, mu_get_clip_rect(ctx)); } + + mu_BlurredRectCommand* cmd = (mu_BlurredRectCommand*)mu_push_command(ctx, MU_COMMAND_BLUR_RECT, sizeof(mu_BlurredRectCommand)); + cmd->rect = rect; + cmd->color = color; + cmd->radius = blur_radius; + + if (clipped) { mu_set_clip(ctx, unclipped_rect); } + } + } + + static void draw_frame(mu_Context *ctx, mu_Rect rect, int colorid) { + shadow_style& shadow = colorid==MU_COLOR_WINDOWBG?panel_shadow_style:element_shadow_style; + + // draw shadow if the right element type + if (shadow.clr.a>0.f && ( + colorid == MU_COLOR_WINDOWBG || + colorid == MU_COLOR_SCROLLTHUMB || + colorid == MU_COLOR_BUTTON || + colorid == MU_COLOR_BUTTONHOVER || + colorid == MU_COLOR_BUTTONFOCUS || + colorid == MU_COLOR_BASE || + colorid == MU_COLOR_BASEHOVER || + colorid == MU_COLOR_BASEFOCUS + )){ + mu_Rect shadow_rect = rect; + shadow_rect.x += shadow.offset.x; + shadow_rect.y += shadow.offset.y; + draw_blurred_rect(ctx, shadow_rect, to_mu(shadow.clr), shadow.radius); + } + + // draw main frame + if (ctx->style->colors[colorid].a) + mu_draw_rect(ctx, rect, ctx->style->colors[colorid]); + + if (colorid == MU_COLOR_SCROLLBASE || + colorid == MU_COLOR_TITLEBG) { return; } + + // draw border + if (ctx->style->colors[MU_COLOR_BORDER].a) + mu_draw_box(ctx, expand_rect(rect, 1), ctx->style->colors[MU_COLOR_BORDER]); + } + + // Delay loading of the ui atlas until it's actually needed + // otherwise we'll trigger creating the 'initial window' unnecessarily + sk_drawing_surface* get_ui_atlas() + { + static sk_drawing_surface ui_atlas; + static bool ui_atlas_loaded = false; + + if (!ui_atlas_loaded) + { + ui_atlas = sk_create_bitmap(ATLAS_WIDTH, ATLAS_HEIGHT); + + // Fill the bitmap with values from atlas_texture + for(int y = 0; y < ATLAS_HEIGHT; y++) + for(int x = 0; x < ATLAS_WIDTH; x++) + sk_set_bitmap_pixel(&ui_atlas, {1.f, 1.f, 1.f, atlas_texture[y * ATLAS_WIDTH + x]/255.f}, x, y); + + sk_refresh_bitmap(&ui_atlas); + ui_atlas_loaded = true; + } + + return &ui_atlas; + } + + static void(*style_init_callback)() = nullptr; + void sk_interface_init() + { + _initialize_button_and_key_map(); + _initialize_atlas_map(); + + ctx = (mu_Context*)malloc(sizeof(mu_Context)); + mu_init(ctx); + ctx->text_width = _text_width; + ctx->text_height = _text_height; + ctx->draw_frame = &draw_frame; + + default_style = *ctx->style; + sk_interface_style_reset(); + + if (style_init_callback) + style_init_callback(); // Create custom logger - the default SplashKit is a bit verbose // for the messages this wants to be able to output @@ -294,639 +294,639 @@ namespace splashkit_lib conf.setGlobally(el::ConfigurationType::Format, "%level -> %msg"); conf.setGlobally(el::ConfigurationType::Filename, "logs/splashkit.log"); - el::Loggers::reconfigureLogger("interface", conf); - } - - void sk_interface_set_init_style_callback(void(*callback)()) - { - style_init_callback = callback; - // if we've already initialized, call back now - if (ctx) - style_init_callback(); - } - - void sk_interface_draw(drawing_options opts) - { - sk_interface_end(); - - sk_drawing_surface *surface; - - surface = to_surface_ptr(opts.dest); - - sk_drawing_surface* ui_atlas = get_ui_atlas(); - - if (surface) - { - mu_Command *cmd = NULL; - while (mu_next_command(ctx, &cmd)) - { - switch (cmd->type) - { - case MU_COMMAND_TEXT: - const font_size_pair* font_info; - font_info = _get_font_size_pair(cmd->text.font); - - if (cmd->text.font) - sk_draw_text(surface, font_info->first, font_info->second, cmd->text.pos.x, cmd->text.pos.y, cmd->text.str, from_mu(cmd->text.color)); - - break; - - case MU_COMMAND_RECT: - sk_fill_aa_rect(surface, from_mu(cmd->rect.color), cmd->rect.rect.x, cmd->rect.rect.y, cmd->rect.rect.w, cmd->rect.rect.h); - - break; - - case MU_COMMAND_BLUR_RECT: - mu_BlurredRectCommand* brect; - brect = (mu_BlurredRectCommand*)cmd; - sk_draw_blurred_rect(surface, from_mu(brect->color), brect->rect.x, brect->rect.y, brect->rect.w, brect->rect.h, brect->radius); - - break; - - case MU_COMMAND_ICON: - rectangle atlas_rect; - double src_data[4]; - double dst_data[7]; - sk_renderer_flip flip; - - // if it's a custom icon, handle specially - if (cmd->icon.id >= MU_ICON_MAX) - { - registered_icon* icon = _get_registered_icon(cmd->icon.id); - if (icon) - { - icon->dst_data[0] = cmd->icon.rect.x + (cmd->icon.rect.w - icon->src_data[2]) / 2; // X - icon->dst_data[1] = cmd->icon.rect.y + (cmd->icon.rect.h - icon->src_data[3]) / 2; // Y - sk_draw_bitmap(icon->src, surface, icon->src_data, 4, icon->dst_data, 7, icon->flip); - } - } - else // otherwise draw from atlas - { - atlas_rect = atlas[cmd->icon.id]; - - src_data[0] = atlas_rect.x; - src_data[1] = atlas_rect.y; - src_data[2] = atlas_rect.width; - src_data[3] = atlas_rect.height; - - dst_data[0] = cmd->icon.rect.x + (cmd->icon.rect.w - atlas_rect.width) / 2; // X - dst_data[1] = cmd->icon.rect.y + (cmd->icon.rect.h - atlas_rect.height) / 2; // Y - dst_data[2] = opts.angle; // Angle - dst_data[3] = opts.anchor_offset_x; // Centre X - dst_data[4] = opts.anchor_offset_y; // Centre Y - dst_data[5] = opts.scale_x; // Scale X - dst_data[6] = opts.scale_y; // Scale Y - - flip = sk_FLIP_NONE; - - sk_set_bitmap_tint(ui_atlas, from_mu(cmd->icon.color)); - sk_draw_bitmap(ui_atlas, surface, src_data, 4, dst_data, 7, flip); - } - - break; - - case MU_COMMAND_CLIP: - sk_set_clip_rect(surface, cmd->clip.rect.x, cmd->clip.rect.y, cmd->clip.rect.w, cmd->clip.rect.h); - - break; - } - } - } - } - - void sk_interface_style_set_font(font fnt) - { - current_font = fnt; - - ctx->style->font = _add_font_size_pair(current_font, current_font_size); - ctx->style->size.y = current_font_size; - } - - void sk_interface_style_set_font_size(int size) - { - current_font_size = size; - - ctx->style->font = _add_font_size_pair(current_font, current_font_size); - ctx->style->size.y = current_font_size; - } - - void sk_interface_start() - { - fonts_this_frame.clear(); - registered_icons_this_frame.clear(); - ctx->style->font = _add_font_size_pair(current_font, current_font_size); - - // if re-starting without properly ending, end first - if (ctx_started) sk_interface_end(); - - mu_begin(ctx); - ctx_started = true; - - // create invisible root window, so we can draw directly on the main window - mu_begin_window_ex(ctx, "", unclipped_rect, - MU_OPT_NOFRAME|MU_OPT_NOTITLE|MU_OPT_NOCLOSE|MU_OPT_NORESIZE| - MU_OPT_NOINTERACT|MU_OPT_NOSCROLL - ); - mu_get_current_container(ctx)->zindex = -1; - sk_interface_set_layout(1,{0},0); - } - - void sk_interface_end() - { - // end root window - mu_end_window(ctx); - - mu_end(ctx); - ctx_started = false; - - // If we were focussed on a text box previously, but now aren't, - // then stop reading. - if (focused_text_box != 0 && ctx->focus != focused_text_box) - { - focused_text_box = 0; - current_window()->reading_text = false; - } - } - - bool sk_interface_is_started() - { - return ctx_started; - } - - bool sk_interface_capacity_limited() - { - #define INTERFACE_SAFE_CAPACITY 0.93 //~(30/32) - return - (ctx->command_list.idx > MU_COMMANDLIST_SIZE * INTERFACE_SAFE_CAPACITY) || - (ctx->root_list.idx > MU_ROOTLIST_SIZE * INTERFACE_SAFE_CAPACITY) || - (ctx->container_stack.idx > MU_CONTAINERSTACK_SIZE * INTERFACE_SAFE_CAPACITY) || - (ctx->clip_stack.idx > MU_CLIPSTACK_SIZE * INTERFACE_SAFE_CAPACITY) || - (ctx->id_stack.idx > MU_IDSTACK_SIZE * INTERFACE_SAFE_CAPACITY) || - (ctx->layout_stack.idx > MU_LAYOUTSTACK_SIZE * INTERFACE_SAFE_CAPACITY); - #undef INTERFACE_SAFE_CAPACITY - } - - bool sk_interface_start_panel(const string& name, rectangle initial_rectangle) - { - return mu_begin_window(ctx, name.c_str(), to_mu(initial_rectangle)); - } - - void sk_interface_end_panel() - { - mu_end_window(ctx); - } - - bool sk_interface_start_popup(const string& name) - { - return mu_begin_popup(ctx, name.c_str()); - } - - void sk_interface_end_popup() - { - mu_end_popup(ctx); - } - - void sk_interface_start_inset(const string& name) - { - mu_begin_panel(ctx, name.c_str()); - } - - void sk_interface_end_inset() - { - mu_end_panel(ctx); - } - - bool sk_interface_start_treenode(const string& name) - { - return mu_begin_treenode(ctx, name.c_str()); - } - - void sk_interface_end_treenode() - { - mu_end_treenode(ctx); - } - - void sk_interface_open_popup(const string& name) - { - mu_open_popup(ctx, name.c_str()); - } - - void sk_interface_set_layout(int items, int* widths, int height) - { - mu_layout_row(ctx, items, widths, height); - } - - void sk_interface_set_layout_next(const rectangle& rect, bool relative) - { - mu_layout_set_next(ctx, to_mu(rect), relative ? 1 : 2);/*see microui.c line 527*/ - } - - void sk_interface_set_layout_width(int width) - { - mu_layout_width(ctx, width); - } - - void sk_interface_set_layout_height(int height) - { - mu_layout_height(ctx, height); - } - - void sk_interface_start_column() - { - mu_layout_begin_column(ctx); - } - - void sk_interface_end_column() - { - mu_layout_end_column(ctx); - } - - int sk_interface_get_container_width() - { - return mu_get_current_container(ctx)->body.w; - } - - int sk_interface_get_container_height() - { - return mu_get_current_container(ctx)->body.h; - } - - int sk_interface_get_layout_width() - { - if (ctx->layout_stack.idx <= 0) return 0; - - return ctx->layout_stack.items[ctx->layout_stack.idx - 1].body.w; - } - - int sk_interface_get_layout_height() - { - if (ctx->layout_stack.idx <= 0) return 0; - - return ctx->layout_stack.items[ctx->layout_stack.idx - 1].body.h; - } - - void update_elements_changed(int result) - { - element_changed = result; - element_confirmed = result & MU_RES_SUBMIT; - } - - void sk_interface_push_ptr_id(void* ptr) - { - mu_push_id(ctx, &ptr, sizeof(ptr)); - } - - void sk_interface_pop_id() - { - mu_pop_id(ctx); - } - - bool sk_interface_header(const string& label) - { - return mu_header(ctx, label.c_str()); - } - - void sk_interface_label(const string& label) - { - mu_label(ctx, label.c_str()); - } - - void sk_interface_text(const string& text) - { - mu_text(ctx, text.c_str()); - } - - bool sk_interface_button(const string& label, int icon) - { - update_elements_changed(mu_button_ex(ctx, label.c_str(), icon, MU_OPT_ALIGNCENTER)); - return element_confirmed; - } - - bool sk_interface_checkbox(const string& label, const bool& value) - { - sk_interface_push_ptr_id((void*)&value); - - int temp_value = value; - update_elements_changed(mu_checkbox(ctx, label.c_str(), &temp_value)); - - sk_interface_pop_id(); - return temp_value; - } - - float sk_interface_slider(const float& value, float min_value, float max_value) - { - sk_interface_push_ptr_id((void*)&value); - - float temp_value = value; - update_elements_changed(mu_slider(ctx, &temp_value, min_value, max_value)); - - sk_interface_pop_id(); - return temp_value; - } - - float sk_interface_number(const float& value, float step) - { - sk_interface_push_ptr_id((void*)&value); - - float temp_value = value; - update_elements_changed(mu_number(ctx, &temp_value, step)); - - sk_interface_pop_id(); - return temp_value; - } - - std::string sk_interface_text_box(const std::string& value) - { - const std::string* id = &value; - mu_Id m_id = mu_get_id(ctx, &id, sizeof(id)); - mu_Rect r = mu_layout_next(ctx); - - // max 512 characters - // considering the lack of word wrap or even - // keyboard navigation, this should be enough. - char temp_value[512]; - - bool was_focused = ctx->focus == m_id; - - // If focussed, temporarily add the current composition to the string - we'll remove it at the end - if (was_focused) - strncpy(temp_value, (value+current_window()->composition).c_str(), sizeof(temp_value)); - else - strncpy(temp_value, value.c_str(), sizeof(temp_value)); - - temp_value[sizeof(temp_value) - 1] = 0; - - update_elements_changed(mu_textbox_raw(ctx, temp_value, sizeof(temp_value), m_id, r, 0)); - - // Is this element newly focussed? - if (ctx->focus == m_id) - { - // Start reading - if (focused_text_box == 0) - sk_start_reading_text(current_window(), r.x, r.y, r.w, r.h, ""); - focused_text_box = m_id; - } - - // Remove the composition from the string if it was added - if (was_focused) - return std::string(temp_value, 0, strlen(temp_value) - current_window()->composition.size()); - else - return temp_value; - } - - void sk_interface_color_box(color clr) - { - mu_Rect rect = mu_layout_next(ctx); - mu_draw_rect(ctx, rect, to_mu(clr)); - mu_draw_box(ctx, rect, to_mu(COLOR_BLACK)); - } - - bool sk_interface_changed() - { - return element_changed; - } - - bool sk_interface_confirmed() - { - return element_confirmed; - } - - void* sk_interface_get_context() - { - return (void*)ctx; - } - - void sk_interface_mousemove(int motion_x, int motion_y) - { - mu_input_mousemove(ctx, motion_x, motion_y); - } - - void sk_interface_scroll(int motion_x, int motion_y) - { - mu_input_scroll(ctx, motion_x, motion_y * -30); - } - - void sk_interface_text(char* text) - { - mu_input_text(ctx, text); - } - - void sk_interface_mousedown(int x, int y, int button) - { - int b = button_map[button & 0xff]; - mu_input_mousedown(ctx, x, y, b); - } - - void sk_interface_mouseup(int x, int y, int button) - { - int b = button_map[button & 0xff]; - mu_input_mouseup(ctx, x, y, b); - } - - void sk_interface_keydown(int key) - { - int c = key_map[key & 0xff]; - mu_input_keydown(ctx, c); - } - - void sk_interface_keyup(int key) - { - int c = key_map[key & 0xff]; - mu_input_keyup(ctx, c); - } - - void sk_interface_style_reset() - { - *ctx->style = default_style; - panel_shadow_style.clr = COLOR_BLACK; - panel_shadow_style.radius = 35; - panel_shadow_style.offset = {16,16}; - element_shadow_style.clr = COLOR_BLACK; - element_shadow_style.radius = 7; - element_shadow_style.offset = {3,3}; - } - - void sk_interface_style_set_border_color(sk_color clr) - { - ctx->style->colors[MU_COLOR_BORDER] = to_mu(clr); - } - - void sk_interface_style_set_text_color(sk_color clr) - { - ctx->style->colors[MU_COLOR_TEXT] = to_mu(clr); - } - - void sk_interface_style_set_title_color(sk_color clr) - { - ctx->style->colors[MU_COLOR_TITLETEXT] = to_mu(clr); - } - - void sk_interface_style_set_titlebar_color(sk_color clr) - { - ctx->style->colors[MU_COLOR_TITLEBG] = to_mu(clr); - } - - void sk_interface_style_set_panel_color(sk_color clr) - { - ctx->style->colors[MU_COLOR_WINDOWBG] = to_mu(clr); - } - - void sk_interface_style_set_inset_color(sk_color clr) - { - ctx->style->colors[MU_COLOR_PANELBG] = to_mu(clr); - } - - void sk_interface_style_set_button_color(sk_color clr) - { - ctx->style->colors[MU_COLOR_BUTTON] = to_mu(clr); - } - - void sk_interface_style_set_button_accent_colors(sk_color hover_clr, sk_color active_clr) - { - ctx->style->colors[MU_COLOR_BUTTONHOVER] = to_mu(hover_clr); - ctx->style->colors[MU_COLOR_BUTTONFOCUS] = to_mu(active_clr); - } - - void sk_interface_style_set_control_color(sk_color clr) - { - ctx->style->colors[MU_COLOR_BASE] = to_mu(clr); - } - - void sk_interface_style_set_control_accent_colors(sk_color hover_clr, sk_color active_clr) - { - ctx->style->colors[MU_COLOR_BASEHOVER] = to_mu(hover_clr); - ctx->style->colors[MU_COLOR_BASEFOCUS] = to_mu(active_clr); - } - - void sk_interface_style_set_scroll_base_color(sk_color clr) - { - ctx->style->colors[MU_COLOR_SCROLLBASE] = to_mu(clr); - } - - void sk_interface_style_set_scrollbar_color(sk_color clr) - { - ctx->style->colors[MU_COLOR_SCROLLTHUMB] = to_mu(clr); - } - - void sk_interface_style_set_panel_shadow_color(sk_color clr) - { - panel_shadow_style.clr = clr; - } - - void sk_interface_style_set_panel_shadow_radius(int radius) - { - panel_shadow_style.radius = radius; - } - - void sk_interface_style_set_panel_shadow_offset(point_2d offset) - { - panel_shadow_style.offset = offset; - } - - void sk_interface_style_set_element_shadow_color(sk_color clr) - { - element_shadow_style.clr = clr; - } - - void sk_interface_style_set_element_shadow_radius(int radius) - { - element_shadow_style.radius = radius; - } - - void sk_interface_style_set_element_shadow_offset(point_2d offset) - { - element_shadow_style.offset = offset; - } - - void sk_interface_style_set_padding(int padding) - { - ctx->style->padding = padding; - } - - void sk_interface_style_set_spacing(int spacing) - { - ctx->style->spacing = spacing; - } - - void sk_interface_style_set_indent(int indent) - { - ctx->style->indent = indent; - } - - void sk_interface_style_set_title_height(int title_height) - { - ctx->style->title_height = title_height; - } - - void sk_interface_style_set_scrollbar_size(int scrollbar_size) - { - ctx->style->scrollbar_size = scrollbar_size; - } - - void sk_interface_style_set_thumb_size(int thumb_size) - { - ctx->style->thumb_size = thumb_size; - } - - int sk_interface_style_get_padding() - { - return ctx->style->padding; - } - int sk_interface_style_get_spacing() - { - return ctx->style->spacing; - } - - static bool interface_enabled = true; - - // MicroUI has no inbuilt functionality for disabling - // the UI, so we emulate it by taking a copy of current - // input state, then zeroing out everything. - // We then restore it once the interface is enabled again. - void sk_interface_set_enabled(bool enabled) - { - // copy of relevant input state - static mu_Id focus; - static mu_Vec2 mouse_pos; - static int mouse_down; - static int mouse_pressed; - static int key_down; - static int key_pressed; - - if (interface_enabled == enabled) - return; - - interface_enabled = enabled; - - if (interface_enabled) - { - ctx->focus = focus; - ctx->mouse_pos = mouse_pos; - ctx->mouse_down = mouse_down; - ctx->mouse_pressed = mouse_pressed; - ctx->key_down = key_down; - ctx->key_pressed = key_pressed; - } - else - { - focus = ctx->focus; - mouse_pos = ctx->mouse_pos; - mouse_down = ctx->mouse_down; - mouse_pressed = ctx->mouse_pressed; - key_down = ctx->key_down; - key_pressed = ctx->key_pressed; - - ctx->focus = -1; - ctx->mouse_pos ={ -1, -1 }; - ctx->mouse_down = 0; - ctx->mouse_pressed = 0; - ctx->key_down = 0; - ctx->key_pressed = 0; - } - } - - bool sk_interface_is_enabled() - { - return interface_enabled; - } + el::Loggers::reconfigureLogger("interface", conf); + } + + void sk_interface_set_init_style_callback(void(*callback)()) + { + style_init_callback = callback; + // if we've already initialized, call back now + if (ctx) + style_init_callback(); + } + + void sk_interface_draw(drawing_options opts) + { + sk_interface_end(); + + sk_drawing_surface *surface; + + surface = to_surface_ptr(opts.dest); + + sk_drawing_surface* ui_atlas = get_ui_atlas(); + + if (surface) + { + mu_Command *cmd = NULL; + while (mu_next_command(ctx, &cmd)) + { + switch (cmd->type) + { + case MU_COMMAND_TEXT: + const font_size_pair* font_info; + font_info = _get_font_size_pair(cmd->text.font); + + if (cmd->text.font) + sk_draw_text(surface, font_info->first, font_info->second, cmd->text.pos.x, cmd->text.pos.y, cmd->text.str, from_mu(cmd->text.color)); + + break; + + case MU_COMMAND_RECT: + sk_fill_aa_rect(surface, from_mu(cmd->rect.color), cmd->rect.rect.x, cmd->rect.rect.y, cmd->rect.rect.w, cmd->rect.rect.h); + + break; + + case MU_COMMAND_BLUR_RECT: + mu_BlurredRectCommand* brect; + brect = (mu_BlurredRectCommand*)cmd; + sk_draw_blurred_rect(surface, from_mu(brect->color), brect->rect.x, brect->rect.y, brect->rect.w, brect->rect.h, brect->radius); + + break; + + case MU_COMMAND_ICON: + rectangle atlas_rect; + double src_data[4]; + double dst_data[7]; + sk_renderer_flip flip; + + // if it's a custom icon, handle specially + if (cmd->icon.id >= MU_ICON_MAX) + { + registered_icon* icon = _get_registered_icon(cmd->icon.id); + if (icon) + { + icon->dst_data[0] = cmd->icon.rect.x + (cmd->icon.rect.w - icon->src_data[2]) / 2; // X + icon->dst_data[1] = cmd->icon.rect.y + (cmd->icon.rect.h - icon->src_data[3]) / 2; // Y + sk_draw_bitmap(icon->src, surface, icon->src_data, 4, icon->dst_data, 7, icon->flip); + } + } + else // otherwise draw from atlas + { + atlas_rect = atlas[cmd->icon.id]; + + src_data[0] = atlas_rect.x; + src_data[1] = atlas_rect.y; + src_data[2] = atlas_rect.width; + src_data[3] = atlas_rect.height; + + dst_data[0] = cmd->icon.rect.x + (cmd->icon.rect.w - atlas_rect.width) / 2; // X + dst_data[1] = cmd->icon.rect.y + (cmd->icon.rect.h - atlas_rect.height) / 2; // Y + dst_data[2] = opts.angle; // Angle + dst_data[3] = opts.anchor_offset_x; // Centre X + dst_data[4] = opts.anchor_offset_y; // Centre Y + dst_data[5] = opts.scale_x; // Scale X + dst_data[6] = opts.scale_y; // Scale Y + + flip = sk_FLIP_NONE; + + sk_set_bitmap_tint(ui_atlas, from_mu(cmd->icon.color)); + sk_draw_bitmap(ui_atlas, surface, src_data, 4, dst_data, 7, flip); + } + + break; + + case MU_COMMAND_CLIP: + sk_set_clip_rect(surface, cmd->clip.rect.x, cmd->clip.rect.y, cmd->clip.rect.w, cmd->clip.rect.h); + + break; + } + } + } + } + + void sk_interface_style_set_font(font fnt) + { + current_font = fnt; + + ctx->style->font = _add_font_size_pair(current_font, current_font_size); + ctx->style->size.y = current_font_size; + } + + void sk_interface_style_set_font_size(int size) + { + current_font_size = size; + + ctx->style->font = _add_font_size_pair(current_font, current_font_size); + ctx->style->size.y = current_font_size; + } + + void sk_interface_start() + { + fonts_this_frame.clear(); + registered_icons_this_frame.clear(); + ctx->style->font = _add_font_size_pair(current_font, current_font_size); + + // if re-starting without properly ending, end first + if (ctx_started) sk_interface_end(); + + mu_begin(ctx); + ctx_started = true; + + // create invisible root window, so we can draw directly on the main window + mu_begin_window_ex(ctx, "", unclipped_rect, + MU_OPT_NOFRAME|MU_OPT_NOTITLE|MU_OPT_NOCLOSE|MU_OPT_NORESIZE| + MU_OPT_NOINTERACT|MU_OPT_NOSCROLL + ); + mu_get_current_container(ctx)->zindex = -1; + sk_interface_set_layout(1,{0},0); + } + + void sk_interface_end() + { + // end root window + mu_end_window(ctx); + + mu_end(ctx); + ctx_started = false; + + // If we were focussed on a text box previously, but now aren't, + // then stop reading. + if (focused_text_box != 0 && ctx->focus != focused_text_box) + { + focused_text_box = 0; + current_window()->reading_text = false; + } + } + + bool sk_interface_is_started() + { + return ctx_started; + } + + bool sk_interface_capacity_limited() + { + #define INTERFACE_SAFE_CAPACITY 0.93 //~(30/32) + return + (ctx->command_list.idx > MU_COMMANDLIST_SIZE * INTERFACE_SAFE_CAPACITY) || + (ctx->root_list.idx > MU_ROOTLIST_SIZE * INTERFACE_SAFE_CAPACITY) || + (ctx->container_stack.idx > MU_CONTAINERSTACK_SIZE * INTERFACE_SAFE_CAPACITY) || + (ctx->clip_stack.idx > MU_CLIPSTACK_SIZE * INTERFACE_SAFE_CAPACITY) || + (ctx->id_stack.idx > MU_IDSTACK_SIZE * INTERFACE_SAFE_CAPACITY) || + (ctx->layout_stack.idx > MU_LAYOUTSTACK_SIZE * INTERFACE_SAFE_CAPACITY); + #undef INTERFACE_SAFE_CAPACITY + } + + bool sk_interface_start_panel(const string& name, rectangle initial_rectangle) + { + return mu_begin_window(ctx, name.c_str(), to_mu(initial_rectangle)); + } + + void sk_interface_end_panel() + { + mu_end_window(ctx); + } + + bool sk_interface_start_popup(const string& name) + { + return mu_begin_popup(ctx, name.c_str()); + } + + void sk_interface_end_popup() + { + mu_end_popup(ctx); + } + + void sk_interface_start_inset(const string& name) + { + mu_begin_panel(ctx, name.c_str()); + } + + void sk_interface_end_inset() + { + mu_end_panel(ctx); + } + + bool sk_interface_start_treenode(const string& name) + { + return mu_begin_treenode(ctx, name.c_str()); + } + + void sk_interface_end_treenode() + { + mu_end_treenode(ctx); + } + + void sk_interface_open_popup(const string& name) + { + mu_open_popup(ctx, name.c_str()); + } + + void sk_interface_set_layout(int items, int* widths, int height) + { + mu_layout_row(ctx, items, widths, height); + } + + void sk_interface_set_layout_next(const rectangle& rect, bool relative) + { + mu_layout_set_next(ctx, to_mu(rect), relative ? 1 : 2);/*see microui.c line 527*/ + } + + void sk_interface_set_layout_width(int width) + { + mu_layout_width(ctx, width); + } + + void sk_interface_set_layout_height(int height) + { + mu_layout_height(ctx, height); + } + + void sk_interface_start_column() + { + mu_layout_begin_column(ctx); + } + + void sk_interface_end_column() + { + mu_layout_end_column(ctx); + } + + int sk_interface_get_container_width() + { + return mu_get_current_container(ctx)->body.w; + } + + int sk_interface_get_container_height() + { + return mu_get_current_container(ctx)->body.h; + } + + int sk_interface_get_layout_width() + { + if (ctx->layout_stack.idx <= 0) return 0; + + return ctx->layout_stack.items[ctx->layout_stack.idx - 1].body.w; + } + + int sk_interface_get_layout_height() + { + if (ctx->layout_stack.idx <= 0) return 0; + + return ctx->layout_stack.items[ctx->layout_stack.idx - 1].body.h; + } + + void update_elements_changed(int result) + { + element_changed = result; + element_confirmed = result & MU_RES_SUBMIT; + } + + void sk_interface_push_ptr_id(void* ptr) + { + mu_push_id(ctx, &ptr, sizeof(ptr)); + } + + void sk_interface_pop_id() + { + mu_pop_id(ctx); + } + + bool sk_interface_header(const string& label_text) + { + return mu_header(ctx, label_text.c_str()); + } + + void sk_interface_label(const string& label_text) + { + mu_label(ctx, label_text.c_str()); + } + + void sk_interface_text(const string& text) + { + mu_text(ctx, text.c_str()); + } + + bool sk_interface_button(const string& label_text, int icon) + { + update_elements_changed(mu_button_ex(ctx, label_text.c_str(), icon, MU_OPT_ALIGNCENTER)); + return element_confirmed; + } + + bool sk_interface_checkbox(const string& label_text, const bool& value) + { + sk_interface_push_ptr_id((void*)&value); + + int temp_value = value; + update_elements_changed(mu_checkbox(ctx, label_text.c_str(), &temp_value)); + + sk_interface_pop_id(); + return temp_value; + } + + float sk_interface_slider(const float& value, float min_value, float max_value) + { + sk_interface_push_ptr_id((void*)&value); + + float temp_value = value; + update_elements_changed(mu_slider(ctx, &temp_value, min_value, max_value)); + + sk_interface_pop_id(); + return temp_value; + } + + float sk_interface_number(const float& value, float step) + { + sk_interface_push_ptr_id((void*)&value); + + float temp_value = value; + update_elements_changed(mu_number(ctx, &temp_value, step)); + + sk_interface_pop_id(); + return temp_value; + } + + std::string sk_interface_text_box(const std::string& value) + { + const std::string* id = &value; + mu_Id m_id = mu_get_id(ctx, &id, sizeof(id)); + mu_Rect r = mu_layout_next(ctx); + + // max 512 characters + // considering the lack of word wrap or even + // keyboard navigation, this should be enough. + char temp_value[512]; + + bool was_focused = ctx->focus == m_id; + + // If focussed, temporarily add the current composition to the string - we'll remove it at the end + if (was_focused) + strncpy(temp_value, (value+current_window()->composition).c_str(), sizeof(temp_value)); + else + strncpy(temp_value, value.c_str(), sizeof(temp_value)); + + temp_value[sizeof(temp_value) - 1] = 0; + + update_elements_changed(mu_textbox_raw(ctx, temp_value, sizeof(temp_value), m_id, r, 0)); + + // Is this element newly focussed? + if (ctx->focus == m_id) + { + // Start reading + if (focused_text_box == 0) + sk_start_reading_text(current_window(), r.x, r.y, r.w, r.h, ""); + focused_text_box = m_id; + } + + // Remove the composition from the string if it was added + if (was_focused) + return std::string(temp_value, 0, strlen(temp_value) - current_window()->composition.size()); + else + return temp_value; + } + + void sk_interface_color_box(color clr) + { + mu_Rect rect = mu_layout_next(ctx); + mu_draw_rect(ctx, rect, to_mu(clr)); + mu_draw_box(ctx, rect, to_mu(COLOR_BLACK)); + } + + bool sk_interface_changed() + { + return element_changed; + } + + bool sk_interface_confirmed() + { + return element_confirmed; + } + + void* sk_interface_get_context() + { + return (void*)ctx; + } + + void sk_interface_mousemove(int motion_x, int motion_y) + { + mu_input_mousemove(ctx, motion_x, motion_y); + } + + void sk_interface_scroll(int motion_x, int motion_y) + { + mu_input_scroll(ctx, motion_x, motion_y * -30); + } + + void sk_interface_text(char* text) + { + mu_input_text(ctx, text); + } + + void sk_interface_mousedown(int x, int y, int button) + { + int b = button_map[button & 0xff]; + mu_input_mousedown(ctx, x, y, b); + } + + void sk_interface_mouseup(int x, int y, int button) + { + int b = button_map[button & 0xff]; + mu_input_mouseup(ctx, x, y, b); + } + + void sk_interface_keydown(int key) + { + int c = key_map[key & 0xff]; + mu_input_keydown(ctx, c); + } + + void sk_interface_keyup(int key) + { + int c = key_map[key & 0xff]; + mu_input_keyup(ctx, c); + } + + void sk_interface_style_reset() + { + *ctx->style = default_style; + panel_shadow_style.clr = COLOR_BLACK; + panel_shadow_style.radius = 35; + panel_shadow_style.offset = {16,16}; + element_shadow_style.clr = COLOR_BLACK; + element_shadow_style.radius = 7; + element_shadow_style.offset = {3,3}; + } + + void sk_interface_style_set_border_color(sk_color clr) + { + ctx->style->colors[MU_COLOR_BORDER] = to_mu(clr); + } + + void sk_interface_style_set_text_color(sk_color clr) + { + ctx->style->colors[MU_COLOR_TEXT] = to_mu(clr); + } + + void sk_interface_style_set_title_color(sk_color clr) + { + ctx->style->colors[MU_COLOR_TITLETEXT] = to_mu(clr); + } + + void sk_interface_style_set_titlebar_color(sk_color clr) + { + ctx->style->colors[MU_COLOR_TITLEBG] = to_mu(clr); + } + + void sk_interface_style_set_panel_color(sk_color clr) + { + ctx->style->colors[MU_COLOR_WINDOWBG] = to_mu(clr); + } + + void sk_interface_style_set_inset_color(sk_color clr) + { + ctx->style->colors[MU_COLOR_PANELBG] = to_mu(clr); + } + + void sk_interface_style_set_button_color(sk_color clr) + { + ctx->style->colors[MU_COLOR_BUTTON] = to_mu(clr); + } + + void sk_interface_style_set_button_accent_colors(sk_color hover_clr, sk_color active_clr) + { + ctx->style->colors[MU_COLOR_BUTTONHOVER] = to_mu(hover_clr); + ctx->style->colors[MU_COLOR_BUTTONFOCUS] = to_mu(active_clr); + } + + void sk_interface_style_set_control_color(sk_color clr) + { + ctx->style->colors[MU_COLOR_BASE] = to_mu(clr); + } + + void sk_interface_style_set_control_accent_colors(sk_color hover_clr, sk_color active_clr) + { + ctx->style->colors[MU_COLOR_BASEHOVER] = to_mu(hover_clr); + ctx->style->colors[MU_COLOR_BASEFOCUS] = to_mu(active_clr); + } + + void sk_interface_style_set_scroll_base_color(sk_color clr) + { + ctx->style->colors[MU_COLOR_SCROLLBASE] = to_mu(clr); + } + + void sk_interface_style_set_scrollbar_color(sk_color clr) + { + ctx->style->colors[MU_COLOR_SCROLLTHUMB] = to_mu(clr); + } + + void sk_interface_style_set_panel_shadow_color(sk_color clr) + { + panel_shadow_style.clr = clr; + } + + void sk_interface_style_set_panel_shadow_radius(int radius) + { + panel_shadow_style.radius = radius; + } + + void sk_interface_style_set_panel_shadow_offset(point_2d offset) + { + panel_shadow_style.offset = offset; + } + + void sk_interface_style_set_element_shadow_color(sk_color clr) + { + element_shadow_style.clr = clr; + } + + void sk_interface_style_set_element_shadow_radius(int radius) + { + element_shadow_style.radius = radius; + } + + void sk_interface_style_set_element_shadow_offset(point_2d offset) + { + element_shadow_style.offset = offset; + } + + void sk_interface_style_set_padding(int padding) + { + ctx->style->padding = padding; + } + + void sk_interface_style_set_spacing(int spacing) + { + ctx->style->spacing = spacing; + } + + void sk_interface_style_set_indent(int indent) + { + ctx->style->indent = indent; + } + + void sk_interface_style_set_title_height(int title_height) + { + ctx->style->title_height = title_height; + } + + void sk_interface_style_set_scrollbar_size(int scrollbar_size) + { + ctx->style->scrollbar_size = scrollbar_size; + } + + void sk_interface_style_set_thumb_size(int thumb_size) + { + ctx->style->thumb_size = thumb_size; + } + + int sk_interface_style_get_padding() + { + return ctx->style->padding; + } + int sk_interface_style_get_spacing() + { + return ctx->style->spacing; + } + + static bool interface_enabled = true; + + // MicroUI has no inbuilt functionality for disabling + // the UI, so we emulate it by taking a copy of current + // input state, then zeroing out everything. + // We then restore it once the interface is enabled again. + void sk_interface_set_enabled(bool enabled) + { + // copy of relevant input state + static mu_Id focus; + static mu_Vec2 mouse_pos; + static int mouse_down; + static int mouse_pressed; + static int key_down; + static int key_pressed; + + if (interface_enabled == enabled) + return; + + interface_enabled = enabled; + + if (interface_enabled) + { + ctx->focus = focus; + ctx->mouse_pos = mouse_pos; + ctx->mouse_down = mouse_down; + ctx->mouse_pressed = mouse_pressed; + ctx->key_down = key_down; + ctx->key_pressed = key_pressed; + } + else + { + focus = ctx->focus; + mouse_pos = ctx->mouse_pos; + mouse_down = ctx->mouse_down; + mouse_pressed = ctx->mouse_pressed; + key_down = ctx->key_down; + key_pressed = ctx->key_pressed; + + ctx->focus = -1; + ctx->mouse_pos ={ -1, -1 }; + ctx->mouse_down = 0; + ctx->mouse_pressed = 0; + ctx->key_down = 0; + ctx->key_pressed = 0; + } + } + + bool sk_interface_is_enabled() + { + return interface_enabled; + } } \ No newline at end of file diff --git a/source/keyboard_input.cpp b/source/keyboard_input.cpp index 77dc7db..ff1dbf8 100644 --- a/source/keyboard_input.cpp +++ b/source/keyboard_input.cpp @@ -92,6 +92,7 @@ namespace splashkit_lib _keys_just_typed[keycode] = true; _raise_key_event(_on_key_typed, keycode); } + _key_pressed = true; _raise_key_event(_on_key_down, keycode); } diff --git a/source/line_geometry.cpp b/source/line_geometry.cpp index 736a135..6e69411 100644 --- a/source/line_geometry.cpp +++ b/source/line_geometry.cpp @@ -109,8 +109,11 @@ namespace splashkit_lib point_2d closest_point_on_lines(const point_2d from_pt, const vector &lines, int &line_idx) { line_idx = -1; - float min_dist = -1, dst; point_2d result = point_at_origin(); + + if (lines.size() < 1) return result; + + float min_dist = std::numeric_limits::max(), dst; point_2d pt; for (int i = 0; i < lines.size(); i++) @@ -125,7 +128,7 @@ namespace splashkit_lib result = pt; } } - return pt; + return result; } vector lines_from(const triangle &t) diff --git a/source/logging.cpp b/source/logging.cpp index 51c4152..9dbab8d 100644 --- a/source/logging.cpp +++ b/source/logging.cpp @@ -65,7 +65,7 @@ namespace splashkit_lib { write("INFO: "); } - else if (_log_mode == LOG_FILE_ONLY || _log_mode == LOG_CONSOLE_AND_FILE) + if (_log_mode == LOG_FILE_ONLY || _log_mode == LOG_CONSOLE_AND_FILE) { custom_log_file << "INFO: "; } @@ -79,7 +79,7 @@ namespace splashkit_lib { write("DEBUG: "); } - else if (_log_mode == LOG_FILE_ONLY || _log_mode == LOG_CONSOLE_AND_FILE) + if (_log_mode == LOG_FILE_ONLY || _log_mode == LOG_CONSOLE_AND_FILE) { custom_log_file << "DEBUG: "; } @@ -93,7 +93,7 @@ namespace splashkit_lib { write("WARNING: "); } - else if (_log_mode == LOG_FILE_ONLY || _log_mode == LOG_CONSOLE_AND_FILE) + if (_log_mode == LOG_FILE_ONLY || _log_mode == LOG_CONSOLE_AND_FILE) { custom_log_file << "WARNING: "; } @@ -107,7 +107,7 @@ namespace splashkit_lib { write("ERROR: "); } - else if (_log_mode == LOG_FILE_ONLY || _log_mode == LOG_CONSOLE_AND_FILE) + if (_log_mode == LOG_FILE_ONLY || _log_mode == LOG_CONSOLE_AND_FILE) { custom_log_file << "ERROR: "; } @@ -117,7 +117,7 @@ namespace splashkit_lib { write("FATAL: "); } - else if (_log_mode == LOG_FILE_ONLY || _log_mode == LOG_CONSOLE_AND_FILE) + if (_log_mode == LOG_FILE_ONLY || _log_mode == LOG_CONSOLE_AND_FILE) { custom_log_file << "FATAL: "; } @@ -134,7 +134,7 @@ namespace splashkit_lib write(" "); write_line(message); } - else if (_log_mode == LOG_FILE_ONLY || _log_mode == LOG_CONSOLE_AND_FILE) + if (_log_mode == LOG_FILE_ONLY || _log_mode == LOG_CONSOLE_AND_FILE) { custom_log_file << str_time.substr(0, str_time.length() - 1); custom_log_file << " "; diff --git a/source/music.cpp b/source/music.cpp index 7dfa45b..a7c6c3f 100644 --- a/source/music.cpp +++ b/source/music.cpp @@ -131,7 +131,7 @@ namespace splashkit_lib } } - void play_music(music data, int times, float volume) + void play_music(music data, int times, double volume) { if ( !audio_ready() ) return; @@ -219,12 +219,12 @@ namespace splashkit_lib return sk_music_playing(); } - void set_music_volume(float volume) + void set_music_volume(double volume) { sk_set_music_vol(volume); } - float music_volume() + double music_volume() { return sk_music_vol(); } diff --git a/source/point_geometry.cpp b/source/point_geometry.cpp index 4a79505..a26cd8b 100644 --- a/source/point_geometry.cpp +++ b/source/point_geometry.cpp @@ -107,7 +107,7 @@ namespace splashkit_lib v = (dot00 * dot12 - dot01 * dot02) * inv_denom; // Check if point is in triangle - return ((u > 0) and (v > 0) and (u + v < 1)); + return ((u >= 0) and (v >= 0) and (u + v <= 1)); } bool point_in_rectangle(const point_2d &pt, const rectangle &rect) diff --git a/source/quad_geometry.cpp b/source/quad_geometry.cpp index d6bdb9d..2830143 100644 --- a/source/quad_geometry.cpp +++ b/source/quad_geometry.cpp @@ -61,7 +61,7 @@ namespace splashkit_lib void set_quad_point(quad &q, int idx, const point_2d &value) { - if (idx < 0 || idx > 3) + if (idx >= 0 && idx <= 3) { q.points[idx] = value; } diff --git a/source/random.cpp b/source/random.cpp index c67c67e..3334b42 100644 --- a/source/random.cpp +++ b/source/random.cpp @@ -10,6 +10,9 @@ #include "random.h" #include #include +#include +#include + namespace splashkit_lib { static bool _do_seed = true; @@ -21,6 +24,8 @@ namespace splashkit_lib int rnd(int ubound) { + if (ubound <= 0) return 0; + if (_do_seed) { _do_seed = false; @@ -32,12 +37,21 @@ namespace splashkit_lib int rnd(int min, int max) { + if (min > max) + { + LOG(WARNING) << "Min value is greater than max value when calling rnd."; + return rnd(max, min); + } + + if (min == max) return min; + if (_do_seed) { _do_seed = false; srand((unsigned)time(0)); } - return min + rand() % (max - min); + int range = abs(max - min) + 1; + return min + (rand() % range); } } diff --git a/source/sk_clib.cpp b/source/sk_clib.cpp index 1252e33..6ae8a4f 100644 --- a/source/sk_clib.cpp +++ b/source/sk_clib.cpp @@ -571,6 +571,20 @@ float __sklib__circle_radius__circle(const __sklib_circle c) { float __skreturn = circle_radius(__skparam__c); return __sklib__to_float(__skreturn); } +int __sklib__circle_triangle_intersect__circle_ref__triangle_ref(const __sklib_circle c, const __sklib_triangle tri) { + circle __skparam__c = __sklib__to_circle(c); + triangle __skparam__tri = __sklib__to_triangle(tri); + bool __skreturn = circle_triangle_intersect(__skparam__c, __skparam__tri); + return __sklib__to_int(__skreturn); +} +int __sklib__circle_triangle_intersect__circle_ref__triangle_ref__point_2d_ref(const __sklib_circle c, const __sklib_triangle tri, __sklib_point_2d *p) { + circle __skparam__c = __sklib__to_circle(c); + triangle __skparam__tri = __sklib__to_triangle(tri); + point_2d __skparam__p = __sklib__to_point_2d(*p); + bool __skreturn = circle_triangle_intersect(__skparam__c, __skparam__tri, __skparam__p); + *p = __sklib__to_sklib_point_2d(__skparam__p); + return __sklib__to_int(__skreturn); +} float __sklib__circle_x__circle_ref(const __sklib_circle c) { circle __skparam__c = __sklib__to_circle(c); float __skreturn = circle_x(__skparam__c); @@ -615,6 +629,12 @@ __sklib_point_2d __sklib__closest_point_on_rect_from_circle__circle_ref__rectang point_2d __skreturn = closest_point_on_rect_from_circle(__skparam__c, __skparam__rect); return __sklib__to_sklib_point_2d(__skreturn); } +__sklib_point_2d __sklib__closest_point_on_triangle_from_circle__circle_ref__triangle_ref(const __sklib_circle c, const __sklib_triangle tri) { + circle __skparam__c = __sklib__to_circle(c); + triangle __skparam__tri = __sklib__to_triangle(tri); + point_2d __skreturn = closest_point_on_triangle_from_circle(__skparam__c, __skparam__tri); + return __sklib__to_sklib_point_2d(__skreturn); +} __sklib_point_2d __sklib__distant_point_on_circle__point_2d_ref__circle_ref(const __sklib_point_2d pt, const __sklib_circle c) { point_2d __skparam__pt = __sklib__to_point_2d(pt); circle __skparam__c = __sklib__to_circle(c); @@ -2355,17 +2375,17 @@ int __sklib__bitmap_button__bitmap__drawing_options(__sklib_bitmap bmp, __sklib_ bool __skreturn = bitmap_button(__skparam__bmp, __skparam__opts); return __sklib__to_int(__skreturn); } -int __sklib__bitmap_button__string_ref__bitmap(const __sklib_string label, __sklib_bitmap bmp) { - string __skparam__label = __sklib__to_string(label); +int __sklib__bitmap_button__string_ref__bitmap(const __sklib_string label_text, __sklib_bitmap bmp) { + string __skparam__label_text = __sklib__to_string(label_text); bitmap __skparam__bmp = __sklib__to_bitmap(bmp); - bool __skreturn = bitmap_button(__skparam__label, __skparam__bmp); + bool __skreturn = bitmap_button(__skparam__label_text, __skparam__bmp); return __sklib__to_int(__skreturn); } -int __sklib__bitmap_button__string_ref__bitmap__drawing_options(const __sklib_string label, __sklib_bitmap bmp, __sklib_drawing_options opts) { - string __skparam__label = __sklib__to_string(label); +int __sklib__bitmap_button__string_ref__bitmap__drawing_options(const __sklib_string label_text, __sklib_bitmap bmp, __sklib_drawing_options opts) { + string __skparam__label_text = __sklib__to_string(label_text); bitmap __skparam__bmp = __sklib__to_bitmap(bmp); drawing_options __skparam__opts = __sklib__to_drawing_options(opts); - bool __skreturn = bitmap_button(__skparam__label, __skparam__bmp, __skparam__opts); + bool __skreturn = bitmap_button(__skparam__label_text, __skparam__bmp, __skparam__opts); return __sklib__to_int(__skreturn); } int __sklib__button__string_ref__rectangle_ref(const __sklib_string text, const __sklib_rectangle rect) { @@ -2379,10 +2399,10 @@ int __sklib__button__string_ref(const __sklib_string text) { bool __skreturn = button(__skparam__text); return __sklib__to_int(__skreturn); } -int __sklib__button__string_ref__string_ref(const __sklib_string label, const __sklib_string text) { - string __skparam__label = __sklib__to_string(label); +int __sklib__button__string_ref__string_ref(const __sklib_string label_text, const __sklib_string text) { + string __skparam__label_text = __sklib__to_string(label_text); string __skparam__text = __sklib__to_string(text); - bool __skreturn = button(__skparam__label, __skparam__text); + bool __skreturn = button(__skparam__label_text, __skparam__text); return __sklib__to_int(__skreturn); } int __sklib__checkbox__string_ref__bool_ref__rectangle_ref(const __sklib_string text, const int value, const __sklib_rectangle rect) { @@ -2398,11 +2418,11 @@ int __sklib__checkbox__string_ref__bool_ref(const __sklib_string text, const int bool __skreturn = checkbox(__skparam__text, __skparam__value); return __sklib__to_int(__skreturn); } -int __sklib__checkbox__string_ref__string_ref__bool_ref(const __sklib_string label, const __sklib_string text, const int value) { - string __skparam__label = __sklib__to_string(label); +int __sklib__checkbox__string_ref__string_ref__bool_ref(const __sklib_string label_text, const __sklib_string text, const int value) { + string __skparam__label_text = __sklib__to_string(label_text); string __skparam__text = __sklib__to_string(text); bool __skparam__value = __sklib__to_bool(value); - bool __skreturn = checkbox(__skparam__label, __skparam__text, __skparam__value); + bool __skreturn = checkbox(__skparam__label_text, __skparam__text, __skparam__value); return __sklib__to_int(__skreturn); } __sklib_color __sklib__color_slider__color_ref__rectangle_ref(const __sklib_color clr, const __sklib_rectangle rect) { @@ -2416,10 +2436,10 @@ __sklib_color __sklib__color_slider__color_ref(const __sklib_color clr) { color __skreturn = color_slider(__skparam__clr); return __sklib__to_sklib_color(__skreturn); } -__sklib_color __sklib__color_slider__string_ref__color_ref(const __sklib_string label, const __sklib_color clr) { - string __skparam__label = __sklib__to_string(label); +__sklib_color __sklib__color_slider__string_ref__color_ref(const __sklib_string label_text, const __sklib_color clr) { + string __skparam__label_text = __sklib__to_string(label_text); color __skparam__clr = __sklib__to_color(clr); - color __skreturn = color_slider(__skparam__label, __skparam__clr); + color __skreturn = color_slider(__skparam__label_text, __skparam__clr); return __sklib__to_sklib_color(__skreturn); } void __sklib__disable_interface() { @@ -2443,9 +2463,9 @@ void __sklib__end_popup__string_ref(const __sklib_string name) { string __skparam__name = __sklib__to_string(name); end_popup(__skparam__name); } -void __sklib__end_treenode__string_ref(const __sklib_string label) { - string __skparam__label = __sklib__to_string(label); - end_treenode(__skparam__label); +void __sklib__end_treenode__string_ref(const __sklib_string label_text) { + string __skparam__label_text = __sklib__to_string(label_text); + end_treenode(__skparam__label_text); } void __sklib__enter_column() { enter_column(); @@ -2454,9 +2474,9 @@ int __sklib__get_interface_label_width() { int __skreturn = get_interface_label_width(); return __sklib__to_int(__skreturn); } -int __sklib__header__string_ref(const __sklib_string label) { - string __skparam__label = __sklib__to_string(label); - bool __skreturn = header(__skparam__label); +int __sklib__header__string_ref(const __sklib_string label_text) { + string __skparam__label_text = __sklib__to_string(label_text); + bool __skreturn = header(__skparam__label_text); return __sklib__to_int(__skreturn); } __sklib_color __sklib__hsb_color_slider__color_ref__rectangle_ref(const __sklib_color clr, const __sklib_rectangle rect) { @@ -2470,10 +2490,10 @@ __sklib_color __sklib__hsb_color_slider__color_ref(const __sklib_color clr) { color __skreturn = hsb_color_slider(__skparam__clr); return __sklib__to_sklib_color(__skreturn); } -__sklib_color __sklib__hsb_color_slider__string_ref__color_ref(const __sklib_string label, const __sklib_color clr) { - string __skparam__label = __sklib__to_string(label); +__sklib_color __sklib__hsb_color_slider__string_ref__color_ref(const __sklib_string label_text, const __sklib_color clr) { + string __skparam__label_text = __sklib__to_string(label_text); color __skparam__clr = __sklib__to_color(clr); - color __skreturn = hsb_color_slider(__skparam__label, __skparam__clr); + color __skreturn = hsb_color_slider(__skparam__label_text, __skparam__clr); return __sklib__to_sklib_color(__skreturn); } int __sklib__interface_enabled() { @@ -2484,14 +2504,14 @@ void __sklib__interface_style_panel__rectangle_ref(const __sklib_rectangle initi rectangle __skparam__initial_rectangle = __sklib__to_rectangle(initial_rectangle); interface_style_panel(__skparam__initial_rectangle); } -void __sklib__label__string_ref(const __sklib_string text) { +void __sklib__label_element__string_ref(const __sklib_string text) { string __skparam__text = __sklib__to_string(text); - label(__skparam__text); + label_element(__skparam__text); } -void __sklib__label__string_ref__rectangle_ref(const __sklib_string text, const __sklib_rectangle rect) { +void __sklib__label_element__string_ref__rectangle_ref(const __sklib_string text, const __sklib_rectangle rect) { string __skparam__text = __sklib__to_string(text); rectangle __skparam__rect = __sklib__to_rectangle(rect); - label(__skparam__text, __skparam__rect); + label_element(__skparam__text, __skparam__rect); } int __sklib__last_element_changed() { bool __skreturn = last_element_changed(); @@ -2517,11 +2537,11 @@ float __sklib__number_box__float_ref__float(const float value, float step) { float __skreturn = number_box(__skparam__value, __skparam__step); return __sklib__to_float(__skreturn); } -float __sklib__number_box__string_ref__float_ref__float(const __sklib_string label, const float value, float step) { - string __skparam__label = __sklib__to_string(label); +float __sklib__number_box__string_ref__float_ref__float(const __sklib_string label_text, const float value, float step) { + string __skparam__label_text = __sklib__to_string(label_text); float __skparam__value = __sklib__to_float(value); float __skparam__step = __sklib__to_float(step); - float __skreturn = number_box(__skparam__label, __skparam__value, __skparam__step); + float __skreturn = number_box(__skparam__label_text, __skparam__value, __skparam__step); return __sklib__to_float(__skreturn); } void __sklib__open_popup__string_ref(const __sklib_string name) { @@ -2640,12 +2660,12 @@ float __sklib__slider__float_ref__float__float(const float value, float min_valu float __skreturn = slider(__skparam__value, __skparam__min_value, __skparam__max_value); return __sklib__to_float(__skreturn); } -float __sklib__slider__string_ref__float_ref__float__float(const __sklib_string label, const float value, float min_value, float max_value) { - string __skparam__label = __sklib__to_string(label); +float __sklib__slider__string_ref__float_ref__float__float(const __sklib_string label_text, const float value, float min_value, float max_value) { + string __skparam__label_text = __sklib__to_string(label_text); float __skparam__value = __sklib__to_float(value); float __skparam__min_value = __sklib__to_float(min_value); float __skparam__max_value = __sklib__to_float(max_value); - float __skreturn = slider(__skparam__label, __skparam__value, __skparam__min_value, __skparam__max_value); + float __skreturn = slider(__skparam__label_text, __skparam__value, __skparam__min_value, __skparam__max_value); return __sklib__to_float(__skreturn); } void __sklib__split_into_columns__int(int count) { @@ -2686,9 +2706,9 @@ int __sklib__start_popup__string_ref(const __sklib_string name) { bool __skreturn = start_popup(__skparam__name); return __sklib__to_int(__skreturn); } -int __sklib__start_treenode__string_ref(const __sklib_string label) { - string __skparam__label = __sklib__to_string(label); - bool __skreturn = start_treenode(__skparam__label); +int __sklib__start_treenode__string_ref(const __sklib_string label_text) { + string __skparam__label_text = __sklib__to_string(label_text); + bool __skreturn = start_treenode(__skparam__label_text); return __sklib__to_int(__skreturn); } __sklib_string __sklib__text_box__string_ref(const __sklib_string value) { @@ -2702,10 +2722,10 @@ __sklib_string __sklib__text_box__string_ref__rectangle_ref(const __sklib_string string __skreturn = text_box(__skparam__value, __skparam__rect); return __sklib__to_sklib_string(__skreturn); } -__sklib_string __sklib__text_box__string_ref__string_ref(const __sklib_string label, const __sklib_string value) { - string __skparam__label = __sklib__to_string(label); +__sklib_string __sklib__text_box__string_ref__string_ref(const __sklib_string label_text, const __sklib_string value) { + string __skparam__label_text = __sklib__to_string(label_text); string __skparam__value = __sklib__to_string(value); - string __skreturn = text_box(__skparam__label, __skparam__value); + string __skreturn = text_box(__skparam__label_text, __skparam__value); return __sklib__to_sklib_string(__skreturn); } __sklib_json __sklib__create_json() { @@ -3418,9 +3438,9 @@ int __sklib__music_valid__music(__sklib_music m) { bool __skreturn = music_valid(__skparam__m); return __sklib__to_int(__skreturn); } -float __sklib__music_volume() { - float __skreturn = music_volume(); - return __sklib__to_float(__skreturn); +double __sklib__music_volume() { + double __skreturn = music_volume(); + return __sklib__to_double(__skreturn); } void __sklib__pause_music() { pause_music(); @@ -3443,17 +3463,17 @@ void __sklib__play_music__music__int(__sklib_music data, int times) { int __skparam__times = __sklib__to_int(times); play_music(__skparam__data, __skparam__times); } -void __sklib__play_music__music__int__float(__sklib_music data, int times, float volume) { +void __sklib__play_music__music__int__double(__sklib_music data, int times, double volume) { music __skparam__data = __sklib__to_music(data); int __skparam__times = __sklib__to_int(times); - float __skparam__volume = __sklib__to_float(volume); + double __skparam__volume = __sklib__to_double(volume); play_music(__skparam__data, __skparam__times, __skparam__volume); } void __sklib__resume_music() { resume_music(); } -void __sklib__set_music_volume__float(float volume) { - float __skparam__volume = __sklib__to_float(volume); +void __sklib__set_music_volume__double(double volume) { + double __skparam__volume = __sklib__to_double(volume); set_music_volume(__skparam__volume); } void __sklib__stop_music() { @@ -4609,9 +4629,9 @@ void __sklib__play_sound_effect__string_ref(const __sklib_string name) { string __skparam__name = __sklib__to_string(name); play_sound_effect(__skparam__name); } -void __sklib__play_sound_effect__string_ref__float(const __sklib_string name, float volume) { +void __sklib__play_sound_effect__string_ref__double(const __sklib_string name, double volume) { string __skparam__name = __sklib__to_string(name); - float __skparam__volume = __sklib__to_float(volume); + double __skparam__volume = __sklib__to_double(volume); play_sound_effect(__skparam__name, __skparam__volume); } void __sklib__play_sound_effect__string_ref__int(const __sklib_string name, int times) { @@ -4619,19 +4639,19 @@ void __sklib__play_sound_effect__string_ref__int(const __sklib_string name, int int __skparam__times = __sklib__to_int(times); play_sound_effect(__skparam__name, __skparam__times); } -void __sklib__play_sound_effect__string_ref__int__float(const __sklib_string name, int times, float volume) { +void __sklib__play_sound_effect__string_ref__int__double(const __sklib_string name, int times, double volume) { string __skparam__name = __sklib__to_string(name); int __skparam__times = __sklib__to_int(times); - float __skparam__volume = __sklib__to_float(volume); + double __skparam__volume = __sklib__to_double(volume); play_sound_effect(__skparam__name, __skparam__times, __skparam__volume); } void __sklib__play_sound_effect__sound_effect(__sklib_sound_effect effect) { sound_effect __skparam__effect = __sklib__to_sound_effect(effect); play_sound_effect(__skparam__effect); } -void __sklib__play_sound_effect__sound_effect__float(__sklib_sound_effect effect, float volume) { +void __sklib__play_sound_effect__sound_effect__double(__sklib_sound_effect effect, double volume) { sound_effect __skparam__effect = __sklib__to_sound_effect(effect); - float __skparam__volume = __sklib__to_float(volume); + double __skparam__volume = __sklib__to_double(volume); play_sound_effect(__skparam__effect, __skparam__volume); } void __sklib__play_sound_effect__sound_effect__int(__sklib_sound_effect effect, int times) { @@ -4639,10 +4659,10 @@ void __sklib__play_sound_effect__sound_effect__int(__sklib_sound_effect effect, int __skparam__times = __sklib__to_int(times); play_sound_effect(__skparam__effect, __skparam__times); } -void __sklib__play_sound_effect__sound_effect__int__float(__sklib_sound_effect effect, int times, float volume) { +void __sklib__play_sound_effect__sound_effect__int__double(__sklib_sound_effect effect, int times, double volume) { sound_effect __skparam__effect = __sklib__to_sound_effect(effect); int __skparam__times = __sklib__to_int(times); - float __skparam__volume = __sklib__to_float(volume); + double __skparam__volume = __sklib__to_double(volume); play_sound_effect(__skparam__effect, __skparam__times, __skparam__volume); } __sklib_string __sklib__sound_effect_filename__sound_effect(__sklib_sound_effect effect) { @@ -6217,9 +6237,9 @@ double __sklib__vector_magnitude__vector_2d_ref(const __sklib_vector_2d v) { double __skreturn = vector_magnitude(__skparam__v); return __sklib__to_double(__skreturn); } -double __sklib__vector_magnitude_sqared__vector_2d_ref(const __sklib_vector_2d v) { +double __sklib__vector_magnitude_squared__vector_2d_ref(const __sklib_vector_2d v) { vector_2d __skparam__v = __sklib__to_vector_2d(v); - double __skreturn = vector_magnitude_sqared(__skparam__v); + double __skreturn = vector_magnitude_squared(__skparam__v); return __sklib__to_double(__skreturn); } __sklib_vector_2d __sklib__vector_multiply__vector_2d_ref__double(const __sklib_vector_2d v1, double s) { diff --git a/source/sound.cpp b/source/sound.cpp index 217022a..1509feb 100644 --- a/source/sound.cpp +++ b/source/sound.cpp @@ -128,7 +128,7 @@ namespace splashkit_lib return VALID_PTR(effect, AUDIO_PTR); } - void play_sound_effect(sound_effect effect, int times, float volume) + void play_sound_effect(sound_effect effect, int times, double volume) { if (not audio_ready()) return; @@ -163,12 +163,12 @@ namespace splashkit_lib play_sound_effect(effect, times, 1.0f); } - void play_sound_effect(sound_effect effect, float volume) + void play_sound_effect(sound_effect effect, double volume) { play_sound_effect(effect, 1, volume); } - void play_sound_effect(const string &name, int times, float volume) + void play_sound_effect(const string &name, int times, double volume) { play_sound_effect(sound_effect_named(name), times, volume); } @@ -183,7 +183,7 @@ namespace splashkit_lib play_sound_effect(sound_effect_named(name), 1, 1.0f); } - void play_sound_effect(const string &name, float volume) + void play_sound_effect(const string &name, double volume) { play_sound_effect(sound_effect_named(name), 1, volume); } diff --git a/source/sprites.cpp b/source/sprites.cpp index 825ca0a..d7df7b4 100644 --- a/source/sprites.cpp +++ b/source/sprites.cpp @@ -231,7 +231,7 @@ namespace splashkit_lib result->last_update = timer_ticks(_sprite_timer); // Write_ln("adding for ", name, " ", Hex_str(obj)); - _sprites[name] = result; + _sprites[sn] = result; current_pack().push_back(result); @@ -1023,8 +1023,8 @@ namespace splashkit_lib if (s->position_at_anchor_point) { - s->position.x += s->anchor_point.x; - s->position.y += s->anchor_point.y; + s->position.x -= s->anchor_point.x; + s->position.y -= s->anchor_point.y; } } @@ -1558,6 +1558,10 @@ namespace splashkit_lib // TODO: Temporarily do not call due to 70c30d4 vector &pack = _sprite_packs[name]; _call_for_all_sprites(pack, &_free_sprite); + if (name == _current_pack) + { + _current_pack = INITIAL_PACK_NAME; + } _sprite_packs.erase(name); } diff --git a/source/terminal.cpp b/source/terminal.cpp index 468e141..0a1c29e 100644 --- a/source/terminal.cpp +++ b/source/terminal.cpp @@ -71,6 +71,8 @@ namespace splashkit_lib string read_line() { string result; + cin.clear(); + cin.sync(); getline(std::cin, result); return result; } @@ -78,7 +80,10 @@ namespace splashkit_lib char read_char() { char result = 0; + cin.clear(); + cin.sync(); cin >> result; + cin.ignore(std::numeric_limits::max(), '\n'); return result; } diff --git a/source/text_driver.cpp b/source/text_driver.cpp index 7e188f3..5113aa1 100644 --- a/source/text_driver.cpp +++ b/source/text_driver.cpp @@ -241,6 +241,7 @@ namespace splashkit_lib sk_color clr ) { internal_sk_init(); + gfxPrimitivesSetFont(nullptr, 0, 0); unsigned int count = _sk_renderer_count(surface); for (unsigned int i = 0; i < count; i++) diff --git a/source/text_input.cpp b/source/text_input.cpp index bb8e788..ebfcc76 100644 --- a/source/text_input.cpp +++ b/source/text_input.cpp @@ -124,7 +124,7 @@ namespace splashkit_lib LOG(WARNING) << "Ending reading text with invalid window"; return; } - + sk_end_reading_text(); wind->reading_text = false; } } diff --git a/source/utils.cpp b/source/utils.cpp index 2facd53..4ddd5cd 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -36,7 +36,7 @@ namespace splashkit_lib else { unsigned int t; - for (t = 1; t < milliseconds / 50; t++) + for (t = 0; t < milliseconds / 50; t++) { if ( number_open_windows() > 0 ) { diff --git a/source/vector_2d.cpp b/source/vector_2d.cpp index bc01381..930cfea 100644 --- a/source/vector_2d.cpp +++ b/source/vector_2d.cpp @@ -132,14 +132,14 @@ namespace splashkit_lib return { -v.y / magnitude, v.x / magnitude }; } - double vector_magnitude_sqared(const vector_2d &v) + double vector_magnitude_squared(const vector_2d &v) { return (v.x * v.x) + (v.y * v.y); } double vector_magnitude(const vector_2d &v) { - return sqrt(vector_magnitude_sqared(v)); + return sqrt(vector_magnitude_squared(v)); } vector_2d vector_limit(const vector_2d &v, double limit) diff --git a/source/window_manager.cpp b/source/window_manager.cpp index 66157d1..6a60b21 100644 --- a/source/window_manager.cpp +++ b/source/window_manager.cpp @@ -183,6 +183,7 @@ namespace splashkit_lib void close_all_windows() { FREE_ALL_FROM_MAP(_windows, WINDOW_PTR, close_window); + _sk_destroy_initial_window(); } bool has_window(string caption) From 21147f0dc9222620d4fc9b5af75f16586c192d68 Mon Sep 17 00:00:00 2001 From: NoahJCross Date: Tue, 7 Jan 2025 04:54:25 +1100 Subject: [PATCH 2/6] added equality operators to structs --- .vscode/settings.json | 5 ++ clang++/include/types.h | 111 +++++++++++++++++++++++++++++++++++ g++/include/types.h | 111 +++++++++++++++++++++++++++++++++++ source/clipping.cpp | 4 +- source/utility_functions.cpp | 3 +- source/vector_2d.cpp | 4 +- 6 files changed, 234 insertions(+), 4 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..530faa5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "xstring": "cpp" + } +} diff --git a/clang++/include/types.h b/clang++/include/types.h index 54e9201..252cd92 100644 --- a/clang++/include/types.h +++ b/clang++/include/types.h @@ -126,22 +126,70 @@ typedef struct { double x; double y; } point_2d; + +inline bool operator==(const point_2d& lhs, const point_2d& rhs) { + return + lhs.x == rhs.x && + lhs.y == rhs.y; +} + +inline bool operator!=(const point_2d& lhs, const point_2d& rhs) { + return !(lhs == rhs); +} + typedef struct { point_2d center; double radius; } circle; + +inline bool operator==(const circle& lhs, const circle& rhs) { + return + lhs.center == rhs.center && + lhs.radius == rhs.radius; +} + +inline bool operator!=(const circle& lhs, const circle& rhs) { + return !(lhs == rhs); +} + typedef struct { float r; float g; float b; float a; } color; + +inline bool operator==(const color& lhs, const color& rhs) { + return + lhs.r == rhs.r && + lhs.g == rhs.g && + lhs.b == rhs.b && + lhs.a == rhs.a; +} + +inline bool operator!=(const color& lhs, const color& rhs) { + return !(lhs == rhs); +} + typedef struct { double x; double y; double width; double height; } rectangle; + +inline bool operator==(const rectangle& lhs, const rectangle& rhs) { + return + lhs.x == rhs.x && + lhs.y == rhs.y && + lhs.width == rhs.width && + lhs.height == rhs.height; +} + +inline bool operator!=(const rectangle& lhs, const rectangle& rhs) { + return !(lhs == rhs); +} + typedef struct { void *dest; float scale_x; @@ -158,19 +206,82 @@ typedef struct { int line_width; animation anim; } drawing_options; + +inline bool operator==(const drawing_options& lhs, const drawing_options& rhs) { + return + lhs.dest == rhs.dest && + lhs.scale_x == rhs.scale_x && + lhs.scale_y == rhs.scale_y && + lhs.angle == rhs.angle && + lhs.anchor_offset_x == rhs.anchor_offset_x && + lhs.anchor_offset_y == rhs.anchor_offset_y && + lhs.flip_x == rhs.flip_x && + lhs.flip_y == rhs.flip_y && + lhs.is_part == rhs.is_part && + lhs.part == rhs.part && + lhs.draw_cell == rhs.draw_cell && + lhs.camera == rhs.camera && + lhs.line_width == rhs.line_width && + lhs.anim == rhs.anim; +} + +inline bool operator!=(const drawing_options& lhs, const drawing_options& rhs) { + return !(lhs == rhs); +} + typedef struct { point_2d start_point; point_2d end_point; } line; + +inline bool operator==(const line& lhs, const line& rhs) { + return + lhs.start_point == rhs.start_point && + lhs.end_point == rhs.end_point; +} + +inline bool operator!=(const line& lhs, const line& rhs) { + return !(lhs == rhs); +} + typedef struct { point_2d points[4]; } quad; + +inline bool operator==(const quad& lhs, const quad& rhs) { + return + lhs.points[0] == rhs.points[0] && lhs.points[1] == rhs.points[1] && lhs.points[2] == rhs.points[2] && lhs.points[3] == rhs.points[3];} + +inline bool operator!=(const quad& lhs, const quad& rhs) { + return !(lhs == rhs); +} + typedef struct { point_2d points[3]; } triangle; + +inline bool operator==(const triangle& lhs, const triangle& rhs) { + return + lhs.points[0] == rhs.points[0] && lhs.points[1] == rhs.points[1] && lhs.points[2] == rhs.points[2];} + +inline bool operator!=(const triangle& lhs, const triangle& rhs) { + return !(lhs == rhs); +} + typedef struct { double x; double y; } vector_2d; +inline bool operator==(const vector_2d& lhs, const vector_2d& rhs) { + return + lhs.x == rhs.x && + lhs.y == rhs.y; +} + +inline bool operator!=(const vector_2d& lhs, const vector_2d& rhs) { + return !(lhs == rhs); +} + + #endif /* __types_h */ diff --git a/g++/include/types.h b/g++/include/types.h index 54e9201..252cd92 100644 --- a/g++/include/types.h +++ b/g++/include/types.h @@ -126,22 +126,70 @@ typedef struct { double x; double y; } point_2d; + +inline bool operator==(const point_2d& lhs, const point_2d& rhs) { + return + lhs.x == rhs.x && + lhs.y == rhs.y; +} + +inline bool operator!=(const point_2d& lhs, const point_2d& rhs) { + return !(lhs == rhs); +} + typedef struct { point_2d center; double radius; } circle; + +inline bool operator==(const circle& lhs, const circle& rhs) { + return + lhs.center == rhs.center && + lhs.radius == rhs.radius; +} + +inline bool operator!=(const circle& lhs, const circle& rhs) { + return !(lhs == rhs); +} + typedef struct { float r; float g; float b; float a; } color; + +inline bool operator==(const color& lhs, const color& rhs) { + return + lhs.r == rhs.r && + lhs.g == rhs.g && + lhs.b == rhs.b && + lhs.a == rhs.a; +} + +inline bool operator!=(const color& lhs, const color& rhs) { + return !(lhs == rhs); +} + typedef struct { double x; double y; double width; double height; } rectangle; + +inline bool operator==(const rectangle& lhs, const rectangle& rhs) { + return + lhs.x == rhs.x && + lhs.y == rhs.y && + lhs.width == rhs.width && + lhs.height == rhs.height; +} + +inline bool operator!=(const rectangle& lhs, const rectangle& rhs) { + return !(lhs == rhs); +} + typedef struct { void *dest; float scale_x; @@ -158,19 +206,82 @@ typedef struct { int line_width; animation anim; } drawing_options; + +inline bool operator==(const drawing_options& lhs, const drawing_options& rhs) { + return + lhs.dest == rhs.dest && + lhs.scale_x == rhs.scale_x && + lhs.scale_y == rhs.scale_y && + lhs.angle == rhs.angle && + lhs.anchor_offset_x == rhs.anchor_offset_x && + lhs.anchor_offset_y == rhs.anchor_offset_y && + lhs.flip_x == rhs.flip_x && + lhs.flip_y == rhs.flip_y && + lhs.is_part == rhs.is_part && + lhs.part == rhs.part && + lhs.draw_cell == rhs.draw_cell && + lhs.camera == rhs.camera && + lhs.line_width == rhs.line_width && + lhs.anim == rhs.anim; +} + +inline bool operator!=(const drawing_options& lhs, const drawing_options& rhs) { + return !(lhs == rhs); +} + typedef struct { point_2d start_point; point_2d end_point; } line; + +inline bool operator==(const line& lhs, const line& rhs) { + return + lhs.start_point == rhs.start_point && + lhs.end_point == rhs.end_point; +} + +inline bool operator!=(const line& lhs, const line& rhs) { + return !(lhs == rhs); +} + typedef struct { point_2d points[4]; } quad; + +inline bool operator==(const quad& lhs, const quad& rhs) { + return + lhs.points[0] == rhs.points[0] && lhs.points[1] == rhs.points[1] && lhs.points[2] == rhs.points[2] && lhs.points[3] == rhs.points[3];} + +inline bool operator!=(const quad& lhs, const quad& rhs) { + return !(lhs == rhs); +} + typedef struct { point_2d points[3]; } triangle; + +inline bool operator==(const triangle& lhs, const triangle& rhs) { + return + lhs.points[0] == rhs.points[0] && lhs.points[1] == rhs.points[1] && lhs.points[2] == rhs.points[2];} + +inline bool operator!=(const triangle& lhs, const triangle& rhs) { + return !(lhs == rhs); +} + typedef struct { double x; double y; } vector_2d; +inline bool operator==(const vector_2d& lhs, const vector_2d& rhs) { + return + lhs.x == rhs.x && + lhs.y == rhs.y; +} + +inline bool operator!=(const vector_2d& lhs, const vector_2d& rhs) { + return !(lhs == rhs); +} + + #endif /* __types_h */ diff --git a/source/clipping.cpp b/source/clipping.cpp index d26c48f..9e37bff 100644 --- a/source/clipping.cpp +++ b/source/clipping.cpp @@ -119,7 +119,7 @@ namespace splashkit_lib if ( img.clip_stack.size() > 0 ) { - rectangle clip_rect = *img.clip_stack.back(); + rectangle clip_rect = img.clip_stack.back(); sk_set_clip_rect(&img.surface, clip_rect.x, clip_rect.y, clip_rect.width, clip_rect.height); } else @@ -158,7 +158,7 @@ namespace splashkit_lib rectangle _current_clip(const image_data &img) { if (img.clip_stack.size() > 0) - return *img.clip_stack.back(); + return img.clip_stack.back(); else return rectangle_from(0, 0, img.surface.width, img.surface.height); } diff --git a/source/utility_functions.cpp b/source/utility_functions.cpp index def71f7..6cc4a6d 100644 --- a/source/utility_functions.cpp +++ b/source/utility_functions.cpp @@ -129,7 +129,8 @@ namespace splashkit_lib if(elem.find(PATH_SEP) == 0 and not first) elem.erase(0,1); result += elem; - if(elem.find_last_of(PATH_SEP) < elem.length() - 1) + size_t last_sep = elem.find_last_of(PATH_SEP); + if (last_sep == string::npos || last_sep < elem.length() - 1) result += PATH_SEP; first = false; diff --git a/source/vector_2d.cpp b/source/vector_2d.cpp index 930cfea..6ba31bc 100644 --- a/source/vector_2d.cpp +++ b/source/vector_2d.cpp @@ -116,7 +116,9 @@ namespace splashkit_lib double angle_between(const vector_2d &v1, const vector_2d &v2) { - return vector_angle( vector_subtract(v2, v1) ); + double dot = dot_product(v1, v2); + double det = v1.x * v2.y - v1.y * v2.x; + return rad_to_deg(atan2(det, dot)); } vector_2d vector_normal(const vector_2d &v) From 7c9d1a599fe69793ff83eb6cae7ca1aa12b27a63 Mon Sep 17 00:00:00 2001 From: NoahJCross Date: Tue, 7 Jan 2025 06:33:35 +1100 Subject: [PATCH 3/6] updated all color constants to use byte-value division --- source/color.cpp | 358 +++++++++++++++++++++++------------------------ 1 file changed, 179 insertions(+), 179 deletions(-) diff --git a/source/color.cpp b/source/color.cpp index 372b1fa..9cb79de 100644 --- a/source/color.cpp +++ b/source/color.cpp @@ -257,726 +257,726 @@ namespace splashkit_lib color color_gray() { - return rgba_color(0.5f, 0.5f, 0.5f, 1.0f); + return rgba_color(127/255.0, 127/255.0, 127/255.0, 1.0); } color color_light_grey() { - return rgba_color(0.784313f, 0.784313f, 0.784313f, 1.0f); + return rgba_color(200/255.0, 200/255.0, 200/255.0, 1.0); } color color_transparent() { - return rgba_color(1.0f, 1.0f, 1.0f, 1.0f); + return rgba_color(255/255.0, 255/255.0, 255/255.0, 1.0); } color color_alice_blue() { - return rgba_color(240 / 255.0f, 248 / 255.0f, 1.0f, 1.0f); + return rgba_color(240/255.0, 248/255.0, 255/255.0, 1.0); } color color_antique_white() { - return rgba_color(250 / 255.0f, 235 / 255.0f, 215 / 255.0f, 1.0f); + return rgba_color(250/255.0, 235/255.0, 215/255.0, 1.0); } color color_aqua() { - return rgba_color(0 / 255.0f, 1.0f, 1.0f, 1.0f); + return rgba_color(0/255.0, 255/255.0, 255/255.0, 1.0); } color color_aquamarine() { - return rgba_color(127 / 255.0f, 1.0f, 212 / 255.0f, 1.0f); + return rgba_color(127/255.0, 255/255.0, 212/255.0, 1.0); } color color_azure() { - return rgba_color(240 / 255.0f, 1.0f, 1.0f, 1.0f); + return rgba_color(240/255.0, 255/255.0, 255/255.0, 1.0); } color color_beige() { - return rgba_color(245 / 255.0f, 245 / 255.0f, 220 / 255.0f, 1.0f); + return rgba_color(245/255.0, 245/255.0, 220/255.0, 1.0); } color color_bisque() { - return rgba_color(1.0f, 228 / 255.0f, 196 / 255.0f, 1.0f); + return rgba_color(255/255.0, 228/255.0, 196/255.0, 1.0); } color color_black() { - return rgba_color(0 / 255.0f, 0 / 255.0f, 0 / 255.0f, 1.0f); + return rgba_color(0/255.0, 0/255.0, 0/255.0, 1.0); } color color_blanched_almond() { - return rgba_color(1.0f, 235 / 255.0f, 205 / 255.0f, 1.0f); + return rgba_color(255/255.0, 235/255.0, 205/255.0, 1.0); } color color_blue() { - return rgba_color(0 / 255.0f, 0 / 255.0f, 1.0f, 1.0f); + return rgba_color(0/255.0, 0/255.0, 255/255.0, 1.0); } color color_blue_violet() { - return rgba_color(138 / 255.0f, 43 / 255.0f, 226 / 255.0f, 1.0f); + return rgba_color(138/255.0, 43/255.0, 226/255.0, 1.0); } color color_brown() { - return rgba_color(165 / 255.0f, 42 / 255.0f, 42 / 255.0f, 1.0f); + return rgba_color(165/255.0, 42/255.0, 42/255.0, 1.0); } color color_burly_wood() { - return rgba_color(222 / 255.0f, 184 / 255.0f, 135 / 255.0f, 1.0f); + return rgba_color(222/255.0, 184/255.0, 135/255.0, 1.0); } color color_cadet_blue() { - return rgba_color(95 / 255.0f, 158 / 255.0f, 160 / 255.0f, 1.0f); + return rgba_color(95/255.0, 158/255.0, 160/255.0, 1.0); } color color_chartreuse() { - return rgba_color(127 / 255.0f, 1.0f, 0 / 255.0f, 1.0f); + return rgba_color(127/255.0, 255/255.0, 0/255.0, 1.0); } color color_chocolate() { - return rgba_color(210 / 255.0f, 105 / 255.0f, 30 / 255.0f, 1.0f); + return rgba_color(210/255.0, 105/255.0, 30/255.0, 1.0); } color color_coral() { - return rgba_color(1.0f, 127 / 255.0f, 80 / 255.0f, 1.0f); + return rgba_color(255/255.0, 127/255.0, 80/255.0, 1.0); } color color_cornflower_blue() { - return rgba_color(100 / 255.0f, 149 / 255.0f, 237 / 255.0f, 1.0f); + return rgba_color(100/255.0, 149/255.0, 237/255.0, 1.0); } color color_cornsilk() { - return rgba_color(1.0f, 248 / 255.0f, 220 / 255.0f, 1.0f); + return rgba_color(255/255.0, 248/255.0, 220/255.0, 1.0); } color color_crimson() { - return rgba_color(220 / 255.0f, 20 / 255.0f, 60 / 255.0f, 1.0f); + return rgba_color(220/255.0, 20/255.0, 60/255.0, 1.0); } color color_cyan() { - return rgba_color(0 / 255.0f, 1.0f, 1.0f, 1.0f); + return rgba_color(0/255.0, 255/255.0, 255/255.0, 1.0); } color color_dark_blue() { - return rgba_color(0 / 255.0f, 0 / 255.0f, 139 / 255.0f, 1.0f); + return rgba_color(0/255.0, 0/255.0, 139/255.0, 1.0); } color color_dark_cyan() { - return rgba_color(0 / 255.0f, 139 / 255.0f, 139 / 255.0f, 1.0f); + return rgba_color(0/255.0, 139/255.0, 139/255.0, 1.0); } color color_dark_goldenrod() { - return rgba_color(184 / 255.0f, 134 / 255.0f, 11 / 255.0f, 1.0f); + return rgba_color(184/255.0, 134/255.0, 11/255.0, 1.0); } color color_dark_gray() { - return rgba_color(169 / 255.0f, 169 / 255.0f, 169 / 255.0f, 1.0f); + return rgba_color(169/255.0, 169/255.0, 169/255.0, 1.0); } color color_dark_green() { - return rgba_color(0 / 255.0f, 100 / 255.0f, 0 / 255.0f, 1.0f); + return rgba_color(0/255.0, 100/255.0, 0/255.0, 1.0); } color color_dark_khaki() { - return rgba_color(189 / 255.0f, 183 / 255.0f, 107 / 255.0f, 1.0f); + return rgba_color(189/255.0, 183/255.0, 107/255.0, 1.0); } color color_dark_magenta() { - return rgba_color(139 / 255.0f, 0 / 255.0f, 139 / 255.0f, 1.0f); + return rgba_color(139/255.0, 0/255.0, 139/255.0, 1.0); } color color_dark_olive_green() { - return rgba_color(85 / 255.0f, 107 / 255.0f, 47 / 255.0f, 1.0f); + return rgba_color(85/255.0, 107/255.0, 47/255.0, 1.0); } color color_dark_orange() { - return rgba_color(1.0f, 140 / 255.0f, 0 / 255.0f, 1.0f); + return rgba_color(255/255.0, 140/255.0, 0/255.0, 1.0); } color color_dark_orchid() { - return rgba_color(153 / 255.0f, 50 / 255.0f, 204 / 255.0f, 1.0f); + return rgba_color(153/255.0, 50/255.0, 204/255.0, 1.0); } color color_dark_red() { - return rgba_color(139 / 255.0f, 0 / 255.0f, 0 / 255.0f, 1.0f); + return rgba_color(139/255.0, 0/255.0, 0/255.0, 1.0); } color color_dark_salmon() { - return rgba_color(233 / 255.0f, 150 / 255.0f, 122 / 255.0f, 1.0f); + return rgba_color(233/255.0, 150/255.0, 122/255.0, 1.0); } color color_dark_sea_green() { - return rgba_color(143 / 255.0f, 188 / 255.0f, 139 / 255.0f, 1.0f); + return rgba_color(143/255.0, 188/255.0, 139/255.0, 1.0); } color color_dark_slate_blue() { - return rgba_color(72 / 255.0f, 61 / 255.0f, 139 / 255.0f, 1.0f); + return rgba_color(72/255.0, 61/255.0, 139/255.0, 1.0); } color color_dark_slate_gray() { - return rgba_color(47 / 255.0f, 79 / 255.0f, 79 / 255.0f, 1.0f); + return rgba_color(47/255.0, 79/255.0, 79/255.0, 1.0); } color color_dark_turquoise() { - return rgba_color(0 / 255.0f, 206 / 255.0f, 209 / 255.0f, 1.0f); + return rgba_color(0/255.0, 206/255.0, 209/255.0, 1.0); } color color_dark_violet() { - return rgba_color(148 / 255.0f, 0 / 255.0f, 211 / 255.0f, 1.0f); + return rgba_color(148/255.0, 0/255.0, 211/255.0, 1.0); } color color_deep_pink() { - return rgba_color(1.0f, 20 / 255.0f, 147 / 255.0f, 1.0f); + return rgba_color(255/255.0, 20/255.0, 147/255.0, 1.0); } color color_deep_sky_blue() { - return rgba_color(0 / 255.0f, 191 / 255.0f, 1.0f, 1.0f); + return rgba_color(0/255.0, 191/255.0, 255/255.0, 1.0); } color color_dim_gray() { - return rgba_color(105 / 255.0f, 105 / 255.0f, 105 / 255.0f, 1.0f); + return rgba_color(105/255.0, 105/255.0, 105/255.0, 1.0); } color color_dodger_blue() { - return rgba_color(30 / 255.0f, 144 / 255.0f, 1.0f, 1.0f); + return rgba_color(30/255.0, 144/255.0, 255/255.0, 1.0); } color color_firebrick() { - return rgba_color(178 / 255.0f, 34 / 255.0f, 34 / 255.0f, 1.0f); + return rgba_color(178/255.0, 34/255.0, 34/255.0, 1.0); } color color_floral_white() { - return rgba_color(1.0f, 250 / 255.0f, 240 / 255.0f, 1.0f); + return rgba_color(255/255.0, 250/255.0, 240/255.0, 1.0); } color color_forest_green() { - return rgba_color(34 / 255.0f, 139 / 255.0f, 34 / 255.0f, 1.0f); + return rgba_color(34/255.0, 139/255.0, 34/255.0, 1.0); } color color_fuchsia() { - return rgba_color(1.0f, 0 / 255.0f, 1.0f, 1.0f); + return rgba_color(255/255.0, 0/255.0, 255/255.0, 1.0); } color color_gainsboro() { - return rgba_color(220 / 255.0f, 220 / 255.0f, 220 / 255.0f, 1.0f); + return rgba_color(220/255.0, 220/255.0, 220/255.0, 1.0); } color color_ghost_white() { - return rgba_color(248 / 255.0f, 248 / 255.0f, 1.0f, 1.0f); + return rgba_color(248/255.0, 248/255.0, 255/255.0, 1.0); } color color_gold() { - return rgba_color(1.0f, 215 / 255.0f, 0 / 255.0f, 1.0f); + return rgba_color(255/255.0, 215/255.0, 0/255.0, 1.0); } color color_goldenrod() { - return rgba_color(218 / 255.0f, 165 / 255.0f, 32 / 255.0f, 1.0f); + return rgba_color(218/255.0, 165/255.0, 32/255.0, 1.0); } color color_grey() { - return rgba_color(0.5f, 0.5f, 0.5f, 1.0f); + return rgba_color(127/255.0, 127/255.0, 127/255.0, 1.0); } color color_green() { - return rgba_color(0 / 255.0f, 0.5f, 0 / 255.0f, 1.0f); + return rgba_color(0/255.0, 127/255.0, 0/255.0, 1.0); } color color_bright_green() { - return rgba_color(0 / 255.0f, 1.0f, 0 / 255.0f, 1.0f); + return rgba_color(0/255.0, 255/255.0, 0/255.0, 1.0); } color color_green_yellow() { - return rgba_color(173 / 255.0f, 1.0f, 47 / 255.0f, 1.0f); + return rgba_color(173/255.0, 255/255.0, 47/255.0, 1.0); } color color_honeydew() { - return rgba_color(240 / 255.0f, 1.0f, 240 / 255.0f, 1.0f); + return rgba_color(240/255.0, 255/255.0, 240/255.0, 1.0); } color color_hot_pink() { - return rgba_color(1.0f, 105 / 255.0f, 180 / 255.0f, 1.0f); + return rgba_color(255/255.0, 105/255.0, 180/255.0, 1.0); } color color_indian_red() { - return rgba_color(205 / 255.0f, 92 / 255.0f, 92 / 255.0f, 1.0f); + return rgba_color(205/255.0, 92/255.0, 92/255.0, 1.0); } color color_indigo() { - return rgba_color(75 / 255.0f, 0 / 255.0f, 130 / 255.0f, 1.0f); + return rgba_color(75/255.0, 0/255.0, 130/255.0, 1.0); } color color_ivory() { - return rgba_color(1.0f, 1.0f, 240 / 255.0f, 1.0f); + return rgba_color(255/255.0, 255/255.0, 240/255.0, 1.0); } color color_khaki() { - return rgba_color(240 / 255.0f, 230 / 255.0f, 140 / 255.0f, 1.0f); + return rgba_color(240/255.0, 230/255.0, 140/255.0, 1.0); } color color_lavender() { - return rgba_color(230 / 255.0f, 230 / 255.0f, 250 / 255.0f, 1.0f); + return rgba_color(230/255.0, 230/255.0, 250/255.0, 1.0); } color color_lavender_blush() { - return rgba_color(1.0f, 240 / 255.0f, 245 / 255.0f, 1.0f); + return rgba_color(255/255.0, 240/255.0, 245/255.0, 1.0); } color color_lawn_green() { - return rgba_color(124 / 255.0f, 252 / 255.0f, 0 / 255.0f, 1.0f); + return rgba_color(124/255.0, 252/255.0, 0/255.0, 1.0); } color color_lemon_chiffon() { - return rgba_color(1.0f, 250 / 255.0f, 205 / 255.0f, 1.0f); + return rgba_color(255/255.0, 250/255.0, 205/255.0, 1.0); } color color_light_blue() { - return rgba_color(173 / 255.0f, 216 / 255.0f, 230 / 255.0f, 1.0f); + return rgba_color(173/255.0, 216/255.0, 230/255.0, 1.0); } color color_light_coral() { - return rgba_color(240 / 255.0f, 0.5f, 0.5f, 1.0f); + return rgba_color(240/255.0, 127/255.0, 127/255.0, 1.0); } color color_light_cyan() { - return rgba_color(224 / 255.0f, 1.0f, 1.0f, 1.0f); + return rgba_color(224/255.0, 255/255.0, 255/255.0, 1.0); } color color_light_goldenrod_yellow() { - return rgba_color(250 / 255.0f, 250 / 255.0f, 210 / 255.0f, 1.0f); + return rgba_color(250/255.0, 250/255.0, 210/255.0, 1.0); } color color_light_green() { - return rgba_color(144 / 255.0f, 238 / 255.0f, 144 / 255.0f, 1.0f); + return rgba_color(144/255.0, 238/255.0, 144/255.0, 1.0); } color color_light_gray() { - return rgba_color(211 / 255.0f, 211 / 255.0f, 211 / 255.0f, 1.0f); + return rgba_color(211/255.0, 211/255.0, 211/255.0, 1.0); } color color_light_pink() { - return rgba_color(1.0f, 182 / 255.0f, 193 / 255.0f, 1.0f); + return rgba_color(255/255.0, 182/255.0, 193/255.0, 1.0); } color color_light_salmon() { - return rgba_color(1.0f, 160 / 255.0f, 122 / 255.0f, 1.0f); + return rgba_color(255/255.0, 160/255.0, 122/255.0, 1.0); } color color_light_sea_green() { - return rgba_color(32 / 255.0f, 178 / 255.0f, 170 / 255.0f, 1.0f); + return rgba_color(32/255.0, 178/255.0, 170/255.0, 1.0); } color color_light_sky_blue() { - return rgba_color(135 / 255.0f, 206 / 255.0f, 250 / 255.0f, 1.0f); + return rgba_color(135/255.0, 206/255.0, 250/255.0, 1.0); } color color_light_slate_gray() { - return rgba_color(119 / 255.0f, 136 / 255.0f, 153 / 255.0f, 1.0f); + return rgba_color(119/255.0, 136/255.0, 153/255.0, 1.0); } color color_light_steel_blue() { - return rgba_color(176 / 255.0f, 196 / 255.0f, 222 / 255.0f, 1.0f); + return rgba_color(176/255.0, 196/255.0, 222/255.0, 1.0); } color color_light_yellow() { - return rgba_color(1.0f, 1.0f, 224 / 255.0f, 1.0f); + return rgba_color(255/255.0, 255/255.0, 224/255.0, 1.0); } color color_lime() { - return rgba_color(0 / 255.0f, 1.0f, 0 / 255.0f, 1.0f); + return rgba_color(0/255.0, 255/255.0, 0/255.0, 1.0); } color color_lime_green() { - return rgba_color(50 / 255.0f, 205 / 255.0f, 50 / 255.0f, 1.0f); + return rgba_color(50/255.0, 205/255.0, 50/255.0, 1.0); } color color_linen() { - return rgba_color(250 / 255.0f, 240 / 255.0f, 230 / 255.0f, 1.0f); + return rgba_color(250/255.0, 240/255.0, 230/255.0, 1.0); } color color_magenta() { - return rgba_color(1.0f, 0 / 255.0f, 1.0f, 1.0f); + return rgba_color(255/255.0, 0/255.0, 255/255.0, 1.0); } color color_maroon() { - return rgba_color(0.5f, 0 / 255.0f, 0 / 255.0f, 1.0f); + return rgba_color(127/255.0, 0/255.0, 0/255.0, 1.0); } color color_medium_aquamarine() { - return rgba_color(102 / 255.0f, 205 / 255.0f, 170 / 255.0f, 1.0f); + return rgba_color(102/255.0, 205/255.0, 170/255.0, 1.0); } color color_medium_blue() { - return rgba_color(0 / 255.0f, 0 / 255.0f, 205 / 255.0f, 1.0f); + return rgba_color(0/255.0, 0/255.0, 205/255.0, 1.0); } color color_medium_orchid() { - return rgba_color(186 / 255.0f, 85 / 255.0f, 211 / 255.0f, 1.0f); + return rgba_color(186/255.0, 85/255.0, 211/255.0, 1.0); } color color_medium_purple() { - return rgba_color(147 / 255.0f, 112 / 255.0f, 219 / 255.0f, 1.0f); + return rgba_color(147/255.0, 112/255.0, 219/255.0, 1.0); } color color_medium_sea_green() { - return rgba_color(60 / 255.0f, 179 / 255.0f, 113 / 255.0f, 1.0f); + return rgba_color(60/255.0, 179/255.0, 113/255.0, 1.0); } color color_medium_slate_blue() { - return rgba_color(123 / 255.0f, 104 / 255.0f, 238 / 255.0f, 1.0f); + return rgba_color(123/255.0, 104/255.0, 238/255.0, 1.0); } color color_medium_spring_green() { - return rgba_color(0 / 255.0f, 250 / 255.0f, 154 / 255.0f, 1.0f); + return rgba_color(0/255.0, 250/255.0, 154/255.0, 1.0); } color color_medium_turquoise() { - return rgba_color(72 / 255.0f, 209 / 255.0f, 204 / 255.0f, 1.0f); + return rgba_color(72/255.0, 209/255.0, 204/255.0, 1.0); } color color_medium_violet_red() { - return rgba_color(199 / 255.0f, 21 / 255.0f, 133 / 255.0f, 1.0f); + return rgba_color(199/255.0, 21/255.0, 133/255.0, 1.0); } color color_midnight_blue() { - return rgba_color(25 / 255.0f, 25 / 255.0f, 112 / 255.0f, 1.0f); + return rgba_color(25/255.0, 25/255.0, 112/255.0, 1.0); } color color_mint_cream() { - return rgba_color(245 / 255.0f, 1.0f, 250 / 255.0f, 1.0f); + return rgba_color(245/255.0, 255/255.0, 250/255.0, 1.0); } color color_misty_rose() { - return rgba_color(1.0f, 228 / 255.0f, 225 / 255.0f, 1.0f); + return rgba_color(255/255.0, 228/255.0, 225/255.0, 1.0); } color color_moccasin() { - return rgba_color(1.0f, 228 / 255.0f, 181 / 255.0f, 1.0f); + return rgba_color(255/255.0, 228/255.0, 181/255.0, 1.0); } color color_navajo_white() { - return rgba_color(1.0f, 222 / 255.0f, 173 / 255.0f, 1.0f); + return rgba_color(255/255.0, 222/255.0, 173/255.0, 1.0); } color color_navy() { - return rgba_color(0 / 255.0f, 0 / 255.0f, 0.5f, 1.0f); + return rgba_color(0/255.0, 0/255.0, 127/255.0, 1.0); } color color_old_lace() { - return rgba_color(253 / 255.0f, 245 / 255.0f, 230 / 255.0f, 1.0f); + return rgba_color(253/255.0, 245/255.0, 230/255.0, 1.0); } color color_olive() { - return rgba_color(0.5f, 0.5f, 0 / 255.0f, 1.0f); + return rgba_color(127/255.0, 127/255.0, 0/255.0, 1.0); } color color_olive_drab() { - return rgba_color(107 / 255.0f, 142 / 255.0f, 35 / 255.0f, 1.0f); + return rgba_color(107/255.0, 142/255.0, 35/255.0, 1.0); } color color_orange() { - return rgba_color(1.0f, 165 / 255.0f, 0 / 255.0f, 1.0f); + return rgba_color(255/255.0, 165/255.0, 0/255.0, 1.0); } color color_orange_red() { - return rgba_color(1.0f, 69 / 255.0f, 0 / 255.0f, 1.0f); + return rgba_color(255/255.0, 69/255.0, 0/255.0, 1.0); } color color_orchid() { - return rgba_color(218 / 255.0f, 112 / 255.0f, 214 / 255.0f, 1.0f); + return rgba_color(218/255.0, 112/255.0, 214/255.0, 1.0); } color color_pale_goldenrod() { - return rgba_color(238 / 255.0f, 232 / 255.0f, 170 / 255.0f, 1.0f); + return rgba_color(238/255.0, 232/255.0, 170/255.0, 1.0); } color color_pale_green() { - return rgba_color(152 / 255.0f, 251 / 255.0f, 152 / 255.0f, 1.0f); + return rgba_color(152/255.0, 251/255.0, 152/255.0, 1.0); } color color_pale_turquoise() { - return rgba_color(175 / 255.0f, 238 / 255.0f, 238 / 255.0f, 1.0f); + return rgba_color(175/255.0, 238/255.0, 238/255.0, 1.0); } color color_pale_violet_red() { - return rgba_color(219 / 255.0f, 112 / 255.0f, 147 / 255.0f, 1.0f); + return rgba_color(219/255.0, 112/255.0, 147/255.0, 1.0); } color color_papaya_whip() { - return rgba_color(1.0f, 239 / 255.0f, 213 / 255.0f, 1.0f); + return rgba_color(255/255.0, 239/255.0, 213/255.0, 1.0); } - + color color_peach_puff() { - return rgba_color(1.0f, 218 / 255.0f, 185 / 255.0f, 1.0f); + return rgba_color(255/255.0, 218/255.0, 185/255.0, 1.0); } - + color color_peru() { - return rgba_color(205 / 255.0f, 133 / 255.0f, 63 / 255.0f, 1.0f); + return rgba_color(205/255.0, 133/255.0, 63/255.0, 1.0); } - + color color_pink() { - return rgba_color(1.0f, 192 / 255.0f, 203 / 255.0f, 1.0f); + return rgba_color(255/255.0, 192/255.0, 203/255.0, 1.0); } - + color color_plum() { - return rgba_color(221 / 255.0f, 160 / 255.0f, 221 / 255.0f, 1.0f); + return rgba_color(221/255.0, 160/255.0, 221/255.0, 1.0); } - + color color_powder_blue() { - return rgba_color(176 / 255.0f, 224 / 255.0f, 230 / 255.0f, 1.0f); + return rgba_color(176/255.0, 224/255.0, 230/255.0, 1.0); } - + color color_purple() { - return rgba_color(0.5f, 0 / 255.0f, 0.5f, 1.0f); + return rgba_color(127/255.0, 0/255.0, 127/255.0, 1.0); } - + color color_red() { - return rgba_color(1.0f, 0 / 255.0f, 0 / 255.0f, 1.0f); + return rgba_color(255/255.0, 0/255.0, 0/255.0, 1.0); } - + color color_rosy_brown() { - return rgba_color(188 / 255.0f, 143 / 255.0f, 143 / 255.0f, 1.0f); + return rgba_color(188/255.0, 143/255.0, 143/255.0, 1.0); } - + color color_royal_blue() { - return rgba_color(65 / 255.0f, 105 / 255.0f, 225 / 255.0f, 1.0f); + return rgba_color(65/255.0, 105/255.0, 225/255.0, 1.0); } - + color color_saddle_brown() { - return rgba_color(139 / 255.0f, 69 / 255.0f, 19 / 255.0f, 1.0f); + return rgba_color(139/255.0, 69/255.0, 19/255.0, 1.0); } - + color color_salmon() { - return rgba_color(250 / 255.0f, 0.5f, 114 / 255.0f, 1.0f); + return rgba_color(250/255.0, 127/255.0, 114/255.0, 1.0); } - + color color_sandy_brown() { - return rgba_color(244 / 255.0f, 164 / 255.0f, 96 / 255.0f, 1.0f); + return rgba_color(244/255.0, 164/255.0, 96/255.0, 1.0); } - + color color_sea_green() { - return rgba_color(46 / 255.0f, 139 / 255.0f, 87 / 255.0f, 1.0f); + return rgba_color(46/255.0, 139/255.0, 87/255.0, 1.0); } - + color color_sea_shell() { - return rgba_color(1.0f, 245 / 255.0f, 238 / 255.0f, 1.0f); + return rgba_color(255/255.0, 245/255.0, 238/255.0, 1.0); } - + color color_sienna() { - return rgba_color(160 / 255.0f, 82 / 255.0f, 45 / 255.0f, 1.0f); + return rgba_color(160/255.0, 82/255.0, 45/255.0, 1.0); } - + color color_silver() { - return rgba_color(192 / 255.0f, 192 / 255.0f, 192 / 255.0f, 1.0f); + return rgba_color(192/255.0, 192/255.0, 192/255.0, 1.0); } - + color color_sky_blue() { - return rgba_color(135 / 255.0f, 206 / 255.0f, 235 / 255.0f, 1.0f); + return rgba_color(135/255.0, 206/255.0, 235/255.0, 1.0); } - + color color_slate_blue() { - return rgba_color(106 / 255.0f, 90 / 255.0f, 205 / 255.0f, 1.0f); + return rgba_color(106/255.0, 90/255.0, 205/255.0, 1.0); } - + color color_slate_gray() { - return rgba_color(112 / 255.0f, 0.5f, 144 / 255.0f, 1.0f); + return rgba_color(112/255.0, 127/255.0, 144/255.0, 1.0); } - + color color_snow() { - return rgba_color(1.0f, 250 / 255.0f, 250 / 255.0f, 1.0f); + return rgba_color(255/255.0, 250/255.0, 250/255.0, 1.0); } - + color color_spring_green() { - return rgba_color(0 / 255.0f, 1.0f, 127 / 255.0f, 1.0f); + return rgba_color(0/255.0, 255/255.0, 127/255.0, 1.0); } - + color color_steel_blue() { - return rgba_color(70 / 255.0f, 130 / 255.0f, 180 / 255.0f, 1.0f); + return rgba_color(70/255.0, 130/255.0, 180/255.0, 1.0); } - + color color_tan() { - return rgba_color(210 / 255.0f, 180 / 255.0f, 140 / 255.0f, 1.0f); + return rgba_color(210/255.0, 180/255.0, 140/255.0, 1.0); } - + color color_teal() { - return rgba_color(0 / 255.0f, 0.5f, 0.5f, 1.0f); + return rgba_color(0/255.0, 127/255.0, 127/255.0, 1.0); } - + color color_thistle() { - return rgba_color(216 / 255.0f, 191 / 255.0f, 216 / 255.0f, 1.0f); + return rgba_color(216/255.0, 191/255.0, 216/255.0, 1.0); } - + color color_tomato() { - return rgba_color(1.0f, 99 / 255.0f, 71 / 255.0f, 1.0f); + return rgba_color(255/255.0, 99/255.0, 71/255.0, 1.0); } - + color color_turquoise() { - return rgba_color(64 / 255.0f, 224 / 255.0f, 208 / 255.0f, 1.0f); + return rgba_color(64/255.0, 224/255.0, 208/255.0, 1.0); } - + color color_violet() { - return rgba_color(238 / 255.0f, 130 / 255.0f, 238 / 255.0f, 1.0f); + return rgba_color(238/255.0, 130/255.0, 238/255.0, 1.0); } - + color color_wheat() { - return rgba_color(245 / 255.0f, 222 / 255.0f, 179 / 255.0f, 1.0f); + return rgba_color(245/255.0, 222/255.0, 179/255.0, 1.0); } - + color color_white() { - return rgba_color(1.0f, 1.0f, 1.0f, 1.0f); + return rgba_color(255/255.0, 255/255.0, 255/255.0, 1.0); } - + color color_white_smoke() { - return rgba_color(245 / 255.0f, 245 / 255.0f, 245 / 255.0f, 1.0f); + return rgba_color(245/255.0, 245/255.0, 245/255.0, 1.0); } - + color color_yellow() { - return rgba_color(1.0f, 1.0f, 0 / 255.0f, 1.0f); + return rgba_color(255/255.0, 255/255.0, 0/255.0, 1.0); } - + color color_yellow_green() { - return rgba_color(154 / 255.0f, 205 / 255.0f, 50 / 255.0f, 1.0f); + return rgba_color(154/255.0, 205/255.0, 50/255.0, 1.0); } - + color color_swinburne_red() { - return rgba_color(237 / 255.0f, 36 / 255.0f, 25 / 255.0f, 1.0f); + return rgba_color(237/255.0, 36/255.0, 25/255.0, 1.0); } } From 0d5bf3f9c9326caa783506a51181b204eb15c422 Mon Sep 17 00:00:00 2001 From: NoahJCross Date: Tue, 7 Jan 2025 17:14:53 +1100 Subject: [PATCH 4/6] fixed triangle_from_coordinates name --- python3/splashkit.py | 22 +++++++++++----------- source/include/triangle_geometry.h | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/python3/splashkit.py b/python3/splashkit.py index 483bd5b..bb79eef 100644 --- a/python3/splashkit.py +++ b/python3/splashkit.py @@ -6504,7 +6504,7 @@ def close_log_process ( ): def init_custom_logger ( mode ): __skparam__mode = __skadapter__to_sklib_log_mode(mode) sklib.__sklib__init_custom_logger__log_mode(__skparam__mode) -def init_custom_logger__name_override_mode ( app_name, override_prev_log, mode ): +def init_custom_logger_name_override_mode ( app_name, override_prev_log, mode ): __skparam__app_name = __skadapter__to_sklib_string(app_name) __skparam__override_prev_log = __skadapter__to_sklib_bool(override_prev_log) __skparam__mode = __skadapter__to_sklib_log_mode(mode) @@ -8624,35 +8624,35 @@ def free_all_timers ( ): def free_timer ( to_free ): __skparam__to_free = __skadapter__to_sklib_timer(to_free) sklib.__sklib__free_timer__timer(__skparam__to_free) -def has_timer__named ( name ): +def has_timer_named ( name ): __skparam__name = __skadapter__to_sklib_string(name) __skreturn = sklib.__sklib__has_timer__string(__skparam__name) return __skadapter__to_bool(__skreturn) -def pause_timer__named ( name ): +def pause_timer_named ( name ): __skparam__name = __skadapter__to_sklib_string(name) sklib.__sklib__pause_timer__string(__skparam__name) def pause_timer ( to_pause ): __skparam__to_pause = __skadapter__to_sklib_timer(to_pause) sklib.__sklib__pause_timer__timer(__skparam__to_pause) -def reset_timer__named ( name ): +def reset_timer_named ( name ): __skparam__name = __skadapter__to_sklib_string(name) sklib.__sklib__reset_timer__string(__skparam__name) def reset_timer ( tmr ): __skparam__tmr = __skadapter__to_sklib_timer(tmr) sklib.__sklib__reset_timer__timer(__skparam__tmr) -def resume_timer__named ( name ): +def resume_timer_named ( name ): __skparam__name = __skadapter__to_sklib_string(name) sklib.__sklib__resume_timer__string(__skparam__name) def resume_timer ( to_resume ): __skparam__to_resume = __skadapter__to_sklib_timer(to_resume) sklib.__sklib__resume_timer__timer(__skparam__to_resume) -def start_timer__named ( name ): +def start_timer_named ( name ): __skparam__name = __skadapter__to_sklib_string(name) sklib.__sklib__start_timer__string(__skparam__name) def start_timer ( to_start ): __skparam__to_start = __skadapter__to_sklib_timer(to_start) sklib.__sklib__start_timer__timer(__skparam__to_start) -def stop_timer__named ( name ): +def stop_timer_named ( name ): __skparam__name = __skadapter__to_sklib_string(name) sklib.__sklib__stop_timer__string(__skparam__name) def stop_timer ( to_stop ): @@ -8662,7 +8662,7 @@ def timer_named ( name ): __skparam__name = __skadapter__to_sklib_string(name) __skreturn = sklib.__sklib__timer_named__string(__skparam__name) return __skadapter__to_timer(__skreturn) -def timer_paused__named ( name ): +def timer_paused_named ( name ): __skparam__name = __skadapter__to_sklib_string(name) __skreturn = sklib.__sklib__timer_paused__string(__skparam__name) return __skadapter__to_bool(__skreturn) @@ -8670,7 +8670,7 @@ def timer_paused ( to_get ): __skparam__to_get = __skadapter__to_sklib_timer(to_get) __skreturn = sklib.__sklib__timer_paused__timer(__skparam__to_get) return __skadapter__to_bool(__skreturn) -def timer_started__named ( name ): +def timer_started_named ( name ): __skparam__name = __skadapter__to_sklib_string(name) __skreturn = sklib.__sklib__timer_started__string(__skparam__name) return __skadapter__to_bool(__skreturn) @@ -8678,7 +8678,7 @@ def timer_started ( to_get ): __skparam__to_get = __skadapter__to_sklib_timer(to_get) __skreturn = sklib.__sklib__timer_started__timer(__skparam__to_get) return __skadapter__to_bool(__skreturn) -def timer_ticks__named ( name ): +def timer_ticks_named ( name ): __skparam__name = __skadapter__to_sklib_string(name) __skreturn = sklib.__sklib__timer_ticks__string(__skparam__name) return __skadapter__to_unsigned_int(__skreturn) @@ -8880,7 +8880,7 @@ def triangle_from ( p1, p2, p3 ): __skparam__p3 = __skadapter__to_sklib_point_2d(p3) __skreturn = sklib.__sklib__triangle_from__point_2d_ref__point_2d_ref__point_2d_ref(__skparam__p1, __skparam__p2, __skparam__p3) return __skadapter__to_triangle(__skreturn) -def triangle_from__from_coordinates ( x1, y1, x2, y2, x3, y3 ): +def triangle_from_coordinates ( x1, y1, x2, y2, x3, y3 ): __skparam__x1 = __skadapter__to_sklib_double(x1) __skparam__y1 = __skadapter__to_sklib_double(y1) __skparam__x2 = __skadapter__to_sklib_double(x2) diff --git a/source/include/triangle_geometry.h b/source/include/triangle_geometry.h index 08fb739..5044ecf 100644 --- a/source/include/triangle_geometry.h +++ b/source/include/triangle_geometry.h @@ -23,7 +23,7 @@ namespace splashkit_lib * @param y3 The y coordinate for the third point * @return A triangle at the indicated points * - * @attribute suffix from_coordinates + * @attribute suffix coordinates */ triangle triangle_from(double x1, double y1, double x2, double y2, double x3, double y3); From bd4ac955a04a15da15e9b6c86cee52d3cf557c40 Mon Sep 17 00:00:00 2001 From: NoahJCross Date: Tue, 7 Jan 2025 17:33:24 +1100 Subject: [PATCH 5/6] fixed center_point for non overload compatible languages --- python3/splashkit.py | 4 ++-- source/include/circle_geometry.h | 2 ++ source/include/sprites.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/python3/splashkit.py b/python3/splashkit.py index bb79eef..5f7f783 100644 --- a/python3/splashkit.py +++ b/python3/splashkit.py @@ -4344,7 +4344,7 @@ def fill_circle_on_window_with_options ( destination, clr, x, y, radius, opts ): __skparam__radius = __skadapter__to_sklib_double(radius) __skparam__opts = __skadapter__to_sklib_drawing_options(opts) sklib.__sklib__fill_circle_on_window__window__color__double__double__double__drawing_options(__skparam__destination, __skparam__clr, __skparam__x, __skparam__y, __skparam__radius, __skparam__opts) -def center_point ( c ): +def center_point_of_circle ( c ): __skparam__c = __skadapter__to_sklib_circle(c) __skreturn = sklib.__sklib__center_point__circle_ref(__skparam__c) return __skadapter__to_point_2d(__skreturn) @@ -7731,7 +7731,7 @@ def call_for_all_sprites ( fn ): def call_on_sprite_event ( handler ): __skparam__handler = __skadapter__to_sklib_sprite_event_handler(handler) sklib.__sklib__call_on_sprite_event__sprite_event_handler_ptr(__skparam__handler) -def center_point ( s ): +def center_point_of_sprite ( s ): __skparam__s = __skadapter__to_sklib_sprite(s) __skreturn = sklib.__sklib__center_point__sprite(__skparam__s) return __skadapter__to_point_2d(__skreturn) diff --git a/source/include/circle_geometry.h b/source/include/circle_geometry.h index 8da2bb9..b5c34e5 100644 --- a/source/include/circle_geometry.h +++ b/source/include/circle_geometry.h @@ -99,6 +99,8 @@ namespace splashkit_lib * * @param c The circle to get the center point * @returns The center point of the circle + * + * @attribute suffix of_circle */ point_2d center_point(const circle &c); diff --git a/source/include/sprites.h b/source/include/sprites.h index 31699b8..5c2eaee 100644 --- a/source/include/sprites.h +++ b/source/include/sprites.h @@ -1228,6 +1228,7 @@ namespace splashkit_lib * * @attribute class sprite * @attribute getter center_point + * @attribute suffix of_sprite */ point_2d center_point(sprite s); From fccd57dd604aa822b0d6354df27d1066ce48e38e Mon Sep 17 00:00:00 2001 From: NoahJCross Date: Tue, 7 Jan 2025 18:25:07 +1100 Subject: [PATCH 6/6] updated terminal file --- source/terminal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/terminal.cpp b/source/terminal.cpp index 0a1c29e..f252bb9 100644 --- a/source/terminal.cpp +++ b/source/terminal.cpp @@ -65,7 +65,7 @@ namespace splashkit_lib void write_line(char data) { - write_line(std::to_string(data)); + write_line(std::string(1, data)); } string read_line()