84 lines
2.7 KiB
C
84 lines
2.7 KiB
C
#ifndef EDITOR_H
|
|
#define EDITOR_H
|
|
|
|
#include "engine.h"
|
|
|
|
typedef enum EditorModeEnum {
|
|
MODE_NONE,
|
|
MODE_VERTEX,
|
|
MODE_NEIGHBOR,
|
|
MODE_HEX,
|
|
MODE_REGION,
|
|
MODE_MAX_ENUM,
|
|
} EditorMode;
|
|
|
|
typedef struct EditorDataStruct EditorData;
|
|
typedef struct ModeKeyStruct ModeKey;
|
|
|
|
typedef void(*ModeKeyCallback)(EditorData* data, ClientContext* context, ModeKey* binding, int action, int mods);
|
|
|
|
struct ModeKeyStruct {
|
|
int key;
|
|
ModeKeyCallback logic;
|
|
int axis;
|
|
float amount;
|
|
};
|
|
|
|
struct EditorDataStruct {
|
|
ModeKey* mode_keys[MODE_MAX_ENUM];
|
|
uint32_t mode_key_counts[MODE_MAX_ENUM];
|
|
|
|
// The full-window container hosting context->camera (see editor_startup/
|
|
// container_set_camera) - kept around so editor_frame_callback's resize
|
|
// check can update its size without a lookup every frame.
|
|
Container* main_container;
|
|
|
|
uint32_t selected_max;
|
|
uint32_t selected_count;
|
|
|
|
uint32_t* selected_regions;
|
|
uint32_t* selected_hexes;
|
|
uint32_t* selected_vertices;
|
|
|
|
bool hover_valid;
|
|
uint32_t hover_region;
|
|
uint32_t hover_hex;
|
|
uint32_t hover_vertex;
|
|
|
|
// Camera control scheme: WASD/scroll accumulate into these, which
|
|
// editor_frame_callback integrates into context->camera each frame. The
|
|
// camera itself (position/rotation/distance/view) is engine-owned
|
|
// (ClientContext.camera) - this is app policy for how input drives it,
|
|
// not camera state, so a different app (or a scripted sequence) can drive
|
|
// the same camera without this accumulator scheme at all.
|
|
vec3 velocity;
|
|
int32_t spin[2];
|
|
int32_t zoom;
|
|
|
|
float spin_speed;
|
|
float zoom_speed;
|
|
float move_speed;
|
|
};
|
|
|
|
EditorData* create_editor_data(void);
|
|
|
|
void editor_startup(ClientContext* context);
|
|
void editor_frame_callback(ClientContext* context, double delta_time);
|
|
void editor_key_callback(ClientContext* context, int key, int action, int mods);
|
|
void editor_scroll_callback(ClientContext* context, double x, double y);
|
|
void editor_button_callback(ClientContext* context, float x, float y, int button, int action, int mods);
|
|
void editor_cursor_callback(ClientContext* context, float x, float y);
|
|
|
|
EditorMode current_mode(ClientContext* context);
|
|
void editor_set_mode(ClientContext* context, EditorMode mode);
|
|
|
|
void resize_selected(EditorData* data, unsigned int size);
|
|
int32_t find_selected_hex(EditorData* data, uint32_t region, uint32_t hex);
|
|
int32_t find_selected_vertex(EditorData* data, uint32_t region, uint32_t hex, uint32_t vertex);
|
|
void add_selected(EditorData* data, uint32_t region, uint32_t hex, uint32_t vertex);
|
|
void remove_selected_at(EditorData* data, uint32_t index);
|
|
|
|
bool editor_pick(ClientContext* context, double cursor[2], uint32_t* rid, uint32_t* hid, uint32_t* vertex, bool edge_only);
|
|
|
|
#endif
|