-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAniConv.lpr
118 lines (104 loc) · 2.72 KB
/
AniConv.lpr
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
program AniConv;
{$mode objfpc}{$H+}
// {$define workingcopy}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, SysUtils, CustApp, JsonTools, AniTxtJson, castle_base
{ you can add units after this };
type
{ AniList }
AniList = class(TCustomApplication)
protected
procedure DoRun; override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure WriteHelp; virtual;
end;
{$ifdef workingcopy}
const AList: Array[0..11] of String = (
'C:\Assets\3drt\paid\chibii-racers-dirt-bikes\_bike_animations.txt',
'C:\Assets\3drt\paid\Crazy-Rabbits\crazy-rabbits-animations-list.txt',
'C:\Assets\3drt\paid\Elf-Females\souldblade-elfrangers-aniamtions-list.txt',
'C:\Assets\3drt\paid\Elf-Males\elfrangers-aniamtions-list.txt',
'C:\Assets\3drt\paid\Ghouls\animations-list-ghouls.txt',
'C:\Assets\3drt\paid\Goblins-Undead\goblin_anim.txt',
'C:\Assets\3drt\paid\Spiders\spider_anim.txt',
'C:\Assets\3drt\paid\Thief\Thief-animations-list.txt',
'C:\Assets\3drt\paid\Dragon\dragon_animation_list.txt',
'C:\Assets\3drt\paid\Dragon-boss\dragonboss_animation_list.txt',
'C:\Assets\3drt\paid\Elongata\Elong_anim.txt',
'C:\Assets\3drt\paid\Female-Ninja\Animations.txt');
{$endif}
{ AniList }
procedure AniList.DoRun;
var
FileName: String;
ErrorMsg: String;
Json: TJsonNode;
{$ifdef workingcopy}
I: Integer;
{$endif}
begin
// quick check parameters
ErrorMsg:=CheckOptions('h', 'help');
if ErrorMsg<>'' then begin
ShowException(Exception.Create(ErrorMsg));
Terminate;
Exit;
end;
// parse parameters
if HasOption('h', 'help') then begin
WriteHelp;
Terminate;
Exit;
end;
{ add your program here }
{$ifdef workingcopy}
for I := 0 to Length(Alist) - 1 do
begin
FileName := AList[I];
{$else}
FileName := 'C:\Assets\3drt\paid\Elf-Males\elfrangers-aniamtions-list.txt';
{$endif}
WriteLn('Parsing ' + FileName);
Json := AniTxtToJson(FileName);
if not(Json = nil) then
begin
WriteLn('Saving to ' + FileName + '.json');
WriteLn('');
Json.SaveToFile(FileName + '.json', True);
JSon.Free;
end
else
WriteLn('Errors encountered converting file.');
{$ifdef workingcopy}
end;
{$endif}
// stop program loop
Terminate;
end;
constructor AniList.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
StopOnException:=True;
end;
destructor AniList.Destroy;
begin
inherited Destroy;
end;
procedure AniList.WriteHelp;
begin
{ add your help code here }
writeln('Usage: ', ExeName, ' -h');
end;
var
Application: AniList;
begin
Application:=AniList.Create(nil);
Application.Title:='Animation List Converter';
Application.Run;
Application.Free;
end.