Games-Axmud
view release on metacpan or search on metacpan
lib/Games/Axmud/PrefWin.pm view on Meta::CPAN
# $slWidget - The GA::Obj::SimpleList
# $columns - The number of columns in the list
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $slWidget, $columns, $check) = @_;
# Local variables
my @dataList;
# Check for improper arguments
if (! defined $slWidget || ! defined $columns || defined $check) {
return $axmud::CLIENT->writeImproper(
$self->_objClass . '->workspaces6Tab_refreshList',
@_,
);
}
# Compile the simple list data
foreach my $obj (
sort {
if ($a->workspaceObj->number != $b->workspaceObj->number) {
return $a->workspaceObj->number <=> $b->workspaceObj->number;
} else {
return $a->number <=> $b->number;
}
}
($axmud::CLIENT->desktopObj->ivValues('gridHash'))
) {
my $string;
if ($obj->owner) {
$string = $obj->owner->number;
} else {
$string = '(shared)';
}
push (@dataList,
$obj->workspaceObj->number,
$obj->number,
$string,
$obj->zonemap,
$obj->currentLayer,
$obj->maxLayers,
$obj->ivPairs('zoneHash'),
$obj->ivPairs('gridWinHash'),
);
}
# Reset the simple list
$self->resetListData($slWidget, [@dataList], $columns);
return 1;
}
sub workspaces6Tab_resetCombo {
# Called by $self->workspaces6Tab to reset the contents of the first combobox
#
# Expected arguments
# $combo - The combobox whose contents should be reset
# $title - The title used in the combobox
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $combo, $title, $check) = @_;
# Local variables
my @comboList;
# Check for improper arguments
if (! defined $combo || ! defined $title || defined $check) {
return $axmud::CLIENT->writeImproper(
$self->_objClass . '->workspaces6Tab_resetCombo',
@_,
);
}
# Compile a list of combobox items
@comboList = sort {$a <=> $b} ($axmud::CLIENT->desktopObj->ivKeys('workspaceHash'));
unshift (@comboList, $title);
# Reset the combobox
$self->resetComboBox($combo, @comboList);
return 1;
}
sub workspaces6Tab_resetCombo2 {
# Called by $self->workspaces6Tab to reset the contents of the second combobox
#
# Expected arguments
# $combo - The combobox whose contents should be reset
# $title - The title used in the combobox
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $combo, $title, $check) = @_;
# Local variables
my @comboList;
# Check for improper arguments
if (! defined $combo || ! defined $title || defined $check) {
return $axmud::CLIENT->writeImproper(
$self->_objClass . '->workspaces6Tab_resetCombo2',
@_,
);
}
# Compile a list of combobox items
@comboList = sort {lc($a) cmp lc($b)} ($axmud::CLIENT->ivKeys('zonemapHash'));
unshift (@comboList, $title);
# Reset the combobox
$self->resetComboBox($combo, @comboList);
return 1;
}
sub workspaces7Tab {
# Workspaces7 tab
#
# Expected arguments
# $innerNotebook - The Gtk3::Notebook object inside $self->notebook
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $innerNotebook, $check) = @_;
# Local variables
my @columnList;
# Check for improper arguments
if (! defined $innerNotebook || defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->workspaces7Tab', @_);
}
# Tab setup
my $grid = $self->addTab(
$innerNotebook,
'Page _7',
['Zonemaps'],
);
# Zonemaps
$self->addLabel($grid, '<b>Zonemaps</b>',
0, 12, 0, 1);
$self->addLabel($grid,
'<i>List of zonemaps, which divide a workspace grid into distinct zones</i>',
1, 12, 1, 2);
# Add a simple list
@columnList = (
'Name', 'text',
'Standard', 'bool',
'Full', 'bool',
'Temporary', 'bool',
'Number of zone models', 'int',
);
my $slWidget = $self->addSimpleList($grid, undef, \@columnList,
1, 12, 2, 9);
# Initialise the list
$self->workspaces7Tab_refreshList($slWidget, scalar (@columnList / 2));
# Add entry boxes and editing buttons
$self->addLabel($grid, 'Name',
1, 2, 9, 10);
my $entry = $self->addEntryWithIcon($grid, undef, 'string', 1, 16,
lib/Games/Axmud/PrefWin.pm view on Meta::CPAN
$radioButton->signal_connect('toggled' => sub {
if ($radioButton->get_active()) {
$self->ivPoke('searchAllFlag', TRUE);
$self->ivUndef('searchRegion');
}
});
($radioGroup, $radioButton2) = $self->addRadioButton(
$grid,
$radioGroup,
'Search in current region',
undef, undef,
TRUE,
1, 12, 3, 4
);
$radioButton2->signal_connect('toggled' => sub {
$self->ivPoke('searchAllFlag', FALSE);
$self->ivPoke('searchRegion', $self->session->mapWin->currentRegionmap->name);
});
# This widget is insensitive, if the current session doesn't have an Automapper window open,
# or if the Automapper window has no current regionmap
if (! $self->session->mapWin || ! $self->session->mapWin->currentRegionmap) {
$radioButton2->set_state('insensitive');
}
($radioGroup, $radioButton3) = $self->addRadioButton(
$grid,
$radioGroup,
'Search in region:',
undef, undef,
TRUE,
1, 4, 4, 5,
);
# Get a sorted list of regionmap names
@comboList = sort {lc($a) cmp lc($b)}
($self->session->worldModelObj->ivKeys('regionmapHash'));
my $combo = $self->addComboBox($grid, undef, \@comboList, '',
TRUE, # No 'undef' value used
4, 8, 4, 5);
$combo->signal_connect('changed' => sub {
if ($radioButton3->get_active()) {
$self->ivPoke('searchAllFlag', TRUE);
$self->ivPoke('searchRegion', $combo->get_active_text());
}
});
$radioButton3->signal_connect('toggled' => sub {
$self->ivPoke('searchAllFlag', FALSE);
$self->ivPoke('searchRegion', $combo->get_active_text());
});
# This radiobutton and its combobox are insensitive, if there are no regions
if (! $self->session->worldModelObj->regionmapHash) {
$radioButton3->set_state('insensitive');
$combo->set_state('insensitive');
}
# Bottom section
$self->addLabel($grid, '<i>Specify which categories of model object to search</i>',
1, 12, 6, 7);
# Add check buttons, one for each category of world model object
push (
@widgetList,
$self->searchTab_addCheckButton($grid, 'region', 'Search regions', 1, 4, 7, 8),
);
push (
@widgetList,
$self->searchTab_addCheckButton($grid, 'room', 'Search rooms', 1, 4, 8, 9),
);
push (
@widgetList,
$self->searchTab_addCheckButton($grid, 'weapon', 'Search weapons', 1, 4, 10, 11),
);
push (
@widgetList,
$self->searchTab_addCheckButton($grid, 'armour', 'Search armour', 1, 4, 11, 12),
);
push (
@widgetList,
$self->searchTab_addCheckButton($grid, 'garment', 'Search garments', 4, 8, 7, 8),
);
push (
@widgetList,
$self->searchTab_addCheckButton($grid, 'char', 'Search characters', 4, 8, 8, 9),
);
push (
@widgetList,
$self->searchTab_addCheckButton($grid, 'minion', 'Search minions', 4, 8, 10, 11),
);
push (
@widgetList,
$self->searchTab_addCheckButton($grid, 'sentient', 'Search sentients', 4, 8, 11, 12),
);
push (
@widgetList,
$self->searchTab_addCheckButton($grid, 'creature', 'Search creatures', 8, 12, 7, 8),
);
push (
@widgetList,
$self->searchTab_addCheckButton($grid, 'portable', 'Search portables', 8, 12, 8, 9),
);
lib/Games/Axmud/PrefWin.pm view on Meta::CPAN
if (
! defined $grid || ! defined $iv || ! defined $ivType || ! defined $label
|| ! defined $topAttach || defined $check
) {
return $axmud::CLIENT->writeImproper(
$self->_objClass . '->propertiesTab_addCheckButton',
@_,
);
}
# Add a checkbutton which turns on/off checking this IV completely
my $checkButton = $self->addCheckButton($grid, $label, undef, TRUE,
1, 6, $topAttach, ($topAttach + 1));
# Add a second checkbutton to specify the state of the flag
my $checkButton2 = $self->addCheckButton(
$grid, 'Select or deselect this setting', undef, TRUE,
6, 12, $topAttach, ($topAttach + 1));
# Signal connects
$checkButton->signal_connect('toggled' => sub {
if ($checkButton->get_active()) {
if ($checkButton2->get_active()) {
$self->ivAdd('searchHash', $iv, TRUE);
} else {
$self->ivAdd('searchHash', $iv, FALSE);
}
} else {
$self->ivDelete('searchHash', $iv);
}
});
$checkButton2->signal_connect('toggled' => sub {
if ($checkButton->get_active()) {
if ($checkButton2->get_active()) {
$self->ivAdd('searchHash', $iv, TRUE);
} else {
$self->ivAdd('searchHash', $iv, FALSE);
}
} else {
$self->ivDelete('searchHash', $iv);
}
});
$self->ivAdd('searchTypeHash', $iv, $ivType);
return 1;
}
sub propertiesTab_addComboBox {
# Called by several $self->propertiesXXX tabs
# Adds a single line to the tab with a main checkbutton, a label and a combobox
#
# Expected arguments
# $grid - The Gtk3::Grid for this tab
# $iv - The IV to add to the search - matches a key in $self->searchHash
# $ivType - What kind of checking should be done on thiss IV (see the comments in
# ->new)
# $label - The accompanying label text
# $listRef - Reference to a list containing the values to put in the combobox
# $topAttach - The position of the line in the grid
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $grid, $iv, $ivType, $label, $listRef, $topAttach, $check) = @_;
# Check for improper arguments
if (
! defined $grid || ! defined $iv || ! defined $ivType || ! defined $label
|| ! defined $listRef || ! defined $topAttach || defined $check
) {
return $axmud::CLIENT->writeImproper(
$self->_objClass . '->propertiesTab_addComboBox',
@_,
);
}
# Add a checkbutton which turns on/off checking this IV completely
my $checkButton = $self->addCheckButton($grid, $label, undef, TRUE,
1, 6, $topAttach, ($topAttach + 1));
# Add a combobox
my $combo = $self->addComboBox($grid, undef, $listRef, '',
TRUE, # No 'undef' value used
6, 12, $topAttach, ($topAttach + 1));
# Signal connects
$checkButton->signal_connect('toggled' => sub {
if ($checkButton->get_active()) {
$self->ivAdd('searchHash', $iv, $combo->get_active_text());
} else {
$self->ivDelete('searchHash', $iv);
}
});
$combo->signal_connect('changed' => sub {
if ($checkButton->get_active()) {
$self->ivAdd('searchHash', $iv, $combo->get_active_text());
} else {
$self->ivDelete('searchHash', $iv);
}
});
$self->ivAdd('searchTypeHash', $iv, $ivType);
return 1;
}
sub propertiesTab_addEntryWithIcon {
# Called by several $self->propertiesXXX tabs
# Adds a single line to the tab with a main checkbutton, a label and an entry
#
# Expected arguments
# $grid - The Gtk3::Grid for this tab
# $iv - The IV to add to the search - matches a key in $self->searchHash
# $ivType - What kind of checking should be done on this IV (see the comments in
# ->new)
# $label - The accompanying label text
# $mode - 'int', 'float', 'string' or a reference to a function
# - if 'int', an integer is expected with the specified min/max values
# - if 'float', a floating point number is expected with the specified min/max
# values
# - if 'string', a string is expected (which might be a number) with the
# specified min/max length
# - if 'regex', a regex is expected with the specified min/max length
# - if a function reference, a function is called which should return FALSE or
# TRUE, depending on the value of the entry; the icon is set accordingly
# $min, $max - The values described above (ignored when $mode is a function reference).
# If $min is 'undef', there is no minimum; if $max is 'undef', there is no
# maximum
# $topAttach - The position of the line in the grid
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $grid, $iv, $ivType, $label, $mode, $min, $max, $topAttach, $check) = @_;
# Check for improper arguments
if (
! defined $grid || ! defined $iv || ! defined $ivType || ! defined $label
|| ! defined $mode || ! defined $topAttach || defined $check
) {
return $axmud::CLIENT->writeImproper(
$self->_objClass . '->propertiesTab_addEntryWithIcon',
@_,
);
}
# Add a checkbutton which turns on/off checking this IV completely
my $checkButton = $self->addCheckButton($grid, $label, undef, TRUE,
1, 6, $topAttach, ($topAttach + 1));
# Add the entry box
my $entry = $self->addEntryWithIcon($grid, undef, $mode, $min, $max,
6, 12, $topAttach, ($topAttach + 1));
# Signal connects
$checkButton->signal_connect('toggled' => sub {
if ($checkButton->get_active() && $self->checkEntryIcon($entry)) {
$self->ivAdd('searchHash', $iv, $entry->get_text());
} else {
$self->ivDelete('searchHash', $iv);
}
});
$entry->signal_connect('changed' => sub {
if ($checkButton->get_active()) {
$self->ivAdd('searchHash', $iv, $entry->get_text());
} else {
$self->ivDelete('searchHash', $iv);
}
});
$self->ivAdd('searchTypeHash', $iv, $ivType);
return 1;
}
sub propertiesTab_addEntryWithRange {
# Called by several $self->propertiesXXX tabs
# Adds a single line to the tab with a main checkbutton, a label, a combobox specifiying an
# operator (equals, less than, etc) and one or two entry boxes
# Used with IVs that have numeric values
#
# Expected arguments
# $grid - The Gtk3::Grid for this tab
# $iv - The IV to add to the search - matches a key in $self->searchHash
# $ivType - What kind of checking should be done on this IV (see the comments in
# ->new)
# $label - The accompanying label text
# $mode - What kind of value is expected - should be 'int' or 'float'
# $min, $max - The values described above (ignored when $mode is a function reference).
# If $min is 'undef', there is no minimum; if $max is 'undef', there is no
# maximum
# $topAttach - The position of the line in the grid
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $grid, $iv, $ivType, $label, $mode, $min, $max, $topAttach, $check) = @_;
# Local variables
my @comboList;
# Check for improper arguments
if (
! defined $grid || ! defined $iv || ! defined $ivType || ! defined $label
|| ! defined $mode || ! defined $topAttach || defined $check
) {
return $axmud::CLIENT->writeImproper(
$self->_objClass . '->propertiesTab_addEntryWithRange',
@_,
);
}
# Add a checkbutton which turns on/off checking this IV completely
my $checkButton = $self->addCheckButton($grid, $label, undef, TRUE,
1, 4, $topAttach, ($topAttach + 1));
# Add a combo
@comboList = (
'==',
'>',
'>=',
'<',
'<=',
'min-max',
);
my $combo = $self->addComboBox($grid, undef, \@comboList, '',
TRUE, # No 'undef' value used
4, 6, $topAttach, ($topAttach + 1));
# Add two entry boxes, the second only available when the combo box is set to 'min-max',
my $entry = $self->addEntryWithIcon($grid, undef, $mode, $min, $max,
6, 8, $topAttach, ($topAttach + 1));
$self->addLabel($grid, '(Max:)',
8, 10, $topAttach, ($topAttach + 1));
my $entry2 = $self->addEntryWithIcon($grid, undef, $mode, $min, $max,
10, 12, $topAttach, ($topAttach + 1));
lib/Games/Axmud/PrefWin.pm view on Meta::CPAN
. $interfaceObj->name . '\'',
$interfaceObj,
FALSE, # Not temporary
);
}
# Refresh the simple list
$self->interfaces1Tab_refreshList($slWidget, scalar (@columnList / 2), $category);
}
});
my $button2 = $self->addButton($grid,
'Export', 'Export selected interfaces to the interface clipboard', undef,
3, 5, 10, 11);
$button2->signal_connect('clicked' => sub {
my (
$interfaceObj, $comboBox,
@interfaceList,
);
@interfaceList = $self->getSimpleListData($slWidget, 0);
if (@interfaceList) {
# Empty the clipboard
$self->session->pseudoCmd(
'clearclipboard',
$self->pseudoCmdMode,
);
# Export the selected interfaces
foreach my $number (@interfaceList) {
$interfaceObj = $self->session->ivShow('interfaceNumHash', $number);
$self->session->pseudoCmd(
'export' . $interfaceObj->category . ' -i ' . $number,
$self->pseudoCmdMode,
);
}
# Refresh this simple list
$self->interfaces1Tab_refreshList(
$slWidget,
scalar (@columnList / 2),
$category,
);
# Refresh the simple list/combo in the first tab
$comboBox = $self->ivShow('editConfigHash', 'interface_combo');
if ($comboBox->get_active() == 1) {
$self->interfaces1Tab_refreshList(
$self->ivShow('editConfigHash', 'interface_list_all'),
scalar (@columnList / 2),
'all',
);
} else {
# Updating the combobox, refreshes the simple list
$comboBox->set_active(1);
}
}
});
my $button3 = $self->addButton($grid,
'Move up', 'Move the selected active interface up the list', undef,
8, 10, 10, 11);
$button3->signal_connect('clicked' => sub {
my ($number, $iv, $posn, $comboBox);
($number) = $self->getSimpleListData($slWidget, 0);
if (defined $number) {
# Get the interface's current position in the list
$iv = $category . 'OrderList'; # e.g. 'triggerOrderList'
$posn = $self->session->ivFind($iv, $number);
# Can't move the interface if it's already at the top of the list
if (defined $posn && $posn != 0) {
# Move the active interface. The client command understands the position to be
# a number in the range 1..., whereas $posn is an index in the range 0...,
# so to move the interface up one position, we just use $posn
$self->session->pseudoCmd(
'moveactiveinterface ' . $number . ' ' . $posn,
$self->pseudoCmdMode,
);
# Refresh this simple list
$self->interfaces1Tab_refreshList(
$slWidget,
scalar (@columnList / 2),
$category,
);
# The interface should still be highlighted, after being moved up
$slWidget->select($posn - 1);
# Refresh the simple list/combo in the first tab
$comboBox = $self->ivShow('editConfigHash', 'interface_combo');
if ($comboBox->get_active() == 1) {
$self->interfaces1Tab_refreshList(
$self->ivShow('editConfigHash', 'interface_list_all'),
scalar (@columnList / 2),
'all',
);
} else {
# Updating the combobox, refreshes the simple list
$comboBox->set_active(1);
}
}
}
});
my $button4 = $self->addButton($grid,
'Move down', 'Move the selected active interface down the list', undef,
10, 12, 10, 11);
$button4->signal_connect('clicked' => sub {
my ($number, $iv, $posn, $comboBox);
($number) = $self->getSimpleListData($slWidget, 0);
if (defined $number) {
# Get the interface's current position in the list
$iv = $category . 'OrderList'; # e.g. 'triggerOrderList'
$posn = $self->session->ivFind($iv, $number);
# Can't move the interface if it's already at the bottom of the list
if (defined $posn && $posn < ((scalar $self->session->$iv) - 1)) {
# Move the active interface. The client command understands the position to be
# a number in the range 1..., whereas $posn is an index in the range 0...,
# so to move the interface down one position, we must add 2 to $posn
$self->session->pseudoCmd(
'moveactiveinterface ' . $number . ' ' . ($posn + 2),
$self->pseudoCmdMode,
);
# Refresh this simple list
$self->interfaces1Tab_refreshList(
$slWidget,
scalar (@columnList / 2),
$category,
);
# The interface should still be highlighted, after being moved down
$slWidget->select($posn + 1);
# Refresh the simple list/combo in the first tab
$comboBox = $self->ivShow('editConfigHash', 'interface_combo');
if ($comboBox->get_active() == 1) {
$self->interfaces1Tab_refreshList(
$self->ivShow('editConfigHash', 'interface_list_all'),
scalar (@columnList / 2),
'all',
);
} else {
# Updating the combobox, refreshes the simple list
$comboBox->set_active(1);
}
}
}
});
my $button5 = $self->addButton(
$grid,
'Edit ' . $category . ' interface model...',
'Edit the model for this type of interface',
undef,
1, 5, 11, 12);
$button5->signal_connect('clicked' => sub {
my $obj = $axmud::CLIENT->ivShow('interfaceModelHash', $category);
if ($obj) {
# Open up an 'edit' window to edit the object
$self->createFreeWin(
'Games::Axmud::EditWin::InterfaceModel',
$self,
$self->session,
'Edit ' . $category . ' interface model',
$obj,
FALSE, # Not temporary
);
}
});
my $button6 = $self->addButton($grid,
'Update list', 'Update the list of interfaces', undef,
10, 12, 11, 12);
$button6->signal_connect('clicked' => sub {
# Refresh the simple list
$self->interfaces1Tab_refreshList($slWidget, scalar (@columnList / 2), $category);
});
# Tab complete
return 1;
}
sub interfaces2Tab_buttonToggled {
# Callback from GA::Generic::EditWin->addSimpleList
#
# Expected arguments
# $slWidget - The GA::Obj::SimpleList
# $model - The Gtk3::ListStore
# $iter - The Gtk3::TreeIter of the line clicked
# @data - Data for all the cells on that line
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $slWidget, $model, $iter, @dataList) = @_;
# Local variables
my ($interfaceName, $flag, $interfaceObj, $comboBox);
lib/Games/Axmud/PrefWin.pm view on Meta::CPAN
return $axmud::CLIENT->writeImproper(
$self->_objClass . '->interfaces2Tab_buttonToggled',
@_,
);
}
# Update IVs
$interfaceName = $dataList[1];
$flag = $dataList[4];
$interfaceObj = $self->session->ivShow('interfaceHash', $interfaceName);
if (! $interfaceObj) {
# Failsafe
return undef;
}
if ($flag) {
if (! $interfaceObj->enabledFlag) {
$self->session->pseudoCmd(
'enableactiveinterface ' . $interfaceName,
$self->pseudoCmdMode,
);
} else {
# Refresh the simple list for this tab
$self->interfaces1Tab_refreshList($slWidget, scalar @dataList, 'all');
}
} elsif (! $flag) {
if ($interfaceObj->enabledFlag) {
$self->session->pseudoCmd(
'disableactiveinterface ' . $interfaceName,
$self->pseudoCmdMode,
);
} else {
# Refresh the simple list for this tab
$self->interfaces1Tab_refreshList($slWidget, scalar @dataList, 'all');
}
}
# Refresh the simple list/combo for the first tab
$comboBox = $self->ivShow('editConfigHash', 'interface_combo');
if ($comboBox->get_active() == 1) {
$self->interfaces1Tab_refreshList(
$self->ivShow('editConfigHash', 'interface_list_all'),
scalar @dataList,
'all',
);
} else {
# Updating the combobox, refreshes the simple list
$comboBox->set_active(1);
}
return 1;
}
sub tasksTab {
# Tasks tab
#
# Expected arguments
# (none besides $self)
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $check) = @_;
# Local variables
my @columnList;
# Check for improper arguments
if (defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->tasksTab', @_);
}
# Tab setup
my $grid = $self->addTab(
$self->notebook,
'_Tasks',
['Current tasks'],
);
# Current tasks
$self->addLabel($grid, '<b>Current tasks</b>',
0, 12, 0, 1);
$self->addLabel($grid,
'<i>List of tasks in this session\'s current tasklist (showing task window status)</i>',
1, 12, 1, 2);
# Add a simple list
@columnList = (
'Task', 'text',
'Allowed', 'bool',
'Required', 'bool',
'Open on start', 'bool',
'Open now', 'bool',
'Preferred locations', 'text',
'Use winmap', 'text',
);
my $slWidget = $self->addSimpleList($grid, undef, \@columnList,
1, 12, 2, 10);
# Refresh the list
$self->tasksTab_refreshList($slWidget, scalar (@columnList / 2));
# Add buttons to open/close windows
( run in 1.139 second using v1.01-cache-2.11-cpan-8dfa8b56332 )