From: Javier Sancho Date: Sat, 21 Mar 2020 19:10:29 +0000 (+0100) Subject: get-cursor-control set-visible! X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=fd10e89f595a8ae45d4471a7d77426d0a1b77502;p=guile-irrlicht.git get-cursor-control set-visible! --- diff --git a/examples/02.Quake3Map.scm b/examples/02.Quake3Map.scm index 47c8125..a79b849 100644 --- a/examples/02.Quake3Map.scm +++ b/examples/02.Quake3Map.scm @@ -72,14 +72,14 @@ ;; FPS camera (add-camera-scene-node-fps! scene-manager) -(set-visible-cursor! (get-cursor-control device) #f) +(set-visible! (get-cursor-control device) #f) ;; loop (define last-fps -1) -(while (device-run? device) +(while (run device) (cond ((is-window-active? device) (begin-scene driver #:color '(255 200 200 200)) - (scene-draw-all scene-manager) + (draw-all scene-manager) (end-scene driver) (let ((fps (get-fps driver))) @@ -92,5 +92,5 @@ (yield device)))) ;; delete device -(device-drop! device) +(drop! device) (exit #t) diff --git a/src/cursor-control.cpp b/src/cursor-control.cpp index 4a870e8..ada992f 100644 --- a/src/cursor-control.cpp +++ b/src/cursor-control.cpp @@ -21,7 +21,9 @@ #include #include + #include "cursor-control.h" +#include "device.h" #include "position2d.h" #include "wrapped.h" @@ -31,12 +33,22 @@ extern "C" { init_cursor_control (void) { init_cursor_control_type (); + scm_c_define_gsubr ("get-cursor-control", 1, 0, 0, (scm_t_subr)irr_getCursorControl); + scm_c_export ("get-cursor-control", NULL); } DEFINE_WRAPPED_TYPE (irr::gui::ICursorControl*, "cursor-control", init_cursor_control_type, cursor_control_p, wrap_cursor_control, unwrap_cursor_control); + SCM + irr_getCursorControl (SCM wrapped_device) + { + irr::gui::ICursorControl* cursor_control = + unwrap_device (wrapped_device)->getCursorControl (); + return wrap_cursor_control (cursor_control); + } + SCM irr_gui_setPosition (SCM wrapped_cursor_control, SCM position) diff --git a/src/cursor-control.h b/src/cursor-control.h index 9191881..d7a4bc5 100644 --- a/src/cursor-control.h +++ b/src/cursor-control.h @@ -34,6 +34,9 @@ extern "C" { DECLARE_WRAPPED_TYPE (irr::gui::ICursorControl*, init_cursor_control_type, cursor_control_p, wrap_cursor_control, unwrap_cursor_control); + SCM + irr_getCursorControl (SCM wrapped_device); + SCM irr_gui_setPosition (SCM wrapped_cursor_control, SCM position); diff --git a/src/misc.cpp b/src/misc.cpp index 9997fdd..bd3e037 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -23,6 +23,7 @@ #include #include "cursor-control.h" +#include "gui-element.h" #include "mesh-scene-node.h" #include "misc.h" #include "scene-node.h" @@ -36,7 +37,8 @@ extern "C" { { scm_c_define_gsubr ("get-name", 1, 0, 0, (scm_t_subr)irr_getName); scm_c_define_gsubr ("set-position!", 2, 0, 0, (scm_t_subr)irr_setPosition); - scm_c_export ("get-name", "set-position!", NULL); + scm_c_define_gsubr ("set-visible!", 2, 0, 0, (scm_t_subr)irr_setVisible); + scm_c_export ("get-name", "set-position!", "set-visible!", NULL); } SCM @@ -72,4 +74,28 @@ extern "C" { } } + SCM + irr_setVisible (SCM wrapped_obj, + SCM visible) + { + if (cursor_control_p (wrapped_obj)) + { + unwrap_cursor_control (wrapped_obj)->setVisible (scm_to_bool (visible)); + } + else if (gui_element_p (wrapped_obj)) + { + unwrap_gui_element (wrapped_obj)->setVisible (scm_to_bool (visible)); + } + else if (scene_node_p (wrapped_obj)) + { + unwrap_scene_node (wrapped_obj)->setVisible (scm_to_bool (visible)); + } + else + { + scm_error (scm_arg_type_key, NULL, "Cannot set visibility for object: ~S", + scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); + } + return SCM_UNSPECIFIED; + } + } diff --git a/src/misc.h b/src/misc.h index 6fb1d11..d7c7b27 100644 --- a/src/misc.h +++ b/src/misc.h @@ -37,6 +37,10 @@ extern "C" { irr_setPosition (SCM wrapped_obj, SCM position); + SCM + irr_setVisible (SCM wrapped_obj, + SCM visible); + } #endif