Descent3/legacy/hogedit/HogEditDoc.h

182 lines
5.7 KiB
C
Raw Normal View History

/*
2024-06-15 18:13:59 +00:00
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
--- HISTORICAL COMMENTS FOLLOW ---
2024-04-19 21:54:58 +00:00
* $Logfile: /DescentIII/Main/hogedit/HogEditDoc.h $
* $Revision: 1.1.1.1 $
* $Date: 2003-08-26 03:57:56 $
* $Author: kevinb $
*
2024-06-15 18:13:59 +00:00
*
2024-04-19 21:54:58 +00:00
*
* $Log: not supported by cvs2svn $
2024-06-15 18:13:59 +00:00
*
2024-04-19 21:54:58 +00:00
* 9 5/05/99 12:53p Nate
* Added support for multiple file extraction
2024-06-15 18:13:59 +00:00
*
2024-04-19 21:54:58 +00:00
* 8 10/30/98 11:15a Nate
* Added support for modification of hog files.
2024-06-15 18:13:59 +00:00
*
2024-04-19 21:54:58 +00:00
* 7 9/17/98 4:29p Nate
* Added Import Directory option.
2024-06-15 18:13:59 +00:00
*
2024-04-19 21:54:58 +00:00
* 6 8/14/98 4:38p Nate
* Fixed a few minor bugs and added better error reporting
2024-06-15 18:13:59 +00:00
*
2024-04-19 21:54:58 +00:00
* 5 8/14/98 1:01p Nate
* Added better error reporting for the HogEditor
2024-06-15 18:13:59 +00:00
*
2024-04-19 21:54:58 +00:00
* 4 7/22/98 2:38p Nate
* Added Modified File prompt when exiting
2024-06-15 18:13:59 +00:00
*
2024-04-19 21:54:58 +00:00
* 3 7/20/98 3:35p Nate
* Added more Editing functionality
2024-06-15 18:13:59 +00:00
*
2024-04-19 21:54:58 +00:00
* 2 7/15/98 12:31p Nate
* Initial version
*
* $NoKeywords: $
*/
// HogEditDoc.h : interface of the CHogEditDoc class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_HOGEDITDOC_H__48BE52BE_172F_11D2_8CBC_00A0C96ED60D__INCLUDED_)
#define AFX_HOGEDITDOC_H__48BE52BE_172F_11D2_8CBC_00A0C96ED60D__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include "pstypes.h"
2024-06-15 18:13:59 +00:00
#define FILE_IS_SAME 0
#define FILE_HAS_CHANGED 1
#define FILE_IS_GONE 2
2024-04-19 21:54:58 +00:00
#define RIB_TAG_STR "RIB_ID"
2024-06-15 18:13:59 +00:00
#define DEFAULT_NEW_FILENAME "Untitled.rib"
2024-04-19 21:54:58 +00:00
2024-06-15 18:13:59 +00:00
#define ADDFILE_OK 0
#define ADDFILE_LONG_FNAME_ERROR 1
#define ADDFILE_DUP_FILE_ERROR 2
#define ADDFILE_STAT_ERROR 3
2024-04-19 21:54:58 +00:00
// the following structures are slightly modified versions of the CFILE hog structs
2024-06-15 18:13:59 +00:00
struct hog_library_entry {
char path[_MAX_PATH]; // location of data file (filename not included)
char name[PSFILENAME_LEN + 1]; // just the filename
unsigned length; // length of this file
int32_t timestamp; // time and date of file
int flags; // misc flags
int offset; // file offset in hog (or -1 if in .rib file)
};
2024-04-19 21:54:58 +00:00
// the hog library structure
2024-06-15 18:13:59 +00:00
struct hog_library {
char filename[_MAX_PATH]; // full hog file path (including filename)
int flags; // misc flags for the hog file
int num_entries; // number of entries in the hog file
CList<hog_library_entry, hog_library_entry &> filelist;
};
2024-04-19 21:54:58 +00:00
// Comparison function for sorting filenames
2024-06-15 18:13:59 +00:00
int compare(const void *arg1, const void *arg2);
2024-04-19 21:54:58 +00:00
// HogEdit Doc class
2024-06-15 18:13:59 +00:00
class CHogEditDoc : public CDocument {
2024-04-19 21:54:58 +00:00
protected: // create from serialization only
2024-06-15 18:13:59 +00:00
CHogEditDoc();
DECLARE_DYNCREATE(CHogEditDoc)
2024-04-19 21:54:58 +00:00
2024-06-15 18:13:59 +00:00
// Attributes
2024-04-19 21:54:58 +00:00
public:
2024-06-15 18:13:59 +00:00
CString m_DocumentName; // name of hog document
bool m_StaticHog; // is library a loaded hogfile or a lite hogfile(only names)
bool m_NoNameChosen; // Isn't set until user specifies name for a new file
hog_library Library; // stores the list of entries
2024-04-19 21:54:58 +00:00
2024-06-15 18:13:59 +00:00
// Operations
2024-04-19 21:54:58 +00:00
public:
2024-06-15 18:13:59 +00:00
int LoadDocument(CString &name); // loads a hog or rib
int SaveDocument(CString &name); // saves a hog or rib
void NewDocument(); // creates a new document (entry list)
2024-04-19 21:54:58 +00:00
2024-06-15 18:13:59 +00:00
int LoadHog(const char *pathname); // loads a Hog file
int SaveHog(const char *pathname); // saves a Hog file
int LoadRib(const char *pathname); // loads a Rib file.
int SaveRib(const char *pathname); // saves a Rib file.
2024-04-19 21:54:58 +00:00
2024-06-15 18:13:59 +00:00
int AddFile(const char *pathname, hog_library_entry *entry); // adds a file to the file list.
2024-04-19 21:54:58 +00:00
2024-06-15 18:13:59 +00:00
bool ReadHogLibEntry(FILE *fp, hog_library_entry *entry);
bool WriteHogLibEntry(FILE *fp, hog_library_entry *entry);
2024-04-19 21:54:58 +00:00
2024-06-15 18:13:59 +00:00
bool CreateFilenameList(char ***filenames);
void SortFilenameList(char **filenames);
bool DeleteFilenameList(char **filenames);
2024-04-19 21:54:58 +00:00
2024-06-15 18:13:59 +00:00
int UpdatedFileCheck(hog_library_entry *entry);
bool ExtractFile(int file_pos, unsigned file_len, char *out_fname);
2024-04-19 21:54:58 +00:00
2024-06-15 18:13:59 +00:00
uint32_t CalcHogFileSize(void);
2024-04-19 21:54:58 +00:00
2024-06-15 18:13:59 +00:00
FILE *FindFileInHog(char *hog_fname, tHogFileEntry *table_entry);
2024-04-19 21:54:58 +00:00
2024-06-15 18:13:59 +00:00
int CreateNewHogFromCurrentHog(char *src_hog_fname, char *target_hog_fname, int nfiles, const char **filenames,
void (*UpdateFunction)(char *));
2024-04-19 21:54:58 +00:00
2024-06-15 18:13:59 +00:00
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CHogEditDoc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive &ar);
//}}AFX_VIRTUAL
2024-04-19 21:54:58 +00:00
2024-06-15 18:13:59 +00:00
// Implementation
2024-04-19 21:54:58 +00:00
public:
2024-06-15 18:13:59 +00:00
virtual ~CHogEditDoc();
2024-04-19 21:54:58 +00:00
#ifdef _DEBUG
2024-06-15 18:13:59 +00:00
virtual void AssertValid() const;
virtual void Dump(CDumpContext &dc) const;
2024-04-19 21:54:58 +00:00
#endif
protected:
2024-06-15 18:13:59 +00:00
// Generated message map functions
2024-04-19 21:54:58 +00:00
protected:
2024-06-15 18:13:59 +00:00
//{{AFX_MSG(CHogEditDoc)
afx_msg void OnUpdateActionInsert(CCmdUI *pCmdUI);
afx_msg void OnUpdateActionCreate(CCmdUI *pCmdUI);
afx_msg void OnUpdateFileSave(CCmdUI *pCmdUI);
afx_msg void OnUpdateFileSaveAs(CCmdUI *pCmdUI);
afx_msg void OnUpdateActionUpdate(CCmdUI *pCmdUI);
afx_msg void OnUpdateActionImport(CCmdUI *pCmdUI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
2024-04-19 21:54:58 +00:00
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_HOGEDITDOC_H__48BE52BE_172F_11D2_8CBC_00A0C96ED60D__INCLUDED_)