Games-Axmud
view release on metacpan or search on metacpan
lib/Games/Axmud/PrefWin.pm view on Meta::CPAN
'Category', 'text',
'Indep', 'bool',
'Enabled', 'bool_editable',
'Associated profile', 'text',
'Cooldown expires (seconds)', 'text',
);
my $slWidget = $self->addSimpleList($grid, undef, \@columnList,
1, 12, 2, 10,
-1, -1,
$self->getMethodRef('interfaces1Tab_buttonToggled'),
);
# Unusual step - need to save the simple list, because $self->interfaces1Tab_refreshList
# updates multiple simple lists together. Because this is a 'pref' window, the lists are
# stored in $self->editConfigHash
$self->ivAdd('editConfigHash', 'interface_list_all', $slWidget);
# Initialise the list
$listType = 'all';
$self->interfaces1Tab_refreshList($slWidget, scalar (@columnList / 2), $listType);
# Add buttons and combos
my $button = $self->addButton($grid,
'Edit...', 'Edit the selected active interface', undef,
1, 3, 10, 11);
$button->signal_connect('clicked' => sub {
my ($number, $interfaceObj);
($number) = $self->getSimpleListData($slWidget, 0);
if (defined $number) {
$interfaceObj = $self->session->ivShow('interfaceNumHash', $number);
if ($interfaceObj) {
# Open up an 'edit' window to edit the object
$self->createFreeWin(
'Games::Axmud::EditWin::Interface::Active',
$self,
$self->session,
'Edit active ' . $interfaceObj->category . ' interface \''
. $interfaceObj->name . '\'',
$interfaceObj,
FALSE, # Not temporary
);
}
# Refresh this simple list
$self->interfaces1Tab_refreshList($slWidget, scalar (@columnList / 2), $listType);
# Refresh the simple list for the corresponding tab
$self->interfaces1Tab_refreshList(
$self->ivShow('editConfigHash', 'interface_list_' . $interfaceObj->category),
scalar (@columnList / 2),
$interfaceObj->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,
@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), $listType);
# Refresh the simple list for the corresponding tab
$self->interfaces1Tab_refreshList(
$self->ivShow('editConfigHash', 'interface_list_' . $interfaceObj->category),
scalar (@columnList / 2),
$interfaceObj->category,
);
}
});
# Prepare a list of combo items. The keys are the combo items themselves, the corresponding
# values are arguments to send to $self->interfaces1Tab_refreshList
@list = (
'Numerically' => 'all',
'Alphabetically' => 'alpha',
'Dependent only' => 'dependent',
'Independent only' => 'independent',
'Triggers only' => 'trigger',
'Aliases only' => 'alias',
'Macros only' => 'macro',
'Timers only' => 'timer',
'Hooks only' => 'hook',
);
do {
my $key = shift @list;
my $value = shift @list;
push (@comboList, $key);
$comboHash{$key} = $value;
} until (! @list);
# Add the combo
$title = 'View interfaces:';
my $comboBox = $self->addComboBox($grid, undef, \@comboList, $title,
FALSE, # Title, so no 'undef' value seen
9, 12, 10, 11);
$comboBox->signal_connect('changed' => sub {
my $text = $comboBox->get_active_text();
if ($text ne $title) {
lib/Games/Axmud/PrefWin.pm view on Meta::CPAN
. ' consulted</i>',
1, 12, 1, 2);
# Add a simple list
@columnList = (
'#', 'int',
'Name', 'text',
'Category', 'text',
'Indep', 'bool',
'Enabled', 'bool_editable',
'Associated profile', 'text',
'Cooldown expires (seconds)', 'text',
);
my $slWidget = $self->addSimpleList($grid, undef, \@columnList,
1, 12, 2, 10,
-1, -1,
$self->getMethodRef('interfaces2Tab_buttonToggled'),
);
# Unusual step - need to save the simple list, because $self->interfaces1Tab_refreshList
# updates multiple simple lists together. Because this is a 'pref' window, the lists are
# stored in $self->editConfigHash
$self->ivAdd('editConfigHash', 'interface_list_' . $category, $slWidget);
# Initialise the list
$self->interfaces1Tab_refreshList($slWidget, scalar (@columnList / 2), $category);
# Add buttons and combos
my $button = $self->addButton($grid,
'Edit...', 'Edit the selected active interface', undef,
1, 3, 10, 11);
$button->signal_connect('clicked' => sub {
my ($number, $interfaceObj);
($number) = $self->getSimpleListData($slWidget, 0);
if (defined $number) {
$interfaceObj = $self->session->ivShow('interfaceNumHash', $number);
if ($interfaceObj) {
# Open up an 'edit' window to edit the object
$self->createFreeWin(
'Games::Axmud::EditWin::Interface::Active',
$self,
$self->session,
'Edit active ' . $interfaceObj->category . ' interface \''
. $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,
( run in 1.086 second using v1.01-cache-2.11-cpan-84e82930d8c )