Games-Axmud
view release on metacpan or search on metacpan
lib/Games/Axmud/OtherWin.pm view on Meta::CPAN
return 1;
}
sub getMnemonic {
# Called by $self->setTabList_prof and several other functions
# Given the label of a tab - e.g. 'world' - create a label mnemonic, e.g. '_world' (which
# the user can select with the ALT+W key combination)
# The calling function supplies a hash of letters that have already been used for other
# mnemonics, so that each label can be selected with a different key combination (for as
# long as there are spare letters remaining)
#
# Expected arguments
# $string - The string to process, e.g. 'world'
# $hashRef - Reference to a hash of mnemonics already used, in the form
# $hash{letter} = undef
#
# Return values
# 'undef' on improper arguments
# Otherwise, returns the modified string
my ($self, $string, $hashRef, $check) = @_;
# Check for improper arguments
if (! defined $string || ! defined $hashRef || defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->getMnemonic', @_);
}
if (! $string) {
# Can't process an empty string
return $string;
}
# Dereference the supplied hash (for convenience)
# Examine each letter of $string in turn, looking for one which hasn't already been used as
# a mnemonic
for (my $count = 0; $count < length($string); $count++) {
my $letter = lc(substr($string, $count, 1));
if (! exists $$hashRef{$letter}) {
# Insert an underline at this location
substr($string, $count, 0, '_');
# This mnemonic is no longer available
$$hashRef{$letter} = undef;
return $string;
}
}
# Cannot add an underline to $string; all of its letters are already in use. Return the
# unmodified string
return $string
}
# Treeview header responses - profiles
sub allProfHeader {
# Called by ->treeViewChanged when the user clicks on the 'All profiles' header in the
# treeview
#
# Expected arguments
# $item - The treeview item that was clicked (i.e. the text it contains)
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $item, $check) = @_;
# Local variables
my (
$tabListRef, $shortTabListRef, $columnListRef, $dataHashRef, $buttonListRef,
@shortTabList,
%dataHash,
);
# Check for improper arguments
if (! defined $item || defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->allProfHeader', @_);
}
# Prepare the list of tabs
($tabListRef, $shortTabListRef) = $self->setTabList_prof();
# Prepare the list of column headings
$columnListRef = $self->setColumnList_prof();
# Prepare the list of buttons
$buttonListRef = $self->setButtonList_prof();
# Prepare the data to be displayed. Each item in @$shortTabListRef is a profile category,
# e.g. 'world' or 'char'
@shortTabList = @$shortTabListRef;
foreach my $tab (@shortTabList) {
my (@profList, @sortedList, @dataList);
if ($tab eq 'world') {
# Add world profiles from the GA::Client's hash
@profList = sort {lc($a->name) cmp lc($b->name)}
($axmud::CLIENT->ivValues('worldProfHash'));
foreach my $profObj (@profList) {
my ($flag, $listRef);
if ($profObj eq $self->session->currentWorld) {
$flag = TRUE;
} else {
$flag = FALSE;
}
$listRef = [$flag, $profObj->name, $profObj->category];
push (@dataList, $listRef);
lib/Games/Axmud/OtherWin.pm view on Meta::CPAN
# treeview
#
# Expected arguments
# $item - The treeview item that was clicked (i.e. the text it contains)
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $item, $check) = @_;
# Local variables
my (
$tabListRef, $columnListRef, $dataHashRef, $buttonListRef, $count,
@dataList, @otherList,
%dataHash,
);
# Check for improper arguments
if (! defined $item || defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->profPriorityHeader', @_);
}
# Prepare the list of tabs
$tabListRef = [
'Profile priority list', 'Profile _priority list',
];
# Prepare the list of column headings
$columnListRef = [
'Priority' => 'text',
'Category' => 'text',
];
# Prepare the list of buttons
$buttonListRef = [
'Move to top', 'Profile category has the highest priority',
'buttonMoveTop_profPriority',
'Move up', 'Profile category has a higher priority',
'buttonMoveUp_profPriority',
'Move down', 'Profile category has a lower priority',
'buttonMoveDown_profPriority',
'Give priority', 'Add the selected category to the priority list',
'buttonGivePriority_profPriority',
'Lose priority', 'Remove the selected category from the priority list',
'buttonLosePriority_profPriority',
'Reset list', 'Use the default priority list',
'buttonResetList_profPriority',
];
# Compile the data to display
$dataHashRef = $self->compileList_profPriority();
# (Nothing happens if the user double-clicks on a row)
# Display all of this in the notebook
return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef);
}
# Treeview header responses - dictionaries
sub allDictHeader {
# Called by ->treeViewChanged when the user clicks on the 'All dictionaries' header in the
# treeview
#
# Expected arguments
# $item - The treeview item that was clicked (i.e. the text it contains)
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $item, $check) = @_;
# Local variables
my (
$tabListRef, $columnListRef, $dataHashRef, $buttonListRef,
@objList, @dataList,
%dataHash,
);
# Check for improper arguments
if (! defined $item || defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->allDictHeader', @_);
}
# Prepare the list of tabs
$tabListRef = [
'Dictionary' => '_Dictionary',
];
# Prepare the list of column headings
$columnListRef = [
'Current' => 'bool',
'Name' => 'text',
'Language' => 'text',
];
# Prepare the list of buttons
$buttonListRef = [
'Add', 'Add a new dictionary', 'buttonAdd_dict',
'Edit', 'Edit the selected dictionary', 'buttonEdit_dict',
'Set current', 'Set the current dictionary', 'buttonSet_dict',
'Clone', 'Clone the selected dictionary', 'buttonClone_dict',
'Delete', 'Delete the selected dictinoary', 'buttonDelete_dict',
'Dump', 'Display a list of dictionaries in the \'main\' window', 'buttonDump_dict',
];
# Prepare the data to be displayed (there is only one tab)
@objList = sort {lc($a->name) cmp lc($b->name)} ($axmud::CLIENT->ivValues('dictHash'));
OUTER: foreach my $dictObj (@objList) {
my ($listRef, $flag);
if ($dictObj eq $self->session->currentDict) {
$flag = TRUE;
} else {
$flag = FALSE;
lib/Games/Axmud/OtherWin.pm view on Meta::CPAN
@dataList,
%dataHash,
);
# Check for improper arguments
if (! defined $item || defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->currentDictHeader', @_);
}
# Prepare the list of tabs
$tabListRef = [
'Dictionary' => '_Dictionary',
];
# Prepare the list of column headings
$columnListRef = [
'Current' => 'bool',
'Name' => 'text',
'Language' => 'text',
];
# Prepare the list of buttons
$buttonListRef = [
'Add', 'Add a new dictionary', 'buttonAdd_dict',
'Edit', 'Edit the selected dictionary', 'buttonEdit_dict',
'Set current', 'Set the current dictionary', 'buttonSet_dict',
'Clone', 'Clone the selected dictionary', 'buttonClone_dict',
'Delete', 'Delete the selected dictinoary', 'buttonDelete_dict',
'Dump', 'Display a list of dictionaries in the \'main\' window', 'buttonDump_dict',
];
# Prepare the data to be displayed (there is only one tab, and there should be only one
# dictionary to display)
OUTER: foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) {
my $listRef;
if ($dictObj eq $self->session->currentDict) {
$listRef = [TRUE, $dictObj->name, $dictObj->language];
push (@dataList, $listRef);
}
}
$dataHash{'Dictionary'} = \@dataList;
$dataHashRef = \%dataHash;
# Which function to call if the user double-clicks on a row in the list - in this case, it's
# equivalent to the edit button
$self->ivPoke('notebookSelectRef', sub {
$self->buttonEdit_dict();
});
# Display all of this in the notebook
return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef);
}
# Treeview header responses - tasks
sub availableTaskHeader {
# Called by ->treeViewChanged when the user clicks on the 'Available tasks' header in the
# treeview
#
# Expected arguments
# $item - The treeview item that was clicked (i.e. the text it contains)
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $item, $check) = @_;
# Local variables
my (
$tabListRef, $columnListRef, $dataHashRef, $buttonListRef,
@objList, @dataList,
%dataHash,
);
# Check for improper arguments
if (! defined $item || defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->availableTaskHeader', @_);
}
# Prepare the list of tabs
$tabListRef = [
'Available tasks' => '_Available tasks',
];
# Prepare the list of column headings
$columnListRef = [
'Built-in' => 'bool',
'Task name' => 'text',
];
# Prepare the list of buttons
$buttonListRef = [
'Start', 'Start a new task with default settings', 'buttonStart_availableTask',
'Start options', 'Start a new task with non-standard settings',
'buttonStartOptions_availableTask',
'Add initial', 'Add a new task to the global initial tasklist',
'buttonAddInitial_availableTask',
'Add custom', 'Add a new task to the custom tasklist',
'buttonAddCustom_availableTask',
'Halt', 'Halt all currently-running copies of the selected task',
'buttonHalt_availableTask',
'Kill', 'Kill all currently-running copies of the selected task',
'buttonKill_availableTask',
'Pause', 'Pauses all currently-running copies of the selected task',
'buttonPause_availableTask',
'Safe resume', 'Resume all tasks paused with the pause button',
'buttonSafeResume_task',
'Reset', 'Reset all currently-running copies of the selected task',
'buttonReset_availableTask',
'Help', 'Shows help for the selected task', 'buttonHelp_availableTask',
];
lib/Games/Axmud/OtherWin.pm view on Meta::CPAN
}
# Prepare the list of tabs
$tabListRef = [
'Task labels' => 'Task _labels',
];
# Prepare the list of column headings
$columnListRef = [
'Built-in' => 'bool',
'Label' => 'text',
'Standard task name' => 'text',
];
# Prepare the list of buttons
$buttonListRef = [
'Add', 'Add a new task label', 'buttonAdd_taskLabel',
'Delete', 'Delete an existing task label', 'buttonDelete_taskLabel',
'Empty labels', 'Empties all labels attached to a particular task',
'buttonEmpty_taskLabel',
'Reset', 'Reset all task labels to defaults', 'buttonReset_taskLabel',
'Reset All', 'Resets all task labels to defaults', 'buttonResetAll_taskLabel',
'Dump', 'Dumps the list of task labels to the \'main\' window', 'buttonDump_taskLabel',
];
# Prepare the data to be displayed (there is only one tab)
@list = sort {lc($a) cmp lc($b)} ($axmud::CLIENT->ivKeys('taskLabelHash'));
foreach my $label (@list) {
my ($flag, $listRef);
if ($axmud::CLIENT->ivExists('constTaskLabelHash', $label)) {
$flag = TRUE;
} else {
$flag = FALSE,
}
$listRef = [
$flag,
$label,
$axmud::CLIENT->ivShow('taskLabelHash', $label),
];
push (@dataList, $listRef);
}
$dataHash{'Task labels'} = \@dataList;
$dataHashRef = \%dataHash;
# Which function to call if the user double-clicks on a row in the list - in this case, it's
# equivalent to the edit button
$self->ivPoke('notebookSelectRef', sub {
$self->buttonEdit_taskLabel();
});
# Display all of this in the notebook
return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef);
}
# Treeview header responses - cages
sub allCageHeader {
# Called by ->treeViewChanged when the user clicks on the 'All cages' header in the treeview
#
# Expected arguments
# $item - The treeview item that was clicked (i.e. the text it contains)
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $item, $check) = @_;
# Local variables
my (
$tabListRef, $shortTabListRef, $columnListRef, $dataHashRef, $buttonListRef,
@shortTabList,
%dataHash,
);
# Check for improper arguments
if (! defined $item || defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->allCageHeader', @_);
}
# Prepare the list of tabs
($tabListRef, $shortTabListRef) = $self->setTabList_cage();
# Prepare the list of column headings
$columnListRef = $self->setColumnList_cage();
# Prepare the list of buttons
$buttonListRef = $self->setButtonList_cage();
# Prepare the data to be displayed
@shortTabList = @$shortTabListRef;
OUTER: foreach my $tab (@shortTabList) {
my (@cageList, @dataList);
@cageList = $self->getSortedCages($tab);
# @cageList contains a sorted list of cages. Convert that list into one that can be
# displayed in a GA::Obj::SimpleList, in columns
foreach my $cageObj (@cageList) {
my ($flag, $listRef);
if (
$self->session->ivExists('currentCageHash', $cageObj->name)
&& $self->session->ivShow('currentCageHash', $cageObj->name) eq $cageObj
) {
$flag = TRUE;
} else {
$flag = FALSE;
}
$listRef = [$flag, $cageObj->name];
push (@dataList, $listRef);
}
lib/Games/Axmud/OtherWin.pm view on Meta::CPAN
my ($self, $item, $check) = @_;
# Local variables
my (
$tabListRef, $columnListRef, $dataHashRef, $buttonListRef,
@categoryList, @dataList,
%dataHash,
);
# Check for improper arguments
if (! defined $item || defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->interfaceModelHeader', @_);
}
# Prepare the list of tabs
$tabListRef = [
'Interface models' => '_Interface models',
];
# Prepare the list of column headings
$columnListRef = [
'Category' => 'text',
'Stimulus' => 'text',
'Response' => 'text',
];
# Prepare the list of buttons
$buttonListRef = [
'View', 'View the selected interface model', 'buttonView_interfaceModel',
'Dump', 'Display this list of interface models in the \'main\' window',
'buttonDump_interfaceModel',
];
# Prepare the data to be displayed (there is only one tab)
@categoryList = ('trigger', 'alias', 'macro', 'timer', 'hook');
foreach my $category (@categoryList) {
my ($modelObj, $listRef);
$modelObj = $axmud::CLIENT->ivShow('interfaceModelHash', $category);
$listRef = [$modelObj->category, $modelObj->stimulusName, $modelObj->responseName];
push (@dataList, $listRef);
}
$dataHash{'Interface models'} = \@dataList;
$dataHashRef = \%dataHash;
# Which function to call if the user double-clicks on a row in the list - in this case, it's
# equivalent to the edit button
$self->ivPoke('notebookSelectRef', sub {
$self->buttonView_interfaceModel();
});
# Display all of this in the notebook
return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef);
}
# Treeview header responses - world model
sub modelHeader {
# Called by $self->allModelHeader, $self->regionModelHeader etc, after a call by
# ->treeViewChanged when the user clicks on one of the items under the 'world model'
# header in the treeview
#
# Expected arguments
# $tabName - What to display on the tab, e.g. 'Weapons'
# $tabShortCut - e.g. '_Weapons'
# $iv - The GA::Obj::WorldModel IV storing all the world model objects of a
# certain type, e.g. 'regionModelHash', 'weaponModelHash' (or even
# 'modelHash')
# $buttonListRef - Reference to a list containing the buttons to use for this category of
# world model object (usually defined by $self->setButtonList_model,
# but some types of object specify their own buttons)
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $tabName, $tabShortCut, $iv, $buttonListRef, $check) = @_;
# Local variables
my (
$tabListRef, $columnListRef, $wmObj, $dataHashRef,
@objList, @dataList,
%dataHash,
);
# Check for improper arguments
if (
! defined $tabName || ! defined $tabShortCut || ! defined $iv
|| ! defined $buttonListRef || defined $check
) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->modelHeader', @_);
}
# Prepare the list of tabs
$tabListRef = [
$tabName => $tabShortCut,
];
# Prepare the list of column headings
$columnListRef = $self->setColumnList_model();
# Import the world model object (for convenience)
$wmObj = $self->session->worldModelObj;
# Prepare the data to be displayed (there is only one tab). Rather than sort the model
# objects by number (which might take a long time), check every number between 1 and
# GA::Obj::WorldModel->modelObjCount, using only objects which are actually stored in $iv
if ($wmObj->modelObjCount) {
for (my $count = 1; $count <= $wmObj->modelObjCount; $count++) {
if (exists $wmObj->{$iv}{$count}) {
push (@objList, $wmObj->{$iv}{$count});
}
}
lib/Games/Axmud/OtherWin.pm view on Meta::CPAN
$columnListRef = [
'Exit #' => 'int',
'Room #' => 'int',
'Nominal dir' => 'text',
'Map dir' => 'text',
];
# Prepare the list of buttons
$buttonListRef = [
'Add', 'Add an exit to the exit model', 'buttonAdd_exitModel',
'Edit', 'Edit the selected exit', 'buttonEdit_exitModel',
'Delete', 'Delete the selected exit from the exit model', 'buttonDelete_exitModel',
'Dump', 'Dump the contents of the exit model in the \'main\' window',
'buttonDump_exitModel',
];
# Import the world model object (for convenience)
$wmObj = $self->session->worldModelObj;
# Prepare the data to be displayed (there is only one tab). Rather than sort the exit model
# objects by number (which might take a long time), check every number between 1 and
# GA::Obj::WorldModel->exitObjCount, using only objects which are actually stored in $iv
if ($wmObj->exitObjCount) {
for (my $count = 1; $count <= $wmObj->exitObjCount; $count++) {
if (exists $wmObj->{'exitModelHash'}{$count}) {
push (@objList, $wmObj->{'exitModelHash'}{$count});
}
}
}
foreach my $exitObj (@objList) {
my ($listRef, $mapDir);
if ($exitObj->mapDir) {
$mapDir = $exitObj->mapDir;
} else {
$mapDir = 'unallocatable';
}
$listRef = [$exitObj->number, $exitObj->parent, $exitObj->dir, $mapDir];
push (@dataList, $listRef);
}
$dataHash{'Exits'} = \@dataList;
$dataHashRef = \%dataHash;
# Which function to call if the user double-clicks on a row in the list - in this case, it's
# equivalent to the edit button
$self->ivPoke('notebookSelectRef', sub {
$self->buttonEdit_exitModel();
});
# Display all of this in the notebook
return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef);
}
# Treeview header responses - buffers
sub displayBufferHeader {
# Called by ->treeViewChanged when the user clicks on the 'Display buffer' header in the
# treeview
#
# Expected arguments
# $item - The treeview item that was clicked (i.e. the text it contains)
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $item, $check) = @_;
# Local variables
my (
$tabListRef, $columnListRef, $dataHashRef, $buttonListRef,
@objList, @dataList,
%dataHash,
);
# Check for improper arguments
if (! defined $item || defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->displayBufferHeader', @_);
}
# Prepare the list of tabs
$tabListRef = [
'Display buffer' => '_Display buffer',
];
# Prepare the list of column headings
$columnListRef = [
'Line' => 'int',
'Time' => 'int',
'Text' => 'text',
];
# Prepare the list of buttons
$buttonListRef = [
'Dump 20', 'Display the most recent 20 lines in the \'main\' window',
'buttonDump20_displayBuffer',
'Dump all', 'Display all lines in the \'main\' window', 'buttonDumpAll_displayBuffer',
'Status', 'Display the display buffer\'s status in the \'main\' window',
'buttonStatus_displayBuffer',
'View line', 'View the selected line in an \'edit\' window', 'buttonView_displayBuffer',
'Test pattern', 'Test a pattern (regex) against this line', 'buttonTest_displayBuffer',
'Save buffer', 'Save lines from the display buffer to file', 'buttonSave_displayBuffer',
'Save both', 'Save lines from the display and command buffers to file',
'buttonSaveBoth_displayBuffer',
];
# Prepare the data to be displayed (there is only one tab). Rather than sort the buffer
# objects by number (which might take a while), check every number between
# GA::Session->displayBufferFirst and ->displayBufferLast
if (defined $self->session->displayBufferLast) {
for (
lib/Games/Axmud/OtherWin.pm view on Meta::CPAN
'Time' => 'int',
'Command' => 'text',
];
# Prepare the list of buttons
$buttonListRef = [
'Dump 20', 'Display the most recent 20 commands in the \'main\' window',
'buttonDump20_cmdBuffer',
'Dump all', 'Display all commands in the \'main\' window', 'buttonDumpAll_cmdBuffer',
'Status', 'Display the command buffer\'s status in the \'main\' window',
'buttonStatus_cmdBuffer',
'View line', 'View the selected line in an \'edit\' window', 'buttonView_cmdBuffer',
'Save buffer', 'Save lines from the command buffer to file', 'buttonSave_cmdBuffer',
'Save both', 'Save lines from the text and command buffers to file',
'buttonSaveBoth_displayBuffer',
];
# Prepare the data to be displayed (there is only one tab). Rather than sort the buffer
# objects by number (which might take a while), check every number between
# GA::Session->cmdBufferFirst and ->cmdBufferLast
if ($self->session->cmdBufferCount) {
for (
my $count = $self->session->cmdBufferFirst;
$count <= $self->session->cmdBufferLast;
$count++
) {
# There shouldn't be any missing buffer objects, but just in case...
if (exists $self->session->{'cmdBufferHash'}{$count}) {
push (@objList, $self->session->{'cmdBufferHash'}{$count});
}
}
}
foreach my $bufferObj (@objList) {
my $listRef = [
$bufferObj->number,
int ($bufferObj->time),
$bufferObj->cmd,
];
push (@dataList, $listRef);
}
$dataHash{'Command buffer'} = \@dataList;
$dataHashRef = \%dataHash;
# (Do nothing when a line is double-clicked)
# Display all of this in the notebook
return $self->refreshNotebook(
$tabListRef,
$columnListRef,
$dataHashRef,
$buttonListRef,
TRUE, # Scroll to bottom
);
}
# Treeview header responses - other objects
sub chatContactHeader {
# Called by ->treeViewChanged when the user clicks on the 'Chat contacts' header in the
# treeview
#
# Expected arguments
# $item - The treeview item that was clicked (i.e. the text it contains)
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $item, $check) = @_;
# Local variables
my (
$tabListRef, $columnListRef, $dataHashRef, $buttonListRef,
@list, @dataList,
%dataHash,
);
# Check for improper arguments
if (! defined $item || defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->chatContactHeader', @_);
}
# Prepare the list of tabs
$tabListRef = [
'Chat contact' => '_Chat contact',
];
# Prepare the list of column headings
$columnListRef = [
'Name' => 'text',
];
# Prepare the list of buttons
$buttonListRef = [
'Add', 'Add a new chat contact', 'buttonAdd_chatContact',
'Edit', 'Edit the selected chat contact', 'buttonEdit_chatContact',
'Delete', 'Delete the selected chat contact', 'buttonDelete_chatContact',
'Dump', 'Display a list of chat contacts in the \'main\' window',
'buttonDump_chatContact',
];
# Prepare the data to be displayed (there is only one tab)
@list = sort {lc($a->name) cmp lc($b->name)} ($axmud::CLIENT->ivValues('chatContactHash'));
OUTER: foreach my $obj (@list) {
push (@dataList, [$obj->name]);
}
$dataHash{'Chat contact'} = \@dataList;
$dataHashRef = \%dataHash;
# Which function to call if the user double-clicks on a row in the list - in this case, it's
# equivalent to the edit button
$self->ivPoke('notebookSelectRef', sub {
lib/Games/Axmud/OtherWin.pm view on Meta::CPAN
);
# Check for improper arguments
if (! defined $item || defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->zonemapHeader', @_);
}
# Prepare the list of tabs
$tabListRef = [
'Zonemap' => '_Zonemap',
];
# Prepare the list of column headings
$columnListRef = [
'Standard' => 'bool',
'Full' => 'bool',
'Temporary' => 'bool',
'Name' => 'text',
];
# Prepare the list of buttons
$buttonListRef = [
'Add', 'Add a new zonemap', 'buttonAdd_zonemap',
'Clone', 'Clone the selected zonemap', 'buttonClone_zonemap',
'Edit', 'Edit the selected zonemap', 'buttonEdit_zonemap',
'Delete', 'Delete the selected zonemap', 'buttonDelete_zonemap',
'Dump', 'Display a list of zonemaps in the \'main\' window', 'buttonDump_zonemap',
];
# Prepare the data to be displayed (there is only one tab)
@list = sort {lc($a->name) cmp lc($b->name)} ($axmud::CLIENT->ivValues('zonemapHash'));
OUTER: foreach my $obj (@list) {
my ($flag, $listRef);
if ($axmud::CLIENT->ivExists('standardZonemapHash', $obj->name)) {
$flag = TRUE;
} else {
$flag = FALSE;
}
$listRef = [$flag, $obj->fullFlag, $obj->tempFlag, $obj->name];
push (@dataList, $listRef);
}
$dataHash{'Zonemap'} = \@dataList;
$dataHashRef = \%dataHash;
# Which function to call if the user double-clicks on a row in the list - in this case, it's
# equivalent to the edit button
$self->ivPoke('notebookSelectRef', sub {
$self->buttonEdit_zonemap();
});
# Display all of this in the notebook
return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef);
}
# Treeview header responses - help
sub quickHelpHeader {
# Called by ->treeViewChanged when the user clicks on one of the quick help item in the
# treeview
#
# Expected arguments
# $item - The treeview item that was clicked (i.e. the text it contains)
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $item, $check) = @_;
# Local variables
my (
$file, $fileHandle,
@list,
);
# Check for improper arguments
if (! defined $item || defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->quickHelpHeader', @_);
}
# Load the quick help file
$file = $axmud::SHARE_DIR . '/help/misc/quickhelp';
if (-e $file && open($fileHandle, $file)) {
@list = <$fileHandle>;
close($fileHandle);
foreach my $item (@list) {
chomp $item;
}
}
# Display the help in the notebook
return $self->refreshTextView($item, @list);
}
sub peekPokeHelpHeader {
# Called by ->treeViewChanged when the user clicks on one of the peek/poke help item in the
# treeview
#
# Expected arguments
# $item - The treeview item that was clicked (i.e. the text it contains)
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $item, $check) = @_;
# Local variables
my (
lib/Games/Axmud/OtherWin.pm view on Meta::CPAN
my @list;
# Check for improper arguments
if (defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->setColumnList_model', @_);
}
@list = (
'Model #' => 'int',
'Category' => 'text',
'Name' => 'text',
);
return \@list;
}
sub setButtonList_model {
# Called by $self->allModelHeader, $self->regionModelHeader, etc (most world model object
# tabs use this function, but a few - such as the tab for characters - specify their own
# buttons)
# Sets up the list of buttons appropriate for manipulating model objects in the notebook
# list, in the form
# [
# 'button_name', 'tooltip', 'callback_sub_ref',
# 'button_name', 'tooltip', 'callback_sub_ref',
# 'button_name', 'tooltip', 'callback_sub_ref',
# ...
# ]
#
# Expected arguments
# (none besides $self)
#
# Return values
# 'undef' on improper arguments
# Otherwise returns a reference to the list described above
my ($self, $check) = @_;
# Local variables
my @list;
# Check for improper arguments
if (defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->setButtonList_model', @_);
}
@list = (
'Add', 'Add an object to the world model', 'buttonAdd_model',
'Edit', 'Edit the selected world model object', 'buttonEdit_model',
'Delete', 'Delete the selected world model object', 'buttonDelete_model',
'Dump', 'Displays a list of all world model objects in the \'main\' window',
'buttonDump_model',
);
return \@list;
}
# Treeview callbacks
sub treeViewRowActivated {
# Treeview's 'row_activated' callback - expands and collapses parts of the tree
# Defined in $self->enable
#
# Expected arguments
# $tree - The Gtk3::TreeView widget
# $path, $column - The clicked cell
# $self - This Perl object
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($tree, $path, $column, $self, $check) = @_;
# Check for improper arguments
if (
! defined $tree || ! defined $path || ! defined $column || ! defined $self
|| defined $check
) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->treeViewRowActivated', @_);
}
if ($tree->row_expanded($path)) {
$tree->collapse_row($path);
} else {
$tree->expand_row($path, FALSE);
}
return 1;
}
sub treeViewChanged {
# Treeview's 'changed' callback - responds to clicks on the tree
# Defined in $self->winEnable
#
# Expected arguments
# $selection - Gtk3::Selection
# $self - This Perl object
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($selection, $self, $check) = @_;
# Local variables
my ($model, $iter, $type, $method);
# Check for improper arguments
if (! defined $selection || ! defined $self || defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->treeViewChanged', @_);
}
($model, $iter) = $selection->get_selected();
if (! $iter) {
return undef;
} else {
$type = $model->get($iter, 0);
}
# Is the clicked item a header? If so, call its function
if ($self->ivExists('headerHash', $type)) {
# ->notebookSelectRef's default value is 'undef'; the function we're about to call will
# set it, if need be
$self->ivPoke('notebookSelectRef', undef);
# Remember which type of notebook we're about to display
$self->ivPoke('notebookCurrentHeader', $type);
# Call the function to create this type of notebook
$method = $self->ivShow('headerHash', $type);
$self->$method($type);
}
return 1;
}
# Profile button callbacks
sub buttonAdd_prof {
# Callback: Adds a profile (equivalent to ';addworld', ';addchar', etc)
#
# Expected arguments
# (none besides $self)
#
# Return values
# 'undef' on improper arguments or if a temporary profile object can't be created
# 1 otherwise
( run in 2.202 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )