From 1c9e3e2a69e58a2966a5bebd33a5dd874951b128 Mon Sep 17 00:00:00 2001 From: saverio Date: Sun, 8 May 2022 22:32:34 +0200 Subject: [PATCH 1/4] Add possibility to skip view with space --- Makefile | 3 ++- include/npc.h | 8 +++--- src/npc/update/event_skip_tp_magi.c | 34 +++++++++++++++++++++++++ src/npc/update/magician_view_rotation.c | 10 +++++--- 4 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 src/npc/update/event_skip_tp_magi.c diff --git a/Makefile b/Makefile index bd47ff2d..e95cddcc 100644 --- a/Makefile +++ b/Makefile @@ -228,7 +228,8 @@ SRC_NPC_UPDATE := update_dialog_text.c \ update_intro_magician.c \ update_dialogue_box.c \ update_npc.c \ - update_elder.c + update_elder.c \ + event_skip_tp_magi.c SRC_NPC_UPDATE := $(addprefix update/,$(SRC_NPC_UPDATE)) SRC_NPC_NPC := callback_npc.c diff --git a/include/npc.h b/include/npc.h index b3c1e26b..9ab2271a 100644 --- a/include/npc.h +++ b/include/npc.h @@ -97,8 +97,10 @@ void update_magician(object_t *obj, scene_t *scene, window_t *win, void init_npc_spawner(object_t *obj, scene_t *scene, window_t *win, __attribute__((unused)) float time); -void event_quit_dialog_off(__attribute__((unused)) object_t *obj, - scene_t *scene, window_t *win, - __attribute__((unused)) set_event_t *event); +void event_quit_dialog_off(object_t *obj, scene_t *scene, window_t *win, + set_event_t *event); + +void skip_event_magician_tp(object_t *obj, scene_t *scene, window_t *win, + set_event_t *evt); #endif diff --git a/src/npc/update/event_skip_tp_magi.c b/src/npc/update/event_skip_tp_magi.c new file mode 100644 index 00000000..b1eacde4 --- /dev/null +++ b/src/npc/update/event_skip_tp_magi.c @@ -0,0 +1,34 @@ +/* +** EPITECH PROJECT, 2022 +** myrpg +** File description: +** event to skip tp +*/ + +#include "my_bgs.h" +#include "my_bgs_framebuffer.h" +#include "my_json.h" +#include "npc.h" + +extern const char rotation_data_key[]; + +extern const char total_time_key[]; + +void skip_event_magician_tp(object_t *obj, + __attribute__((unused)) scene_t *scene, + __attribute__ ((unused)) window_t *win, + __attribute__((unused)) set_event_t *evt) +{ + any_t *rotation_data = NULL; + any_t *total_time = NULL; + + if (obj == NULL) { + return; + } + rotation_data = dico_t_get_value(obj->components, rotation_data_key); + total_time = get_from_any(rotation_data, "d", total_time_key); + if (total_time == NULL) { + return; + } + total_time->type = INT; +} diff --git a/src/npc/update/magician_view_rotation.c b/src/npc/update/magician_view_rotation.c index 52d8ef5f..52b86355 100644 --- a/src/npc/update/magician_view_rotation.c +++ b/src/npc/update/magician_view_rotation.c @@ -5,20 +5,22 @@ ** magician view rotation */ +#include +#include #include "my_bgs.h" +#include "my_bgs_components.h" #include "my_dico.h" #include "npc.h" #include "macro.h" #include "rpg_struct.h" #include "stage.h" #include "player.h" -#include static const char view_rotation_data[] = "./assets/data/npc/rotation_data.json"; -static const char rotation_data_key[] = "rotation data"; +const char rotation_data_key[] = "rotation data"; -static const char total_time_key[] = "total time"; +const char total_time_key[] = "total time"; static const char actualisation_time_key[] = "actualisation time"; @@ -117,6 +119,8 @@ void create_view_rotation(scene_t *scene) if (object_set_custom(obj) != BGS_OK) { return; } + event_add_node(create_event(skip_event_magician_tp, false, obj, NULL), + (node_params_t) {sfMouseLeft, sfKeyEscape, KEY}); rotation_data = parse_json_file(view_rotation_data); if (rotation_data == NULL || rotation_data->type != DICT) { return; From 0a90eca529678537b7a67c80eee68a81ab3335f6 Mon Sep 17 00:00:00 2001 From: saverio Date: Sun, 8 May 2022 22:50:30 +0200 Subject: [PATCH 2/4] Change time total --- assets/data/npc/rotation_data.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/data/npc/rotation_data.json b/assets/data/npc/rotation_data.json index 25a46a68..2abe21ec 100644 --- a/assets/data/npc/rotation_data.json +++ b/assets/data/npc/rotation_data.json @@ -1,5 +1,5 @@ { - "total time": 3.0, + "total time": 9.0, "actualisation time": 0.01, "rotation": 5.0, "zoom": 40.0 From a2ddae192f4b9446b4698096b9099ff1d2328fce Mon Sep 17 00:00:00 2001 From: saverio Date: Sun, 8 May 2022 23:16:16 +0200 Subject: [PATCH 3/4] Change key to skip + new methdo --- src/npc/update/event_skip_tp_magi.c | 4 +++- src/npc/update/magician_view_rotation.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/npc/update/event_skip_tp_magi.c b/src/npc/update/event_skip_tp_magi.c index b1eacde4..29f482b9 100644 --- a/src/npc/update/event_skip_tp_magi.c +++ b/src/npc/update/event_skip_tp_magi.c @@ -22,13 +22,15 @@ void skip_event_magician_tp(object_t *obj, any_t *rotation_data = NULL; any_t *total_time = NULL; + printf("ok\n"); if (obj == NULL) { return; } + printf("oki\n"); rotation_data = dico_t_get_value(obj->components, rotation_data_key); total_time = get_from_any(rotation_data, "d", total_time_key); if (total_time == NULL) { return; } - total_time->type = INT; + total_time->value.f = 0; } diff --git a/src/npc/update/magician_view_rotation.c b/src/npc/update/magician_view_rotation.c index 52b86355..e8cc4837 100644 --- a/src/npc/update/magician_view_rotation.c +++ b/src/npc/update/magician_view_rotation.c @@ -120,7 +120,7 @@ void create_view_rotation(scene_t *scene) return; } event_add_node(create_event(skip_event_magician_tp, false, obj, NULL), - (node_params_t) {sfMouseLeft, sfKeyEscape, KEY}); + (node_params_t) {sfMouseLeft, sfKeyReturn, KEY}); rotation_data = parse_json_file(view_rotation_data); if (rotation_data == NULL || rotation_data->type != DICT) { return; From a64e4162ca6145f5774dce163540d0aa91cf980a Mon Sep 17 00:00:00 2001 From: saverio Date: Sun, 8 May 2022 23:19:18 +0200 Subject: [PATCH 4/4] Remove debug --- src/npc/update/event_skip_tp_magi.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/npc/update/event_skip_tp_magi.c b/src/npc/update/event_skip_tp_magi.c index 29f482b9..1d537bac 100644 --- a/src/npc/update/event_skip_tp_magi.c +++ b/src/npc/update/event_skip_tp_magi.c @@ -22,11 +22,9 @@ void skip_event_magician_tp(object_t *obj, any_t *rotation_data = NULL; any_t *total_time = NULL; - printf("ok\n"); if (obj == NULL) { return; } - printf("oki\n"); rotation_data = dico_t_get_value(obj->components, rotation_data_key); total_time = get_from_any(rotation_data, "d", total_time_key); if (total_time == NULL) {