blib/lib/Games/Axmud/Obj/Parchment.pm untested

filter: Statementstmt 0.0% 0 / 470 Branchbran 0.0% 0 / 172 Conditioncond 0.0% 0 / 129 MC/DCmcdc 0.0% 0 / 70 Subroutinesub 0.0% 0 / 70 Podpod 0.0% 0 / 64 totaltotal 0.0% 0 / 975 CC 87 SCAR 32.9
CC
87
Cov
0%
deleteDrawnRoom
132.0
deleteDrawnExit
90.0
deleteDrawnExitTag
42.0
CRAP 27.0
1 # Copyright (C) 2011-2024 A S Lewis
2 #
3 # This program is free software: you can redistribute it and/or modify it under the terms of the GNU
4 # General Public License as published by the Free Software Foundation, either version 3 of the
5 # License, or (at your option) any later version.
6 #
7 # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
8 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9 # General Public License for more details.
10 #
11 # You should have received a copy of the GNU General Public License along with this program. If not,
12 # see <http://www.gnu.org/licenses/>.
13 #
14 #
15 # Games::Axmud::Obj::Parchment
16 # Handles canvas widgets and canvas objects for drawing a single region
17 # Games::Axmud::Obj::ParchmentLevel
18 # Stores the canvas objects drawn on a single level in that region
19  
20 { package Games::Axmud::Obj::Parchment;
21  
22 use strict;
23 use warnings;
24 # use diagnostics;
25  
26 use Glib qw(TRUE FALSE);
27  
28 our @ISA = qw(Games::Axmud);
29  
30 ##################
31 # Constructors
32  
33 sub new {
34  
35 # Called by GA::Win::Map->setCurrentRegion and ->preparePreDraw
36 # Creates a parchment object, which handles canvas widgets and canvas objects for drawing a
37 # single region
38 #
39 # Expected arguments
40 # $name - The name of the region/regionmap (matching a key in
41 # GA::Obj::WorldModel->regionmapHash)
42 # $worldModelObj - The world model (GA::Obj::WorldModel) used by this session
43 #
44 # Return values
45 # 'undef' on improper arguments
46 # Blessed reference to the newly-created object on success
47  
48 my ($class, $name, $worldModelObj, $check) = @_;
49  
50 # Check for improper arguments
51 if (! defined $name || defined $check) {
52  
53 return $axmud::CLIENT->writeImproper($class . '->new', @_);
54 }
55  
56 # Setup
57 my $self = {
58 _objName => $name,
59 _objClass => $class,
60 _parentFile => undef,
61 _parentWorld => undef,
62 _privFlag => FALSE, # All IVs are public
63  
64 # IVs
65 # ---
66  
67 # The name of the region/regionmap (matching a key in
68 # GA::Obj::WorldModel->regionmapHash)
69 name => $name,
70 # The world model (GA::Obj::WorldModel) used by this session
71 worldModelObj => $worldModelObj,
72  
73 # A hash of Goo2Canvas::Canvas widgets, one for each level on which rooms, exits and
74 # labels are drawn
75 # Hash in the form
76 # $canvasWidgetHash{level} = Goo2Canvas::Canvas
77 canvasWidgetHash => {},
78 # In order to make the background the colour we want, a single Goo2Canvas::CanvasRect
79 # (called the 'background canvas object) is drawn, one for each level
80 # Hash in the form
81 # $bgHash{level} = Goo2Canvas::CanvasRect
82 bgCanvasObjHash => {},
83  
84 # The map itself is just a collection of GA::ModelObj::Room objects, GA::Obj::Exit
85 # objects and GA::Obj::MapLabel objects. They are stored in each region's
86 # GA::Obj::Regionmap
87 # This parchment objects consists of one or more canvas widgets (Goo2Canvas::Canvas
88 # objects, stored above), and a collection of canvas objects
89 # (Goo2Canvas::CanvasRect, Goo2Canvas::CanvasText, etc)
90 # Each GA::ModelObj::Room, GA::Obj::Exit and GA::Obj::MapLabel object is drawn using
91 # one or more canvas objects
92 # In order to stack the canvas objects correctly (i.e. so labels appear above rooms),
93 # we need to know which canvas objects have been drawn on each level
94 # A parchment level object (GA::Obj::ParchmentLevel) stores all the canvas objects
95 # drawn on each level. Hash in the form
96 # $levelHash{level} = blessed_reference_to_parchment_level_object
97 levelHash => {},
98  
99 # Coloured squares and rectangles are stored here, not in the parchment level object
100 # Hash of coloured gridblocks (for background colouring, not a clickable object on the
101 # map), in the form
102 # $colouredSquareHash{'x_y_z'} = canvas_object
103 colouredSquareHash => {},
104 # Hash of coloured rectangles (for background colouring, not a clickable object on the
105 # map), in the form
106 # $colouredRectHash{object-number_level} = canvas_object
107 colouredRectHash => {},
108  
109 # When we need to draw (or redraw) objects on the canvas, we might want to
110 # 1. Draw the objects right away, because they're drawn on the visible region and
111 # level
112 # 2. Don't draw the objects yet, because we want to wait until something is finished
113 # before we do the drawing
114 # 3. Don't draw the objects yet, because they're not drawn on the visible region and
115 # level; add them to the queue so they can be drawn by background processes (i.e.
116 # regular calls to GA::Win::Map->winUpdate)
117 #
118 # For (1) draw things right away, code can call GA::Win::Map->doDraw with a list of
119 # things to draw. Anything that's not on the visible region and level is added to the
120 # queue (3)
121 #
122 # For (2) drawn things soon, code can call GA::Win::Map->markObjs. Any objects on the
123 # visible region and level are added to these hashes; any other objects are added to
124 # the queue (3)
125 # When it's time to draw the marked objects, the code can just call ->doDraw again
126 #
127 # Since we're using hashes, it's safe to call ->doDraw or ->markObjs with the same
128 # object multiple times
129 # Drawing a room will redraw any room tags/room guilds associated with that room. If
130 # the room tag/room guild has already been drawn, it is not drawn a second time during
131 # any single call to GA::Win::Map->doDraw.
132 # The same applies for exits; drawing an exit will redraw its exit tag. If the exit tag
133 # has already been drawn, it is not drawn a second time during any single call to
134 # GA::Win::Map->doDraw
135 # Hash of rooms to be drawn soon, in the form
136 # $markedRoomHash{model_number} = blessed_reference_to_room_object
137 markedRoomHash => {},
138 # Hash of room tags to be drawn soon, in the form
139 # $markedRoomTagHash{model_number} = blessed_reference_to_room_object
140 markedRoomTagHash => {},
141 # Hash of room guilds to be drawn soon, in the form
142 # $markedRoomGuildHash{model_number} = blessed_reference_to_room_object
143 markedRoomGuildHash => {},
144 # Hash of exits to be drawn soon, in the form
145 # $markedExitHash{exit_model_number} = blessed_reference_to_exit_object
146 markedExitHash => {},
147 # Hash of exit tagss to be drawn soon, in the form
148 # $markedExitTagHash{exit_model_number} = blessed_reference_to_exit_object
149 markedExitTagHash => {},
150 # Hash of labels to be drawn soon, in the form
151 # $markedLabelHash{label_number} = blessed_reference_to_label_object
152 markedLabelHash => {},
153 #
154 # For (3) draw things using background processes, objects are added to these hashes
155 # until the background processes are ready to draw them
156 # Canvas objects are arranged in a stack (so that labels are drawn above rooms). The
157 # stack is in the order:
158 # 7 - labels and draggable exits (placed at the top of the stack)
159 # 6 - room tags, room guilds and exit tags
160 # 5 - exits, exit ornaments and checked directions
161 # 4 - room interior text
162 # 3 - room boxes
163 # 2 - room echoes and fake room boxes
164 # 1 - coloured rectangles on the map background
165 # 0 - coloured blocks on the map background
166 # - - map background (at the bottom of the stack)
167 # When pre-drawing, objects are drawn in stack order, from bottom to top; in very large
168 # maps (thousands of rooms), GooCanvas2 can complete the drawing much more quickly
169 # when everything can be raised to the top of the stack, rather than being
170 # arbitrarily inserted somewhere in the middle
171 #
172 # Hash of rooms whose room echoes are waiting to be drawn. in the form
173 # $queueRoomEchoHash{model_number} = blessed_reference_to_room_object
174 # (When the echo is drawn, the room is removed from this hash, and added to the next)
175 queueRoomEchoHash => {},
176 # Hash of rooms whose room boxes are waiting to be drawn, in the form
177 # $queueRoomBoxHash{model_number} = blessed_reference_to_room_object
178 # (When the box is drawn, the room is removed from this hash, and added to the next)
179 queueRoomBoxHash => {},
180 # Hash of rooms whose interior text is waiting to be drawn, in the form
181 # $queueRoomTextHash{model_number} = blessed_reference_to_room_object
182 # (When the text is drawn, the room is removed from this hash, and added to the next)
183 queueRoomTextHash => {},
184 # Hash of rooms whose exits, exit ornaments and checked directions are waiting to be
185 # drawn, in the form
186 # $queueRoomExitHash{model_number} = blessed_reference_to_room_object
187 # (When the text is drawn, the room is removed from this hash, and added to the next)
188 queueRoomExitHash => {},
189 # Hash of rooms whose room tags, room guilds and exit tags are waiting to be drawn, in
190 # the form
191 # $queueRoomInfoHash{model_number} = blessed_reference_to_room_object
192 # (When the text is drawn, the room is completely drawn, so is removed from this hash)
193 queueRoomInfoHash => {},
194 # Hash of labels waiting to be drawn, in the form
195 # $queueLabelHash{label_number} = blessed_reference_to_label_object
196 queueLabelHash => {},
197  
198 # When obscured rooms are enabled, exits are only drawn for rooms near the current room,
199 # or for selected rooms (and selected exits), and for rooms whose rooms flags match
200 # those in GA::Client->constRoomNoObscuredHash (e.g. 'main_route')
201 # When obscured rooms are enabled, this hash is reset by a call to
202 # GA::Win::Map->compileNoObscuredRooms. The hash contains any rooms which are due to
203 # be drawn, and which should not be obscured
204 # Hash in the form
205 # $noObscuredRoomHash{model_number} = undef
206 noObscuredRoomHash => {},
207 # When $self->noObscuredRoomHash, any rooms that are being removed from the hash are
208 # stored in this IV. The calling code uses this IV to destroy the room's exit canvas
209 # objects, if required
210 reObscuredRoomHash => {},
211 };
212  
213 # Bless the object into existence
214 bless $self, $class;
215 return $self;
216 }
217  
218 ##################
219 # Methods
220  
221 # Get canvas objects
222  
223 sub getDrawnRoom {
224  
225 # Called by various functions
226 # Given a room model object (GA::ModelObj::Room), returns a reference to a list of canvas
227 # objects that have been used to draw it (or 'undef', if that room isn't yet drawn in this
228 # region)
229 #
230 # Expected arguments
231 # $roomObj - The room model object
232 #
233 # Return values
234 # 'undef' on improper arguments or if the room object has not been drawn
235 # Otherwise returns the list reference described above
236  
237 my ($self, $roomObj, $check) = @_;
238  
239 # Local variables
240 my $levelObj;
241  
242 # Check for improper arguments
243 if (! defined $roomObj || defined $check) {
244  
245 return $axmud::CLIENT->writeImproper($self->_objClass . '->getDrawnRoom', @_);
246 }
247  
248 $levelObj = $self->ivShow('levelHash', $roomObj->zPosBlocks);
249 if ($levelObj) {
250  
251 return $levelObj->ivShow(
252 'drawnRoomHash',
253 $roomObj->xPosBlocks . '_' . $roomObj->yPosBlocks . '_' . $roomObj->zPosBlocks,
254 );
255  
256 } else {
257  
258 # Room not drawn
259 return undef;
260 }
261 }
262  
263 sub getDrawnExit {
264  
265 # Called by various functions
266 # Given an exit model object (GA::Obj::Exit), returns a reference to a list of canvas
267 # objects that have been used to draw it (or 'undef', if that exit isn't yet drawn in this
268 # region)
269 #
270 # Expected arguments
271 # $exitObj - The exit model object
272 #
273 # Optional arguments
274 # $roomObj - The exit's parent room, if known. Otherwise this function fetches it
275 #
276 # Return values
277 # 'undef' on improper arguments or if the exit object has not been drawn
278 # Otherwise returns the list reference described above
279  
280 my ($self, $exitObj, $roomObj, $check) = @_;
281  
282 # Local variables
283 my $levelObj;
284  
285 # Check for improper arguments
286 if (! defined $exitObj || defined $check) {
287  
288 return $axmud::CLIENT->writeImproper($self->_objClass . '->getDrawnExit', @_);
289 }
290  
291 if (! $roomObj) {
292  
293 $roomObj = $self->worldModelObj->ivShow('modelHash', $exitObj->parent);
294 }
295  
296 if ($roomObj) {
297  
298 $levelObj = $self->ivShow('levelHash', $roomObj->zPosBlocks);
299 if ($levelObj) {
300  
301 return $levelObj->ivShow('drawnExitHash', $exitObj->number);
302 }
303 }
304  
305 # Exit not drawn
306 return undef;
307 }
308  
309 sub getDrawnLabel {
310  
311 # Called by various functions
312 # Given a map label object (GA::Obj::MapLabel), returns a reference to a list of canvas
313 # objects that have been used to draw it (or 'undef', if that room isn't yet drawn in this
314 # region)
315 #
316 # Expected arguments
317 # $labelObj - The map label object
318 #
319 # Return values
320 # 'undef' on improper arguments or if the label object has not been drawn
321 # Otherwise returns the list reference described above
322  
323 my ($self, $labelObj, $check) = @_;
324  
325 # Local variables
326 my $levelObj;
327  
328 # Check for improper arguments
329 if (! defined $labelObj || defined $check) {
330  
331 return $axmud::CLIENT->writeImproper($self->_objClass . '->getDrawnLabel', @_);
332 }
333  
334 $levelObj = $self->ivShow('levelHash', $labelObj->level);
335 if ($levelObj) {
336  
337 return $levelObj->ivShow('drawnLabelHash', $labelObj->number);
338  
339 } else {
340  
341 # Label not drawn
342 return undef;
343 }
344 }
345  
346 # Add canvas objects
347  
348 sub addDrawnRoom {
349  
350 # After drawing a room model object (GA::ModelObj::Room), the automapper window calls this
351 # function to store the canvas object(s)
352 #
353 # Expected arguments
354 # $roomObj - The room model object
355 # $listRef - Reference to a list of canvas objects
356 #
357 # Return values
358 # 'undef' on improper arguments
359 # 1 otherwise
360  
361 my ($self, $roomObj, $listRef, $check) = @_;
362  
363 # Local variables
364 my $levelObj;
365  
366 # Check for improper arguments
367 if (! defined $roomObj || ! defined $listRef || defined $check) {
368  
369 return $axmud::CLIENT->writeImproper($self->_objClass . '->addDrawnRoom', @_);
370 }
371  
372 $levelObj = $self->ivShow('levelHash', $roomObj->zPosBlocks);
373 if ($levelObj) {
374  
375 $levelObj->ivAdd(
376 'drawnRoomHash',
377 $roomObj->xPosBlocks . '_' . $roomObj->yPosBlocks . '_' . $roomObj->zPosBlocks,
378 $listRef,
379 );
380 }
381  
382 return 1;
383 }
384  
385 sub addDrawnRoomEcho {
386  
387 # After drawing a room echo for a room model object (GA::ModelObj::Room), the automapper
388 # window calls this function to store the canvas object(s)
389 #
390 # Expected arguments
391 # $roomObj - The room model object
392 # $mode - +1 if this echo is drawn just above the room, -1 if it's drawn just below
393 # the room
394 # $listRef - Reference to a list of canvas objects
395 #
396 # Return values
397 # 'undef' on improper arguments
398 # 1 otherwise
399  
400 my ($self, $roomObj, $mode, $listRef, $check) = @_;
401  
402 # Local variables
403 my $levelObj;
404  
405 # Check for improper arguments
406 if (! defined $roomObj || ! defined $mode || ! defined $listRef || defined $check) {
407  
408 return $axmud::CLIENT->writeImproper($self->_objClass . '->addDrawnRoomEcho', @_);
409 }
410  
411 $levelObj = $self->ivShow('levelHash', ($roomObj->zPosBlocks + $mode));
412 if ($levelObj) {
413  
414 $levelObj->ivAdd(
415 'drawnRoomEchoHash',
416 $roomObj->xPosBlocks . '_' . $roomObj->yPosBlocks . '_' . $roomObj->zPosBlocks,
417 $listRef,
418 );
419 }
420  
421 return 1;
422 }
423  
424 sub addDrawnRoomTag {
425  
426 # After drawing a room tag for a room model object (GA::ModelObj::Room), the automapper
427 # window calls this function to store the canvas object(s)
428 #
429 # Expected arguments
430 # $roomObj - The room model object
431 # $listRef - Reference to a list of canvas objects
432 #
433 # Return values
434 # 'undef' on improper arguments
435 # 1 otherwise
436  
437 my ($self, $roomObj, $listRef, $check) = @_;
438  
439 # Local variables
440 my $levelObj;
441  
442 # Check for improper arguments
443 if (! defined $roomObj || ! defined $listRef || defined $check) {
444  
445 return $axmud::CLIENT->writeImproper($self->_objClass . '->addDrawnRoomTag', @_);
446 }
447  
448 $levelObj = $self->ivShow('levelHash', $roomObj->zPosBlocks);
449 if ($levelObj) {
450  
451 $levelObj->ivAdd(
452 'drawnRoomTagHash',
453 $roomObj->xPosBlocks . '_' . $roomObj->yPosBlocks . '_' . $roomObj->zPosBlocks,
454 $listRef,
455 );
456 }
457  
458 return 1;
459 }
460  
461 sub addDrawnRoomGuild {
462  
463 # After drawing a room guild for a room model object (GA::ModelObj::Room), the automapper
464 # window calls this function to store the canvas object(s)
465 #
466 # Expected arguments
467 # $roomObj - The room model object
468 # $listRef - Reference to a list of canvas objects
469 #
470 # Return values
471 # 'undef' on improper arguments
472 # 1 otherwise
473  
474 my ($self, $roomObj, $listRef, $check) = @_;
475  
476 # Local variables
477 my $levelObj;
478  
479 # Check for improper arguments
480 if (! defined $roomObj || ! defined $listRef || defined $check) {
481  
482 return $axmud::CLIENT->writeImproper($self->_objClass . '->addDrawnRoomGuild', @_);
483 }
484  
485 $levelObj = $self->ivShow('levelHash', $roomObj->zPosBlocks);
486 if ($levelObj) {
487  
488 $levelObj->ivAdd(
489 'drawnRoomGuildHash',
490 $roomObj->xPosBlocks . '_' . $roomObj->yPosBlocks . '_' . $roomObj->zPosBlocks,
491 $listRef,
492 );
493 }
494  
495 return 1;
496 }
497  
498 sub addDrawnRoomText {
499  
500 # After drawing room text for a room model object (GA::ModelObj::Room), the automapper
501 # window calls this function to store the canvas object(s)
502 # This function might be called more than once while drawing a room, so if canvas objects
503 # for the room already exist, the new canvas objects are added to them
504 #
505 # Expected arguments
506 # $roomObj - The room model object
507 # $listRef - Reference to a list of canvas objects
508 #
509 # Return values
510 # 'undef' on improper arguments
511 # 1 otherwise
512  
513 my ($self, $roomObj, $listRef, $check) = @_;
514  
515 # Local variables
516 my ($levelObj, $posn, $oldListRef);
517  
518 # Check for improper arguments
519 if (! defined $roomObj || ! defined $listRef || defined $check) {
520  
521 return $axmud::CLIENT->writeImproper($self->_objClass . '->addDrawnRoomText', @_);
522 }
523  
524 $levelObj = $self->ivShow('levelHash', $roomObj->zPosBlocks);
525 if ($levelObj) {
526  
527 $posn = $roomObj->xPosBlocks . '_' . $roomObj->yPosBlocks . '_' . $roomObj->zPosBlocks;
528 $oldListRef = $levelObj->ivShow('drawnRoomTextHash', $posn);
529 if (defined $oldListRef) {
530  
531 push (@$oldListRef, @$listRef);
532  
533 } else {
534  
535 $levelObj->ivAdd('drawnRoomTextHash', $posn, $listRef);
536 }
537 }
538  
539 return 1;
540 }
541  
542 sub addDrawnExit {
543  
544 # After drawing an exit model object (GA::Obj::Exit), the automapper window calls this
545 # function to store the canvas object(s)
546 #
547 # Expected arguments
548 # $roomObj - The parent room model object
549 # $exitObj - The exit model object
550 # $listRef - Reference to a list of canvas objects
551 #
552 # Return values
553 # 'undef' on improper arguments
554 # 1 otherwise
555  
556 my ($self, $roomObj, $exitObj, $listRef, $check) = @_;
557  
558 # Local variables
559 my $levelObj;
560  
561 # Check for improper arguments
562 if (! defined $roomObj || ! defined $exitObj || ! defined $listRef || defined $check) {
563  
564 return $axmud::CLIENT->writeImproper($self->_objClass . '->addDrawnExit', @_);
565 }
566  
567 $levelObj = $self->ivShow('levelHash', $roomObj->zPosBlocks);
568 if ($levelObj) {
569  
570 $levelObj->ivAdd('drawnExitHash', $exitObj->number, $listRef);
571 }
572  
573 return 1;
574 }
575  
576 sub addDrawnExitTag {
577  
578 # After drawing an exit tag for an exit model object (GA::Obj::Exit), the automapper window
579 # calls this function to store the canvas object(s)
580 #
581 # Expected arguments
582 # $roomObj - The parent room model object
583 # $exitObj - The exit model object
584 # $listRef - Reference to a list of canvas objects
585 #
586 # Return values
587 # 'undef' on improper arguments
588 # 1 otherwise
589  
590 my ($self, $roomObj, $exitObj, $listRef, $check) = @_;
591  
592 # Local variables
593 my $levelObj;
594  
595 # Check for improper arguments
596 if (! defined $roomObj || ! defined $exitObj || ! defined $listRef || defined $check) {
597  
598 return $axmud::CLIENT->writeImproper($self->_objClass . '->addDrawnExitTag', @_);
599 }
600  
601 $levelObj = $self->ivShow('levelHash', $roomObj->zPosBlocks);
602 if ($levelObj) {
603  
604 $levelObj->ivAdd('drawnExitTagHash', $exitObj->number, $listRef);
605 }
606  
607 return 1;
608 }
609  
610 sub addDrawnOrnament {
611  
612 # After drawing an exit ornament for an exit model object (GA::Obj::Exit), the automapper
613 # window calls this function to store the canvas object(s)
614 #
615 # Expected arguments
616 # $roomObj - The parent room model object
617 # $exitObj - The exit model object
618 # $listRef - Reference to a list of canvas objects
619 #
620 # Return values
621 # 'undef' on improper arguments
622 # 1 otherwise
623  
624 my ($self, $roomObj, $exitObj, $listRef, $check) = @_;
625  
626 # Local variables
627 my ($levelObj, $oldListRef);
628  
629 # Check for improper arguments
630 if (! defined $roomObj || ! defined $exitObj || ! defined $listRef || defined $check) {
631  
632 return $axmud::CLIENT->writeImproper($self->_objClass . '->addDrawnOrnament', @_);
633 }
634  
635 $levelObj = $self->ivShow('levelHash', $roomObj->zPosBlocks);
636 if ($levelObj) {
637  
638 # This function might be called twice; once for an exit, and once for its twin exit, in
639 # which case combine the canvas objects drawn into one list
640 $oldListRef = $levelObj->ivShow('drawnOrnamentHash', $exitObj->number);
641 if (! defined $oldListRef) {
642 $levelObj->ivAdd('drawnOrnamentHash', $exitObj->number, $listRef);
643 } else {
644 push (@$oldListRef, @$listRef);
645 }
646 }
647  
648 return 1;
649 }
650  
651 sub addDrawnLabel {
652  
653 # After drawing a map model object (GA::Obj::MapLabel), the automapper window calls this
654 # function to store the canvas object(s)
655 #
656 # Expected arguments
657 # $labelObj - The map label object
658 # $listRef - Reference to a list of canvas objects
659 #
660 # Return values
661 # 'undef' on improper arguments
662 # 1 otherwise
663  
664 my ($self, $labelObj, $listRef, $check) = @_;
665  
666 # Local variables
667 my $levelObj;
668  
669 # Check for improper arguments
670 if (! defined $labelObj || ! defined $listRef || defined $check) {
671  
672 return $axmud::CLIENT->writeImproper($self->_objClass . '->addDrawnLabel', @_);
673 }
674  
675 $levelObj = $self->ivShow('levelHash', $labelObj->level);
676 if ($levelObj) {
677  
678 $levelObj->ivAdd('drawnLabelHash', $labelObj->number, $listRef);
679 }
680  
681 return 1;
682 }
683  
684 sub addDrawnCheckedDir {
685  
686 # After drawing one or more checked directions for a room model object (GA::ModelObj::Room),
687 # the automapper window calls this function to store the canvas object(s)
688 #
689 # Expected arguments
690 # $roomObj - The room model object
691 # $listRef - Reference to a list of canvas objects
692 #
693 # Return values
694 # 'undef' on improper arguments
695 # 1 otherwise
696  
697 my ($self, $roomObj, $listRef, $check) = @_;
698  
699 # Local variables
700 my $levelObj;
701  
702 # Check for improper arguments
703 if (! defined $roomObj || ! defined $listRef || defined $check) {
704  
705 return $axmud::CLIENT->writeImproper($self->_objClass . '->addDrawnCheckedDir', @_);
706 }
707  
708 $levelObj = $self->ivShow('levelHash', $roomObj->zPosBlocks);
709 if ($levelObj) {
710  
711 $levelObj->ivAdd(
712 'drawnCheckedDirHash',
713 $roomObj->xPosBlocks . '_' . $roomObj->yPosBlocks . '_' . $roomObj->zPosBlocks,
714 $listRef,
715 );
716 }
717  
718 return 1;
719 }
720  
721 # Delete canvas objects
722  
723 sub deleteDrawnRoom {
724  
725 # Called by various functions
726 # Checks whether a room model object (GA::ModelObj::Room) has been drawn for this region. If
727 # so, removes the canvas objects used to draw it and updates IVs
728 #
729 # Expected arguments
730 # $roomObj - The room model object
731 #
732 # Optional arguments
733 # $allFlag - If TRUE, canvas objects for any room echoes/room tags/room guilds/room
734 # text/checked directions are removed at the same time. FALSE (or
735 # 'undef') otherwise
736 #
737 # Return values
738 # 'undef' on improper arguments
739 # 1 otherwise
740  
741 my ($self, $roomObj, $allFlag, $check) = @_;
742  
743 # Local variables
744 my ($levelObj, $posn, $listRef);
745  
746 # Check for improper arguments
747 if (! defined $roomObj || defined $check) {
748  
749 return $axmud::CLIENT->writeImproper($self->_objClass . '->deleteDrawnRoom', @_);
750 }
751  
752 $levelObj = $self->ivShow('levelHash', $roomObj->zPosBlocks);
753 if ($levelObj) {
754  
755 $posn = $roomObj->xPosBlocks . '_' . $roomObj->yPosBlocks . '_' . $roomObj->zPosBlocks;
756 $listRef = $levelObj->ivShow('drawnRoomHash', $posn);
757 if (defined $listRef) {
758  
759 # Delete these canvas objects
760 foreach my $canvasObj (@$listRef) {
761  
762 $canvasObj->remove();
763 }
764  
765 $levelObj->ivDelete('drawnRoomHash', $posn);
766 }
767  
768 if ($allFlag) {
769  
770 foreach my $echoLevel (($roomObj->zPosBlocks + 1), ($roomObj->zPosBlocks - 1)) {
771  
772 my $echoLevelObj = $self->ivShow('levelHash', $echoLevel);
773 if ($echoLevelObj) {
774  
775 $listRef = $echoLevelObj->ivShow('drawnRoomEchoHash', $posn);
776 if (defined $listRef) {
777  
778 foreach my $canvasObj (@$listRef) {
779  
780 $canvasObj->remove();
781 }
782  
783 $echoLevelObj->ivDelete('drawnRoomEchoHash', $posn);
784 }
785 }
786 }
787  
788 $listRef = $levelObj->ivShow('drawnRoomTagHash', $posn);
789 if (defined $listRef) {
790  
791 foreach my $canvasObj (@$listRef) {
792  
793 $canvasObj->remove();
794 }
795  
796 $levelObj->ivDelete('drawnRoomTagHash', $posn);
797 }
798  
799 $listRef = $levelObj->ivShow('drawnRoomGuildHash', $posn);
800 if (defined $listRef) {
801  
802 foreach my $canvasObj (@$listRef) {
803  
804 $canvasObj->remove();
805 }
806  
807 $levelObj->ivDelete('drawnRoomGuildHash', $posn);
808 }
809  
810 $listRef = $levelObj->ivShow('drawnRoomTextHash', $posn);
811 if (defined $listRef) {
812  
813 foreach my $canvasObj (@$listRef) {
814  
815 $canvasObj->remove();
816 }
817  
818 $levelObj->ivDelete('drawnRoomTextHash', $posn);
819 }
820  
821 $listRef = $levelObj->ivShow('drawnCheckedDirHash', $posn);
822 if (defined $listRef) {
823  
824 foreach my $canvasObj (@$listRef) {
825  
826 $canvasObj->remove();
827 }
828  
829 $levelObj->ivDelete('drawnCheckedDirHash', $posn);
830 }
831 }
832 }
833  
834 return 1;
835 }
836  
837 sub deleteDrawnRoomEcho {
838  
839 # Called by various functions
840 # Checks whether a room echo for a room model object (GA::ModelObj::Room) has been drawn for
841 # this region. If so, removes the canvas objects used to draw it and updates IVs
842 #
843 # Expected arguments
844 # $roomObj - The room model object
845 #
846 # Return values
847 # 'undef' on improper arguments
848 # 1 otherwise
849  
850 my ($self, $roomObj, $check) = @_;
851  
852 # Local variables
853 my $posn;
854  
855 # Check for improper arguments
856 if (! defined $roomObj || defined $check) {
857  
858 return $axmud::CLIENT->writeImproper($self->_objClass . '->deleteDrawnRoomEcho', @_);
859 }
860  
861 $posn = $roomObj->xPosBlocks . '_' . $roomObj->yPosBlocks . '_' . $roomObj->zPosBlocks;
862  
863 foreach my $level (($roomObj->zPosBlocks + 1), ($roomObj->zPosBlocks - 1)) {
864  
865 my ($levelObj, $posn, $listRef);
866  
867 $levelObj = $self->ivShow('levelHash', $level);
868 if ($levelObj) {
869  
870 $listRef = $levelObj->ivShow('drawnRoomEchoHash', $posn);
871 if (defined $listRef) {
872  
873 # Delete these canvas objects
874 foreach my $canvasObj (@$listRef) {
875  
876 $canvasObj->remove();
877 }
878  
879 $levelObj->ivDelete('drawnRoomEchoHash', $posn);
880 }
881 }
882 }
883  
884 return 1;
885 }
886  
887 sub deleteDrawnRoomTag {
888  
889 # Called by various functions
890 # Checks whether a room tag for a room model object (GA::ModelObj::Room) has been drawn for
891 # this region. If so, removes the canvas objects used to draw it and updates IVs
892 #
893 # Expected arguments
894 # $roomObj - The room model object
895 #
896 # Return values
897 # 'undef' on improper arguments
898 # 1 otherwise
899  
900 my ($self, $roomObj, $check) = @_;
901  
902 # Local variables
903 my ($levelObj, $posn, $listRef);
904  
905 # Check for improper arguments
906 if (! defined $roomObj || defined $check) {
907  
908 return $axmud::CLIENT->writeImproper($self->_objClass . '->deleteDrawnRoomTag', @_);
909 }
910  
911 $levelObj = $self->ivShow('levelHash', $roomObj->zPosBlocks);
912 if ($levelObj) {
913  
914 $posn = $roomObj->xPosBlocks . '_' . $roomObj->yPosBlocks . '_' . $roomObj->zPosBlocks;
915 $listRef = $levelObj->ivShow('drawnRoomTagHash', $posn);
916 if (defined $listRef) {
917  
918 # Delete these canvas objects
919 foreach my $canvasObj (@$listRef) {
920  
921 $canvasObj->remove();
922 }
923  
924 $levelObj->ivDelete('drawnRoomTagHash', $posn);
925 }
926 }
927  
928 return 1;
929 }
930  
931 sub deleteDrawnRoomGuild {
932  
933 # Called by various functions
934 # Checks whether a room guild for a room model object (GA::ModelObj::Room) has been drawn
935 # for this region. If so, removes the canvas objects used to draw it and updates IVs
936 #
937 # Expected arguments
938 # $roomObj - The room model object
939 #
940 # Return values
941 # 'undef' on improper arguments
942 # 1 otherwise
943  
944 my ($self, $roomObj, $check) = @_;
945  
946 # Local variables
947 my ($levelObj, $posn, $listRef);
948  
949 # Check for improper arguments
950 if (! defined $roomObj || defined $check) {
951  
952 return $axmud::CLIENT->writeImproper($self->_objClass . '->deleteDrawnRoomGuild', @_);
953 }
954  
955 $levelObj = $self->ivShow('levelHash', $roomObj->zPosBlocks);
956 if ($levelObj) {
957  
958 $posn = $roomObj->xPosBlocks . '_' . $roomObj->yPosBlocks . '_' . $roomObj->zPosBlocks;
959 $listRef = $levelObj->ivShow('drawnRoomGuildHash', $posn);
960 if (defined $listRef) {
961  
962 # Delete these canvas objects
963 foreach my $canvasObj (@$listRef) {
964  
965 $canvasObj->remove();
966 }
967  
968 $levelObj->ivDelete('drawnRoomGuildHash', $posn);
969 }
970 }
971  
972 return 1;
973 }
974  
975 sub deleteDrawnRoomText {
976  
977 # Called by various functions
978 # Checks whether room text for a room model object (GA::ModelObj::Room) has been drawn for
979 # this region. If so, removes the canvas objects used to draw it and updates IVs
980 #
981 # Expected arguments
982 # $roomObj - The room model object
983 #
984 # Return values
985 # 'undef' on improper arguments
986 # 1 otherwise
987  
988 my ($self, $roomObj, $check) = @_;
989  
990 # Local variables
991 my ($levelObj, $posn, $listRef);
992  
993 # Check for improper arguments
994 if (! defined $roomObj || defined $check) {
995  
996 return $axmud::CLIENT->writeImproper($self->_objClass . '->deleteDrawnRoomText', @_);
997 }
998  
999 $levelObj = $self->ivShow('levelHash', $roomObj->zPosBlocks);
1000 if ($levelObj) {
1001  
1002 $posn = $roomObj->xPosBlocks . '_' . $roomObj->yPosBlocks . '_' . $roomObj->zPosBlocks;
1003 $listRef = $levelObj->ivShow('drawnRoomTextHash', $posn);
1004 if (defined $listRef) {
1005  
1006 # Delete these canvas objects
1007 foreach my $canvasObj (@$listRef) {
1008  
1009 $canvasObj->remove();
1010 }
1011  
1012 $levelObj->ivDelete('drawnRoomTextHash', $posn);
1013 }
1014 }
1015  
1016 return 1;
1017 }
1018  
1019 sub deleteDrawnExit {
1020  
1021 # Called by various functions
1022 # Checks whether an exit model object (GA::Obj::Exit) has been drawn for this region. If
1023 # so, removes the canvas objects used to draw it and updates IVs
1024 #
1025 # Expected arguments
1026 # $exitObj - The exit model object
1027 #
1028 # Optional arguments
1029 # $roomObj - The exit's parent room, if known. Otherwise this function fetches it
1030 # $allFlag - If TRUE, canvas objects for any exit tags/ornaments are removed at the
1031 # same time. FALSE (or 'undef') otherwise
1032 #
1033 # Return values
1034 # 'undef' on improper arguments
1035 # 1 otherwise
1036  
1037 my ($self, $exitObj, $roomObj, $allFlag, $check) = @_;
1038  
1039 # Local variables
1040 my ($levelObj, $listRef);
1041  
1042 # Check for improper arguments
1043 if (! defined $exitObj || defined $check) {
1044  
1045 return $axmud::CLIENT->writeImproper($self->_objClass . '->deleteDrawnExit', @_);
1046 }
1047  
1048 if (! $roomObj) {
1049  
1050 $roomObj = $self->worldModelObj->ivShow('modelHash', $exitObj->parent);
1051 }
1052  
1053 if ($roomObj) {
1054  
1055 $levelObj = $self->ivShow('levelHash', $roomObj->zPosBlocks);
1056 if ($levelObj) {
1057  
1058 $listRef = $levelObj->ivShow('drawnExitHash', $exitObj->number);
1059 if (defined $listRef) {
1060  
1061 # Delete these canvas objects
1062 foreach my $canvasObj (@$listRef) {
1063  
1064 $canvasObj->remove();
1065 }
1066  
1067 $levelObj->ivDelete('drawnExitHash', $exitObj->number);
1068 }
1069  
1070 if ($allFlag) {
1071  
1072 $listRef = $levelObj->ivShow('drawnExitTagHash', $exitObj->number);
1073 if (defined $listRef) {
1074  
1075 foreach my $canvasObj (@$listRef) {
1076  
1077 $canvasObj->remove();
1078 }
1079  
1080 $levelObj->ivDelete('drawnExitTagHash', $exitObj->number);
1081 }
1082  
1083 $listRef = $levelObj->ivShow('drawnOrnamentHash', $exitObj->number);
1084 if (defined $listRef) {
1085  
1086 foreach my $canvasObj (@$listRef) {
1087  
1088 $canvasObj->remove();
1089 }
1090  
1091 $levelObj->ivDelete('drawnOrnamentHash', $exitObj->number);
1092 }
1093 }
1094 }
1095 }
1096  
1097 return 1;
1098 }
1099  
1100 sub deleteDrawnExitTag {
1101  
1102 # Called by various functions
1103 # Checks whether an exit tag for an exit model object (GA::Obj::Exit) has been drawn for
1104 # this region. If so, removes the canvas objects used to draw it and updates IVs
1105 #
1106 # Expected arguments
1107 # $exitObj - The exit model object
1108 #
1109 # Optional arguments
1110 # $roomObj - The exit's parent room, if known. Otherwise this function fetches it
1111 #
1112 # Return values
1113 # 'undef' on improper arguments
1114 # 1 otherwise
1115  
1116 my ($self, $exitObj, $roomObj, $check) = @_;
1117  
1118 # Local variables
1119 my ($levelObj, $listRef);
1120  
1121 # Check for improper arguments
1122 if (! defined $exitObj || defined $check) {
1123  
1124 return $axmud::CLIENT->writeImproper($self->_objClass . '->deleteDrawnExitTag', @_);
1125 }
1126  
1127 if (! $roomObj) {
1128  
1129 $roomObj = $self->worldModelObj->ivShow('modelHash', $exitObj->parent);
1130 }
1131  
1132 if ($roomObj) {
1133  
1134 $levelObj = $self->ivShow('levelHash', $roomObj->zPosBlocks);
1135 if ($levelObj) {
1136  
1137 $listRef = $levelObj->ivShow('drawnExitTagHash', $exitObj->number);
1138 if (defined $listRef) {
1139  
1140 # Delete these canvas objects
1141 foreach my $canvasObj (@$listRef) {
1142  
1143 $canvasObj->remove();
1144 }
1145  
1146 $levelObj->ivDelete('drawnExitTagHash', $exitObj->number);
1147 }
1148 }
1149 }
1150  
1151 return 1;
1152 }
1153  
1154 sub deleteDrawnOrnament {
1155  
1156 # Called by various functions
1157 # Checks whether an exit ornament for an exit model object (GA::Obj::Exit) has been drawn
1158 # for this region. If so, removes the canvas objects used to draw it and updates IVs
1159 #
1160 # Expected arguments
1161 # $exitObj - The exit model object
1162 #
1163 # Optional arguments
1164 # $roomObj - The exit's parent room, if known. Otherwise this function fetches it
1165 #
1166 # Return values
1167 # 'undef' on improper arguments
1168 # 1 otherwise
1169  
1170 my ($self, $exitObj, $roomObj, $check) = @_;
1171  
1172 # Local variables
1173 my ($levelObj, $listRef);
1174  
1175 # Check for improper arguments
1176 if (! defined $exitObj || defined $check) {
1177  
1178 return $axmud::CLIENT->writeImproper($self->_objClass . '->deleteDrawnOrnament', @_);
1179 }
1180  
1181 if (! $roomObj) {
1182  
1183 $roomObj = $self->worldModelObj->ivShow('modelHash', $exitObj->parent);
1184 }
1185  
1186 if ($roomObj) {
1187  
1188 $levelObj = $self->ivShow('levelHash', $roomObj->zPosBlocks);
1189 if ($levelObj) {
1190  
1191 $listRef = $levelObj->ivShow('drawnOrnamentHash', $exitObj->number);
1192 if (defined $listRef) {
1193  
1194 # Delete these canvas objects
1195 foreach my $canvasObj (@$listRef) {
1196  
1197 $canvasObj->remove();
1198 }
1199  
1200 $levelObj->ivDelete('drawnOrnamentHash', $exitObj->number);
1201 }
1202 }
1203 }
1204  
1205 return 1;
1206 }
1207  
1208 sub deleteDrawnLabel {
1209  
1210 # Called by various functions
1211 # Checks whether a map label object (GA::Obj::MapLabel) has been drawn for this region. If
1212 # so, removes the canvas objects used to draw it and updates IVs
1213 #
1214 # Expected arguments
1215 # $labelObj - The map label object
1216 #
1217 # Return values
1218 # 'undef' on improper arguments
1219 # 1 otherwise
1220  
1221 my ($self, $labelObj, $check) = @_;
1222  
1223 # Local variables
1224 my ($levelObj, $listRef);
1225  
1226 # Check for improper arguments
1227 if (! defined $labelObj || defined $check) {
1228  
1229 return $axmud::CLIENT->writeImproper($self->_objClass . '->deleteDrawnLabel', @_);
1230 }
1231  
1232 $levelObj = $self->ivShow('levelHash', $labelObj->level);
1233 if ($levelObj) {
1234  
1235 $listRef = $levelObj->ivShow('drawnLabelHash', $labelObj->number);
1236 if (defined $listRef) {
1237  
1238 # Delete these canvas objects
1239 foreach my $canvasObj (@$listRef) {
1240  
1241 $canvasObj->remove();
1242 }
1243  
1244 $levelObj->ivDelete('drawnLabelHash', $labelObj->number);
1245 }
1246 }
1247  
1248 return 1;
1249 }
1250  
1251 sub deleteDrawnCheckedDir {
1252  
1253 # Called by various functions
1254 # Checks whether checked directions for a room model object (GA::ModelObj::Room) have been
1255 # drawn for this region. If so, removes the canvas objects used to draw them and updates
1256 # IVs
1257 #
1258 # Expected arguments
1259 # $roomObj - The room model object
1260 #
1261 # Return values
1262 # 'undef' on improper arguments
1263 # 1 otherwise
1264  
1265 my ($self, $roomObj, $check) = @_;
1266  
1267 # Local variables
1268 my ($levelObj, $posn, $listRef);
1269  
1270 # Check for improper arguments
1271 if (! defined $roomObj || defined $check) {
1272  
1273 return $axmud::CLIENT->writeImproper($self->_objClass . '->deleteDrawnCheckedDir', @_);
1274 }
1275  
1276 $levelObj = $self->ivShow('levelHash', $roomObj->zPosBlocks);
1277 if ($levelObj) {
1278  
1279 $posn = $roomObj->xPosBlocks . '_' . $roomObj->yPosBlocks . '_' . $roomObj->zPosBlocks;
1280 $listRef = $levelObj->ivShow('drawnCheckedDirHash', $posn);
1281 if (defined $listRef) {
1282  
1283 # Delete these canvas objects
1284 foreach my $canvasObj (@$listRef) {
1285  
1286 $canvasObj->remove();
1287 }
1288  
1289 $levelObj->ivDelete('drawnCheckedDirHash', $posn);
1290 }
1291 }
1292  
1293 return 1;
1294 }
1295  
1296 sub deleteColouredSquare {
1297  
1298 # Called by various functions
1299 # Checks whether a particular coloured square has been drawn for this region. If so,
1300 # removes the canvas objects used to draw it and updates IVs
1301 #
1302 # Expected arguments
1303 # $string - A string used to stored the coloured square in $self->colouredSquareHash;
1304 # in the form 'x_y' (for squares visible on all levels) or 'x_y_z' (for
1305 # squares visible only on one level)
1306 #
1307 # Return values
1308 # 'undef' on improper arguments
1309 # 1 otherwise
1310  
1311 my ($self, $string, $check) = @_;
1312  
1313 # Local variables
1314 my $canvasObj;
1315  
1316 # Check for improper arguments
1317 if (! defined $string || defined $check) {
1318  
1319 return $axmud::CLIENT->writeImproper($self->_objClass . '->deleteColouredSquare', @_);
1320 }
1321  
1322 $canvasObj = $self->ivShow('colouredSquareHash', $string);
1323 if ($canvasObj) {
1324  
1325 # $string is in the form 'x_y_z'. Delete the canvas object
1326 $canvasObj->remove();
1327 $self->ivDelete('colouredSquareHash', $string);
1328  
1329 } else {
1330  
1331 # $string is in the form 'x_y'. Check all levels
1332 foreach my $level ($self->ivKeys('levelHash')) {
1333  
1334 my $key = $string . '_' . $level;
1335 $canvasObj = $self->ivShow('colouredSquareHash', $key);
1336 if ($canvasObj) {
1337  
1338 # Delete the canvas object
1339 $canvasObj->remove();
1340 $self->ivDelete('colouredSquareHash', $key);
1341 }
1342 }
1343 }
1344  
1345 return 1;
1346 }
1347  
1348 sub deleteColouredRect {
1349  
1350 # Called by various functions
1351 # Checks whether a particular coloured rectangle has been drawn for this region. If so,
1352 # removes the canvas objects used to draw it and updates IVs
1353 #
1354 # Expected arguments
1355 # $string - A string used to stored the coloured rectangle in $self->colouredRectHash;
1356 # in the form 'object-number' (for rectangles visible on all levels) or
1357 # 'object-number_level' (for rectangles visible only on one level)
1358 #
1359 # Return values
1360 # 'undef' on improper arguments
1361 # 1 otherwise
1362  
1363 my ($self, $string, $check) = @_;
1364  
1365 # Local variables
1366 my $canvasObj;
1367  
1368 # Check for improper arguments
1369 if (! defined $string || defined $check) {
1370  
1371 return $axmud::CLIENT->writeImproper($self->_objClass . '->deleteColouredRect', @_);
1372 }
1373  
1374 $canvasObj = $self->ivShow('colouredRectHash', $string);
1375 if ($canvasObj) {
1376  
1377 # $string is in the form 'object-number_level'. Delete the canvas object
1378 $canvasObj->remove();
1379 $self->ivDelete('colouredRectHash', $string);
1380  
1381 } else {
1382  
1383 # $string is in the form 'object-number'. Check all levels
1384 foreach my $level ($self->ivKeys('levelHash')) {
1385  
1386 my $key = $string . '_' . $level;
1387 $canvasObj = $self->ivShow('colouredRectHash', $key);
1388 if ($canvasObj) {
1389  
1390 # Delete the canvas object
1391 $canvasObj->remove();
1392 $self->ivDelete('colouredRectHash', $key);
1393 }
1394 }
1395 }
1396  
1397 return 1;
1398 }
1399  
1400 ##################
1401 # Accessors - set
1402  
1403 sub reset_markedHash {
1404  
1405 my ($self, $check) = @_;
1406  
1407 # Check for improper arguments
1408 if (defined $check) {
1409  
1410 return $axmud::CLIENT->writeImproper($self->_objClass . '->reset_markedHash', @_);
1411 }
1412  
1413 $self->ivEmpty('markedRoomHash');
1414 $self->ivEmpty('markedRoomTagHash');
1415 $self->ivEmpty('markedRoomGuildHash');
1416 $self->ivEmpty('markedExitHash');
1417 $self->ivEmpty('markedExitTagHash');
1418 $self->ivEmpty('markedLabelHash');
1419  
1420 return 1;
1421 }
1422  
1423 sub reset_queueHash {
1424  
1425 my ($self, $check) = @_;
1426  
1427 # Check for improper arguments
1428 if (defined $check) {
1429  
1430 return $axmud::CLIENT->writeImproper($self->_objClass . '->reset_queueHash', @_);
1431 }
1432  
1433 $self->ivEmpty('queueRoomEchoHash');
1434 $self->ivEmpty('queueRoomBoxHash');
1435 $self->ivEmpty('queueRoomTextHash');
1436 $self->ivEmpty('queueRoomExitHash');
1437 $self->ivEmpty('queueRoomInfoHash');
1438 $self->ivEmpty('queueLabelHash');
1439  
1440 return 1;
1441 }
1442  
1443 ##################
1444 # Accessors - get
1445  
1446 sub name
1447 { $_[0]->{name} }
1448 sub worldModelObj
1449 { $_[0]->{worldModelObj} }
1450  
1451 sub canvasWidgetHash
1452 { my $self = shift; return %{$self->{canvasWidgetHash}}; }
1453 sub bgCanvasObjHash
1454 { my $self = shift; return %{$self->{bgCanvasObjHash}}; }
1455  
1456 sub levelHash
1457 { my $self = shift; return %{$self->{levelHash}}; }
1458  
1459 sub colouredSquareHash
1460 { my $self = shift; return %{$self->{colouredSquareHash}}; }
1461 sub colouredRectHash
1462 { my $self = shift; return %{$self->{colouredRectHash}}; }
1463  
1464 sub markedRoomHash
1465 { my $self = shift; return %{$self->{markedRoomHash}}; }
1466 sub markedRoomTagHash
1467 { my $self = shift; return %{$self->{markedRoomTagHash}}; }
1468 sub markedRoomGuildHash
1469 { my $self = shift; return %{$self->{markedRoomGuildHash}}; }
1470 sub markedExitHash
1471 { my $self = shift; return %{$self->{markedExitHash}}; }
1472 sub markedExitTagHash
1473 { my $self = shift; return %{$self->{markedExitTagHash}}; }
1474 sub markedLabelHash
1475 { my $self = shift; return %{$self->{markedLabelHash}}; }
1476  
1477 sub queueRoomEchoHash
1478 { my $self = shift; return %{$self->{queueRoomEchoHash}}; }
1479 sub queueRoomBoxHash
1480 { my $self = shift; return %{$self->{queueRoomBoxHash}}; }
1481 sub queueRoomTextHash
1482 { my $self = shift; return %{$self->{queueRoomTextHash}}; }
1483 sub queueRoomExitHash
1484 { my $self = shift; return %{$self->{queueRoomExitHash}}; }
1485 sub queueRoomInfoHash
1486 { my $self = shift; return %{$self->{queueRoomInfoHash}}; }
1487 sub queueLabelHash
1488 { my $self = shift; return %{$self->{queueLabelHash}}; }
1489  
1490 sub noObscuredRoomHash
1491 { my $self = shift; return %{$self->{noObscuredRoomHash}}; }
1492 sub reObscuredRoomHash
1493 { my $self = shift; return %{$self->{reObscuredRoomHash}}; }
1494 }
1495  
1496 { package Games::Axmud::Obj::ParchmentLevel;
1497  
1498 use strict;
1499 use warnings;
1500 # use diagnostics;
1501  
1502 use Glib qw(TRUE FALSE);
1503  
1504 our @ISA = qw(Games::Axmud);
1505  
1506 ##################
1507 # Constructors
1508  
1509 sub new {
1510  
1511 # Called by GA::Win::Map->createMap
1512 # Stores the canvas objects drawn on a single level in a region
1513 #
1514 # Expected arguments
1515 # $region - The name of the regionmap (and also of the parent parchment object,
1516 # GA::Obj::Parchment)
1517 # $level - The regionmap level (matches a possible value for
1518 # GA::Obj::Regionmap->currentLevel)
1519 #
1520 # Return values
1521 # 'undef' on improper arguments
1522 # Blessed reference to the newly-created object on success
1523  
1524 my ($class, $region, $level, $check) = @_;
1525  
1526 # Check for improper arguments
1527 if (! defined $region || ! defined $level || ! defined $level || defined $check) {
1528  
1529 return $axmud::CLIENT->writeImproper($class . '->new', @_);
1530 }
1531  
1532 # Setup
1533 my $self = {
1534 _objName => $region . '_' . $level,
1535 _objClass => $class,
1536 _parentFile => undef,
1537 _parentWorld => undef,
1538 _privFlag => FALSE, # All IVs are public
1539  
1540 # IVs
1541 # ---
1542  
1543 # A name for this object, combining the region name and level
1544 name => $region . '_' . $level,
1545 # The region name and level as separate IVs
1546 region => $region,
1547 level => $level,
1548  
1549 # The map itself is just a collection of GA::ModelObj::Room objects, GA::Obj::Exit
1550 # objects and GA::Obj::MapLabel objects. They are stored in each region's
1551 # GA::Obj::Regionmap
1552 # Each GA::ModelObj::Room, GA::Obj::Exit and GA::Obj::MapLabel object is drawn using
1553 # one or more canvas objects
1554 # These hashes work in parallel with the regionmap's ->gridRoomHash, ->gridRoomTagHash,
1555 # ->gridRoomGuildHash, ->gridExitHash, ->gridExitTagHash and ->gridLabelHash. The keys
1556 # are the same for each, but the values in these hashes contain a reference to a list
1557 # of canvas objects (which may be a list containing one canvas object)
1558 # Only one room is allowed per gridblock, but exits and labels can be drawn freely
1559 #
1560 # These hashes contain everything currently drawn in this region, at this level (but
1561 # they will be incomplete, if we haven't finished drawing objects in this region yet)
1562 # (NB Coloured squares and rectangles are stored in the parent parchment object)
1563 #
1564 # Hash of drawn rooms from this regionmap, in the form
1565 # $drawnRoomHash{'x_y_z'} = [canvas_object, canvas_object...]
1566 drawnRoomHash => {},
1567 # Hash of drawn room echos from this regionmap, in the form
1568 # $drawnRoomEchoHash{'x_y_z'} = [canvas_object, canvas_object...]
1569 # NB A room has two echoes, one on the level above it, one on the level below; therefore
1570 # two parchment level objects will have an entry for each room
1571 drawnRoomEchoHash => {},
1572 # Hash of drawn rooms with room tags from this regionmap, in the form
1573 # $drawnRoomTagHash{'x_y_z'} = [canvas_object, canvas_object...]
1574 drawnRoomTagHash => {},
1575 # Hash of drawn rooms with room guilds from this regionmap, in the form
1576 # $drawnRoomGuildHash{'x_y_z'} = [canvas_object, canvas_object...]
1577 drawnRoomGuildHash => {},
1578 # Hash of drawn rooms that have text drawn within their interiors, in the form
1579 # $drawnRoomTextHash{'x_y_z'} = [canvas_object, canvas_object...]
1580 drawnRoomTextHash => {},
1581 # Hash of drawn exits from this regionmap (not necessarily all the exits in all the
1582 # rooms), in the form
1583 # $drawnExitHash{exit_model_number} = [canvas_object, canvas_object...]
1584 drawnExitHash => {},
1585 # Hash of drawn exits with exit tags from this regionmap, in the form
1586 # $drawnExitTagHash{exit_model_number} = [canvas_object, canvas_object...]
1587 drawnExitTagHash => {},
1588 # Hash of drawn exits from this regionmap that have exit ornaments, in the form
1589 # $drawnOrnamentHash{exit_model_number} = [canvas_object, canvas_object...]
1590 drawnOrnamentHash => {},
1591 # Hash of (all) labels that exist in this regionmap, in the form
1592 # $drawnLabelHash{label_number} = [canvas_object, canvas_object...]
1593 drawnLabelHash => {},
1594 # Hash of checked directions for each room, if they have been drawn. Checked directions
1595 # can't be clicked (selected), so all the canvas objects for checked directions in a
1596 # room are stored together as a single key-value pair. Hash in the form
1597 # $drawnCheckedDirHash{'x_y_z'} = [canvas_object, canvas_object...]
1598 drawnCheckedDirHash => {},
1599  
1600 # Canvas objects are arranged in a stack (so that labels are drawn above rooms). The
1601 # stack is in the order:
1602 # 7 - labels and draggable exits (placed at the top of the stack)
1603 # 6 - room tags, room guilds and exit tags
1604 # 5 - exits, exit ornaments and checked directions
1605 # 4 - room interior text
1606 # 3 - room boxes
1607 # 2 - room echoes and fake room boxes
1608 # 1 - coloured rectangles on the map background
1609 # 0 - coloured blocks on the map background
1610 # - - map background (at the bottom of the stack)
1611 # GooCanvas provides ->lower and ->raise functions, which move a canvas object above or
1612 # below an existing canvas object (or to the top/bottom of the stack)
1613 # It would be nice to place a new room above the highest existing room in the stack, but
1614 # we can't, because if the room is deleted we have no way of finding the next-highest
1615 # room in the stack
1616 # Instead, we'll create eight slave canvas objects, hidden away in one corner of the
1617 # map. Because the slave objects are never deleted, we can place every new canvas
1618 # object immediately below one of the slave objects
1619 # Hence, we have a list of eight stunt objects, [0 1 2 3 4 5 6 7]. For example, the
1620 # slave object at index 3 is just above all room boxes, and therefore all new room
1621 # boxes are added to the stack just below it
1622 slaveCanvasObjList => [],
1623 };
1624  
1625 # Bless the object into existence
1626 bless $self, $class;
1627 return $self;
1628 }
1629  
1630 ##################
1631 # Methods
1632  
1633 ##################
1634 # Accessors - set
1635  
1636 ##################
1637 # Accessors - get
1638  
1639 sub name
1640 { $_[0]->{name} }
1641 sub region
1642 { $_[0]->{region} }
1643 sub level
1644 { $_[0]->{level} }
1645  
1646 sub drawnRoomHash
1647 { my $self = shift; return %{$self->{drawnRoomHash}}; }
1648 sub drawnRoomEchoHash
1649 { my $self = shift; return %{$self->{drawnRoomEchoHash}}; }
1650 sub drawnRoomTagHash
1651 { my $self = shift; return %{$self->{drawnRoomTagHash}}; }
1652 sub drawnRoomGuildHash
1653 { my $self = shift; return %{$self->{drawnRoomGuildHash}}; }
1654 sub drawnRoomTextHash
1655 { my $self = shift; return %{$self->{drawnRoomTextHash}}; }
1656 sub drawnExitHash
1657 { my $self = shift; return %{$self->{drawnExitHash}}; }
1658 sub drawnExitTagHash
1659 { my $self = shift; return %{$self->{drawnExitTagHash}}; }
1660 sub drawnOrnamentHash
1661 { my $self = shift; return %{$self->{drawnOrnamentHash}}; }
1662 sub drawnLabelHash
1663 { my $self = shift; return %{$self->{drawnLabelHash}}; }
1664 sub drawnCheckedDirHash
1665 { my $self = shift; return %{$self->{drawnCheckedDirHash}}; }
1666  
1667 sub slaveCanvasObjList
1668 { my $self = shift; return @{$self->{slaveCanvasObjList}}; }
1669 }
1670  
1671 # Package must return a true value
1672 1