forked from OpenBOR/OpenBORStats
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunEntityDetails.pas
More file actions
executable file
·172 lines (156 loc) · 5.21 KB
/
unEntityDetails.pas
File metadata and controls
executable file
·172 lines (156 loc) · 5.21 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
unit unEntityDetails;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
clsEntityDetails,
Dialogs, Grids, JvExGrids, JvStringGrid, ToolWin, ComCtrls, JvExComCtrls,
JvToolBar, jvStrings, StdCtrls;
type
TfrmEntityDetails = class(TForm)
JvToolBar1: TJvToolBar;
gridEntityDetails: TJvStringGrid;
tbOpen: TToolButton;
ToolButton2: TToolButton;
edtEntityFile: TEdit;
procedure gridEntityDetailsClick(Sender: TObject);
procedure tbOpenClick(Sender: TObject);
procedure gridEntityDetailsDblClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
function emptyLine(s:string):boolean;
public
{ Public declarations }
EntityDetails : TEntityDetails;
procedure populateEntityDetails(filename:string);
procedure populateGrid;
end;
var
frmEntityDetails: TfrmEntityDetails;
implementation
Uses
unMain, formEditor;
{$R *.dfm}
function TfrmEntityDetails.emptyLine(s: string): boolean;
Var
isEmpty : boolean;
begin
if (s = ' ') or
(s = ' ') or
(s = ' ') or
(s = #09) or
(s = #09#09) or
(s = #09#09#09) then
isEmpty := true
else
isEmpty := false;
Result := isEmpty;
end;
procedure TfrmEntityDetails.gridEntityDetailsClick(Sender: TObject);
Var
SStat : TShiftState;
begin
if Form1.cbSort.Checked = true then
(sender as TJvStringGrid).SortGridByCols((sender as TJvStringGrid).Col);
SStat := KeyboardStateToShiftState;
If SStat = [ssCtrl..ssLeft] then
(sender as TJvStringGrid).SortGridByCols((sender as TJvStringGrid).Col);
end;
procedure TfrmEntityDetails.populateEntityDetails(filename: string);
{Var
//aFileList, iAnimList : TStringList;
i, iAnimLineNumber : integer;
iAnimStart : Boolean;
sCurrentLine : String;}
begin
{edtEntityFile.Text := filename;
aFileList := TStringList.Create;
iAnimList := TStringList.Create;
iAnimStart := false;
Caption := ExtractFileName(filename);}
edtEntityFile.Text := filename;
if EntityDetails = nil then
EntityDetails := TEntityDetails.create
else
EntityDetails.list.Clear;
EntityDetails := EntityDetails.loadEntitryDetails(filename);
{aFileList.LoadFromFile(filename);
for i := 0 to aFileList.count -1 do Begin
sCurrentLine := LowerCase(aFileList.Strings[i]);
Form1.StringDelete2End(sCurrentLine,'#');
if emptyLine(sCurrentLine) then
sCurrentLine := '';
//Search for anim details
//Search for a Entity creation position
if PosStr('anim',sCurrentLine) > 0 then Begin
iAnimStart := True;
iAnimLineNumber := i;
end;
//Add entity data into datalist
if iAnimStart = true then Begin
iAnimList.Add(sCurrentLine);
end;
//Check for end of Entity state
if (iAnimStart = true) and
(sCurrentLine = '') then Begin
iAnimStart := false;
EntityDetails.addData(iAnimList, iAnimLineNumber);
iAnimLineNumber := 0;
iAnimList.Clear;
end;
end;}
populateGrid;
{iAnimList.Free;
aFileList.Free;}
end;
procedure TfrmEntityDetails.populateGrid;
Var
i : integer;
currentEntity : TEntityDetail;
begin
if EntityDetails <> nil then Begin
gridEntityDetails.RowCount := 2;
gridEntityDetails.ColCount := 2;
gridEntityDetails.ColCount := 6;
gridEntityDetails.Cells[0,0] := 'Line Number';
gridEntityDetails.Cells[1,0] := 'Anime Name';
gridEntityDetails.Cells[2,0] := 'Total Frames';
gridEntityDetails.Cells[3,0] := 'Total Delay';
gridEntityDetails.Cells[4,0] := 'Total Damage';
gridEntityDetails.Cells[5,0] := 'Total Hits';
for i := 0 to EntityDetails.list.Count -1 do Begin
currentEntity := (EntityDetails.list.Objects[i] as TEntityDetail);
gridEntityDetails.Cells[0,gridEntityDetails.RowCount] := IntToStr(currentEntity.LineNumber);
gridEntityDetails.Cells[1,gridEntityDetails.RowCount] := currentEntity.animeName;
gridEntityDetails.Cells[2,gridEntityDetails.RowCount] := IntToStr(currentEntity.totalFrames);
gridEntityDetails.Cells[3,gridEntityDetails.RowCount] := IntToStr(currentEntity.totalDelay);
gridEntityDetails.Cells[4,gridEntityDetails.RowCount] := IntToStr(currentEntity.totalDamage);
gridEntityDetails.Cells[5,gridEntityDetails.RowCount] := IntToStr(currentEntity.totalSeparateHits);
gridEntityDetails.RowCount := gridEntityDetails.RowCount + 1;
end;
end;
end;
procedure TfrmEntityDetails.tbOpenClick(Sender: TObject);
begin
if Form1.JvOpenDialog1.Execute then Begin
populateEntityDetails(Form1.JvOpenDialog1.FileName);
end;
end;
procedure TfrmEntityDetails.gridEntityDetailsDblClick(Sender: TObject);
Var
searchName:string;
i : integer;
begin
try
searchName := edtEntityFile.Text;
i := StrToInt((Sender as TJvStringGrid).Cells[0,(Sender as TJvStringGrid).Row]);
frmEditor.populateEditor(searchName,i);
frmEditor.Show;
except
end;
end;
procedure TfrmEntityDetails.FormDestroy(Sender: TObject);
begin
if(assigned(EntityDetails)) then FreeAndNil(EntityDetails);
end;
end.