add level names in main menu
This commit is contained in:
parent
aced4c28be
commit
70cac4ccf3
|
@ -31,6 +31,7 @@ def convert(input, output, params, target):
|
|||
|
||||
def convert_level(input, params):
|
||||
RE_VALUES = {
|
||||
"name": re.compile(r'.*'),
|
||||
"map": re.compile(r'[a-zA-Z_][a-zA-Z0-9-]*'),
|
||||
"spawner": re.compile(r'\d+,\d+'),
|
||||
"player_spawn": re.compile(r'\d+,\d+'),
|
||||
|
@ -54,6 +55,12 @@ def convert_level(input, params):
|
|||
|
||||
lines[i] = (key, value)
|
||||
|
||||
# Determine level name
|
||||
level_name = "<Untitled>"
|
||||
for key, value in lines:
|
||||
if key == "name":
|
||||
level_name = value
|
||||
|
||||
# Determine map name
|
||||
map_name = None
|
||||
for key, value in lines:
|
||||
|
@ -119,6 +126,7 @@ def convert_level(input, params):
|
|||
w += fxconv.u32(delay_after)
|
||||
|
||||
o = fxconv.Structure()
|
||||
o += fxconv.string(level_name)
|
||||
o += fxconv.ptr(f"map_{map_name}")
|
||||
o += player_spawn
|
||||
o += bytes(2)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
name: Mossy Dungeon
|
||||
map: lv1
|
||||
|
||||
player_spawn: 12,5
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
name: Wrecked Lab
|
||||
map: lv2
|
||||
|
||||
player_spawn: 5,1
|
||||
|
|
|
@ -35,6 +35,8 @@ typedef struct {
|
|||
} level_wave_t;
|
||||
|
||||
typedef struct {
|
||||
char const *name;
|
||||
|
||||
map_t const *map;
|
||||
/* Player spawn location */
|
||||
uint8_t player_spawn_x;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
typedef struct {
|
||||
/* Same mechanism as in game_t */
|
||||
level_t const *level;
|
||||
map_t const *map;
|
||||
uint16_t *map_anim;
|
||||
camera_t camera;
|
||||
|
@ -18,6 +19,7 @@ typedef struct {
|
|||
static menu_game_t *menu_load_game(level_t const *level)
|
||||
{
|
||||
menu_game_t *mg = malloc(sizeof *mg);
|
||||
mg->level = level;
|
||||
mg->map = level->map;
|
||||
mg->map_anim = malloc(mg->map->width * mg->map->height *
|
||||
sizeof *mg->map_anim);
|
||||
|
@ -96,6 +98,9 @@ int menu_level_select(int start)
|
|||
fixed_t map_center = fix(options[i]->map->width) / 2;
|
||||
options[i]->camera.x = map_center - fix(local_offset) / TILE_WIDTH;
|
||||
menu_render_game(options[i]);
|
||||
|
||||
dprint_opt(DWIDTH/2 + local_offset, DHEIGHT - 24, C_WHITE, C_NONE,
|
||||
DTEXT_CENTER, DTEXT_MIDDLE, "%s", options[i]->level->name);
|
||||
}
|
||||
|
||||
dimage(148, 9, &img_menu_title);
|
||||
|
|
Loading…
Reference in New Issue