forked from paulhoad/gp2trackeditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJamFileEditor.h
More file actions
executable file
·118 lines (97 loc) · 2.32 KB
/
JamFileEditor.h
File metadata and controls
executable file
·118 lines (97 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#ifndef _INCLUDED_JAM_H_
#define _INCLUDED_JAM_H_
#include "Observer.h"
#include "TrackTreeCtrl.h"
#include "Jam.h"
static char lpszJamFilter[] =
"F1GP2 Jam Files (*.jam)|*.jam|All Files (*.*)|*.*|";
class JamFileEditor : public Observer
, public CObject
{
char lpszJamFile[256];
public:
// HTREEITEM TreeNode;
HTREEITEM SubTree;
CTreeCtrl *tree;
JAM *JamFileStructure;
BOOL Internal;
JamFileEditor(GPTrack *track, LPCSTR jam, BOOL Internal = FALSE)
: Observer(track, t_JamFile, NULL), SubTree(0), Internal(Internal)
{
JamFileStructure = NULL;
Observer::setTreeNode(NULL);
setJamFileName((LPSTR)jam);
JamFileStructure = new JAM(getFullPathToJamFileName());
}
virtual ~JamFileEditor() { delete JamFileStructure; }
char *
getJamFileName()
{
return lpszJamFile;
}
void
setJamFileName(char *name)
{
strcpy(lpszJamFile, name);
if (JamFileStructure)
JamFileStructure->filename = getFullPathToJamFileName();
}
char *
getFullPathToJamFileName()
{
static char buffer[512];
CString gp2Location = ((CTrackEditorApp *)AfxGetApp())->getGP2Location();
wsprintf(buffer, "%s\\%s", gp2Location, getJamFileName());
return buffer;
}
void
setTreeNode(CTreeCtrl *listtree, HTREEITEM node)
{
tree = listtree;
Observer::setTreeNode(node);
}
int Open();
void
Delete();
void
Expand(CTrackTree *tracktree, HTREEITEM node)
{
if (SubTree && tree) {
HTREEITEM itemToDelete = SubTree;
while (itemToDelete) {
HTREEITEM next = tree->GetNextSiblingItem(itemToDelete);
tree->DeleteItem(itemToDelete);
itemToDelete = next;
}
}
JamFileStructure->OpenToRead(TRUE);
LoadJamTree(tracktree, node);
}
void
LoadJamTree(CTrackTree *tree, HTREEITEM root)
{
SubTree = JamFileStructure->LoadTree(tree, root, FALSE);
}
JAM *
getJAM()
{
return JamFileStructure;
}
BOOL
isDefault()
{
return Internal;
}
};
static int
numberOfJams(Vector *jams)
{
int count = 0;
for (int i = 0; i < jams->size(); i++) {
JamFileEditor *jam = (JamFileEditor *)jams->elementAt(i);
if (jam->Internal) continue;
count++;
}
return count;
}
#endif