Games-Axmud
view release on metacpan or search on metacpan
lib/Games/Axmud/EditWin.pm view on Meta::CPAN
# 1 otherwise
my ($self, $check) = @_;
# Check for improper arguments
if (defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->expandNotebook', @_);
}
$self->contentsTab();
return 1;
}
sub saveChanges {
# Called by $self->buttonOK and $self->buttonSave (usually for 'edit' windows only, not
# 'pref' windows)
# Saves any changes made to data stored by the edit object
#
# 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 . '->saveChanges', @_);
}
if ($self->editHash) {
# Store the changes the user has made
foreach my $key ($self->ivKeys('editHash')) {
$self->editObj->{$key} = $self->ivShow('editHash', $key);
}
# The changes can now be cleared
$self->ivEmpty('editHash');
# Mark the object's corresponding file object as needing to be saved, if it exists
if ($self->editObj->_parentFile) {
$self->editObj->doModify('saveChanges');
}
# Update the current session's data viewer window, if it is open
if ($self->session->viewerWin) {
$self->session->viewerWin->updateNotebook();
}
# Redraw menu bars/toolbars in all automapper windows using this world model
$self->session->worldModelObj->updateMapMenuToolbars();
}
return 1;
}
# Notebook tabs
sub roomTab {
# Room tab
#
# 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 . '->roomTab', @_);
}
# Tab setup
# Create a notebook within the main one, so that we have two rows of tabs
my $innerNotebook = $self->addInnerNotebookTabs($self->notebook, '_Room');
# Add tabs to the inner notebook (mostly inherited from GA::EditWin::ModelObj::Room, so we
# pass an extra argument to show the tab which page number to display)
$self->ownRoom1Tab($innerNotebook); # (not inherited)
$self->room2Tab($innerNotebook, 'Page _2'); # ->roomFlagHash
$self->room4Tab($innerNotebook, 'Page _3'); # ->descripHash
$self->ownRoom2Tab($innerNotebook); # (not inherited)
$self->room7Tab($innerNotebook, 'Page _5'); # ->exclusiveFlag, ->exclusiveHash
return 1;
}
sub ownRoom1Tab {
# OwnRoom1Tab 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 (@guildList, @comboList);
# Check for improper arguments
if (! defined $innerNotebook || defined $check) {
lib/Games/Axmud/EditWin.pm view on Meta::CPAN
sub stripsTab_resetInitWidgets {
# Called by $self->stripsTab
# Resets and desensitises the initialisation widgets when a strip object in the simple list
# is unselected, or when a strip object with an empty initialisation hash is selected
#
# Expected arguments
# $noStripString, $noneString
# - Text to use in the comboboxes
# $flag - Flag set to TRUE if a strip object is selected in the simple list,
# FALSE if not
# $entry, $comboBox3, $button9, $button10, $button11, $button12, $button13
# - List of widgets to desensitise
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my (
$self, $noStripString, $noneString, $flag, $entry, $comboBox3, $button9, $button10,
$button11, $button12, $button13, $check,
) = @_;
# Check for improper arguments
if (
! defined $noStripString || ! defined $noneString || ! defined $flag || ! defined $entry
|| ! defined $comboBox3 || ! defined $button9 || ! defined $button10
|| ! defined $button11 || ! defined $button12 || ! defined $button13
|| defined $check
) {
return $axmud::CLIENT->writeImproper(
$self->_objClass . '->stripsTab_resetInitWidgets',
@_,
);
}
# Reset widgets. Using some text in the combo, rather than nothing, reduces widget re-sizing
$entry->set_text('');
$self->desensitiseWidgets(
$entry, $comboBox3, $button9, $button10, $button11, $button12, $button13,
);
# (Reset combo last, otherwise the ->signal_connect for the combo desensitises widgets,
# which are re-sensitised by this ->signal_connect)
if (! $flag) {
$self->resetComboBox($comboBox3, $noStripString);
} else {
$self->resetComboBox($comboBox3, $noneString);
}
return 1;
}
sub stripsTab_checkPackage {
# Called by $self->stripsTab_updateCombo2
# Checks whether a strip object package name exists in the ->stripInitList IV, or not
#
# Expected arguments
# $package - The package name to check, e.g. 'Games::Axmud::Strip::MenuBar'
#
# Return values
# 'undef' on improper arguments or if the package name is not in ->stripInitList
# 1 if the package name is found in ->stripInitList
my ($self, $package, $check) = @_;
# Local variables
my @ivList;
# Check for improper arguments
if (! defined $package || defined $check) {
return $axmud::CLIENT->writeImproper(
$self->_objClass . '->stripsTab_updateStripList',
@_,
);
}
@ivList = $self->getEditHash_listIV('stripInitList');
if (@ivList) {
do {
my ($thisPackage, $hashRef);
$thisPackage = shift @ivList;
$hashRef = shift @ivList;
if ($thisPackage eq $package) {
return 1;
}
} until (! @ivList);
}
return undef;
}
sub winzonesTab {
# Winzones tab
#
# 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 . '->winzonesTab', @_);
}
# Tab setup
lib/Games/Axmud/EditWin.pm view on Meta::CPAN
# Local variables
my (
$blockWidth, $blockHeight, $roomWidth, $roomHeight, $failFlag, $newValue, $regionmapObj,
@ivList,
);
# Check for improper arguments
if (defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->saveChanges', @_);
}
if ($self->editHash) {
# If new gridblock/room sizes have been specified, must check that the room is smaller
# than a gridblock
if (
$self->ivExists('editHash', 'defaultBlockWidthPixels')
|| $self->ivExists('editHash', 'defaultRoomWidthPixels')
) {
$blockWidth = $self->getEditHash_scalarIV('defaultBlockWidthPixels');
$roomWidth = $self->getEditHash_scalarIV('defaultRoomWidthPixels');
if ($roomWidth >= $blockWidth) {
$failFlag = TRUE;
}
}
if (! $failFlag) {
if (
$self->ivExists('editHash', 'defaultBlockHeightPixels')
|| $self->ivExists('editHash', 'defaultRoomHeightPixels')
) {
$blockHeight = $self->getEditHash_scalarIV('defaultBlockHeightPixels');
$roomHeight = $self->getEditHash_scalarIV('defaultRoomHeightPixels');
if ($roomHeight >= $blockHeight) {
$failFlag = TRUE;
}
}
}
if ($failFlag) {
# Ignore all changes to the room/block width/height
$self->ivDelete('editHash', 'defaultBlockWidthPixels');
$self->ivDelete('editHash', 'defaultRoomWidthPixels');
$self->ivDelete('editHash', 'defaultBlockHeightPixels');
$self->ivDelete('editHash', 'defaultRoomHeightPixels');
}
# Some widgets (especially those in $self->settingsXTabs) require a call to the world
# model object, when they are changed. Deal with them each in turn
# (Automapper window components)
@ivList = (
'showMenuBarFlag', 'showToolbarFlag', 'showTreeViewFlag', 'showCanvasFlag',
);
foreach my $iv (@ivList) {
if ($self->ivExists('editHash', $iv)) {
if ($self->ivShow('editHash', $iv) ne $self->editObj->$iv) {
$self->editObj->toggleWinComponents(
$iv,
$self->ivShow('editHash', $iv),
);
}
$self->ivDelete('editHash', $iv);
}
}
# (GA::Obj::WorldModel flags)
@ivList = (
# ->settings1Tab
'drawOrnamentsFlag', 'draw_ornaments', 'icon_draw_ornaments',
'obscuredExitFlag', 'obscured_exits', 'icon_obscured_exits',
'obscuredExitRedrawFlag', 'auto_redraw_obscured', 'icon_auto_redraw_obscured',
'trackPosnFlag', 'track_current_room', 'icon_track_current_room',
'preDrawAllowFlag', 'allow_pre_draw', undef,
# ->settings2Tab
# (none)
# ->settings3Tab
'matchTitleFlag', 'match_title', undef,
'matchDescripFlag', 'match_descrip', undef,
'matchExitFlag', 'match_exit', undef,
'analyseDescripFlag', 'analyse_descrip', undef,
'matchSourceFlag', 'match_source', undef,
'matchVNumFlag', 'match_vnum', undef,
'updateTitleFlag', 'update_title', undef,
'updateDescripFlag', 'update_descrip', undef,
'updateExitFlag', 'update_exit', undef,
'updateSourceFlag', 'update_source', undef,
'updateVNumFlag', 'update_vnum', undef,
'updateRoomCmdFlag', 'update_room_cmd', undef,
'updateOrnamentFlag', 'update_ornament', undef,
# ->settings4Tab
# 'autoCompareAllFlag', 'auto_compare_region', undef, # Set below
'autoRescueFlag', 'auto_rescue', undef,
'autoRescueFirstFlag', 'auto_rescue_first', undef,
'autoRescuePromptFlag', 'auto_rescue_prompt', undef,
'autoRescueNoMoveFlag', 'auto_rescue_no_move', undef,
'autoRescueVisitsFlag', 'auto_rescue_visits', undef,
'autoRescueForceFlag', 'auto_rescue_foce', undef,
# ->settings5Tab
'allowModelScriptFlag', 'allow_model_scripts', undef,
'allowRoomScriptFlag', 'allow_room_scripts', undef,
# ->settings6Tab
# (none)
# ->settings7Tab
'assistedMovesFlag', 'allow_assisted_moves', undef,
'assistedBreakFlag', 'break_before_move', undef,
'assistedPickFlag', 'pick_before_move', undef,
'assistedUnlockFlag', 'unlock_before_move', undef,
lib/Games/Axmud/EditWin.pm view on Meta::CPAN
}
# Tab setup
# Create a notebook within the main one, so that we have two rows of tabs
my $innerNotebook = $self->addInnerNotebookTabs($self->notebook, 'S_ettings');
# Add tabs to the inner notebook
$self->settings1Tab($innerNotebook);
$self->settings2Tab($innerNotebook);
$self->settings3Tab($innerNotebook);
$self->settings4Tab($innerNotebook);
$self->settings5Tab($innerNotebook);
$self->settings6Tab($innerNotebook);
$self->settings7Tab($innerNotebook);
$self->settings8Tab($innerNotebook);
return 1;
}
sub settings1Tab {
# Settings1 tab
#
# Expected arguments
# $innerNotebook - The Gtk3::Notebook object inside $self->notebook
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $innerNotebook, $check) = @_;
# Check for improper arguments
if (! defined $innerNotebook || defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->settings1Tab', @_);
}
# Tab setup
my $grid = $self->addTab(
$innerNotebook,
'Page _1',
[
'Window components',
'Label alignment',
'Painter',
'Show \'Working...\' dialogue',
'Map font',
'Tracking',
'Synchronise grid coordinates',
],
);
# Settings (1/8)
$self->addLabel($grid, '<b>Settings (1/8)</b>',
0, 12, 0, 1);
# Left column
$self->addLabel($grid, '<u>Window components</u>',
1, 6, 1, 2);
$self->addCheckButton($grid, 'Show menu bar', 'showMenuBarFlag', TRUE,
1, 6, 2, 3);
$self->addCheckButton($grid, 'Show toolbar', 'showToolbarFlag', TRUE,
1, 6, 3, 4);
$self->addCheckButton($grid, 'Show region list', 'showTreeViewFlag', TRUE,
1, 6, 4, 5);
$self->addCheckButton($grid, 'Show map', 'showCanvasFlag', TRUE,
1, 6, 5, 6);
$self->addLabel($grid, '<u>Label alignment</u>',
1, 6, 6, 7);
$self->addCheckButton($grid, 'Labels alignored horizontally', 'mapLabelAlignXFlag', FALSE,
1, 6, 7, 8);
$self->addCheckButton($grid, 'Labels aligned vertically', 'mapLabelAlignYFlag', FALSE,
1, 6, 8, 9);
$self->addCheckButton(
$grid,
'Window uses multi-line input',
'mapLabelTextViewFlag',
FALSE,
1, 6, 9, 10);
$self->addLabel($grid, '<u>Painter</u>',
1, 6, 10, 11);
$self->addCheckButton($grid, 'Paint existing rooms', 'paintAllRoomsFlag', FALSE,
1, 6, 11, 12);
$self->addCheckButton($grid, 'Quick-paint without resetting', 'quickPaintMultiFlag', FALSE,
1, 6, 12, 13);
# Right column
$self->addLabel($grid, '<u>Show \'Working...\' dialogue</u>',
7, 12, 1, 2);
$self->addLabel($grid, 'Draw objects (100+)',
7, 9, 2, 3);
$self->addEntryWithIcon($grid, 'drawPauseNum', 'int', 100, undef,
9, 12, 2, 3,
8, 8);
$self->addLabel($grid, 'Calculate region paths (10+)',
7, 9, 3, 4);
$self->addEntryWithIcon($grid, 'recalculatePauseNum', 'int', 10, undef,
9, 12, 3, 4,
8, 8);
$self->addLabel($grid, '<u>Map font</u>',
7, 12, 4, 5);
$self->addLabel($grid, 'Font',
7, 9, 5, 6);
my $entry4 = $self->addEntry($grid, undef, FALSE,
9, 10, 5, 6);
$entry4->set_text($self->editObj->mapFont);
my $button = $self->addButton($grid, 'Modify', 'Change the automapper font', undef,
10, 12, 5, 6);
$button->signal_connect('clicked' => sub {
my $newFont = $self->showFontSelectionDialogue(
'Automapper window font',
$self->getEditHash_scalarIV('mapFont'),
);
if (defined $newFont) {
( run in 0.484 second using v1.01-cache-2.11-cpan-39bf76dae61 )