Games-Axmud

 view release on metacpan or  search on metacpan

lib/Games/Axmud/Win/Map.pm  view on Meta::CPAN

            $roomName = $self->mapObj->currentRoom->name;
            if ($roomName eq '<unnamed room>') {
                $roomName = '(unnamed room)';
            } elsif (length($roomName) > 31) {
                $roomName = substr($roomName, 0, 29) . '...';
            }

            $msg .= $roomName . "'\n\n";

        } else {

            $msg = '';
        }

        if (@reducedList) {

            if (scalar @sortedList != scalar @reducedList) {

                $msg .= "Selected rooms (first " . $limit . " rooms of " . scalar @sortedList
                        . ")";

            } elsif (scalar @sortedList == 1) {

                $msg .= "Selected rooms (1 room)";

            } else {

                $msg .= "Selected rooms (" . scalar @sortedList . " rooms)";
            }

            foreach my $obj (@reducedList) {

                my $roomName;

                $msg .= "\n   #" . $obj->number . " '";

                $roomName = $obj->name;
                if ($roomName eq '<unnamed room>') {
                    $roomName = '(unnamed room)';
                } elsif (length($roomName) > 31) {
                    $roomName = substr($roomName, 0, 29) . '...';
                }

                $msg .= $roomName . "'";
            }
        }

        # Display a popup to show the results
        $self->showMsgDialogue(
            'Identify rooms',
            'info',
            $msg,
            'ok',
            undef,
            TRUE,           # Preserve newline characters in $msg
        );

        return 1;
    }

    sub updateVisitsCallback {

        # Called by $self->enableRoomsColumn, ->enableRoomsPopupMenu and ->drawMiscButtonSet
        # Adjusts the number of character visits shown in the selected room(s)
        # Normally, the current character's visits are changed. However, if $self->showChar is set,
        #   that character's visits are changed
        #
        # Expected arguments
        #   $mode   - 'increase' to increase the number of visits by one, 'decrease' to decrease the
        #               visits by one, 'manual' to let the user enter a value manually, 'reset' to
        #               reset the number to zero
        #
        # Return values
        #   'undef' on improper arguments, if the standard callback check fails, if the user clicks
        #       the 'cancel' button on a 'dialogue' window or for any other error
        #   1 otherwise

        my ($self, $mode, $check) = @_;

        # Local variables
        my (
            $char, $current, $result, $matchFlag,
            @roomList, @drawList,
        );

        # Check for improper arguments
        if (
            ! defined $mode
            || ($mode ne 'increase' && $mode ne 'decrease' && $mode ne 'manual' && $mode ne 'reset')
            || defined $check
        ) {
            return $axmud::CLIENT->writeImproper($self->_objClass . '->updateVisitsCallback', @_);
        }

        # Standard callback check
        if (! $self->currentRegionmap || (! $self->selectedRoom && ! $self->selectedRoomHash)) {

            return undef;
        }

        # Get a list of selected room(s)
        @roomList = $self->compileSelectedRooms();

        # Decide which character to use
        if ($self->showChar) {

            $char = $self->showChar;

        } elsif ($self->session->currentChar) {

            $char = $self->session->currentChar->name;

        } else {

            $self->showMsgDialogue(
                'Update character visits',
                'error',
                'Can\'t update the number of visits - there is no current character set',
                'ok',
            );

lib/Games/Axmud/Win/Map.pm  view on Meta::CPAN

                if ($checkTime && $count >= $checkCount) {

                    if ($checkTime < $axmud::CLIENT->getTime()) {

                        $stopFlag = TRUE;
                        last OUTER;

                    } else {

                        $count = 0;
                    }
                }
            }
        }

        # Draw labels (position #7 in the canvas drawing stack)
        if (! $stopFlag) {

            OUTER: foreach my $labelObj ($parchmentObj->ivValues('queueLabelHash')) {

                $parchmentObj->ivDelete('queueLabelHash', $labelObj->number);

                # Draw the label
                $self->drawLabel($labelObj);
                $count++;

                if (! $parchmentObj->queueLabelHash) {

                    $self->updateSlaveInStack($parchmentObj, 7);
                }

                if ($checkTime && $count >= $checkCount) {

                    if ($checkTime < $axmud::CLIENT->getTime()) {

                        $stopFlag = TRUE;
                        last OUTER;

                    } else {

                        $count = 0;
                    }
                }
            }
        }

        # Tidy up by resetting drawing cycle IVs
        $self->tidyUpDraw();

        # The next drawing cycle can insert canvas objects at arbitrary positions in the canvas
        #   drawing stack
        $self->ivPoke('quickDrawFlag', FALSE);
        # Further calls to this function and to $self->doDraw are now allowed
        $self->ivPoke('delayDrawFlag', FALSE);

        # Return control to the calling function, having drawn some (or possibly all) of the
        #   rooms, exits and/or labels waiting to be drawn
        return 1;
    }

    sub updateSlaveInStack {

        # Called by $self->doQuickDraw
        # Canvas objects are arranged in a stack (so that labels are drawn above rooms). So that we
        #   can quickly position new canvas objects in that stick, we use a small number of
        #   invisible canvas objects. This function is called after (for example) all room boxes
        #   have been drawn, or all exits have been drawn, to move one of the invisible canvas
        #   objects to their correct stack position, which at the time of calling is at the top of
        #   the stack
        #
        # Expected arguments
        #   $parchmentObj   - The parchment object (GA::Obj::Parchment) on which pre-draw operations
        #                       are currently taking place
        #   $posn           - The relative position of the invisible canvas objects, a value in the
        #                       range 0-7 (defined in the comments for GA::Obj::Parchment->new)
        #
        # Return values
        #   'undef' on improper arguments
        #   1 otherwise

        my ($self, $parchmentObj, $posn, $check) = @_;

        # Check for improper arguments
        if (! defined $parchmentObj || ! defined $posn || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->updateSlaveInStack', @_);
        }

        foreach my $levelObj ($parchmentObj->ivValues('levelHash')) {

            my $slaveObj = $levelObj->ivIndex('slaveCanvasObjList', $posn);
            if ($slaveObj) {

                $slaveObj->raise();
            }
        }

        return 1;
    }

    sub prepareDraw {

        # During a drawing cycle, called by $self->doDraw/->doQuickDraw for each region in which
        #   canvas objects will be drawn (also called, outside of a drawing cycle, by
        #   $self->startDrag)
        # Optimises the drawing process by doing many of the size and position calculations in
        #   advance
        #
        # Expected arguments
        #   $exitMode   - Matches the ->drawExitMode IV in GA::Obj::WorldModel or
        #                   $self->drawRegionmap; set to 'no_exit', 'simple_exit' or 'complex_exit'
        #
        # Return values
        #   'undef' on improper arguments
        #   1 otherwise

        my ($self, $exitMode, $check) = @_;

        # Check for improper arguments
        if (! defined $exitMode || defined $check) {



( run in 3.242 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )