Skip to content

Commit

Permalink
Hook in code to open texture directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
fragglet committed Jun 5, 2024
1 parent 6b5177f commit 4e5bb04
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "stringlib.h"
#include "ui/ui.h"
#include "fs/vfs.h"
#include "textures/textures.h"
#include "view.h"

#define WAD_JUNK_THRESHOLD_KB 500
Expand Down Expand Up @@ -824,6 +825,18 @@ static void PerformView(struct directory_pane *active_pane,
return;
}

if (ent->type == FILE_TYPE_LUMP
&& StringHasPrefix(ent->name, "TEXTURE")) {
struct directory *new_dir =
TX_OpenTextureDir(active_pane->dir, ent);
if (new_dir == NULL) {
UI_MessageBox("Error opening texture directory.");
return;
}
NavigateNew(active_pane, new_dir);
return;
}

OpenDirent(active_pane->dir, ent);
}

Expand Down
7 changes: 4 additions & 3 deletions src/textures/texture_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "common.h"
#include "fs/vfile.h"
#include "fs/vfs.h"
#include "stringlib.h"

#include "textures/textures.h"

Expand Down Expand Up @@ -149,13 +150,13 @@ struct directory_funcs texture_dir_funcs = {
TextureDirFree,
};

struct directory *OpenTextureDir(struct directory *parent,
struct directory_entry *ent)
struct directory *TX_OpenTextureDir(struct directory *parent,
struct directory_entry *ent)
{
struct texture_dir *dir = calloc(1, sizeof(struct texture_dir));

dir->dir.type = FILE_TYPE_DIR; // TODO: texture list
dir->dir.path = checked_strdup("TEXTURE1");
dir->dir.path = StringJoin("/", parent->path, ent->name, NULL);
dir->dir.refcount = 1;
dir->dir.entries = NULL;
dir->dir.num_entries = 0;
Expand Down
3 changes: 3 additions & 0 deletions src/textures/textures.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ struct textures *TX_ParseTextureConfig(VFILE *input, struct pnames *pn);
struct pnames *TX_ParsePnamesConfig(VFILE *input);

void TX_AddSerialNos(struct textures *txs);

struct directory *TX_OpenTextureDir(struct directory *parent,
struct directory_entry *ent);

0 comments on commit 4e5bb04

Please sign in to comment.