From 72b74e9c76db89dab4ddd038605d44402d31e0a6 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 13 Jul 2024 18:00:00 -0400 Subject: [PATCH] Add new directory type for palette database. Part of #2. --- src/browser/browser.c | 50 +++++++++++++++++++++++++++++++------------ src/fs/vfs.h | 1 + src/palette/palfs.c | 2 +- 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/browser/browser.c b/src/browser/browser.c index 5fe7a01..e065270 100644 --- a/src/browser/browser.c +++ b/src/browser/browser.c @@ -215,7 +215,7 @@ static const struct action *dir_actions[] = { NULL, }; -static const struct action *texture_actions[] = { +static const struct action *txt_actions[] = { &edit_textures_action, &rearrange_action, &sort_entries_action, @@ -226,7 +226,7 @@ static const struct action *texture_actions[] = { NULL, }; -static const struct action *pnames_actions[] = { +static const struct action *pnm_actions[] = { &edit_pnames_action, &rearrange_action, &sort_entries_action, @@ -236,6 +236,10 @@ static const struct action *pnames_actions[] = { NULL, }; +static const struct action *pal_actions[] = { + NULL, +}; + static const struct action *wad_to_wad[] = { &update_action, ©_action, @@ -249,11 +253,15 @@ static const struct action *wad_to_dir[] = { NULL, }; -static const struct action *wad_to_pnames[] = { +static const struct action *wad_to_pnm[] = { ©_pnames_action, NULL, }; +static const struct action *wad_to_pal[] = { + NULL, +}; + static const struct action *dir_to_wad[] = { &update_action, &import_action, @@ -266,36 +274,48 @@ static const struct action *dir_to_dir[] = { NULL, }; -static const struct action *dir_to_pnames[] = { +static const struct action *dir_to_pnm[] = { &import_texture_config, NULL, }; -static const struct action *dir_to_textures[] = { +static const struct action *dir_to_pal[] = { + NULL, +}; + +static const struct action *dir_to_txt[] = { &import_texture_config, NULL, }; -static const struct action *textures_to_dir[] = { +static const struct action *txt_to_dir[] = { &export_texture_config, NULL, }; -static const struct action *textures_to_textures[] = { +static const struct action *txt_to_txt[] = { ©_textures_action, NULL, }; -static const struct action *pnames_to_pnames[] = { +static const struct action *pnm_to_pnm[] = { ©_pnames_action, NULL, }; -static const struct action *pnames_to_dir[] = { +static const struct action *pnm_to_dir[] = { &export_texture_config, NULL, }; +static const struct action *pal_to_dir[] = { + NULL, +}; + +static const struct action *pal_to_wad[] = { + NULL, +}; + static const struct action *no_actions[] = {NULL}; static const struct action *common_actions[] = { @@ -317,15 +337,16 @@ static const struct action *common_actions[] = { }; static const struct action **type_actions[NUM_DIR_FILE_TYPES] = { - dir_actions, wad_actions, texture_actions, pnames_actions, + dir_actions, wad_actions, txt_actions, pnm_actions, pal_actions, }; static const struct action **action_lists[NUM_DIR_FILE_TYPES][NUM_DIR_FILE_TYPES] = { - {dir_to_dir, dir_to_wad, dir_to_textures, dir_to_pnames}, - {wad_to_dir, wad_to_wad, no_actions, wad_to_pnames}, - {textures_to_dir, no_actions, textures_to_textures, no_actions}, - {pnames_to_dir, no_actions, no_actions, pnames_to_pnames}, + {dir_to_dir, dir_to_wad, dir_to_txt, dir_to_pnm, dir_to_pal}, + {wad_to_dir, wad_to_wad, no_actions, wad_to_pnm, wad_to_pal}, + {txt_to_dir, no_actions, txt_to_txt, no_actions, no_actions}, + {pnm_to_dir, no_actions, no_actions, pnm_to_pnm, no_actions}, + {pal_to_dir, pal_to_wad, no_actions, no_actions, no_actions}, }; static void AddActionList(const struct action **list, int *idx) @@ -491,6 +512,7 @@ static bool DrawInfoPane(void *p) case FILE_TYPE_TEXTURE_LIST: case FILE_TYPE_PNAMES_LIST: + case FILE_TYPE_PALETTES: UI_PrintMultilineString(pane->window, 1, 2, "List"); break; diff --git a/src/fs/vfs.h b/src/fs/vfs.h index 5439c6c..26e4731 100644 --- a/src/fs/vfs.h +++ b/src/fs/vfs.h @@ -22,6 +22,7 @@ enum file_type { FILE_TYPE_WAD, FILE_TYPE_TEXTURE_LIST, FILE_TYPE_PNAMES_LIST, + FILE_TYPE_PALETTES, NUM_DIR_FILE_TYPES, FILE_TYPE_FILE, FILE_TYPE_LUMP, diff --git a/src/palette/palfs.c b/src/palette/palfs.c index 44a418c..7b382d8 100644 --- a/src/palette/palfs.c +++ b/src/palette/palfs.c @@ -175,7 +175,7 @@ struct directory *PAL_OpenDirectory(void) pd->dir.directory_funcs = &palette_fs_functions; VFS_InitDirectory(&pd->dir, path); - pd->dir.type = FILE_TYPE_DIR; + pd->dir.type = FILE_TYPE_PALETTES; pd->inner = inner; PaletteFSRefresh(pd, &pd->dir.entries, &pd->dir.num_entries);