-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadgui.pp
409 lines (375 loc) · 12.1 KB
/
adgui.pp
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
unit adgui;
{$I-}
interface
procedure PrintInfo;
procedure PrintAsyaDrawLogo;
procedure PrintStartScreen;
procedure PrintAboutPage;
procedure PrintHelpPage;
procedure MessageScaleScreen(ScrnWidth, ScrnHeight: integer);
procedure ShowReadString(mes: string; x, y: integer);
procedure PrintFilename(filename: string);
procedure IOResultOpenFile;
procedure IOResultWriteFile;
procedure IOResultCreateFile;
procedure IOResultReadFile;
implementation
uses crt;
procedure PrintAnyMes(color, back, x, y: integer; var mes: string);
begin
TextColor(color);
TextBackground(back);
GotoXY(x, y);
write(mes)
end;
procedure PrintInfo;
var
symb: string = '|Symbol: ';
info: string = '| AsyaDraw is a free simple ASCII graphics editor using Free Pascal |';
begin
PrintAnyMes(White, Black, 1, 1, symb);
PrintAnyMes(White, Black, 12, 1, info);
end;
procedure PrintAsyaDrawLogo;
var
cX, cY: integer;
s1: string = ' ___ ____ ';
s2: string = ' / | _______ ______ _/ __ \_________ __ __';
s3: string = ' / /| | / ___/ / / / __ `/ / / / ___/ __ `/ | /| / /';
s4: string = ' / ___ |(__ ) /_/ / /_/ / /_/ / / / /_/ /| |/ |/ / ';
s5: string = '/_/ |_/____/\__, /\__,_/_____/_/ \__,_/ |__/|__/ ';
s6: string = ' /____/ ';
begin
cX := ScreenWidth div 2 - Length(s1) div 2 + 1;
cY := 1;
PrintAnyMes(LightCyan, Black, cX, cY, s1);
PrintAnyMes(LightCyan, Black, cX, cY + 1, s2);
PrintAnyMes(LightCyan, Black, cX, cY + 2, s3);
PrintAnyMes(LightCyan, Black, cX, cY + 3, s4);
PrintAnyMes(LightCyan, Black, cX, cY + 4, s5);
PrintAnyMes(LightCyan, Black, cX, cY + 5, s6);
end;
procedure PrintStartScreen;
var
cX, cY, dX: integer;
article: string = 'AsyaDraw is a free simple ASCII graphics editor using Free Pascal';
tabp: string = 'tab + ';
bblack: string = 'b - Black';
ublue: string = 'u - blUe';
ggren: string = 'g - Green';
ccyan: string = 'c - Cyan';
rred: string = 'r - Red';
mmagen: string = 'm - Magenta';
obrown: string = 'o - broWn';
lgray: string = 'l - Lightgray';
dgray: string = 'd - Darkgray';
hblue: string = 'h - ligHtblue';
ngren: string = 'n -lightgreeN';
acyan: string = 'a - lightcyAn';
ered: string = 'e - lightrEd';
tmagen: string = 't - lighTmagenTa';
yyelow: string = 'y - Yellow';
wwhite: string = 'w - White';
control: string = 'Arrows - Move; Any key - Brush; Space - Draw; Backspace - delete';
vers: string = 'V0.2.1 (2023.05.08)';
project: string = 'New/Open File: ';
abpage: string = 'Type /about - for more information or /help - for help';
begin
clrscr;
cX := ScreenWidth div 2;
cY := ScreenHeight div 2;
PrintAsyaDrawLogo;
PrintAnyMes(LightCyan, Black,cX - Length(article) div 2, 8, article);
PrintAnyMes(Black, LightGray, cX - Length(abpage) div 2, cY - 2, abpage);
dX := -36;
PrintAnyMes(White, Black, cX + dX, cY + 4, tabp);
dX := -30;
PrintAnyMes(Black, LightGray, cX + dX, cY + 4, bblack);
PrintAnyMes(Blue, Black, cX + dX, cY + 5, ublue);
PrintAnyMes(Green, Black, cX + dX, cY + 6, ggren);
PrintAnyMes(Cyan, Black, cX + dX, cY + 7, ccyan);
dX := -16;
PrintAnyMes(Red, Black, cX + dX, cY + 4, rred);
PrintAnyMes(Magenta, Black, cX + dX, cY + 5, mmagen);
PrintAnyMes(Brown, Black, cX + dX, cY + 6, obrown);
PrintAnyMes(LightGray, Black, cX + dX, cY + 7, lgray);
dX := 2;
PrintAnyMes(DarkGray, Black, cX + dX, cY + 4, dgray);
PrintAnyMes(LightBlue, Black, cX + dX, cY + 5, hblue);
PrintAnyMes(LightGreen, Black, cX + dX, cY + 6, ngren);
PrintAnyMes(LightCyan, Black, cX + dX, cY + 7, acyan);
dX := 20;
PrintAnyMes(LightRed, Black, cX + dX, cY + 4, ered);
PrintAnyMes(LightMagenta, Black, cX + dX, cY + 5, tmagen);
PrintAnyMes(Yellow, Black, cX + dX, cY + 6, yyelow);
PrintAnyMes(White, Black, cX + dX, cY + 7, wwhite);
dX := -33;
PrintAnyMes(Black, LightGray, cX + dX, cY + 10, control);
dX := -4;
PrintAnyMes(White, Black, ScreenWidth - Length(vers) + dX, ScreenHeight, vers);
dX := -36;
PrintAnyMes(White, Black, cX + dX, cY, project);
end;
procedure PrintAboutPage;
var
cX, cY: integer;
s1: string = 'ASYADRAW';
s2: string = 'Author: Ulysses Apokin (JELISEJ APOKIN)';
s3: string = 'Contacts: aoipkn@yandex.ru';
s4: string = ' greenoctopuscinema@gmail.com';
s5: string = ' @epo124 (Telegram)';
s6: string = 'LICENSE';
s7: string = 'This license establishes the rules for using and distributing the AsyaDraw';
s8: string = 'program. You are allowed to freely execute the program for any purpose.';
s9: string = 'It is allowed to modify the text of the program. Permission is granted to';
s10: string = 'distribute FREE copies of this program to others. It is allowed to transfer';
s11: string = 'modified copies of the program to others, with a MANDATORY description of';
s12: string = 'the changes made. ';
s13: string = 'SOURCE CODE';
s14: string = 'https://github.com/UlyssesApokin/AsyaDrawFPC.git';
begin
clrscr;
PrintAsyaDrawLogo;
cX := ScreenWidth div 2 - Length(s1) div 2 + 1;
cY := 8;
PrintAnyMes(LightCyan, Black, cX, cY, s1);
cY := 8;
cX := ScreenWidth div 2 - Length(s2) div 2 + 1;
PrintAnyMes(White, Black, cX, cY + 1, s2);
PrintAnyMes(White, Black, cX, cY + 2, s3);
PrintAnyMes(White, Black, cX, cY + 3, s4);
PrintAnyMes(White, Black, cX, cY + 4, s5);
cY := 14;
cX := ScreenWidth div 2 - Length(s6) div 2 + 1;
PrintAnyMes(LightCyan, Black, cX, cY, s6);
cY := 15;
cX := ScreenWidth div 2 - Length(s7) div 2 + 1;
PrintAnyMes(White, Black, cX, cY, s7);
PrintAnyMes(White, Black, cX, cY + 1, s8);
PrintAnyMes(White, Black, cX, cY + 2, s9);
PrintAnyMes(White, Black, cX, cY + 3, s10);
PrintAnyMes(White, Black, cX, cY + 4, s11);
PrintAnyMes(White, Black, cX, cY + 5, s12);
cY := 21;
cX := ScreenWidth div 2 - Length(s13) div 2 + 1;
PrintAnyMes(LightCyan, Black, cX, cY, s13);
cY := 22;
cX := ScreenWidth div 2 - Length(s14) div 2 + 1;
PrintAnyMes(White, Black, cX, cY, s14);
end;
procedure PrintHelpPage;
var
cX, cY: integer;
s1: string = 'START';
s2: string = 'To start creating beautiful images, enter the name of your work in the line';
s3: string = '"New/Open File:". This operation will create a file with the same name in';
s4: string = 'the directory where the program is running. If a file with that name already';
s5: string = 'exists, it will be opened.';
s6: string = 'DRAW';
s7: string = 'Use the arrows on the keyboard to move the cursor on the screen. In the upper';
s8: string = 'left corner you will see the symbol and the color with which you draw. To';
s9: string = 'change the drawing symbol, use any key on the keyboard. For example, the "g"';
s10: string = 'or "#" key. To change the drawing color, use double tab or alternately';
s11: string = 'press tab and then any of the keys "b"/ "u"/ "g"/ "c"/ "r"/ "m"/ "o"/ "l"/';
s12: string = '"d"/ "n"/ "a"/ "e"/ "t"/ "y"/ "w". Press the space bar to draw a symbol on';
s13: string = 'the screen. And backspace to delete the character. Use tab + 2 to change';
s14: string = 'just the character.';
s15: string = 'SAVE & EXIT';
s16: string = 'Your work is saved in real time. Press escape to exit the program. You will';
s17: string = 'see your image file in the directory from which the program was launched.';
s18: string = 'To open it, use AsyaDraw.';
begin
clrscr;
cX := ScreenWidth div 2;
cY := 2;
PrintAnyMes(LightCyan, Black, cX - Length(s1) div 2, cY, s1);
PrintAnyMes(White, Black, cX - Length(s2) div 2, cY + 1, s2);
PrintAnyMes(White, Black, cX - Length(s2) div 2, cY + 2, s3);
PrintAnyMes(White, Black, cX - Length(s2) div 2, cY + 3, s4);
PrintAnyMes(White, Black, cX - Length(s2) div 2, cY + 4, s5);
cY := 8;
PrintAnyMes(LightCyan, Black, cX - Length(s6) div 2, cY, s6);
PrintAnyMes(White, Black, cX - Length(s8) div 2, cY + 1, s7);
PrintAnyMes(White, Black, cX - Length(s8) div 2, cY + 2, s8);
PrintAnyMes(White, Black, cX - Length(s8) div 2, cY + 3, s9);
PrintAnyMes(White, Black, cX - Length(s8) div 2, cY + 4, s10);
PrintAnyMes(White, Black, cX - Length(s8) div 2, cY + 5, s11);
PrintAnyMes(White, Black, cX - Length(s8) div 2, cY + 6, s12);
PrintAnyMes(White, Black, cX - Length(s8) div 2, cY + 7, s13);
PrintAnyMes(White, Black, cX - Length(s8) div 2, cY + 8, s14);
cY := 18;
PrintAnyMes(LightCyan, Black, cX - Length(s15) div 2, cY, s15);
PrintAnyMes(White, Black, cX - Length(s16) div 2, cY + 1, s16);
PrintAnyMes(White, Black, cX - Length(s16) div 2, cY + 2, s17);
PrintAnyMes(White, Black, cX - Length(s16) div 2, cY + 3, s18);
end;
procedure PrintFrame(x, y, sizeX, sizeY: integer);
var
i: integer;
begin
TextColor(LightGray);
for i := 0 to sizeX do
begin
GotoXY(x + i, y);
Write('#')
end;
for i := 0 to sizeX do
begin
GotoXY(x + i, y + SizeY);
Write('#')
end;
for i := 0 to SizeY do
begin
GotoXY(x, y + i);
Write('#')
end;
for i := 0 to SizeY do
begin
GotoXY(x + sizeX, y + i);
write('#')
end
end;
procedure MessageCantOpenFile;
var
x, y: integer;
sizeX, sizeY: integer;
mes: string = 'Couldn''t open the file';
begin
clrscr;
sizeX := 29;
sizeY := 6;
x := (ScreenWidth div 2) - (sizeX div 2);
y := (ScreenHeight div 2) - 1 - (sizeY div 2);
PrintFrame(x, y, sizeX, sizeY);
PrintAnyMes(Yellow, Black, x + 4, y + (sizeY div 2), mes);
PrintAsyaDrawLogo;
TextColor(White);
GotoXY(1, ScreenHeight);
end;
procedure MessageCantCreateFile;
var
x, y: integer;
sizeX, sizeY: integer;
mes: string = 'Couldn''t create the file';
begin
clrscr;
sizeX := 29;
sizeY := 6;
x := (ScreenWidth div 2) - (sizeX div 2);
y := (ScreenHeight div 2) - 1 - (sizeY div 2);
PrintFrame(x, y, sizeX, sizeY);
PrintAnyMes(Yellow, Black, x + 4, y + (sizeY div 2), mes);
PrintAsyaDrawLogo;
TextColor(White);
GotoXY(1, ScreenHeight);
end;
procedure MessageCantReadFile;
var
x, y: integer;
sizeX, sizeY: integer;
mes: string = 'Couldn''t read to the file';
begin
clrscr;
sizeX := 35;
sizeY := 6;
x := (ScreenWidth div 2) - (sizeX div 2);
y := (ScreenHeight div 2) - 1 - (sizeY div 2);
PrintFrame(x, y, sizeX, sizeY);
PrintAnyMes(Yellow, Black, x + 4, y + (sizeY div 2), mes);
PrintAsyaDrawLogo;
TextColor(White);
GotoXY(1, ScreenHeight);
end;
procedure MessageCantWriteFile;
var
x, y: integer;
sizeX, sizeY: integer;
mes: string = 'Couldn''t write to the file';
begin
clrscr;
sizeX := 36;
sizeY := 6;
x := (ScreenWidth div 2) - (sizeX div 2);
y := (ScreenHeight div 2) - 1 - (sizeY div 2);
PrintFrame(x, y, sizeX, sizeY);
PrintAnyMes(Yellow, Black, x + 4, y + (sizeY div 2), mes);
PrintAsyaDrawLogo;
TextColor(White);
GotoXY(1, ScreenHeight);
end;
procedure MessageScaleScreen(ScrnWidth, ScrnHeight: integer);
var
x, y: integer;
sizeX, sizeY: integer;
mes1: string = 'The size of this image is ';
mes2: string = 'The size of your screen workspace is ';
mes3: string = 'Scale the workspace to the size of the image';
begin
clrscr;
sizeX := 51;
sizeY := 8;
x := (ScreenWidth div 2) - (sizeX div 2);
y := (ScreenHeight div 2) - (sizeY div 2);
PrintFrame(x, y, sizeX, sizeY);
PrintAnyMes(Yellow, Black, x + 4, y + (sizeY div 2) - 2, mes1);
GotoXY(x + 4, y + (sizeY div 2) - 1);
write(ScrnWidth, 'X', ScrnHeight);
PrintAnyMes(Yellow, Black, x + 4, y + (sizeY div 2), mes2);
GotoXY(x + 4, y + (sizeY div 2) + 1);
write(ScreenWidth, 'X', ScreenHeight - 1);
PrintAnyMes(Yellow, Black, x + 4, y + (sizeY div 2) + 2, mes3);
PrintAsyaDrawLogo;
TextColor(White);
GotoXY(1, ScreenHeight);
end;
procedure ShowReadString(mes: string; x, y: integer);
var
s: string = ' ';
i: integer;
begin
for i := 0 to Length(mes) do
begin
PrintAnyMes(White, Black, x + i, y, s);
end;
PrintAnyMes(White, Black, x, y, mes)
end;
procedure PrintFilename(filename: string);
var
mes: string = ' File: ';
begin
PrintAnyMes(White, Black, 1, ScreenHeight, mes);
ShowReadString(filename, 8, ScreenHeight);
end;
procedure IOResultOpenFile;
begin
if IOResult <> 0 then
begin
MessageCantOpenFile;
halt(1)
end
end;
procedure IOResultCreateFile;
begin
if IOResult <> 0 then
begin
MessageCantCreateFile;
halt(1)
end
end;
procedure IOResultWriteFile;
begin
if IOResult <> 0 then
begin
MessageCantWriteFile;
halt(1)
end
end;
procedure IOResultReadFile;
begin
if IOResult <> 0 then
begin
MessageCantReadFile;
halt(1)
end
end;
end.