inkcpp
Loading...
Searching...
No Matches
inkcpp.h
1#ifndef _INKCPP_H
2#define _INKCPP_H
3
4#include <stdint.h>
5
6#ifdef __cplusplus
7extern "C" {
8#else
9typedef struct HInkSnapshot HInkSnapshot;
10typedef struct HInkChoice HInkChoice;
11typedef struct HInkList HInkList;
12typedef struct InkListIter InkListIter;
13typedef struct InkFlag InkFlag;
14typedef struct InkValue InkValue;
15typedef struct HInkRunner HInkRunner;
16typedef struct HInkGlobals HInkGlobals;
17typedef struct HInkSTory HInkStory;
18#endif
19
65 struct HInkSnapshot;
69 HInkSnapshot* ink_snapshot_from_file(const char* filename);
79 void ink_snapshot_write_to_file(const HInkSnapshot* self, const char* filename);
80
86 struct HInkChoice;
91 const char* ink_choice_text(const HInkChoice* self);
101 const char* ink_choice_get_tag(const HInkChoice* self, int index);
102
107 struct HInkList;
108
125 struct InkListIter {
126 const void* _data;
127 int _i;
128 int _single_list;
129 const char* flag_name;
130 const char* list_name;
131 };
132
133 void ink_list_add(HInkList* self, const char* flag_name);
134 void ink_list_remove(HInkList* self, const char* flag_name);
135 int ink_list_contains(const HInkList* self, const char* flag_name);
142 int ink_list_flags(const HInkList* self, InkListIter* iter);
152 int ink_list_flags_from(const HInkList* self, const char* list_name, InkListIter* iter);
159
193
194 // const char* ink_value_to_string(const InkValue* self);
195
201 typedef InkValue (*InkExternalFunction)(int argc, const InkValue argv[]);
208 typedef void (*InkExternalFunctionVoid)(int argc, const InkValue argv[]);
209
215 struct HInkRunner;
233 const char* ink_runner_get_line(HInkRunner* self);
242 const char* ink_runner_tag(const HInkRunner* self, int index);
252 const HInkChoice* ink_runner_get_choice(const HInkRunner* self, int index);
257 void ink_runner_choose(HInkRunner* self, int index);
258
270 HInkRunner* self, const char* function_name, InkExternalFunctionVoid callback,
271 int lookaheadSafe
272 );
284 HInkRunner* self, const char* function_name, InkExternalFunction callback, int lookaheadSafe
285 );
286
287
294 struct HInkGlobals;
300 typedef void (*InkObserver)(InkValue new_value, InkValue old_value);
317 void ink_globals_observe(HInkGlobals* self, const char* variable_name, InkObserver observer);
324 InkValue ink_globals_get(const HInkGlobals* self, const char* variable_name);
333 int ink_globals_set(HInkGlobals* self, const char* variable_name, InkValue value);
334
342 struct HInkStory;
346 HInkStory* ink_story_from_file(const char* filename);
374 HInkStory* self, const HInkSnapshot* obj, HInkGlobals* store, int runner_id
375 );
376
385 void
386 ink_compile_json(const char* input_filename, const char* output_filename, const char** error);
387
388
389#ifdef __cplusplus
390}
391#endif
392
393#endif
Handler for a ink choice.
int ink_choice_num_tags(const HInkChoice *self)
number of tags assoziated with this choice
const char * ink_choice_get_tag(const HInkChoice *self, int index)
access tag.
const char * ink_choice_text(const HInkChoice *self)
Choice text.
Handle for the global variable store shared among ink runners.
int ink_globals_set(HInkGlobals *self, const char *variable_name, InkValue value)
Sets the value of a globals variable.
void(* InkObserver)(InkValue new_value, InkValue old_value)
Definition inkcpp.h:300
void ink_globals_observe(HInkGlobals *self, const char *variable_name, InkObserver observer)
assignes a observer to the variable with the corresponding name.
void ink_globals_delete(HInkGlobals *self)
Deconstructs the globals store and frees all assoziated memories.
HInkSnapshot * ink_globals_create_snapshot(const HInkGlobals *self)
Creates a snapshot for later reloading.
InkValue ink_globals_get(const HInkGlobals *self, const char *variable_name)
Gets the value of a global variable.
Handler for a ink list.
int ink_list_flags_from(const HInkList *self, const char *list_name, InkListIter *iter)
Creates an Iterator over all flags contained in a list assziated with a defined list.
int ink_list_flags(const HInkList *self, InkListIter *iter)
Creates an Iterator over all flags contained in a list.
A handle for an ink runner.
const HInkChoice * ink_runner_get_choice(const HInkRunner *self, int index)
Gets a choice.
void ink_runner_bind(HInkRunner *self, const char *function_name, InkExternalFunction callback, int lookaheadSafe)
Binds a external function which is called from the runtime, with a return vallue.
HInkSnapshot * ink_runner_create_snapshot(const HInkRunner *self)
Creates a snapshot, for later reloading.
InkValue(* InkExternalFunction)(int argc, const InkValue argv[])
Callback for a Ink external function which returns void.
Definition inkcpp.h:201
int ink_runner_num_tags(const HInkRunner *self)
return the number of current.
const char * ink_runner_tag(const HInkRunner *self, int index)
access tag.
void ink_runner_bind_void(HInkRunner *self, const char *function_name, InkExternalFunctionVoid callback, int lookaheadSafe)
Binds a external function which is called form the runtime, with no return value.
void ink_runner_choose(HInkRunner *self, int index)
Make a choice.
const char * ink_runner_get_line(HInkRunner *self)
Continue execution until the next newline, then allocate a c-style string with the output.
int ink_runner_num_choices(const HInkRunner *self)
Returns the number of choices currently available.
void(* InkExternalFunctionVoid)(int argc, const InkValue argv[])
Callback for a Ink external function wihich returns a value.
Definition inkcpp.h:208
int ink_runner_can_continue(const HInkRunner *self)
Can the runner continue?
void ink_runner_delete(HInkRunner *self)
Deconstructs the Runner and all frees assoziated resources.
Handler for a ink snapshot.
int ink_snapshot_num_runners(const HInkSnapshot *self)
number of runners which are stored inside this snapshot
HInkSnapshot * ink_snapshot_from_file(const char *filename)
deserialize snapshot from file.
void ink_snapshot_write_to_file(const HInkSnapshot *self, const char *filename)
serialize snapshot to file
Handle for a loaded ink story.
HInkGlobals * ink_story_new_globals_from_snapshot(HInkStory *self, const HInkSnapshot *obj)
Reconstructs globals from snapshot.
void ink_story_delete(HInkStory *self)
deletes a story and all assoziated resources
HInkRunner * ink_story_new_runner(HInkStory *self, HInkGlobals *store)
Creates a new runner.
HInkGlobals * ink_story_new_globals(HInkStory *self)
Creates a new global store.
HInkStory * ink_story_from_file(const char *filename)
Creates a new story object from a file.
HInkRunner * ink_story_new_runner_from_snapshot(HInkStory *self, const HInkSnapshot *obj, HInkGlobals *store, int runner_id)
reconstruct runner from a snapshot
void ink_compile_json(const char *input_filename, const char *output_filename, const char **error)
Compiles a .ink.json file to an inkCPP .bin file.
Iterater used to iterate flags of a HInkList.
Definition inkcpp.h:125
const char * list_name
name of the list the flag corresponds to
Definition inkcpp.h:130
int ink_list_iter_next(InkListIter *self)
const char * flag_name
Name of the current flag.
Definition inkcpp.h:129
Repserentation of a ink variable.
Definition inkcpp.h:167
int32_t int32_v
contains value if type == ValueTypeInt32
Definition inkcpp.h:172
const char * string_v
contains value if type == ValueTypeString
Definition inkcpp.h:174
enum InkValue::Type type
indicates type contained in value
Type
indicates which type is contained in the value
Definition inkcpp.h:183
@ ValueTypeString
a string
Definition inkcpp.h:188
@ ValueTypeNone
the Value does not contain any value
Definition inkcpp.h:184
@ ValueTypeList
a ink list
Definition inkcpp.h:190
@ ValueTypeFloat
a floating point number
Definition inkcpp.h:189
@ ValueTypeBool
a boolean
Definition inkcpp.h:185
@ ValueTypeInt32
a signed integer
Definition inkcpp.h:187
@ ValueTypeUint32
a unsigned integer
Definition inkcpp.h:186
int bool_v
contains value if type == ValueTypeBool
Definition inkcpp.h:169
float float_v
contains value if type == ValueTypeFloat
Definition inkcpp.h:176
HInkList * list_v
contains value if type == ValueTypeList
Definition inkcpp.h:179
uint32_t uint32_v
contains value if type == ValueTypeUint32
Definition inkcpp.h:170