Games-Axmud
view release on metacpan or search on metacpan
lib/Games/Axmud/Win/Internal.pm view on Meta::CPAN
}
});
return 1;
}
sub setFocusOutEvent {
# Called by $self->winEnable
# Set up a ->signal_connect to watch out for the 'internal' window losing the focus
#
# 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 . '->setFocusInEvent', @_);
}
$self->winBox->signal_connect('focus-out-event' => sub {
my ($widget, $event) = @_;
# Update IVs
$self->ivPoke('focusFlag', FALSE);
# For 'main' windows, check active hook interfaces for all sessions using this window
# and fire hooks that are using the 'lose_focus' hook event
if ($self->visibleSession) {
foreach my $session ($axmud::CLIENT->listSessions()) {
if ($session->mainWin && $session->mainWin eq $self) {
$session->checkHooks('lose_focus');
}
}
}
# When the window loses focus, we no longer track SHIFT, ALT, CTRL or NUM LOCK
# keypresses. Set IVs
$self->ivPoke('shiftKeyFlag', FALSE);
$self->ivPoke('altKeyFlag', FALSE);
$self->ivPoke('altGrKeyFlag', FALSE);
$self->ivPoke('ctrlKeyFlag', FALSE);
$self->ivPoke('modifierKeyFlag', FALSE);
});
return 1;
}
# Other functions
sub updateColourScheme {
# Called by GA::Cmd::UpdateColourScheme->do (usually after a colour scheme is modified) and
# by GA::Cmd::SetXTerm->do (when the xterm colour cube is switched)
# Also called by $self->redrawWidgets, to neutralise Gtk3's charming tendency to redraw all
# our textviews the wrong colour
# Checks all textview objects in all pane objects in this window's Gtk3::Grid and updates
# colours for any textview objects that use the specified colour scheme
#
# Expected arguments
# (none besides $self)
#
# Optional arguments
# $colourScheme - The name of the colour scheme (matches a key in
# GA::Client->colourSchemeHash). If 'undef', all pane objects are
# updated using their existing colour scheme
# $noDrawFlag - TRUE when called by $self->redrawWidgets, meaning that the pane
# objects are told not to call GA::Win::Generic->winShowAll or
# GA::Obj::Desktop->updateWidgets as they normally would, so that
# ->redrawWidgets can do it when ready. FALSE (or 'undef') otherwise
#
# Return values
# 'undef' on improper arguments
# 1 on success
my ($self, $colourScheme, $noDrawFlag, $check) = @_;
# Check for improper arguments
if (defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->updateColourScheme', @_);
}
# If $colourScheme was specified, check it's a recognised colour scheme
if (defined $colourScheme) {
if (! $axmud::CLIENT->ivExists('colourSchemeHash', $colourScheme)) {
# Update all textview objects
$colourScheme = undef;
}
}
foreach my $tableObj ($self->tableStripObj->ivValues('tableObjHash')) {
if ($tableObj->type eq 'pane') {
$tableObj->updateColourScheme($colourScheme, $noDrawFlag);
}
}
return 1;
}
sub applyColourScheme {
# Called by GA::Cmd::ApplyColourScheme->do
# Applies a colour scheme to all textview objects in all pane objects in this window's
# Gtk3::Grid, replacing any colour schemes used before
#
# Expected arguments
lib/Games/Axmud/Win/Internal.pm view on Meta::CPAN
if (defined $check) {
return $axmud::CLIENT->writeImproper(
$self->_objClass . '->checkConnectedSessions',
@_,
);
}
if (! $axmud::CLIENT->confirmCloseMainWinFlag) {
# The window can be closed - no confirmation required
return 1;
}
# Otherwise, count connected sessions
$count = 0;
foreach my $session ($axmud::CLIENT->ivValues('sessionHash')) {
if (
$session->mainWin
&& $session->mainWin eq $self
&& $session->status eq 'connected'
) {
$count++;
}
}
if ($count) {
if ($count == 1) {
$msg = '1 connected session';
} else {
$msg = $count . ' connected sessions';
}
$choice = $self->showMsgDialogue(
'Close \'main\' window',
'question',
'This window is in use by ' . $msg . '. Are you sure you want to close it?',
'yes-no',
);
if ($choice && $choice eq 'yes') {
# Allow the window to close
return 1;
} else {
# Don't allow the window to close
return undef;
}
} else {
# No connected sessions, allow the window to close
return 1;
}
}
sub updateGauges {
# Called by various functions as a shortcut to GA::Strip::GaugeBox->updateGauges
#
# Expected arguments
# (none besides $self)
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $winmapName, $check) = @_;
# Local variables
my $stripObj;
# Check for improper arguments
if (defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->updateGauges', @_);
}
$stripObj = $self->ivShow('firstStripHash', 'Games::Axmud::Strip::GaugeBox');
if ($stripObj) {
$stripObj->updateGauges();
}
return 1;
}
sub resetEntry {
# Called by GA::Client->set_autoCompleteMode, ->set_autoCompleteType and
# ->set_autoCompleteParent or any other code which needs to reset the entry box (for some
# reason)
# The user can press the 'up'/'down' arrow keys to change the command displayed in the
# GA::Strip::Entry's command entry box
# The new command depends on various client IVs. If those IVs are changed, the entry box
# must be reset
#
# Expected arguments
# (none besides $self)
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $check) = @_;
# Local variables
my $stripObj;
# Check for improper arguments
if (defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->resetEntry', @_);
}
$stripObj = $self->ivShow('firstStripHash', 'Games::Axmud::Strip::Entry');
if ($stripObj) {
( run in 2.171 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )