Games-Axmud
view release on metacpan or search on metacpan
lib/Games/Axmud/Win/Map.pm view on Meta::CPAN
# If the automapper object is in 'track alone' mode, disable the mode
$self->session->mapObj->set_trackAloneFlag(FALSE);
return 1;
}
sub winDisengage {
# Should not be called, in general (provides compatibility with other types of window,
# whose window objects can be destroyed without closing the windows themselves)
# If called, this function just calls $self->winDestroy and returns the result
#
# Expected arguments
# (none besides $self)
#
# Return values
# 'undef' on improper arguments or if the window can't be disengaged
# 1 on success
my ($self, $check) = @_;
# Check for improper arguments
if (defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->winDisengage', @_);
}
return $self->winDestroy();
}
sub winDestroy {
# Called by GA::Obj::WorkspaceGrid->stop or by any other function
# Updates the automapper object (GA::Obj::Map), informs the parent workspace grid (if this
# 'grid' window is on a workspace grid) and the desktop object, and then destroys the
# Gtk3::Window (if it is open)
#
# Expected arguments
# (none besides $self)
#
# Return values
# 'undef' on improper arguments, if the window can't be destroyed or if it has already
# been destroyed
# 1 on success
my ($self, $check) = @_;
# Check for improper arguments
if (defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->winDestroy', @_);
}
if (! $self->winBox) {
# Window already destroyed in a previous call to this function
return undef;
}
# If the pause window is visible, destroy it
if ($axmud::CLIENT->busyWin) {
$self->hidePauseWin();
}
# If the automapper object knows the current world model room, and if the Locator task is
# running and knows about the current location, and if the world model flag that permits
# it is set, and if this Automapper window isn't currently in 'wait' mode, let the
# automapper go into 'track alone' mode
if (
$self->mapObj->currentRoom
&& $self->session->locatorTask
&& $self->session->locatorTask->roomObj
&& $self->worldModelObj->allowTrackAloneFlag
&& $self->mode ne 'wait'
) {
# Go into 'track alone' mode
$self->mapObj->set_trackAloneFlag(TRUE);
}
# Update the parent GA::Obj::Map in all cases
$self->mapObj->set_mapWin();
# Close any 'free' windows for which this window is a parent
foreach my $winObj ($self->ivValues('childFreeWinHash')) {
$winObj->winDestroy();
}
# Inform the parent workspace grid object (if any)
if ($self->workspaceGridObj) {
$self->workspaceGridObj->del_gridWin($self);
}
# Inform the desktop object
$axmud::CLIENT->desktopObj->del_gridWin($self);
# Destroy the Gtk3::Window
eval { $self->winBox->destroy(); };
if ($@) {
# Window can't be destroyed
return undef;
} else {
$self->ivUndef('winWidget');
$self->ivUndef('winBox');
}
# Inform the ->owner, if there is one
if ($self->owner) {
$self->owner->del_winObj($self);
}
# This type of window is unique to its GA::Session (only one can be open at any time, per
# session); inform the session it has closed
$self->session->set_mapWin();
lib/Games/Axmud/Win/Map.pm view on Meta::CPAN
# Check for improper arguments
if (defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->restrictUpdateMode', @_);
}
# Mark the radio/toolbar buttons for 'update mode' as sensitive, or not
$radioMenuItem = $self->ivShow('menuToolItemHash', 'set_update_mode');
$toolbarButton = $self->ivShow('menuToolItemHash', 'icon_set_update_mode');
if ($self->worldModelObj->disableUpdateModeFlag || $self->session->status eq 'offline') {
if ($radioMenuItem) {
$radioMenuItem->set_sensitive(FALSE);
}
if ($toolbarButton) {
$toolbarButton->set_sensitive(FALSE);
}
} else {
if ($radioMenuItem) {
$radioMenuItem->set_sensitive(TRUE);
}
if ($toolbarButton) {
$toolbarButton->set_sensitive(TRUE);
}
}
return 1;
}
# Pause windows handlers
sub showPauseWin {
# Can be called by anything
# Makes the pause window visible (a 'dialogue' window used only by this automapper)
#
# Expected arguments
# (none besides $self)
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $check) = @_;
# Check for improper arguments
if (defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->showPauseWin', @_);
}
if (! $axmud::CLIENT->busyWin) {
# Show the window widget
$self->showBusyWin(
$axmud::SHARE_DIR . '/icons/system/mapper.png',
'Working...',
);
}
return 1;
}
sub hidePauseWin {
# Can be called by anything
# Makes the pause window invisible
#
# Expected arguments
# (none besides $self)
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $check) = @_;
# Check for improper arguments
if (defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->hidePauseWin', @_);
}
if ($axmud::CLIENT->busyWin) {
$self->closeDialogueWin($axmud::CLIENT->busyWin);
}
return 1;
}
# Canvas callbacks
sub setupCanvasEvent {
# Called by $self->resetMap() to create an anonymous function to intercept signals from the
# map background, filter out the signals we don't want, and pass the signals we do want to
# an event handler
# Because the background is at the 'bottom', the anonymous function is only called when the
# user is clicking on an empty part of the map
# Also called by $self->drawRoomEcho when the user clicks on a room echo, which we should
# treat as if it were a click on the map background
#
# Expected arguments
# $canvasObj - The GooCanvas2::CanvasRect which is the map's background (or the
# GooCanvas2::CanvasRect which is a room echo, which should be treated
# as part of the map background)
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $canvasObj, $check) = @_;
# Check for improper arguments
if (! defined $canvasObj || defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->setupCanvasEvent', @_);
}
$canvasObj->signal_connect('button_press_event' => sub {
my ($item, $target, $event) = @_;
# If the tooltips are visible, hide them
$self->hideTooltips();
# All clicks on the canvas itself are handled by this function
$self->canvasEventHandler($canvasObj, $event);
});
$canvasObj->signal_connect('button_release_event' => sub {
my ($item, $target, $event) = @_;
# If the tooltips are visible, hide them
$self->hideTooltips();
# All clicks on the canvas itself are handled by this function
$self->canvasEventHandler($canvasObj, $event);
});
$canvasObj->signal_connect('motion_notify_event' => sub {
my ($item, $target, $event) = @_;
( run in 1.754 second using v1.01-cache-2.11-cpan-39bf76dae61 )