-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathformSystemEditor.pas
More file actions
executable file
·420 lines (388 loc) · 15.1 KB
/
Copy pathformSystemEditor.pas
File metadata and controls
executable file
·420 lines (388 loc) · 15.1 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
unit formSystemEditor;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, unCommon, jvstrings,
xmlopenBorSystemClass, xmlopenBorSystem, clsEntityDetails,
frameSystemEditor, clsopenBorSystemVst,
ExtCtrls, JvExExtCtrls, JvNetscapeSplitter, VirtualTrees, ToolWin,
ComCtrls, JvExComCtrls, JvToolBar, Buttons, Menus;
type
TfrmSystemEditor = class(TForm)
JvToolBar1: TJvToolBar;
btnImportText: TButton;
vstopenBorSystemList: TVirtualStringTree;
JvNetscapeSplitter1: TJvNetscapeSplitter;
pnlSystemEditor: TPanel;
pnlBottom: TPanel;
btnOk: TBitBtn;
btnCancel: TBitBtn;
PopupMenu1: TPopupMenu;
Add1: TMenuItem;
Delete1: TMenuItem;
btnSave: TButton;
tbSave: TToolButton;
ToolButton1: TToolButton;
StatusBar1: TStatusBar;
N1: TMenuItem;
ExportAnimationScript1: TMenuItem;
Standard: TMenuItem;
LogMode1: TMenuItem;
procedure btnImportTextClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure btnOkClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
procedure vstopenBorSystemListFocusChanged(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex);
procedure btnSaveClick(Sender: TObject);
procedure vstopenBorSystemListPaintText(Sender: TBaseVirtualTree;
const TargetCanvas: TCanvas; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType);
procedure tbSaveClick(Sender: TObject);
procedure vstopenBorSystemListEnter(Sender: TObject);
procedure Delete1Click(Sender: TObject);
procedure Add1Click(Sender: TObject);
procedure StandardClick(Sender: TObject);
procedure LogMode1Click(Sender: TObject);
private
{ Private declarations }
entityDetails : TEntityDetails;
pEntityHeader, pEntityAnimTypes, pEntityAnimData : PVirtualNode;
nodeModels, nodeLevelHeader, nodeLevelSets, nodeLevelDesign,
nodeLevelObjects, nodeFunctions, nodeAnimationScript : PVirtualNode;
modified : Boolean;
procedure populateEditTree;
public
{ Public declarations }
systemEditor : TfsystemEditor;
treeEditorVst : TclsopenBorSystemVst;
workingrData : ropenBorSystem;
returnString : String;
returnValues : TStrings;
procedure setMode(mode:integer);
procedure populateData(rData:ropenBorSystem;zValue:string;zentityDetails : TEntityDetails); Overload;
procedure populateData(rData:ropenBorSystem;zValue:Tstrings;zentityDetails : TEntityDetails); Overload;
end;
var
frmSystemEditor: TfrmSystemEditor;
implementation
uses unMain, formCharacterEditor, formLevelDesign;
{$R *.dfm}
procedure TfrmSystemEditor.btnImportTextClick(Sender: TObject);
begin
//ses.borSys.fopenBorSystem.Clear;
//ses.borSys.importFromFile('c:\Program Files\Borland\Delphi7\Bin\Mario\Home\openBorStats\xml Schema\EntityHeader(Var).txt',0);
//ses.borSys.importFromFile('c:\Program Files\Borland\Delphi7\Bin\Mario\Home\openBorStats\xml Schema\EntityAnimTypes(Var).txt',1);
//ses.borSys.importFromFile('c:\Program Files\Borland\Delphi7\Bin\Mario\Home\openBorStats\xml Schema\EntityAnimData(Var).txt',2);
//ses.borSys.importFromFile('c:\Program Files\Borland\Delphi7\Bin\Mario\Home\openBorStats\xml Schema\ModelsHeader(Var).txt',3);
//ses.borSys.importFromFile('c:\Program Files\Borland\Delphi7\Bin\Mario\Home\openBorStats\xml Schema\LevelHeaders(Var).txt',4);
//ses.borSys.importFromFile('c:\Program Files\Borland\Delphi7\Bin\Mario\Home\openBorStats\xml Schema\LevelsSets(Var).txt',5);
//ses.borSys.importFromFile('c:\Program Files\Borland\Delphi7\Bin\Mario\Home\openBorStats\xml Schema\LevelDesign(Var).txt',6);
//ses.borSys.importFromFile('c:\Program Files\Borland\Delphi7\Bin\Mario\Home\openBorStats\xml Schema\LevelObjects(Var).txt',7);
//ses.borSys.importFromFile('c:\Program Files\Borland\Delphi7\Bin\Mario\Home\openBorStats\xml Schema\Function(Var).txt',8);
end;
procedure TfrmSystemEditor.FormCreate(Sender: TObject);
begin
systemEditor := TfsystemEditor.Create(pnlSystemEditor);
systemEditor.Parent := pnlSystemEditor;
systemEditor.Align := alClient;
systemEditor.formCreate;
treeEditorVst := TclsopenBorSystemVst.Create(vstopenBorSystemList,ses.borSys);
returnValues := TStringList.Create;
treeVisuals(vstopenBorSystemList);
end;
procedure TfrmSystemEditor.populateData(rData: ropenBorSystem;
zValue: string;zentityDetails : TEntityDetails);
begin
returnString := '';
entityDetails := zentityDetails;
try
if returnValues <> nil then
returnValues.Clear;
except
returnValues := TStringList.Create;
end;
systemEditor.formStartup(zValue,rData,zentityDetails);
end;
procedure TfrmSystemEditor.btnOkClick(Sender: TObject);
Var
i : integer;
s : string;
begin
if systemEditor.edtReturnValue.Text <> '' then
if ses.ropenBorSystemSelected.htyp = 9 then Begin
if PosStr('@cmd',LowerCase(systemEditor.returnValue)) > 0 then
returnString := systemEditor.returnValue
else
returnString := #09+ '@cmd ' + systemEditor.edtCommandName.Text + ' ' + systemEditor.returnValue
end
else
returnString := systemEditor.edtCommandName.Text + #09 + systemEditor.returnValue
else Begin
returnValues.Clear;
for i := 0 to systemEditor.reMultiReturn.Lines.Count -1 do Begin
s := systemEditor.reMultiReturn.Lines.Strings[i];
if ses.ropenBorSystemSelected.htyp = 9 then
s := #09+ '@cmd ' + systemEditor.edtCommandName.Text + ' ' + s
else
s := systemEditor.edtCommandName.Text + #09 + s;
returnValues.Add(s);
end;
end;
end;
procedure TfrmSystemEditor.btnCancelClick(Sender: TObject);
begin
returnString := '';
returnValues.Clear;
end;
procedure TfrmSystemEditor.setMode(mode: integer);
begin
case mode of
0 : Begin
vstopenBorSystemList.Visible := false;
JvNetscapeSplitter1.Visible := False;
btnSave.Visible := false;
systemEditor.setMode(mode);
btnOk.Visible := True;
btnCancel.Visible := true;
end;
1 : Begin
vstopenBorSystemList.Visible := True;
JvNetscapeSplitter1.Visible := True;
btnSave.Visible := True;
systemEditor.setMode(mode);
populateEditTree;
btnOk.Visible := false;
btnCancel.Visible := false;
systemEditor.JvPageControl1.HideAllTabs := false;
end;
end;
end;
const titles : array [0 .. 9] of string = (
'Entity Header',
'Entity Anim Types',
'Entity Anim Data',
'Models',
'Level Header',
'Level Sets',
'Level Design',
'Level Objects',
'Script Functions',
'Script Animation'
);
procedure TfrmSystemEditor.populateEditTree;
Var
i : integer;
rData : ropenBorSystem;
groupNode : PVirtualNode;
tempList: tstringlist;
begin
//Add Root Nodes
vstopenBorSystemList.clear;
for i := 0 to 9 do begin
rData := ses.borSys.clearopenBorSystemrData(rdata);
rData.title := titles[i];
rData.htyp := i;
pEntityHeader := nil;
pEntityHeader := treeEditorVst.addopenBorSystemNode(rData,nil,false);
templist := ses.borSys.getGroupList(i);
form1.addSubGroupsEntity(pEntityHeader,templist,1,treeEditorVst);
freeAndNil(templist);
end;
//Populate data from xml to type
for i := 0 to ses.borSys.fopenBorSystem.Count -1 do Begin
rData := ses.borSys.getopenBorSystemData(i);
case rData.htyp of
0: Begin
groupNode := form1.getSubGroupsEntity(pEntityHeader,rData.Group,1,vstopenBorSystemList);
treeEditorVst.addopenBorSystemNode(rData,groupNode);//pEntityHeader);
end;
1: Begin
groupNode := form1.getSubGroupsEntity(pEntityAnimTypes,rData.Group,1,vstopenBorSystemList);
treeEditorVst.addopenBorSystemNode(rData,groupNode);//pEntityAnimTypes);
end;
2: Begin
groupNode := form1.getSubGroupsEntity(pEntityAnimData,rData.Group,1,vstopenBorSystemList);
treeEditorVst.addopenBorSystemNode(rData,groupNode);//pEntityAnimData);
end;
3: Begin
groupNode := form1.getSubGroupsEntity(nodeModels,rData.Group,1,vstopenBorSystemList);
treeEditorVst.addopenBorSystemNode(rData,groupNode);//nodeModels);
end;
4: Begin
groupNode := form1.getSubGroupsEntity(nodeLevelHeader,rData.Group,1,vstopenBorSystemList);
treeEditorVst.addopenBorSystemNode(rData,groupNode);//nodeLevelHeader);
end;
5: Begin
groupNode := form1.getSubGroupsEntity(nodeLevelSets,rData.Group,1,vstopenBorSystemList);
treeEditorVst.addopenBorSystemNode(rData,groupNode);//nodeLevelSets);
end;
6: Begin
groupNode := form1.getSubGroupsEntity(nodeLevelDesign,rData.Group,1,vstopenBorSystemList);
treeEditorVst.addopenBorSystemNode(rData,groupNode);//nodeLevelDesign);
end;
7: Begin
groupNode := form1.getSubGroupsEntity(nodeLevelObjects,rData.Group,1,vstopenBorSystemList);
treeEditorVst.addopenBorSystemNode(rData,groupNode);//nodeLevelObjects);
end;
8: Begin
groupNode := form1.getSubGroupsEntity(nodeFunctions,rData.Group,1,vstopenBorSystemList);
treeEditorVst.addopenBorSystemNode(rData,groupNode);//nodeFunctions);
end;
9: Begin
groupNode := form1.getSubGroupsEntity(nodeAnimationScript,rData.Group,1,vstopenBorSystemList);
treeEditorVst.addopenBorSystemNode(rData,groupNode);//nodeAnimationScript);
end;
end;
end;
vstopenBorSystemList.SortTree(0,sdAscending);
end;
procedure TfrmSystemEditor.vstopenBorSystemListFocusChanged(
Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex);
Var
pData : popenBorSystem;
rData : ropenBorSystem;
begin
if node <> nil then Begin
pData := Sender.GetNodeData(Node);
rData := ses.borSys.pData2openBorSystemrData(pData);
ses.ropenBorSystemSelected := ses.borSys.pData2openBorSystemrData(pData);
systemEditor.populaterOpenBorSystem(rData,entityDetails);
end;
end;
procedure TfrmSystemEditor.btnSaveClick(Sender: TObject);
Var
rData : ropenBorSystem;
pData : popenBorSystem;
begin
if vstopenBorSystemList.FocusedNode <> nil then Begin
rData := systemEditor.retrieveData;
if rData.gd <> '' then Begin
ses.borSys.setopenBorSystemData(rData);
pdata := vstopenBorSystemList.GetNodeData(vstopenBorSystemList.FocusedNode);
pdata := treeEditorVst.rData2openBorSystempData(rData,pData);
//populateEditTree;
modified := true;
end;
end;
end;
procedure TfrmSystemEditor.vstopenBorSystemListPaintText(
Sender: TBaseVirtualTree; const TargetCanvas: TCanvas;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType);
Var
pData : popenBorSystem;
begin
if Node <> nil then Begin
pData := Sender.GetNodeData(node);
//If has description
if (pData.dscrp = '') or
(pData.dscrp = ' ') then
TargetCanvas.Font.Style := TargetCanvas.Font.Style - [fsBold]
else
TargetCanvas.Font.Style := TargetCanvas.Font.Style + [fsBold];
//If has command
if (pData.iCommand > 0) then
TargetCanvas.Font.Style := TargetCanvas.Font.Style + [fsItalic]
else
TargetCanvas.Font.Style := TargetCanvas.Font.Style - [fsItalic]
end;
end;
procedure TfrmSystemEditor.populateData(rData: ropenBorSystem;
zValue: Tstrings;zentityDetails : TEntityDetails);
begin
returnString := '';
entityDetails := zentityDetails;
returnValues := zValue;
systemEditor.formStartup(zValue,rData,zentityDetails);
end;
procedure TfrmSystemEditor.tbSaveClick(Sender: TObject);
begin
ses.borSys.SavetoFile(ses.localDir+'\System\system.xml');
if Form1.frameEditor <> nil then
Form1.frameEditor.populateEditorTree;
if frmCharacterEditor.frameEditor <> nil then
frmCharacterEditor.frameEditor.populateEditorTree;
if frmLevelDesign.frameEditor <> nil then
frmLevelDesign.frameEditor.populateEditorTree;
//ShowMessage('You will have to restart openBor Stats!'+#10+#13+'Saved!');
end;
procedure TfrmSystemEditor.vstopenBorSystemListEnter(Sender: TObject);
begin
StatusBar1.Panels[0].Text := vstopenBorSystemList.Hint;
end;
procedure TfrmSystemEditor.Delete1Click(Sender: TObject);
Var
pData : popenBorSystem;
begin
if vstopenBorSystemList.FocusedNode <> nil then Begin
pData := vstopenBorSystemList.GetNodeData(vstopenBorSystemList.FocusedNode);
ses.borSys.delopenBorSystemData(pData);
vstopenBorSystemList.DeleteNode(vstopenBorSystemList.FocusedNode);
modified := true;
end;
end;
procedure TfrmSystemEditor.Add1Click(Sender: TObject);
Var
pData : popenBorSystem;
rData : ropenBorSystem;
begin
if vstopenBorSystemList.FocusedNode <> nil then Begin
pData := vstopenBorSystemList.GetNodeData(vstopenBorSystemList.FocusedNode);
rData := ses.borSys.getopenBorSystemNew;
rData.htyp := pData.htyp;
rData.title := 'New';
//pEntityHeader, pEntityAnimTypes, pEntityAnimData : PVirtualNode;
case pData.htyp of
0: Begin
treeEditorVst.addopenBorSystemNode(rData,pEntityHeader);
ses.borSys.addopenBorSystemData(rData);
end;
1: Begin
treeEditorVst.addopenBorSystemNode(rData,pEntityAnimTypes);
ses.borSys.addopenBorSystemData(rData);
end;
2: Begin
treeEditorVst.addopenBorSystemNode(rData,pEntityAnimData);
ses.borSys.addopenBorSystemData(rData);
end;
3: Begin
treeEditorVst.addopenBorSystemNode(rData,nodeModels);
ses.borSys.addopenBorSystemData(rData);
end;
4: Begin
treeEditorVst.addopenBorSystemNode(rData,nodeLevelHeader);
ses.borSys.addopenBorSystemData(rData);
end;
5: Begin
treeEditorVst.addopenBorSystemNode(rData,nodeLevelSets);
ses.borSys.addopenBorSystemData(rData);
end;
6: Begin
treeEditorVst.addopenBorSystemNode(rData,nodeLevelDesign);
ses.borSys.addopenBorSystemData(rData);
end;
7: Begin
treeEditorVst.addopenBorSystemNode(rData,nodeLevelObjects);
ses.borSys.addopenBorSystemData(rData);
end;
8: Begin
treeEditorVst.addopenBorSystemNode(rData,nodeFunctions);
ses.borSys.addopenBorSystemData(rData);
end;
9: Begin
treeEditorVst.addopenBorSystemNode(rData,nodeAnimationScript);
ses.borSys.addopenBorSystemData(rData);
end;
end;
modified := true;
end;
end;
procedure TfrmSystemEditor.StandardClick(Sender: TObject);
begin
Form1.frameEditor.saveNodeScriptToFile(Form1.frameEditor.nodeAnimationScript,form1.edtDirectory.Text+'\scripts\aniscp.c');
end;
procedure TfrmSystemEditor.LogMode1Click(Sender: TObject);
begin
Form1.frameEditor.saveNodeScriptToFile(Form1.frameEditor.nodeAnimationScript,form1.edtDirectory.Text+'\scripts\aniscp.c',true);
end;
end.