mirror of
https://github.com/zoriya/ForecastingVillage.git
synced 2026-06-02 10:45:17 +00:00
Implementing a dialog holder
This commit is contained in:
+1
-1
@@ -252,7 +252,7 @@ add_executable(my_rpg
|
||||
src/systems/map_movement_system.c
|
||||
lib/gamacon/src/components/renderers/anim_utils.c
|
||||
lib/gamacon/src/isometry/map_utilities.c
|
||||
lib/gamacon/src/sfml_renderer/sfml_utilities.c lib/gamacon/src/components/map_linker.c lib/gamacon/include/components/map_linker.h lib/gamacon/src/systems/map_linker_system.c)
|
||||
lib/gamacon/src/sfml_renderer/sfml_utilities.c lib/gamacon/src/components/map_linker.c lib/gamacon/include/components/map_linker.h lib/gamacon/src/systems/map_linker_system.c lib/gamacon/include/tile.h src/components/dialog_holder.c include/components/dialog_holder.h)
|
||||
|
||||
add_compile_options(-W -Wall -Wextra -Wshadow)
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ SRC = src/main.c \
|
||||
src/components/map_movement.c \
|
||||
src/components/controllable_component.c \
|
||||
src/components/controllers/keyboard_controller.c \
|
||||
src/components/dialog_holder.c \
|
||||
src/systems/map_movement_system.c \
|
||||
src/systems/controllers/keyboard_controller_system.c
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2020
|
||||
** my_rpg
|
||||
** File description:
|
||||
** dialog_holder.h
|
||||
*/
|
||||
|
||||
#ifndef MY_RPG_DIALOG_HOLDER_H
|
||||
#define MY_RPG_DIALOG_HOLDER_H
|
||||
|
||||
#include "component.h"
|
||||
|
||||
struct dialog_holder {
|
||||
gc_component base;
|
||||
char **text;
|
||||
bool single_usage;
|
||||
bool has_seen;
|
||||
|
||||
int current_line;
|
||||
char *current_text;
|
||||
};
|
||||
|
||||
const struct dialog_holder dialog_holder;
|
||||
|
||||
#endif //MY_RPG_DIALOG_HOLDER_H
|
||||
+1
-1
Submodule lib/gamacon updated: 26ba13532a...ce1fd3fb58
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2020
|
||||
** my_rpg
|
||||
** File description:
|
||||
** dialog_holder.c
|
||||
*/
|
||||
|
||||
#include "components/dialog_holder.h"
|
||||
#include <stddef.h>
|
||||
#include <malloc.h>
|
||||
|
||||
static void ctr(void *component, va_list args)
|
||||
{
|
||||
struct dialog_holder *cmp = (struct dialog_holder *)component;
|
||||
|
||||
cmp->text = va_arg(args, char **);
|
||||
cmp->single_usage = va_arg(args, int);
|
||||
cmp->has_seen = false;
|
||||
cmp->current_line = 0;
|
||||
cmp->current_text = NULL;
|
||||
}
|
||||
|
||||
static void fdctr(gc_entity *entity, gc_scene *scene, void *component, node *n)
|
||||
{
|
||||
struct dialog_holder *cmp = (struct dialog_holder *)component;
|
||||
int count = xml_getchildcount(n);
|
||||
|
||||
cmp->single_usage = xml_getbool(n, "single_usage", false);
|
||||
cmp->text = malloc(sizeof(char *) * (count + 1));
|
||||
if (!cmp->text)
|
||||
return;
|
||||
n = n->child;
|
||||
for (int i = 0; n; n = n->next, i++)
|
||||
cmp->text[i] = xml_getproperty(n, "data");
|
||||
cmp->text[count] = NULL;
|
||||
}
|
||||
|
||||
static void dtr(void *component)
|
||||
{
|
||||
(void)component;
|
||||
}
|
||||
|
||||
static char *serialize(void *component)
|
||||
{
|
||||
(void)component;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
const struct dialog_holder dialog_holder = {
|
||||
base: {
|
||||
name: "dialog_holder",
|
||||
size: sizeof(struct dialog_holder),
|
||||
dependencies: (char *[]){
|
||||
NULL
|
||||
},
|
||||
ctr: &ctr,
|
||||
fdctr: &fdctr,
|
||||
dtr: &dtr,
|
||||
serialize: &serialize,
|
||||
destroy: &component_destroy
|
||||
}
|
||||
};
|
||||
@@ -46,6 +46,7 @@ float dtime)
|
||||
if (new_tile && !new_tile->solid && ctl->move_callback <= 0) {
|
||||
link->tile->entity = NULL;
|
||||
new_tile->entity = entity;
|
||||
engine->trigger_event(engine, "entity_moved", entity, link->tile);
|
||||
ctl->move_callback = 10;
|
||||
}
|
||||
ctl->move_callback--;
|
||||
|
||||
Reference in New Issue
Block a user