////////////////////////////////////////////////////////////////////////////////
// MechWarrior3AnimFile.h
// Parser for MW3 anim.zbd files
// Copyright Bjoern Ganster
// Developed since 2022
////////////////////////////////////////////////////////////////////////////////

#ifndef MechWarrior3AnimFile__h
#define MechWarrior3AnimFile__h

#include "BGBase.h"
#include "Archive.h"

////////////////////////////////////////////////////////////////////////////////
// Implementation of an archive class for anim.zbd files
// todo: since this most likely isn't an archive, many functions here do not make sense

// Anim reader for both MW3 and MW3:PM
class MechWarrior3AnimFile : public MWArchive {
public:
	// Constructor
	MechWarrior3AnimFile();

	// Destructor
	~MechWarrior3AnimFile() OVERRIDE;

	// Open file
	bool open(const PathChar* PRJFN, bool readOnly = true) OVERRIDE;

	// Close file
	void close() OVERRIDE;

	// Read bufSize bytes from file numbered index at offset into buf
	bool getFileChunk(size_t index, size_t offset, void* buf, size_t bufSize) OVERRIDE;

	// Enter subdirectory
	bool enterSubDir(size_t /*index*/) OVERRIDE;

	bool enterSubDir(const char* /*dirName*/) OVERRIDE;

	// Leave subdirectory
	bool leaveDir() OVERRIDE;

	// Check if currently in sub directory
	bool inSubDir() const OVERRIDE;

	// Replace file
	bool replaceFile(size_t /*fileNum*/, const PathChar* /*srcFN*/) OVERRIDE;

	// Check if archive type supports file replacement
	bool replaceFilePossible() const OVERRIDE;

	// Check if entry index is a directory
	bool isDirectory(size_t /*index*/) const OVERRIDE;

	// Add files to archive
	void addFileToArchive(const PathChar* /*FN*/) OVERRIDE;
	bool canAddFilesToArchive() const OVERRIDE;

private:
	// Keep anim.zbd in memory for fast access
	MemoryBlock mMb;

	uint32_t headerVersion, animDataOffset, animDataCount;
};

#endif
