Debian Codegraph @

editor/TableFileFilterMng.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef _TABLE_FILE_FILTER_MNG_H_
20 #define _TABLE_FILE_FILTER_MNG_H_
21
22 #include "pstypes.h"
23 #include "manage.h"
24
25 #define SOURCE_TABLE_FILENAME "F:\\Descent3\\data\\tables\\table.gam"
26
27 #define DEFAULT_TABLEPARSE_FNAME "main\\table_parse.out"
28
29 // Control Column header info
30 #define PAGE_NAME_COLUMN 0
31 #define PAGE_TYPE_COLUMN 1
32
33 #define PAGE_NAME_COLUMN_WIDTH 0.7
34 #define PAGE_TYPE_COLUMN_WIDTH 0.3
35
36 // Data Node Flags
37 #define ADDED_FOR_LEVEL_FLAG 0x01
38 #define ADDED_FOR_USER_FLAG 0x02
39 #define PAGE_WRITTEN_FLAG 0x04
40
41 // Page Processing types
42 #define ADD_PAGES 0
43 #define REMOVE_PAGES 1
44
45 #define ALWAYS_WRITE_GAMEFILE_PAGES 0
46
47 ///////////////////////
48 // Page Data Node class
49 ///////////////////////
50 class PageDataNode {
51 friend class PageDataList;
52
53 private:
54 PageDataNode *prev;
55 PageDataNode *next;
56
57 // The page data
58 uint8_t type; // stores the page type
59 char name[PAGENAME_LEN]; // stores the page name
60
61 int flags; // Stores whether file was added from level (or just added as extra)
62 int tag_count; // Stores number of level files requiring this page
63
64 public:
65 PageDataNode::PageDataNode();
66 PageDataNode::~PageDataNode();
67
68 bool operator<(const PageDataNode &node);
69
70 bool Load(CFILE *infile);
71 bool Save(CFILE *outfile);
72 };
73
74 ///////////////////////////////////////////////////////////
75 // Generic Page List class (maintains linked list of pages)
76 ///////////////////////////////////////////////////////////
77
78 #define MAX_LEVEL_FILENAMES 256
79
80 class PageDataList {
81 private:
82 PageDataNode *m_head;
83 PageDataNode *m_tail;
84 int m_size;
85
86 char m_LevelFilenames[MAX_LEVEL_FILENAMES][_MAX_PATH];
87 int m_NumLevelFilenames;
88
89 // Dialog controls
90 CDialog *m_Dlg;
91 CEdit *m_TableParseFile;
92 CListCtrl *m_PageDataListCtrl;
93 CListBox *m_LevelListBox;
94 CString *m_NumPagesText;
95 CString *m_StatusText;
96
97 CString m_DataListFilename;
98 bool m_DataListLoaded;
99 bool m_DataListModified;
100
101 public:
102 PageDataList::PageDataList();
103 PageDataList::~PageDataList();
104
105 void SetModified(bool mMod) { m_DataListModified = mMod; }
106 bool IsModified(void) { return (m_DataListModified); }
107 bool IsLoaded(void) { return (m_DataListLoaded); }
108 bool FilenameSpecified(void) { return (!m_DataListFilename.IsEmpty()); }
109
110 void ClearList(void);
111 bool AddToList(PageDataNode *node);
112 bool AddToList(char *page_name, uint8_t page_type, int page_flags);
113 bool RemoveFromList(PageDataNode *goner_node);
114 bool RemoveFromList(char *page_name, uint8_t page_type);
115 PageDataNode *FindNode(char *page_name, uint8_t page_type);
116
117 bool LoadList(char *list_filename);
118 bool SaveList(char *list_filename);
119
120 bool AddLevelFilename(char *level_filename);
121 bool RemoveSelLevelFilename(void);
122
123 bool ProcessPagesForLevel(char *level_filename, int process_type);
124 bool DetermineRequiredPages(int process_type);
125 bool ProcessPage(char *page_name, uint8_t page_type, int process_type, int flags = ADDED_FOR_LEVEL_FLAG);
126
127 void AddTexturePage(int id, int process_type);
128 void AddSoundPage(int id, int process_type);
129 void AddGenericPage(int id, int process_type);
130 void AddWeaponPage(int id, int process_type);
131 void AddDoorPage(int id, int process_type);
132 void AddShipPage(int id, int process_type);
133
134 bool AddPageFromUser(char *page_name, uint8_t page_type);
135 bool ProcessPagesInTextFile(char *filename, int process_type);
136 bool ProcessPageFromFile(char *page_name, uint8_t page_type, int process_type);
137 uint8_t GetPageTypeFromString(char *text);
138
139 bool CreateNewTableFile(char *new_table_filename, char *src_table_filename);
140
141 // Dialog control functions
142 void BindDlg(CDialog *dlg) { m_Dlg = dlg; }
143 void BindOutputFileEdit(CEdit *edit) { m_TableParseFile = edit; }
144 void BindPageDataListCtrl(CListCtrl *list) { m_PageDataListCtrl = list; }
145 void BindLevelListBox(CListBox *box) { m_LevelListBox = box; }
146 void BindNumPagesText(CString *str) { m_NumPagesText = str; }
147 void BindStatusText(CString *str) { m_StatusText = str; }
148
149 bool AddAllGamefilePages(void);
150
151 bool AddToListCtrl(int index, PageDataNode *node);
152 bool RemoveSelFromListCtrl(void);
153
154 int ModifiedPrompt(void);
155 void SetTitleString(void);
156 };
157
158 #endif /* _TABLE_FILE_FILTER_MNG_H_ */