blib/lib/Games/Axmud/WizWin.pm untested

filter: Statementstmt 0.0% 0 / 1814 Branchbran 0.0% 0 / 618 Conditioncond 0.0% 0 / 363 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 96 Podpod 0.0% 0 / 88 totaltotal 0.0% 0 / 2979 CC 310 SCAR 58.8
CC
310
Cov
0%
analyseComponent
1482.0
saveChanges
992.0
analysisPage
812.0
CRAP 358.4
1 # Copyright (C) 2011-2022 A S Lewis
2 #
3 # This program is free software: you can redistribute it and/or modify it under the terms of the GNU
4 # General Public License as published by the Free Software Foundation, either version 3 of the
5 # License, or (at your option) any later version.
6 #
7 # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
8 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9 # General Public License for more details.
10 #
11 # You should have received a copy of the GNU General Public License along with this program. If not,
12 # see <http://www.gnu.org/licenses/>.
13 #
14 #
15 # Games::Axmud::WizWin::XXX
16 # Handles all 'wiz' windows, inheriting from GA::Generic::WizWin
17  
18 { package Games::Axmud::WizWin::Setup;
19  
20 use strict;
21 use warnings;
22 use diagnostics;
23  
24 use Glib qw(TRUE FALSE);
25  
26 our @ISA = qw(
27 Games::Axmud::Generic::WizWin Games::Axmud::Generic::FreeWin Games::Axmud::Generic::Win
28 Games::Axmud
29 );
30  
31 ##################
32 # Constructors
33  
34 sub new {
35  
36 # Called by GA::Generic::Win->createFreeWin
37 # Creates a new instance of the Setup 'wiz' window, created by GA::Client->start when Axmud
38 # first runs, to let the user specify some initialisation settings
39 #
40 # Expected arguments
41 # $number - Unique number for this window object
42 # $workspaceObj - The GA::Obj::Workspace handling the workspace in which this window
43 # should be created
44 # $owner - The owner; a 'grid' window object (but not an 'external' window) or a
45 # 'free' window object. When this window opens/closes, the owner is
46 # informed via calls to its ->add_childFreeWin / ->del_childFreeWin
47 # functions
48 #
49 # Optional arguments
50 # $session - The GA::Session from which this function was called. 'undef' if the
51 # calling function didn't specify a session and $owner's ->session IV
52 # is also 'undef'
53 # $title - A string to use as the window title. If 'undef', a generic title is
54 # used
55 # $editObj - Ignored if set
56 # $tempFlag - Ignored if set
57 # %configHash - Hash containing any number of key-value pairs needed for this
58 # particular 'wiz' window; for example, for example,
59 # GA::PrefWin::TaskStart uses it to specify a task name and type.
60 # Set to an empty hash if not required
61 # - This type of window object recognises these initialisation settings:
62 #
63 # ...
64 #
65 # Return values
66 # 'undef' on improper arguments or if the window can't be created
67 # Blessed reference to the newly-created object on success
68  
69 my (
70 $class, $number, $workspaceObj, $owner, $session, $title, $editObj, $tempFlag,
71 %configHash,
72 ) = @_;
73  
74 # Check for improper arguments
75 if (! defined $class || ! defined $number || ! defined $workspaceObj || ! defined $owner) {
76  
77 return $axmud::CLIENT->writeImproper($class . '->new', @_);
78 }
79  
80 # This window must only be opened when GA::Client->start wants to open it
81 if (! $axmud::CLIENT->showSetupWizWinFlag || $axmud::CLIENT->sessionCount) {
82  
83 return undef;
84 }
85  
86 # Set the values to use for some standard window IVs
87 if (! $title) {
88  
89 $title = $axmud::SCRIPT . ' setup wizard';
90 }
91  
92 # Setup
93 my $self = {
94 _objName => 'wiz_win_' . $number,
95 _objClass => $class,
96 _parentFile => undef, # No parent file object
97 _parentWorld => undef, # No parent file object
98 _privFlag => TRUE, # All IVs are private
99  
100 # Standard window object IVs
101 # --------------------------
102  
103 # Unique number for this window object
104 number => $number,
105 # The window category - 'grid' or 'free'
106 winCategory => 'free',
107 # The window type, any of the keys in GA::Client->constFreeWinTypeHash
108 winType => 'wiz',
109 # A name for the window (for 'config' windows, the same as the window type)
110 winName => 'setup_wiz',
111 # The GA::Obj::Workspace object for the workspace in which this window is created
112 workspaceObj => $workspaceObj,
113 # The owner; a 'grid' window object (but not an 'external' window) or a 'free' window
114 # object. When this window opens/closes, the owner is informed via calls to its
115 # ->add_childFreeWin / ->del_childFreeWin functions
116 owner => $owner,
117 # The GA::Session from which this function was called. 'undef' if the calling function
118 # didn't specify a session and $owner's ->session IV is also 'undef'
119 session => $session,
120 # When GA::Session->pseudoCmd is called to execute a client command, the mode in which
121 # it should be called (usually 'win_error' or 'win_only', which causes errors to be
122 # displayed in a 'dialogue' window)
123 pseudoCmdMode => 'win_error',
124  
125 # The window widget. For most window objects, the Gtk3::Window. For pseudo-windows, the
126 # parent 'main' window's Gtk3::Window
127 # The code should use this IV when it wants to do something to the window itself
128 # (minimise it, make it active, etc)
129 winWidget => undef,
130 # The window container. For most window objects, the Gtk3::Window. For pseudo-windows,
131 # the parent GA::Table::PseudoWin table object
132 # The code should use this IV when it wants to add, modify or remove widgets inside the
133 # window itself
134 winBox => undef,
135 # Flag set to TRUE if the window actually exists (after a call to $self->winEnable),
136 # FALSE if not
137 enabledFlag => FALSE,
138 # Flag set to TRUE if the Gtk3 window itself is visible (after a call to
139 # $self->setVisible), FALSE if it is not visible (after a call to $self->setInvisible)
140 visibleFlag => TRUE,
141 # Registry hash of 'free' windows (excluding 'dialogue' windows) for which this window
142 # is the parent, a subset of GA::Obj::Desktop->freeWinHash. Hash in the form
143 # $childFreeWinHash{unique_number} = blessed_reference_to_window_object
144 childFreeWinHash => {},
145 # When a child 'free' window (excluding 'dialogue' windows) is destroyed, this parent
146 # window is informed via a call to $self->del_childFreeWin
147 # When the child is destroyed, this window might want to call some of its own functions
148 # to update various widgets and/or IVs, in which case this window adds an entry to
149 # this hash; a hash in the form
150 # $childDestroyHash{unique_number} = list_reference
151 # ...where 'unique_number' is the child window's ->number, and 'list_reference' is a
152 # reference to a list in groups of 2, in the form
153 # (sub_name, argument_list_ref, sub_name, argument_list_ref...)
154 childDestroyHash => {},
155  
156 # The container widget into which all other widgets are packed (usually a Gtk3::VBox or
157 # Gtk3::HBox, but any container widget can be used; takes up the whole window client
158 # area)
159 packingBox => undef, # Gtk3::VBox
160  
161 # Standard IVs for 'free' windows
162  
163 # The window's default size, in pixels
164 widthPixels => $axmud::CLIENT->customFreeWinWidth,
165 heightPixels => $axmud::CLIENT->customFreeWinHeight,
166 # Default border/item spacing sizes used in the window, in pixels
167 borderPixels => $axmud::CLIENT->constFreeBorderPixels,
168 spacingPixels => $axmud::CLIENT->constFreeSpacingPixels,
169  
170 # A string to use as the window title. If 'undef', a generic title is used
171 title => $title,
172 # Hash containing any number of key-value pairs needed for this particular 'config'
173 # window; for example, for example, GA::PrefWin::TaskStart uses it to specify a task
174 # name and type. Set to an empty hash if not required
175 configHash => {%configHash},
176  
177 # Standard IVs for 'wiz' windows
178  
179 # Widgets
180  
181 # A vertical pane, with the main area above, and a button strip below
182 scroller => undef, # Gtk3::ScrolledWindow
183 hAdjustment => undef, # Gtk3::Adjustment
184 vAdjustment => undef, # Gtk3::Adjustment
185 grid => undef, # Gtk3::Grid
186 hBox => undef, # Gtk3::HBox
187 nextButton => undef, # Gtk3::Button
188 previousButton => undef, # Gtk3::Button
189 cancelButton => undef, # Gtk3::Button
190  
191 # Three flags that can be set by any page, to prevent one of three buttons from being
192 # made sensitive (temporarily)
193 disableNextButtonFlag => FALSE,
194 disablePreviousButtonFlag => FALSE,
195 disableCancelButtonFlag => FALSE,
196  
197 # The names of pages, in order of appearance
198 pageList => [
199 'intro',
200 'mainWin',
201 'zonemap',
202 'world',
203 'task',
204 'sigil',
205 'last',
206 ],
207 # The number of the current page (first page is 0)
208 currentPage => 0,
209  
210 # Two hashes for using the 'Next' / 'Previous' buttons to skip around the pages, rather
211 # than going to the actual next or previous page (as normal)
212 # The current page should add an entry to the hash, if necessary; the entry is removed
213 # by ->buttonPrevious or ->buttonNext as soon as either button is clicked
214 # Hashes in the form
215 # $hash{current_page_number} = page_number_if_button_clicked
216 # NB The first page's number is 0, so the fourth page will be page 3, not page 4
217 specialNextButtonHash => {},
218 specialPreviousButtonHash => {},
219  
220 # IVs for this type of 'wiz' window
221  
222 # Corresponds to same IV in GA::Client
223 shareMainWinFlag => TRUE,
224 # Default zonemap for the first workspace, stored in GA::Client->initWorkspaceHash -
225 # 'basic', 'extended', 'widescreen', 'horizontal2', 'vertical2' or, representing
226 # GA::Client->activateGridFlag = TRUE, the value 'none'
227 zonemap => 'basic',
228 # Flag set to TRUE if $self->zonemapPage decides to switch the zonemap to 'widescreen',
229 # so that this happens only once (i.e. if the Previous button is clicked, we don't
230 # want to switch the zonemap back to widescreen a second time)
231 widescreenFlag => FALSE,
232  
233 # The GA::Obj::SimpleList containing a list of pre-configured worlds
234 slWidget => undef,
235  
236 # Pre-configured worlds, in the order they're
237 # Initial tasks
238 taskInitHash => {
239 'status' => TRUE,
240 'locator' => TRUE,
241 'attack' => FALSE,
242 'compass' => FALSE,
243 'channels' => FALSE,
244 'divert' => FALSE,
245 'inventory' => FALSE,
246 'launch' => FALSE,
247 'notepad' => FALSE,
248 },
249 # Initial task settings
250 taskSettingHash => {
251 'status_win' => TRUE,
252 'status_gauge' => TRUE,
253 'locator_win' => TRUE,
254 },
255 # Instruction sigils
256 sigilHash => {
257 'echo' => FALSE,
258 'perl' => FALSE,
259 'script' => FALSE,
260 'multi' => FALSE,
261 'speed' => FALSE,
262 'bypass' => FALSE,
263 },
264 };
265  
266 # Bless the object into existence
267 bless $self, $class;
268  
269 return $self;
270 }
271  
272 ##################
273 # Methods
274  
275 # Standard window object functions
276  
277 sub winSetup {
278  
279 # Called by GA::Generic::Win->createFreeWin, after the call to $self->new
280 # Creates the Gtk3::Window itself
281 #
282 # Expected arguments
283 # (none besides $self)
284 #
285 # Return values
286 # 'undef' on improper arguments or if the window can't be opened
287 # 1 on success
288  
289 my ($self, $check) = @_;
290  
291 # Local variables
292 my ($hAdjust, $vAdjust, $ratioX, $ratioY, $newX, $newY);
293  
294 # Check for improper arguments
295 if (defined $check) {
296  
297 return $axmud::CLIENT->writeImproper($self->_objClass . '->winSetup', @_);
298 }
299  
300 # Most of the code is in the generic function
301 if (! $self->Games::Axmud::Generic::FreeWin::winSetup()) {
302  
303 return undef;
304 }
305  
306 # Some desktop managers use a bigger font than the author's desktop manager; as a result,
307 # 'free' windows like this one will be too small for comfort
308 # This window is (usually) only seen the first time Axmud is run. If the user's destkop
309 # manager font is too big, this window's Gtk3::ScrolledWindow will contain scrollbars
310 # If the scrollbars are present, we can increase the size of default 'free' windows to
311 # compensate, which removes the scrollbars in this window and (hopefully) most other
312 # 'free' windows, too
313 # Typically, this process makes the default 'free' window size slightly larger than it
314 # strictly needs to be, but that's still better than a Connections window with none of
315 # the 'Connect' buttons visible
316  
317 # Drawing the window early makes the scrollbars testable (->winShowAll() is normally first
318 # called by $self->winEnable)
319 $self->winShowAll($self->_objClass . '->winSetup');
320  
321 # Detect the presence of any scrollbars and decide by which ratio the window's size should
322 # be increased
323 $hAdjust = $self->scroller->get_hadjustment();
324 if ($hAdjust->get_upper() != $hAdjust->get_page_size()) {
325 $ratioX = $hAdjust->get_upper() / $hAdjust->get_page_size();
326 } else {
327 $ratioX = 1;
328 }
329  
330 $vAdjust = $self->scroller->get_vadjustment();
331 if ($vAdjust->get_upper() != $vAdjust->get_page_size()) {
332 $ratioY = $vAdjust->get_upper() / $vAdjust->get_page_size();
333 } else {
334 $ratioY = 1;
335 }
336  
337 if ($ratioX != 1 || $ratioY != 1) {
338  
339 # One (or both) scrollbars detected
340 $newX = int($self->widthPixels * $ratioX);
341 $newY = int($self->heightPixels * $ratioY);
342  
343 # Adjust the size of this window to compensate
344 $self->winWidget->resize($newX, $newY);
345 # Adjust the default size of future 'free' windows to compensate
346 $axmud::CLIENT->set_customFreeWinSize($newX, $newY);
347 }
348  
349 return 1;
350 }
351  
352 # sub winEnable {} # Inherited from GA::Generic::WizWin
353  
354 # sub winDesengage {} # Inherited from GA::Generic::FreeWin
355  
356 sub winDestroy {
357  
358 # Can be called by anything
359 # Updates IVs
360 #
361 # Expected arguments
362 # (none besides $self)
363 #
364 # Return values
365 # 'undef' on improper arguments, if the window can't be destroyed or if it has already
366 # been destroyed
367 # 1 on success
368  
369 my ($self, $check) = @_;
370  
371 # Local variables
372 my $result;
373  
374 # Check for improper arguments
375 if (defined $check) {
376  
377 return $axmud::CLIENT->writeImproper($self->_objClass . '->winDestroy', @_);
378 }
379  
380 # Most of the code is in the generic function
381 $result = $self->Games::Axmud::Generic::WizWin::winDestroy();
382 if ($result) {
383  
384 # Window closed. The Connections window must now be opened
385 $axmud::CLIENT->mainWin->quickFreeWin('Games::Axmud::OtherWin::Connect');
386 }
387  
388 return $result;
389 }
390  
391 # sub winShowAll {} # Inherited from GA::Generic::Win
392  
393 # sub drawWidgets {} # Inherited from GA::Generic::WizWin
394  
395 # sub redrawWidgets {} # Inherited from GA::Generic::Win
396  
397 # ->signal_connects
398  
399 # Other functions
400  
401 sub saveChanges {
402  
403 # Called by $self->buttonNext when the user clicks the 'Finish' button
404 # Saves changes to the current world profile and/or current dictionary, before closing the
405 # window
406 #
407 # Expected arguments
408 # (none besides $self)
409 #
410 # Return values
411 # 'undef' on improper arguments
412 # 1 otherwise
413  
414 my ($self, $check) = @_;
415  
416 # Local variables
417 my (
418 $zonemapObj, $slWidget, $initStatusObj, $initLocatorObj,
419 @taskList,
420 %checkHash,
421 );
422  
423 # Check for improper arguments
424 if (defined $check) {
425  
426 return $axmud::CLIENT->writeImproper($self->_objClass . '->saveChanges', @_);
427 }
428  
429 # Update Client IVs
430 if (! $self->shareMainWinFlag) {
431 $axmud::CLIENT->set_shareMainWinFlag(FALSE);
432 } else {
433 $axmud::CLIENT->set_shareMainWinFlag(TRUE);
434 }
435  
436 if ($self->zonemap eq 'none') {
437  
438 $axmud::CLIENT->set_activateGridFlag(TRUE);
439 $axmud::CLIENT->desktopObj->defaultWorkspaceObj->disableWorkspaceGrids();
440 $axmud::CLIENT->desktopObj->defaultWorkspaceObj->reset_defaultZonemap();
441  
442 } else {
443  
444 $axmud::CLIENT->ivAdd('initWorkspaceHash', 0, $self->zonemap);
445 $zonemapObj = $axmud::CLIENT->ivShow('zonemapHash', $self->zonemap);
446 if ($zonemapObj) {
447  
448 $axmud::CLIENT->desktopObj->defaultWorkspaceObj->set_defaultZonemap($zonemapObj);
449 }
450 }
451  
452 # In v1.2.0, window tiling was enabled for MSWin users. For those users with existing Axmud
453 # installations, this 'wiz' window is called a second time
454 # For that reason, check that Locator/Status tasks don't already exist in the global
455 # tasklist. If they do, update their settings, rather than creating a new task
456 foreach my $initTaskObj ($axmud::CLIENT->ivValues('initTaskHash')) {
457  
458 if ($initTaskObj->name eq 'status_task') {
459 $initStatusObj = $initTaskObj;
460 } elsif ($initTaskObj->name eq 'locator_task') {
461 $initLocatorObj = $initTaskObj;
462 }
463  
464 # While we're at it, compile a hash of global initial tasks, containing only the first
465 # instance of each type of task
466 $checkHash{$initTaskObj->name} = undef;
467 }
468  
469 # Remove pre-configured worlds, as required
470 $slWidget = $self->slWidget;
471 OUTER: foreach my $listRef (@{$slWidget->{data}}) {
472  
473 my ($worldObj, $fileObj);
474  
475 # $listRef is in the form [remove_flag, profile_name...]
476 if ($$listRef[0]) {
477  
478 # Remove this world profile
479 $worldObj = $axmud::CLIENT->ivShow('worldProfHash', $$listRef[1]);
480 if ($worldObj) {
481  
482 # (It should not be possible for any session to be running, but in case someone
483 # is testing this window, we'll check anyway)
484 INNER: foreach my $session ($axmud::CLIENT->listSessions()) {
485  
486 if (defined $session->currentWorld && $session->currentWorld eq $worldObj) {
487  
488 # (Not a fatal error)
489 $axmud::CLIENT->writeWarning(
490 'Could not delete world profile \'' . $worldObj->name
491 . '\' - it is in use by a session',
492 $self->_objClass . '->saveChanges',
493 );
494  
495 next OUTER;
496 }
497 }
498  
499 # Delete the world's data files. First find the file object
500 $fileObj = $axmud::CLIENT->ivShow('fileObjHash', $worldObj->name);
501 if (! $fileObj) {
502  
503 # (Not a fatal error)
504 $axmud::CLIENT->writeWarning(
505 'Could not delete world profile \'' . $worldObj->name
506 . '\' - file object is missing',
507 $self->_objClass . '->saveChanges',
508 );
509 }
510  
511 # Delete the whole directory used for that world (e.g. /data/worlds/WORLD_NAME)
512 if (! $fileObj->destroyStandardDir()) {
513  
514 # (Not a fatal error)
515 $axmud::CLIENT->writeWarning(
516 'Could not delete data files for the world profile \'' . $worldObj->name
517 . '\'',
518 $self->_objClass . '->saveChanges',
519 );
520 }
521  
522 # Update the GA::Client registries
523 $axmud::CLIENT->del_worldProf($worldObj);
524 $axmud::CLIENT->del_fileObj($fileObj);
525 }
526 }
527 }
528  
529 # Add initial tasks (if any) in a set order
530 @taskList = qw(status locator attack compass channels divert inventory launch notepad);
531 foreach my $name (@taskList) {
532  
533 my $taskObj;
534  
535 if ($self->ivShow('taskInitHash', $name)) {
536  
537 if ($name eq 'status' && $initStatusObj) {
538  
539 $taskObj = $initStatusObj;
540  
541 } elsif ($name eq 'locator' && $initLocatorObj) {
542  
543 $taskObj = $initLocatorObj;
544  
545 } elsif (! exists $checkHash{$name . '_task'}) {
546  
547 # e.g. 'status_task'
548 $taskObj = $axmud::CLIENT->addGlobalInitTask($name . '_task');
549 }
550  
551 if ($taskObj) {
552  
553 if ($name eq 'status') {
554  
555 if (! $self->ivShow('taskSettingHash', 'status_win')) {
556 $taskObj->set_startWithWinFlag(FALSE);
557 } else {
558 $taskObj->set_startWithWinFlag(TRUE);
559 }
560  
561 if (! $self->ivShow('taskSettingHash', 'status_gauge')) {
562 $taskObj->set_gaugeFlag(FALSE);
563 } else {
564 $taskObj->set_gaugeFlag(TRUE);
565 }
566  
567 } elsif ($name eq 'locator') {
568  
569 if (! $self->ivShow('taskSettingHash', 'locator_win')) {
570 $taskObj->set_startWithWinFlag(FALSE);
571 } else {
572 $taskObj->set_startWithWinFlag(TRUE);
573 }
574 }
575 }
576 }
577 }
578  
579 # Enable instruction sigils, in no particular order
580 foreach my $sigil ($self->ivKeys('sigilHash')) {
581  
582 if ($self->ivShow('sigilHash', $sigil)) {
583  
584 $axmud::CLIENT->toggle_sigilFlag($sigil);
585 }
586 }
587  
588 # All changes made. Close the window
589 $self->winDestroy();
590  
591 return 1;
592 }
593  
594 # Standard callbacks
595  
596 sub buttonCancel {
597  
598 # 'Cancel' button callback
599 #
600 # Expected arguments
601 # (none besides $self)
602 #
603 # Return values
604 # 'undef' on improper arguments
605 # 1 otherwise
606  
607 my ($self, $check) = @_;
608  
609 # Local variables
610 my $taskObj;
611  
612 # Check for improper arguments
613 if (defined $check) {
614  
615 return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonCancel', @_);
616 }
617  
618 # Close the window
619 $self->winDestroy();
620  
621 # Do the average user a favour by adding the Status and Locator tasks to the global initial
622 # tasklist, even if they clicked the 'Cancel' button
623 # (Of course, if the user closed the window some other way, no initial tasks are added)
624 $taskObj = $axmud::CLIENT->addGlobalInitTask('status_task');
625 if ($taskObj) {
626  
627 $taskObj->set_gaugeFlag(TRUE);
628 }
629  
630 $axmud::CLIENT->addGlobalInitTask('locator_task');
631  
632 return 1;
633 }
634  
635 # Window pages
636  
637 sub introPage {
638  
639 # Intro page - called by $self->setupGrid or ->updateGrid
640 #
641 # Expected arguments
642 # (none besides $self)
643 #
644 # Return values
645 # 'undef' on improper arguments
646 # 1 otherwise
647  
648 my ($self, $check) = @_;
649  
650 # Local variables
651 my @spacingList;
652  
653 # Check for improper arguments
654 if (defined $check) {
655  
656 return $axmud::CLIENT->writeImproper($self->_objClass . '->introPage', @_);
657 }
658  
659 # Intro
660 $self->addLabel($self->grid, '<b>Setup wizard (' . $self->getPageString() . ')</b>',
661 0, 12, 0, 1);
662  
663 $self->addSimpleImage(
664 $self->grid,
665 $axmud::CLIENT->getDialogueIcon('large'),
666 undef,
667 1, 6, 1, 12);
668  
669 # (Empty labels for spacing)
670 my $label = $self->addLabel($self->grid, '',
671 7, 10, 1, 4);
672 $label->set_vexpand(TRUE);
673  
674 $self->addLabel($self->grid, '<b>Welcome to ' . $axmud::SCRIPT . '!</b>',
675 7, 10, 4, 5);
676 $self->addLabel(
677 $self->grid,
678 '<i>Please take a few moments to set up your new MUD client</i>',
679 7, 10, 5, 6);
680  
681 my $button = $self->addButton(
682 $self->grid,
683 undef,
684 "Ok, let's get started!",
685 "Move on to the next page",
686 7, 10, 6, 7);
687 $button->set_vexpand(TRUE);
688 $button->signal_connect('clicked' => sub {
689  
690 # (The same as clicking the 'Next' button at the bottom of the window)
691 $self->buttonNext();
692 });
693  
694 my $button2 = $self->addButton(
695 $self->grid,
696 undef,
697 "Use recommended settings for my system",
698 "Close this window and use recommended settings",
699 7, 10, 7, 8);
700 $button2->set_vexpand(TRUE);
701 $button2->signal_connect('clicked' => sub {
702  
703 # The only change that the widgets on the following pages make is to set the zonemap...
704 if (
705 defined $self->workspaceObj->currentWidth
706 && $self->workspaceObj->currentWidth >= 1800
707 ) {
708 $self->ivPoke('zonemap', 'widescreen');
709 }
710  
711 # All other system-dependent changes are already specified by this object's IVs, so we
712 # can call the function as if the user had clicked the 'Save' button at the bottom of
713 # the window
714 $self->saveChanges();
715 });
716  
717 my $button3 = $self->addButton(
718 $self->grid,
719 undef,
720 "Just use default settings",
721 "Close this window and use default settings",
722 7, 10, 8, 9);
723 $button3->set_vexpand(TRUE);
724 $button3->signal_connect('clicked' => sub {
725  
726 # (The same as clicking the 'Cancel' button at the bottom of the window)
727 $self->buttonCancel();
728 });
729  
730 # (Empty labels for spacing)
731 my $label2 = $self->addLabel($self->grid, '',
732 7, 10, 9, 12);
733 $label2->set_vexpand(TRUE);
734  
735 return 1;
736 }
737  
738 sub mainWinPage {
739  
740 # 'Main' window page - called by $self->setupGrid or ->updateGrid
741 #
742 # Expected arguments
743 # (none besides $self)
744 #
745 # Return values
746 # 'undef' on improper arguments
747 # 1 otherwise
748  
749 my ($self, $check) = @_;
750  
751 # Local variables
752 my @spacingList;
753  
754 # Check for improper arguments
755 if (defined $check) {
756  
757 return $axmud::CLIENT->writeImproper($self->_objClass . '->mainWinPage', @_);
758 }
759  
760 # 'Main' windows
761 $self->addLabel($self->grid, '<b>\'Main\' windows (' . $self->getPageString() . ')</b>',
762 0, 12, 0, 1);
763 $self->addLabel(
764 $self->grid,
765 "<i>Choose how Axmud handles multiple simultaneous connections.</i>",
766 1, 12, 1, 2);
767  
768 $self->addSimpleImage(
769 $self->grid,
770 $axmud::SHARE_DIR . '/icons/setup/shared.png',
771 undef,
772 1, 3, 3, 5);
773  
774 my ($radioButton, $radioButton2, $group);
775 ($group, $radioButton) = $self->addRadioButton(
776 $self->grid,
777 undef,
778 undef,
779 undef,
780 FALSE,
781 TRUE,
782 4, 5, 3, 4);
783  
784 $self->addLabel(
785 $self->grid,
786 "All connections <b>share</b> a single \'main\' window.",
787 5, 12, 3, 4);
788  
789 $self->addLabel(
790 $self->grid,
791 "<i>This is a good choice if you have a small monitor, or if you often connect\n"
792 . "to several worlds at a time. You can click the tabs at the top of each\n"
793 . "window to switch between connections.</i>",
794 5, 12, 4, 5);
795  
796 # (Empty labels for spacing)
797 $self->addLabel($self->grid, '',
798 1, 12, 5, 6);
799  
800 $self->addSimpleImage(
801 $self->grid,
802 $axmud::SHARE_DIR . '/icons/setup/single.png',
803 undef,
804 1, 3, 6, 8);
805  
806 ($group, $radioButton2) = $self->addRadioButton(
807 $self->grid,
808 undef,
809 $group,
810 undef,
811 FALSE,
812 TRUE,
813 4, 5, 6, 7);
814  
815 $self->addLabel(
816 $self->grid,
817 "All connections have <b>their own</b> \'main\' window.",
818 5, 12, 6, 7);
819  
820 $self->addLabel(
821 $self->grid,
822 "<i>This is a good choice if you have a large monitor (or several monitors),\n"
823 . "or if you rarely connect to more than one world at a time.</i>",
824 5, 12, 7, 8);
825  
826 # (->signal_connects from above)
827 if ($self->shareMainWinFlag) {
828 $radioButton->set_active(TRUE);
829 } else {
830 $radioButton2->set_active(TRUE);
831 }
832  
833 $radioButton->signal_connect('toggled' => sub {
834  
835 if ($radioButton->get_active()) {
836  
837 $self->ivPoke('shareMainWinFlag', TRUE);
838 $self->ivPoke('zonemap', 'basic');
839 }
840 });
841  
842 $radioButton2->signal_connect('toggled' => sub {
843  
844 if ($radioButton2->get_active()) {
845  
846 $self->ivPoke('shareMainWinFlag', FALSE);
847 $self->ivPoke('zonemap', 'horizontal');
848 }
849 });
850  
851 # (Empty labels for spacing)
852 my $label = $self->addLabel($self->grid, '',
853 1, 12, 9, 10);
854 $label->set_vexpand(TRUE);
855  
856 return 1;
857 }
858  
859 sub zonemapPage {
860  
861 # Zonemap page - called by $self->setupGrid or ->updateGrid
862 #
863 # Expected arguments
864 # (none besides $self)
865 #
866 # Return values
867 # 'undef' on improper arguments
868 # 1 otherwise
869  
870 my ($self, $check) = @_;
871  
872 # Local variables
873 my @spacingList;
874  
875 # Check for improper arguments
876 if (defined $check) {
877  
878 return $axmud::CLIENT->writeImproper($self->_objClass . '->zonemapPage', @_);
879 }
880  
881 # Zonemaps
882 $self->addLabel($self->grid, '<b>Zonemaps (' . $self->getPageString() . ')</b>',
883 0, 12, 0, 1);
884 $self->addLabel(
885 $self->grid,
886 "<i>A zonemap is a plan for arranging windows on the desktop. Select the best zonemap"
887 . " for your system.</i>",
888 1, 12, 1, 2);
889  
890 if ($self->shareMainWinFlag) {
891  
892 $self->addSimpleImage(
893 $self->grid,
894 $axmud::SHARE_DIR . '/icons/setup/basic_zonemap.png',
895 undef,
896 1, 4, 2, 5);
897  
898 my ($radioButton, $radioButton2, $radioButton3, $group);
899 ($group, $radioButton) = $self->addRadioButton(
900 $self->grid,
901 undef,
902 undef,
903 'Basic',
904 FALSE,
905 TRUE,
906 4, 6, 3, 4);
907  
908 $self->addSimpleImage(
909 $self->grid,
910 $axmud::SHARE_DIR . '/icons/setup/extended_zonemap.png',
911 undef,
912 7, 10, 2, 5);
913  
914 ($group, $radioButton2) = $self->addRadioButton(
915 $self->grid,
916 undef,
917 $group,
918 'Extended',
919 FALSE,
920 TRUE,
921 10, 12, 3, 4);
922  
923 # (Empty labels for spacing)
924 $self->addLabel($self->grid, '',
925 1, 12, 5, 6);
926  
927 $self->addSimpleImage(
928 $self->grid,
929 $axmud::SHARE_DIR . '/icons/setup/widescreen_zonemap.png',
930 undef,
931 1, 4, 6, 9);
932  
933 ($group, $radioButton3) = $self->addRadioButton(
934 $self->grid,
935 undef,
936 $group,
937 'Widescreen',
938 FALSE,
939 TRUE,
940 4, 6, 7, 8);
941  
942 # (->signal_connects from above)
943  
944 # As a convenience for users, auto-set the 'widescreen' zonemap (but only do this once,
945 # otherwise widescreen will be re-selected if the 'Previous' button is clicked)
946 # Use 1800, rather than 1920, as the test in case there are desktop panels on the
947 # left and/or right sides
948  
949 if (
950 defined $self->workspaceObj->currentWidth
951 && $self->workspaceObj->currentWidth >= 1800
952 && ! $self->widescreenFlag
953 ) {
954 $radioButton3->set_active(TRUE);
955 $self->ivPoke('zonemap', 'widescreen');
956 $self->ivPoke('widescreenFlag', TRUE);
957  
958 } elsif ($self->zonemap eq 'basic') {
959  
960 $radioButton->set_active(TRUE);
961  
962 } elsif ($self->zonemap eq 'extended') {
963  
964 $radioButton2->set_active(TRUE);
965  
966 } else {
967  
968 $radioButton3->set_active(TRUE);
969 }
970  
971 $radioButton->signal_connect('toggled' => sub {
972  
973 if ($radioButton->get_active()) {
974  
975 $self->ivPoke('zonemap', 'basic');
976 }
977 });
978  
979 $radioButton2->signal_connect('toggled' => sub {
980  
981 if ($radioButton2->get_active()) {
982  
983 $self->ivPoke('zonemap', 'extended');
984 }
985 });
986  
987 $radioButton3->signal_connect('toggled' => sub {
988  
989 if ($radioButton3->get_active()) {
990  
991 $self->ivPoke('zonemap', 'widescreen');
992 }
993 });
994  
995 } else {
996  
997 $self->addSimpleImage(
998 $self->grid,
999 $axmud::SHARE_DIR . '/icons/setup/horizontal_zonemap.png',
1000 undef,
1001 1, 4, 2, 5);
1002  
1003 my ($radioButton, $radioButton2, $radioButton3, $group);
1004 ($group, $radioButton) = $self->addRadioButton(
1005 $self->grid,
1006 undef,
1007 $group,
1008 'Horizontal',
1009 FALSE,
1010 TRUE,
1011 4, 6, 3, 4);
1012  
1013 $self->addSimpleImage(
1014 $self->grid,
1015 $axmud::SHARE_DIR . '/icons/setup/vertical_zonemap.png',
1016 undef,
1017 7, 10, 2, 5);
1018  
1019 ($group, $radioButton2) = $self->addRadioButton(
1020 $self->grid,
1021 undef,
1022 $group,
1023 'Vertical',
1024 FALSE,
1025 TRUE,
1026 10, 12, 3, 4);
1027  
1028 # (Empty labels for spacing)
1029 $self->addLabel($self->grid, '',
1030 1, 12, 5, 6);
1031  
1032 $self->addSimpleImage(
1033 $self->grid,
1034 $axmud::SHARE_DIR . '/icons/setup/no_zonemap.png',
1035 undef,
1036 1, 4, 6, 9);
1037  
1038 ($group, $radioButton3) = $self->addRadioButton(
1039 $self->grid,
1040 undef,
1041 $group,
1042 'No zonemap',
1043 FALSE,
1044 TRUE,
1045 4, 6, 7, 8);
1046  
1047 # (->signal_connects from above)
1048 if ($self->zonemap eq 'horizontal') {
1049 $radioButton->set_active(TRUE);
1050 } elsif ($self->zonemap eq 'vertical') {
1051 $radioButton2->set_active(TRUE);
1052 } else {
1053 $radioButton3->set_active(TRUE);
1054 }
1055  
1056 $radioButton->signal_connect('toggled' => sub {
1057  
1058 if ($radioButton->get_active()) {
1059  
1060 $self->ivPoke('zonemap', 'horizontal2');
1061 }
1062 });
1063  
1064 $radioButton2->signal_connect('toggled' => sub {
1065  
1066 if ($radioButton2->get_active()) {
1067  
1068 $self->ivPoke('zonemap', 'vertical2');
1069 }
1070 });
1071  
1072 $radioButton3->signal_connect('toggled' => sub {
1073  
1074 if ($radioButton3->get_active()) {
1075  
1076 $self->ivPoke('zonemap', 'none');
1077 }
1078 });
1079 }
1080  
1081 # (Empty labels for spacing)
1082 my $label = $self->addLabel($self->grid, '',
1083 1, 12, 9, 10);
1084 $label->set_vexpand(TRUE);
1085  
1086 return 1;
1087 }
1088  
1089 sub worldPage {
1090  
1091 # World page - called by $self->setupGrid or ->updateGrid
1092 #
1093 # Expected arguments
1094 # (none besides $self)
1095 #
1096 # Return values
1097 # 'undef' on improper arguments
1098 # 1 otherwise
1099  
1100 my ($self, $check) = @_;
1101  
1102 # Local variables
1103 my (
1104 $count,
1105 @columnList, @dataList,
1106 );
1107  
1108 # Check for improper arguments
1109 if (defined $check) {
1110  
1111 return $axmud::CLIENT->writeImproper($self->_objClass . '->worldPage', @_);
1112 }
1113  
1114 # Pre-configured worlds
1115 $self->addLabel(
1116 $self->grid, '<b>Pre-configured worlds (' . $self->getPageString() . ')</b>',
1117 0, 12, 0, 1);
1118 $self->addLabel(
1119 $self->grid,
1120 '<i>If you don\'t want a lot of pre-configured worlds, you can remove some of them'
1121 . ' here.</i>',
1122 1, 12, 1, 2);
1123  
1124 # Add a simple list
1125 @columnList = (
1126 'Remove', 'bool',
1127 'Profile', 'text',
1128 'Pre-configured world', 'text',
1129 'Host', 'text',
1130 'Port', 'int',
1131 );
1132  
1133 $count = $axmud::CLIENT->ivPairs('worldProfHash');
1134 foreach my $worldObj (
1135 sort {lc($a->name) cmp lc($b->name)} ($axmud::CLIENT->ivValues('worldProfHash'))
1136 ) {
1137 push (@dataList,
1138 FALSE, # Don't delete the world profile, unless the user selects it
1139 $worldObj->name,
1140 $worldObj->longName,
1141 $worldObj->dns,
1142 $worldObj->port,
1143 );
1144 }
1145  
1146 my $slWidget = $self->addSimpleList($self->grid, \@columnList, \@dataList, TRUE,
1147 1, 12, 2, 11);
1148  
1149 my $button = $self->addButton(
1150 $self->grid,
1151 undef,
1152 'Remove all', 'Remove all pre-configured worlds',
1153 1, 6, 11, 12);
1154 $button->signal_connect('clicked' => sub {
1155  
1156 for (my $i = 0; $i < $count; $i++) {
1157  
1158 ${$slWidget->{data}}[$i][0] = TRUE;
1159 }
1160 });
1161  
1162 my $button2 = $self->addButton(
1163 $self->grid,
1164 undef,
1165 'Remove none', 'Retain all pre-configured worlds',
1166 6, 12, 11, 12);
1167 $button2->signal_connect('clicked' => sub {
1168  
1169 for (my $i = 0; $i < $count; $i++) {
1170  
1171 ${$slWidget->{data}}[$i][0] = FALSE;
1172 }
1173 });
1174  
1175 # Update IVs
1176 $self->ivPoke('slWidget', $slWidget);
1177  
1178 return 1;
1179 }
1180  
1181 sub taskPage {
1182  
1183 # Task page - called by $self->setupGrid or ->updateGrid
1184 #
1185 # Expected arguments
1186 # (none besides $self)
1187 #
1188 # Return values
1189 # 'undef' on improper arguments
1190 # 1 otherwise
1191  
1192 my ($self, $check) = @_;
1193  
1194 # Local variables
1195 my (
1196 $noneFlag,
1197 @signalList, @signalList2,
1198 );
1199  
1200 # Check for improper arguments
1201 if (defined $check) {
1202  
1203 return $axmud::CLIENT->writeImproper($self->_objClass . '->taskPage', @_);
1204 }
1205  
1206 # Tasks
1207 $self->addLabel($self->grid, '<b>Tasks (' . $self->getPageString() . ')</b>',
1208 0, 12, 0, 1);
1209 $self->addLabel(
1210 $self->grid,
1211 "<i>Choose which of " . $axmud::SCRIPT . "'s built-in tasks (if any) should start at"
1212 . " the beginning of every session.</i>",
1213 1, 10, 1, 2);
1214 my $button = $self->addButton(
1215 $self->grid,
1216 undef,
1217 'Select all', 'Select/deselect all tasks',
1218 10, 12, 1, 2);
1219  
1220 # Recommended tasks
1221 $self->addLabel($self->grid, '<u>Recommended tasks</u>',
1222 1, 12, 2, 3);
1223  
1224 $self->addSimpleImage(
1225 $self->grid,
1226 $axmud::SHARE_DIR . '/icons/setup/status_task.png',
1227 undef,
1228 1, 2, 3, 5);
1229  
1230 my $checkButton = $self->addCheckButton(
1231 $self->grid,
1232 'Status task',
1233 undef,
1234 $self->ivShow('taskInitHash', 'status'),
1235 TRUE,
1236 2, 6, 3, 4);
1237 my $checkButton2 = $self->addCheckButton(
1238 $self->grid,
1239 'Show task window',
1240 undef,
1241 $self->ivShow('taskSettingHash', 'status_win'),
1242 TRUE,
1243 2, 4, 4, 5);
1244 my $checkButton3 = $self->addCheckButton(
1245 $self->grid,
1246 'Show gauges',
1247 undef,
1248 $self->ivShow('taskSettingHash', 'status_gauge'),
1249 TRUE,
1250 4, 6, 4, 5);
1251  
1252 $self->addLabel(
1253 $self->grid,
1254 "<i>Tracks information about the character, such as their\n"
1255 . "health and energy points. It's essential for the gauges\n"
1256 . "that appear near the bottom of the 'main' window.</i>",
1257 1, 6, 6, 7);
1258  
1259 $self->addSimpleImage(
1260 $self->grid,
1261 $axmud::SHARE_DIR . '/icons/setup/locator_task.png',
1262 undef,
1263 7, 8, 3, 5);
1264  
1265 my $checkButton4 = $self->addCheckButton(
1266 $self->grid,
1267 'Locator task',
1268 undef,
1269 $self->ivShow('taskInitHash', 'locator'),
1270 TRUE,
1271 8, 12, 3, 4);
1272 my $checkButton5 = $self->addCheckButton(
1273 $self->grid,
1274 'Show task window',
1275 undef,
1276 $self->ivShow('taskSettingHash', 'locator_win'),
1277 TRUE,
1278 8, 12, 4, 5);
1279  
1280 $self->addLabel(
1281 $self->grid,
1282 "<i>Tracks the character\'s position in the world. It\'s essential\n"
1283 . "for the automapper, but neither the Locator nor Status\n"
1284 . "task windows actually need to be open.</i>",
1285 7, 12, 6, 7);
1286  
1287 # Optional tasks
1288 $self->addLabel($self->grid, '<u>Optional tasks</u>',
1289 1, 12, 7, 8);
1290  
1291 $self->addSimpleImage(
1292 $self->grid,
1293 $axmud::SHARE_DIR . '/icons/setup/attack_task.png',
1294 undef,
1295 1, 2, 8, 9);
1296  
1297 my $checkButton6 = $self->addCheckButton(
1298 $self->grid,
1299 'Attack task',
1300 undef,
1301 $self->ivShow('taskInitHash', 'attack'),
1302 TRUE,
1303 2, 6, 8, 9);
1304 $self->addLabel(
1305 $self->grid,
1306 "<i>Tracks the character\'s fights and interactions,\n"
1307 . "updating current profiles as it goes.</i>",
1308 2, 6, 9, 10);
1309  
1310 $self->addSimpleImage(
1311 $self->grid,
1312 $axmud::SHARE_DIR . '/icons/setup/compass_task.png',
1313 undef,
1314 1, 2, 10, 11);
1315  
1316 my $checkButton7 = $self->addCheckButton(
1317 $self->grid,
1318 'Compass task',
1319 undef,
1320 $self->ivShow('taskInitHash', 'compass'),
1321 TRUE,
1322 2, 6, 10, 11);
1323 $self->addLabel(
1324 $self->grid,
1325 "<i>A convenient way to enable and disable keypad\n"
1326 . "macros for moving around the world.</i>",
1327 2, 6, 11, 12);
1328  
1329 $self->addSimpleImage(
1330 $self->grid,
1331 $axmud::SHARE_DIR . '/icons/setup/divert_task.png',
1332 undef,
1333 1, 2, 12, 13);
1334  
1335 my $checkButton8 = $self->addCheckButton(
1336 $self->grid,
1337 'Channels task, or',
1338 undef,
1339 $self->ivShow('taskInitHash', 'divert'),
1340 TRUE,
1341 2, 4, 12, 13);
1342 my $checkButton9 = $self->addCheckButton(
1343 $self->grid,
1344 'Divert task',
1345 undef,
1346 $self->ivShow('taskInitHash', 'divert'),
1347 TRUE,
1348 4, 6, 12, 13);
1349 $self->addLabel(
1350 $self->grid,
1351 "<i>Diverts social messages and tells to a separate\n"
1352 . "task window. Channels tasks have multiple tabs.</i>",
1353 2, 6, 13, 14);
1354  
1355 # (Right column)
1356 $self->addSimpleImage(
1357 $self->grid,
1358 $axmud::SHARE_DIR . '/icons/setup/inventory_task.png',
1359 undef,
1360 7, 8, 8, 9);
1361  
1362 my $checkButton10 = $self->addCheckButton(
1363 $self->grid,
1364 'Inventory task',
1365 undef,
1366 $self->ivShow('taskInitHash', 'inventory'),
1367 TRUE,
1368 8, 12, 8, 9);
1369 $self->addLabel(
1370 $self->grid,
1371 "<i>Keeps track of the character's inventory and\n"
1372 . "displays a summary in its own task window.</i>",
1373 8, 12, 9, 10);
1374  
1375 $self->addSimpleImage(
1376 $self->grid,
1377 $axmud::SHARE_DIR . '/icons/setup/launch_task.png',
1378 undef,
1379 7, 8, 10, 11);
1380  
1381 my $checkButton11 = $self->addCheckButton(
1382 $self->grid,
1383 'Launch task',
1384 undef,
1385 $self->ivShow('taskInitHash', 'launch'),
1386 TRUE,
1387 8, 12, 10, 11);
1388 $self->addLabel(
1389 $self->grid,
1390 "<i>A convenient method for selecting and running\n"
1391 . $axmud::BASIC_NAME . " scripts.</i>",
1392 8, 12, 11, 12);
1393  
1394 $self->addSimpleImage(
1395 $self->grid,
1396 $axmud::SHARE_DIR . '/icons/setup/notepad_task.png',
1397 undef,
1398 7, 8, 12, 13);
1399  
1400 my $checkButton12 = $self->addCheckButton(
1401 $self->grid,
1402 'Notepad task',
1403 undef,
1404 $self->ivShow('taskInitHash', 'notepad'),
1405 TRUE,
1406 8, 12, 12, 13);
1407 $self->addLabel(
1408 $self->grid,
1409 "<i>Write your notes here. They will be waiting for\n"
1410 . "you, the next time you connect to the world.</i>",
1411 8, 12, 13, 14);
1412  
1413 # (->signal_connects from above)
1414 $button->signal_connect('clicked' => sub {
1415  
1416 if (! $noneFlag) {
1417  
1418 # 'Select all'
1419 $checkButton->set_active(TRUE);
1420 $checkButton4->set_active(TRUE);
1421 $checkButton6->set_active(TRUE);
1422 $checkButton7->set_active(TRUE);
1423 $checkButton8->set_active(TRUE);
1424 $checkButton9->set_active(FALSE);
1425 $checkButton10->set_active(TRUE);
1426 $checkButton11->set_active(TRUE);
1427 $checkButton12->set_active(TRUE);
1428  
1429 # Next button click is 'Select none'
1430 $button->set_label('Select none');
1431 $noneFlag = TRUE;
1432  
1433 } else {
1434  
1435 # 'Select none'
1436 $checkButton->set_active(FALSE);
1437 $checkButton2->set_active(FALSE);
1438 $checkButton3->set_active(FALSE);
1439 $checkButton4->set_active(FALSE);
1440 $checkButton5->set_active(FALSE);
1441 $checkButton6->set_active(FALSE);
1442 $checkButton7->set_active(FALSE);
1443 $checkButton8->set_active(FALSE);
1444 $checkButton9->set_active(FALSE);
1445 $checkButton10->set_active(FALSE);
1446 $checkButton11->set_active(FALSE);
1447 $checkButton12->set_active(FALSE);
1448  
1449 # Next button click is 'Select all'
1450 $button->set_label('Select all');
1451 $noneFlag = FALSE;
1452 }
1453 });
1454  
1455 @signalList = (
1456 $checkButton => 'status',
1457 $checkButton4 => 'locator',
1458 $checkButton6 => 'attack',
1459 $checkButton7 => 'compass',
1460 $checkButton8 => 'channels',
1461 $checkButton9 => 'divert',
1462 $checkButton10 => 'inventory',
1463 $checkButton11 => 'launch',
1464 $checkButton12 => 'notepad',
1465 );
1466  
1467 do {
1468  
1469 my ($widget, $key);
1470  
1471 $widget = shift @signalList;
1472 $key = shift @signalList;
1473  
1474 $widget->signal_connect('toggled' => sub {
1475  
1476 if (! $widget->get_active()) {
1477  
1478 $self->ivAdd('taskInitHash', $key, FALSE);
1479  
1480 if ($key eq 'status' && $widget eq $checkButton) {
1481  
1482 # If no Status task, don't show task window or gauges
1483 $checkButton2->set_active(FALSE);
1484 $checkButton3->set_active(FALSE);
1485  
1486 } elsif ($key eq 'locator' && $widget eq $checkButton4) {
1487  
1488 # If not Locator task, don't show task window
1489 $checkButton5->set_active(FALSE);
1490 }
1491  
1492 } else {
1493  
1494 if ($key eq 'channels' && $widget eq $checkButton8) {
1495  
1496 # If Channels selected, don't select Divert
1497 $checkButton9->set_active(FALSE);
1498 $self->ivAdd('taskInitHash', 'channels', TRUE);
1499 $self->ivAdd('taskInitHash', 'divert', FALSE);
1500  
1501 } elsif ($key eq 'divert' && $widget eq $checkButton9) {
1502  
1503 $checkButton8->set_active(FALSE);
1504 $self->ivAdd('taskInitHash', 'divert', TRUE);
1505 $self->ivAdd('taskInitHash', 'channels', FALSE);
1506  
1507 } else {
1508  
1509 $self->ivAdd('taskInitHash', $key, TRUE);
1510 }
1511 }
1512 });
1513  
1514 } until (! @signalList);
1515  
1516 @signalList2 = (
1517 $checkButton2 => 'status_win',
1518 $checkButton3 => 'status_gauge',
1519 $checkButton5 => 'locator_win',
1520 );
1521  
1522 do {
1523  
1524 my ($widget, $key);
1525  
1526 $widget = shift @signalList2;
1527 $key = shift @signalList2;
1528  
1529 $widget->signal_connect('toggled' => sub {
1530  
1531 if (! $widget->get_active()) {
1532 $self->ivAdd('taskSettingHash', $key, FALSE);
1533 } else {
1534 $self->ivAdd('taskSettingHash', $key, TRUE);
1535 }
1536 });
1537  
1538 } until (! @signalList2);
1539  
1540 return 1;
1541 }
1542  
1543 sub sigilPage {
1544  
1545 # Sigil page - called by $self->setupGrid or ->updateGrid
1546 #
1547 # Expected arguments
1548 # (none besides $self)
1549 #
1550 # Return values
1551 # 'undef' on improper arguments
1552 # 1 otherwise
1553  
1554 my ($self, $check) = @_;
1555  
1556 # Local variables
1557 my (
1558 $noneFlag,
1559 @signalList,
1560 );
1561  
1562 # Check for improper arguments
1563 if (defined $check) {
1564  
1565 return $axmud::CLIENT->writeImproper($self->_objClass . '->sigilPage', @_);
1566 }
1567  
1568 # Commands
1569 $self->addLabel($self->grid, '<b>Commands (' . $self->getPageString() . ')</b>',
1570 0, 12, 0, 1);
1571 $self->addLabel(
1572 $self->grid,
1573 "<i>Some types of command start with a special character (sigil). Choose which sigils"
1574 . " to enable.</i>",
1575 1, 10, 1, 2);
1576 my $button = $self->addButton(
1577 $self->grid,
1578 undef,
1579 'Select all', 'Select/deselect all sigils',
1580 10, 12, 1, 2);
1581  
1582 # Compulsory sigils
1583 $self->addLabel($self->grid, '<u>Compulsory sigils</u>',
1584 1, 12, 2, 3);
1585  
1586 $self->addSimpleImage(
1587 $self->grid,
1588 $axmud::SHARE_DIR . '/icons/setup/client_sigil.png',
1589 undef,
1590 1, 2, 3, 4);
1591  
1592 my $checkButton = $self->addCheckButton($self->grid, 'Client commands', undef, TRUE, FALSE,
1593 2, 6, 3, 4);
1594  
1595 $self->addLabel(
1596 $self->grid,
1597 "<i>Client commands are processed by " . $axmud::SCRIPT . " directly,\n"
1598 . "not sent to the world.</i>",
1599 1, 6, 4, 5);
1600  
1601 $self->addSimpleImage(
1602 $self->grid,
1603 $axmud::SHARE_DIR . '/icons/setup/forced_sigil.png',
1604 undef,
1605 7, 8, 3, 4);
1606  
1607 my $checkButton2 = $self->addCheckButton(
1608 $self->grid, 'Forced world commands', undef, TRUE, FALSE,
1609 8, 12, 3, 4);
1610  
1611 $self->addLabel(
1612 $self->grid,
1613 "<i>Everything after the commas is sent directly to the world;\n"
1614 . "useful for world commands beginning with an " . $axmud::SCRIPT . " sigil.</i>",
1615 7, 12, 4, 5);
1616  
1617 # Optional sigils
1618 $self->addLabel($self->grid, '<u>Optional sigils</u>',
1619 1, 12, 5, 6);
1620  
1621 $self->addSimpleImage(
1622 $self->grid,
1623 $axmud::SHARE_DIR . '/icons/setup/echo_sigil.png',
1624 undef,
1625 1, 2, 6, 7);
1626  
1627 my $checkButton3 = $self->addCheckButton(
1628 $self->grid,
1629 'Echo commands',
1630 undef,
1631 $self->ivShow('sigilHash', 'echo'),
1632 TRUE,
1633 2, 6, 6, 7);
1634 $self->addLabel(
1635 $self->grid,
1636 "<i>Everything after the quote is displayed in the\n"
1637 . "'main' window as a system message.</i>",
1638 2, 6, 7, 8);
1639  
1640 $self->addSimpleImage(
1641 $self->grid,
1642 $axmud::SHARE_DIR . '/icons/setup/perl_sigil.png',
1643 undef,
1644 1, 2, 8, 9);
1645  
1646 my $checkButton4 = $self->addCheckButton(
1647 $self->grid,
1648 'Perl commands',
1649 undef,
1650 $self->ivShow('sigilHash', 'perl'),
1651 TRUE,
1652 2, 6, 8, 9);
1653 $self->addLabel(
1654 $self->grid,
1655 "<i>Everything after the forward slash is executed\n"
1656 . "as a mini-Perl programme.</i>",
1657 2, 6, 9, 10);
1658  
1659 $self->addSimpleImage(
1660 $self->grid,
1661 $axmud::SHARE_DIR . '/icons/setup/script_sigil.png',
1662 undef,
1663 1, 2, 10, 11);
1664  
1665 my $checkButton5 = $self->addCheckButton(
1666 $self->grid,
1667 'Script commands',
1668 undef,
1669 $self->ivShow('sigilHash', 'script'),
1670 TRUE,
1671 2, 6, 10, 11);
1672 $self->addLabel(
1673 $self->grid,
1674 "<i>A quick way to run " . $axmud::BASIC_NAME . " scripts. Everything\n"
1675 . "after the ampersand is the name of the script.</i>",
1676 2, 6, 11, 12);
1677  
1678 # (Right column)
1679 $self->addSimpleImage(
1680 $self->grid,
1681 $axmud::SHARE_DIR . '/icons/setup/multi_sigil.png',
1682 undef,
1683 7, 8, 6, 7);
1684  
1685 my $checkButton6 = $self->addCheckButton(
1686 $self->grid,
1687 'Multi commands',
1688 undef,
1689 $self->ivShow('sigilHash', 'multi'),
1690 TRUE,
1691 8, 12, 6, 7);
1692 $self->addLabel(
1693 $self->grid,
1694 "<i>Sends a world command to every session (or every\n"
1695 . "session connected to the same world.)</i>",
1696 8, 12, 7, 8);
1697  
1698 $self->addSimpleImage(
1699 $self->grid,
1700 $axmud::SHARE_DIR . '/icons/setup/speedwalk_sigil.png',
1701 undef,
1702 7, 8, 8, 9);
1703  
1704 my $checkButton7 = $self->addCheckButton(
1705 $self->grid,
1706 'Speedwalk commands',
1707 undef,
1708 $self->ivShow('sigilHash', 'speed'),
1709 TRUE,
1710 8, 12, 8, 9);
1711 $self->addLabel(
1712 $self->grid,
1713 "<i>Speedwalk commands can be simple, e.g. <b>.3n</b>\n"
1714 . "or complex, e.g. <b>3[close]wO(sw)(sw)</b></i>",
1715 8, 12, 9, 10);
1716  
1717 $self->addSimpleImage(
1718 $self->grid,
1719 $axmud::SHARE_DIR . '/icons/setup/bypass_sigil.png',
1720 undef,
1721 7, 8, 10, 11);
1722  
1723 my $checkButton8 = $self->addCheckButton(
1724 $self->grid,
1725 'Bypass commands',
1726 undef,
1727 $self->ivShow('sigilHash', 'bypass'),
1728 TRUE,
1729 8, 12, 10, 11);
1730 $self->addLabel(
1731 $self->grid,
1732 "<i>Sends a command to the world immediately,\n"
1733 . "bypassing any queued world commands.</i>",
1734 8, 12, 11, 12);
1735  
1736 # (->signal_connects from above)
1737 $button->signal_connect('clicked' => sub {
1738  
1739 if (! $noneFlag) {
1740  
1741 # 'Select all'
1742 $checkButton3->set_active(TRUE);
1743 $checkButton4->set_active(TRUE);
1744 $checkButton5->set_active(TRUE);
1745 $checkButton6->set_active(TRUE);
1746 $checkButton7->set_active(TRUE);
1747 $checkButton8->set_active(TRUE);
1748  
1749 # Next button click is 'Select none'
1750 $button->set_label('Select none');
1751 $noneFlag = TRUE;
1752  
1753 } else {
1754  
1755 # 'Select none'
1756 $checkButton3->set_active(FALSE);
1757 $checkButton4->set_active(FALSE);
1758 $checkButton5->set_active(FALSE);
1759 $checkButton6->set_active(FALSE);
1760 $checkButton7->set_active(FALSE);
1761 $checkButton8->set_active(FALSE);
1762  
1763 # Next button click is 'Select all'
1764 $button->set_label('Select all');
1765 $noneFlag = FALSE;
1766 }
1767 });
1768  
1769 @signalList = (
1770 $checkButton3 => 'echo',
1771 $checkButton4 => 'perl',
1772 $checkButton5 => 'script',
1773 $checkButton6 => 'multi',
1774 $checkButton7 => 'speed',
1775 $checkButton8 => 'bypass',
1776 );
1777  
1778 do {
1779  
1780 my ($widget, $key);
1781  
1782 $widget = shift @signalList;
1783 $key = shift @signalList;
1784  
1785 $widget->signal_connect('toggled' => sub {
1786  
1787 if (! $widget->get_active()) {
1788 $self->ivAdd('sigilHash', $key, FALSE);
1789 } else {
1790 $self->ivAdd('sigilHash', $key, TRUE);
1791 }
1792 });
1793  
1794 } until (! @signalList);
1795  
1796 return 1;
1797 }
1798  
1799 sub lastPage {
1800  
1801 # Last page - called by $self->setupGrid or ->updateGrid
1802 #
1803 # Expected arguments
1804 # (none besides $self)
1805 #
1806 # Return values
1807 # 'undef' on improper arguments
1808 # 1 otherwise
1809  
1810 my ($self, $check) = @_;
1811  
1812 # Local variables
1813 my (@verboseList, @shortList, @briefList);
1814  
1815 # Check for improper arguments
1816 if (defined $check) {
1817  
1818 return $axmud::CLIENT->writeImproper($self->_objClass . '->lastPage', @_);
1819 }
1820  
1821 $self->addLabel($self->grid, '<b>Finished (' . $self->getPageString() . ')</b>',
1822 0, 12, 0, 1);
1823 $self->addLabel(
1824 $self->grid,
1825 "<i>" . $axmud::SCRIPT . " isn't like other MUD clients. Click the help icon at any"
1826 . " time to read about its most important features.</i>",
1827 1, 12, 1, 2);
1828  
1829 $self->addSimpleImage(
1830 $self->grid,
1831 $axmud::SHARE_DIR . '/icons/setup/help.png',
1832 undef,
1833 1, 12, 2, 11);
1834  
1835 $self->addLabel(
1836 $self->grid,
1837 "<b>Click the Finish button to get started!</b>",
1838 1, 12, 11, 12,
1839 0.5, 0.5);
1840  
1841 return 1;
1842 }
1843  
1844 # Support functions
1845  
1846 ##################
1847 # Accessors - set
1848  
1849 ##################
1850 # Accessors - get
1851  
1852 sub shareMainWinFlag
1853 { $_[0]->{shareMainWinFlag} }
1854 sub zonemap
1855 { $_[0]->{zonemap} }
1856 sub widescreenFlag
1857 { $_[0]->{widescreenFlag} }
1858  
1859 sub slWidget
1860 { $_[0]->{slWidget} }
1861  
1862 sub taskInitHash
1863 { my $self = shift; return %{$self->{taskInitHash}}; }
1864 sub taskSettingHash
1865 { my $self = shift; return %{$self->{taskSettingHash}}; }
1866 sub sigilHash
1867 { my $self = shift; return %{$self->{sigilHash}}; }
1868 }
1869  
1870 { package Games::Axmud::WizWin::Locator;
1871  
1872 use strict;
1873 use warnings;
1874 use diagnostics;
1875  
1876 use Glib qw(TRUE FALSE);
1877  
1878 our @ISA = qw(
1879 Games::Axmud::Generic::WizWin Games::Axmud::Generic::FreeWin Games::Axmud::Generic::Win
1880 Games::Axmud
1881 );
1882  
1883 ##################
1884 # Constructors
1885  
1886 sub new {
1887  
1888 # Called by GA::Generic::Win->createFreeWin
1889 # Creates a new instance of the Locator 'wiz' window, which assists with setting up world
1890 # profile IVs used mostly by the Locator task
1891 #
1892 # Expected arguments
1893 # $number - Unique number for this window object
1894 # $workspaceObj - The GA::Obj::Workspace handling the workspace in which this window
1895 # should be created
1896 # $owner - The owner; a 'grid' window object (but not an 'external' window) or a
1897 # 'free' window object. When this window opens/closes, the owner is
1898 # informed via calls to its ->add_childFreeWin / ->del_childFreeWin
1899 # functions
1900 #
1901 # Optional arguments
1902 # $session - The GA::Session from which this function was called. 'undef' if the
1903 # calling function didn't specify a session and $owner's ->session IV
1904 # is also 'undef'
1905 # $title - A string to use as the window title. If 'undef', a generic title is
1906 # used
1907 # $editObj - Ignored if set
1908 # $tempFlag - Ignored if set
1909 # %configHash - Hash containing any number of key-value pairs needed for this
1910 # particular 'wiz' window; for example, for example,
1911 # GA::PrefWin::TaskStart uses it to specify a task name and type.
1912 # Set to an empty hash if not required
1913 # - This type of window object recognises these initialisation settings:
1914 #
1915 # ...
1916 #
1917 # Return values
1918 # 'undef' on improper arguments
1919 # Blessed reference to the newly-created object on success
1920  
1921 my (
1922 $class, $number, $workspaceObj, $owner, $session, $title, $editObj, $tempFlag,
1923 %configHash,
1924 ) = @_;
1925  
1926 # Check for improper arguments
1927 if (! defined $class || ! defined $number || ! defined $workspaceObj || ! defined $owner) {
1928  
1929 return $axmud::CLIENT->writeImproper($class . '->new', @_);
1930 }
1931  
1932 # Set the values to use for some standard window IVs
1933 if (! $title) {
1934  
1935 $title = 'Locator wizard';
1936 }
1937  
1938 # Setup
1939 my $self = {
1940 _objName => 'wiz_win_' . $number,
1941 _objClass => $class,
1942 _parentFile => undef, # No parent file object
1943 _parentWorld => undef, # No parent file object
1944 _privFlag => TRUE, # All IVs are private
1945  
1946 # Standard window object IVs
1947 # --------------------------
1948  
1949 # Unique number for this window object
1950 number => $number,
1951 # The window category - 'grid' or 'free'
1952 winCategory => 'free',
1953 # The window type, any of the keys in GA::Client->constFreeWinTypeHash
1954 winType => 'wiz',
1955 # A name for the window (for 'config' windows, the same as the window type)
1956 winName => 'locator_wiz',
1957 # The GA::Obj::Workspace object for the workspace in which this window is created
1958 workspaceObj => $workspaceObj,
1959 # The owner; a 'grid' window object (but not an 'external' window) or a 'free' window
1960 # object. When this window opens/closes, the owner is informed via calls to its
1961 # ->add_childFreeWin / ->del_childFreeWin functions
1962 owner => $owner,
1963 # The GA::Session from which this function was called. 'undef' if the calling function
1964 # didn't specify a session and $owner's ->session IV is also 'undef'
1965 session => $session,
1966 # When GA::Session->pseudoCmd is called to execute a client command, the mode in which
1967 # it should be called (usually 'win_error' or 'win_only', which causes errors to be
1968 # displayed in a 'dialogue' window)
1969 pseudoCmdMode => 'win_error',
1970  
1971 # The window widget. For most window objects, the Gtk3::Window. For pseudo-windows, the
1972 # parent 'main' window's Gtk3::Window
1973 # The code should use this IV when it wants to do something to the window itself
1974 # (minimise it, make it active, etc)
1975 winWidget => undef,
1976 # The window container. For most window objects, the Gtk3::Window. For pseudo-windows,
1977 # the parent GA::Table::PseudoWin table object
1978 # The code should use this IV when it wants to add, modify or remove widgets inside the
1979 # window itself
1980 winBox => undef,
1981 # Flag set to TRUE if the window actually exists (after a call to $self->winEnable),
1982 # FALSE if not
1983 enabledFlag => FALSE,
1984 # Flag set to TRUE if the Gtk3 window itself is visible (after a call to
1985 # $self->setVisible), FALSE if it is not visible (after a call to $self->setInvisible)
1986 visibleFlag => TRUE,
1987 # Registry hash of 'free' windows (excluding 'dialogue' windows) for which this window
1988 # is the parent, a subset of GA::Obj::Desktop->freeWinHash. Hash in the form
1989 # $childFreeWinHash{unique_number} = blessed_reference_to_window_object
1990 childFreeWinHash => {},
1991 # When a child 'free' window (excluding 'dialogue' windows) is destroyed, this parent
1992 # window is informed via a call to $self->del_childFreeWin
1993 # When the child is destroyed, this window might want to call some of its own functions
1994 # to update various widgets and/or IVs, in which case this window adds an entry to
1995 # this hash; a hash in the form
1996 # $childDestroyHash{unique_number} = list_reference
1997 # ...where 'unique_number' is the child window's ->number, and 'list_reference' is a
1998 # reference to a list in groups of 2, in the form
1999 # (sub_name, argument_list_ref, sub_name, argument_list_ref...)
2000 childDestroyHash => {},
2001  
2002 # The container widget into which all other widgets are packed (usually a Gtk3::VBox or
2003 # Gtk3::HBox, but any container widget can be used; takes up the whole window client
2004 # area)
2005 packingBox => undef, # Gtk3::VBox
2006  
2007 # Standard IVs for 'free' windows
2008  
2009 # The window's default size, in pixels
2010 widthPixels => $axmud::CLIENT->customFreeWinWidth,
2011 heightPixels => $axmud::CLIENT->customFreeWinHeight,
2012 # Default border/item spacing sizes used in the window, in pixels
2013 borderPixels => $axmud::CLIENT->constFreeBorderPixels,
2014 spacingPixels => $axmud::CLIENT->constFreeSpacingPixels,
2015  
2016 # A string to use as the window title. If 'undef', a generic title is used
2017 title => $title,
2018 # Hash containing any number of key-value pairs needed for this particular 'config'
2019 # window; for example, for example, GA::PrefWin::TaskStart uses it to specify a task
2020 # name and type. Set to an empty hash if not required
2021 configHash => {%configHash},
2022  
2023 # Standard IVs for 'wiz' windows
2024  
2025 # Widgets
2026  
2027 # A vertical pane, with the main area above, and a button strip below
2028 scroller => undef, # Gtk3::ScrolledWindow
2029 hAdjustment => undef, # Gtk3::Adjustment
2030 vAdjustment => undef, # Gtk3::Adjustment
2031 grid => undef, # Gtk3::Grid
2032 hBox => undef, # Gtk3::HBox
2033 nextButton => undef, # Gtk3::Button
2034 previousButton => undef, # Gtk3::Button
2035 cancelButton => undef, # Gtk3::Button
2036  
2037 # Three flags that can be set by any page, to prevent one of three buttons from being
2038 # made sensitive (temporarily)
2039 disableNextButtonFlag => FALSE,
2040 disablePreviousButtonFlag => FALSE,
2041 disableCancelButtonFlag => FALSE,
2042  
2043 # The names of pages, in order of appearance
2044 pageList => [
2045 'intro', # Corresponds to function $self->introPage
2046 'directions',
2047 'dictionary',
2048 'statements',
2049 'capture',
2050 'analysis',
2051 'analysis2',
2052 'last',
2053 ],
2054 # The number of the current page (first page is 0)
2055 currentPage => 0,
2056  
2057 # Two hashes for using the 'Next' / 'Previous' buttons to skip around the pages, rather
2058 # than going to the actual next or previous page (as normal)
2059 # The current page should add an entry to the hash, if necessary; the entry is removed
2060 # by ->buttonPrevious or ->buttonNext as soon as either button is clicked
2061 # Hashes in the form
2062 # $hash{current_page_number} = page_number_if_button_clicked
2063 # NB The first page's number is 0, so the fourth page will be page 3, not page 4
2064 specialNextButtonHash => {},
2065 specialPreviousButtonHash => {},
2066  
2067 # IVs for this type of 'wiz' window
2068  
2069 # A hash of custom primary directions, in the form
2070 # $hash{standard_primary_direction} = custom_primary_direction
2071 customPrimaryDirHash => {}, # Set below
2072 # A hash of custom abbreviated primary directions, in the form
2073 # $hash{standard_primary_direction} = custom_primary_abbreviated_direction
2074 customPrimaryAbbrevHash => {}, # Set below
2075 # NB For both these hashes, if the user empties an entry box, the value is set to
2076 # 'undef' - in that case, the value stored in the current dictionary isn't changed
2077  
2078 # Lists of definite/indefinite articles, to be stored in the current dictionary
2079 # (replacing the contents of the same IVs)
2080 definiteList => [],
2081 indefiniteList => [],
2082 # List of words for 'and'/'or', to be stored in the current dictionary (replacing the
2083 # contents of the same IVs)
2084 andList => [],
2085 orList => [],
2086 # A list of numbers from 1-10, which replaces key-value pairs in the current
2087 # dictionary's ->numberHash
2088 numberList => [],
2089 # A list of contents markers initially imported from
2090 # GA::Profile::World->contentPatternList
2091 markerList => [],
2092  
2093 # Hash to show which of the IVs above have been changed by the user, in the form
2094 # $hash{iv} = flag
2095 # where 'flag' is TRUE if the IV has been changed, FALSE if not
2096 # $self->updateTextView modifies the hash for a number of IVs, but only the 7 IVs above
2097 # are checked at the end of the setup process
2098 ivChangeHash => {},
2099  
2100 # Hash of room statement component types. Includes components specified by
2101 # GA::Profile::World, as well as one components used by this 'wiz' window only:
2102 # 'outside_statement'. Hash in the form
2103 # $hash{component_type} = short_description
2104 componentTypeHash => {
2105 # Component used by this window only
2106 'outside_statement' => 'Line outside the statement',
2107 # Components specified by GA::Profile::World
2108 # 'anchor' => 'Line is the anchor line', # Not required here
2109 'ignore_line' => 'Ignore this line',
2110 'verb_title' => 'Room title (verbose)',
2111 'verb_descrip' => 'Description (verbose)',
2112 'verb_exit' => 'Exit list (verbose)',
2113 'verb_content' => 'Contents list (verbose)',
2114 'verb_special' => 'Special contents list',
2115 'brief_title' => 'Room title (brief)',
2116 'brief_exit' => 'Exit list (brief)',
2117 'brief_title_exit' => 'Room title/exit list (brief)',
2118 'brief_exit_title' => 'Exit list/room title (brief)',
2119 'brief_content' => 'Contents list (brief)',
2120 # 'mudlib_path' => 'Path to the mudlib file' # Not required here
2121 # 'custom' => 'Custom component', # Not required here
2122 },
2123 # A list of verbose room statement components - a selection of the keys in
2124 # $self->componentTypeHash
2125 verboseComponentList => [
2126 'outside_statement',
2127 'ignore_line',
2128 'verb_title',
2129 'verb_descrip',
2130 'verb_special',
2131 'verb_exit',
2132 'verb_content',
2133 ],
2134 # A list of short verbose room statement components - a selection of the keys in
2135 # $self->componentTypeHash
2136 shortComponentList => [
2137 'outside_statement',
2138 'ignore_line',
2139 'verb_title',
2140 'verb_special',
2141 'verb_exit',
2142 'verb_content',
2143 ],
2144 # A list of brief room statement components - a selection of the keys in
2145 # $self->componentTypeHash
2146 briefComponentList => [
2147 'outside_statement',
2148 'ignore_line',
2149 'brief_title',
2150 'brief_exit',
2151 'brief_title_exit',
2152 'brief_exit_title',
2153 'brief_content',
2154 ],
2155  
2156 # A list of consecutive GA::Buffer::Display objects for analysis
2157 bufferObjList => [],
2158 # A corresponding list specifying to which type of component each buffer object in
2159 # $self->bufferObjList belongs (matches keys in $self->componentTypeHash)
2160 bufferTypeList => [],
2161  
2162 # How many analyses have been completed
2163 analysisCount => 0,
2164 # The current analysis is of which type? ('verbose', 'short' or 'brief')
2165 analysisType => 'verbose',
2166 # How many recently-received lines to analyse, by default
2167 analysisLength => 9,
2168 # The minimum and maximum number of recently-received lines to analyse
2169 analysisMinLength => 6,
2170 analysisMaxLength => 15,
2171 # How many lines to increase/decrease this number at a time
2172 analysisInc => 3,
2173 # A hash containing an analysis of ->bufferObjList, compiled by
2174 # $self->collectComponentGroups, in the form
2175 # $hash{component_name} = reference_to_list_of_lines
2176 # ...where 'reference_to_list_of_lines' contains a list of indexes in ->bufferObjList
2177 # in the range 0 to ($self->analysisLength - 1)
2178 analysisHash => {},
2179  
2180 # After an analysis is complete, the list of new GA::Obj::Component objects created
2181 # (the IV used depends on the current value of $self->analysisType)
2182 verboseComponentObjList => [],
2183 shortComponentObjList => [],
2184 briefComponentObjList => [],
2185  
2186 # IVs which are set by various pages, which are transferred directly to the current
2187 # world profile when the setup process is complete. A hash in the form
2188 # $profUpdateHash{iv} = scalar
2189 # $profUpdateHash{iv} = list_reference
2190 profUpdateHash => {},
2191  
2192 # A list of exit names ('north', 'up', etc) extracted from the 'verb_exit' component
2193 # during the analysis
2194 analysisExitList => [],
2195 # Some values extracted from the 'brief_title_exit' and 'brief_exit_title' components,
2196 # stored by $self->analyseComponent and retrieved by $self->analysisPage
2197 tempStartText => undef,
2198 tempStopText => undef,
2199 tempDelimList => [],
2200  
2201 # The languages set by buttons in the first two pages, matching the ->name IV of a
2202 # phrasebook object (Games::Axmud::Obj::Phrasebook)
2203 # Set to 'undef' if no language button was used, or if the 'reset' button is clicked
2204 dirPageLang => undef,
2205 dictPageLang => undef,
2206 # When directions are displayed by $self->directionsPage, the directions don't appear in
2207 # the same order they appear in a phrasebook object (Games::Axmud::Obj::Phrasebook).
2208 # This hash converts indexes in a phrasebook object's ->primaryDirList and
2209 # ->primaryAbbrevDirList into an entry box number
2210 indexConvertHash => {
2211 0 => 0, # n / n
2212 1 => 10, # nne / ne
2213 2 => 1, # ne / e
2214 3 => 11, # ene / se
2215 4 => 2, # e / s
2216 5 => 12, # ese / sw
2217 6 => 3, # se / w
2218 7 => 13, # sse / nw
2219 8 => 4, # s / u
2220 9 => 14, # ssw / d
2221 10 => 5, # sw / nne
2222 11 => 15, # wsw / ene
2223 12 => 6, # w / ese
2224 13 => 16, # wnw / sse
2225 14 => 7, # nw / ssw
2226 15 => 17, # nnw / wsw
2227 16 => 8, # u / wnw
2228 17 => 9, # d / nnw
2229 },
2230 };
2231  
2232 # Bless the object into existence
2233 bless $self, $class;
2234  
2235 # Set up the direction IVs using the current dictionary
2236 $self->resetDirs();
2237 # Set the other word/phrase IVs using the current dictonary
2238 $self->resetOtherWords();
2239 # Set the initial list of contents markers
2240 $self->ivPoke('markerList', $self->session->currentWorld->contentPatternList);
2241  
2242 return $self;
2243 }
2244  
2245 ##################
2246 # Methods
2247  
2248 # Standard window object functions
2249  
2250 # sub winSetup {} # Inherited from GA::Generic::FreeWin
2251  
2252 # sub winEnable {} # Inherited from GA::Generic::WizWin
2253  
2254 # sub winDesengage {} # Inherited from GA::Generic::FreeWin
2255  
2256 # sub winDestroy {} # Inherited from GA::Generic::WizWin
2257  
2258 # sub winShowAll {} # Inherited from GA::Generic::Win
2259  
2260 # sub drawWidgets {} # Inherited from GA::Generic::WizWin
2261  
2262 # sub redrawWidgets {} # Inherited from GA::Generic::Win
2263  
2264 # ->signal_connects
2265  
2266 # Other functions
2267  
2268 sub saveChanges {
2269  
2270 # Called by $self->buttonNext when the user clicks the 'Finish' button
2271 # Saves changes to the current world profile and/or current dictionary, before closing the
2272 # window
2273 #
2274 # Expected arguments
2275 # (none besides $self)
2276 #
2277 # Return values
2278 # 'undef' on improper arguments
2279 # 1 otherwise
2280  
2281 my ($self, $check) = @_;
2282  
2283 # Local variables
2284 my (
2285 $profObj, $dictObj, $declineString, $choice, $string, $pbObjDir, $pbObjDict, $dictFlag,
2286 @numberList, @comboList,
2287 %primaryHash, %abbrevHash,
2288 );
2289  
2290 # Check for improper arguments
2291 if (defined $check) {
2292  
2293 return $axmud::CLIENT->writeImproper($self->_objClass . '->saveChanges', @_);
2294 }
2295  
2296 # Save changes to the current world profile
2297 $profObj = $self->session->currentWorld;
2298  
2299 # Component lists
2300 if ($self->verboseComponentObjList) {
2301  
2302 $profObj->ivEmpty('verboseComponentList');
2303  
2304 foreach my $componentObj ($self->verboseComponentObjList) {
2305  
2306 # Add the component object itself to the profile
2307 $profObj->ivAdd('componentHash', $componentObj->name, $componentObj);
2308  
2309 # For 'verb_content' and 'brief_content' components, the marker patterns stored in
2310 # GA::Profile::World->contentPatternList must also be added to the component
2311 # itself
2312 $self->updateContentComponent($componentObj);
2313  
2314 # The special 'anchor' component must be inserted before the component which
2315 # contains exits (which acts as our anchor line)
2316 $self->insertAnchor($profObj, 'verboseComponentList', $componentObj->type);
2317 $profObj->ivPush('verboseComponentList', $componentObj->name);
2318 }
2319 }
2320  
2321 if ($self->shortComponentObjList) {
2322  
2323 $profObj->ivEmpty('shortComponentList');
2324  
2325 foreach my $componentObj ($self->shortComponentObjList) {
2326  
2327 $profObj->ivAdd('componentHash', $componentObj->name, $componentObj);
2328  
2329 $self->insertAnchor($profObj, 'shortComponentList', $componentObj->type);
2330 $profObj->ivPush('shortComponentList', $componentObj->name);
2331 }
2332 }
2333  
2334 if ($self->briefComponentObjList) {
2335  
2336 $profObj->ivEmpty('briefComponentList');
2337  
2338 foreach my $componentObj ($self->briefComponentObjList) {
2339  
2340 $profObj->ivAdd('componentHash', $componentObj->name, $componentObj);
2341  
2342 $self->insertAnchor($profObj, 'briefComponentList', $componentObj->type);
2343 $profObj->ivPush('briefComponentList', $componentObj->name);
2344 }
2345 }
2346  
2347 # IVs stored in $self->profUpdateHash
2348 foreach my $key ($self->ivKeys('profUpdateHash')) {
2349  
2350 my (
2351 $value,
2352 @list,
2353 );
2354  
2355 $value = $self->ivShow('profUpdateHash', $key);
2356  
2357 # For list IVs, $value is a reference to a list. De-reference it
2358 if (substr($key, -4) eq 'List') {
2359  
2360 @list = @$value;
2361 }
2362  
2363 # Set scalar IVs
2364 if (
2365 $key eq 'verboseAnchorOffset' || $key eq 'shortAnchorOffset'
2366 || $key eq 'briefAnchorOffset'
2367 ) {
2368 $profObj->ivPoke($key, $value);
2369  
2370 # Replace some list IVs...
2371 } elsif ($key eq 'verboseExitDelimiterList' || $key eq 'briefExitDelimiterList') {
2372  
2373 $profObj->ivPoke($key, @list);
2374  
2375 # ...update other list IVs, adding new values to old ones (but not adding duplicates)
2376 } elsif (
2377 $key eq 'verboseAnchorPatternList' || $key eq 'shortAnchorPatternList'
2378 || $key eq 'briefAnchorPatternList' || $key eq 'verboseExitLeftMarkerList'
2379 || $key eq 'verboseExitRightMarkerList' || $key eq 'briefExitLeftMarkerList'
2380 || $key eq 'briefExitRightMarkerList'
2381 ) {
2382 $self->updateProfileList($profObj, $key, @list);
2383 }
2384 }
2385  
2386 # IVs stored in $self->markerList (replace the current contents of the world profile's IV
2387 if ($self->markerList) {
2388  
2389 $profObj->ivPoke('contentPatternList', $self->markerList);
2390 }
2391  
2392 # Check the world profile's ->verboseExitNonDelimiterList, and remove any items that have
2393 # been added to ->verboseExitDelimiterList
2394 $self->checkDelimiters($profObj, 'verboseExitDelimiterList', 'verboseExitNonDelimiterList');
2395 # Check the world profile's ->briefExitNonDelimiterList, and remove any items that have been
2396 # added to ->briefExitDelimiterList
2397 $self->checkDelimiters($profObj, 'briefExitDelimiterList', 'briefExitNonDelimiterList');
2398  
2399 # Save changes to the current dictionary
2400 $dictObj = $self->session->currentDict;
2401 # Import lists/hashes for simplicity
2402 %primaryHash = $self->customPrimaryDirHash;
2403 %abbrevHash = $self->customPrimaryAbbrevHash;
2404 @numberList = $self->numberList;
2405  
2406 foreach my $standardDir (keys %primaryHash) {
2407  
2408 # If the value in the key-value pair is defined, the user has changed it
2409 if (defined $primaryHash{$standardDir}) {
2410  
2411 $dictObj->ivAdd('primaryDirHash', $standardDir, $primaryHash{$standardDir});
2412 $dictFlag = TRUE;
2413 }
2414 }
2415  
2416 foreach my $standardDir (keys %abbrevHash) {
2417  
2418 if (defined $abbrevHash{$standardDir}) {
2419  
2420 $dictObj->ivAdd('primaryAbbrevHash', $standardDir, $abbrevHash{$standardDir});
2421 $dictFlag = TRUE;
2422 }
2423 }
2424  
2425 if ($dictFlag) {
2426  
2427 # Update the dictionary's ->primaryOppHash and ->primaryOppAbbrevHash IVs
2428 $dictObj->updateOppDirHash();
2429 }
2430  
2431 if ($self->ivShow('ivChangeHash', 'definiteList')) {
2432  
2433 $dictObj->ivPoke('definiteList', $self->definiteList);
2434 }
2435  
2436 if ($self->ivShow('ivChangeHash', 'indefiniteList')) {
2437  
2438 $dictObj->ivPoke('indefiniteList', $self->indefiniteList);
2439 }
2440  
2441 if ($self->ivShow('ivChangeHash', 'andList')) {
2442  
2443 $dictObj->ivPoke('andList', $self->andList);
2444 }
2445  
2446 if ($self->ivShow('ivChangeHash', 'orList')) {
2447  
2448 $dictObj->ivPoke('orList', $self->orList);
2449 }
2450  
2451 if ($self->ivShow('ivChangeHash', 'numberList')) {
2452  
2453 if (@numberList && (scalar @numberList) == 10) {
2454  
2455 for (my $num = 1; $num <= 10; $num++) {
2456  
2457 $dictObj->ivAdd(
2458 'numberHash',
2459 shift @numberList,
2460 $num,
2461 );
2462 }
2463 }
2464 }
2465  
2466 # If the user clicked one of the language buttons in either of the first two windows, ask
2467 # them if they'd like to set the dictionary's language
2468 # $self->dirPageLang and ->dictPageLang, if set, are the names of the equivalent phrasebook
2469 # objects
2470 if ($self->dirPageLang) {
2471  
2472 $pbObjDir = $axmud::CLIENT->ivShow('constPhrasebookHash', $self->dirPageLang);
2473 }
2474  
2475 if ($self->dictPageLang) {
2476  
2477 $pbObjDict = $axmud::CLIENT->ivShow('constPhrasebookHash', $self->dirPageLang);
2478 }
2479  
2480 if ($pbObjDir && $pbObjDict && $pbObjDir->name ne $pbObjDict->name) {
2481  
2482 # Open a 'dialogue' window with a combobox, so the user can choose between the languages
2483 $declineString = 'Don\'t change the language';
2484  
2485 # @comboList should only contain languages that aren't the current dictionary's language
2486 push (@comboList, $declineString);
2487  
2488 if ($pbObjDir->targetName ne $dictObj->language) {
2489  
2490 push (@comboList, $pbObjDir->targetName);
2491 }
2492  
2493 if ($pbObjDict->targetName ne $dictObj->language) {
2494  
2495 push (@comboList, $pbObjDict->targetName);
2496 }
2497  
2498 # Prompt the user
2499 $choice = $self->showComboDialogue(
2500 'Change dictionary language',
2501 'Do you want to change the current dictionary\'s language?',
2502 \@comboList,
2503 );
2504  
2505 if ($choice && $choice ne $declineString) {
2506  
2507 $dictObj->ivPoke('language', $choice);
2508 # Also set the dictionary's noun-adjective word order, while we're at it
2509 if ($pbObjDir->targetName eq $choice) {
2510 $dictObj->ivPoke('nounPosn', $pbObjDir->nounPosn);
2511 } else {
2512 $dictObj->ivPoke('nounPosn', $pbObjDict->nounPosn);
2513 }
2514 }
2515  
2516 } elsif ($pbObjDir || $pbObjDict) {
2517  
2518 # Open a 'dialogue' window with yes/no buttons, so the user can choose a language
2519 if ($pbObjDir) {
2520 $string = $pbObjDir->targetName;
2521 } else {
2522 $string = $pbObjDict->targetName;
2523 }
2524  
2525 $choice = $self->showMsgDialogue(
2526 'Change dictionary language',
2527 'question',
2528 'Do you want to change the current dictionary\'s language to \'' . $string . '\'?',
2529 'yes-no',
2530 );
2531  
2532 if ($choice && $choice eq 'yes') {
2533  
2534 $dictObj->ivPoke('language', $string);
2535 if ($pbObjDir->targetName eq $choice) {
2536 $dictObj->ivPoke('nounPosn', $pbObjDir->nounPosn);
2537 } else {
2538 $dictObj->ivPoke('nounPosn', $pbObjDict->nounPosn);
2539 }
2540 }
2541 }
2542  
2543 # All changes made. Reset the Locator task, if it's open, which will hopefully work now;
2544 # then close the window
2545 if ($self->session->locatorTask) {
2546  
2547 $self->session->pseudoCmd('resetlocatortask', $self->pseudoCmdMode);
2548 }
2549  
2550 $self->winDestroy();
2551  
2552 return 1;
2553 }
2554  
2555 # Window pages
2556  
2557 sub introPage {
2558  
2559 # Intro page - called by $self->setupGrid or ->updateGrid
2560 #
2561 # Expected arguments
2562 # (none besides $self)
2563 #
2564 # Return values
2565 # 'undef' on improper arguments
2566 # 1 otherwise
2567  
2568 my ($self, $check) = @_;
2569  
2570 # Local variables
2571 my @list;
2572  
2573 # Check for improper arguments
2574 if (defined $check) {
2575  
2576 return $axmud::CLIENT->writeImproper($self->_objClass . '->introPage', @_);
2577 }
2578  
2579 # Intro
2580 $self->addLabel($self->grid, '<b>Locator wizard (' . $self->getPageString() . ')</b>',
2581 0, 12, 0, 1);
2582  
2583 my $image = $self->addSimpleImage(
2584 $self->grid,
2585 $axmud::SHARE_DIR . '/icons/system/mapper_medium.png',
2586 undef,
2587 1, 6, 3, 10);
2588  
2589 $self->addLabel(
2590 $self->grid,
2591 "This wizard teaches the current world profile and the\ncurrent dictionary how to read"
2592 . " room statements (also\ncalled \'room descriptions\') in the game world.",
2593 7, 12, 3, 4);
2594  
2595 $self->addLabel(
2596 $self->grid,
2597 "The Locator task and the Automapper window <b>won\'t work\nat all</b> until the wizard"
2598 . " has finished (unless you are using a\npre-configured world).",
2599 7, 12, 5, 6);
2600  
2601 $self->addLabel(
2602 $self->grid,
2603 "Use the <b>Next</b> and <b>Previous</b> buttons to navigate between\npages.",
2604 7, 12, 7, 8);
2605  
2606 $self->addLabel(
2607 $self->grid,
2608 "(You can also configure world profiles and dictionaries\nby using their 'edit'"
2609 . " windows.)",
2610 7, 12, 9, 10);
2611  
2612 # Add a few empty labels to get the spacing right
2613 @list = (1, 2, 10, 11);
2614 foreach my $row (@list) {
2615  
2616 $self->addLabel($self->grid, '',
2617 1, 12, $row, ($row + 1));
2618 }
2619  
2620 return 1;
2621 }
2622  
2623 sub directionsPage {
2624  
2625 # Directions page - called by $self->setupGrid or ->updateGrid
2626 #
2627 # Expected arguments
2628 # (none besides $self)
2629 #
2630 # Return values
2631 # 'undef' on improper arguments
2632 # 1 otherwise
2633  
2634 my ($self, $check) = @_;
2635  
2636 # Local variables
2637 my (
2638 $row,
2639 @phrasebookList, @entryList, @entryAbbrevList, @dirList,
2640 );
2641  
2642 # Check for improper arguments
2643 if (defined $check) {
2644  
2645 return $axmud::CLIENT->writeImproper($self->_objClass . '->directionsPage', @_);
2646 }
2647  
2648 # Get a sorted list of phrasebook objects
2649 @phrasebookList = sort {$a->targetName cmp $b->targetName}
2650 ($axmud::CLIENT->ivValues('constPhrasebookHash'));
2651  
2652 # Primary directions
2653 $self->addLabel($self->grid, '<b>Primary directions (' . $self->getPageString() . ')</b>',
2654 0, 12, 0, 1);
2655  
2656 $self->addLabel(
2657 $self->grid,
2658 $axmud::SCRIPT . "\'s primary directions are the eight usual cardinal directions"
2659 . " (\'north\', \'east\', \'southwest\'\nand so on), the eight lesser-used cardinal"
2660 . " directions (\'eastnortheast\', \'southsouthwest\' and\nso on) plus the directions"
2661 . " \'up\' and \'down\'.",
2662 1, 12, 1, 2);
2663 $self->addLabel(
2664 $self->grid,
2665 "The Automapper window draws all exits as one of these primary directions. An exit"
2666 . " called\n\'north\' is always drawn pointing towards the top of the map,"
2667 . " but you can choose how exits\ncalled \'enter\', \'out\' and \'portal\' are drawn.",
2668 1, 12, 2, 3);
2669 $self->addLabel(
2670 $self->grid,
2671 "If the world\'s language is not English, or if it uses a different set of primary"
2672 . " directions, you\ncan set them below. Otherwise, just click the <b>Next</b> button.",
2673 1, 12, 3, 4);
2674  
2675 # Column titles, used twice so that 'northnortheast' (etc) appear towards the bottom
2676 $self->addLabel($self->grid, '<u>Primary direction</u>',
2677 1, 3, 4, 5);
2678 $self->addLabel($self->grid, '<u>Custom primary direction</u>',
2679 3, 6, 4, 5);
2680 $self->addLabel($self->grid, '<u>Custom abbreviation</u>',
2681 6, 9, 4, 5);
2682 $self->addLabel($self->grid, '<u>Primary direction</u>',
2683 1, 3, 15, 16);
2684 $self->addLabel($self->grid, '<u>Custom primary direction</u>',
2685 3, 6, 15, 16);
2686 $self->addLabel($self->grid, '<u>Custom abbreviation</u>',
2687 6, 9, 15, 16);
2688  
2689 # Entry boxes for each custom direction. Compose a list of directions, using the usual
2690 # eight cardinal directions first, then up/down, then the rarer cardinal directions
2691 @dirList = $axmud::CLIENT->constShortPrimaryDirList;
2692 foreach my $dir ($axmud::CLIENT->constPrimaryDirList) {
2693  
2694 if (! $axmud::CLIENT->ivExists('constShortPrimaryDirHash', $dir)) {
2695  
2696 push (@dirList, $dir);
2697 }
2698 }
2699  
2700 $row = 4;
2701 foreach my $standardDir (@dirList) {
2702  
2703 $row++;
2704 # Leave a gap between up/down and the rarer cardinal directions
2705 if ($standardDir eq 'northnortheast') {
2706  
2707 $row++;
2708 }
2709  
2710 $self->addLabel($self->grid, $standardDir,
2711 1, 3, $row, ($row + 1));
2712  
2713 my $entry = $self->addEntry(
2714 $self->grid,
2715 undef,
2716 $self->ivShow('customPrimaryDirHash', $standardDir),
2717 TRUE,
2718 3, 6, $row, ($row + 1));
2719 $entry->signal_connect('changed' => sub {
2720  
2721 my $text = $entry->get_text();
2722  
2723 if ($text) {
2724  
2725 $self->ivAdd('customPrimaryDirHash', $standardDir, $text);
2726  
2727 } else {
2728  
2729 # Don't overwrite the current dictionary's stored direction
2730 $self->ivAdd('customPrimaryDirHash', $standardDir, undef);
2731 }
2732  
2733 # Mark the IV as having been changed
2734 $self->ivAdd('ivChangeHash', 'customPrimaryDirHash', TRUE);
2735 });
2736 push (@entryList, $entry);
2737  
2738 my $entry2 = $self->addEntry(
2739 $self->grid,
2740 undef,
2741 $self->ivShow('customPrimaryAbbrevHash', $standardDir),
2742 TRUE,
2743 6, 9, $row, ($row + 1),
2744 8); # Restrict entry box width
2745 $entry2->signal_connect('changed' => sub {
2746  
2747 my $text = $entry2->get_text();
2748  
2749 if ($text) {
2750  
2751 $self->ivAdd('customPrimaryAbbrevHash', $standardDir, $text);
2752  
2753 } else {
2754  
2755 # Don't overwrite the current dictionary's stored direction
2756 $self->ivAdd('customPrimaryAbbrevHash', $standardDir, undef);
2757 }
2758  
2759 # Mark the IV as having been changed
2760 $self->ivAdd('ivChangeHash', 'customPrimaryAbbrevHash', TRUE);
2761 });
2762 push (@entryAbbrevList, $entry2);
2763 }
2764  
2765 # Reset directions button
2766 my $button = $self->addButton(
2767 $self->grid,
2768 undef,
2769 'Reset directions', 'Reset the lists of primary directions',
2770 9, 12, 4, 5);
2771 # ->signal_connect appears further down...
2772  
2773 $row = 4;
2774 foreach my $pbObj (@phrasebookList) {
2775  
2776 $row++;
2777  
2778 my $button2 = $self->addButton(
2779 $self->grid,
2780 undef,
2781 $pbObj->targetName,
2782 'Use ' . ucfirst($pbObj->name) . ' language directions',
2783 9, 12, $row, ($row + 1));
2784  
2785 $button2->signal_connect('clicked' => sub {
2786  
2787 $self->ivPoke('dirPageLang', $pbObj->name);
2788  
2789 for (my $count = 0; $count < 18; $count++) {
2790  
2791 my $index = $self->ivShow('indexConvertHash', $count);
2792  
2793 # Update the entry boxes, which automatically updates stored IVs
2794 $entryList[$index]->set_text($pbObj->ivIndex('primaryDirList', $count));
2795 $entryAbbrevList[$index]->set_text(
2796 $pbObj->ivIndex('primaryAbbrevDirList', $count),
2797 );
2798 }
2799 });
2800 }
2801  
2802 # ->signal_connect for the 'reset' button
2803 $button->signal_connect('clicked' => sub {
2804  
2805 my $index;
2806  
2807 # Reset the IVs ->customPrimaryDirHash and ->customPrimaryAbbrevHash
2808 $self->resetDirs();
2809  
2810 # Reset the language
2811 $self->ivUndef('dirPageLang');
2812  
2813 # There are eighteen (standard) primary directions
2814 $index = -1;
2815 foreach my $standardDir (@dirList) {
2816  
2817 $index++;
2818  
2819 # Update the entry boxes, which automatically updates stored IVs
2820 if (defined $self->ivShow('customPrimaryDirHash', $standardDir)) {
2821  
2822 $entryList[$index]->set_text(
2823 $self->ivShow('customPrimaryDirHash', $standardDir),
2824 );
2825 }
2826  
2827 if (defined $self->ivShow('customPrimaryAbbrevHash', $standardDir)) {
2828  
2829 $entryAbbrevList[$index]->set_text(
2830 $self->ivShow('customPrimaryAbbrevHash', $standardDir),
2831 );
2832 }
2833 }
2834  
2835 # Mark the IVs as not having been changed
2836 $self->ivAdd('ivChangeHash', 'customPrimaryDirHash', FALSE);
2837 $self->ivAdd('ivChangeHash', 'customPrimaryAbbrevHash', FALSE);
2838 });
2839  
2840 return 1;
2841 }
2842  
2843 sub dictionaryPage {
2844  
2845 # Dictionary page - called by $self->setupGrid or ->updateGrid
2846 #
2847 # Expected arguments
2848 # (none besides $self)
2849 #
2850 # Return values
2851 # 'undef' on improper arguments
2852 # 1 otherwise
2853  
2854 my ($self, $check) = @_;
2855  
2856 # Local variables
2857 my (
2858 $row,
2859 @phrasebookList,
2860 );
2861  
2862 # Check for improper arguments
2863 if (defined $check) {
2864  
2865 return $axmud::CLIENT->writeImproper($self->_objClass . '->dictionaryPage', @_);
2866 }
2867  
2868 # Get a sorted list of phrasebook objects
2869 @phrasebookList = sort {$a->targetName cmp $b->targetName}
2870 ($axmud::CLIENT->ivValues('constPhrasebookHash'));
2871  
2872 # Dictionary words
2873 $self->addLabel($self->grid, '<b>Dictionary words (' . $self->getPageString() . ')</b>',
2874 0, 12, 0, 1);
2875 $self->addLabel(
2876 $self->grid,
2877 "In order to work out what\'s in the current room, " . $axmud::SCRIPT
2878 . " tries to analyse lines like these:",
2879 1, 12, 1, 2);
2880 $self->addLabel(
2881 $self->grid,
2882 '<i>Three orcs, two lamps and a giraffe are here.</i>',
2883 2, 12, 2, 3);
2884 $self->addLabel(
2885 $self->grid,
2886 "Many worlds use the exact words \'five\', \'the\' and \'or\', but if this world"
2887 . " uses another set of\nwords, you can enter them below. Otherwise, just click the"
2888 . " <b>Next</b> button.",
2889 1, 12, 3, 4);
2890 $self->addLabel(
2891 $self->grid,
2892 "<b>Hint:</b> Each box should contain one word (or phrase) per line.",
2893 1, 12, 4, 5);
2894  
2895 # First column
2896 $self->addLabel($self->grid, '<u>Articles</u>',
2897 1, 3, 5, 6);
2898 $self->addLabel($self->grid, '<i>\'the\'</i>',
2899 1, 3, 6, 7);
2900 my $textView = $self->addTextView($self->grid, undef, undef, undef, TRUE,
2901 1, 3, 7, 11);
2902 my $buffer = $textView->get_buffer();
2903 if ($self->definiteList) {
2904  
2905 $buffer->set_text(join("\n", $self->definiteList));
2906 }
2907 $self->textViewSignalConnect($buffer, 'definiteList');
2908  
2909 $self->addLabel($self->grid, '<i>\'a / an\'</i>',
2910 1, 3, 11, 12);
2911 my $textView2 = $self->addTextView($self->grid, undef, undef, undef, TRUE,
2912 1, 3, 12, 16);
2913 my $buffer2 = $textView2->get_buffer();
2914 if ($self->indefiniteList) {
2915  
2916 $buffer2->set_text(join("\n", $self->indefiniteList));
2917 }
2918 $self->textViewSignalConnect($buffer2, 'indefiniteList');
2919  
2920 # Second column
2921 $self->addLabel($self->grid, '<u>Conjunctions</u>',
2922 3, 6, 5, 6);
2923 $self->addLabel($self->grid, '<i>\'and\'</i>',
2924 3, 6, 6, 7);
2925 my $textView3 = $self->addTextView($self->grid, undef, undef, undef, TRUE,
2926 3, 6, 7, 11);
2927 my $buffer3 = $textView3->get_buffer();
2928 if ($self->andList) {
2929  
2930 $buffer3->set_text(join("\n", $self->andList));
2931 }
2932 $self->textViewSignalConnect($buffer3, 'andList');
2933  
2934 $self->addLabel($self->grid, '<i>\'or\'</i>',
2935 3, 6, 11, 12);
2936 my $textView4 = $self->addTextView($self->grid, undef, undef, undef, TRUE,
2937 3, 6, 12, 16);
2938 my $buffer4 = $textView4->get_buffer();
2939 if ($self->orList) {
2940  
2941 $buffer4->set_text(join("\n", $self->orList));
2942 }
2943 $self->textViewSignalConnect($buffer4, 'orList');
2944  
2945 # Third column
2946 $self->addLabel($self->grid, '<u>Numbers</u>',
2947 6, 9, 5, 6);
2948 $self->addLabel($self->grid, '<i>\'one\' - \'ten\'</i>',
2949 6, 9, 6, 7);
2950 my $textView5 = $self->addTextView($self->grid, undef, undef, undef, TRUE,
2951 6, 9, 7, 16);
2952 my $buffer5 = $textView5->get_buffer();
2953 if ($self->numberList) {
2954  
2955 $buffer5->set_text(join("\n", $self->numberList));
2956 }
2957 $self->textViewSignalConnect($buffer5, 'numberList');
2958  
2959 # Fourth column
2960  
2961 # Reset list button
2962 my $button = $self->addButton(
2963 $self->grid,
2964 undef,
2965 'Reset words',
2966 'Reset the lists of words and phrases',
2967 9, 12, 5, 6);
2968 # ->signal_connect appears further down...
2969  
2970 # Add one button for each language supported by this object
2971 $row = 6;
2972 foreach my $pbObj (@phrasebookList) {
2973  
2974 $row++;
2975  
2976 my $button2 = $self->addButton(
2977 $self->grid,
2978 undef,
2979 $pbObj->targetName,
2980 'Use ' . ucfirst($pbObj->name) . ' language terms',
2981 9, 12, $row, ($row + 1));
2982  
2983 $button2->signal_connect('clicked' => sub {
2984  
2985 $self->ivPoke('dictPageLang', $pbObj->name);
2986  
2987 # Update the textviews
2988 $buffer->set_text(join("\n", $pbObj->definiteList));
2989 $buffer2->set_text(join("\n", $pbObj->indefiniteList));
2990 $buffer3->set_text(join("\n", $pbObj->andList));
2991 $buffer4->set_text(join("\n", $pbObj->orList));
2992 $buffer5->set_text(join("\n", $pbObj->numberList));
2993 });
2994 }
2995  
2996 # ->signal_connect for the 'reset' button
2997 $button->signal_connect('clicked' => sub {
2998  
2999 # Reset the IVs ->definiteList, ->indefiniteList, ->andList, ->orList and ->numberList
3000 $self->resetOtherWords();
3001  
3002 # Reset the language
3003 $self->ivUndef('dictPageLang');
3004  
3005 # Update the textviews
3006 $buffer->set_text(join("\n", $self->definiteList));
3007 $buffer2->set_text(join("\n", $self->indefiniteList));
3008 $buffer3->set_text(join("\n", $self->andList));
3009 $buffer4->set_text(join("\n", $self->orList));
3010 $buffer5->set_text(join("\n", $self->numberList));
3011  
3012 # Update the hash of changed IVs
3013 $self->ivAdd('ivChangeHash', 'definiteList', FALSE);
3014 $self->ivAdd('ivChangeHash', 'indefiniteList', FALSE);
3015 $self->ivAdd('ivChangeHash', 'andList', FALSE);
3016 $self->ivAdd('ivChangeHash', 'orList', FALSE);
3017 $self->ivAdd('ivChangeHash', 'numberList', FALSE);
3018 });
3019  
3020 return 1;
3021 }
3022  
3023 sub statementsPage {
3024  
3025 # Statements page - called by $self->setupGrid or ->updateGrid
3026 #
3027 # Expected arguments
3028 # (none besides $self)
3029 #
3030 # Return values
3031 # 'undef' on improper arguments
3032 # 1 otherwise
3033  
3034 my ($self, $check) = @_;
3035  
3036 # Check for improper arguments
3037 if (defined $check) {
3038  
3039 return $axmud::CLIENT->writeImproper($self->_objClass . '->statementsPage', @_);
3040 }
3041  
3042 $self->addLabel($self->grid, '<b>Room statements (' . $self->getPageString() . ')</b>',
3043 0, 12, 0, 1);
3044 $self->addLabel(
3045 $self->grid,
3046 "In " . $axmud::SCRIPT . " terminology, a \'room statement\' is a complete description"
3047 . " of a room. Each statement\nconsists of several different components which occur"
3048 . " in a predictable order.",
3049 1, 12, 1, 2);
3050 $self->addLabel(
3051 $self->grid,
3052 $axmud::SCRIPT . " distinguishes between \'verbose\', \'short verbose\' and \'brief\'"
3053 . " statements. The components\nof a \'verbose\' room statement usually include:",
3054 1, 12, 2, 3);
3055  
3056 # Example room taken from the DeadSouls mudlib
3057 $self->addLabel($self->grid, "<b>The room title</b>",
3058 1, 4, 3, 4);
3059 $self->addLabel($self->grid, "<i>Village Road Intersection</i>",
3060 5, 12, 3, 4);
3061  
3062 $self->addLabel($self->grid, "<b>The room description</b>",
3063 1, 4, 4, 5);
3064 $self->addLabel(
3065 $self->grid,
3066 "<i>You are in the main intersection of the village. Saquivor\nroad extends north and"
3067 . " south, intersected east to west\nby a road that leads west toward a wilderness, and"
3068 . " east\ntoward shore.</i>",
3069 5, 12, 4, 5);
3070  
3071 $self->addLabel($self->grid, "<b>The special contents list</b>",
3072 1, 4, 5, 6);
3073 $self->addLabel($self->grid, "<i>There is a sign here you can read.</i>",
3074 5, 12, 5, 6);
3075  
3076 $self->addLabel($self->grid, "<b>The exit list</b>",
3077 1, 4, 6, 7);
3078 $self->addLabel($self->grid, "<i>Obvious exits: south, north, east, west</i>",
3079 5, 12, 6, 7);
3080  
3081 $self->addLabel($self->grid, "<b>The contents list</b>",
3082 1, 4, 7, 8);
3083 $self->addLabel($self->grid, "<i>A great clock tower is here.</i>",
3084 5, 12, 7, 8);
3085  
3086 $self->addLabel(
3087 $self->grid,
3088 "A \'brief\' room statement often includes the following components:",
3089 1, 12, 8, 9);
3090  
3091 # Imaginary example
3092 $self->addLabel($self->grid, "<b>Room title/exit list</b>",
3093 1, 4, 9, 10);
3094 $self->addLabel($self->grid, "<i>Main intersection [s, n, e, w]</i>",
3095 5, 12, 9, 10);
3096  
3097 $self->addLabel($self->grid, "<b>The contents list</b>",
3098 1, 4, 10, 11);
3099 $self->addLabel($self->grid, "<i>A great clock tower is here.</i>",
3100 5, 12, 10, 11);
3101  
3102 $self->addLabel(
3103 $self->grid,
3104 "Alternatively, some worlds allow you to use \'short verbose\' room statements, which"
3105 . " are usually\njust like \'verbose\' room statements, but without the room"
3106 . " description component.",
3107 1, 12, 11, 12);
3108  
3109 $self->addLabel(
3110 $self->grid,
3111 "<b>You should now type the world\'s \'look\' command (or simply move to another room)"
3112 . "\nso that a <u>whole room statement</u> is visible - when you\'re ready, click on"
3113 . " \'Next\'.</b>",
3114 1, 12, 12, 13);
3115  
3116 return 1;
3117 }
3118  
3119 sub capturePage {
3120  
3121 # Capture page - called by $self->setupGrid or ->updateGrid
3122 #
3123 # Expected arguments
3124 # (none besides $self)
3125 #
3126 # Return values
3127 # 'undef' on improper arguments
3128 # 1 otherwise
3129  
3130 my ($self, $check) = @_;
3131  
3132 # Local variables
3133 my (
3134 $row,
3135 @labelList, @entryList, @comboList,
3136 );
3137  
3138 # Check for improper arguments
3139 if (defined $check) {
3140  
3141 return $axmud::CLIENT->writeImproper($self->_objClass . '->capturePage', @_);
3142 }
3143  
3144 # Add initial labels
3145 $self->addLabel(
3146 $self->grid,
3147 '<b>Room statement capture (' . $self->getPageString() . ')</b>',
3148 0, 12, 0, 1);
3149 $self->addLabel(
3150 $self->grid,
3151 "Starting from the top, please identify the component to which every line belongs.",
3152 1, 12, 1, 2);
3153  
3154 # Add some widgets immediately below the labels
3155 my $button = $self->addButton(
3156 $self->grid,
3157 undef,
3158 'Update lines',
3159 'Use the most recently-received lines',
3160 1, 3, 2, 3);
3161 my $button2 = $self->addButton(
3162 $self->grid,
3163 undef,
3164 'More lines',
3165 'Use more lines',
3166 3, 5, 2, 3);
3167 my $button3 = $self->addButton(
3168 $self->grid,
3169 undef,
3170 'Fewer lines',
3171 'Use fewer lines',
3172 5, 7, 2, 3);
3173  
3174 my ($radioButton, $radioButton2, $radioButton3, $group);
3175 ($group, $radioButton) = $self->addRadioButton(
3176 $self->grid,
3177 undef,
3178 undef,
3179 'Verbose',
3180 FALSE,
3181 TRUE,
3182 8, 10, 2, 3);
3183 ($group, $radioButton2) = $self->addRadioButton(
3184 $self->grid,
3185 undef,
3186 $group,
3187 'Short verbose',
3188 FALSE,
3189 TRUE,
3190 10, 11, 2, 3);
3191 ($group, $radioButton3) = $self->addRadioButton(
3192 $self->grid,
3193 undef,
3194 $group,
3195 'Brief',
3196 FALSE,
3197 TRUE,
3198 11, 12, 2, 3);
3199  
3200 # ->signal_connects appear further down...
3201 if ($self->analysisType eq 'short') {
3202 $radioButton2->set_active(TRUE);
3203 } elsif ($self->analysisType eq 'brief') {
3204 $radioButton3->set_active(TRUE);
3205 }
3206  
3207 # Set the row at which the remaining widgets start to be drawn
3208 $row = 3;
3209  
3210 # Add a list of entry and comboboxes, one for each line of recently-received text
3211 $self->capturePage_drawWidgets($row, \@labelList, \@entryList, \@comboList);
3212  
3213 # If no capture has yet been performed, set their initial values
3214 if (! $self->bufferObjList) {
3215  
3216 # No capture has yet been performed, so set their initial values
3217 $self->capturePage_resetWidgets(\@entryList, \@comboList);
3218  
3219 } else {
3220  
3221 # Show data in the entries and comboboxes from the previous capture
3222 $self->capturePage_updateWidgets(\@entryList, \@comboList);
3223 }
3224  
3225 # Give the comboboxes their own ->signal_connect methods
3226 $self->capturePage_connectCombos(\@comboList);
3227  
3228 # Here's the ->signal_connect methods from earlier
3229 $button->signal_connect('clicked' => sub {
3230  
3231 # 'Update list' button. Reset the list of lines recently received from the world
3232 $self->capturePage_resetWidgets(\@entryList, \@comboList);
3233 $self->capturePage_connectCombos(\@comboList);
3234 });
3235  
3236 $button2->signal_connect('clicked' => sub {
3237  
3238 # 'More lines' button. Add more lines to the number displayed, then re-draw the entries
3239 # and comboboxes.
3240 $self->ivPoke('analysisLength', $self->analysisLength + $self->analysisInc);
3241  
3242 # Prevent the user from setting more lines than the maximum by desensitising the button
3243 if ($self->analysisLength >= $self->analysisMaxLength) {
3244 $button2->set_sensitive(FALSE);
3245 } else {
3246 $button2->set_sensitive(TRUE);
3247 }
3248  
3249 # (The opposite button must be sensitised)
3250 $button3->set_sensitive(TRUE);
3251  
3252 # Redraw the entries and comboboxes
3253 $self->capturePage_drawWidgets($row, \@labelList, \@entryList, \@comboList);
3254 $self->capturePage_resetWidgets(\@entryList, \@comboList);
3255 $self->capturePage_connectCombos(\@comboList);
3256  
3257 # Make the changes visible
3258 $self->winShowAll($self->_objClass . '->capturePage');
3259 });
3260  
3261 $button3->signal_connect('clicked' => sub {
3262  
3263 # 'Fewer lines' button. Remove more lines to the number displayed, then re-draw the
3264 # entries and comboboxes.
3265 $self->ivPoke('analysisLength', $self->analysisLength - $self->analysisInc);
3266  
3267 # Prevent the user setting fewer lines than the minimum by desensitising the button
3268 if ($self->analysisLength <= $self->analysisMinLength) {
3269 $button3->set_sensitive(FALSE);
3270 } else {
3271 $button3->set_sensitive(TRUE);
3272 }
3273  
3274 # (The opposite button must be sensitised)
3275 $button2->set_sensitive(TRUE);
3276  
3277 # Redraw the entries and comboboxes
3278 $self->capturePage_drawWidgets($row, \@labelList, \@entryList, \@comboList);
3279 $self->capturePage_resetWidgets(\@entryList, \@comboList);
3280 $self->capturePage_connectCombos(\@comboList);
3281  
3282 # Make the changes visible
3283 $self->winShowAll($self->_objClass . '->capturePage');
3284 });
3285  
3286 $radioButton->signal_connect('toggled' => sub {
3287  
3288 if ($radioButton->get_active()) {
3289  
3290 $self->ivPoke('analysisType', 'verbose');
3291 }
3292  
3293 # Redraw the entries and comboboxes
3294 $self->capturePage_drawWidgets($row, \@labelList, \@entryList, \@comboList);
3295 $self->capturePage_resetWidgets(\@entryList, \@comboList);
3296 $self->capturePage_connectCombos(\@comboList);
3297  
3298 # Make the changes visible
3299 $self->winShowAll($self->_objClass . '->capturePage');
3300 });
3301  
3302 $radioButton2->signal_connect('toggled' => sub {
3303  
3304 if ($radioButton2->get_active()) {
3305  
3306 $self->ivPoke('analysisType', 'short');
3307 }
3308  
3309 # Redraw the entries and comboboxes
3310 $self->capturePage_drawWidgets($row, \@labelList, \@entryList, \@comboList);
3311 $self->capturePage_resetWidgets(\@entryList, \@comboList);
3312 $self->capturePage_connectCombos(\@comboList);
3313  
3314 # Make the changes visible
3315 $self->winShowAll($self->_objClass . '->capturePage');
3316 });
3317  
3318 $radioButton3->signal_connect('toggled' => sub {
3319  
3320 if ($radioButton3->get_active()) {
3321  
3322 $self->ivPoke('analysisType', 'brief');
3323 }
3324  
3325 # Redraw the entries and comboboxes
3326 $self->capturePage_drawWidgets($row, \@labelList, \@entryList, \@comboList);
3327 $self->capturePage_resetWidgets(\@entryList, \@comboList);
3328 $self->capturePage_connectCombos(\@comboList);
3329  
3330 # Make the changes visible
3331 $self->winShowAll($self->_objClass . '->capturePage');
3332 });
3333  
3334 return 1;
3335 }
3336  
3337 sub capturePage_drawWidgets {
3338  
3339 # Called by $self->capturePage
3340 # Draws a Gtk3::Entry and a Gtk3::Combobox, one for each line in the display buffer
3341 # displayed on this page
3342 #
3343 # Expected arguments
3344 # $startRow - The row on which the first entry/combobox is drawn
3345 # $labelListRef - Reference to a list of Gtk3::Labels at the beginning of each line
3346 # (an empty list if none have been drawn yet)
3347 # $entryListRef - Reference to a list of Gtk3::Entry boxes in which to display received
3348 # lines (an empty list if none have been drawn yet)
3349 # $comboListRef - Reference to a list of Gtk3::ComboBoxes in which to display components
3350 # (an empty list if none have been drawn yet)
3351 #
3352 # Return values
3353 # 'undef' on improper arguments
3354 # 1 otherwise
3355  
3356 my ($self, $startRow, $labelListRef, $entryListRef, $comboListRef, $check) = @_;
3357  
3358 # Local variables
3359 my $row;
3360  
3361 # Check for improper arguments
3362 if (
3363 ! defined $startRow || ! defined $labelListRef || ! defined $entryListRef
3364 || ! defined $comboListRef || defined $check
3365 ) {
3366 return $axmud::CLIENT->writeImproper(
3367 $self->_objClass . '->capturePage_drawWidgets',
3368 @_,
3369 );
3370 }
3371  
3372 # If any labels/entries/combo boxes have already been drawn, remove them from the grid
3373 if (@$labelListRef) {
3374  
3375 foreach my $label (@$labelListRef) {
3376  
3377 $axmud::CLIENT->desktopObj->removeWidget($self->grid, $label);
3378 }
3379  
3380 @$labelListRef = ();
3381  
3382 foreach my $entry (@$entryListRef) {
3383  
3384 $axmud::CLIENT->desktopObj->removeWidget($self->grid, $entry);
3385 }
3386  
3387 @$entryListRef = ();
3388  
3389 foreach my $comboBox (@$comboListRef) {
3390  
3391 $axmud::CLIENT->desktopObj->removeWidget($self->grid, $comboBox);
3392 }
3393  
3394 @$comboListRef = ();
3395 }
3396  
3397 # Add a list of entry boxes, one for each line
3398 $row = $startRow;
3399 for (my $line = 0; $line < $self->analysisLength; $line++) {
3400  
3401 $row++;
3402  
3403 my $label = $self->addLabel($self->grid, '#' . ($line + 1),
3404 1, 2, $row, ($row + 1));
3405  
3406 push (@$labelListRef, $label);
3407  
3408 my $entry = $self->addEntry($self->grid, undef, undef, TRUE,
3409 2, 9, $row, ($row + 1),
3410 40); # Fixed width
3411 # (Rather than desensitising the entry boxes, just make them un-editable)
3412 $entry->set_editable(FALSE);
3413  
3414 push (@$entryListRef, $entry);
3415 }
3416  
3417 # Add combo boxes, one for each entry box
3418 $row = $startRow;
3419 for (my $line = 0; $line < $self->analysisLength; $line++) {
3420  
3421 my (@componentList, @comboList);
3422  
3423 $row++;
3424  
3425 # The comboboxes show the default list of components (for verbose, short verbose or
3426 # brief statements)
3427 if ($self->analysisType eq 'verbose') {
3428 @componentList = $self->verboseComponentList;
3429 } elsif ($self->analysisType eq 'short') {
3430 @componentList = $self->shortComponentList;
3431 } elsif ($self->analysisType eq 'brief') {
3432 @componentList = $self->briefComponentList;
3433 }
3434  
3435 foreach my $component (@componentList) {
3436  
3437 push (@comboList, $self->ivShow('componentTypeHash', $component));
3438 }
3439  
3440 my $comboBox = $self->addComboBox($self->grid, undef, \@comboList, undef,
3441 9, 12, $row, ($row + 1));
3442  
3443 push (@$comboListRef, $comboBox);
3444 }
3445  
3446 return 1;
3447 }
3448  
3449 sub capturePage_resetWidgets {
3450  
3451 # Called by $self->capturePage, sometimes after a call to $self->capturePage_drawWidgets
3452 # Resets the entry/combo boxes (one for each line in the display buffer displayed on this
3453 # page)
3454 #
3455 # Expected arguments
3456 # $entryListRef - Reference to a list of Gtk3::Entry boxes in which to display received
3457 # lines
3458 # $comboListRef - Reference to a list of Gtk3::ComboBox-s in which to display components
3459 #
3460 # Return values
3461 # An empty list on improper arguments
3462 # Otherwise, returns the list of lines displayed
3463  
3464 my ($self, $entryListRef, $comboListRef, $check) = @_;
3465  
3466 # Local variables
3467 my (
3468 $startLine, $stopLine, $count,
3469 @emptyList, @entryList, @lineList,
3470 );
3471  
3472 # Check for improper arguments
3473 if (! defined $entryListRef || ! defined $comboListRef || defined $check) {
3474  
3475 $axmud::CLIENT->writeImproper($self->_objClass . '->capturePage_resetWidgets', @_);
3476 return @emptyList;
3477 }
3478  
3479 $self->ivEmpty('bufferObjList');
3480 $self->ivEmpty('bufferTypeList');
3481  
3482 # Show the last $self->analysisLength lines received by the world, but don't exceed the
3483 # boundaries of the display buffer
3484 if ($self->session->displayBufferCount) {
3485  
3486 $stopLine = $self->session->displayBufferLast;
3487 $startLine = $self->session->displayBufferLast - ($self->analysisLength - 1);
3488  
3489 if ($startLine < $self->session->displayBufferFirst) {
3490  
3491 # Don't look before the first line in the buffer
3492 $startLine = $self->session->displayBufferFirst;
3493 }
3494 }
3495  
3496 if ($startLine && $stopLine) {
3497  
3498 $count = -1;
3499  
3500 for (my $line = $startLine; $line <= $stopLine; $line++) {
3501  
3502 my ($bufferObj, $text, $entry);
3503  
3504 $count++;
3505  
3506 $bufferObj = $self->session->ivShow('displayBufferHash', $line);
3507 $text = $bufferObj->modLine;
3508  
3509 # Set the value displayed in the entry box numbered $count
3510 $entry = $$entryListRef[$count];
3511 $entry->set_text($text);
3512 push (@lineList, $text);
3513  
3514 # Update the record stored in the IV
3515 $self->ivPush('bufferObjList', $bufferObj);
3516 }
3517 }
3518  
3519 # Reset the comboboxes to contain the first component in the component list (which is
3520 # 'outside_statement' for verbose, short verbose and brief statements)
3521 foreach my $comboBox (@$comboListRef) {
3522  
3523 $comboBox->set_active(0);
3524  
3525 if ($self->analysisType eq 'verbose') {
3526 $self->ivPush('bufferTypeList', $self->ivFirst('verboseComponentList'));
3527 } elsif ($self->analysisType eq ' short') {
3528 $self->ivPush('bufferTypeList', $self->ivFirst('shortComponentList'));
3529 } else {
3530 $self->ivPush('bufferTypeList', $self->ivFirst('briefComponentList'));
3531 }
3532 }
3533  
3534 return @lineList;
3535 }
3536  
3537 sub capturePage_updateWidgets {
3538  
3539 # Called by $self->capturePage
3540 # Updates the entry/combo boxes (one for each line in the display buffer displayed on this
3541 # page) after the initial call to ->capturePage, in order to display data from the last
3542 # capture
3543 #
3544 # Expected arguments
3545 # $entryListRef - Reference to a list of Gtk3::Entry boxes in which to display received
3546 # lines
3547 # $comboListRef - Reference to a list of Gtk3::ComboBox-s in which to display components
3548 #
3549 # Return values
3550 # 'undef' on improper arguments
3551 # 1 otherwise
3552  
3553 my ($self, $entryListRef, $comboListRef, $check) = @_;
3554  
3555 # Local variables
3556 my (
3557 $count,
3558 @bufferObjList,
3559 );
3560  
3561 # Check for improper arguments
3562 if (! defined $entryListRef || ! defined $comboListRef || defined $check) {
3563  
3564 return $axmud::CLIENT->writeImproper(
3565 $self->_objClass . '->capturePage_updateWidgets',
3566 @_,
3567 );
3568 }
3569  
3570 # Import the previously-captured list of display buffer objects
3571 @bufferObjList = $self->bufferObjList;
3572  
3573 # Update the entry boxes
3574 $count = -1;
3575 foreach my $bufferObj (@bufferObjList) {
3576  
3577 my $entry;
3578  
3579 $count++;
3580  
3581 $entry = $$entryListRef[$count];
3582 $entry->set_text($bufferObj->modLine);
3583 }
3584  
3585 # Update the combos
3586 $count = -1;
3587 OUTER: foreach my $component ($self->bufferTypeList) {
3588  
3589 my ($combo, $posn);
3590  
3591 $count++;
3592 $combo = $$comboListRef[$count];
3593  
3594 if (defined $combo) {
3595  
3596 # Find the position of the component in the ordered list
3597 if ($self->analysisType eq 'verbose') {
3598 $posn = $self->ivFind('verboseComponentList', $component);
3599 } elsif ($self->analysisType eq 'short') {
3600 $posn = $self->ivFind('shortComponentList', $component);
3601 } else {
3602 $posn = $self->ivFind('briefComponentList', $component);
3603 }
3604  
3605 # Set the combobox to that position (if it was found)
3606 if (defined $posn) {
3607  
3608 $combo->set_active($posn);
3609 }
3610 }
3611 }
3612  
3613 return 1;
3614 }
3615  
3616 sub capturePage_connectCombos {
3617  
3618 # Called by $self->capturePage, usually after a call to ->capturePage_drawWidgets
3619 # Gives each combobox a ->signal_connect method
3620 #
3621 # Expected arguments
3622 # $comboListRef - Reference to a list of Gtk3::ComboBoxes in which to display components
3623 #
3624 # Return values
3625 # 'undef' on improper arguments
3626 # 1 otherwise
3627  
3628 my ($self, $comboListRef, $check) = @_;
3629  
3630 # Check for improper arguments
3631 if (! defined $comboListRef || defined $check) {
3632  
3633 return $axmud::CLIENT->writeImproper(
3634 $self->_objClass . '->capturePage_connectCombos',
3635 @_,
3636 );
3637 }
3638  
3639 OUTER: foreach my $comboBox (@$comboListRef) {
3640  
3641 $comboBox->signal_connect('changed' => sub {
3642  
3643 my ($textIndex, $match, $updateFlag);
3644  
3645 $textIndex = $comboBox->get_active();
3646  
3647 # Find the index of this combobox, as stored in $comboListRef
3648 INNER: for (my $count = 0; $count < $self->analysisLength; $count++) {
3649  
3650 if ($$comboListRef[$count] eq $comboBox) {
3651  
3652 $match = $count;
3653 last INNER;
3654 }
3655 }
3656  
3657 # Update the record stored in the IV
3658 if ($self->analysisType eq 'verbose') {
3659  
3660 $self->ivReplace(
3661 'bufferTypeList',
3662 $match,
3663 $self->ivIndex('verboseComponentList', $textIndex),
3664 );
3665  
3666 } elsif ($self->analysisType eq 'short') {
3667  
3668 $self->ivReplace(
3669 'bufferTypeList',
3670 $match,
3671 $self->ivIndex('shortComponentList', $textIndex),
3672 );
3673  
3674 } else {
3675  
3676 $self->ivReplace(
3677 'bufferTypeList',
3678 $match,
3679 $self->ivIndex('briefComponentList', $textIndex),
3680 );
3681 }
3682  
3683 # Change the contents of every combobox beneath this one to match
3684 if ($match < ($self->analysisLength - 1)) {
3685  
3686 $$comboListRef[$match + 1]->set_active($textIndex);
3687 }
3688 });
3689 }
3690  
3691 return 1;
3692 }
3693  
3694 sub analysisPage {
3695  
3696 # Analysis page - called by $self->setupGrid or ->updateGrid
3697 #
3698 # Expected arguments
3699 # (none besides $self)
3700 #
3701 # Return values
3702 # 'undef' on improper arguments
3703 # 1 otherwise
3704  
3705 my ($self, $check) = @_;
3706  
3707 # Local variables
3708 my ($result, $msg, $row, $string, $listRef, $bufferObj);
3709  
3710 # Check for improper arguments
3711 if (defined $check) {
3712  
3713 return $axmud::CLIENT->writeImproper($self->_objClass . '->analysisPage', @_);
3714 }
3715  
3716 $self->addLabel($self->grid, '<b>Analysis (' . $self->getPageString() . ')</b>',
3717 0, 12, 0, 1);
3718  
3719 # Perform the analysis of the data gathered in the previous page
3720 ($result, $msg) = $self->analyseLines();
3721  
3722 # Analysis failed
3723 if (! $result) {
3724  
3725 $self->addLabel($self->grid, 'Room statement analysis <u>FAILED</u>. Failure message:',
3726 1, 12, 1, 2);
3727 $self->addLabel($self->grid, '<i>' . $msg . '</i>',
3728 1, 12, 2, 3);
3729 $self->addLabel(
3730 $self->grid,
3731 "Try analysing a different room statement. Send your character to the new room,"
3732 . " then click\nthe <b>\'Previous\'</b> button to return to the previous page.",
3733 1, 12, 3, 4);
3734 $self->addLabel(
3735 $self->grid,
3736 "(N.B. The wizard uses a set of rules which are stricter than the normal rules. If"
3737 . " you want to\ndo something that\'s not allowed here, you can try editing the"
3738 . " world profile directly\nusing its 'edit' window.)",
3739 1, 12, 4, 5);
3740  
3741 # If the user had already analysed a room statement, allow them to move on to the last
3742 # page (skipping the next one); otherwise, de-sensitise the 'Next' button, forcing
3743 # them to go back
3744 if ($self->analysisCount) {
3745  
3746 # Allow moving on to the last page
3747 $self->addLabel(
3748 $self->grid,
3749 "If you\'re happy to use the results of previous analyses, click the"
3750 . " <b>\'Next\'</b> button to complete the\nsetup process.",
3751 1, 12, 5, 6);
3752  
3753 # Special rule for the \'next\' button: it returns to page 8
3754 $self->ivAdd('specialNextButtonHash', $self->currentPage, 7);
3755  
3756 } else {
3757  
3758 # Force the user to go back
3759 $self->ivPoke('disableNextButtonFlag', TRUE);
3760 }
3761  
3762 # Add a few empty labels, so that the paragraphs in the window aren't spaced so oddly
3763 for (my $row = 6; $row < 12; $row++) {
3764  
3765 $self->addLabel($self->grid, '',
3766 1, 12, $row, ($row + 1),
3767 );
3768 }
3769  
3770 return 1;
3771  
3772 # Analysis succeeded in verbose/short verbose mode
3773 } elsif ($self->analysisType eq 'verbose' || $self->analysisType eq 'short') {
3774  
3775 $self->ivIncrement('analysisCount');
3776  
3777 if ($self->analysisType eq 'verbose') {
3778 $string = 'Verbose';
3779 } else {
3780 $string = 'Short verbose';
3781 }
3782  
3783 $self->addLabel(
3784 $self->grid,
3785 "$string room statement analysis <u>successful</u>. If the results seems to be in"
3786 . " order, click the <b>\'Next\'</b>\nbutton to see the rest of the analysis.",
3787 1, 12, 1, 2);
3788 $self->addLabel(
3789 $self->grid,
3790 "Otherwise, try analysing a different room statement. Send your character to the"
3791 . " new room, then\nclick the <b>\'Previous\'</b> button to return to the previous"
3792 . " page.",
3793 1, 12, 2, 3);
3794  
3795 # Left column
3796 $self->addLabel($self->grid, '<i>Room title</i>',
3797 1, 6, 3, 4);
3798 my $entry = $self->addEntry($self->grid, undef, undef, TRUE,
3799 1, 6, 4, 5);
3800 $entry->set_editable(FALSE);
3801 if ($self->ivExists('analysisHash', 'verb_title')) {
3802  
3803 $listRef = $self->ivShow('analysisHash', 'verb_title');
3804 # The wizard requires that the 'verb_title' component is only one line
3805 $bufferObj = $self->ivIndex('bufferObjList', $$listRef[0]);
3806 $entry->set_text($bufferObj->modLine);
3807 }
3808 # Add a few empty labels below the entry for padding
3809 for (my $row = 5; $row < 7; $row++) {
3810  
3811 $self->addLabel($self->grid, '',
3812 1, 6, $row, ($row + 1),
3813 );
3814 }
3815  
3816 $self->addLabel($self->grid, '<i>Verbose description</i>',
3817 1, 6, 7, 8);
3818 my $textView = $self->addTextView($self->grid, undef, undef, undef, FALSE,
3819 1, 6, 8, 11);
3820 $self->updateTextView($textView, 'verb_descrip');
3821  
3822 # Right column
3823 $self->addLabel($self->grid, '<i>Exit list</i>',
3824 6, 12, 3, 4);
3825 my $textView2 = $self->addTextView($self->grid, undef, undef, undef, FALSE,
3826 6, 12, 4, 7);
3827 $self->updateTextView($textView2, 'verb_exit');
3828  
3829 $self->addLabel($self->grid, '<i>Individual exits</i>',
3830 6, 12, 7, 8);
3831 my $textView3 = $self->addTextView($self->grid, undef, undef, undef, FALSE,
3832 6, 12, 8, 11);
3833 if ($self->analysisExitList) {
3834  
3835 my $buffer3 = $textView3->get_buffer();
3836 $buffer3->set_text(join("\n", $self->analysisExitList));
3837 }
3838  
3839 return 1;
3840  
3841 # Analysis succeeded in brief mode
3842 } elsif ($self->analysisType eq 'brief') {
3843  
3844 my ($component, $button, $posn, $title);
3845  
3846 $self->ivIncrement('analysisCount');
3847  
3848 $self->addLabel(
3849 $self->grid,
3850 "Brief room statement analysis <u>successful</u>.",
3851 1, 12, 1, 2);
3852  
3853 # For convenience, set which component contains the exit line
3854 if ($self->ivExists('analysisHash', 'brief_title_exit')) {
3855 $component = 'brief_title_exit';
3856 } elsif ($self->ivExists('analysisHash', 'brief_exit_title')) {
3857 $component = 'brief_exit_title';
3858 } else {
3859 $component = 'brief_exit';
3860 }
3861  
3862 # If the 'brief_title_exit' or 'brief_exit_title' components were specified, prompt the
3863 # user to confirm which part of the line contains the room title
3864 if (
3865 (
3866 ! $self->ivExists('profUpdateHash', 'briefExitLeftMarkerList')
3867 && $component eq 'brief_title_exit'
3868 ) || (
3869 ! $self->ivExists('profUpdateHash', 'briefExitRightMarkerList')
3870 && $component eq 'brief_exit_title'
3871 )
3872 ) {
3873 # (The instructions don't need to be repeated, after the user has completed this
3874 # page once before)
3875 $self->addLabel(
3876 $self->grid,
3877 "Please confirm which part of the line containing the room title and exit list"
3878 . " is the room title\nitself, then click the <b>\'Test\'</b> button. For"
3879 . " example, in the line:",
3880 1, 12, 2, 3);
3881 $self->addLabel($self->grid, "<i>Town Centre (n, s, e, w)</i>",
3882 2, 12, 3, 4);
3883 $self->addLabel(
3884 $self->grid,
3885 "...you should copy and paste the <u>Town Centre</u> part (but not the first"
3886 . " bracket) into the box below.",
3887 1, 12, 4, 5);
3888  
3889 # Leave a small gap
3890 $row = 6;
3891  
3892 } else {
3893  
3894 # Leave a small gap
3895 $row = 3;
3896 }
3897  
3898 # (Each of the three components has only line)
3899 $listRef = $self->ivShow('analysisHash', $component);
3900 $bufferObj = $self->ivIndex('bufferObjList', $$listRef[0]);
3901  
3902 if ($component eq 'brief_title_exit') {
3903  
3904 $self->addLabel($self->grid, 'Room title / exit list',
3905 1, 3, $row, ($row + 1));
3906  
3907 } elsif ($component eq 'brief_exit_title') {
3908  
3909 $self->addLabel($self->grid, 'Exit list / room title',
3910 1, 3, $row, ($row + 1));
3911  
3912 } else {
3913  
3914 $self->addLabel($self->grid, 'Exit list',
3915 1, 3, $row, ($row + 1));
3916 }
3917  
3918 my $entry = $self->addEntry($self->grid, undef, $bufferObj->modLine, TRUE,
3919 4, 12, $row, ($row + 1));
3920 $entry->set_editable(FALSE);
3921  
3922 $self->addLabel($self->grid, 'Room title part',
3923 1, 3, ($row + 1), ($row + 2));
3924 my $entry2 = $self->addEntry($self->grid, undef, undef, TRUE,
3925 4, 12, ($row + 1), ($row + 2));
3926  
3927 # If this page has already been completed, we can fill in the room title part
3928 if (
3929 $self->ivExists('profUpdateHash', 'briefExitLeftMarkerList')
3930 && $component eq 'brief_title_exit'
3931 ) {
3932 # The room title is everything to the left of the marker
3933 $listRef = $self->ivShow('profUpdateHash', 'briefExitLeftMarkerList');
3934 OUTER: foreach my $marker (@$listRef) {
3935  
3936 $posn = index($bufferObj->modLine, $marker);
3937 if ($posn > -1) {
3938  
3939 $title = substr($bufferObj->modLine, 0, $posn);
3940 last OUTER;
3941 }
3942 }
3943  
3944 } elsif (
3945 $self->ivExists('profUpdateHash', 'briefExitRightMarkerList')
3946 && $component eq 'brief_exit_title'
3947 ) {
3948 # The room title is everything to the right of the marker
3949 $listRef = $self->ivShow('profUpdateHash', 'briefExitRightMarkerList');
3950 OUTER: foreach my $marker (@$listRef) {
3951  
3952 $posn = index($bufferObj->modLine, $marker);
3953 if ($posn > -1) {
3954  
3955 $title = substr($bufferObj->modLine, ($posn + length($marker)));
3956 last OUTER;
3957 }
3958 }
3959 }
3960  
3961 # Display the room title, if we have it
3962 if ($title) {
3963  
3964 $entry2->set_text($title);
3965 }
3966  
3967 $button = $self->addButton(
3968 $self->grid,
3969 undef,
3970 'Test',
3971 'Test the line containing the list of exits',
3972 1, 12, ($row + 2), ($row + 3));
3973 # ->signal_connect follows...
3974  
3975 # Middle left column
3976 $self->addLabel($self->grid, '<i>Room title</i>',
3977 1, 6, ($row + 3), ($row + 4));
3978 my $entry3 = $self->addEntry($self->grid, undef, undef, TRUE,
3979 1, 6, ($row + 4), ($row + 5));
3980 $entry3->set_editable(FALSE);
3981  
3982 # Middle right column
3983 $self->addLabel($self->grid, '<i>Individual exits</i>',
3984 6, 12, ($row + 3), ($row + 4));
3985 my $entry4 = $self->addEntry($self->grid, undef, undef, TRUE,
3986 6, 12, ($row + 4), ($row + 5));
3987 $entry4->set_editable(FALSE);
3988  
3989 # Bottom portion
3990 $self->addLabel(
3991 $self->grid,
3992 "If the results seem to be in order, click the <b>\'Next\'</b> button. Otherwise,"
3993 . " try analysing a\ndifferent room statement. Send your character to the new room,"
3994 . " then click the <b>\'Previous\'</b> button.",
3995 1, 12, ($row + 5), ($row + 6));
3996  
3997 if ($component eq 'brief_exit') {
3998  
3999 # Add a few empty labels to make the spacing between widgets better
4000 for (my $count = ($row + 5); $count < ($row + 9); $count++) {
4001  
4002 $self->addLabel($self->grid, '',
4003 1, 12, $count, ($count + 1));
4004 }
4005  
4006 } else {
4007  
4008 # Add just a single label to make the spacing between widgets better
4009 $self->addLabel($self->grid, '',
4010 1, 12, ($row + 5), ($row + 6));
4011 }
4012  
4013 # 'Test' button signal_connect
4014 $button->signal_connect('clicked' => sub {
4015  
4016 my (
4017 $lineText, $startText, $stopText, $qmStartText, $qmStopText, $errorMsg,
4018 $newStartText, $newStopText, $foundFlag, $pattern,
4019 @exitList,
4020 );
4021  
4022 $title = $entry2->get_text();
4023 if ($title) {
4024  
4025 # The line stored in $bufferObj->modLine is in the form
4026 # <start_text><exit><delimiter><exit><delimiter><exit><stop_text>
4027 # For the 'brief_title_exit' component, the room title will be somewhere in
4028 # <start_text>; for the 'brief_exit_title' component, the room title will be
4029 # somewhere in <stop_text>.
4030 # The remainding portions of <start_text> and <stop_text> will comprise the
4031 # brief exit markers stored in GA::Profile::World->briefExitLeftMarkerList and
4032 # ->briefExitRightMarkerList
4033 $lineText = $bufferObj->modLine;
4034 $startText = $newStartText = $self->tempStartText;
4035 $stopText = $newStopText = $self->tempStopText;
4036 $qmStartText = quotemeta($startText);
4037 $qmStopText = quotemeta($stopText);
4038  
4039 $errorMsg = 'Test failed (usually because the room title contains a direction,'
4040 . ' e.g. \'The northeast corner of the square\').'
4041 . ' Click the \'Previous\' button and try a room with a'
4042 . ' different title.';
4043  
4044 if ($component eq 'brief_title_exit' && $lineText =~ m/$qmStartText/) {
4045  
4046 # Remove everything up to and including the room title, leaving the rest as
4047 # the left marker
4048 $posn = index($startText, $title);
4049 if ($posn < 0) {
4050  
4051 $self->showMsgDialogue(
4052 'Room title test',
4053 'error',
4054 $errorMsg,
4055 'ok',
4056 );
4057  
4058 } else {
4059  
4060 $newStartText = substr($startText, ($posn + (length $title)));
4061 $foundFlag = TRUE;
4062 }
4063  
4064 } elsif ($component eq 'brief_exit_title' && $lineText =~ m/$qmStopText/) {
4065  
4066 # Remove everything from the room title onwards, leaving the rest as the
4067 # right marker
4068 $posn = index($stopText, $title);
4069 if ($posn < 0) {
4070  
4071 $self->showMsgDialogue(
4072 'Test brief title/exit',
4073 'error',
4074 $errorMsg,
4075 'ok',
4076 );
4077  
4078 } else {
4079  
4080 $newStopText = substr($stopText, 0, $posn);
4081 $foundFlag = TRUE;
4082 }
4083 }
4084  
4085 if ($foundFlag) {
4086  
4087 # Try to extract a list of exits, ready for display. Remove the
4088 # <start_text> and <stop_text> parts from the line...
4089 $lineText =~ s/$qmStartText//;
4090 $lineText =~ s/$qmStopText//;
4091 @exitList = $self->testExtractExits($lineText);
4092  
4093 if (@exitList) {
4094  
4095 # Success! Update $self->profUpdateHash
4096 $self->profileUpdatePush(
4097 'briefExitLeftMarkerList',
4098 quotemeta($newStartText),
4099 );
4100  
4101 $self->profileUpdatePush(
4102 'briefExitRightMarkerList',
4103 quotemeta($newStopText),
4104 );
4105  
4106 $self->profileUpdatePush(
4107 'briefExitDelimiterList',
4108 $self->tempDelimList,
4109 );
4110  
4111 # Update the entry boxes
4112 $entry3->set_text($title);
4113 $entry4->set_text(join(' ', @exitList));
4114  
4115 # As we did for 'brief_exit', compile a regex in the form
4116 # '<start_text>(.*)<stop_text>'
4117 $pattern = quotemeta($newStartText) . '(.*)' . quotemeta($newStopText);
4118 # To cope with a <start_text> part (or even a <stop_text> part) which is
4119 # 'There are four obvious exits:', go through the pattern, removing
4120 # any number words (or numerals!)
4121 $pattern = $self->processPattern($pattern);
4122 # Store the results
4123 $self->profileUpdatePush('briefAnchorPatternList', $pattern);
4124 $self->ivAdd('profUpdateHash', 'briefAnchorOffset', 1);
4125  
4126 # For consistency, also store the analysed exit list
4127 $self->ivPoke('analysisExitList', @exitList);
4128 }
4129 }
4130 }
4131 });
4132  
4133 # For the 'brief_exit' component, there is no room title to display, so desensitise the
4134 # entry boxes and the 'Test' button
4135 if ($component eq 'brief_exit') {
4136  
4137 $entry2->set_sensitive(FALSE);
4138 $entry3->set_sensitive(FALSE);
4139 $button->set_sensitive(FALSE);
4140  
4141 # Also fill $entry4, as if the 'Text' button had already been clicked
4142 $entry4->set_text(join(' ', $self->analysisExitList));
4143 }
4144  
4145 return 1;
4146 }
4147 }
4148  
4149 sub analysis2Page {
4150  
4151 # Analysis2 page - called by $self->setupGrid or ->updateGrid
4152 #
4153 # Expected arguments
4154 # (none besides $self)
4155 #
4156 # Return values
4157 # 'undef' on improper arguments
4158 # 1 otherwise
4159  
4160 my ($self, $check) = @_;
4161  
4162 # Local variables
4163 my ($component, $listRef);
4164  
4165 # Check for improper arguments
4166 if (defined $check) {
4167  
4168 return $axmud::CLIENT->writeImproper($self->_objClass . '->analysis2Page', @_);
4169 }
4170  
4171 # Contents analysis
4172 $self->addLabel($self->grid, '<b>Contents analysis (' . $self->getPageString() . ')</b>',
4173 0, 12, 0, 1);
4174 $self->addLabel(
4175 $self->grid,
4176 $axmud::SCRIPT . " needs some more details so it can analyse lists of objects. For"
4177 . " example, in the line:",
4178 1, 12, 1, 2);
4179 $self->addLabel(
4180 $self->grid,
4181 '<i>Three orcs, two lamps and a giraffe are here.</i>',
4182 2, 12, 2, 3);
4183 $self->addLabel(
4184 $self->grid,
4185 "..." . $axmud::SCRIPT . " needs to know that the pattern <i>\'are here\'</i> means"
4186 . " that there are objects in this room.",
4187 1, 12, 3, 4);
4188 $self->addLabel(
4189 $self->grid,
4190 "Please examine the contents list on the left (it will be empty if you didn\'t allocate"
4191 . " any contents).\nIf the box on the right doesn\'t contain the correct patterns"
4192 . " (regular expressions), you can add them now.",
4193 1, 12, 4, 5);
4194  
4195 if ($self->ivExists('analysisHash', 'verb_content')) {
4196 $component = 'verb_content';
4197 } elsif ($self->ivExists('analysisHash', 'brief_content')) {
4198 $component = 'brief_content';
4199 }
4200  
4201 # Left column
4202 $self->addLabel($self->grid, '<i>Room statement\'s contents list</i>',
4203 1, 6, 5, 6);
4204 my $textView = $self->addTextView($self->grid, undef, undef, undef, FALSE,
4205 1, 6, 6, 7);
4206 my $buffer = $textView->get_buffer();
4207 if ($component && ($component eq 'verb_content' || $component eq 'brief_content')) {
4208  
4209 $self->updateTextView($textView, $component);
4210 }
4211  
4212 # Right column
4213 $self->addLabel($self->grid, '<i>Marker patterns (e.g. \'is here.\')</i>',
4214 6, 12, 5, 6);
4215 my $textView2 = $self->addTextView($self->grid, undef, undef, undef, TRUE,
4216 6, 12, 6, 7);
4217 my $buffer2 = $textView2->get_buffer();
4218 if ($self->markerList) {
4219  
4220 $buffer2->set_text(join("\n", $self->markerList));
4221 }
4222 $self->textViewSignalConnect($buffer2, 'markerList');
4223  
4224 # Bottom area
4225 if ($component) {
4226  
4227 $self->addLabel(
4228 $self->grid,
4229 "If you like, you can test the patterns by clicking the <b>\'Test\'</b> button."
4230 . " When you\'re satisfied,\nclick the <b>\'Next\'</b> button at the bottom of the"
4231 . " window.",
4232 1, 9, 7, 8);
4233 my $button = $self->addButton(
4234 $self->grid,
4235 undef,
4236 'Test',
4237 'Test the contents patterns',
4238 9, 12, 7, 8);
4239 # ->signal_connect appears just below...
4240  
4241 my $textView3 = $self->addTextView($self->grid, undef, undef, undef, FALSE,
4242 1, 12, 8, 9);
4243 my $buffer3 = $textView3->get_buffer();
4244  
4245 $button->signal_connect('clicked' => sub {
4246  
4247 my (@stringList, @modList);
4248  
4249 # Use the standard object parsing code to convert the room's contents list into
4250 # a list of non-model objects
4251 $listRef = $self->ivShow('analysisHash', $component);
4252  
4253 foreach my $line (@$listRef) {
4254  
4255 my $bufferObj = $self->ivIndex('bufferObjList', $line);
4256 push (@stringList, $bufferObj->modLine);
4257 }
4258  
4259 # We can't use GA::Obj::WorldModel->parseObj, because that function uses the
4260 # current world's ->contentPatternList - whereas we want to test the new content
4261 # markers in $textView2
4262 # For each line in turn, perform a substitution - but only once per line
4263 OUTER: foreach my $string (@stringList) {
4264  
4265 INNER: foreach my $regex ($self->markerList) {
4266  
4267 if ($string =~ m/$regex/) {
4268  
4269 $string =~ s/$regex//;
4270 next OUTER;
4271 }
4272 }
4273 }
4274  
4275 $buffer3->set_text(join("\n", @stringList));
4276 });
4277  
4278 } else {
4279  
4280 $self->addLabel(
4281 $self->grid,
4282 "When you\'re ready, click the \'Next\' button at the bottom of the window.",
4283 1, 12, 7, 8);
4284 }
4285  
4286 return 1;
4287 }
4288  
4289 sub lastPage {
4290  
4291 # Last page - called by $self->setupGrid or ->updateGrid
4292 #
4293 # Expected arguments
4294 # (none besides $self)
4295 #
4296 # Return values
4297 # 'undef' on improper arguments
4298 # 1 otherwise
4299  
4300 my ($self, $check) = @_;
4301  
4302 # Local variables
4303 my (@verboseList, @shortList, @briefList);
4304  
4305 # Check for improper arguments
4306 if (defined $check) {
4307  
4308 return $axmud::CLIENT->writeImproper($self->_objClass . '->lastPage', @_);
4309 }
4310  
4311 $self->addLabel($self->grid, '<b>Checklist (' . $self->getPageString() . ')</b>',
4312 0, 12, 0, 1);
4313 $self->addLabel(
4314 $self->grid,
4315 "The world profile will now be updated to use the components displayed below. The"
4316 . " current\ndictionary will also be updated with any modifications you made earlier.",
4317 1, 12, 1, 2);
4318 $self->addLabel(
4319 $self->grid,
4320 "Click <b>\'Finish\'</b> to complete the setup process or click <b>\'Previous\'</b> to"
4321 . " capture another room\nstatement.",
4322 1, 12, 2, 3);
4323  
4324 # Left column
4325 $self->addLabel($self->grid, '<u>Verbose statements</u>',
4326 1, 4, 3, 4);
4327 my $checkButton = $self->addCheckButton(
4328 $self->grid, 'Analysis complete', undef, FALSE, FALSE,
4329 1, 4, 4, 5);
4330 if ($self->verboseComponentObjList) {
4331  
4332 $checkButton->set_active(TRUE);
4333 }
4334  
4335 my $checkButton2 = $self->addCheckButton(
4336 $self->grid, 'Set in profile', undef, FALSE, FALSE,
4337 1, 4, 5, 6);
4338 if ($self->session->currentWorld->verboseComponentList) {
4339  
4340 $checkButton2->set_active(TRUE);
4341 }
4342  
4343 $self->addLabel($self->grid, 'Component list:',
4344 1, 4, 6, 7);
4345 my $textView = $self->addTextView($self->grid, undef, undef, undef, FALSE,
4346 1, 4, 7, 10);
4347 my $buffer = $textView->get_buffer();
4348 foreach my $componentObj ($self->verboseComponentObjList) {
4349  
4350 push (@verboseList, $componentObj->name);
4351 }
4352 $buffer->set_text(join("\n", @verboseList));
4353  
4354 # Middle column
4355 $self->addLabel($self->grid, '<u>Short verbose statements</u>',
4356 5, 8, 3, 4);
4357 my $checkButton3 = $self->addCheckButton(
4358 $self->grid, 'Analysis complete', undef, FALSE, FALSE,
4359 5, 8, 4, 5);
4360 if ($self->shortComponentObjList) {
4361  
4362 $checkButton3->set_active(TRUE);
4363 }
4364  
4365 my $checkButton4 = $self->addCheckButton(
4366 $self->grid, 'Set in profile', undef, FALSE, FALSE,
4367 5, 8, 5, 6);
4368 if ($self->session->currentWorld->shortComponentList) {
4369  
4370 $checkButton4->set_active(TRUE);
4371 }
4372  
4373 $self->addLabel($self->grid, 'Component list:',
4374 5, 8, 6, 7);
4375 my $textView2 = $self->addTextView($self->grid, undef, undef, undef, FALSE,
4376 5, 8, 7, 10);
4377 my $buffer2 = $textView2->get_buffer();
4378 foreach my $componentObj ($self->shortComponentObjList) {
4379  
4380 push (@shortList, $componentObj->name);
4381 }
4382 $buffer2->set_text(join("\n", @shortList));
4383  
4384 # Right column
4385 $self->addLabel($self->grid, '<u>Brief statements</u>',
4386 9, 12, 3, 4);
4387 my $checkButton5 = $self->addCheckButton(
4388 $self->grid, 'Analysis complete', undef, FALSE, FALSE,
4389 9, 12, 4, 5);
4390 if ($self->briefComponentObjList) {
4391  
4392 $checkButton5->set_active(TRUE);
4393 }
4394  
4395 my $checkButton6 = $self->addCheckButton(
4396 $self->grid, 'Set in profile', undef, FALSE, FALSE,
4397 9, 12, 5, 6);
4398 if ($self->session->currentWorld->briefComponentList) {
4399  
4400 $checkButton6->set_active(TRUE);
4401 }
4402  
4403 $self->addLabel($self->grid, 'Component list:',
4404 9, 12, 6, 7);
4405 my $textView3 = $self->addTextView($self->grid, undef, undef, undef, FALSE,
4406 9, 12, 7, 10);
4407 my $buffer3 = $textView3->get_buffer();
4408 foreach my $componentObj ($self->briefComponentObjList) {
4409  
4410 push (@briefList, $componentObj->name);
4411 }
4412 $buffer3->set_text(join("\n", @briefList));
4413  
4414 # Special rule for the \'previous\' button: it returns to page 5
4415 $self->ivAdd('specialPreviousButtonHash', $self->currentPage, 4);
4416  
4417 return 1;
4418 }
4419  
4420 # Support functions
4421  
4422 sub resetDirs {
4423  
4424 # Called by $self->new or ->directionsPage
4425 # Sets (or resets) several direction IVs
4426 #
4427 # Expected arguments
4428 # (none besides $self)
4429 #
4430 # Return values
4431 # 'undef' on improper arguments
4432 # 1 otherwise
4433  
4434 my ($self, $check) = @_;
4435  
4436 # Check for improper arguments
4437 if (defined $check) {
4438  
4439 return $axmud::CLIENT->writeImproper($self->_objClass . '->resetDirs', @_);
4440 }
4441  
4442 $self->ivPoke('customPrimaryDirHash', $self->session->currentDict->primaryDirHash);
4443 $self->ivPoke('customPrimaryAbbrevHash', $self->session->currentDict->primaryAbbrevHash);
4444  
4445 return 1;
4446 }
4447  
4448 sub resetOtherWords {
4449  
4450 # Called by $self->new or ->dictionaryPage
4451 # Sets (or resets) word and phrase IVs
4452 #
4453 # Expected arguments
4454 # (none besides $self)
4455 #
4456 # Return values
4457 # 'undef' on improper arguments
4458 # 1 otherwise
4459  
4460 my ($self, $check) = @_;
4461  
4462 # Local variables
4463 my (
4464 $dictObj,
4465 @numberList,
4466 %numberHash, %newHash,
4467 );
4468  
4469 # Check for improper arguments
4470 if (defined $check) {
4471  
4472 return $axmud::CLIENT->writeImproper($self->_objClass . '->resetOtherWords', @_);
4473 }
4474  
4475 # Import the current dictionary (for convenience)
4476 $dictObj = $self->session->currentDict;
4477  
4478 # Set/reset IVs
4479 $self->ivPoke('definiteList', $dictObj->definiteList);
4480 $self->ivPoke('indefiniteList', $dictObj->indefiniteList);
4481 $self->ivPoke('andList', $dictObj->andList);
4482 $self->ivPoke('orList', $dictObj->orList);
4483  
4484 # $self->numberList is a bit trickier. Import %numberHash, in the form
4485 # $hash{word} = numeral
4486 %numberHash = $dictObj->numberHash;
4487 # Check every key-value pair, looking for the first occurence of each numeral from
4488 # 1 to 10
4489 OUTER: for (my $count = 1; $count <= 10; $count++) {
4490  
4491 INNER: foreach my $key (%numberHash) {
4492  
4493 my $value = $numberHash{$key};
4494  
4495 if (defined $value && $value == $count) {
4496  
4497 if ($newHash{$value}) {
4498  
4499 # We've already added this numeral
4500 next INNER;
4501  
4502 } else {
4503  
4504 # Use this numeral
4505 $newHash{$value} = undef;
4506 push (@numberList, $key);
4507 last INNER;
4508 }
4509 }
4510 }
4511 }
4512  
4513 $self->ivPoke('numberList', @numberList);
4514  
4515 return 1;
4516 }
4517  
4518 sub analyseLines {
4519  
4520 # Called by $self->analysisPage to analyse a room statement gathered in the 'Capture' page
4521 # Analyses the room statement. First performs some checks, and returns an error message if
4522 # any of the checks fail. Otherwise, calls $self->analyseComponent for each component in
4523 # turn
4524 #
4525 # Expected arguments
4526 # (none besides $self)
4527 #
4528 # Return values
4529 # Returns an empty list on improper arguments
4530 # Otherwise, returns a list in the form (1, undef) on success, or (undef, failure_message)
4531 # on failure
4532  
4533 my ($self, $check) = @_;
4534  
4535 # Local variables
4536 my (
4537 $count, $msg, $previous, $anchorLineIndex, $anchorComponent, $flag,
4538 @emptyList, @componentList, @componentObjList,
4539 %analysisHash,
4540 );
4541  
4542 # Check for improper arguments
4543 if (defined $check) {
4544  
4545 $axmud::CLIENT->writeImproper($self->_objClass . '->analyseLines', @_);
4546 return @emptyList;
4547 }
4548  
4549 # The statement's components are spread across up to $self->analysisLength lines
4550 # Divide these lines into groups, one for each component, by compiling a hash in the form
4551 # $hash{component_name} = reference_to_list_of_lines
4552 # Store the hash as $self->analysisHash
4553 $self->collectComponentGroups();
4554  
4555 # For speed, import $self->analysisHash
4556 %analysisHash = $self->analysisHash;
4557  
4558 # Check 1: The wizard uses the first line of the first component containing exits as the
4559 # the anchor line (the user can, of course, designate any part of the room statement as
4560 # the anchor line by using the world profile's 'edit' window)
4561 # There must be exactly one (no more, no less) components containing exits
4562 $count = 0;
4563 foreach my $component (keys %analysisHash) {
4564  
4565 if (
4566 $component eq 'verb_exit' || $component eq 'brief_exit'
4567 || $component eq 'brief_title_exit' || $component eq 'brief_exit_title'
4568 ) {
4569 $count++;
4570 }
4571 }
4572  
4573 if (! $count) {
4574  
4575 $msg = "At least one line must be marked as containing exits (currently, no lines are"
4576 . " marked as\nbelonging to one of the components that contains exits).",
4577  
4578 return (0, $msg);
4579  
4580 } elsif ($count > 1) {
4581  
4582 $msg = "No more than one component containing exits can be specified (you specified "
4583 . $count . " components\nwhich contain exits).";
4584  
4585 return (0, $msg);
4586 }
4587  
4588 # Check 2: There must be either 0 or 1 components containing the room title (specifically,
4589 # the user can't have both 'brief_title' and 'brief_title_exit' / 'brief_exit_title')
4590 $count = 0;
4591 foreach my $component (keys %analysisHash) {
4592  
4593 if (
4594 $component eq 'verb_title' || $component eq 'brief_title'
4595 || $component eq 'brief_title_exit' || $component eq 'brief_exit_title'
4596 ) {
4597 $count++;
4598 }
4599 }
4600  
4601 if ($count > 1) {
4602  
4603 $msg = "No more than one component containing the room title can be specified (you"
4604 . " specified " . $count . "\ncomponents which contain a room title).";
4605  
4606 return (0, $msg);
4607 }
4608  
4609 # Check 3: The wizard requires that some components are a maximum of one line long (the user
4610 # is free, once again, to specify any size in the world profile's 'edit' window)
4611 foreach my $component (keys %analysisHash) {
4612  
4613 my $listRef;
4614  
4615 if (
4616 $component eq 'verb_title' || $component eq 'brief_title'
4617 || $component eq 'brief_exit' || $component eq 'brief_title_exit'
4618 || $component eq 'brief_exit_title'
4619 ) {
4620 $listRef = $analysisHash{$component};
4621  
4622 if (@$listRef > 1) {
4623  
4624 $msg = "Components which contain the room title cannot be longer than 1 line.",
4625  
4626 return (0, $msg);
4627 }
4628 }
4629 }
4630  
4631 # Check 4: The wizard requires that most components are contiguous; i.e. you can't have the
4632 # verbose description on lines 2, 3 and 8 (the user is free, once again, to specify
4633 # non-contiguous components in the world profile's 'edit' window)
4634 # However, the 'outside_statement' and 'ignore_line' don't have to be contiguous
4635 foreach my $component (keys %analysisHash) {
4636  
4637 my ($listRef, $previousLine);
4638  
4639 # Two components are allowed to be split up...
4640 if ($component ne 'outside_statement' && $component ne 'ignore_line') {
4641  
4642 $listRef = $analysisHash{$component};
4643  
4644 foreach my $line (@$listRef) {
4645  
4646 if (defined $previousLine && $line != ($previousLine + 1)) {
4647  
4648 # The component is not contiguous
4649 $msg = "Components can\'t be split up - for example, you can\'t have a"
4650 . " description component on\nlines 2, 3, and 8. (Exception:"
4651 . " \'ignore\' lines can be placed anywhere.)";
4652 return (0, $msg);
4653  
4654 } else {
4655  
4656 $previousLine = $line;
4657 }
4658 }
4659 }
4660 }
4661  
4662 # Check 5: the user may have used 'ignore_line' rather than 'outside_statement' at the
4663 # beginning and end of the list. Convert the former to the latter
4664 $self->convertIgnoreLines();
4665  
4666 # Check 6: there must be no more than 2 'outside_component' groups - one starting at the
4667 # first line, one ending at the last line. ('ignore_line' can be used anywhere, in any
4668 # order)
4669 if (! $self->checkOutsideGroups()) {
4670  
4671 $msg = "You can\'t mark a line in the middle of the room statement as being outside it."
4672 . " Try marking\nthem as lines to ignore, instead.";
4673 return (0, $msg);
4674 }
4675  
4676 # Get a list of components, in the order in which they occur
4677 foreach my $component ($self->bufferTypeList) {
4678  
4679 if (
4680 ! $previous # This is the first component
4681 || $component ne $previous # This is the next component
4682 ) {
4683 push (@componentList, $component);
4684 $previous = $component;
4685 }
4686 }
4687  
4688 # Decide which line is going to be the anchor line (it's the first line of the first
4689 # component containing exits)
4690 OUTER: for (my $line = 0; $line < $self->analysisLength; $line++) {
4691  
4692 my $component;
4693  
4694 if (defined $self->ivIndex('bufferObjList', $line)) {
4695  
4696 $component = $self->ivIndex('bufferTypeList', $line);
4697  
4698 if (
4699 $component eq 'verb_exit' || $component eq 'brief_exit'
4700 || $component eq 'brief_title_exit' || $component eq 'brief_exit_title'
4701 ) {
4702 # This is the anchor line. $anchorLineIndex records its position in
4703 # $self->bufferObjList (not the number of the display buffer line itself)
4704 $anchorLineIndex = $line;
4705 $anchorComponent = $component;
4706 last OUTER;
4707 }
4708 }
4709 }
4710  
4711 # For each component in turn, create a GA::Obj::Component object
4712 foreach my $component (@componentList) {
4713  
4714 my ($componentObj, $listRef);
4715  
4716 # Don't analyse the 'outside_statement' component, obviously
4717 if ($component ne 'outside_statement') {
4718  
4719 $listRef = $analysisHash{$component};
4720  
4721 ($componentObj, $msg) = $self->analyseComponent(
4722 $anchorLineIndex,
4723 $component,
4724 @$listRef,
4725 );
4726  
4727 if (! $componentObj) {
4728  
4729 return (undef, $msg);
4730  
4731 } else {
4732  
4733 push (@componentObjList, $componentObj);
4734 }
4735 }
4736 }
4737  
4738 # Store the list of component objects
4739 if ($self->analysisType eq 'verbose') {
4740 $self->ivPoke('verboseComponentObjList', @componentObjList);
4741 } elsif ($self->analysisType eq 'short') {
4742 $self->ivPoke('shortComponentObjList', @componentObjList);
4743 } elsif ($self->analysisType eq 'brief') {
4744 $self->ivPoke('briefComponentObjList', @componentObjList);
4745 }
4746  
4747 # Analysis successful!
4748 return (1, undef);
4749 }
4750  
4751 sub analyseComponent {
4752  
4753 # Called by $self->analyseLines to analyse one or more lines comprising a single component
4754 # Analyses the lines. If successful, creates a new GA::Obj::Component object for the
4755 # component and sets other IVs ready for them to be copied into the world profile. If not
4756 # successful, returns an error message for ->analysisPage to display
4757 #
4758 # Expected arguments
4759 # $anchorLineIndex - The index of $self->bufferObjList that contains the buffer object
4760 # for the anchor line
4761 # $component - The component's type, e.g. 'verb_title'
4762 # @indexList - A list of of indexes in $self->bufferObjList, each one
4763 # corresponding to a GA::Buffer::Display object. Each index is in
4764 # the range 0 to ($self->analysisLength - 1)
4765 #
4766 # Return values
4767 # Returns an empty list on improper arguments
4768 # Otherwise, returns a list in the form (component_object, undef) on success, or
4769 # (undef, failure_message) on failure
4770  
4771 my ($self, $anchorLineIndex, $component, @indexList) = @_;
4772  
4773 # Local variables
4774 my (
4775 $componentObj, $beforeAnchorFlag, $firstObj, $lastObj, $previousObj, $nextObj,
4776 $componentName, $matchFlag,
4777 @emptyList, @bufferObjList, @originalObjList, @tagList,
4778 );
4779  
4780 # Check for improper arguments
4781 if (! defined $anchorLineIndex || ! defined $component || ! @indexList) {
4782  
4783 $axmud::CLIENT->writeImproper($self->_objClass . '->analyseComponent', @_);
4784 return @emptyList;
4785 }
4786  
4787 # Does this component occur before the anchor line?
4788 if ($indexList[-1] < $anchorLineIndex) {
4789 $beforeAnchorFlag = TRUE;
4790 } else {
4791 $beforeAnchorFlag = FALSE; # Need defined value for a function call
4792 }
4793  
4794 # Get a list of the GA::Buffer::Display objects in this component
4795 foreach my $index (@indexList) {
4796  
4797 push (@bufferObjList, $self->ivIndex('bufferObjList', $index));
4798 }
4799  
4800 # If the component occurs before the anchor line, then we analyse the component's buffer
4801 # objects in reverse order
4802 # (NB In some cases, we need the buffer objects in their original order, so we'll create a
4803 # list for that, too)
4804 @originalObjList = @bufferObjList;
4805 if ($beforeAnchorFlag) {
4806  
4807 @bufferObjList = reverse @bufferObjList;
4808 }
4809  
4810 # For convenience, get the first and last buffer objects (which might be the same). In this
4811 # context, 'first'/'last' mean 'the first/last buffer object to be analysed'
4812 $firstObj = $bufferObjList[0];
4813 $lastObj = $bufferObjList[-1];
4814  
4815 # Get the buffer object which precedes the component ('precedes' means 'the Locator task
4816 # would analyse it before $firstObj'). If there is no such object, $previousObj is 'undef'
4817 if ($beforeAnchorFlag) {
4818 $previousObj = $self->session->ivShow('displayBufferHash', ($firstObj->number + 1));
4819 } else {
4820 $previousObj = $self->session->ivShow('displayBufferHash', ($firstObj->number - 1));
4821 }
4822  
4823 # Get the buffer object which follows the component ('follows' means 'the Locator task
4824 # would analyse it after $lastObj'). If there is no such object, $nextObj is 'undef'
4825 if ($beforeAnchorFlag) {
4826 $nextObj = $self->session->ivShow('displayBufferHash', ($firstObj->number - 1));
4827 } else {
4828 $nextObj = $self->session->ivShow('displayBufferHash', ($firstObj->number + 1));
4829 }
4830  
4831 # A component of the same type could appear in two or all three of the types of room
4832 # statement (verbose, short verbose and brief), and have different characteristics in
4833 # each one. Therefore, give each component a unique name (not already in use by the
4834 # world profile's component hash)
4835 $componentName = $self->setComponentName($component);
4836  
4837 # Create a new component object
4838 $componentObj = Games::Axmud::Obj::Component->new(
4839 $self->session,
4840 $self->session->currentWorld,
4841 $componentName,
4842 $component,
4843 TRUE, # Temporary component (can be made permanent later)
4844 );
4845  
4846 if (! $componentObj) {
4847  
4848 return (undef, "General component error");
4849 }
4850  
4851 # Configure the component, starting with its size. The wizard demands that six components
4852 # have a fixed size; all others have an optional size
4853 if (
4854 $component eq 'verb_title' || $component eq 'brief_title' || $component eq 'brief_exit'
4855 || $component eq 'brief_title_exit' || $component eq 'brief_exit_title'
4856 ) {
4857 # Fixed size - 1 line
4858 $componentObj->ivPoke('size', 1);
4859  
4860 } elsif ($component eq 'verb_exit') {
4861  
4862 # ('verb_exit' components should be treated as single lines, by default)
4863 $componentObj->ivPoke('combineLinesFlag', TRUE);
4864  
4865 # If this component was the last one, or if the size of the component was one line
4866 # (this will be the case nearly every time this wizard is used), assume that the
4867 # component has a fixed size of 1
4868 if ((scalar @indexList) > 1) {
4869  
4870 $matchFlag = $self->checkVerbExitSize($beforeAnchorFlag, @indexList);
4871 }
4872  
4873 if ($matchFlag || (scalar @indexList) == 1) {
4874  
4875 # This component was the last one besides 'outside_statement' components (or the
4876 # first one, if moving backwards)
4877 # Use a fixed size of 1
4878 $componentObj->ivPoke('size', 1);
4879  
4880 } else {
4881  
4882 # Use a minimum size of 1
4883 $componentObj->ivPoke('size', 0);
4884 $componentObj->ivPoke('minSize', 1);
4885 }
4886  
4887 } elsif ($component eq 'ignore_line') {
4888  
4889 # Fixed size - the number of lines specified by the user
4890 $componentObj->ivPoke('size', scalar @indexList);
4891  
4892 } else {
4893  
4894 # Use other IVs to find the size
4895 $componentObj->ivPoke('size', 0);
4896  
4897 # Set the minimum size. For optional components - those that might appear in the room
4898 # statement, or might not, depending on the room - the minimum size is set to 0
4899 if (
4900 $component eq 'verb_content' || $component eq 'verb_special'
4901 || $component eq 'brief_content'
4902 ) {
4903 # Optional component
4904 $componentObj->ivPoke('minSize', 0);
4905 } else {
4906 $componentObj->ivPoke('minSize', 1);
4907 }
4908 }
4909  
4910 if (! $componentObj->size) {
4911  
4912 # The component object specifies several IVs for patterns and Axmud colour/style tags
4913 # which mark the extent of the component. There's no way we can guess which patterns
4914 # might appear in all of the world's room statements, but we can guess which tags are
4915 # being used
4916  
4917 # If there are any colour/style tags used by $firstObj but not used in the preceding
4918 # line, $previousObj...
4919 @tagList = $self->compareTags($firstObj, $previousObj);
4920 if (@tagList) {
4921  
4922 # Store them
4923 $componentObj->ivPoke('startTagList', @tagList);
4924 }
4925  
4926 # If there are any colour/style tags used by $lastObj but not used in the following
4927 # line, $nextObj...
4928 @tagList = $self->compareTags($lastObj, $nextObj);
4929 if (@tagList) {
4930  
4931 # Store them
4932 $componentObj->ivPoke('stopBeforeNoTagList', @tagList);
4933  
4934 } else {
4935  
4936 # Conversely, if there are any colour/style tags used in the following line,
4937 # $nextObj, but not used in $lastObj...
4938 @tagList = $self->compareTags($nextObj, $lastObj);
4939 if (@tagList) {
4940  
4941 # Store them
4942 $componentObj->ivPoke('stopBeforeTagList', @tagList);
4943  
4944 } else {
4945  
4946 # Otherwise, for components before the anchor line, we'll have to assume that
4947 # they stop at the earliest-received line starting with a capital letter
4948 if ($beforeAnchorFlag) {
4949  
4950 $componentObj->ivPoke('upperCount', 1);
4951  
4952 # For components at/after the anchor line, we'll have to assume that they
4953 # stop at the latest-received line containing no alphanumeric characters
4954 } else {
4955  
4956 $componentObj->ivPoke('stopBeforeMode', 'no_letter_num');
4957 }
4958 }
4959 }
4960 }
4961  
4962 # Set the contents of ->profUpdateHash, which in turn is used by $self->saveChanges to
4963 # update the world profile
4964 if ($component eq 'verb_exit') {
4965  
4966 my (
4967 $string, $msg, $exitCount, $subString,
4968 @list, @sortedExitList, @sortedPosnList, @extractedExitList,
4969 %exitPosnHash,
4970 );
4971  
4972 # Empty the temporary list of exits from previous analyses
4973 $self->ivEmpty('analysisExitList');
4974  
4975 # The 'verb_exit' component can consist of more than one line. If it does, usually it's
4976 # because the world has split a long list of exits into two lines; recombine them
4977 # into a single string
4978 $string = '';
4979 foreach my $bufferObj (@originalObjList) {
4980  
4981 if ($string) {
4982 $string .= ' ' . $bufferObj->modLine;
4983 } else {
4984 $string = $bufferObj->modLine;
4985 }
4986 }
4987  
4988 # Get a sorted list of recognised primary directions by length, largest first, and
4989 # eliminate those directions which haven't been set (and are therefore 'undef')
4990 @list = $self->eliminateUndefsFromList(
4991 $self->ivValues('customPrimaryDirHash'),
4992 $self->ivValues('customPrimaryAbbrevHash'),
4993 );
4994  
4995 @sortedExitList = sort {(length $b) <=> (length $a)} (@list);
4996  
4997 # Find the position of each exit in the string. When an exit which matches one of the
4998 # directions in @sortedExitList is found, add it to a hash; in this way, when we find
4999 # the exit 'northeast', we can ignore the exits 'north' and 'east' found at the same
5000 # position
5001 # The hash is in the form
5002 # $exitPosnHash{offset} = exit_name
5003 %exitPosnHash = $self->extractExits($string, @sortedExitList);
5004 if (! %exitPosnHash) {
5005  
5006 $msg = "You marked a line as containing a list of exits, but no exits in recognised"
5007 . " primary directions\nwere found on that line. Either try a different"
5008 . " room, or go back to the first page and modify\nthe list of primary"
5009 . " directions.";
5010 return (0, $msg);
5011 }
5012  
5013 # Otherwise, at least one exit was found. Sort the keys of %exitPosnHash so that we get
5014 # a list of exits found, in the order in which they occured
5015 @sortedPosnList = sort {$a <=> $b} (keys %exitPosnHash);
5016 $exitCount = scalar (@sortedPosnList);
5017  
5018 # Also save the list of exit names (for display on the next page)
5019 foreach my $posn (@sortedPosnList) {
5020  
5021 push (@extractedExitList, $exitPosnHash{$posn});
5022 }
5023  
5024 $self->ivPush('analysisExitList', @extractedExitList);
5025  
5026 # Update $self->profUpdateHash as necessary
5027 if ($exitCount == 1) {
5028  
5029 my ($thisPosn, $thisExit, $pattern);
5030  
5031 # Assume that $string is in the form <start_text><exit><stop_text>
5032 $thisPosn = $sortedPosnList[0];
5033 $thisExit = $exitPosnHash{$thisPosn}; # e.g. 'north'
5034  
5035 # Convert $string into a regex in the form '^<start_text>(.*)<stop_text>'
5036 $pattern = '^' . quotemeta(substr($string, 0, $thisPosn)) . '(.*)'
5037 . quotemeta(substr($string, ($thisPosn + length ($thisExit))));
5038  
5039 # Store the result
5040 if ($self->analysisType eq 'verbose') {
5041  
5042 $self->profileUpdatePush('verboseAnchorPatternList', $pattern);
5043 $self->ivAdd('profUpdateHash', 'verboseAnchorOffset', 1);
5044  
5045 } elsif ($self->analysisType eq 'short') {
5046  
5047 $self->profileUpdatePush('shortAnchorPatternList', $pattern);
5048 $self->ivAdd('profUpdateHash', 'shortAnchorOffset', 1);
5049 }
5050  
5051 # Convert $string into a regex in the form '^<start_text>', and remove any number
5052 # words or numerals (e.g. convert 'There are six exits' to 'There are (.*) exits')
5053 $pattern = '^' . quotemeta(substr($string, 0, $thisPosn));
5054 $pattern = $self->processPattern($pattern);
5055 # Store the result
5056 $self->profileUpdatePush('verboseExitLeftMarkerList', $pattern);
5057  
5058 # Convert $string into a regex in the form '<stop_text>' and remove any number words
5059 # or numerals
5060 $subString = substr($string, ($thisPosn + length ($thisExit)));
5061 $pattern = quotemeta($subString);
5062 $pattern = $self->processPattern($pattern);
5063 # If '<stop_text>' contains only empty space, use an empty string (if the pattern
5064 # contains a space character, and one of the delimiters is also a space
5065 # character, this confuses the Locator task)
5066 if (! ($subString =~ m/\S/)) {
5067  
5068 $pattern = '';
5069 }
5070  
5071 # Store the result
5072 if ($pattern) {
5073  
5074 $self->profileUpdatePush('verboseExitRightMarkerList', $pattern);
5075 }
5076  
5077 } else {
5078  
5079 my (
5080 $startText, $lastPosn, $lastExit, $stopText, $pattern,
5081 @delimList,
5082 );
5083  
5084 # Assume that $string is in the form
5085 # <start_text><exit><delimiter><exit><delimiter><exit><stop_text>
5086 # Get <start_text> and <stop_text>
5087 $startText = substr($string, 0, $sortedPosnList[0]);
5088 $lastPosn = $sortedPosnList[-1];
5089 $lastExit = $exitPosnHash{$lastPosn};
5090 $stopText = substr($string, ($lastPosn + length ($lastExit)));
5091  
5092 # Get a list of <delimiter>s
5093 OUTER: for (my $count = 0; $count < ($exitCount - 1); $count++) {
5094  
5095 my ($thisPosn, $thisExit, $nextPosn, $delim, $flag);
5096  
5097 $thisPosn = $sortedPosnList[$count];
5098 $thisExit = $exitPosnHash{$thisPosn};
5099 $nextPosn = $sortedPosnList[$count + 1];
5100  
5101 $delim = substr(
5102 $string,
5103 ($thisPosn + length($thisExit)),
5104 ($nextPosn - $thisPosn - length($thisExit)),
5105 );
5106  
5107 # Check $delim against the delimiters already in @delimList. If it's not already
5108 # there, add it
5109 INNER: foreach my $otherDelim (@delimList) {
5110  
5111 if ($otherDelim eq $delim) {
5112  
5113 $flag = TRUE;
5114 last INNER;
5115 }
5116 }
5117  
5118 if (! $flag) {
5119  
5120 push (@delimList, $delim);
5121 }
5122 }
5123  
5124 # Compile a regex in the form '^<start_text>(.*)<stop_text>'
5125 $pattern = '^' . quotemeta($startText) . '(.*)' . quotemeta($stopText);
5126 # To cope with a <start_text> part (or even a <stop_text> part) which is 'There are
5127 # four obvious exits:', go through the pattern, removing any number words (or
5128 # numerals!)
5129 $pattern = $self->processPattern($pattern);
5130  
5131 # Store the results
5132 if ($self->analysisType eq 'verbose') {
5133  
5134 $self->profileUpdatePush('verboseAnchorPatternList', $pattern);
5135 $self->ivAdd('profUpdateHash', 'verboseAnchorOffset', 1);
5136  
5137 } elsif ($self->analysisType eq 'short') {
5138  
5139 $self->profileUpdatePush('shortAnchorPatternList', $pattern);
5140 $self->ivAdd('profUpdateHash', 'shortAnchorOffset', 1);
5141 }
5142  
5143 # Compile regexes in the form '^start_text>' and '<stop_text>', and remove any
5144 # number words or numerals (e.g. convert 'There are six exits' to
5145 # 'There are (.*) exits')
5146 # Then store the results
5147 $pattern = '^' . quotemeta($startText);
5148 $pattern = $self->processPattern($pattern);
5149 $self->profileUpdatePush('verboseExitLeftMarkerList', $pattern);
5150  
5151 $pattern = quotemeta($stopText);
5152 $pattern = $self->processPattern($pattern);
5153 # If '<stop_text>' contains only empty space, use an empty string (if the pattern
5154 # contains a space character, and one of the delimiters is also a space
5155 # character, this confuses the Locator task)
5156 if (! ($stopText =~ m/\S/)) {
5157  
5158 $pattern = '';
5159 }
5160  
5161 if ($pattern) {
5162  
5163 $self->profileUpdatePush('verboseExitRightMarkerList', $pattern);
5164 }
5165  
5166 $self->profileUpdatePushSort('verboseExitDelimiterList', @delimList);
5167 }
5168  
5169 } elsif (
5170 $component eq 'brief_exit'
5171 || $component eq 'brief_title_exit'
5172 || $component eq 'brief_exit_title'
5173 ) {
5174 my (
5175 $thisBufferObj, $string, $msg, $exitCount, $startText, $lastPosn, $lastExit,
5176 $stopText, $pattern,
5177 @list, @sortedExitList, @sortedPosnList, @extractedExitList, @delimList,
5178 %exitPosnHash,
5179 );
5180  
5181 # Empty the temporary list of exits from previous analyses
5182 $self->ivEmpty('analysisExitList');
5183  
5184 # The 'verb_exit' component can consist of more than one line, but the wizard requires
5185 # that these three components must be all on line. For compatibility with the code
5186 # above, extract the text of the line into a $string
5187 $thisBufferObj = $bufferObjList[0];
5188 $string = $thisBufferObj->modLine;
5189  
5190 # Get a sorted list of recognised primary directions by length, largest first, and
5191 # eliminate those directions which haven't been set (and are therefore 'undef')
5192 # For the 'verb_exit' component, only non-abbreviated directions are expected; however,
5193 # here we'll assume that both abbreviated and unabbreviated directions are possible
5194 @list = (
5195 $self->eliminateUndefsFromList($self->ivValues('customPrimaryDirHash')),
5196 $self->eliminateUndefsFromList($self->ivValues('customPrimaryAbbrevHash')),
5197 );
5198  
5199 @sortedExitList = sort {(length $b) <=> (length $a)} (@list);
5200  
5201 # Find the position of each exit in the string. When an exit which matches one of the
5202 # directions in @sortedExitList is found, add it to a hash; in this way, when we find
5203 # the exit 'ne', we can ignore the exits 'n' and 'e' found at the same position
5204 # The hash is in the form
5205 # $exitPosnHash{offset} = exit_name
5206 %exitPosnHash = $self->extractExits($string, @sortedExitList);
5207 if (! %exitPosnHash) {
5208  
5209 $msg = "You marked a line as containing a list of exits, but no exits in recognised"
5210 . " primary (abbreviated)\ndirections were found on that line. Either try a"
5211 . " different room, or go back to the first page and\nmodify the list of"
5212 . " primary abbreviated directions.";
5213 return (0, $msg);
5214 }
5215  
5216 # Otherwise, at least one exit was found. Sort the keys of %exitPosnHash so that we get
5217 # a list of exits found, in the order in which they occured
5218 @sortedPosnList = sort {$a <=> $b} (keys %exitPosnHash);
5219 $exitCount = scalar (@sortedPosnList);
5220  
5221 # Also save the list of exit names (for display on the next page)
5222 foreach my $posn (@sortedPosnList) {
5223  
5224 push (@extractedExitList, $exitPosnHash{$posn});
5225 }
5226  
5227 $self->ivPush('analysisExitList', @extractedExitList);
5228  
5229 # Update $self->profUpdateHash as necessary. Assume that $string is in the form
5230 # <start_text><exit><delimiter><exit><delimiter><exit><stop_text>
5231 # ...where <start_text> or <stop_text>, if present, can contain either the room title
5232 # or another <delimiter>
5233  
5234 # Get <start_text> and <stop_text>
5235 $startText = substr($string, 0, $sortedPosnList[0]);
5236 $lastPosn = $sortedPosnList[-1];
5237 $lastExit = $exitPosnHash{$lastPosn};
5238 $stopText = substr($string, ($lastPosn + length ($lastExit)));
5239  
5240 # Get a list of <delimiter>s
5241 OUTER: for (my $count = 0; $count < ($exitCount - 1); $count++) {
5242  
5243 my ($thisPosn, $thisExit, $nextPosn, $delim, $flag);
5244  
5245 $thisPosn = $sortedPosnList[$count];
5246 $thisExit = $exitPosnHash{$thisPosn};
5247 $nextPosn = $sortedPosnList[$count + 1];
5248  
5249 $delim = substr(
5250 $string,
5251 ($thisPosn + length($thisExit)),
5252 ($nextPosn - $thisPosn - length($thisExit)),
5253 );
5254  
5255 # Check $delim against the delimiters already in @delimList. If it's not already
5256 # there, add it
5257 INNER: foreach my $otherDelim (@delimList) {
5258  
5259 if ($otherDelim eq $delim) {
5260  
5261 $flag = TRUE;
5262 last INNER;
5263 }
5264 }
5265  
5266 if (! $flag) {
5267  
5268 push (@delimList, $delim);
5269 }
5270 }
5271  
5272 if ($component eq 'brief_exit') {
5273  
5274 # Compile a regex in the form '^<start_text>(.*)<stop_text>'
5275 $pattern = '^' . quotemeta($startText) . '(.*)' . quotemeta($stopText);
5276 # To cope with a <start_text> part (or even a <stop_text> part) which is 'There are
5277 # four obvious exits:', go through the pattern, removing any number words (or
5278 # numerals!)
5279 $pattern = $self->processPattern($pattern);
5280  
5281 # Store the results
5282 $self->profileUpdatePush('briefAnchorPatternList', $pattern);
5283 $self->ivAdd('profUpdateHash', 'briefAnchorOffset', 1);
5284  
5285 $self->profileUpdatePush('briefExitLeftMarkerList', '^' . quotemeta($startText));
5286  
5287 if ($stopText) {
5288  
5289 $self->profileUpdatePush('briefExitRightMarkerList', quotemeta($stopText));
5290 }
5291  
5292 $self->profileUpdatePushSort('briefExitDelimiterList', @delimList);
5293  
5294 } else {
5295  
5296 # For the 'brief_title_exit' and 'brief_exit_title' components, we need to store
5297 # the substrings and delimiter list temporarily so that $self->analysisPage can
5298 # retrieve them
5299 $self->ivPoke('tempStartText', $startText);
5300 $self->ivPoke('tempStopText', $stopText);
5301 $self->ivPoke('tempDelimList', @delimList);
5302 }
5303 }
5304  
5305 # Analysis complete
5306 return ($componentObj, undef);
5307 }
5308  
5309 sub collectComponentGroups {
5310  
5311 # Called by $self->analyseLines
5312 # Compile the IV ->analysisHash by grouping lines of each component together
5313 #
5314 # Expected arguments
5315 # (none besides $self)
5316 #
5317 # Return values
5318 # 'undef' on improper arguments
5319 # 1 otherwise
5320  
5321 my ($self, $check) = @_;
5322  
5323 # Local variables
5324 my %hash;
5325  
5326 # Check for improper arguments
5327 if (defined $check) {
5328  
5329 return $axmud::CLIENT->writeImproper($self->_objClass . '->collectComponentGroups', @_);
5330 }
5331  
5332 # The statement's components are spread across up to $self->analysisLength lines
5333 # Divide these lines into groups, one for each component, by compiling a hash in the form
5334 # $hash{component_name} = reference_to_list_of_lines
5335 # e.g. $hash{'verb_descrip'} = [3, 4, 5]
5336 for (my $line = 0; $line < $self->analysisLength; $line++) {
5337  
5338 my ($component, $listRef);
5339  
5340 if (defined $self->ivIndex('bufferObjList', $line)) {
5341  
5342 $component = $self->ivIndex('bufferTypeList', $line);
5343  
5344 if (! exists $hash{$component}) {
5345  
5346 $hash{$component} = [$line];
5347  
5348 } else {
5349  
5350 $listRef = $hash{$component};
5351 push (@$listRef, $line);
5352  
5353 $hash{$component} = $listRef;
5354 }
5355 }
5356 }
5357  
5358 # Save the compiled list as an IV
5359 $self->ivPoke('analysisHash', %hash);
5360  
5361 return 1;
5362 }
5363  
5364 sub convertIgnoreLines {
5365  
5366 # Called by $self->analyseLines
5367 # The user may have used 'ignore_line' rather than 'outside_statement' at the beginning
5368 # and end of the list. If so, convert the former to the latter
5369 #
5370 # Expected arguments
5371 # (none besides $self)
5372 #
5373 # Return values
5374 # 'undef' on improper arguments
5375 # 1 otherwise
5376  
5377 my ($self, $check) = @_;
5378  
5379 # Check for improper arguments
5380 if (defined $check) {
5381  
5382 return $axmud::CLIENT->writeImproper($self->_objClass . '->convertIgnoreLines', @_);
5383 }
5384  
5385 # Start from the beginning...
5386 OUTER: for (my $line = 0; $line < $self->analysisLength; $line++) {
5387  
5388 my $type = $self->ivIndex('bufferTypeList', $line);
5389  
5390 if ($type ne 'outside_statement' && $type ne 'ignore_line') {
5391  
5392 last OUTER;
5393  
5394 } elsif ($type eq 'ignore_line') {
5395  
5396 # Convert an 'ignore' to an 'outside'
5397 $self->ivReplace('bufferTypeList', $line, 'outside_statement');
5398 }
5399 }
5400  
5401 # Work back from the end...
5402 OUTER: for (my $line = ($self->analysisLength - 1); $line >= 0; $line--) {
5403  
5404 my $type = $self->ivIndex('bufferTypeList', $line);
5405  
5406 if ($type ne 'outside_statement' && $type ne 'ignore_line') {
5407  
5408 last OUTER;
5409  
5410 } elsif ($type eq 'ignore_line') {
5411  
5412 # Convert an 'ignore' to an 'outside'
5413 $self->ivReplace('bufferTypeList', $line, 'outside_statement');
5414 }
5415 }
5416  
5417 return 1;
5418 }
5419  
5420 sub checkOutsideGroups {
5421  
5422 # Called by $self->analyseLines
5423 # There must be no more than 2 'outside_statement' components - one starting at the first
5424 # line, one ending at the last line ('ignore_line' can be used anywhere, in any order)
5425 # This function checks whether any 'outside_statement' components in the analysed lines
5426 # comply with these rules
5427 #
5428 # Expected arguments
5429 # (none besides $self)
5430 #
5431 # Return values
5432 # 'undef' on improper arguments or if the check fails (the 'outside_component' groups are
5433 # unacceptable)
5434 # 1 if the check succeeds or if there are no 'outside_component' groups in the analysed
5435 # lines
5436  
5437 my ($self, $check) = @_;
5438  
5439 # Local variables
5440 my ($line, $group1Start, $group1Stop, $group2Start, $group2Stop);
5441  
5442 # Check for improper arguments
5443 if (defined $check) {
5444  
5445 return $axmud::CLIENT->writeImproper($self->_objClass . '->checkOutsideGroups', @_);
5446 }
5447  
5448 if ($self->ivExists('analysisHash', 'outside_statement')) {
5449  
5450 $line = -1;
5451  
5452 do {
5453  
5454 $line++;
5455  
5456 if ($self->ivIndex('bufferTypeList', $line) eq 'outside_statement') {
5457  
5458 # First line of group 1
5459 if (! defined $group1Start) {
5460  
5461 $group1Start = $line;
5462  
5463 # First line of group 2
5464 } elsif (defined $group1Stop && ! defined $group2Start) {
5465  
5466 $group2Start = $line;
5467  
5468 # Start of an illegal third group
5469 } elsif (defined $group1Stop && defined $group2Stop) {
5470  
5471 # Check has failed
5472 return undef;
5473 }
5474  
5475 } elsif (defined $group1Start && ! defined $group1Stop) {
5476  
5477 # Last line of group 1
5478 $group1Stop = ($line - 1);
5479  
5480 } elsif (defined $group2Start && ! defined $group2Stop) {
5481  
5482 # Last line of group 2
5483 $group2Stop = ($line - 1);
5484 }
5485  
5486 } until ($line >= ($self->analysisLength - 1));
5487  
5488 # Check for groups that extended all the way to the end
5489 if (defined $group1Start && ! defined $group1Stop) {
5490  
5491 $group1Stop = $self->analysisLength - 1;
5492 }
5493  
5494 if (defined $group2Start && ! defined $group2Stop) {
5495  
5496 $group2Stop = $self->analysisLength - 1;
5497 }
5498  
5499 # Check that 2nd group (if it exists) doesn't stop before the end
5500 if (defined $group2Start && $group2Stop != ($self->analysisLength - 1)) {
5501  
5502 # Check has failed
5503 return undef;
5504 }
5505  
5506 # Check that 1st group (if there are two) doesn't start after the beginning
5507 if (defined $group2Start && $group1Start != 0) {
5508  
5509 # Check has failed
5510 return undef;
5511 }
5512 }
5513  
5514 # Check successful
5515 return 1;
5516 }
5517  
5518 sub checkVerbExitSize {
5519  
5520 # Called by $self->analyseComponent when analysing a 'verb_exit' component
5521 # Checks whether this component is the last one (besides 'outside_statement' components),
5522 # so that we can set the component's size
5523 #
5524 # Expected arguments
5525 # $beforeAnchorFlag
5526 # - Flag set to TRUE if this component occurs before the anchor line, FALSE if it
5527 # occurs after the anchor line
5528 # @indexList
5529 # - A list of of indexes in $self->bufferObjList, each one corresponding to an
5530 # GA::Buffer::Display object
5531 #
5532 # Return values
5533 # 'undef' on improper arguments or if there is another component after the 'verb_exit'
5534 # component
5535 # 1 if the 'verb_exit' component is the last one (besides 'outisde_statement' components)
5536  
5537 my ($self, $beforeAnchorFlag, @indexList) = @_;
5538  
5539 # Local variables
5540 my ($lastIndex, $nextIndex, $step, $exitFlag, $thisIndex);
5541  
5542 # Check for improper arguments
5543 if (! defined $beforeAnchorFlag || ! @indexList) {
5544  
5545 return $axmud::CLIENT->writeImproper($self->_objClass . '->checkVerbExitSize', @_);
5546 }
5547  
5548 # Is this 'verb_exit' component the last one (besides 'outside_statement' components?)
5549 if ($beforeAnchorFlag) {
5550  
5551 $lastIndex = $indexList[0];
5552 $nextIndex = $lastIndex - 1;
5553 $step = -1;
5554  
5555 } else {
5556  
5557 $lastIndex = $indexList[-1];
5558 $nextIndex = $lastIndex + 1;
5559 $step = 1;
5560 }
5561  
5562 $thisIndex = $nextIndex;
5563  
5564 do {
5565  
5566 if ($thisIndex < 0 || $thisIndex >= scalar @indexList) {
5567  
5568 # This 'verb_exit' component is the last one (besides 'outside_statement'
5569 # components)
5570 return 1;
5571  
5572 } elsif ($self->ivIndex('bufferTypeList', $thisIndex) ne 'outside_statement') {
5573  
5574 # This 'verb_exit' component is the not the last one
5575 $exitFlag = TRUE;
5576  
5577 } else {
5578  
5579 # Keep looking
5580 $thisIndex = $thisIndex + $step;
5581 }
5582  
5583 } until ($exitFlag);
5584  
5585 return undef;
5586 }
5587  
5588 sub processPattern {
5589  
5590 # Called by $self->analyseComponent
5591 # The calling function has compiled a pattern to represent the exit list, in the form
5592 # ^<start_text><list_of_exits><stop_text>
5593 # To guard against the possibility that <start_text> might read something like 'There are
5594 # four obvious exits', we need to remove any known number words (and numerals),
5595 # replacing them with '(.*)'
5596 #
5597 # Expected arguments
5598 # $pattern - The pattern to process
5599 #
5600 # Return values
5601 # 'undef' on improper arguments
5602 # Otherwise, returns the processed pattern
5603  
5604 my ($self, $pattern, $check) = @_;
5605  
5606 # Local variables
5607 my (@numberList, @sortedList);
5608  
5609 # Check for improper arguments
5610 if (! defined $pattern || defined $check) {
5611  
5612 return $axmud::CLIENT->writeImproper($self->_objClass . '->processPattern', @_);
5613 }
5614  
5615 # Get a list of words, 'one', 'two', 'three'...
5616 # If the user didn't define any number words in the first page, use the current dictionary
5617 if ($self->numberList) {
5618  
5619 @numberList = $self->numberList;
5620  
5621 } else {
5622  
5623 @numberList = $self->session->currentDict('numberHash');
5624 }
5625  
5626 # Sort the words/phrases in order of size, so that (for example) if $pattern contains the
5627 # word 'nineteen', we don't remove the word 'nine' (leaving 'teen')
5628 @sortedList = sort {length($a) <=> length($b)} (@numberList);
5629  
5630 # Replace number words
5631 foreach my $item (@numberList) {
5632  
5633 $pattern =~ s/$item/(.*)/g;
5634 }
5635  
5636 # Replace numerals
5637 $pattern =~ s/\d+//g;
5638  
5639 return $pattern;
5640 }
5641  
5642 sub extractExits {
5643  
5644 # Called by $self->analyseComponent
5645 # Finds the position of each exit (which matches a recognised custom primary direction) in a
5646 # string which represents one or more buffer lines in a single component
5647 # Adds the exits to a hash, and returns them
5648 #
5649 # Expected arguments
5650 # $string - The line of text to process
5651 #
5652 # Optional arguments
5653 # @exitList - A list of either custom primary directions ('northeast', 'north') or
5654 # custom abbreviated primary directions ('ne', n'), sorted by length,
5655 # largest first. If an empty list, no exits can be extracted (and an
5656 # empty list is returned)
5657 #
5658 # Return values
5659 # An empty list on improper arguments or if $string contains none of the exits in
5660 # @exitList
5661 # Otherwise, returns a hash in the form
5662 # $exitPosnHash{character_number} = direction_name
5663  
5664 my ($self, $string, @exitList) = @_;
5665  
5666 # Local variables
5667 my (
5668 @emptyList,
5669 %exitPosnHash,
5670 );
5671  
5672 # Check for improper arguments
5673 if (! defined $string) {
5674  
5675 $axmud::CLIENT->writeImproper($self->_objClass . '->extractExits', @_);
5676 return @emptyList;
5677 }
5678  
5679 # In some worlds, the list of exits in the room statement is capitalised (e.g.
5680 # 'Exits: North South East'
5681 # Guard against this unfortunate tendency by making sure $string contains no capitals
5682 $string = lc($string);
5683  
5684 # Find the position of each exit in turn
5685 OUTER: foreach my $exit (@exitList) {
5686  
5687 my ($posn, $nextPosn, $exitFlag);
5688  
5689 do {
5690  
5691 my ($previousChar, $nextChar);
5692  
5693 if (defined $nextPosn) {
5694  
5695 # Keep looking after the last position checked
5696 $posn = index($string, $exit, $nextPosn);
5697 $nextPosn = undef;
5698  
5699 } else {
5700  
5701 # Start looking from the beginning of the line
5702 $posn = index($string, $exit);
5703 }
5704  
5705 # Check that the exit is surrounded by non-alphanumeric characters
5706 if ($posn > 0) {
5707  
5708 $previousChar = substr($string, ($posn - 1), 1);
5709 }
5710  
5711 if ($posn < (length ($string) - 1)) {
5712  
5713 $nextChar = substr($string, ($posn + length($exit)), 1);
5714 }
5715  
5716 # If the exit is preceded or followed by an alphanumeric character, then assume
5717 # we've found 'south' in the word 'southeast'
5718 if ($posn > -1) {
5719  
5720 if (
5721 (defined $previousChar && $previousChar =~ m/\w/)
5722 || (defined $nextChar && $nextChar =~ m/\w/)
5723 ) {
5724 $nextPosn = $posn + 1;
5725  
5726 } else {
5727  
5728 # Found an exit. Add it to the hash...
5729 $exitPosnHash{$posn} = $exit;
5730 # ...and move on to the next exit
5731 $exitFlag = TRUE;
5732 }
5733 }
5734  
5735 } until ($posn < 0 || $exitFlag);
5736 }
5737  
5738 return %exitPosnHash; # May be an empty hash
5739 }
5740  
5741 sub testExtractExits {
5742  
5743 # Called by $self->analysisPage, for brief room statements only, after the user clicks the
5744 # 'Test' button
5745 # Extracts a list of exits from a string, from which the room title and/or brief exit
5746 # markers have already been removed
5747 #
5748 # Expected arguments
5749 # $string - The string to process
5750 #
5751 # Return values
5752 # Am empty list on improper arguments
5753 # Otherwise returns the list of exits
5754  
5755 my ($self, $string, $check) = @_;
5756  
5757 # Local variables
5758 my (@emptyList, @delimList, @tempArray, @returnArray);
5759  
5760 # Check for improper arguments
5761 if (! defined $string || defined $check) {
5762  
5763 $axmud::CLIENT->writeImproper($self->_objClass . '->testExtractExits', @_);
5764 return @emptyList;
5765 }
5766  
5767 # In some worlds, the list of exits in the room statement is capitalised (e.g.
5768 # 'Exits: North South East'
5769 # Guard against this unfortunate tendency by making sure $string contains no capitals
5770 $string = lc($string);
5771  
5772 # $self->tempDelimList contains a list of brief exit delimiters stored by the previous page.
5773 # Sort the delimiter list by size, so that a delimiter which is just a comma isn't
5774 # processed before a delimiter which is <, > - which would be ignored, if the comma
5775 # had already been extracted
5776 @delimList = sort {length ($b) <=> length ($a)} ($self->tempDelimList);
5777  
5778 # Initialise @returnArray with the string containing the list of exits to process
5779 push (@returnArray, $string);
5780 foreach my $delim (@delimList) {
5781  
5782 # For each delimiter, move everything already in @returnArray into @tempArray
5783 # For each element now in @tempArray, split it into a list using the delimiter, and push
5784 # it back into @returnArray
5785 # After each iteration, @returnArray will contain the same number of, or more, elements
5786 # than it did before
5787 @tempArray = @returnArray;
5788 @returnArray = ();
5789 foreach my $item (@tempArray) {
5790  
5791 my @list = split ($delim, $item);
5792 push (@returnArray, @list);
5793 }
5794 }
5795  
5796 return @returnArray;
5797 }
5798  
5799 sub textViewSignalConnect {
5800  
5801 # Called by several functions
5802 # Extracts the data from a textview buffer (added with $self->addTextView). Splits it
5803 # into lines of text, removes leading/trailing whitespace, and stores the result in one
5804 # of this object's list IVs
5805 # (Code used is very similar to the ->signal_connect in GA::Generic::EditWin->addTextView)
5806 #
5807 # Expected arguments
5808 # $buffer - The Gtk3::TextView's buffer
5809 # $iv - The list IV in which the lines should be stored
5810 #
5811 # Return values
5812 # 'undef' on improper arguments
5813 # 1 otherwise
5814  
5815 my ($self, $buffer, $iv, $check) = @_;
5816  
5817 # Check for improper arguments
5818 if (defined $check) {
5819  
5820 return $axmud::CLIENT->writeImproper($self->_objClass . '->textViewSignalConnect', @_);
5821 }
5822  
5823 $buffer->signal_connect('changed' => sub {
5824  
5825 my (
5826 $text,
5827 @list, @finalList,
5828 );
5829  
5830 $text = $axmud::CLIENT->desktopObj->bufferGetText($buffer);
5831  
5832 # Split the contents of the textview into a list of lines, separated by newline
5833 # characters
5834 @list = split("\n", $text);
5835 # Remove any empty lines and leading/trailing whitespace
5836 foreach my $line (@list) {
5837  
5838 if ($line) {
5839  
5840 $line =~ s/^\s*//; # Remove leading whitespace
5841 $line =~ s/\s*$//; # Remove trailing whitepsace
5842  
5843 (push @finalList, $line);
5844 }
5845  
5846 }
5847  
5848 # Set the IV
5849 $self->ivPoke($iv, @finalList);
5850  
5851 # Update the hash of changed IVs
5852 $self->ivAdd('ivChangeHash', $iv, TRUE);
5853 });
5854  
5855 return 1;
5856 }
5857  
5858 sub updateTextView {
5859  
5860 # Called by $self->analysisPage and later pages
5861 # Fills a Gtk3::TextView with the lines in a single component
5862 #
5863 # Expected arguments
5864 # $textView - The Gtk3::TextView to fill up
5865 # $component - The component to use - a key in $self->analysisHash
5866 #
5867 # Return values
5868 # 'undef' on improper arguments
5869 # 1 otherwise
5870  
5871 my ($self, $textView, $component, $check) = @_;
5872  
5873 # Local variables
5874 my (
5875 $textViewBuffer, $listRef,
5876 @bufferObjList, @stringList,
5877 );
5878  
5879 # Check for improper arguments
5880 if (! defined $textView || ! defined $component || defined $check) {
5881  
5882 return $axmud::CLIENT->writeImproper($self->_objClass . '->updateTextView', @_);
5883 }
5884  
5885 $textViewBuffer = $textView->get_buffer();
5886  
5887 # If $component doesn't exist as a key in $self->analysisHash - meaning that the user
5888 # didn't allocate any lines to this component - just make sure the textview is empty
5889 if (! $self->ivExists('analysisHash', $component)) {
5890  
5891 $textViewBuffer->set_text('');
5892  
5893 } else {
5894  
5895 $listRef = $self->ivShow('analysisHash', $component);
5896  
5897 foreach my $line (@$listRef) {
5898  
5899 my $textViewBufferObj = $self->ivIndex('bufferObjList', $line);
5900  
5901 push (@stringList, $textViewBufferObj->modLine);
5902 }
5903  
5904 $textViewBuffer->set_text(join("\n", @stringList));
5905 }
5906  
5907 return 1;
5908 }
5909  
5910 sub eliminateUndefsFromList {
5911  
5912 # Called by several functions which use values from key-value pairs in the hashes
5913 # $self->customPrimaryDirHash and ->customPrimaryAbbrevHash, in which the values might be
5914 # set to 'undef'
5915 # Given a list of elements, eliminates all those which are set to 'undef', and returns
5916 # the modified list
5917 # e.g. in the list ('north', 'south', undef, undef, 'east'), returns
5918 # ('north', 'south', 'east')
5919 #
5920 # Expected arguments
5921 # (none besides $self)
5922 #
5923 # Optional arguments
5924 # @list - A list (usually of custom primary directions)
5925 #
5926 # Return values
5927 # Returns the modified list
5928  
5929 my ($self, @list) = @_;
5930  
5931 # Local variables
5932 my @returnArray;
5933  
5934 # (No improper arguments to check)
5935 foreach my $item (@list) {
5936  
5937 if (defined $item) {
5938  
5939 push (@returnArray, $item);
5940 }
5941 }
5942  
5943 return @returnArray;
5944 }
5945  
5946 sub compareTags {
5947  
5948 # Called by $self->analyseComponent
5949 # Compares two GA::Buffer::Display objects. Returns a list of all the Axmud colour/style
5950 # tags that appear in the first object, but not the second (ignores the dummy tags
5951 # like 'bold', 'reverse_off' and 'attribs_off')
5952 #
5953 # Expected arguments
5954 # $firstObj, $secondObj - The two buffer objects to compare
5955 #
5956 # Return values
5957 # An empty list on improper arguments
5958 # Otherwise, returns a list of all the Axmud colour/style tags that appear in the first
5959 # object, but not the second (ignoring dummy tags); may be an empty list
5960  
5961 my ($self, $firstObj, $secondObj, $check) = @_;
5962  
5963 # Local variables
5964 my (@emptyList, @returnArray);
5965  
5966 # Check for improper arguments
5967 if (! defined $firstObj || ! defined $secondObj || defined $check) {
5968  
5969 $axmud::CLIENT->writeImproper($self->_objClass . '->compareTags', @_);
5970 return @emptyList;
5971 }
5972  
5973 foreach my $tag ($firstObj->ivKeys('tagHash')) {
5974  
5975 if (
5976 ! $secondObj->ivExists('tagHash', $tag)
5977 && ! $axmud::CLIENT->ivExists('constDummyTagHash', $tag)
5978 ) {
5979 push (@returnArray, $tag);
5980 }
5981 }
5982  
5983 # Operation complete
5984 return @returnArray;
5985 }
5986  
5987 sub profileUpdatePush {
5988  
5989 # Called by $self->analysisPage and analyseComponent
5990 #
5991 # The IV $self->profUpdateHash holds any data with which the world profile must be updated,
5992 # when $self->saveChanges is called. The hash is in the form:
5993 # profUpdateHash{$iv} = scalar
5994 # profUpdateHash{$iv} = list_reference
5995 #
5996 # This function adds a new key-value pair for a list IV (but not for a scalar IV).
5997 # If the key already exists, a list of values is added to 'list_reference', however,
5998 # duplicate values are not added
5999 # If the key doesn't yet exist, a new 'list_reference' is created
6000 #
6001 # Expected arguments
6002 # $iv - A list IV (a key in $self->profUpdateHash)
6003 #
6004 # Optional arguments
6005 # @itemList - A list of items to add to the corresponding value in $self->profUpdateHash
6006 # (can be an empty list)
6007 #
6008 # Return values
6009 # 'undef' on improper arguments
6010 # 1 otherwise
6011  
6012 my ($self, $iv, @itemList) = @_;
6013  
6014 # Local variables
6015 my $listRef;
6016  
6017 # Check for improper arguments
6018 if (! defined $iv) {
6019  
6020 return $axmud::CLIENT->writeImproper($self->_objClass . '->profileUpdatePush', @_);
6021 }
6022  
6023 if ($self->ivExists('profUpdateHash', $iv)) {
6024  
6025 $listRef = $self->ivShow('profUpdateHash', $iv);
6026 }
6027  
6028 OUTER: foreach my $newItem (@itemList) {
6029  
6030 INNER: foreach my $oldItem (@$listRef) {
6031  
6032 if ($newItem eq $oldItem) {
6033  
6034 # Don't add the duplicate
6035 next OUTER;
6036 }
6037 }
6038  
6039 # Not a duplicate
6040 push (@$listRef, $newItem);
6041 }
6042  
6043 $self->ivAdd('profUpdateHash', $iv, $listRef);
6044  
6045 return 1;
6046 }
6047  
6048 sub profileUpdatePushSort {
6049  
6050 # Called by $self->analysisPage and analyseComponent
6051 # Companion to $self->profileUpdatePush, called for delimiter lists which need to be
6052 # sorted, longest first
6053 #
6054 # Expected arguments
6055 # $iv - A list IV (a key in $self->profUpdateHash)
6056 #
6057 # Optional arguments
6058 # @itemList - A list of items to add to the corresponding value in $self->profUpdateHash
6059 # (can be an empty list)
6060 #
6061 # Return values
6062 # 'undef' on improper arguments
6063 # 1 otherwise
6064  
6065 my ($self, $iv, @itemList) = @_;
6066  
6067 # Local variables
6068 my $listRef;
6069  
6070 # Check for improper arguments
6071 if (! defined $iv) {
6072  
6073 return $axmud::CLIENT->writeImproper($self->_objClass . '->profileUpdatePush', @_);
6074 }
6075  
6076 if ($self->ivExists('profUpdateHash', $iv)) {
6077  
6078 $listRef = $self->ivShow('profUpdateHash', $iv);
6079 }
6080  
6081 OUTER: foreach my $newItem (@itemList) {
6082  
6083 INNER: foreach my $oldItem (@$listRef) {
6084  
6085 if ($newItem eq $oldItem) {
6086  
6087 # Don't add the duplicate
6088 next OUTER;
6089 }
6090 }
6091  
6092 # Not a duplicate
6093 push (@$listRef, $newItem);
6094 }
6095  
6096 @$listRef = sort {length($b) <=> length($a)} (@$listRef);
6097 $self->ivAdd('profUpdateHash', $iv, $listRef);
6098  
6099 return 1;
6100 }
6101  
6102 sub updateProfileList {
6103  
6104 # Called by $self->saveChanges
6105 #
6106 # Updates a world profile list IV with new values, preserving any existing ones. However,
6107 # duplicate values are not added
6108 #
6109 # Expected arguments
6110 # $profObj - The current world profile
6111 # $iv - An IV in the current world profile
6112 #
6113 # Optional arguments
6114 # @list - A list of values to add to the list IV (if an empty list, no values are
6115 # added)
6116 #
6117 # Return values
6118 # 'undef' on improper arguments or if @list is empty
6119 # 1 otherwise
6120  
6121 my ($self, $profObj, $iv, @list) = @_;
6122  
6123 # Local variables
6124 my @profList;
6125  
6126 # Check for improper arguments
6127 if (! defined $profObj || ! defined $iv) {
6128  
6129 return $axmud::CLIENT->writeImproper($self->_objClass . '->updateProfileList', @_);
6130 }
6131  
6132 # If @list is empty, there's nothing to do
6133 if (! @list) {
6134  
6135 return undef;
6136 }
6137  
6138 # Import the contents of the profile's IV (for convenience)
6139 @profList = $profObj->$iv;
6140  
6141 # Update the list
6142 OUTER: foreach my $item (@list) {
6143  
6144 INNER: foreach my $profItem (@profList) {
6145  
6146 if ($item eq $profItem) {
6147  
6148 # Don't add the duplicate
6149 next OUTER;
6150 }
6151 }
6152  
6153 # Not a duplicate
6154 push (@profList, $item);
6155 }
6156  
6157 # Store the new contents of the IV
6158 $profObj->ivPoke($iv, @profList);
6159  
6160 return 1;
6161 }
6162  
6163 sub insertAnchor {
6164  
6165 # Called by $self->saveChanges
6166 #
6167 # When the world profile's ->verboseComponentList, ->shortComponentList or
6168 # ->briefComponentList is rewritten, we must insert the special 'anchor' component just
6169 # before the component containing exits (which acts as our anchor line)
6170 #
6171 # Expected arguments
6172 # $profObj - The current world profile
6173 # $iv - A list IV in the current world profile (one of the IVs listed above)
6174 # $component - The name of the component about to be inserted into the list IV
6175 #
6176 # Return values
6177 # 'undef' on improper arguments
6178 # 1 otherwise
6179  
6180 my ($self, $profObj, $iv, $component, $check) = @_;
6181  
6182 # Check for improper arguments
6183 if (! defined $profObj || ! defined $iv || ! defined $component || defined $check) {
6184  
6185 return $axmud::CLIENT->writeImproper($self->_objClass . '->insertAnchor', @_);
6186 }
6187  
6188 if (
6189 $component eq 'verb_exit' || $component eq 'brief_exit'
6190 || $component eq 'brief_title_exit' || $component eq 'brief_exit_title'
6191 ) {
6192 $profObj->ivPush($iv, 'anchor');
6193 }
6194  
6195 return 1;
6196 }
6197  
6198 sub checkDelimiters {
6199  
6200 # Called by $self->saveChanges
6201 #
6202 # When the world profile's ->verboseExitDelimiterList IV is updated, we must check that none
6203 # of its values are in ->verboseExitNonDelimiterList and, if so, they must be removed from
6204 # the latter
6205 # We can do the same with ->briefExitDelimiterList and ->briefExitNonDelimiterList
6206 #
6207 # Expected arguments
6208 # $profObj - The current world profile
6209 # $listIV - Set to 'verboseExitDelimiterList' or 'briefExitDelimiterList'
6210 # $nonListIV - Set to 'verboseExitNonDelimiterList' or 'briefExitNonDelimiterList'
6211 #
6212 # Return values
6213 # 'undef' on improper arguments
6214 # 1 otherwise
6215  
6216 my ($self, $profObj, $listIV, $nonListIV, $check) = @_;
6217  
6218 # Local variables
6219 my (@newList);
6220  
6221 # Check for improper arguments
6222 if (! defined $profObj || ! defined $listIV || ! defined $nonListIV || defined $check) {
6223  
6224 return $axmud::CLIENT->writeImproper($self->_objClass . '->checkDelimiters', @_);
6225 }
6226  
6227 OUTER: foreach my $nonDelim ($profObj->$nonListIV) {
6228  
6229 INNER: foreach my $delim ($profObj->$listIV) {
6230  
6231 if ($delim eq $nonDelim) {
6232  
6233 # Remove the non-delimiter by not adding it to @newList
6234 next OUTER;
6235 }
6236 }
6237  
6238 # Preserve the non-delimiter by adding it to @newList
6239 push (@newList, $nonDelim);
6240 }
6241  
6242 # Update the IV
6243 $profObj->ivPoke($nonListIV, @newList);
6244  
6245 return 1;
6246 }
6247  
6248 sub setComponentName {
6249  
6250 # Called by $self->analyseComponent
6251 #
6252 # A component of the same type could appear in two or all three of the types of room
6253 # statement (verbose, short verbose and brief), and have different characteristics in
6254 # each one. Therefore, give each component a unique name (not already in use by the
6255 # world profile's component hash)
6256 #
6257 # Expected arguments
6258 # $type - The component type, e.g. 'verb_descrip'
6259 #
6260 # Return values
6261 # 'undef' on improper arguments
6262 # Otherwise returns the unique component name
6263  
6264 my ($self, $type, $check) = @_;
6265  
6266 # Local variables
6267 my ($count, $name);
6268  
6269 # Check for improper arguments
6270 if (! defined $type || defined $check) {
6271  
6272 return $axmud::CLIENT->writeImproper($self->_objClass . '->setComponentName', @_);
6273 }
6274  
6275 # Try the name 'type_1', then 'type_2', 'type_3', etc
6276 # To prevent any (extremely unlikely) infinite loops, give up at 9999
6277 $count = 0;
6278 # Most pre-configured worlds use components whose names are the same as their type; if
6279 # that's the case, the first new component is 'type_2' rather than 'type_1'
6280 if ($self->session->currentWorld->ivExists('componentHash', $type)) {
6281  
6282 $count = 1;
6283 }
6284  
6285 do {
6286  
6287 my $flag;
6288  
6289 $count++;
6290 $name = $type . '_' . $count;
6291  
6292 # Check that the world profile doesn't have an existing component with this name
6293 if ($self->session->currentWorld->ivExists('componentHash', $name)) {
6294  
6295 $flag = TRUE;
6296 }
6297  
6298 # Check that the wizard hasn't already created any components with this name for a
6299 # different type of room description
6300 if (! $flag && $self->analysisType ne 'verbose') {
6301  
6302 OUTER: foreach my $componentObj ($self->verboseComponentObjList) {
6303  
6304 if ($componentObj->name eq $name) {
6305  
6306 $flag = TRUE;
6307 last OUTER;
6308 }
6309 }
6310 }
6311  
6312 if (! $flag && $self->analysisType ne 'short') {
6313  
6314 OUTER: foreach my $componentObj ($self->shortComponentObjList) {
6315  
6316 if ($componentObj->name eq $name) {
6317  
6318 $flag = TRUE;
6319 last OUTER;
6320 }
6321 }
6322 }
6323  
6324 if (! $flag && $self->analysisType ne 'brief') {
6325  
6326 OUTER: foreach my $componentObj ($self->briefComponentObjList) {
6327  
6328 if ($componentObj->name eq $name) {
6329  
6330 $flag = TRUE;
6331 last OUTER;
6332 }
6333 }
6334 }
6335  
6336 if (! $flag) {
6337  
6338 # The component $name is available
6339 return $name;
6340 }
6341  
6342 } until ($count >= 9999);
6343  
6344 # Escape an (extremely unlikely) infinite loop by just using the name $type
6345 return $type;
6346 }
6347  
6348 sub updateContentComponent {
6349  
6350 # Called by $self->saveChanges
6351 #
6352 # $self->markerList contains the content marker patterns, e.g. 'is here' and 'are here'. The
6353 # markers should also be added to components of the 'verb_content' and 'brief_content', by
6354 # default (would be confusing for the user, if they had to do it themselves using the
6355 # 'edit' window)
6356 #
6357 # Expected arguments
6358 # $componentObj - The GA::Obj::Component to process (can be of any type, but only the
6359 # types 'verb_content' and 'brief_content' are modified)
6360 #
6361 # Return values
6362 # 'undef' on improper arguments or if no modifications are needed
6363 # 1 otherwise
6364  
6365 my ($self, $componentObj, $check) = @_;
6366  
6367 # Check for improper arguments
6368 if (! defined $componentObj || defined $check) {
6369  
6370 return $axmud::CLIENT->writeImproper($self->_objClass . '->updateContentComponent', @_);
6371 }
6372  
6373 # Do nothing if $componentObj is of the wrong type, or if the list of content marker
6374 # patterns in $self->markerList has been emptied
6375 if (
6376 ! $self->markerList
6377 || ($componentObj->type ne 'verb_content' && $componentObj->type ne 'brief_content')
6378 ) {
6379 return undef;
6380 }
6381  
6382 # Use the marker patterns as patterns which mark the start of the component
6383 $componentObj->ivPush('startPatternList', $self->markerList);
6384 # Any line which doesn't contain one of these patterns marks the end of the component
6385 $componentObj->ivPush('stopBeforeNoPatternList', $self->markerList);
6386  
6387 return 1;
6388 }
6389  
6390 ##################
6391 # Accessors - set
6392  
6393 ##################
6394 # Accessors - get
6395  
6396 sub customPrimaryDirHash
6397 { my $self = shift; return %{$self->{customPrimaryDirHash}}; }
6398 sub customPrimaryAbbrevHash
6399 { my $self = shift; return %{$self->{customPrimaryAbbrevHash}}; }
6400  
6401 sub definiteList
6402 { my $self = shift; return @{$self->{definiteList}}; }
6403 sub indefiniteList
6404 { my $self = shift; return @{$self->{indefiniteList}}; }
6405 sub andList
6406 { my $self = shift; return @{$self->{andList}}; }
6407 sub orList
6408 { my $self = shift; return @{$self->{orList}}; }
6409 sub numberList
6410 { my $self = shift; return @{$self->{numberList}}; }
6411 sub markerList
6412 { my $self = shift; return @{$self->{markerList}}; }
6413  
6414 sub ivChangeHash
6415 { my $self = shift; return %{$self->{ivChangeHash}}; }
6416  
6417 sub componentTypeHash
6418 { my $self = shift; return %{$self->{componentTypeHash}}; }
6419 sub verboseComponentList
6420 { my $self = shift; return @{$self->{verboseComponentList}}; }
6421 sub shortComponentList
6422 { my $self = shift; return @{$self->{shortComponentList}}; }
6423 sub briefComponentList
6424 { my $self = shift; return @{$self->{briefComponentList}}; }
6425  
6426 sub bufferObjList
6427 { my $self = shift; return @{$self->{bufferObjList}}; }
6428 sub bufferTypeList
6429 { my $self = shift; return @{$self->{bufferTypeList}}; }
6430  
6431 sub analysisCount
6432 { $_[0]->{analysisCount} }
6433 sub analysisType
6434 { $_[0]->{analysisType} }
6435 sub analysisLength
6436 { $_[0]->{analysisLength} }
6437 sub analysisMinLength
6438 { $_[0]->{analysisMinLength} }
6439 sub analysisMaxLength
6440 { $_[0]->{analysisMaxLength} }
6441 sub analysisInc
6442 { $_[0]->{analysisInc} }
6443 sub analysisHash
6444 { my $self = shift; return %{$self->{analysisHash}}; }
6445  
6446 sub verboseComponentObjList
6447 { my $self = shift; return @{$self->{verboseComponentObjList}}; }
6448 sub shortComponentObjList
6449 { my $self = shift; return @{$self->{shortComponentObjList}}; }
6450 sub briefComponentObjList
6451 { my $self = shift; return @{$self->{briefComponentObjList}}; }
6452  
6453 sub profUpdateHash
6454 { my $self = shift; return %{$self->{profUpdateHash}}; }
6455  
6456 sub analysisExitList
6457 { my $self = shift; return @{$self->{analysisExitList}}; }
6458 sub tempStartText
6459 { $_[0]->{tempStartText} }
6460 sub tempStopText
6461 { $_[0]->{tempStopText} }
6462 sub tempDelimList
6463 { my $self = shift; return @{$self->{tempDelimList}}; }
6464  
6465 sub dirPageLang
6466 { $_[0]->{dirPageLang} }
6467 sub dictPageLang
6468 { $_[0]->{dictPageLang} }
6469 sub indexConvertHash
6470 { my $self = shift; return %{$self->{indexConvertHash}}; }
6471 }
6472  
6473 # Package must return a true value
6474 1