Upgrade level editor for moon campaign support
Preserve tileset path and parallax style on save instead of hardcoding tileset.png. Add tileset cycling (T key), tile flag editing (F key for solid/platform/hazard/none), and 8x8 pixel mini-icons for all entity types in the palette and canvas. Fix entity palette not appearing when editor starts without a prior level load by splitting entity_registry_init into populate and init phases. Fix bitmap font rendering dropping the top row by correcting FONT_H from 6 to 7. Widen toolbar button spacing. Fix invisible collision from placed tiles lacking TileDefs by calling ensure_tile_def on pencil and fill placement. Fix editor hotkeys not working in the web build by latching key presses from SDL_KEYDOWN events instead of comparing keyboard state snapshots.
This commit is contained in:
@@ -22,6 +22,28 @@
|
||||
/* Spawn function: creates an entity at position, returns it */
|
||||
typedef Entity *(*EntitySpawnFn)(EntityManager *em, Vec2 pos);
|
||||
|
||||
/* ── Editor mini-icon indices ────────────────────── */
|
||||
/* Shared between the editor (bitmap definitions) and
|
||||
* the registry (icon field in each entry). Keep in
|
||||
* sync with s_icon_bitmaps[] in editor.c. */
|
||||
typedef enum EditorIcon {
|
||||
ICON_GRUNT = 0, /* spiky enemy */
|
||||
ICON_FLYER = 1, /* bat / wing */
|
||||
ICON_TURRET = 2, /* cannon */
|
||||
ICON_PLATFORM = 3, /* horizontal bar */
|
||||
ICON_PLATFORM_V = 4, /* vertical bar */
|
||||
ICON_FLAME = 5, /* fire / flame vent */
|
||||
ICON_FORCEFIELD = 6, /* electric field */
|
||||
ICON_HEART = 7, /* health pickup */
|
||||
ICON_BOLT = 8, /* jetpack / lightning */
|
||||
ICON_DRONE = 9, /* drone companion */
|
||||
ICON_GUN = 10, /* weapon pickup */
|
||||
ICON_ASTEROID = 11, /* rock */
|
||||
ICON_SPACECRAFT = 12, /* ship */
|
||||
ICON_COUNT,
|
||||
ICON_NONE = -1 /* no icon (fallback) */
|
||||
} EditorIcon;
|
||||
|
||||
typedef struct EntityRegEntry {
|
||||
const char *name; /* .lvl file name, e.g. "grunt" */
|
||||
const char *display; /* human-readable, e.g. "Grunt" */
|
||||
@@ -29,6 +51,7 @@ typedef struct EntityRegEntry {
|
||||
SDL_Color color; /* editor palette color for preview */
|
||||
int width; /* hitbox width (for editor preview) */
|
||||
int height; /* hitbox height (for editor preview) */
|
||||
int icon; /* editor mini-icon index (-1 = none) */
|
||||
} EntityRegEntry;
|
||||
|
||||
typedef struct EntityRegistry {
|
||||
@@ -43,6 +66,11 @@ extern EntityRegistry g_entity_registry;
|
||||
* Also registers entity behaviors with the given EntityManager. */
|
||||
void entity_registry_init(EntityManager *em);
|
||||
|
||||
/* Populate only the registry table (names, colors, icons) without
|
||||
* registering entity behaviors. Safe to call without an EntityManager.
|
||||
* Used by the editor when it starts without a prior level load. */
|
||||
void entity_registry_populate(void);
|
||||
|
||||
/* Look up a registry entry by name (returns NULL if not found) */
|
||||
const EntityRegEntry *entity_registry_find(const char *name);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user