-
Notifications
You must be signed in to change notification settings - Fork 0
/
CCM_Png.pas
208 lines (180 loc) · 5.1 KB
/
CCM_Png.pas
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
unit CCM_Png;
interface
uses Classes;
type THEADER=record
pages_start:cardinal;
idstrings_size:cardinal;
idpointers_start:cardinal;
end;
type IDSTRING=smallint;
type IDPOINTER=longint;
type TSTRINGS=record
nbstrings:smallint;
strings:array[1..5000] of string[128];
end;
type TFRAMES2=record
typeframe2:smallint;
id_frame2:smallint;
idpointer_frame:IDPOINTER;
size_x:smallint;
size_y:smallint;
imageoffset_x:smallint;
imageoffset_y:smallint;
offset_x:smallint;
offset_y:smallint;
end;
type TFRAMES=record
typeframe:smallint;
id_frame:smallint;
size_x:smallint;
size_y:smallint;
numids:smallint;
ids:array[0..10] of smallint;
numinfos:smallint;
infos:array[0..10] of TFRAMES2;
end;
type TINFO=record
screenwidth:smallint;
screenheight:smallint;
page_start:IDPOINTER;
numframes:smallint;
frames:array[0..10] of TFRAMES;
end;
type TINDEXITEM=record
indexword:IDSTRING;
idpage:IDPOINTER;
nbpopups:smallint;
popups:array[0..10] of IDPOINTER;
end;
type TINDEX=record
indexlen:cardinal;
indexitems:array[0..2000] of TINDEXITEM;
end;
type TPOINTERS=record
nbpointers:cardinal;
pointers:array[0..2000] of cardinal;
end;
type TACTION=record
typeaction:smallint;
popup_id:IDPOINTER;
popuplevel:smallint;
item_id:smallint;
linkto:IDPOINTER;
soundtoplay:IDSTRING;
anim:IDSTRING;
command:smallint;
popup_to_close:IDPOINTER;
end;
type TITEM=record
itemtype:smallint;
item_id:smallint;
item_props:smallint;
imgwidth:smallint;
imgheight:smallint;
image:IDSTRING;
x1:smallint;
y1:smallint;
x2:smallint;
y2:smallint;
cursor:IDSTRING;
anim:IDSTRING;
numactions:smallint;
actions:array[0..1] of TACTION;
page_skip:IDPOINTER;
autostart:smallint;
nextpage:IDPOINTER;
popup_id:IDPOINTER;
letter:smallint;
end;
type TPAGE=record
typepage:smallint;
id_frame:smallint;
xoffset:smallint;
yoffset:smallint;
basedirectory:IDSTRING;
numitems:smallint;
items:array[0..100] of TITEM;
links_infos:smallint;
more_infos:smallint;
related_principles_popup:IDPOINTER;
machines_page:IDPOINTER;
inventors_page:IDPOINTER;
timeline_page:IDPOINTER;
end;
type TPOS=array[0..3] of integer;
function OpenPNG(filename:string):boolean;
procedure ClosePNG;
function ReadPagePNG(idpointer:longint):TPAGE;
function getIDPointer(idpointer:longint):longint;
function fixedNavBar(item_id:smallint; actualmachines_page, actualrelated_principles_popup, actualtimeline_page, actualinventors_page:IDPOINTER):IDPOINTER;
var header:THEADER;
strings:TSTRINGS;
info:TINFO;
index:TINDEX;
pointers:TPOINTERS;
PNG:TStream;
CCMWorkshop:IDPOINTER;
CCMindex:IDPOINTER;
CCMScrollBoxPos:TPOS;
implementation
uses CCM_PngEN, CCM_PngFR;
var realOpenPNG:function(filename:string):boolean;
realClosePNG:procedure;
realReadPagePNG:function(idpointer:longint):TPAGE;
realGetIDPointer:function(idpointer:longint):longint;
realFixedNavBar:function(item_id:smallint; actualmachines_page, actualrelated_principles_popup, actualtimeline_page, actualinventors_page:IDPOINTER):IDPOINTER;
currentEngine:word; // Moteur de décodage, 1 = EN, 2 = FR
function loadNextEngine:boolean;
begin
inc(currentEngine);
if (currentEngine = 1) then begin
realOpenPNG:=@CCM_PngEN.OpenPNG;
realClosePNG:=@CCM_PngEN.ClosePNG;
realReadPagePNG:=@CCM_PngEN.ReadPagePNG;
realgetIDPointer:=@CCM_PngEN.getIDPointer;
realFixedNavBar:=@CCM_PngEN.fixedNavBar;
CCMWorkshop:=CCM_PngEN.CCMWorkshop;
CCMindex:=CCM_PngEN.CCMindex;
CCMScrollBoxPos:=CCM_PngEN.CCMScrollBoxPos;
end;
if (currentEngine = 2) then begin
realOpenPNG:=@CCM_PngFR.OpenPNG;
realClosePNG:=@CCM_PngFR.ClosePNG;
realReadPagePNG:=@CCM_PngFR.ReadPagePNG;
realgetIDPointer:=@CCM_PngFR.getIDPointer;
realFixedNavBar:=@CCM_PngFR.fixedNavBar;
CCMWorkshop:=CCM_PngFR.CCMWorkshop;
CCMindex:=CCM_PngFR.CCMindex;
CCMScrollBoxPos:=CCM_PngFR.CCMScrollBoxPos;
end;
loadNextEngine:=currentEngine<=2;
end;
function OpenPNG(filename:string):boolean;
var res:boolean;
begin
res:=false;
while (loadNextEngine) do begin
res:=realOpenPNG(filename);
if (res) then break;
end;
OpenPNG:=res;
end;
procedure ClosePNG;
begin
realClosePNG;
end;
function ReadPagePNG(idpointer:longint):TPAGE;
begin
ReadPagePNG:=realReadPagePNG(idpointer);
end;
function getIDPointer(idpointer:longint):longint;
begin
getIDPointer:=realGetIDPointer(idpointer);
end;
function fixedNavBar(item_id:smallint; actualmachines_page, actualrelated_principles_popup, actualtimeline_page, actualinventors_page:IDPOINTER):IDPOINTER;
begin
fixedNavBar:=realFixedNavBar(item_id, actualmachines_page, actualrelated_principles_popup, actualtimeline_page, actualinventors_page);
end;
begin
currentEngine:=0;
end.