2023-07-30 19:18:50 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// in-game editor
|
|
|
|
// - rlyeh, public domain.
|
2023-11-19 12:07:28 +00:00
|
|
|
|
2023-11-20 20:19:53 +00:00
|
|
|
#define EDITOR_VERSION "2023.10"
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2023-11-26 15:06:55 +00:00
|
|
|
// editor bindings
|
2023-11-20 20:19:53 +00:00
|
|
|
|
|
|
|
typedef struct editor_bind_t {
|
|
|
|
const char *command;
|
|
|
|
const char *bindings;
|
|
|
|
void (*fn)();
|
|
|
|
} editor_bind_t;
|
|
|
|
|
|
|
|
API void editor_addbind(editor_bind_t bind);
|
|
|
|
|
|
|
|
#define EDITOR_BIND(CMD,KEYS,...) \
|
|
|
|
void macro(editor_bind_##CMD##_fn_)() { __VA_ARGS__ }; AUTORUN { array_push(editor_binds, ((editor_bind_t){#CMD,KEYS,macro(editor_bind_##CMD##_fn_)}) ); }
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2023-11-26 15:06:55 +00:00
|
|
|
// editor properties
|
2023-11-20 20:19:53 +00:00
|
|
|
|
|
|
|
#define EDITOR_PROPERTYDEF(T,property_name) \
|
|
|
|
typedef map(void*,T) editor_##property_name##_map_t; \
|
|
|
|
API editor_##property_name##_map_t *editor_##property_name##_map(); \
|
|
|
|
API T editor_##property_name(const void *obj); \
|
|
|
|
API void editor_set##property_name(const void *obj, T value); \
|
|
|
|
API void editor_alt##property_name(const void *obj); \
|
|
|
|
API void editor_no##property_name(void *obj);
|
|
|
|
|
2023-11-26 15:06:55 +00:00
|
|
|
EDITOR_PROPERTYDEF(int, open); ///- whether object is tree opened in tree editor
|
|
|
|
EDITOR_PROPERTYDEF(int, selected); ///- whether object is displaying a contextual popup or not
|
|
|
|
EDITOR_PROPERTYDEF(int, changed); ///- whether object is displaying a contextual popup or not
|
|
|
|
EDITOR_PROPERTYDEF(int, popup); ///- whether object is displaying a contextual popup or not
|
|
|
|
EDITOR_PROPERTYDEF(int, bookmarked); ///-
|
|
|
|
EDITOR_PROPERTYDEF(int, visible); ///-
|
|
|
|
EDITOR_PROPERTYDEF(int, script); ///-
|
|
|
|
EDITOR_PROPERTYDEF(int, event); ///-
|
|
|
|
EDITOR_PROPERTYDEF(char*,iconinstance); ///-
|
|
|
|
EDITOR_PROPERTYDEF(char*,iconclass); ///-
|
|
|
|
EDITOR_PROPERTYDEF(int, treeoffsety); ///-
|
2023-11-20 20:19:53 +00:00
|
|
|
|
|
|
|
API void editor_destroy_properties(void *o);
|
|
|
|
API void editor_load_on_boot(void);
|
|
|
|
API void editor_save_on_quit(void);
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2023-11-26 15:06:55 +00:00
|
|
|
// editor ui
|
2023-11-20 20:19:53 +00:00
|
|
|
|
2023-11-26 15:06:55 +00:00
|
|
|
enum EDITOR_MODE {
|
2023-11-20 20:19:53 +00:00
|
|
|
EDITOR_PANEL,
|
|
|
|
EDITOR_WINDOW,
|
|
|
|
EDITOR_WINDOW_NK,
|
|
|
|
EDITOR_WINDOW_NK_SMALL,
|
|
|
|
};
|
|
|
|
|
|
|
|
API int editor_begin(const char *title, int mode);
|
|
|
|
API int editor_end(int mode);
|
|
|
|
|
2023-11-26 15:06:55 +00:00
|
|
|
// ----------------------------------------------------------------------------------------
|
|
|
|
// editor selection
|
|
|
|
|
2023-11-20 20:19:53 +00:00
|
|
|
API int editor_filter();
|
|
|
|
API void editor_select(const char *mask);
|
|
|
|
API void editor_unselect(); // same than editor_select("!**");
|
|
|
|
|
|
|
|
API void editor_select_aabb(aabb box);
|
|
|
|
API void editor_selectgroup(obj *first, obj *last);
|
|
|
|
API void* editor_first_selected();
|
|
|
|
API void* editor_last_selected();
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------------------
|
2023-11-26 15:06:55 +00:00
|
|
|
// editor instancing
|
2023-11-20 20:19:53 +00:00
|
|
|
|
|
|
|
API void editor_addtoworld(obj *o);
|
|
|
|
API void editor_watch(const void *o);
|
|
|
|
API void* editor_spawn(const char *ini); // deprecate?
|
|
|
|
API void editor_spawn1();
|
|
|
|
|
|
|
|
API void editor_destroy_selected();
|
|
|
|
API void editor_inspect(obj *o);
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------------------
|
2023-11-26 15:06:55 +00:00
|
|
|
// editor utils
|
2023-11-20 20:19:53 +00:00
|
|
|
|
2023-11-26 15:06:55 +00:00
|
|
|
//API void editor();
|
|
|
|
//API bool editor_active();
|
|
|
|
API vec3 editor_pick(float mouse_x, float mouse_y);
|
|
|
|
API char* editor_path(const char *path);
|
2023-11-20 20:19:53 +00:00
|
|
|
|
2023-11-26 15:27:33 +00:00
|
|
|
API void editor_setmouse(int x, int y);
|
|
|
|
API vec2 editor_glyph(int x, int y, unsigned cp);
|
|
|
|
API vec2 editor_glyphstr(int x, int y, const char *utf8);
|
2023-11-20 20:19:53 +00:00
|
|
|
API void editor_gizmos(int dim);
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------------------
|
2023-11-26 15:06:55 +00:00
|
|
|
// editor loop
|
|
|
|
|
|
|
|
API int editor_send(const char *cmd); // returns job-id
|
|
|
|
API const char* editor_recv(int jobid, double timeout_ss);
|
2023-11-20 20:19:53 +00:00
|
|
|
|
2023-11-26 15:06:55 +00:00
|
|
|
API void editor_pump();
|
|
|
|
API void editor_frame( void (*game)(unsigned, float, double) );
|
2023-07-30 19:18:50 +00:00
|
|
|
|
2023-11-26 15:06:55 +00:00
|
|
|
// ----------------------------------------------------------------------------------------
|
|
|
|
// engine section: @todo: expand me
|
2023-07-30 19:18:50 +00:00
|
|
|
|
2023-10-26 07:27:46 +00:00
|
|
|
API float* engine_getf(const char *key);
|
|
|
|
API int* engine_geti(const char *key);
|
|
|
|
API char** engine_gets(const char *key);
|
|
|
|
API int engine_send(const char *cmd, const char *optional_value);
|
2023-10-13 10:59:44 +00:00
|
|
|
|
2023-11-26 15:06:55 +00:00
|
|
|
API int ui_engine();
|