Skip to content

Commit 19c111c

Browse files
committed
Add PRIKAZY.PAS
1 parent 7161f29 commit 19c111c

File tree

1 file changed

+154
-0
lines changed

1 file changed

+154
-0
lines changed

PUDR/PRIKAZY.PAS

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
function last_command: PCommand;
2+
var result: PCommand;
3+
4+
begin result := cmd_start;
5+
while result^.next <> nil do
6+
result := result^.next;
7+
8+
last_command := result end;
9+
10+
11+
procedure add_command(x: Word; y, fg, bg: Byte; type_of, name: string;
12+
action, target: Shortint; thing: Shortint);
13+
var x2: Word;
14+
y2, space: Byte;
15+
region: rectangle_region;
16+
prep: string[6];
17+
new_cmd: PCommand;
18+
19+
begin New(new_cmd);
20+
new_cmd^.name := name;
21+
new_cmd^.action := action;
22+
new_cmd^.target := target;
23+
new_cmd^.next := nil;
24+
25+
if cmd_start = nil then
26+
cmd_start := new_cmd
27+
else
28+
last_command^.next := new_cmd;
29+
30+
region[left] := x;
31+
region[top] := y;
32+
33+
if type_of = 'text' then begin
34+
space := Pos('!'{space}, name);
35+
prep := Copy(name, 1, space);
36+
name := Copy(name, space + 1, 10);
37+
38+
{add arrows indicating movement along corridor}
39+
if (target in [10..18]) and (room in [10..18]) then
40+
if target < room then
41+
Insert('!!!'#27, prep, 3)
42+
else
43+
Insert('!!!'#26, prep, 3);
44+
45+
x2 := x + 8*Length(name) + 3;
46+
y2 := y + 28;
47+
48+
{display text command}
49+
SetFillStyle(SolidFill, bg);
50+
Bar(x, y, x2, y2);
51+
PutPixel(x + 1, y + 1, 3 - bg);
52+
PutPixel(x2 - 1, y + 1, 3 - bg);
53+
PutPixel(x + 1, y2 - 1, 3 - bg);
54+
PutPixel(x2 - 1, y2 - 1, 3 - bg);
55+
SetColor(fg);
56+
SetTextJustify(LeftText, TopText);
57+
decode_and_write(x + 3, y + 7, prep);
58+
decode_and_write(x + 3, y + 17, name);
59+
if action >= 0 then
60+
Line(x + 3, y + 25, x + 9, y + 25);
61+
{x_pos is global, shared with set_clickables and between calls to add_command}
62+
x_pos := x2 end
63+
64+
else begin
65+
x2 := x + 37;
66+
y2 := y + 33 end;
67+
68+
region[right] := x2;
69+
region[bottom] := y2;
70+
new_cmd^.region := region end;
71+
72+
73+
procedure remove_last_command;
74+
var cmd, last: PCommand;
75+
76+
begin cmd := cmd_start;
77+
last := last_command;
78+
while cmd^.next <> last do
79+
cmd := cmd^.next;
80+
cmd^.next := nil;
81+
Dispose(last) end;
82+
83+
84+
procedure clear_clickables;
85+
begin
86+
while last_command <> main_commands[5] do
87+
remove_last_command end;
88+
89+
90+
procedure set_clickables(type_of: string);
91+
var i, inv_slot: Byte;
92+
exits, exit_name: string;
93+
94+
begin
95+
clear_clickables;
96+
97+
if type_of = 'things' then begin
98+
99+
for i := 0 to thing_count do
100+
{things in room}
101+
if (things[i].where = room) then
102+
if ((action <> 2) or things[i].portable) {only portable things can be taken}
103+
and ((action <> 2) or not inventory_full) {& can be taken if inventory not full}
104+
and (action <> 3) {& only owned things can be used}
105+
and ((action <> 4) or (i in openables)) {& only some things make sense to open}
106+
then
107+
add_command(103 + 38*things[i].slot, 12,
108+
0, 0, 'image', things[i].name, -1, i, i)
109+
else begin {dangling else} end
110+
111+
{things in inventory}
112+
else if (things[i].where = 50) then
113+
if (action <> 2) {owned things can't be taken}
114+
and ((action <> 4) or (i in openables)) {& only some things make sense to open}
115+
then begin
116+
inv_slot := 0;
117+
while inventory[inv_slot] <> i do
118+
Inc(inv_slot);
119+
add_command(41 + 40*inv_slot, 128,
120+
0, 0, 'image', things[i].name, -1, i, i) end end
121+
122+
else if type_of = 'exits' then begin
123+
{x_pos is global, shared with add_command}
124+
x_pos := 155;
125+
126+
{first pass: get correct x_pos for a centered display}
127+
exits := room_exits[room];
128+
for i := 1 to Length(exits) do begin
129+
destination := Ord(exits[i]) - 48;
130+
exit_name := exit_names[destination];
131+
exit_name := Copy(exit_name, Pos('!'{space}, exit_name) + 1, 10);
132+
x_pos := x_pos - 4*Length(exit_name) - 3 end;
133+
134+
{second pass: display commands}
135+
for i := 1 to Length(exits) do begin
136+
destination := Ord(exits[i]) - 48;
137+
add_command(x_pos + 5, 79, 3 - i, i, 'text',
138+
exit_names[destination], -1, destination, -1) end end
139+
140+
else
141+
add_command(130, 79, 0, 3, 'text', texts_short[8]{Odejit do DOSu}, -1, 0, -1) end;
142+
143+
144+
function get_clicked_command: PCommand;
145+
var result: PCommand;
146+
147+
begin result := cmd_start;
148+
while result <> nil do begin
149+
if (result^.region[left] <= mouse.x) and (mouse.x <= result^.region[right])
150+
and (result^.region[top] <= mouse.y) and (mouse.y <= result^.region[bottom]) then
151+
Break;
152+
result := result^.next end;
153+
154+
get_clicked_command := result end;

0 commit comments

Comments
 (0)