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

filter: Statementstmt 0.0% 0 / 3568 Branchbran 0.0% 0 / 1084 Conditioncond 0.0% 0 / 618 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 219 Podpod 0.0% 0 / 187 totaltotal 0.0% 0 / 5676 CC 543 SCAR 53.1
CC
543
Cov
0%
drawFileColumn
1190.0
drawGauges
812.0
objEnable
600.0
CRAP 203.1
1 # Copyright (C) 2011-2021 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::Strip::xxx
16 # Objects handling strips within an 'internal' window's client area
17  
18 { package Games::Axmud::Strip::MenuBar;
19  
20 use strict;
21 use warnings;
22 use diagnostics;
23  
24 use Glib qw(TRUE FALSE);
25  
26 our @ISA = qw(Games::Axmud::Generic::Strip Games::Axmud);
27  
28 ##################
29 # Constructors
30  
31 sub new {
32  
33 # Called by GA::Win::Internal->drawWidgets or ->addStripObj
34 # Creates the GA::Strip::MenuBar - a non-compulsory strip object containing a Gtk3::MenuBar
35 #
36 # Expected arguments
37 # $number - The strip object's number within the parent window (matches
38 # GA::Win::Internal->stripCount, or -1 for a temporary strip object
39 # created to access its default IVs)
40 # $winObj - The parent window object (GA::Win::Internal). 'temp' for temporary strip
41 # objects
42 #
43 # Optional arguments
44 # %initHash - A hash containing arbitrary data to use as the strip object's
45 # initialisation settings. The strip object should use default
46 # initialisation settings unless it can succesfully interpret one or more
47 # of the key-value pairs in the hash, if there are any
48 # - (This type of strip object requires no initialisation settings)
49 #
50 # Return values
51 # 'undef' on improper arguments
52 # Blessed reference to the newly-created object on success
53  
54 my ($class, $number, $winObj, %initHash) = @_;
55  
56 # Local variables
57 my %modHash;
58  
59 # Check for improper arguments
60 if (! defined $class || ! defined $number || ! defined $winObj) {
61  
62 return $axmud::CLIENT->writeImproper($class . '->new', @_);
63 }
64  
65 # Setup
66 my $self = {
67 _objName => 'strip_' . $number,
68 _objClass => $class,
69 _parentFile => undef, # No parent file object
70 _parentWorld => undef, # No parent file object
71 _privFlag => TRUE, # All IVs are private
72  
73 # Standard strip object IVs
74 # -------------------------
75  
76 # The strip object's number within the parent window (matches
77 # GA::Win::Internal->stripCount, or -1 for a temporary strip object created to access
78 # its default IVs)
79 number => $number,
80 # The type of strip object (custom strip objects should use a ->type starting with
81 # 'custom_' to avoid clashing with future built-in strip objects)
82 type => 'menu_bar',
83 # The parent window object (GA::Win::Internal). 'temp' for temporary strip objects
84 winObj => $winObj,
85  
86 # Flag set to TRUE if the strip object is visible (has actually drawn widgets in the
87 # window), set to FALSE if it is not visible (has drawn no widgets in the window, but
88 # still exists in GA::Win::Internal->stripHash, etc)
89 # The flag might be set to FALSE in strip objects like GA::Strip::GaugeBox, which might
90 # have gauges to draw, or not, depending on current conditions. (Most strip objects
91 # have this flag set to TRUE all the time)
92 # If FALSE, GA::Win::Internal->drawWidgets and ->addStripObj don't draw any widgets when
93 # called by this object's functions
94 # NB Strip objects are created with this flag set to TRUE or FALSE, but once created,
95 # the flag's value shouldn't be modified by anything other than
96 # GA::Win::Internal->hideStripObj and ->revealStripObj (which in turn call
97 # $self->set_visibleFlag)
98 visibleFlag => TRUE,
99 # Flag set to TRUE is the strip object should be given its share of any extra space
100 # within the packing box (the extra space is divided equally between all children of
101 # the box whose ->expandFlag is TRUE)
102 expandFlag => FALSE,
103 # Flag set to TRUE if any space given to the strip object by the 'expand' option is
104 # actually allocated within the strip object, FALSE if it is used as padding outside
105 # it (on both sides)
106 fillFlag => FALSE,
107 # Flag set to TRUE if the strip object should be packed into its window with a small
108 # gap between strip objects to either side; FALSE if not (can be set to FALSE if the
109 # the strip object's widgets are drawn in a way, such that a gap is not necessary,
110 # for example in the toolbar strip object)
111 spacingFlag => TRUE,
112 # Flag set to TRUE if only one instance of this strip object should be added to the
113 # parent window, set to FALSE if any number of instances can be added
114 jealousyFlag => TRUE,
115 # Flag set to TRUE if this strip object can be added when $axmud::BLIND_MODE_FLAG is
116 # TRUE, FALSE if it can't be added (because it's not useful for visually-impaired
117 # users)
118 blindFlag => FALSE,
119 # Flag set to TRUE if the main container widget, stored in $self->packingBox, should be
120 # allowed to accept the focus, FALSE if not. The restriction is applied during the
121 # call to GA::Win::Internal->drawWidgets and ->addStripObj. Even if FALSE, widgets in
122 # the container widget can be set to accept the focus (e.g. the Gtk3::Entry in
123 # GA::Strip::MenuBar)
124 allowFocusFlag => FALSE,
125  
126 # Initialisation settings stored as a hash (see the comments above)
127 initHash => \%modHash,
128 # Reference to a function to call when some widget is used. This IV is set only when
129 # required by this type of strip object. It can be set by a call to
130 # $self->set_func() or by some setting in $self->initHash, which is applied in the
131 # call to $self->objEnable(). To obtain a reference to an OOP method, you can use the
132 # generic object function Games::Axmud->getMethodRef()
133 funcRef => undef,
134 # A value passed to ->funcRef when it is called which identifies this strip object and
135 # its widget(s). Can be any value, including 'undef'. It can be set by a call to
136 # $self->set_id() or by some setting in $self->initHash, which is applied in the call
137 # to $self->objEnable()
138 funcID => undef,
139  
140 # The container widget for this strip object (usually a Gtk3::HBox or Gtk3::VBox). This
141 # widget is the one added to the window's main Gtk3::HBox or Gtk3::VBox
142 packingBox => undef, # Gtk3::VBox
143  
144 # Other IVs
145 # ---------
146  
147 # Widgets
148 menuBar => undef, # Gtk3::MenuBar
149  
150 # Menu items which will be sensitised or desensitised, depending on the context. Hash
151 # in the form:
152 # $menuItemHash{'item_name'} = Gtk3_widget
153 # ...where:
154 # 'item_name' is a descriptive scalar, e.g. 'move_up_level'
155 # 'Gtk3_widget' is the Gtk3 menu item
156 menuItemHash => {},
157  
158 # The menu column for 'plugins', which can be extended by any loaded plugins
159 pluginMenu => undef, # Gtk3::Menu
160 # Hash of sub-menus in the 'plugins' menu column, one for each plugin that wants one, in
161 # the form
162 # $pluginHash{plugin_name} = menu_widget
163 pluginHash => {},
164 # Additional list of menu items added by plugins, which will be sensitised or
165 # desensitised, depending on the context. Hash in the form:
166 # $pluginMenuItemHash{'plugin_name'} = Gtk3_widget
167 pluginMenuItemHash => {},
168  
169 # Flag set to TRUE when the 'save all sessions' menu item is selected (desensitises
170 # some other menu items)
171 saveAllSessionsFlag => FALSE,
172 };
173  
174 # Bless the object into existence
175 bless $self, $class;
176  
177 return $self;
178 }
179  
180 ##################
181 # Methods
182  
183 # Standard strip object functions
184  
185 sub objEnable {
186  
187 # Called by GA::Win::Internal->drawWidgets or ->addStripObj
188 # Sets up the strip object's widgets
189 #
190 # Expected arguments
191 # $winmapObj - The winmap object (GA::Obj::Winmap) that specifies the layout of the
192 # parent window
193 #
194 # Return values
195 # 'undef' on improper arguments
196 # 1 on success
197  
198 my ($self, $winmapObj, $check) = @_;
199  
200 # Check for improper arguments
201 if (! defined $winmapObj || defined $check) {
202  
203 return $axmud::CLIENT->writeImproper($self->_objClass . '->objEnable', @_);
204 }
205  
206 # Create a packing box
207 my $vBox = Gtk3::VBox->new(FALSE, 0);
208 $vBox->set_border_width(0);
209  
210 # Create a Gtk3::MenuBar
211 my $menuBar = Gtk3::MenuBar->new();
212 $vBox->pack_start($menuBar, TRUE, TRUE, 0);
213  
214 # 'World' column
215 my $menuColumn_world = $self->drawWorldColumn();
216 my $menuItem_world = Gtk3::MenuItem->new('_World');
217 $menuItem_world->set_submenu($menuColumn_world);
218 $menuBar->append($menuItem_world);
219  
220 # 'File' column
221 my $menuColumn_file = $self->drawFileColumn();
222 my $menuItem_file = Gtk3::MenuItem->new('_File');
223 $menuItem_file->set_submenu($menuColumn_file);
224 $menuBar->append($menuItem_file);
225  
226 # 'Edit' column
227 my $menuColumn_edit = $self->drawEditColumn();
228 my $menuItem_edit = Gtk3::MenuItem->new('_Edit');
229 $menuItem_edit->set_submenu($menuColumn_edit);
230 $menuBar->append($menuItem_edit);
231  
232 # 'Interfaces' column
233 my $menuColumn_interfaces = $self->drawInterfacesColumn();
234 my $menuItem_interfaces = Gtk3::MenuItem->new('_Interfaces');
235 $menuItem_interfaces->set_submenu($menuColumn_interfaces);
236 $menuBar->append($menuItem_interfaces);
237  
238 # 'Tasks' column
239 my $menuColumn_tasks = $self->drawTasksColumn();
240 my $menuItem_tasks = Gtk3::MenuItem->new('_Tasks');
241 $menuItem_tasks->set_submenu($menuColumn_tasks);
242 $menuBar->append($menuItem_tasks);
243  
244 # 'Display' column
245 my $menuColumn_display = $self->drawDisplayColumn();
246 my $menuItem_display = Gtk3::MenuItem->new('_Display');
247 $menuItem_display->set_submenu($menuColumn_display);
248 $menuBar->append($menuItem_display);
249  
250 # 'Commands' column
251 my $menuColumn_commands = $self->drawCommandsColumn();
252 my $menuItem_commands = Gtk3::MenuItem->new('_Commands');
253 $menuItem_commands->set_submenu($menuColumn_commands);
254 $menuBar->append($menuItem_commands);
255  
256 # 'Recordings' column
257 my $menuColumn_recordings = $self->drawRecordingsColumn();
258 my $menuItem_recordings = Gtk3::MenuItem->new('_Recordings');
259 $menuItem_recordings->set_submenu($menuColumn_recordings);
260 $menuBar->append($menuItem_recordings);
261  
262 # 'Axbasic' column
263 my $menuColumn_basic = $self->drawAxbasicColumn();
264 my $menuItem_basic = Gtk3::MenuItem->new('_' . $axmud::BASIC_NAME);
265 $menuItem_basic->set_submenu($menuColumn_basic);
266 $menuBar->append($menuItem_basic);
267  
268 # 'Plugins' column
269 my $menuColumn_plugins = $self->drawPluginsColumn();
270 my $menuItem_plugins = Gtk3::MenuItem->new('_Plugins');
271 $menuItem_plugins->set_submenu($menuColumn_plugins);
272 $menuBar->append($menuItem_plugins);
273  
274 # 'Help' column
275 my $menuColumn_help = $self->drawHelpColumn();
276 my $menuItem_help = Gtk3::MenuItem->new('_Help');
277 $menuItem_help->set_submenu($menuColumn_help);
278 $menuBar->append($menuItem_help);
279  
280 # Update IVs
281 $self->ivPoke('packingBox', $vBox);
282 $self->ivPoke('menuBar', $menuBar);
283 $self->ivPoke('pluginMenu', $menuColumn_plugins);
284  
285 # If any plugins have registered their desire to create sub-menus, call those plugins and
286 # create the sub-menus now
287 foreach my $pluginObj (sort {lc($a) cmp lc($b)} ($axmud::CLIENT->ivValues('pluginHash'))) {
288  
289 my ($funcRef, $subMenu);
290  
291 if (
292 $pluginObj->enabledFlag
293 && $axmud::CLIENT->ivExists('pluginMenuFuncHash', $pluginObj->name)
294 ) {
295 $funcRef = $axmud::CLIENT->ivShow('pluginMenuFuncHash', $pluginObj->name);
296 $subMenu = $self->addPluginWidgets($pluginObj->name);
297  
298 if ($funcRef && $subMenu) {
299  
300 &$funcRef($self, $subMenu);
301 }
302 }
303 }
304  
305 # Sensitise/desensitise menu bar/toolbar items, depending on current conditions
306 $axmud::CLIENT->desktopObj->restrictWidgets();
307  
308 return 1;
309 }
310  
311 sub objDestroy {
312  
313 # Called by GA::Win::Internal->removeStripObj, just before the strip is removed from its
314 # parent window, and also by ->winDestroy and ->resetWinmap, to give this object a chance
315 # to do any necessary tidying up
316 #
317 # Expected arguments
318 # (none besides $self)
319 #
320 # Return values
321 # 'undef' on improper arguments
322 # 1 otherwise
323  
324 my ($self, $check) = @_;
325  
326 # Check for improper arguments
327 if (defined $check) {
328  
329 return $axmud::CLIENT->writeImproper($self->_objClass . '->objDestroy', @_);
330 }
331  
332 # (No tidying up required for this type of strip object)
333 # ...
334  
335 return 1;
336 }
337  
338 # sub setWidgetsIfSession {} # Inherited from GA::Generic::Strip
339  
340 # sub setWidgetsChangeSession {} # Inherited from GA::Generic::Strip
341  
342 # ->signal_connects are stored in $self->drawWorldColumn, etc
343  
344 # Other functions
345  
346 sub drawWorldColumn {
347  
348 # Called by $self->enableMenu
349 # Sets up the menu's 'World' column
350 #
351 # Expected arguments
352 # (none besides $self)
353 #
354 # Return values
355 # 'undef' on improper arguments, or if the menu can't be created
356 # Otherwise returns the Gtk3::Menu created
357  
358 my ($self, $check) = @_;
359  
360 # Local variables
361 my ($mode, $choice);
362  
363 # Check for improper arguments
364 if (defined $check) {
365  
366 return $axmud::CLIENT->writeImproper($self->_objClass . '->drawWorldColumn', @_);
367 }
368  
369 # Import IVs (for convenience)
370 $mode = $self->winObj->pseudoCmdMode;
371  
372 # Set up column
373 my $menuColumn_world = Gtk3::Menu->new();
374 if (! $menuColumn_world) {
375  
376 return undef;
377 }
378  
379 my $menuItem_connect = Gtk3::ImageMenuItem->new('_Connect...');
380 my $menuImg_connect = Gtk3::Image->new_from_stock('gtk-connect', 'menu');
381 $menuItem_connect->set_image($menuImg_connect);
382 $menuItem_connect->signal_connect('activate' => sub {
383  
384 my $winObj;
385  
386 if ($self->winObj->visibleSession) {
387  
388 $self->winObj->visibleSession->pseudoCmd('connect', $mode);
389  
390 } else {
391  
392 # Can't use ';connect' because the parent window has no visible session
393  
394 # Check that the Connections window isn't already open
395 if ($axmud::CLIENT->connectWin) {
396  
397 # Window already open; draw attention to the fact by 'present'ing it
398 $axmud::CLIENT->connectWin->restoreFocus();
399  
400 } else {
401  
402 # Open the Connections window
403 $winObj = $self->winObj->quickFreeWin(
404 'Games::Axmud::OtherWin::Connect',
405 $self->winObj->visibleSession,
406 );
407  
408 if ($winObj) {
409  
410 # Only one Connections window can be open at a time
411 $axmud::CLIENT->set_connectWin($winObj);
412 }
413 }
414 }
415 });
416 $menuColumn_world->append($menuItem_connect);
417 # (Desensitised only when the setup wizwin is open)
418 $self->ivAdd('menuItemHash', 'connect', $menuItem_connect);
419  
420 my $menuItem_reconnect = Gtk3::ImageMenuItem->new('_Reconnect');
421 my $menuImg_reconnect = Gtk3::Image->new_from_stock('gtk-connect', 'menu');
422 $menuItem_reconnect->set_image($menuImg_reconnect);
423 $menuItem_reconnect->signal_connect('activate' => sub {
424  
425 $self->winObj->visibleSession->pseudoCmd('reconnect', $mode);
426 });
427 $menuColumn_world->append($menuItem_reconnect);
428 # (Requires a visible session)
429 $self->ivAdd('menuItemHash', 'reconnect', $menuItem_reconnect);
430  
431 my $menuItem_reconnectOffline = Gtk3::MenuItem->new('Reconnect _offline');
432 $menuItem_reconnectOffline->signal_connect('activate' => sub {
433  
434 $self->winObj->visibleSession->pseudoCmd('reconnect -o', $mode);
435 });
436 $menuColumn_world->append($menuItem_reconnectOffline);
437 # (Requires a visible session)
438 $self->ivAdd('menuItemHash', 'reconnect_offline', $menuItem_reconnectOffline);
439  
440 my $menuItem_xConnect = Gtk3::MenuItem->new('Reconnect (_no save)');
441 $menuItem_xConnect->signal_connect('activate' => sub {
442  
443 $self->winObj->visibleSession->pseudoCmd('xconnect', $mode);
444 });
445 $menuColumn_world->append($menuItem_xConnect);
446 # (Requires a visible session)
447 $self->ivAdd('menuItemHash', 'xconnect', $menuItem_xConnect);
448  
449 my $menuItem_xConnectOffline = Gtk3::MenuItem->new('Reconnect offline (no _save)');
450 $menuItem_xConnectOffline->signal_connect('activate' => sub {
451  
452 $self->winObj->visibleSession->pseudoCmd('xconnect -o', $mode);
453 });
454 $menuColumn_world->append($menuItem_xConnectOffline);
455 # (Requires a visible session)
456 $self->ivAdd('menuItemHash', 'xconnect_offline', $menuItem_xConnectOffline);
457  
458 $menuColumn_world->append(Gtk3::SeparatorMenuItem->new()); # Separator
459  
460 my $menuItem_login = Gtk3::ImageMenuItem->new('Character _login');
461 my $menuImg_login = Gtk3::Image->new_from_stock('gtk-network', 'menu');
462 $menuItem_login->set_image($menuImg_login);
463 $menuItem_login->signal_connect('activate' => sub {
464  
465 $self->winObj->visibleSession->pseudoCmd('login', $mode);
466 });
467 $menuColumn_world->append($menuItem_login);
468 # (Requires a visible session whose status is 'connected' or 'offline')
469 $self->ivAdd('menuItemHash', 'login', $menuItem_login);
470  
471 $menuColumn_world->append(Gtk3::SeparatorMenuItem->new()); # Separator
472  
473 my $menuItem_quit = Gtk3::ImageMenuItem->new('Send _quit');
474 my $menuImg_quit = Gtk3::Image->new_from_stock('gtk-disconnect', 'menu');
475 $menuItem_quit->set_image($menuImg_quit);
476 $menuItem_quit->signal_connect('activate' => sub {
477  
478 if (
479 $self->promptUser(
480 'Confirm quit',
481 'Are you sure you want to send the \'quit\' command?',
482 )
483 ) {
484 $self->winObj->visibleSession->pseudoCmd('quit', $mode);
485 }
486 });
487 $menuColumn_world->append($menuItem_quit);
488 # (Requires a visible session whose status is 'connected' or 'offline')
489 $self->ivAdd('menuItemHash', 'quit', $menuItem_quit);
490  
491 my $menuItem_qquit = Gtk3::MenuItem->new('Send quit (no sa_ve)');
492 $menuItem_qquit->signal_connect('activate' => sub {
493  
494 if (
495 $self->promptUser(
496 'Confirm quit',
497 'Are you sure you want to send the \'quit\' command without saving?',
498 )
499 ) {
500 $self->winObj->visibleSession->pseudoCmd('qquit', $mode);
501 }
502 });
503 $menuColumn_world->append($menuItem_qquit);
504 # (Requires a visible session whose status is 'connected' or 'offline')
505 $self->ivAdd('menuItemHash', 'qquit', $menuItem_qquit);
506  
507 my $menuItem_quitAll = Gtk3::MenuItem->new('Send quit (_all sessions)');
508 $menuItem_quitAll->signal_connect('activate' => sub {
509  
510 if (
511 $self->promptUser(
512 'Confirm quit',
513 'Are you sure you want to send the \'quit\' command in all sessions?',
514 )
515 ) {
516 $self->winObj->visibleSession->pseudoCmd('quitall', $mode);
517 }
518 });
519 $menuColumn_world->append($menuItem_quitAll);
520 # (Requires a visible session)
521 $self->ivAdd('menuItemHash', 'quit_all', $menuItem_quitAll);
522  
523 $menuColumn_world->append(Gtk3::SeparatorMenuItem->new()); # Separator
524  
525 my $menuItem_exit = Gtk3::ImageMenuItem->new('_Exit session');
526 my $menuImg_exit = Gtk3::Image->new_from_stock('gtk-disconnect', 'menu');
527 $menuItem_exit->set_image($menuImg_exit);
528 $menuItem_exit->signal_connect('activate' => sub {
529  
530 if (
531 $self->promptUser(
532 'Confirm exit',
533 'Are you sure you want to exit this session?',
534 )
535 ) {
536 $self->winObj->visibleSession->pseudoCmd('exit', $mode);
537 }
538 });
539 $menuColumn_world->append($menuItem_exit);
540 # (Requires a visible session whose status is 'connected' or 'offline')
541 $self->ivAdd('menuItemHash', 'exit', $menuItem_exit);
542  
543 my $menuItem_xxit = Gtk3::MenuItem->new('E_xit session (no save)');
544 $menuItem_xxit->signal_connect('activate' => sub {
545  
546 if (
547 $self->promptUser(
548 'Confirm exit',
549 'Are you sure you want to exit this session without saving?',
550 )
551 ) {
552 $self->winObj->visibleSession->pseudoCmd('xxit', $mode);
553 }
554 });
555 $menuColumn_world->append($menuItem_xxit);
556 # (Requires a visible session whose status is 'connected' or 'offline')
557 $self->ivAdd('menuItemHash', 'xxit', $menuItem_xxit);
558  
559 my $menuItem_exitAll = Gtk3::MenuItem->new('Ex_it all sessions');
560 $menuItem_exitAll->signal_connect('activate' => sub {
561  
562 if (
563 $self->promptUser(
564 'Confirm exit',
565 'Are you sure you want to exit every session?',
566 )
567 ) {
568 $self->winObj->visibleSession->pseudoCmd('exitall', $mode);
569 }
570 });
571 $menuColumn_world->append($menuItem_exitAll);
572 # (Requires a visible session)
573 $self->ivAdd('menuItemHash', 'exit_all', $menuItem_exitAll);
574  
575 $menuColumn_world->append(Gtk3::SeparatorMenuItem->new()); # Separator
576  
577 my $menuItem_stopSession = Gtk3::ImageMenuItem->new('S_top session');
578 my $menuImg_stopSession = Gtk3::Image->new_from_stock('gtk-close', 'menu');
579 $menuItem_stopSession->set_image($menuImg_stopSession);
580 $menuItem_stopSession->signal_connect('activate' => sub {
581  
582 if (
583 $self->winObj->visibleSession->status eq 'connected'
584 && $axmud::CLIENT->confirmCloseMenuFlag
585 ) {
586 $choice = $self->winObj->showMsgDialogue(
587 'Stop session',
588 'question',
589 'This session is connected to a world. Are you sure you want to stop it?',
590 'yes-no',
591 );
592  
593 if ($choice eq 'yes') {
594  
595 $self->winObj->visibleSession->pseudoCmd('stopsession', $mode);
596 }
597  
598 } else {
599  
600 $self->winObj->visibleSession->pseudoCmd('stopsession', $mode);
601 }
602 });
603 $menuColumn_world->append($menuItem_stopSession);
604 # (Requires a visible session)
605 $self->ivAdd('menuItemHash', 'stop_session', $menuItem_stopSession);
606  
607 my $menuItem_stopClient = Gtk3::ImageMenuItem->new('Sto_p client');
608 my $menuImg_stopClient = Gtk3::Image->new_from_stock('gtk-quit', 'menu');
609 $menuItem_stopClient->set_image($menuImg_stopClient);
610 $menuItem_stopClient->signal_connect('activate' => sub {
611  
612 # If there are any connected sessions or unsaved files, prompt the user before executing
613 # the client command; otherwise go ahead and do the ';stopclient' operation
614 if (
615 $axmud::CLIENT->checkSessions()
616 || $self->promptUser(
617 'Confirm stop client',
618 'Are you sure you want to close the ' . $axmud::SCRIPT . ' client?',
619 )
620 ) {
621 if ($self->winObj->visibleSession) {
622  
623 $self->winObj->visibleSession->pseudoCmd('stopclient', $mode);
624  
625 } else {
626  
627 # Can't use ';stopclient' because there is no current session
628 $axmud::CLIENT->stop();
629 }
630 }
631 });
632 $menuColumn_world->append($menuItem_stopClient);
633 # (Desensitised only when the setup wizwin is open)
634 $self->ivAdd('menuItemHash', 'stop_client', $menuItem_stopClient);
635  
636 # Setup complete
637 return $menuColumn_world;
638 }
639  
640 sub drawFileColumn {
641  
642 # Called by $self->enableMenu
643 # Sets up the menu's 'File' column
644 #
645 # Expected arguments
646 # (none besides $self)
647 #
648 # Return values
649 # 'undef' on improper arguments, or if the menu can't be created
650 # Otherwise returns the Gtk3::Menu created
651  
652 my ($self, $check) = @_;
653  
654 # Local variables
655 my ($mode, $forceSwitch, $allSessionSwitch);
656  
657 # Check for improper arguments
658 if (defined $check) {
659  
660 return $axmud::CLIENT->writeImproper($self->_objClass . '->drawFileColumn', @_);
661 }
662  
663 # Import IVs (for convenience)
664 $mode = $self->winObj->pseudoCmdMode;
665  
666 # A pair of radio buttons toggle the value of this string between '' and ' -f', used with
667 # the ';save' command
668 $forceSwitch = '';
669 # Another pair of buttons toggle the value of this string between '' and ' -a', used with
670 # the ';save' command
671 $allSessionSwitch = '';
672  
673 # Set up column
674 my $menuColumn_file = Gtk3::Menu->new();
675 if (! $menuColumn_file) {
676  
677 return undef;
678 }
679  
680 my $menuItem_loadAll = Gtk3::ImageMenuItem->new('_Load all');
681 my $menuImg_loadAll = Gtk3::Image->new_from_stock('gtk-open', 'menu');
682 $menuItem_loadAll->set_image($menuImg_loadAll);
683 $menuItem_loadAll->signal_connect('activate' => sub {
684  
685 $self->winObj->visibleSession->pseudoCmd('load', $mode);
686 });
687 $menuColumn_file->append($menuItem_loadAll);
688 # (Requires a visible session whose status is 'connected' or 'offline')
689 $self->ivAdd('menuItemHash', 'load_all', $menuItem_loadAll);
690  
691 # 'Load files' submenu
692 my $subMenu_loadFile = Gtk3::Menu->new();
693  
694 my $menuItem_loadFile_worldModel = Gtk3::MenuItem->new('_World model file');
695 $menuItem_loadFile_worldModel->signal_connect('activate' => sub {
696  
697 $self->winObj->visibleSession->pseudoCmd('load -m', $mode);
698 });
699 $subMenu_loadFile->append($menuItem_loadFile_worldModel);
700  
701 my $menuItem_loadFile_tasks = Gtk3::MenuItem->new('_Tasks file');
702 $menuItem_loadFile_tasks->signal_connect('activate' => sub {
703  
704 $self->winObj->visibleSession->pseudoCmd('load -t', $mode);
705 });
706 $subMenu_loadFile->append($menuItem_loadFile_tasks);
707  
708 my $menuItem_loadFile_scripts = Gtk3::MenuItem->new('_Scripts file');
709 $menuItem_loadFile_scripts->signal_connect('activate' => sub {
710  
711 $self->winObj->visibleSession->pseudoCmd('load -s', $mode);
712 });
713 $subMenu_loadFile->append($menuItem_loadFile_scripts);
714  
715 my $menuItem_loadFile_contacts = Gtk3::MenuItem->new('_Contacts file');
716 $menuItem_loadFile_contacts->signal_connect('activate' => sub {
717  
718 $self->winObj->visibleSession->pseudoCmd('load -n', $mode);
719 });
720 $subMenu_loadFile->append($menuItem_loadFile_contacts);
721  
722 my $menuItem_loadFile_dicts = Gtk3::MenuItem->new('_Dictionaries file');
723 $menuItem_loadFile_dicts->signal_connect('activate' => sub {
724  
725 $self->winObj->visibleSession->pseudoCmd('load -y', $mode);
726 });
727 $subMenu_loadFile->append($menuItem_loadFile_dicts);
728  
729 my $menuItem_loadFile_toolbar = Gtk3::MenuItem->new('Tool_bar file');
730 $menuItem_loadFile_toolbar->signal_connect('activate' => sub {
731  
732 $self->winObj->visibleSession->pseudoCmd('load -b', $mode);
733 });
734 $subMenu_loadFile->append($menuItem_loadFile_toolbar);
735  
736 my $menuItem_loadFile_userComm = Gtk3::MenuItem->new('_User commands file');
737 $menuItem_loadFile_userComm->signal_connect('activate' => sub {
738  
739 $self->winObj->visibleSession->pseudoCmd('load -u', $mode);
740 });
741 $subMenu_loadFile->append($menuItem_loadFile_userComm);
742  
743 my $menuItem_loadFile_zonemaps = Gtk3::MenuItem->new('_Zonemaps file');
744 $menuItem_loadFile_zonemaps->signal_connect('activate' => sub {
745  
746 $self->winObj->visibleSession->pseudoCmd('load -z', $mode);
747 });
748 $subMenu_loadFile->append($menuItem_loadFile_zonemaps);
749  
750 my $menuItem_loadFile_winmaps = Gtk3::MenuItem->new('Win_maps file');
751 $menuItem_loadFile_winmaps->signal_connect('activate' => sub {
752  
753 $self->winObj->visibleSession->pseudoCmd('load -p', $mode);
754 });
755 $subMenu_loadFile->append($menuItem_loadFile_winmaps);
756  
757 my $menuItem_loadFile_ttsObjs = Gtk3::MenuItem->new('T_ext-to-speech file');
758 $menuItem_loadFile_ttsObjs->signal_connect('activate' => sub {
759  
760 $self->winObj->visibleSession->pseudoCmd('load -x', $mode);
761 });
762 $subMenu_loadFile->append($menuItem_loadFile_ttsObjs);
763  
764 my $menuItem_loadFile = Gtk3::MenuItem->new('L_oad files');
765 $menuItem_loadFile->set_submenu($subMenu_loadFile);
766 $menuColumn_file->append($menuItem_loadFile);
767 # (Requires a visible session whose status is 'connected' or 'offline')
768 $self->ivAdd('menuItemHash', 'load_file', $menuItem_loadFile);
769  
770 $menuColumn_file->append(Gtk3::SeparatorMenuItem->new()); # Separator
771  
772 my $menuItem_saveAll = Gtk3::ImageMenuItem->new('_Save all');
773 my $menuImg_saveAll = Gtk3::Image->new_from_stock('gtk-save', 'menu');
774 $menuItem_saveAll->set_image($menuImg_saveAll);
775 $menuItem_saveAll->signal_connect('activate' => sub {
776  
777 $self->winObj->visibleSession->pseudoCmd(
778 'save ' . $forceSwitch . $allSessionSwitch,
779 $mode,
780 );
781 });
782 $menuColumn_file->append($menuItem_saveAll);
783 # (Requires a visible session whose status is 'connected' or 'offline')
784 $self->ivAdd('menuItemHash', 'save_all', $menuItem_saveAll);
785  
786 # 'Save files' submenu
787 my $subMenu_saveFile = Gtk3::Menu->new();
788  
789 my $menuItem_saveFile_config = Gtk3::MenuItem->new('_Config file');
790 $menuItem_saveFile_config->signal_connect('activate' => sub {
791  
792 $self->winObj->visibleSession->pseudoCmd('save -i' . $forceSwitch, $mode);
793 });
794 $subMenu_saveFile->append($menuItem_saveFile_config);
795  
796 $subMenu_saveFile->append(Gtk3::SeparatorMenuItem->new()); # Separator
797  
798 my $menuItem_saveFile_prof = Gtk3::MenuItem->new('_Profile files');
799 $menuItem_saveFile_prof->signal_connect('activate' => sub {
800  
801 $self->winObj->visibleSession->pseudoCmd('save -d' . $forceSwitch, $mode);
802 });
803 $subMenu_saveFile->append($menuItem_saveFile_prof);
804  
805 my $menuItem_saveFile_currentProf = Gtk3::MenuItem->new('C_urrent profile files');
806 $menuItem_saveFile_currentProf->signal_connect('activate' => sub {
807  
808 $self->winObj->visibleSession->pseudoCmd('save -c' . $forceSwitch, $mode);
809 });
810 $subMenu_saveFile->append($menuItem_saveFile_currentProf);
811  
812 my $menuItem_saveFile_worldProf = Gtk3::MenuItem->new('_World definition...');
813 $menuItem_saveFile_worldProf->signal_connect('activate' => sub {
814  
815 # Display a 'dialogue' window, so the user can choose a world profile
816 my (
817 $choice,
818 @worldList,
819 );
820  
821 # Get an ordered list of all world profiles
822 @worldList = $self->getWorldList();
823 if (@worldList) {
824  
825 # Display the dialogue
826 $choice = $self->winObj->showComboDialogue(
827 'Save file',
828 'Select a world profile to save',
829 \@worldList,
830 );
831  
832 if ($choice) {
833  
834 # Save the file
835 $self->winObj->visibleSession->pseudoCmd(
836 'save -o ' . $choice . $forceSwitch,
837 $mode,
838 );
839 }
840 }
841 });
842 $subMenu_saveFile->append($menuItem_saveFile_worldProf);
843  
844 my $menuItem_saveFile_currentWorld = Gtk3::MenuItem->new('Cu_rrent world files');
845 $menuItem_saveFile_currentWorld->signal_connect('activate' => sub {
846  
847 $self->winObj->visibleSession->pseudoCmd('save -w' . $forceSwitch, $mode);
848 });
849 $subMenu_saveFile->append($menuItem_saveFile_currentWorld);
850  
851 $subMenu_saveFile->append(Gtk3::SeparatorMenuItem->new()); # Separator
852  
853 my $menuItem_saveFile_worldModel = Gtk3::MenuItem->new('World _model file');
854 $menuItem_saveFile_worldModel->signal_connect('activate' => sub {
855  
856 $self->winObj->visibleSession->pseudoCmd('save -m' . $forceSwitch, $mode);
857 });
858 $subMenu_saveFile->append($menuItem_saveFile_worldModel);
859  
860 my $menuItem_saveFile_tasks = Gtk3::MenuItem->new('_Tasks file');
861 $menuItem_saveFile_tasks->signal_connect('activate' => sub {
862  
863 $self->winObj->visibleSession->pseudoCmd('save -t' . $forceSwitch, $mode);
864 });
865 $subMenu_saveFile->append($menuItem_saveFile_tasks);
866  
867 my $menuItem_saveFile_scripts = Gtk3::MenuItem->new('_Scripts file');
868 $menuItem_saveFile_scripts->signal_connect('activate' => sub {
869  
870 $self->winObj->visibleSession->pseudoCmd('save -s' . $forceSwitch, $mode);
871 });
872 $subMenu_saveFile->append($menuItem_saveFile_scripts);
873  
874 my $menuItem_saveFile_contacts = Gtk3::MenuItem->new('C_ontacts file');
875 $menuItem_saveFile_contacts->signal_connect('activate' => sub {
876  
877 $self->winObj->visibleSession->pseudoCmd('save -n' . $forceSwitch, $mode);
878 });
879 $subMenu_saveFile->append($menuItem_saveFile_contacts);
880  
881 my $menuItem_saveFile_dicts = Gtk3::MenuItem->new('_Dictionaries file');
882 $menuItem_saveFile_dicts->signal_connect('activate' => sub {
883  
884 $self->winObj->visibleSession->pseudoCmd('save -y' . $forceSwitch, $mode);
885 });
886 $subMenu_saveFile->append($menuItem_saveFile_dicts);
887  
888 my $menuItem_saveFile_toolbar = Gtk3::MenuItem->new('Tool_bar file');
889 $menuItem_saveFile_toolbar->signal_connect('activate' => sub {
890  
891 $self->winObj->visibleSession->pseudoCmd('save -b' . $forceSwitch, $mode);
892 });
893 $subMenu_saveFile->append($menuItem_saveFile_toolbar);
894  
895 my $menuItem_saveFile_userComm = Gtk3::MenuItem->new('Us_er commands file');
896 $menuItem_saveFile_userComm->signal_connect('activate' => sub {
897  
898 $self->winObj->visibleSession->pseudoCmd('save -u' . $forceSwitch, $mode);
899 });
900 $subMenu_saveFile->append($menuItem_saveFile_userComm);
901  
902 my $menuItem_saveFile_zonemaps = Gtk3::MenuItem->new('_Zonemaps file');
903 $menuItem_saveFile_zonemaps->signal_connect('activate' => sub {
904  
905 $self->winObj->visibleSession->pseudoCmd('save -z' . $forceSwitch, $mode);
906 });
907 $subMenu_saveFile->append($menuItem_saveFile_zonemaps);
908  
909 my $menuItem_saveFile_winmaps = Gtk3::MenuItem->new('W_inmaps file');
910 $menuItem_saveFile_winmaps->signal_connect('activate' => sub {
911  
912 $self->winObj->visibleSession->pseudoCmd('save -p' . $forceSwitch, $mode);
913 });
914 $subMenu_saveFile->append($menuItem_saveFile_winmaps);
915  
916 my $menuItem_saveFile_ttsObjs = Gtk3::MenuItem->new('Te_xt-to-speech file');
917 $menuItem_saveFile_ttsObjs->signal_connect('activate' => sub {
918  
919 $self->winObj->visibleSession->pseudoCmd('save -x' . $forceSwitch, $mode);
920 });
921 $subMenu_saveFile->append($menuItem_saveFile_ttsObjs);
922  
923 my $menuItem_saveFile = Gtk3::MenuItem->new('S_ave files');
924 $menuItem_saveFile->set_submenu($subMenu_saveFile);
925 $menuColumn_file->append($menuItem_saveFile);
926 # (Requires a visible session whose status is 'connected' or 'offline' and
927 # $self->saveAllSessionsFlag set to FALSE)
928 $self->ivAdd('menuItemHash', 'save_file', $menuItem_saveFile);
929  
930 # 'Save options' submenu
931 my $subMenu_saveOptions = Gtk3::Menu->new();
932  
933 my $menuColumn_forced_radio1 = Gtk3::RadioMenuItem->new_with_mnemonic(
934 undef,
935 'Forced saves o_ff',
936 );
937 $menuColumn_forced_radio1->signal_connect('toggled' => sub {
938  
939 if ($menuColumn_forced_radio1->get_active()) {
940 $forceSwitch = '';
941 } else {
942 $forceSwitch = ' -f';
943 }
944 });
945 $subMenu_saveOptions->append($menuColumn_forced_radio1);
946  
947 my $menuColumn_forced_radio2 = Gtk3::RadioMenuItem->new_with_mnemonic(
948 $menuColumn_forced_radio1->get_group(),
949 'Forced saves o_n',
950 );
951 $subMenu_saveOptions->append($menuColumn_forced_radio2);
952  
953 $subMenu_saveOptions->append(Gtk3::SeparatorMenuItem->new()); # Separator
954  
955 my $menuColumn_allSession_radio1 = Gtk3::RadioMenuItem->new_with_mnemonic(
956 undef,
957 'Save in _this session',
958 );
959 $menuColumn_allSession_radio1->signal_connect('toggled' => sub {
960  
961 if ($menuColumn_allSession_radio1->get_active()) {
962  
963 $allSessionSwitch = '';
964 $self->ivPoke('saveAllSessionsFlag', FALSE);
965  
966 } else {
967  
968 $allSessionSwitch = ' -a';
969 $self->ivPoke('saveAllSessionsFlag', TRUE);
970 }
971  
972 # Sensitise/desensitise menu bar/toolbar items, depending on current conditions
973 $axmud::CLIENT->desktopObj->restrictWidgets();
974 });
975 $subMenu_saveOptions->append($menuColumn_allSession_radio1);
976  
977 my $menuColumn_allSession_radio2 = Gtk3::RadioMenuItem->new_with_mnemonic(
978 $menuColumn_allSession_radio1->get_group(),
979 'Save in _all sessions',
980 );
981 $subMenu_saveOptions->append($menuColumn_allSession_radio2);
982  
983 $subMenu_saveOptions->append(Gtk3::SeparatorMenuItem->new()); # Separator
984  
985 my $menuItem_autoSaves_off = Gtk3::MenuItem->new('T_urn auto-saves off');
986 $menuItem_autoSaves_off->signal_connect('activate' => sub {
987  
988 $self->winObj->visibleSession->pseudoCmd('autosave off', $mode);
989 });
990 $subMenu_saveOptions->append($menuItem_autoSaves_off);
991  
992 my $menuItem_autoSaves_on = Gtk3::MenuItem->new('Tu_rn auto-saves on');
993 $menuItem_autoSaves_on->signal_connect('activate' => sub {
994  
995 $self->winObj->visibleSession->pseudoCmd('autosave on', $mode);
996 });
997 $subMenu_saveOptions->append($menuItem_autoSaves_on);
998  
999 $subMenu_saveOptions->append(Gtk3::SeparatorMenuItem->new()); # Separator
1000  
1001 my $menuItem_autoSaves_setTime = Gtk3::MenuItem->new('_Set auto-save time...');
1002 $menuItem_autoSaves_setTime->signal_connect('activate' => sub {
1003  
1004 my $number = $self->winObj->showEntryDialogue(
1005 'Set auto-save time',
1006 'Enter a time in seconds',
1007 );
1008  
1009 if ($number) {
1010  
1011 # Set the auto-save time
1012 $self->winObj->visibleSession->pseudoCmd('autosave ' . $number, $mode);
1013 }
1014 });
1015 $subMenu_saveOptions->append($menuItem_autoSaves_setTime);
1016  
1017 my $menuItem_saveOptions = Gtk3::MenuItem->new('Sa_ve options');
1018 $menuItem_saveOptions->set_submenu($subMenu_saveOptions);
1019 $menuColumn_file->append($menuItem_saveOptions);
1020 # (Requires a visible session whose status is 'connected' or 'offline')
1021 $self->ivAdd('menuItemHash', 'save_options', $menuItem_saveOptions);
1022  
1023 $menuColumn_file->append(Gtk3::SeparatorMenuItem->new()); # Separator
1024  
1025 my $menuItem_importFile = Gtk3::MenuItem->new('I_mport files...');
1026 $menuItem_importFile->signal_connect('activate' => sub {
1027  
1028 $self->winObj->visibleSession->pseudoCmd('importfiles', $mode);
1029 });
1030 $menuColumn_file->append($menuItem_importFile);
1031 # (Requires a visible session whose status is 'connected' or 'offline')
1032 $self->ivAdd('menuItemHash', 'import_files', $menuItem_importFile);
1033  
1034 # my $menuItem_exportAllFile = Gtk3::MenuItem->new('_Export all files...');
1035 # $menuItem_exportAllFile->signal_connect('activate' => sub {
1036 #
1037 # $self->winObj->visibleSession->pseudoCmd('exportfiles', $mode);
1038 # });
1039 # $menuColumn_file->append($menuItem_exportAllFile);
1040 # # (Requires a visible session whose status is 'connected' or 'offline')
1041 # $self->ivAdd('menuItemHash', 'export_all_files', $menuItem_exportAllFile);
1042  
1043 # 'Export files' submenu
1044 my $subMenu_exportFile = Gtk3::Menu->new();
1045  
1046 my $menuItem_exportFile_world = Gtk3::MenuItem->new('_World files...');
1047 $menuItem_exportFile_world->signal_connect('activate' => sub {
1048  
1049 # Display a 'dialogue' window, so the user can choose a world profile
1050 my (
1051 $choice,
1052 @worldList,
1053 );
1054  
1055 # Get an ordered list of all world profiles
1056 @worldList = $self->getWorldList();
1057 if (@worldList) {
1058  
1059 # Display the dialogue
1060 $choice = $self->winObj->showComboDialogue(
1061 'Export file',
1062 'Select a world profile to export',
1063 \@worldList,
1064 );
1065  
1066 if ($choice) {
1067  
1068 # Export the file
1069 $self->winObj->visibleSession->pseudoCmd(
1070 'exportfiles -w ' . $choice,
1071 $mode,
1072 );
1073 }
1074 }
1075 });
1076 $subMenu_exportFile->append($menuItem_exportFile_world);
1077  
1078 $subMenu_exportFile->append(Gtk3::SeparatorMenuItem->new()); # Separator
1079  
1080 my $menuItem_exportFile_model = Gtk3::MenuItem->new('World _model file...');
1081 $menuItem_exportFile_model->signal_connect('activate' => sub {
1082  
1083 # Display a 'dialogue' window, so the user can choose a world profile
1084 my (
1085 $choice,
1086 @worldList,
1087 );
1088  
1089 # Get an ordered list of all world profiles
1090 @worldList = $self->getWorldList();
1091 if (@worldList) {
1092  
1093 # Display the dialogue
1094 $choice = $self->winObj->showComboDialogue(
1095 'Export file',
1096 'Select a world model to export',
1097 \@worldList,
1098 );
1099  
1100 if ($choice) {
1101  
1102 # Export the file
1103 $self->winObj->visibleSession->pseudoCmd(
1104 'exportfiles -m ' . $choice,
1105 $mode,
1106 );
1107 }
1108 }
1109 });
1110 $subMenu_exportFile->append($menuItem_exportFile_model);
1111  
1112 my $menuItem_exportFile_tasks = Gtk3::MenuItem->new('_Tasks file');
1113 $menuItem_exportFile_tasks->signal_connect('activate' => sub {
1114  
1115 $self->winObj->visibleSession->pseudoCmd('exportfiles -t', $mode);
1116 });
1117 $subMenu_exportFile->append($menuItem_exportFile_tasks);
1118  
1119 my $menuItem_exportFile_scripts = Gtk3::MenuItem->new('_Scripts file');
1120 $menuItem_exportFile_scripts->signal_connect('activate' => sub {
1121  
1122 $self->winObj->visibleSession->pseudoCmd('exportfiles -s', $mode);
1123 });
1124 $subMenu_exportFile->append($menuItem_exportFile_scripts);
1125  
1126 my $menuItem_exportFile_contacts = Gtk3::MenuItem->new('_Contacts file');
1127 $menuItem_exportFile_contacts->signal_connect('activate' => sub {
1128  
1129 $self->winObj->visibleSession->pseudoCmd('exportfiles -n', $mode);
1130 });
1131 $subMenu_exportFile->append($menuItem_exportFile_contacts);
1132  
1133 my $menuItem_exportFile_dicts = Gtk3::MenuItem->new('_Dictionaries file');
1134 $menuItem_exportFile_dicts->signal_connect('activate' => sub {
1135  
1136 $self->winObj->visibleSession->pseudoCmd('exportfiles -y', $mode);
1137 });
1138 $subMenu_exportFile->append($menuItem_exportFile_dicts);
1139  
1140 my $menuItem_exportFile_toolbar = Gtk3::MenuItem->new('Tool_bar file');
1141 $menuItem_exportFile_toolbar->signal_connect('activate' => sub {
1142  
1143 $self->winObj->visibleSession->pseudoCmd('exportfiles -b', $mode);
1144 });
1145 $subMenu_exportFile->append($menuItem_exportFile_toolbar);
1146  
1147 my $menuItem_exportFile_userComm = Gtk3::MenuItem->new('_User commands file');
1148 $menuItem_exportFile_userComm->signal_connect('activate' => sub {
1149  
1150 $self->winObj->visibleSession->pseudoCmd('exportfiles -u', $mode);
1151 });
1152 $subMenu_exportFile->append($menuItem_exportFile_userComm);
1153  
1154 my $menuItem_exportFile_zonemaps = Gtk3::MenuItem->new('_Zonemaps file');
1155 $menuItem_exportFile_zonemaps->signal_connect('activate' => sub {
1156  
1157 $self->winObj->visibleSession->pseudoCmd('exportfiles -z', $mode);
1158 });
1159 $subMenu_exportFile->append($menuItem_exportFile_zonemaps);
1160  
1161 my $menuItem_exportFile_winmaps = Gtk3::MenuItem->new('W_inmaps file');
1162 $menuItem_exportFile_winmaps->signal_connect('activate' => sub {
1163  
1164 $self->winObj->visibleSession->pseudoCmd('exportfiles -p', $mode);
1165 });
1166 $subMenu_exportFile->append($menuItem_exportFile_winmaps);
1167  
1168 my $menuItem_exportFile_ttsObjs = Gtk3::MenuItem->new('Te_xt-to-speech file');
1169 $menuItem_exportFile_ttsObjs->signal_connect('activate' => sub {
1170  
1171 $self->winObj->visibleSession->pseudoCmd('exportfiles -x', $mode);
1172 });
1173 $subMenu_exportFile->append($menuItem_exportFile_ttsObjs);
1174  
1175 my $menuItem_exportFile = Gtk3::MenuItem->new('E_xport files');
1176 $menuItem_exportFile->set_submenu($subMenu_exportFile);
1177 $menuColumn_file->append($menuItem_exportFile);
1178 # (Requires a visible session whose status is 'connected' or 'offline')
1179 $self->ivAdd('menuItemHash', 'export_file', $menuItem_exportFile);
1180  
1181 $menuColumn_file->append(Gtk3::SeparatorMenuItem->new()); # Separator
1182  
1183 my $menuItem_importData = Gtk3::MenuItem->new('_Import data...');
1184 $menuItem_importData->signal_connect('activate' => sub {
1185  
1186 $self->winObj->visibleSession->pseudoCmd('importdata', $mode);
1187 });
1188 $menuColumn_file->append($menuItem_importData);
1189 # (Requires a visible session whose status is 'connected' or 'offline')
1190 $self->ivAdd('menuItemHash', 'import_data', $menuItem_importData);
1191  
1192 # 'Export data' submenu
1193 my $subMenu_exportData = Gtk3::Menu->new();
1194  
1195 my $menuItem_exportData_otherProf = Gtk3::MenuItem->new('_Non-world profiles...');
1196 $menuItem_exportData_otherProf->signal_connect('activate' => sub {
1197  
1198 # Display a 'dialogue' window, so the user can choose a non-world profile
1199 my (
1200 $choice,
1201 @otherProfList,
1202 );
1203  
1204 # Get an ordered list of all non-world profiles
1205 @otherProfList = $self->getOtherProfList();
1206 if (@otherProfList) {
1207  
1208 # Display the dialogue
1209 $choice = $self->winObj->showComboDialogue(
1210 'Export data',
1211 'Select a non-world profile to export',
1212 \@otherProfList,
1213 );
1214  
1215 if ($choice) {
1216  
1217 # Export the data
1218 $self->winObj->visibleSession->pseudoCmd('exportdata -d ' . $choice, $mode);
1219 }
1220 }
1221 });
1222 $subMenu_exportData->append($menuItem_exportData_otherProf);
1223  
1224 my $menuItem_exportData_singleCage = Gtk3::MenuItem->new('_Single cage...');
1225 $menuItem_exportData_singleCage->signal_connect('activate' => sub {
1226  
1227 # Display a 'dialogue' window, so the user can choose a cage
1228 my (
1229 $choice,
1230 @cageList,
1231 );
1232  
1233 # Get an ordered list of cages
1234 @cageList
1235 = sort {lc($a) cmp lc($b)} ($self->winObj->visibleSession->ivKeys('cageHash'));
1236 if (@cageList) {
1237  
1238 # Display the dialogue
1239 $choice = $self->winObj->showComboDialogue(
1240 'Export data',
1241 'Select a cage to export',
1242 \@cageList,
1243 );
1244  
1245 if ($choice) {
1246  
1247 # Export the data
1248 $self->winObj->visibleSession->pseudoCmd('exportdata -t ' . $choice, $mode);
1249 }
1250 }
1251 });
1252 $subMenu_exportData->append($menuItem_exportData_singleCage);
1253  
1254 my $menuItem_exportData_profCages = Gtk3::MenuItem->new('_All cages in profile...');
1255 $menuItem_exportData_profCages->signal_connect('activate' => sub {
1256  
1257 # Display a 'dialogue' window, so the user can choose a profile
1258 my (
1259 $choice,
1260 @profList,
1261 );
1262  
1263 # Get an ordered list of profiles
1264 @profList
1265 = sort {lc($a) cmp lc($b)} ($self->winObj->visibleSession->ivKeys('profHash'));
1266  
1267 if (@profList) {
1268  
1269 # Display the dialogue
1270 $choice = $self->winObj->showComboDialogue(
1271 'Export data',
1272 'Select a profile whose cages should be exported',
1273 \@profList,
1274 );
1275  
1276 if ($choice) {
1277  
1278 # Export the data
1279 $self->winObj->visibleSession->pseudoCmd('exportdata -p ' . $choice, $mode);
1280 }
1281 }
1282 });
1283 $subMenu_exportData->append($menuItem_exportData_profCages);
1284  
1285 my $menuItem_exportData_template = Gtk3::MenuItem->new('_Profile template...');
1286 $menuItem_exportData_template->signal_connect('activate' => sub {
1287  
1288 # Display a 'dialogue' window, so the user can choose a profile template
1289 my (
1290 $choice,
1291 @templList,
1292 );
1293  
1294 # Get an ordered list of all templates
1295 @templList = sort {lc($a) cmp lc($b)}
1296 ($self->winObj->visibleSession->ivKeys('templateHash'));
1297  
1298 if (@templList) {
1299  
1300 # Display the dialogue
1301 $choice = $self->winObj->showComboDialogue(
1302 'Export data',
1303 'Select a profile template to export',
1304 \@templList,
1305 );
1306  
1307 if ($choice) {
1308  
1309 # Export the data
1310 $self->winObj->visibleSession->pseudoCmd('exportdata -s ' . $choice, $mode);
1311 }
1312 }
1313 });
1314 $subMenu_exportData->append($menuItem_exportData_template);
1315  
1316 $subMenu_exportData->append(Gtk3::SeparatorMenuItem->new()); # Separator
1317  
1318 my $menuItem_exportData_initialTask = Gtk3::MenuItem->new('(_Global) initial task...');
1319 $menuItem_exportData_initialTask->signal_connect('activate' => sub {
1320  
1321 # Display a 'dialogue' window, so the user can choose a (global) initial task
1322 my (
1323 $choice,
1324 @taskList,
1325 );
1326  
1327 # Get an ordered list of all (global) initial tasks
1328 @taskList = sort {lc($a) cmp lc($b)} ($axmud::CLIENT->ivKeys('initTaskHash'));
1329 if (@taskList) {
1330  
1331 # Display the dialogue
1332 $choice = $self->winObj->showComboDialogue(
1333 'Export data',
1334 'Select a (global) initial task to export',
1335 \@taskList,
1336 );
1337  
1338 if ($choice) {
1339  
1340 # Export the data
1341 $self->winObj->visibleSession->pseudoCmd('exportdata -i ' . $choice, $mode);
1342 }
1343 }
1344 });
1345 $subMenu_exportData->append($menuItem_exportData_initialTask);
1346  
1347 my $menuItem_exportData_customTask = Gtk3::MenuItem->new('_Custom task...');
1348 $menuItem_exportData_customTask->signal_connect('activate' => sub {
1349  
1350 # Display a 'dialogue' window, so the user can choose a custom task
1351 my (
1352 $choice,
1353 @taskList,
1354 );
1355  
1356 # Get an ordered list of all custom task names
1357 @taskList = sort {lc($a) cmp lc($b)} ($axmud::CLIENT->ivKeys('customTaskHash'));
1358 if (@taskList) {
1359  
1360 # Display the dialogue
1361 $choice = $self->winObj->showComboDialogue(
1362 'Export data',
1363 'Select a custom task to export',
1364 \@taskList,
1365 );
1366  
1367 if ($choice) {
1368  
1369 # Export the data
1370 $self->winObj->visibleSession->pseudoCmd('exportdata -c ' . $choice, $mode);
1371 }
1372 }
1373 });
1374 $subMenu_exportData->append($menuItem_exportData_customTask);
1375  
1376 $subMenu_exportData->append(Gtk3::SeparatorMenuItem->new()); # Separator
1377  
1378 my $menuItem_exportData_dict = Gtk3::MenuItem->new('_Dictionary...');
1379 $menuItem_exportData_dict->signal_connect('activate' => sub {
1380  
1381 # Display a 'dialogue' window, so the user can choose a dictionary
1382 my (
1383 $choice,
1384 @dictList,
1385 );
1386  
1387 # Get an ordered list of all dictionaries, with the current dictionary at the top of
1388 # the list
1389 @dictList = $self->getDictList();
1390 if (@dictList) {
1391  
1392 # Display the dialogue
1393 $choice = $self->winObj->showComboDialogue(
1394 'Export data',
1395 'Select a dictionary to export',
1396 \@dictList,
1397 );
1398  
1399 if ($choice) {
1400  
1401 # Export the data
1402 $self->winObj->visibleSession->pseudoCmd('exportdata -y ' . $choice, $mode);
1403 }
1404 }
1405 });
1406 $subMenu_exportData->append($menuItem_exportData_dict);
1407  
1408 my $menuItem_exportData_zonemap = Gtk3::MenuItem->new('_Zonemap...');
1409 $menuItem_exportData_zonemap->signal_connect('activate' => sub {
1410  
1411 # Display a 'dialogue' window, so the user can choose a zonemap
1412 my (
1413 $choice,
1414 @zonemapList,
1415 );
1416  
1417 @zonemapList = (sort {lc($a) cmp lc($b)} ($axmud::CLIENT->ivKeys('zonemapHash')));
1418 if (@zonemapList) {
1419  
1420 # Display the dialogue
1421 $choice = $self->winObj->showComboDialogue(
1422 'Export data',
1423 'Select a zonemap to export',
1424 \@zonemapList,
1425 );
1426  
1427 if ($choice) {
1428  
1429 # Export the data
1430 $self->winObj->visibleSession->pseudoCmd('exportdata -z ' . $choice, $mode);
1431 }
1432 }
1433 });
1434 $subMenu_exportData->append($menuItem_exportData_zonemap);
1435  
1436 my $menuItem_exportData_winmap = Gtk3::MenuItem->new('_Winmap...');
1437 $menuItem_exportData_winmap->signal_connect('activate' => sub {
1438  
1439 # Display a 'dialogue' window, so the user can choose a winmap
1440 my (
1441 $choice,
1442 @winmapList,
1443 );
1444  
1445 @winmapList = (sort {lc($a) cmp lc($b)} ($axmud::CLIENT->ivKeys('winmapHash')));
1446 if (@winmapList) {
1447  
1448 # Display the dialogue
1449 $choice = $self->winObj->showComboDialogue(
1450 'Export data',
1451 'Select a winmap to export',
1452 \@winmapList,
1453 );
1454  
1455 if ($choice) {
1456  
1457 # Export the data
1458 $self->winObj->visibleSession->pseudoCmd('exportdata -p ' . $choice, $mode);
1459 }
1460 }
1461 });
1462 $subMenu_exportData->append($menuItem_exportData_winmap);
1463  
1464 my $menuItem_exportData_colScheme = Gtk3::MenuItem->new('C_olour scheme...');
1465 $menuItem_exportData_colScheme->signal_connect('activate' => sub {
1466  
1467 # Display a 'dialogue' window, so the user can choose a colour scheme
1468 my (
1469 $choice,
1470 @schemeList,
1471 );
1472  
1473 @schemeList = (
1474 sort {lc($a) cmp lc($b)} ($axmud::CLIENT->ivKeys('colourSchemeHash'))
1475 );
1476  
1477 if (@schemeList) {
1478  
1479 # Display the dialogue
1480 $choice = $self->winObj->showComboDialogue(
1481 'Export data',
1482 'Select a colour scheme to export',
1483 \@schemeList,
1484 );
1485  
1486 if ($choice) {
1487  
1488 # Export the data
1489 $self->winObj->visibleSession->pseudoCmd('exportdata -o ' . $choice, $mode);
1490 }
1491 }
1492 });
1493 $subMenu_exportData->append($menuItem_exportData_colScheme);
1494  
1495 my $menuItem_exportData_ttsObj = Gtk3::MenuItem->new('_TTS object...');
1496 $menuItem_exportData_ttsObj->signal_connect('activate' => sub {
1497  
1498 # Display a 'dialogue' window, so the user can choose a TTS object
1499 my (
1500 $choice,
1501 @objList,
1502 );
1503  
1504 @objList = (sort {lc($a) cmp lc($b)} ($axmud::CLIENT->ivKeys('ttsObjHash')));
1505 if (@objList) {
1506  
1507 # Display the dialogue
1508 $choice = $self->winObj->showComboDialogue(
1509 'Export data',
1510 'Select a text-to-speech object to export',
1511 \@objList,
1512 );
1513  
1514 if ($choice) {
1515  
1516 # Export the data
1517 $self->winObj->visibleSession->pseudoCmd('exportdata -x ' . $choice, $mode);
1518 }
1519 }
1520 });
1521 $subMenu_exportData->append($menuItem_exportData_ttsObj);
1522  
1523 my $menuItem_exportData = Gtk3::MenuItem->new('Export _data');
1524 $menuItem_exportData->set_submenu($subMenu_exportData);
1525 $menuColumn_file->append($menuItem_exportData);
1526 # (Requires a visible session whose status is 'connected' or 'offline')
1527 $self->ivAdd('menuItemHash', 'export_data', $menuItem_exportData);
1528  
1529 $menuColumn_file->append(Gtk3::SeparatorMenuItem->new()); # Separator
1530  
1531 # 'Backup data' submenu
1532 my $subMenu_backupRestore = Gtk3::Menu->new();
1533  
1534 my $menuItem_backupData = Gtk3::MenuItem->new('_Backup all data files');
1535 $menuItem_backupData->signal_connect('activate' => sub {
1536  
1537 $self->winObj->visibleSession->pseudoCmd('backupdata', $mode);
1538 });
1539 $subMenu_backupRestore->append($menuItem_backupData);
1540  
1541 my $menuItem_restoreData = Gtk3::MenuItem->new('_Restore from backup...');
1542 $menuItem_restoreData->signal_connect('activate' => sub {
1543  
1544 $self->winObj->visibleSession->pseudoCmd('restoredata', $mode);
1545 });
1546 $subMenu_backupRestore->append($menuItem_restoreData);
1547  
1548 my $menuItem_backupRestore = Gtk3::MenuItem->new('_Backup data');
1549 $menuItem_backupRestore->set_submenu($subMenu_backupRestore);
1550 $menuColumn_file->append($menuItem_backupRestore);
1551 # (Requires a visible session whose status is 'connected' or 'offline')
1552 $self->ivAdd('menuItemHash', 'backup_restore_data', $menuItem_backupRestore);
1553  
1554 $menuColumn_file->append(Gtk3::SeparatorMenuItem->new()); # Separator
1555  
1556 my $menuItem_showFiles = Gtk3::ImageMenuItem->new('S_how file objects');
1557 my $menuImg_showFiles = Gtk3::Image->new_from_stock('gtk-dialog-info', 'menu');
1558 $menuItem_showFiles->set_image($menuImg_showFiles);
1559 $menuItem_showFiles->signal_connect('activate' => sub {
1560  
1561 $self->winObj->visibleSession->pseudoCmd('showfile', $mode);
1562 });
1563 $menuColumn_file->append($menuItem_showFiles);
1564 # (Requires a visible session)
1565 $self->ivAdd('menuItemHash', 'show_files', $menuItem_showFiles);
1566  
1567 my $menuItem_disableSaveWorld = Gtk3::ImageMenuItem->new('Disable _world save');
1568 my $menuImg_disableSaveWorld = Gtk3::Image->new_from_stock('gtk-dialog-warning', 'menu');
1569 $menuItem_disableSaveWorld->set_image($menuImg_disableSaveWorld);
1570 $menuItem_disableSaveWorld->signal_connect('activate' => sub {
1571  
1572 $self->winObj->visibleSession->pseudoCmd('disablesaveworld', $mode);
1573 });
1574 $menuColumn_file->append($menuItem_disableSaveWorld);
1575 # (Requires a visible session whose status is 'connected' or 'offline')
1576 $self->ivAdd('menuItemHash', 'disable_world_save', $menuItem_disableSaveWorld);
1577  
1578 my $menuItem_disableSaveLoad = Gtk3::ImageMenuItem->new('Disabl_e all saves/loads');
1579 my $menuImg_disableSaveLoad = Gtk3::Image->new_from_stock('gtk-dialog-warning', 'menu');
1580 $menuItem_disableSaveLoad->set_image($menuImg_disableSaveLoad);
1581 $menuItem_disableSaveLoad->signal_connect('activate' => sub {
1582  
1583 $self->winObj->visibleSession->pseudoCmd('disablesaveload', $mode);
1584 });
1585 $menuColumn_file->append($menuItem_disableSaveLoad);
1586 # (Requires a visible session whose status is 'connected' or 'offline')
1587 $self->ivAdd('menuItemHash', 'disable_save_load', $menuItem_disableSaveLoad);
1588  
1589 # Setup complete
1590 return $menuColumn_file;
1591 }
1592  
1593 sub drawEditColumn {
1594  
1595 # Called by $self->enableMenu
1596 # Sets up the menu's 'Edit' column
1597 #
1598 # Expected arguments
1599 # (none besides $self)
1600 #
1601 # Return values
1602 # 'undef' on improper arguments, or if the menu can't be created
1603 # Otherwise returns the Gtk3::Menu created
1604  
1605 my ($self, $check) = @_;
1606  
1607 # Local variables
1608 my $mode;
1609  
1610 # Check for improper arguments
1611 if (defined $check) {
1612  
1613 return $axmud::CLIENT->writeImproper($self->_objClass . '->drawEditColumn', @_);
1614 }
1615  
1616 # Import IVs (for convenience)
1617 $mode = $self->winObj->pseudoCmdMode;
1618  
1619 # Set up column
1620 my $menuColumn_edit = Gtk3::Menu->new();
1621 if (! $menuColumn_edit) {
1622  
1623 return undef;
1624 }
1625  
1626 my $menuItem_quickPrefs = Gtk3::ImageMenuItem->new(
1627 '_Quick preferences...',
1628 );
1629 my $menuImg_quickPrefs = Gtk3::Image->new_from_stock('gtk-preferences', 'menu');
1630 $menuItem_quickPrefs->set_image($menuImg_quickPrefs);
1631 $menuItem_quickPrefs->signal_connect('activate' => sub {
1632  
1633 $self->winObj->visibleSession->pseudoCmd('editquick', $mode);
1634 });
1635 $menuColumn_edit->append($menuItem_quickPrefs);
1636 # (Requires a visible session whose status is 'connected' or 'offline')
1637 $self->ivAdd('menuItemHash', 'edit_quick_prefs', $menuItem_quickPrefs);
1638  
1639 my $menuItem_clientPrefs = Gtk3::ImageMenuItem->new(
1640 $axmud::SCRIPT . ' _preferences...',
1641 );
1642 my $menuImg_clientPrefs = Gtk3::Image->new_from_stock('gtk-preferences', 'menu');
1643 $menuItem_clientPrefs->set_image($menuImg_clientPrefs);
1644 $menuItem_clientPrefs->signal_connect('activate' => sub {
1645  
1646 $self->winObj->visibleSession->pseudoCmd('editclient', $mode);
1647 });
1648 $menuColumn_edit->append($menuItem_clientPrefs);
1649 # (Requires a visible session whose status is 'connected' or 'offline')
1650 $self->ivAdd('menuItemHash', 'edit_client_prefs', $menuItem_clientPrefs);
1651  
1652 my $menuItem_sessionPrefs = Gtk3::ImageMenuItem->new('_Session preferences...');
1653 my $menuImg_sessionPrefs = Gtk3::Image->new_from_stock('gtk-preferences', 'menu');
1654 $menuItem_sessionPrefs->set_image($menuImg_sessionPrefs);
1655 $menuItem_sessionPrefs->signal_connect('activate' => sub {
1656  
1657 $self->winObj->visibleSession->pseudoCmd('editsession', $mode);
1658 });
1659 $menuColumn_edit->append($menuItem_sessionPrefs);
1660 # (Requires a visible session whose status is 'connected' or 'offline')
1661 $self->ivAdd('menuItemHash', 'edit_session_prefs', $menuItem_sessionPrefs);
1662  
1663 $menuColumn_edit->append(Gtk3::SeparatorMenuItem->new()); # Separator
1664  
1665 my $menuItem_editWorld = Gtk3::ImageMenuItem->new('Edit current _world...');
1666 my $menuImg_editWorld = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
1667 $menuItem_editWorld->set_image($menuImg_editWorld);
1668 $menuItem_editWorld->signal_connect('activate' => sub {
1669  
1670 $self->winObj->visibleSession->pseudoCmd('editworld', $mode);
1671 });
1672 $menuColumn_edit->append($menuItem_editWorld);
1673 # (Requires a visible session whose status is 'connected' or 'offline')
1674 $self->ivAdd('menuItemHash', 'edit_current_world', $menuItem_editWorld);
1675  
1676 my $menuItem_editGuild = Gtk3::ImageMenuItem->new('Edit current _guild...');
1677 my $menuImg_editGuild = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
1678 $menuItem_editGuild->set_image($menuImg_editGuild);
1679 $menuItem_editGuild->signal_connect('activate' => sub {
1680  
1681 $self->winObj->visibleSession->pseudoCmd('editguild', $mode);
1682 });
1683 $menuColumn_edit->append($menuItem_editGuild);
1684 # Requires a current session whose status is 'connected' or 'offline' and whose
1685 # ->currentGuild is defined
1686 $self->ivAdd('menuItemHash', 'edit_current_guild', $menuItem_editGuild);
1687  
1688 my $menuItem_editRace = Gtk3::ImageMenuItem->new('Edit current _race...');
1689 my $menuImg_editRace = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
1690 $menuItem_editRace->set_image($menuImg_editRace);
1691 $menuItem_editRace->signal_connect('activate' => sub {
1692  
1693 $self->winObj->visibleSession->pseudoCmd('editrace', $mode);
1694 });
1695 $menuColumn_edit->append($menuItem_editRace);
1696 # Requires a current session whose status is 'connected' or 'offline' and whose
1697 # ->currentRace is defined
1698 $self->ivAdd('menuItemHash', 'edit_current_race', $menuItem_editRace);
1699  
1700 my $menuItem_editChar = Gtk3::ImageMenuItem->new('Edit current _character...');
1701 my $menuImg_editChar = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
1702 $menuItem_editChar->set_image($menuImg_editChar);
1703 $menuItem_editChar->signal_connect('activate' => sub {
1704  
1705 $self->winObj->visibleSession->pseudoCmd('editchar', $mode);
1706 });
1707 $menuColumn_edit->append($menuItem_editChar);
1708 # Requires a current session whose status is 'connected' or 'offline' and whose
1709 # ->currentChar is defined
1710 $self->ivAdd('menuItemHash', 'edit_current_char', $menuItem_editChar);
1711  
1712 $menuColumn_edit->append(Gtk3::SeparatorMenuItem->new()); # Separator
1713  
1714 my $menuItem_locatorWiz = Gtk3::ImageMenuItem->new('Run Locator w_izard...');
1715 my $menuImg_locatorWiz = Gtk3::Image->new_from_stock('gtk-page-setup', 'menu');
1716 $menuItem_locatorWiz->set_image($menuImg_locatorWiz);
1717 $menuItem_locatorWiz->signal_connect('activate' => sub {
1718  
1719 $self->winObj->visibleSession->pseudoCmd('locatorwizard', $mode);
1720 });
1721 $menuColumn_edit->append($menuItem_locatorWiz);
1722 # (Requires a visible session whose status is 'connected' or 'offline'. A
1723 # corresponding menu item also appears in $self->drawTasksColumn)
1724 $self->ivAdd('menuItemHash', 'run_locator_wiz', $menuItem_locatorWiz);
1725  
1726 my $menuItem_editWorldModel = Gtk3::ImageMenuItem->new('Edit world _model...');
1727 my $menuImg_editWorldModel = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
1728 $menuItem_editWorldModel->set_image($menuImg_editWorldModel);
1729 $menuItem_editWorldModel->signal_connect('activate' => sub {
1730  
1731 $self->winObj->visibleSession->pseudoCmd('editmodel', $mode);
1732 });
1733 $menuColumn_edit->append($menuItem_editWorldModel);
1734 # (Requires a visible session whose status is 'connected' or 'offline')
1735 $self->ivAdd('menuItemHash', 'edit_world_model', $menuItem_editWorldModel);
1736  
1737 my $menuItem_editDict = Gtk3::ImageMenuItem->new('Edit _dictionary...');
1738 my $menuImg_editDict = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
1739 $menuItem_editDict->set_image($menuImg_editDict);
1740 $menuItem_editDict->signal_connect('activate' => sub {
1741  
1742 $self->winObj->visibleSession->pseudoCmd('editdictionary', $mode);
1743 });
1744 $menuColumn_edit->append($menuItem_editDict);
1745 # (Requires a visible session whose status is 'connected' or 'offline')
1746 $self->ivAdd('menuItemHash', 'edit_dictionary', $menuItem_editDict);
1747  
1748 $menuColumn_edit->append(Gtk3::SeparatorMenuItem->new()); # Separator
1749  
1750 # 'Simulate' submenu
1751 my $subMenu_simulate = Gtk3::Menu->new();
1752  
1753 my $menuItem_simWorld = Gtk3::MenuItem->new('Simulate _world...');
1754 $menuItem_simWorld->signal_connect('activate' => sub {
1755  
1756 # Open a simulate world 'dialogue' window. The text entered is used in a
1757 # ';simulateworld' command
1758 $self->winObj->visibleSession->pseudoCmd('simulateworld', $mode);
1759 });
1760 $subMenu_simulate->append($menuItem_simWorld);
1761  
1762 my $menuItem_simPrompt = Gtk3::MenuItem->new('Simulate _prompt...');
1763 $menuItem_simPrompt->signal_connect('activate' => sub {
1764  
1765 # Open a simulate prompt 'dialogue' window. The text entered is used in a
1766 # ';simulateprompt' command
1767 $self->winObj->visibleSession->pseudoCmd('simulateprompt', $mode);
1768 });
1769 $subMenu_simulate->append($menuItem_simPrompt);
1770  
1771 my $menuItem_simCmd = Gtk3::MenuItem->new('Simulate _command...');
1772 $menuItem_simCmd->signal_connect('activate' => sub {
1773  
1774 # Prompt the user for a world command
1775 my $cmd = $self->winObj->showEntryDialogue(
1776 'Simulate world command',
1777 'Enter a world command (not actually sent to the world)',
1778 );
1779  
1780 if ($cmd) {
1781  
1782 $self->winObj->visibleSession->pseudoCmd(
1783 'simulatecommand <' . $cmd . '>',
1784 $mode,
1785 );
1786 }
1787 });
1788 $subMenu_simulate->append($menuItem_simCmd);
1789  
1790 my $menuItem_simHook = Gtk3::MenuItem->new('Simulate _hook event...');
1791 $menuItem_simHook->signal_connect('activate' => sub {
1792  
1793 my (
1794 $interfaceModel, $choice, $number, $cancelFlag, $cmd,
1795 @eventList, @hookDataList,
1796 );
1797  
1798 # Get the hook interface model, and from there, a list of hook events
1799 $interfaceModel = $axmud::CLIENT->ivShow('interfaceModelHash', 'hook');
1800 @eventList = sort {$a cmp $b} ($interfaceModel->ivKeys('hookEventHash'));
1801  
1802 # Prompt the user for a hook event
1803 $choice = $self->winObj->showComboDialogue(
1804 'Simulate hook event',
1805 'Enter a hook event for ' . $axmud::SCRIPT . ' to simulate',
1806 \@eventList,
1807 );
1808  
1809 if ($choice) {
1810  
1811 # How many items of hook data are expected?
1812 $number = $interfaceModel->ivShow('hookEventHash', $choice);
1813 if ($number == 1) {
1814  
1815 my $result = $self->winObj->showEntryDialogue(
1816 'Simulate hook event',
1817 'Enter hook data #1 for the hook \'' . $choice . '\'',
1818 );
1819  
1820 if (! $result) {
1821  
1822 # Don't simulate the hook event
1823 $cancelFlag = TRUE;
1824  
1825 } else {
1826  
1827 push (@hookDataList, $result);
1828 }
1829  
1830 } elsif ($number == 2) {
1831  
1832 my @resultList = $self->winObj->showDoubleEntryDialogue(
1833 'Simulate hook event',
1834 'Enter hook data #1 for the hook \'' . $choice . '\'',
1835 'Enter hook data #2',
1836 );
1837  
1838 # Both hook data items must contain at least one character
1839 if (! @resultList || ! $resultList[0] || ! $resultList[1]) {
1840  
1841 # Don't simulate the hook event
1842 $cancelFlag = TRUE;
1843  
1844 } else {
1845  
1846 push (@hookDataList, @resultList);
1847 }
1848 }
1849  
1850 if (! $cancelFlag) {
1851  
1852 # Prepare the client command to execute...
1853 $cmd = 'simulatehook ' . $choice;
1854 foreach my $item (@hookDataList) {
1855  
1856 $cmd .= ' <' . $item . '>';
1857 }
1858  
1859 # ...and execute it
1860 $self->winObj->visibleSession->pseudoCmd($cmd, $mode);
1861 }
1862 }
1863 });
1864 $subMenu_simulate->append($menuItem_simHook);
1865  
1866 my $menuItem_simulate = Gtk3::MenuItem->new('Sim_ulate');
1867 $menuItem_simulate->set_submenu($subMenu_simulate);
1868 $menuColumn_edit->append($menuItem_simulate);
1869 # (Requires a visible session whose status is 'connected' or 'offline')
1870 $self->ivAdd('menuItemHash', 'simulate', $menuItem_simulate);
1871  
1872 my $menuItem_patternTest = Gtk3::MenuItem->new('_Test patterns...');
1873 $menuItem_patternTest->signal_connect('activate' => sub {
1874  
1875 $self->winObj->visibleSession->pseudoCmd('testpattern', $mode);
1876 });
1877 $menuColumn_edit->append($menuItem_patternTest);
1878 # (Desensitised only when the setup wizwin is open)
1879 $self->ivAdd('menuItemHash', 'test_pattern', $menuItem_patternTest);
1880  
1881 # Setup complete
1882 return $menuColumn_edit;
1883 }
1884  
1885 sub drawInterfacesColumn {
1886  
1887 # Called by $self->enableMenu
1888 # Sets up the menu's 'Interfaces' column
1889 #
1890 # Expected arguments
1891 # (none besides $self)
1892 #
1893 # Return values
1894 # 'undef' on improper arguments, or if the menu can't be created
1895 # Otherwise returns the Gtk3::Menu created
1896  
1897 my ($self, $check) = @_;
1898  
1899 # Local variables
1900 my $mode;
1901  
1902 # Check for improper arguments
1903 if (defined $check) {
1904  
1905 return $axmud::CLIENT->writeImproper($self->_objClass . '->drawInterfacesColumn', @_);
1906 }
1907  
1908 # Import IVs (for convenience)
1909 $mode = $self->winObj->pseudoCmdMode;
1910  
1911 # Set up column
1912 my $menuColumn_interfaces = Gtk3::Menu->new();
1913 if (! $menuColumn_interfaces) {
1914  
1915 return undef;
1916 }
1917  
1918 my $menuItem_activeInterfaces = Gtk3::MenuItem->new('Acti_ve interfaces...');
1919 $menuItem_activeInterfaces->signal_connect('activate' => sub {
1920  
1921 # Open a session preference window on the notebook's second page, so the user can see
1922 # the list of active interfaces immediately
1923 $self->winObj->visibleSession->pseudoCmd('editactiveinterface', $mode);
1924 });
1925 $menuColumn_interfaces->append($menuItem_activeInterfaces);
1926 # (Requires a visible session whose status is 'connected' or 'offline')
1927 $self->ivAdd('menuItemHash', 'active_interfaces', $menuItem_activeInterfaces);
1928  
1929 $menuColumn_interfaces->append(Gtk3::SeparatorMenuItem->new()); # Separator
1930  
1931 # 'Triggers' submenu
1932 my $subMenu_showTriggers = Gtk3::Menu->new();
1933  
1934 my $menuItem_worldTriggers = Gtk3::MenuItem->new('_World triggers...');
1935 $menuItem_worldTriggers->signal_connect('activate' => sub {
1936  
1937 # Open the cage window on the notebook's second page, so the user can see the list
1938 # of triggers immediately
1939 $self->winObj->visibleSession->pseudoCmd('editcage -t', $mode);
1940 });
1941 $subMenu_showTriggers->append($menuItem_worldTriggers);
1942  
1943 my $menuItem_guildTriggers = Gtk3::MenuItem->new('_Guild triggers...');
1944 $menuItem_guildTriggers->signal_connect('activate' => sub {
1945  
1946 $self->winObj->visibleSession->pseudoCmd(
1947 'editcage trigger_guild_' . $self->winObj->visibleSession->currentGuild->name,
1948 $mode,
1949 );
1950 });
1951 $subMenu_showTriggers->append($menuItem_guildTriggers);
1952 # (Requires a visible session whose status is 'connected' or 'offline', and a current
1953 # guild)
1954 $self->ivAdd('menuItemHash', 'guild_triggers', $menuItem_guildTriggers);
1955  
1956 my $menuItem_raceTriggers = Gtk3::MenuItem->new('_Race triggers...');
1957 $menuItem_raceTriggers->signal_connect('activate' => sub {
1958  
1959 $self->winObj->visibleSession->pseudoCmd(
1960 'editcage trigger_race_' . $self->winObj->visibleSession->currentRace->name,
1961 $mode,
1962 );
1963 });
1964 $subMenu_showTriggers->append($menuItem_raceTriggers);
1965 # (Requires a visible session whose status is 'connected' or 'offline', and a current
1966 # race)
1967 $self->ivAdd('menuItemHash', 'race_triggers', $menuItem_raceTriggers);
1968  
1969 my $menuItem_charTriggers = Gtk3::MenuItem->new('_Character triggers...');
1970 $menuItem_charTriggers->signal_connect('activate' => sub {
1971  
1972 $self->winObj->visibleSession->pseudoCmd(
1973 'editcage trigger_char_' . $self->winObj->visibleSession->currentChar->name,
1974 $mode,
1975 );
1976 });
1977 $subMenu_showTriggers->append($menuItem_charTriggers);
1978 # (Requires a visible session whose status is 'connected' or 'offline', and a current
1979 # character)
1980 $self->ivAdd('menuItemHash', 'char_triggers', $menuItem_charTriggers);
1981  
1982 my $menuItem_showTriggers = Gtk3::MenuItem->new('_Triggers');
1983 $menuItem_showTriggers->set_submenu($subMenu_showTriggers);
1984 $menuColumn_interfaces->append($menuItem_showTriggers);
1985 # (Requires a visible session whose status is 'connected' or 'offline')
1986 $self->ivAdd('menuItemHash', 'show_triggers', $menuItem_showTriggers);
1987  
1988 # 'Aliases' submenu
1989 my $subMenu_showAliases = Gtk3::Menu->new();
1990  
1991 my $menuItem_worldAliases = Gtk3::MenuItem->new('World _aliases...');
1992 $menuItem_worldAliases->signal_connect('activate' => sub {
1993  
1994 # Open the cage window on the notebook's second page, so the user can see the list
1995 # of aliases immediately
1996 $self->winObj->visibleSession->pseudoCmd('editcage -a', $mode);
1997 });
1998 $subMenu_showAliases->append($menuItem_worldAliases);
1999  
2000 my $menuItem_guildAliases = Gtk3::MenuItem->new('_Guild aliases...');
2001 $menuItem_guildAliases->signal_connect('activate' => sub {
2002  
2003 $self->winObj->visibleSession->pseudoCmd(
2004 'editcage alias_guild_' . $self->winObj->visibleSession->currentGuild->name,
2005 $mode,
2006 );
2007 });
2008 $subMenu_showAliases->append($menuItem_guildAliases);
2009 # (Requires a visible session whose status is 'connected' or 'offline', and a current
2010 # guild)
2011 $self->ivAdd('menuItemHash', 'guild_aliases', $menuItem_guildAliases);
2012  
2013 my $menuItem_raceAliases = Gtk3::MenuItem->new('_Race aliases...');
2014 $menuItem_raceAliases->signal_connect('activate' => sub {
2015  
2016 $self->winObj->visibleSession->pseudoCmd(
2017 'editcage alias_race_' . $self->winObj->visibleSession->currentRace->name,
2018 $mode,
2019 );
2020 });
2021 $subMenu_showAliases->append($menuItem_raceAliases);
2022 # (Requires a visible session whose status is 'connected' or 'offline', and a current
2023 # race)
2024 $self->ivAdd('menuItemHash', 'race_aliases', $menuItem_raceAliases);
2025  
2026 my $menuItem_charAliases = Gtk3::MenuItem->new('_Character aliases...');
2027 $menuItem_charAliases->signal_connect('activate' => sub {
2028  
2029 $self->winObj->visibleSession->pseudoCmd(
2030 'editcage alias_char_' . $self->winObj->visibleSession->currentChar->name,
2031 $mode,
2032 );
2033 });
2034 $subMenu_showAliases->append($menuItem_charAliases);
2035 # (Requires a visible session whose status is 'connected' or 'offline', and a current
2036 # character)
2037 $self->ivAdd('menuItemHash', 'char_aliases', $menuItem_charAliases);
2038  
2039 my $menuItem_showAliases = Gtk3::MenuItem->new('_Aliases');
2040 $menuItem_showAliases->set_submenu($subMenu_showAliases);
2041 $menuColumn_interfaces->append($menuItem_showAliases);
2042 # (Requires a visible session whose status is 'connected' or 'offline')
2043 $self->ivAdd('menuItemHash', 'show_aliases', $menuItem_showAliases);
2044  
2045 # 'Macros' submenu
2046 my $subMenu_showMacros = Gtk3::Menu->new();
2047  
2048 my $menuItem_worldMacros = Gtk3::MenuItem->new('_World macros...');
2049 $menuItem_worldMacros->signal_connect('activate' => sub {
2050  
2051 # Open the cage window on the notebook's second page, so the user can see the list
2052 # of macros immediately
2053 $self->winObj->visibleSession->pseudoCmd('editcage -m', $mode);
2054 });
2055 $subMenu_showMacros->append($menuItem_worldMacros);
2056  
2057 my $menuItem_guildMacros = Gtk3::MenuItem->new('_Guild macros...');
2058 $menuItem_guildMacros->signal_connect('activate' => sub {
2059  
2060 $self->winObj->visibleSession->pseudoCmd(
2061 'editcage macro_guild_' . $self->winObj->visibleSession->currentGuild->name,
2062 $mode,
2063 );
2064 });
2065 $subMenu_showMacros->append($menuItem_guildMacros);
2066 # (Requires a visible session whose status is 'connected' or 'offline', and a current
2067 # guild)
2068 $self->ivAdd('menuItemHash', 'guild_macros', $menuItem_guildMacros);
2069  
2070 my $menuItem_raceMacros = Gtk3::MenuItem->new('_Race macros...');
2071 $menuItem_raceMacros->signal_connect('activate' => sub {
2072  
2073 $self->winObj->visibleSession->pseudoCmd(
2074 'editcage macro_race_' . $self->winObj->visibleSession->currentRace->name,
2075 $mode,
2076 );
2077 });
2078 $subMenu_showMacros->append($menuItem_raceMacros);
2079 # (Requires a visible session whose status is 'connected' or 'offline', and a current
2080 # race)
2081 $self->ivAdd('menuItemHash', 'race_macros', $menuItem_raceMacros);
2082  
2083 my $menuItem_charMacros = Gtk3::MenuItem->new('_Character macros...');
2084 $menuItem_charMacros->signal_connect('activate' => sub {
2085  
2086 $self->winObj->visibleSession->pseudoCmd(
2087 'editcage macro_char_' . $self->winObj->visibleSession->currentChar->name,
2088 $mode,
2089 );
2090 });
2091 $subMenu_showMacros->append($menuItem_charMacros);
2092 # (Requires a visible session whose status is 'connected' or 'offline', and a current
2093 # character)
2094 $self->ivAdd('menuItemHash', 'char_macros', $menuItem_charMacros);
2095  
2096 my $menuItem_showMacros = Gtk3::MenuItem->new('_Macros');
2097 $menuItem_showMacros->set_submenu($subMenu_showMacros);
2098 $menuColumn_interfaces->append($menuItem_showMacros);
2099 # (Requires a visible session whose status is 'connected' or 'offline')
2100 $self->ivAdd('menuItemHash', 'show_macros', $menuItem_showMacros);
2101  
2102 # 'Timers' submenu
2103 my $subMenu_showTimers = Gtk3::Menu->new();
2104  
2105 my $menuItem_worldTimers = Gtk3::MenuItem->new('_World timers...');
2106 $menuItem_worldTimers->signal_connect('activate' => sub {
2107  
2108 # Open the cage window on the notebook's second page, so the user can see the list
2109 # of timers immediately
2110 $self->winObj->visibleSession->pseudoCmd('editcage -i', $mode);
2111 });
2112 $subMenu_showTimers->append($menuItem_worldTimers);
2113  
2114 my $menuItem_guildTimers = Gtk3::MenuItem->new('_Guild timers...');
2115 $menuItem_guildTimers->signal_connect('activate' => sub {
2116  
2117 $self->winObj->visibleSession->pseudoCmd(
2118 'editcage timer_guild_' . $self->winObj->visibleSession->currentGuild->name,
2119 $mode,
2120 );
2121 });
2122 $subMenu_showTimers->append($menuItem_guildTimers);
2123 # (Requires a visible session whose status is 'connected' or 'offline', and a current
2124 # guild)
2125 $self->ivAdd('menuItemHash', 'guild_timers', $menuItem_guildTimers);
2126  
2127 my $menuItem_raceTimers = Gtk3::MenuItem->new('_Race timers...');
2128 $menuItem_raceTimers->signal_connect('activate' => sub {
2129  
2130 $self->winObj->visibleSession->pseudoCmd(
2131 'editcage timer_race_' . $self->winObj->visibleSession->currentRace->name,
2132 $mode,
2133 );
2134 });
2135 $subMenu_showTimers->append($menuItem_raceTimers);
2136 # (Requires a visible session whose status is 'connected' or 'offline', and a current
2137 # race)
2138 $self->ivAdd('menuItemHash', 'race_timers', $menuItem_raceTimers);
2139  
2140 my $menuItem_charTimers = Gtk3::MenuItem->new('_Character timers...');
2141 $menuItem_charTimers->signal_connect('activate' => sub {
2142  
2143 $self->winObj->visibleSession->pseudoCmd(
2144 'editcage timer_char_' . $self->winObj->visibleSession->currentChar->name,
2145 $mode,
2146 );
2147 });
2148 $subMenu_showTimers->append($menuItem_charTimers);
2149 # (Requires a visible session whose status is 'connected' or 'offline', and a current
2150 # character)
2151 $self->ivAdd('menuItemHash', 'char_timers', $menuItem_charTimers);
2152  
2153 my $menuItem_showTimers = Gtk3::MenuItem->new('T_imers');
2154 $menuItem_showTimers->set_submenu($subMenu_showTimers);
2155 $menuColumn_interfaces->append($menuItem_showTimers);
2156 # (Requires a visible session whose status is 'connected' or 'offline')
2157 $self->ivAdd('menuItemHash', 'show_timers', $menuItem_showTimers);
2158  
2159 # 'Hooks' submenu
2160 my $subMenu_showHooks = Gtk3::Menu->new();
2161  
2162 my $menuItem_worldHooks = Gtk3::MenuItem->new('_World hooks...');
2163 $menuItem_worldHooks->signal_connect('activate' => sub {
2164  
2165 # Open the cage window on the notebook's second page, so the user can see the list
2166 # of hooks immediately
2167 $self->winObj->visibleSession->pseudoCmd('editcage -h', $mode);
2168 });
2169 $subMenu_showHooks->append($menuItem_worldHooks);
2170  
2171 my $menuItem_guildHooks = Gtk3::MenuItem->new('_Guild hooks...');
2172 $menuItem_guildHooks->signal_connect('activate' => sub {
2173  
2174 $self->winObj->visibleSession->pseudoCmd(
2175 'editcage hook_guild_' . $self->winObj->visibleSession->currentGuild->name,
2176 $mode,
2177 );
2178 });
2179 $subMenu_showHooks->append($menuItem_guildHooks);
2180 # (Requires a visible session whose status is 'connected' or 'offline', and a current
2181 # guild)
2182 $self->ivAdd('menuItemHash', 'guild_hooks', $menuItem_guildHooks);
2183  
2184 my $menuItem_raceHooks = Gtk3::MenuItem->new('_Race hooks...');
2185 $menuItem_raceHooks->signal_connect('activate' => sub {
2186  
2187 $self->winObj->visibleSession->pseudoCmd(
2188 'editcage hook_race_' . $self->winObj->visibleSession->currentRace->name,
2189 $mode,
2190 );
2191 });
2192 $subMenu_showHooks->append($menuItem_raceHooks);
2193 # (Requires a visible session whose status is 'connected' or 'offline', and a current
2194 # race)
2195 $self->ivAdd('menuItemHash', 'race_hooks', $menuItem_raceHooks);
2196  
2197 my $menuItem_charHooks = Gtk3::MenuItem->new('_Character hooks...');
2198 $menuItem_charHooks->signal_connect('activate' => sub {
2199  
2200 $self->winObj->visibleSession->pseudoCmd(
2201 'editcage hook_char_' . $self->winObj->visibleSession->currentChar->name,
2202 $mode,
2203 );
2204 });
2205 $subMenu_showHooks->append($menuItem_charHooks);
2206 # (Requires a visible session whose status is 'connected' or 'offline', and a current
2207 # character)
2208 $self->ivAdd('menuItemHash', 'char_hooks', $menuItem_charHooks);
2209  
2210 my $menuItem_showHooks = Gtk3::MenuItem->new('_Hooks');
2211 $menuItem_showHooks->set_submenu($subMenu_showHooks);
2212 $menuColumn_interfaces->append($menuItem_showHooks);
2213 # (Requires a visible session whose status is 'connected' or 'offline')
2214 $self->ivAdd('menuItemHash', 'show_hooks', $menuItem_showHooks);
2215  
2216 $menuColumn_interfaces->append(Gtk3::SeparatorMenuItem->new()); # Separator
2217  
2218 # 'Commands' submenu
2219 my $subMenu_showCmds = Gtk3::Menu->new();
2220  
2221 my $menuItem_worldCmds = Gtk3::MenuItem->new('_World commands...');
2222 $menuItem_worldCmds->signal_connect('activate' => sub {
2223  
2224 # Open the cage window on the notebook's second page, so the user can see the list
2225 # OF commands immediately
2226 $self->winObj->visibleSession->pseudoCmd('editcage -c', $mode);
2227 });
2228 $subMenu_showCmds->append($menuItem_worldCmds);
2229  
2230 my $menuItem_guildCmds = Gtk3::MenuItem->new('_Guild commands...');
2231 $menuItem_guildCmds->signal_connect('activate' => sub {
2232  
2233 $self->winObj->visibleSession->pseudoCmd(
2234 'editcage cmd_guild_' . $self->winObj->visibleSession->currentGuild->name,
2235 $mode,
2236 );
2237 });
2238 $subMenu_showCmds->append($menuItem_guildCmds);
2239 # (Requires a visible session whose status is 'connected' or 'offline', and a current
2240 # guild)
2241 $self->ivAdd('menuItemHash', 'guild_cmds', $menuItem_guildCmds);
2242  
2243 my $menuItem_raceCmds = Gtk3::MenuItem->new('_Race commands...');
2244 $menuItem_raceCmds->signal_connect('activate' => sub {
2245  
2246 $self->winObj->visibleSession->pseudoCmd(
2247 'editcage cmd_race_' . $self->winObj->visibleSession->currentRace->name,
2248 $mode,
2249 );
2250 });
2251 $subMenu_showCmds->append($menuItem_raceCmds);
2252 # (Requires a visible session whose status is 'connected' or 'offline', and a current
2253 # race)
2254 $self->ivAdd('menuItemHash', 'race_cmds', $menuItem_raceCmds);
2255  
2256 my $menuItem_charCmds = Gtk3::MenuItem->new('_Character commands...');
2257 $menuItem_charCmds->signal_connect('activate' => sub {
2258  
2259 $self->winObj->visibleSession->pseudoCmd(
2260 'editcage cmd_char_' . $self->winObj->visibleSession->currentChar->name,
2261 $mode,
2262 );
2263 });
2264 $subMenu_showCmds->append($menuItem_charCmds);
2265 # (Requires a visible session whose status is 'connected' or 'offline', and a current
2266 # character)
2267 $self->ivAdd('menuItemHash', 'char_cmds', $menuItem_charCmds);
2268  
2269 my $menuItem_showCmds = Gtk3::MenuItem->new('_Commands');
2270 $menuItem_showCmds->set_submenu($subMenu_showCmds);
2271 $menuColumn_interfaces->append($menuItem_showCmds);
2272 # (Requires a visible session whose status is 'connected' or 'offline')
2273 $self->ivAdd('menuItemHash', 'show_cmds', $menuItem_showCmds);
2274  
2275 # 'Routes' submenu
2276 my $subMenu_showRoutes = Gtk3::Menu->new();
2277  
2278 my $menuItem_worldRoutes = Gtk3::MenuItem->new('_World routes...');
2279 $menuItem_worldRoutes->signal_connect('activate' => sub {
2280  
2281 # Open the cage window on the notebook's second page, so the user can see the list
2282 # OF routes immediately
2283 $self->winObj->visibleSession->pseudoCmd('editcage -r', $mode);
2284 });
2285 $subMenu_showRoutes->append($menuItem_worldRoutes);
2286  
2287 my $menuItem_guildRoutes = Gtk3::MenuItem->new('_Guild routes...');
2288 $menuItem_guildRoutes->signal_connect('activate' => sub {
2289  
2290 $self->winObj->visibleSession->pseudoCmd(
2291 'editcage route_guild_' . $self->winObj->visibleSession->currentGuild->name,
2292 $mode,
2293 );
2294 });
2295 $subMenu_showRoutes->append($menuItem_guildRoutes);
2296 # (Requires a visible session whose status is 'connected' or 'offline', and a current
2297 # guild)
2298 $self->ivAdd('menuItemHash', 'guild_routes', $menuItem_guildRoutes);
2299  
2300 my $menuItem_raceRoutes = Gtk3::MenuItem->new('_Race routes...');
2301 $menuItem_raceRoutes->signal_connect('activate' => sub {
2302  
2303 $self->winObj->visibleSession->pseudoCmd(
2304 'editcage route_race_' . $self->winObj->visibleSession->currentRace->name,
2305 $mode,
2306 );
2307 });
2308 $subMenu_showRoutes->append($menuItem_raceRoutes);
2309 # (Requires a visible session whose status is 'connected' or 'offline', and a current
2310 # race)
2311 $self->ivAdd('menuItemHash', 'race_routes', $menuItem_raceRoutes);
2312  
2313 my $menuItem_charRoutes = Gtk3::MenuItem->new('_Character routes...');
2314 $menuItem_charRoutes->signal_connect('activate' => sub {
2315  
2316 $self->winObj->visibleSession->pseudoCmd(
2317 'editcage route_char_' . $self->winObj->visibleSession->currentChar->name,
2318 $mode,
2319 );
2320 });
2321 $subMenu_showRoutes->append($menuItem_charRoutes);
2322 # (Requires a visible session whose status is 'connected' or 'offline', and a current
2323 # character)
2324 $self->ivAdd('menuItemHash', 'char_routes', $menuItem_charRoutes);
2325  
2326 my $menuItem_showRoutes = Gtk3::MenuItem->new('_Routes');
2327 $menuItem_showRoutes->set_submenu($subMenu_showRoutes);
2328 $menuColumn_interfaces->append($menuItem_showRoutes);
2329 # (Requires a visible session whose status is 'connected' or 'offline')
2330 $self->ivAdd('menuItemHash', 'show_routes', $menuItem_showRoutes);
2331  
2332 # Setup complete
2333 return $menuColumn_interfaces;
2334 }
2335  
2336 sub drawTasksColumn {
2337  
2338 # Called by $self->enableMenu
2339 # Sets up the menu's 'Tasks' column
2340 #
2341 # Expected arguments
2342 # (none besides $self)
2343 #
2344 # Return values
2345 # 'undef' on improper arguments, or if the menu can't be created
2346 # Otherwise returns the Gtk3::Menu created
2347  
2348 my ($self, $check) = @_;
2349  
2350 # Local variables
2351 my $mode;
2352  
2353 # Check for improper arguments
2354 if (defined $check) {
2355  
2356 return $axmud::CLIENT->writeImproper($self->_objClass . '->drawTasksColumn', @_);
2357 }
2358  
2359 # Import IVs (for convenience)
2360 $mode = $self->winObj->pseudoCmdMode;
2361  
2362 # Set up column
2363 my $menuColumn_tasks = Gtk3::Menu->new();
2364 if (! $menuColumn_tasks) {
2365  
2366 return undef;
2367 }
2368  
2369 my $menuItem_freezeTasks = Gtk3::CheckMenuItem->new('_Freeze all tasks');
2370 $menuItem_freezeTasks->signal_connect('toggled' => sub {
2371  
2372 $self->winObj->visibleSession->pseudoCmd('freezetask', $mode);
2373 });
2374 $menuColumn_tasks->append($menuItem_freezeTasks);
2375 # (Requires a visible session whose status is 'connected' or 'offline')
2376 $self->ivAdd('menuItemHash', 'freeze_tasks', $menuItem_freezeTasks);
2377  
2378 $menuColumn_tasks->append(Gtk3::SeparatorMenuItem->new()); # Separator
2379  
2380 # 'Channels task' submenu
2381 my $subMenu_channelsTask = Gtk3::Menu->new();
2382  
2383 my $menuItem_channelsTask_addPattern = Gtk3::MenuItem->new('Add _channel pattern...');
2384 $menuItem_channelsTask_addPattern->signal_connect('activate' => sub {
2385  
2386 my ($pattern, $channel);
2387  
2388 # Prompt the user for a pattern/channel
2389 ($pattern, $channel) = $self->winObj->showDoubleEntryDialogue(
2390 'Add channel pattern',
2391 'Enter a pattern (regex)',
2392 'Enter a channel (1-16 chars)',
2393 );
2394  
2395 if (defined $pattern && defined $channel) {
2396  
2397 $self->winObj->visibleSession->pseudoCmd(
2398 'addchannelpattern <' . $channel . '> <' . $pattern . '>',
2399 $mode,
2400 );
2401 }
2402 });
2403 $subMenu_channelsTask->append($menuItem_channelsTask_addPattern);
2404  
2405 my $menuItem_channelsTask_addException = Gtk3::MenuItem->new(
2406 'Add _exception pattern...',
2407 );
2408 $menuItem_channelsTask_addException->signal_connect('activate' => sub {
2409  
2410 # Prompt the user for a pattern
2411 my $pattern = $self->winObj->showEntryDialogue(
2412 'Add exception pattern',
2413 'Enter a pattern (regex)',
2414 );
2415  
2416 if (defined $pattern) {
2417  
2418 $self->winObj->visibleSession->pseudoCmd(
2419 'addchannelpattern -e <' . $pattern . '>',
2420 $mode,
2421 );
2422 }
2423 });
2424 $subMenu_channelsTask->append($menuItem_channelsTask_addException);
2425  
2426 my $menuItem_channelsTask_listPattern = Gtk3::MenuItem->new('_List patterns');
2427 $menuItem_channelsTask_listPattern->signal_connect('activate' => sub {
2428  
2429 $self->winObj->visibleSession->pseudoCmd('listchannelpattern', $mode);
2430 });
2431 $subMenu_channelsTask->append($menuItem_channelsTask_listPattern);
2432  
2433 $subMenu_channelsTask->append(Gtk3::SeparatorMenuItem->new()); # Separator
2434  
2435 my $menuItem_channelsTask_emptyWindow = Gtk3::MenuItem->new('Empty Channels _window');
2436 $menuItem_channelsTask_emptyWindow->signal_connect('activate' => sub {
2437  
2438 $self->winObj->visibleSession->pseudoCmd('emptychannelswindow', $mode);
2439 });
2440 $subMenu_channelsTask->append($menuItem_channelsTask_emptyWindow);
2441  
2442 $subMenu_channelsTask->append(Gtk3::SeparatorMenuItem->new()); # Separator
2443  
2444 my $menuItem_channelsTask_editTask = Gtk3::ImageMenuItem->new('Edit current _task...');
2445 my $menuImg_channelsTask_editTask = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
2446 $menuItem_channelsTask_editTask->set_image($menuImg_channelsTask_editTask);
2447 $menuItem_channelsTask_editTask->signal_connect('activate' => sub {
2448  
2449 my $session = $self->winObj->visibleSession;
2450  
2451 # Open up a task 'edit' window to edit the task, with the 'main' window as the
2452 # parent
2453 $self->winObj->createFreeWin(
2454 'Games::Axmud::EditWin::Task',
2455 $self->winObj,
2456 $session,
2457 'Edit ' . $session->channelsTask->prettyName . ' task',
2458 $session->channelsTask,
2459 FALSE, # Not temporary
2460 # Config
2461 'edit_flag' => FALSE, # Some IVs for current tasks not editable
2462 );
2463 });
2464 $subMenu_channelsTask->append($menuItem_channelsTask_editTask);
2465  
2466 my $menuItem_channelsTask = Gtk3::MenuItem->new('_Channels task');
2467 $menuItem_channelsTask->set_submenu($subMenu_channelsTask);
2468 $menuColumn_tasks->append($menuItem_channelsTask);
2469 # (Requires a visible session whose status is 'connected' or 'offline' and is running a
2470 # Channels task)
2471 $self->ivAdd('menuItemHash', 'channels_task', $menuItem_channelsTask);
2472  
2473 # 'Chat task' submenu
2474 my $subMenu_chatTask = Gtk3::Menu->new();
2475  
2476 my $menuItem_chatTask_listen = Gtk3::MenuItem->new('_Listen for incoming calls');
2477 $menuItem_chatTask_listen->signal_connect('activate' => sub {
2478  
2479 $self->winObj->visibleSession->pseudoCmd('chatlisten', $mode);
2480 });
2481 $subMenu_chatTask->append($menuItem_chatTask_listen);
2482  
2483 my $menuItem_chatTask_ignore = Gtk3::MenuItem->new('_Ignore incoming calls');
2484 $menuItem_chatTask_ignore->signal_connect('activate' => sub {
2485  
2486 $self->winObj->visibleSession->pseudoCmd('chatignore', $mode);
2487 });
2488 $subMenu_chatTask->append($menuItem_chatTask_ignore);
2489  
2490 $subMenu_chatTask->append(Gtk3::SeparatorMenuItem->new()); # Separator
2491  
2492 my $menuItem_chatTask_chatContact = Gtk3::MenuItem->new('_Chat with...');
2493 $menuItem_chatTask_chatContact->signal_connect('activate' => sub {
2494  
2495 my (
2496 $choice,
2497 @comboList,
2498 );
2499  
2500 # Get a sorted list of chat contact names
2501 @comboList = sort {lc($a) cmp lc($b)} ($axmud::CLIENT->ivKeys('chatContactHash'));
2502 if (! @comboList) {
2503  
2504 $self->winObj->showMsgDialogue(
2505 'Chat with contact',
2506 'error',
2507 'There is no-one in your contacts list',
2508 'ok',
2509 );
2510  
2511 } else {
2512  
2513 # Prompt the user to choose a chat contact
2514 $choice = $self->winObj->showComboDialogue(
2515 'Select chat contact',
2516 'Select the chat contact to call',
2517 \@comboList,
2518 );
2519  
2520 if ($choice) {
2521  
2522 $self->session->pseudoCmd(
2523 'chatcall ' . $choice,
2524 $mode,
2525 );
2526 }
2527 }
2528 });
2529 $subMenu_chatTask->append($menuItem_chatTask_chatContact);
2530  
2531 my $menuItem_chatTask_chatMM = Gtk3::MenuItem->new('Chat using _MudMaster...');
2532 $menuItem_chatTask_chatMM->signal_connect('activate' => sub {
2533  
2534 my ($host, $port);
2535  
2536 # Prompt the user for a host and port
2537 ($host, $port) = $self->winObj->showDoubleEntryDialogue(
2538 'Chat using MudMaster',
2539 'Enter a DNS/IP address',
2540 '(Optional) enter the port',
2541 );
2542  
2543 if ($host) {
2544  
2545 if (! $port) {
2546  
2547 # (Don't use an empty string as the port)
2548 $self->winObj->visibleSession->pseudoCmd('chatmcall ' . $host, $mode);
2549  
2550 } else {
2551  
2552 $self->winObj->visibleSession->pseudoCmd(
2553 'chatmcall ' . $host . ' ' . $port,
2554 $mode,
2555 );
2556 }
2557 }
2558 });
2559 $subMenu_chatTask->append($menuItem_chatTask_chatMM);
2560  
2561 my $menuItem_chatTask_chatZChat = Gtk3::MenuItem->new('Chat using _zChat...');
2562 $menuItem_chatTask_chatZChat->signal_connect('activate' => sub {
2563  
2564 my ($host, $port);
2565  
2566 # Prompt the user for an address and port
2567 ($host, $port) = $self->winObj->showDoubleEntryDialogue(
2568 'Chat using zChat',
2569 'Enter a DNS/IP address',
2570 '(Optional) enter the port',
2571 );
2572  
2573 if ($host) {
2574  
2575 if (! $port) {
2576  
2577 # (Don't use an empty string as the port)
2578 $self->winObj->visibleSession->pseudoCmd('chatzcall ' . $host, $mode);
2579  
2580 } else {
2581  
2582 $self->winObj->visibleSession->pseudoCmd(
2583 'chatzcall ' . $host . ' ' . $port,
2584 $mode,
2585 );
2586 }
2587 }
2588 });
2589 $subMenu_chatTask->append($menuItem_chatTask_chatZChat);
2590  
2591 $subMenu_chatTask->append(Gtk3::SeparatorMenuItem->new()); # Separator
2592  
2593 my $menuItem_chatTask_allowSnoop = Gtk3::MenuItem->new('_Allow everyone to snoop');
2594 $menuItem_chatTask_allowSnoop->signal_connect('activate' => sub {
2595  
2596 $self->winObj->visibleSession->pseudoCmd('chatset -a', $mode);
2597 });
2598 $subMenu_chatTask->append($menuItem_chatTask_allowSnoop);
2599  
2600 my $menuItem_chatTask_forbidSnoop = Gtk3::MenuItem->new('_Forbid all snooping');
2601 $menuItem_chatTask_forbidSnoop->signal_connect('activate' => sub {
2602  
2603 $self->winObj->visibleSession->pseudoCmd('chatset -f', $mode);
2604 });
2605 $subMenu_chatTask->append($menuItem_chatTask_forbidSnoop);
2606  
2607 $subMenu_chatTask->append(Gtk3::SeparatorMenuItem->new()); # Separator
2608  
2609 my $menuItem_chatTask_hangUpAll = Gtk3::MenuItem->new('_Hang up on everyone');
2610 $menuItem_chatTask_hangUpAll->signal_connect('activate' => sub {
2611  
2612 $self->winObj->visibleSession->pseudoCmd('chathangup', $mode);
2613 });
2614 $subMenu_chatTask->append($menuItem_chatTask_hangUpAll);
2615  
2616 $subMenu_chatTask->append(Gtk3::SeparatorMenuItem->new()); # Separator
2617  
2618 my $menuItem_chatTask_editTask = Gtk3::ImageMenuItem->new('Edit lead chat _task...');
2619 my $menuImg_chatTask_editTask = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
2620 $menuItem_chatTask_editTask->set_image($menuImg_chatTask_editTask);
2621 $menuItem_chatTask_editTask->signal_connect('activate' => sub {
2622  
2623 my $session = $self->winObj->visibleSession;
2624  
2625 # Open up a task 'edit' window to edit the task, with the 'main' window as the
2626 # parent
2627 $self->winObj->createFreeWin(
2628 'Games::Axmud::EditWin::Task',
2629 $self->winObj,
2630 $session,
2631 'Edit ' . $session->chatTask->prettyName . ' task',
2632 $session->chatTask,
2633 FALSE, # Not temporary
2634 # Config
2635 'edit_flag' => FALSE, # Some IVs for current tasks not editable
2636 );
2637 });
2638 $subMenu_chatTask->append($menuItem_chatTask_editTask);
2639 # (Requires a visible session whose status is 'connected' or 'offline' and is running a
2640 # Chat task)
2641 $self->ivAdd('menuItemHash', 'edit_chat_task', $menuItem_chatTask_editTask);
2642  
2643 my $menuItem_chatTask = Gtk3::MenuItem->new('C_hat task');
2644 $menuItem_chatTask->set_submenu($subMenu_chatTask);
2645 $menuColumn_tasks->append($menuItem_chatTask);
2646 # (Requires a visible session whose status is 'connected' or 'offline')
2647 $self->ivAdd('menuItemHash', 'chat_task', $menuItem_chatTask);
2648  
2649 # 'Compass' submenu
2650 my $subMenu_compassTask = Gtk3::Menu->new();
2651  
2652 my $menuItem_compassTask_enableKeypad
2653 = Gtk3::MenuItem->new('_Enable keypad world commands');
2654 $menuItem_compassTask_enableKeypad->signal_connect('activate' => sub {
2655  
2656 $self->winObj->visibleSession->pseudoCmd('compass on', $mode);
2657 });
2658 $subMenu_compassTask->append($menuItem_compassTask_enableKeypad);
2659  
2660 my $menuItem_compassTask_disableKeypad
2661 = Gtk3::MenuItem->new('_Disable keypad world commands');
2662 $menuItem_compassTask_disableKeypad->signal_connect('activate' => sub {
2663  
2664 $self->winObj->visibleSession->pseudoCmd('compass off', $mode);
2665 });
2666 $subMenu_compassTask->append($menuItem_compassTask_disableKeypad);
2667  
2668 $subMenu_compassTask->append(Gtk3::SeparatorMenuItem->new()); # Separator
2669  
2670 my $menuItem_compassTask_addPattern = Gtk3::MenuItem->new('_Customise key...');
2671 $menuItem_compassTask_addPattern->signal_connect('activate' => sub {
2672  
2673 my (
2674 $cmd, $keycode,
2675 @comboList,
2676 );
2677  
2678 @comboList = (
2679 'kp_0',
2680 'kp_5',
2681 'kp_divide',
2682 'kp_multiply',
2683 'kp_full_stop',
2684 'kp_enter',
2685 );
2686  
2687 # Prompt the user for a pattern
2688 ($cmd, $keycode) = $self->winObj->showEntryComboDialogue(
2689 'Customise keypad key',
2690 '(Optional) world command',
2691 'Keypad key',
2692 \@comboList,
2693 undef, # No max chars
2694 TRUE, # Put combo above entry box
2695 );
2696  
2697 if (defined $keycode) {
2698  
2699 if (defined $cmd) {
2700  
2701 $self->winObj->visibleSession->pseudoCmd(
2702 'compass ' . $keycode . ' ' . $cmd,
2703 $mode,
2704 );
2705  
2706 } else {
2707  
2708 $self->winObj->visibleSession->pseudoCmd('compass ' . $keycode, $mode);
2709 }
2710 }
2711 });
2712 $subMenu_compassTask->append($menuItem_compassTask_addPattern);
2713  
2714 $subMenu_compassTask->append(Gtk3::SeparatorMenuItem->new()); # Separator
2715  
2716 my $menuItem_compassTask_editTask = Gtk3::ImageMenuItem->new('Edit current _task...');
2717 my $menuImg_compassTask_editTask = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
2718 $menuItem_compassTask_editTask->set_image($menuImg_compassTask_editTask);
2719 $menuItem_compassTask_editTask->signal_connect('activate' => sub {
2720  
2721 my $session = $self->winObj->visibleSession;
2722  
2723 # Open up a task 'edit' window to edit the task, with the 'main' window as the
2724 # parent
2725 $self->winObj->createFreeWin(
2726 'Games::Axmud::EditWin::Task',
2727 $self->winObj,
2728 $session,
2729 'Edit ' . $session->compassTask->prettyName . ' task',
2730 $session->compassTask,
2731 FALSE, # Not temporary
2732 # Config
2733 'edit_flag' => FALSE, # Some IVs for current tasks not editable
2734 );
2735 });
2736 $subMenu_compassTask->append($menuItem_compassTask_editTask);
2737  
2738 my $menuItem_compassTask = Gtk3::MenuItem->new('C_ompass task');
2739 $menuItem_compassTask->set_submenu($subMenu_compassTask);
2740 $menuColumn_tasks->append($menuItem_compassTask);
2741 # (Requires a visible session whose status is 'connected' or 'offline' and is running a
2742 # Compass task)
2743 $self->ivAdd('menuItemHash', 'compass_task', $menuItem_compassTask);
2744  
2745 # 'Divert task' submenu
2746 my $subMenu_divertTask = Gtk3::Menu->new();
2747  
2748 my $menuItem_divertTask_addPattern = Gtk3::MenuItem->new('Add _channel pattern...');
2749 $menuItem_divertTask_addPattern->signal_connect('activate' => sub {
2750  
2751 my ($pattern, $channel);
2752  
2753 # Prompt the user for a pattern/channel
2754 ($pattern, $channel) = $self->winObj->showDoubleEntryDialogue(
2755 'Add channel pattern',
2756 'Enter a pattern (regex)',
2757 'Enter a channel (1-16 chars)',
2758 );
2759  
2760 if (defined $pattern && defined $channel) {
2761  
2762 $self->winObj->visibleSession->pseudoCmd(
2763 'addchannelpattern <' . $channel . '> <' . $pattern . '>',
2764 $mode,
2765 );
2766 }
2767 });
2768 $subMenu_divertTask->append($menuItem_divertTask_addPattern);
2769  
2770 my $menuItem_divertTask_addException = Gtk3::MenuItem->new('Add _exception pattern...');
2771 $menuItem_divertTask_addException->signal_connect('activate' => sub {
2772  
2773 # Prompt the user for a pattern
2774 my $pattern = $self->winObj->showEntryDialogue(
2775 'Add exception pattern',
2776 'Enter a pattern (regex)',
2777 );
2778  
2779 if (defined $pattern) {
2780  
2781 $self->winObj->visibleSession->pseudoCmd(
2782 'addchannelpattern -e <' . $pattern . '>',
2783 $mode,
2784 );
2785 }
2786 });
2787 $subMenu_divertTask->append($menuItem_divertTask_addException);
2788  
2789 my $menuItem_divertTask_listPattern = Gtk3::MenuItem->new('_List patterns');
2790 $menuItem_divertTask_listPattern->signal_connect('activate' => sub {
2791  
2792 $self->winObj->visibleSession->pseudoCmd('listchannelpattern', $mode);
2793 });
2794 $subMenu_divertTask->append($menuItem_divertTask_listPattern);
2795  
2796 $subMenu_divertTask->append(Gtk3::SeparatorMenuItem->new()); # Separator
2797  
2798 my $menuItem_divertTask_emptyWindow = Gtk3::MenuItem->new('Empty divert _window');
2799 $menuItem_divertTask_emptyWindow->signal_connect('activate' => sub {
2800  
2801 $self->winObj->visibleSession->pseudoCmd('emptydivertwindow', $mode);
2802 });
2803 $subMenu_divertTask->append($menuItem_divertTask_emptyWindow);
2804  
2805 $subMenu_divertTask->append(Gtk3::SeparatorMenuItem->new()); # Separator
2806  
2807 my $menuItem_divertTask_editTask = Gtk3::ImageMenuItem->new('Edit current _task...');
2808 my $menuImg_divertTask_editTask = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
2809 $menuItem_divertTask_editTask->set_image($menuImg_divertTask_editTask);
2810 $menuItem_divertTask_editTask->signal_connect('activate' => sub {
2811  
2812 my $session = $self->winObj->visibleSession;
2813  
2814 # Open up a task 'edit' window to edit the task, with the 'main' window as the
2815 # parent
2816 $self->winObj->createFreeWin(
2817 'Games::Axmud::EditWin::Task',
2818 $self->winObj,
2819 $session,
2820 'Edit ' . $session->divertTask->prettyName . ' task',
2821 $session->divertTask,
2822 FALSE, # Not temporary
2823 # Config
2824 'edit_flag' => FALSE, # Some IVs for current tasks not editable
2825 );
2826 });
2827 $subMenu_divertTask->append($menuItem_divertTask_editTask);
2828  
2829 my $menuItem_divertTask = Gtk3::MenuItem->new('_Divert task');
2830 $menuItem_divertTask->set_submenu($subMenu_divertTask);
2831 $menuColumn_tasks->append($menuItem_divertTask);
2832 # (Requires a visible session whose status is 'connected' or 'offline' and is running a
2833 # Divert task)
2834 $self->ivAdd('menuItemHash', 'divert_task', $menuItem_divertTask);
2835  
2836 # 'Inventory/Condition task' submenu
2837 my $subMenu_inventoryTask = Gtk3::Menu->new();
2838  
2839 my $menuItem_inventoryTask_activateTask = Gtk3::MenuItem->new('_Activate task');
2840 $menuItem_inventoryTask_activateTask->signal_connect('activate' => sub {
2841  
2842 $self->winObj->visibleSession->pseudoCmd('activateinventory', $mode);
2843 });
2844 $subMenu_inventoryTask->append($menuItem_inventoryTask_activateTask);
2845  
2846 my $menuItem_inventoryTask_disactivateTask = Gtk3::MenuItem->new('_Disactivate task');
2847 $menuItem_inventoryTask_disactivateTask->signal_connect('activate' => sub {
2848  
2849 $self->winObj->visibleSession->pseudoCmd('disactivateinventory', $mode);
2850 });
2851 $subMenu_inventoryTask->append($menuItem_inventoryTask_disactivateTask);
2852  
2853 $subMenu_inventoryTask->append(Gtk3::SeparatorMenuItem->new()); # Separator
2854  
2855 my $menuItem_inventoryTask_sellAll = Gtk3::MenuItem->new('_Sell all');
2856 $menuItem_inventoryTask_sellAll->signal_connect('activate' => sub {
2857  
2858 $self->winObj->visibleSession->pseudoCmd('sellall', $mode);
2859 });
2860 $subMenu_inventoryTask->append($menuItem_inventoryTask_sellAll);
2861  
2862 my $menuItem_inventoryTask_dropAll = Gtk3::MenuItem->new('D_rop all');
2863 $menuItem_inventoryTask_dropAll->signal_connect('activate' => sub {
2864  
2865 $self->winObj->visibleSession->pseudoCmd('dropall', $mode);
2866 });
2867 $subMenu_inventoryTask->append($menuItem_inventoryTask_dropAll);
2868  
2869 $subMenu_inventoryTask->append(Gtk3::SeparatorMenuItem->new()); # Separator
2870  
2871 my $menuItem_inventoryTask_editTask = Gtk3::ImageMenuItem->new(
2872 'Edit current _Inventory task...',
2873 );
2874 my $menuImg_inventoryTask_editTask = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
2875 $menuItem_inventoryTask_editTask->set_image($menuImg_inventoryTask_editTask);
2876 $menuItem_inventoryTask_editTask->signal_connect('activate' => sub {
2877  
2878 my $session = $self->winObj->visibleSession;
2879  
2880 # Open up a task 'edit' window to edit the task, with the 'main' window as the
2881 # parent
2882 $self->winObj->createFreeWin(
2883 'Games::Axmud::EditWin::Task',
2884 $self->winObj,
2885 $session,
2886 'Edit ' . $session->inventoryTask->prettyName . ' task',
2887 $session->inventoryTask,
2888 FALSE, # Not temporary
2889 # Config
2890 'edit_flag' => FALSE, # Some IVs for current tasks not editable
2891 );
2892 });
2893 $subMenu_inventoryTask->append($menuItem_inventoryTask_editTask);
2894  
2895 my $menuItem_conditionTask_editTask = Gtk3::ImageMenuItem->new(
2896 'Edit current _Condition task...',
2897 );
2898 my $menuImg_conditionTask_editTask = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
2899 $menuItem_conditionTask_editTask->set_image($menuImg_conditionTask_editTask);
2900 $menuItem_conditionTask_editTask->signal_connect('activate' => sub {
2901  
2902 my $session = $self->winObj->visibleSession;
2903  
2904 # Open up a task 'edit' window to edit the task, with the 'main' window as the
2905 # parent
2906 $self->winObj->createFreeWin(
2907 'Games::Axmud::EditWin::Task',
2908 $self->winObj,
2909 $session,
2910 'Edit ' . $session->conditionTask->prettyName . ' task',
2911 $session->conditionTask,
2912 FALSE, # Not temporary
2913 # Config
2914 'edit_flag' => FALSE, # Some IVs for current tasks not editable
2915 );
2916 });
2917 $subMenu_inventoryTask->append($menuItem_conditionTask_editTask);
2918  
2919 my $menuItem_inventoryTask = Gtk3::MenuItem->new('_Inventory/Condition tasks');
2920 $menuItem_inventoryTask->set_submenu($subMenu_inventoryTask);
2921 $menuColumn_tasks->append($menuItem_inventoryTask);
2922 # (Requires a visible session whose status is 'connected' or 'offline' and is running a
2923 # Inventory task)
2924 $self->ivAdd('menuItemHash', 'inventory_task', $menuItem_inventoryTask);
2925  
2926 # 'Locator task' submenu
2927 my $subMenu_locatorTask = Gtk3::Menu->new();
2928  
2929 my $menuItem_locatorTask_resetTask = Gtk3::MenuItem->new('_Reset task');
2930 $menuItem_locatorTask_resetTask->signal_connect('activate' => sub {
2931  
2932 $self->winObj->visibleSession->pseudoCmd('resetlocatortask', $mode);
2933 });
2934 $subMenu_locatorTask->append($menuItem_locatorTask_resetTask);
2935  
2936 my $menuItem_locatorTask_toggleLocWin = Gtk3::MenuItem->new('Toggle task _window');
2937 $menuItem_locatorTask_toggleLocWin->signal_connect('activate' => sub {
2938  
2939 if ($self->winObj->visibleSession->locatorTask->winObj) {
2940  
2941 $self->winObj->visibleSession->pseudoCmd('closetaskwindow locator', $mode);
2942  
2943 } else {
2944  
2945 $self->winObj->visibleSession->pseudoCmd('opentaskwindow locator', $mode);
2946 }
2947 });
2948 $subMenu_locatorTask->append($menuItem_locatorTask_toggleLocWin);
2949  
2950 $subMenu_locatorTask->append(Gtk3::SeparatorMenuItem->new()); # Separator
2951  
2952 my $menuItem_locatorTask_toggleUnknown
2953 = Gtk3::MenuItem->new('T_oggle unknown word collection');
2954 $menuItem_locatorTask_toggleUnknown->signal_connect('activate' => sub {
2955  
2956 $self->winObj->visibleSession->pseudoCmd('collectunknownwords', $mode);
2957 });
2958 $subMenu_locatorTask->append($menuItem_locatorTask_toggleUnknown);
2959  
2960 my $menuItem_locatorTask_emptyUnknown
2961 = Gtk3::MenuItem->new('_Empty unknown word list');
2962 $menuItem_locatorTask_emptyUnknown->signal_connect('activate' => sub {
2963  
2964 $self->winObj->visibleSession->pseudoCmd('emptyunknownwords', $mode);
2965 });
2966 $subMenu_locatorTask->append($menuItem_locatorTask_emptyUnknown);
2967  
2968 my $menuItem_locatorTask_displayUnknown
2969 = Gtk3::MenuItem->new('_Display unknown word list');
2970 $menuItem_locatorTask_displayUnknown->signal_connect('activate' => sub {
2971  
2972 $self->winObj->visibleSession->pseudoCmd('listunknownwords', $mode);
2973 });
2974 $subMenu_locatorTask->append($menuItem_locatorTask_displayUnknown);
2975  
2976 $subMenu_locatorTask->append(Gtk3::SeparatorMenuItem->new()); # Separator
2977  
2978 my $menuItem_locatorWiz = Gtk3::ImageMenuItem->new('Run _Locator wizard...');
2979 my $menuImg_locatorWiz = Gtk3::Image->new_from_stock('gtk-page-setup', 'menu');
2980 $menuItem_locatorWiz->set_image($menuImg_locatorWiz);
2981 $menuItem_locatorWiz->signal_connect('activate' => sub {
2982  
2983 $self->winObj->visibleSession->pseudoCmd('locatorwizard', $mode);
2984 });
2985 $subMenu_locatorTask->append($menuItem_locatorWiz);
2986 # (Requires a visible session whose status is 'connected' or 'offline'. A
2987 # corresponding menu item also appears in $self->drawEditColumn)
2988 $self->ivAdd('menuItemHash', 'run_locator_wiz_2', $menuItem_locatorWiz);
2989  
2990 $subMenu_locatorTask->append(Gtk3::SeparatorMenuItem->new()); # Separator
2991  
2992 my $menuItem_locatorTask_editTask = Gtk3::ImageMenuItem->new('Edit current _task...');
2993 my $menuImg_locatorTask_editTask = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
2994 $menuItem_locatorTask_editTask->set_image($menuImg_locatorTask_editTask);
2995 $menuItem_locatorTask_editTask->signal_connect('activate' => sub {
2996  
2997 my $session = $self->winObj->visibleSession;
2998  
2999 # Open up a task 'edit' window to edit the task, with the 'main' window as the
3000 # parent
3001 $self->winObj->createFreeWin(
3002 'Games::Axmud::EditWin::Task',
3003 $self->winObj,
3004 $session,
3005 'Edit ' . $session->locatorTask->prettyName . ' task',
3006 $session->locatorTask,
3007 FALSE, # Not temporary
3008 # Config
3009 'edit_flag' => FALSE, # Some IVs for current tasks not editable
3010 );
3011 });
3012 $subMenu_locatorTask->append($menuItem_locatorTask_editTask);
3013  
3014 my $menuItem_locatorTask = Gtk3::MenuItem->new('_Locator task');
3015 $menuItem_locatorTask->set_submenu($subMenu_locatorTask);
3016 $menuColumn_tasks->append($menuItem_locatorTask);
3017 # (Requires a visible session whose status is 'connected' or 'offline' and is running a
3018 # Locator task)
3019 $self->ivAdd('menuItemHash', 'locator_task', $menuItem_locatorTask);
3020  
3021 # 'Status task' submenu
3022 my $subMenu_statusTask = Gtk3::Menu->new();
3023  
3024 my $menuItem_statusTask_activateTask = Gtk3::MenuItem->new('_Activate task');
3025 $menuItem_statusTask_activateTask->signal_connect('activate' => sub {
3026  
3027 $self->winObj->visibleSession->pseudoCmd('activatestatustask', $mode);
3028 });
3029 $subMenu_statusTask->append($menuItem_statusTask_activateTask);
3030  
3031 my $menuItem_statusTask_disactivateTask = Gtk3::MenuItem->new('_Disactivate task');
3032 $menuItem_statusTask_disactivateTask->signal_connect('activate' => sub {
3033  
3034 $self->winObj->visibleSession->pseudoCmd('disactivatestatustask', $mode);
3035 });
3036 $subMenu_statusTask->append($menuItem_statusTask_disactivateTask);
3037  
3038 my $menuItem_statusTask_resetCounters = Gtk3::MenuItem->new('_Reset all counters');
3039 $menuItem_statusTask_resetCounters->signal_connect('activate' => sub {
3040  
3041 $self->winObj->visibleSession->pseudoCmd('resetcounter', $mode);
3042 });
3043 $subMenu_statusTask->append($menuItem_statusTask_resetCounters);
3044  
3045 $subMenu_statusTask->append(Gtk3::SeparatorMenuItem->new()); # Separator
3046  
3047 # 'Gauges' submenu
3048 my $subMenu_gauges = Gtk3::Menu->new();
3049  
3050 my $menuItem_statusTask_toggleStatWin = Gtk3::MenuItem->new('Toggle task _window');
3051 $menuItem_statusTask_toggleStatWin->signal_connect('activate' => sub {
3052  
3053 if ($self->winObj->visibleSession->statusTask->winObj) {
3054  
3055 $self->winObj->visibleSession->pseudoCmd('closetaskwindow status', $mode);
3056  
3057 } else {
3058  
3059 $self->winObj->visibleSession->pseudoCmd('opentaskwindow status', $mode);
3060 }
3061 });
3062 $subMenu_gauges->append($menuItem_statusTask_toggleStatWin);
3063  
3064 my $menuItem_statusTask_showGauge = Gtk3::MenuItem->new('Toggle _gauges');
3065 $menuItem_statusTask_showGauge->signal_connect('activate' => sub {
3066  
3067 $self->winObj->visibleSession->pseudoCmd('showstatusgauge', $mode);
3068 });
3069 $subMenu_gauges->append($menuItem_statusTask_showGauge);
3070  
3071 my $menuItem_statusTask_showGaugeLabel = Gtk3::MenuItem->new('Toggle gauge _labels');
3072 $menuItem_statusTask_showGaugeLabel->signal_connect('activate' => sub {
3073  
3074 $self->winObj->visibleSession->pseudoCmd('showstatusgauge -l', $mode);
3075 });
3076 $subMenu_gauges->append($menuItem_statusTask_showGaugeLabel);
3077  
3078 my $menuItem_gauges = Gtk3::MenuItem->new('D_isplay');
3079 $menuItem_gauges->set_submenu($subMenu_gauges);
3080 $subMenu_statusTask->append($menuItem_gauges);
3081  
3082 $subMenu_statusTask->append(Gtk3::SeparatorMenuItem->new()); # Separator
3083  
3084 my $menuItem_statusTask_editTask = Gtk3::ImageMenuItem->new('Edit current _task...');
3085 my $menuImg_statusTask_editTask = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
3086 $menuItem_statusTask_editTask->set_image($menuImg_statusTask_editTask);
3087 $menuItem_statusTask_editTask->signal_connect('activate' => sub {
3088  
3089 my $session = $self->winObj->visibleSession;
3090  
3091 # Open up a task 'edit' window to edit the task, with the 'main' window as the
3092 # parent
3093 $self->winObj->createFreeWin(
3094 'Games::Axmud::EditWin::Task',
3095 $self->winObj,
3096 $session,
3097 'Edit ' . $session->statusTask->prettyName . ' task',
3098 $session->statusTask,
3099 FALSE, # Not temporary
3100 # Config
3101 'edit_flag' => FALSE, # Some IVs for current tasks not editable
3102 );
3103 });
3104 $subMenu_statusTask->append($menuItem_statusTask_editTask);
3105  
3106 my $menuItem_statusTask = Gtk3::MenuItem->new('_Status task');
3107 $menuItem_statusTask->set_submenu($subMenu_statusTask);
3108 $menuColumn_tasks->append($menuItem_statusTask);
3109 # (Requires a visible session whose status is 'connected' or 'offline' and is running a
3110 # Status task)
3111 $self->ivAdd('menuItemHash', 'status_task', $menuItem_statusTask);
3112  
3113 # 'Watch' submenu
3114 my $subMenu_watchTask = Gtk3::Menu->new();
3115  
3116 my $menuItem_watchTask_emptyWindow = Gtk3::MenuItem->new('Empty watch _window');
3117 $menuItem_watchTask_emptyWindow->signal_connect('activate' => sub {
3118  
3119 $self->winObj->visibleSession->pseudoCmd('emptywatchwindow', $mode);
3120 });
3121 $subMenu_watchTask->append($menuItem_watchTask_emptyWindow);
3122  
3123 $subMenu_watchTask->append(Gtk3::SeparatorMenuItem->new()); # Separator
3124  
3125 my $menuItem_watchTask_editTask = Gtk3::ImageMenuItem->new('Edit current _task...');
3126 my $menuImg_watchTask_editTask = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
3127 $menuItem_watchTask_editTask->set_image($menuImg_watchTask_editTask);
3128 $menuItem_watchTask_editTask->signal_connect('activate' => sub {
3129  
3130 my $session = $self->winObj->visibleSession;
3131  
3132 # Open up a task 'edit' window to edit the task, with the 'main' window as the
3133 # parent
3134 $self->winObj->createFreeWin(
3135 'Games::Axmud::EditWin::Task',
3136 $self->winObj,
3137 $session,
3138 'Edit ' . $session->watchTask->prettyName . ' task',
3139 $session->watchTask,
3140 FALSE, # Not temporary
3141 # Config
3142 'edit_flag' => FALSE, # Some IVs for current tasks not editable
3143 );
3144 });
3145 $subMenu_watchTask->append($menuItem_watchTask_editTask);
3146  
3147 my $menuItem_watchTask = Gtk3::MenuItem->new('_Watch task');
3148 $menuItem_watchTask->set_submenu($subMenu_watchTask);
3149 $menuColumn_tasks->append($menuItem_watchTask);
3150 # (Requires a visible session whose status is 'connected' or 'offline' and is running a
3151 # Watch task)
3152 $self->ivAdd('menuItemHash', 'watch_task', $menuItem_watchTask);
3153  
3154 $menuColumn_tasks->append(Gtk3::SeparatorMenuItem->new()); # Separator
3155  
3156 # 'Other tasks' submenu
3157 my $subMenu_otherTask = Gtk3::Menu->new();
3158  
3159 my $menuItem_advanceTask_editTask = Gtk3::ImageMenuItem->new(
3160 'Edit current Ad_vance task...',
3161 );
3162 my $menuImg_advanceTask_editTask = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
3163 $menuItem_advanceTask_editTask->set_image($menuImg_advanceTask_editTask);
3164 $menuItem_advanceTask_editTask->signal_connect('activate' => sub {
3165  
3166 my $session = $self->winObj->visibleSession;
3167  
3168 # Open up a task 'edit' window to edit the task, with the 'main' window as the
3169 # parent
3170 $self->winObj->createFreeWin(
3171 'Games::Axmud::EditWin::Task',
3172 $self->winObj,
3173 $session,
3174 'Edit ' . $session->advanceTask->prettyName . ' task',
3175 $session->advanceTask,
3176 FALSE, # Not temporary
3177 # Config
3178 'edit_flag' => FALSE, # Some IVs for current tasks not editable
3179 );
3180 });
3181 $subMenu_otherTask->append($menuItem_advanceTask_editTask);
3182 # (Requires a visible session whose status is 'connected' or 'offline' and is running an
3183 # Advance task)
3184 $self->ivAdd('menuItemHash', 'edit_advance_task', $menuItem_advanceTask_editTask);
3185  
3186 my $menuItem_attackTask_editTask = Gtk3::ImageMenuItem->new(
3187 'Edit current _Attack task...',
3188 );
3189 my $menuImg_attackTask_editTask = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
3190 $menuItem_attackTask_editTask->set_image($menuImg_attackTask_editTask);
3191 $menuItem_attackTask_editTask->signal_connect('activate' => sub {
3192  
3193 my $session = $self->winObj->visibleSession;
3194  
3195 # Open up a task 'edit' window to edit the task, with the 'main' window as the
3196 # parent
3197 $self->winObj->createFreeWin(
3198 'Games::Axmud::EditWin::Task',
3199 $self->winObj,
3200 $session,
3201 'Edit ' . $session->attackTask->prettyName . ' task',
3202 $session->attackTask,
3203 FALSE, # Not temporary
3204 # Config
3205 'edit_flag' => FALSE, # Some IVs for current tasks not editable
3206 );
3207 });
3208 $subMenu_otherTask->append($menuItem_attackTask_editTask);
3209 # (Requires a visible session whose status is 'connected' or 'offline' and is running an
3210 # Attack task)
3211 $self->ivAdd('menuItemHash', 'edit_attack_task', $menuItem_attackTask_editTask);
3212  
3213 my $menuItem_connectTask_editTask = Gtk3::ImageMenuItem->new(
3214 'Edit current _Connections task...',
3215 );
3216 my $menuImg_connectTask_editTask = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
3217 $menuItem_connectTask_editTask->set_image($menuImg_connectTask_editTask);
3218 $menuItem_connectTask_editTask->signal_connect('activate' => sub {
3219  
3220 my $session = $self->winObj->visibleSession;
3221  
3222 # Open up a task 'edit' window to edit the task, with the 'main' window as the
3223 # parent
3224 $self->winObj->createFreeWin(
3225 'Games::Axmud::EditWin::Task',
3226 $self->winObj,
3227 $session,
3228 'Edit ' . $session->connectionsTask->prettyName . ' task',
3229 $session->connectionsTask,
3230 FALSE, # Not temporary
3231 # Config
3232 'edit_flag' => FALSE, # Some IVs for current tasks not editable
3233 );
3234 });
3235 $subMenu_otherTask->append($menuItem_connectTask_editTask);
3236 # (Requires a visible session whose status is 'connected' or 'offline' and is running a
3237 # Connections task)
3238 $self->ivAdd('menuItemHash', 'edit_connections_task', $menuItem_connectTask_editTask);
3239  
3240 my $menuItem_rawTokenTask_editTask = Gtk3::ImageMenuItem->new(
3241 'Edit current Raw _Token task...',
3242 );
3243 my $menuImg_rawTokenTask_editTask = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
3244 $menuItem_rawTokenTask_editTask->set_image($menuImg_rawTokenTask_editTask);
3245 $menuItem_rawTokenTask_editTask->signal_connect('activate' => sub {
3246  
3247 my $session = $self->winObj->visibleSession;
3248  
3249 # Open up a task 'edit' window to edit the task, with the 'main' window as the
3250 # parent
3251 $self->winObj->createFreeWin(
3252 'Games::Axmud::EditWin::Task',
3253 $self->winObj,
3254 $session,
3255 'Edit ' . $session->rawTokenTask->prettyName . ' task',
3256 $session->rawTokenTask,
3257 FALSE, # Not temporary
3258 # Config
3259 'edit_flag' => FALSE, # Some IVs for current tasks not editable
3260 );
3261 });
3262 $subMenu_otherTask->append($menuItem_rawTokenTask_editTask);
3263 # (Requires a visible session whose status is 'connected' or 'offline' and is running a
3264 # RawToken task)
3265 $self->ivAdd('menuItemHash', 'edit_raw_token_task', $menuItem_rawTokenTask_editTask);
3266  
3267 my $menuItem_systemTask_editTask = Gtk3::ImageMenuItem->new(
3268 'Edit current _System task...',
3269 );
3270 my $menuImg_systemTask_editTask = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
3271 $menuItem_systemTask_editTask->set_image($menuImg_systemTask_editTask);
3272 $menuItem_systemTask_editTask->signal_connect('activate' => sub {
3273  
3274 my $session = $self->winObj->visibleSession;
3275  
3276 # Open up a task 'edit' window to edit the task, with the 'main' window as the
3277 # parent
3278 $self->winObj->createFreeWin(
3279 'Games::Axmud::EditWin::Task',
3280 $self->winObj,
3281 $session,
3282 'Edit ' . $session->systemTask->prettyName . ' task',
3283 $session->systemTask,
3284 FALSE, # Not temporary
3285 # Config
3286 'edit_flag' => FALSE, # Some IVs for current tasks not editable
3287 );
3288 });
3289 $subMenu_otherTask->append($menuItem_systemTask_editTask);
3290 # (Requires a visible session whose status is 'connected' or 'offline' and is running a
3291 # System task)
3292 $self->ivAdd('menuItemHash', 'edit_system_task', $menuItem_systemTask_editTask);
3293  
3294 my $menuItem_otherTask = Gtk3::MenuItem->new('Other _built-in tasks');
3295 $menuItem_otherTask->set_submenu($subMenu_otherTask);
3296 $menuColumn_tasks->append($menuItem_otherTask);
3297 # (Requires a visible session whose status is 'connected' or 'offline')
3298 $self->ivAdd('menuItemHash', 'other_task', $menuItem_otherTask);
3299  
3300 # Setup complete
3301 return $menuColumn_tasks;
3302 }
3303  
3304 sub drawDisplayColumn {
3305  
3306 # Called by $self->enableMenu
3307 # Sets up the menu's 'Display' column
3308 #
3309 # Expected arguments
3310 # (none besides $self)
3311 #
3312 # Return values
3313 # 'undef' on improper arguments, or if the menu can't be created
3314 # Otherwise returns the Gtk3::Menu created
3315  
3316 my ($self, $check) = @_;
3317  
3318 # Local variables
3319 my $mode;
3320  
3321 # Check for improper arguments
3322 if (defined $check) {
3323  
3324 return $axmud::CLIENT->writeImproper($self->_objClass . '->drawDisplayColumn', @_);
3325 }
3326  
3327 # Import IVs (for convenience)
3328 $mode = $self->winObj->pseudoCmdMode;
3329  
3330 # Set up column
3331 my $menuColumn_display = Gtk3::Menu->new();
3332 if (! $menuColumn_display) {
3333  
3334 return undef;
3335 }
3336  
3337 my $menuItem_openAutomapper = Gtk3::ImageMenuItem->new('Open _automapper');
3338 my $menuImg_openAutomapper = Gtk3::Image->new_from_stock('gtk-jump-to', 'menu');
3339 $menuItem_openAutomapper->set_image($menuImg_openAutomapper);
3340 $menuItem_openAutomapper->signal_connect('activate' => sub {
3341  
3342 $self->winObj->visibleSession->pseudoCmd('openautomapper', $mode);
3343 });
3344 $menuColumn_display->append($menuItem_openAutomapper);
3345 # (Requires a visible session whose status is 'connected' or 'offline')
3346 $self->ivAdd('menuItemHash', 'open_automapper', $menuItem_openAutomapper);
3347  
3348 my $menuItem_openViewer = Gtk3::ImageMenuItem->new('Open object _viewer');
3349 my $menuImg_openViewer = Gtk3::Image->new_from_stock('gtk-jump-to', 'menu');
3350 $menuItem_openViewer->set_image($menuImg_openViewer);
3351 $menuItem_openViewer->signal_connect('activate' => sub {
3352  
3353 $self->winObj->visibleSession->pseudoCmd('openobjectviewer', $mode);
3354 });
3355 $menuColumn_display->append($menuItem_openViewer);
3356 # (Requires a visible session whose status is 'connected' or 'offline')
3357 $self->ivAdd('menuItemHash', 'open_object_viewer', $menuItem_openViewer);
3358  
3359 $menuColumn_display->append(Gtk3::SeparatorMenuItem->new()); # Separator
3360  
3361 # 'Current layer' submenu
3362 my $subMenu_currentLayer = Gtk3::Menu->new();
3363  
3364 my $menuItem_currentLayer_moveUp = Gtk3::MenuItem->new('Move _up');
3365 $menuItem_currentLayer_moveUp->signal_connect('activate' => sub {
3366  
3367 $self->winObj->visibleSession->pseudoCmd('layerup', $mode);
3368 });
3369 $subMenu_currentLayer->append($menuItem_currentLayer_moveUp);
3370  
3371 my $menuItem_currentLayer_moveDown = Gtk3::MenuItem->new('Move _down');
3372 $menuItem_currentLayer_moveDown->signal_connect('activate' => sub {
3373  
3374 $self->winObj->visibleSession->pseudoCmd('layerdown', $mode);
3375 });
3376 $subMenu_currentLayer->append($menuItem_currentLayer_moveDown);
3377  
3378 $subMenu_currentLayer->append(Gtk3::SeparatorMenuItem->new()); # Separator
3379  
3380 my $menuItem_currentLayer_moveTop = Gtk3::MenuItem->new('Move to _top');
3381 $menuItem_currentLayer_moveTop->signal_connect('activate' => sub {
3382  
3383 # Get the workspace grid object used by the visible session; can't rely on
3384 # $self->workspaceGridObj because 'main' windows might appear on several
3385 # workspaces
3386 my $gridObj
3387 = $self->winObj->workspaceObj->findWorkspaceGrid($self->visibleSession);
3388  
3389 if ($gridObj) {
3390  
3391 $self->winObj->visibleSession->pseudoCmd(
3392 'setlayer ' . ($gridObj->maxLayers - 1),
3393 $mode,
3394 );
3395 }
3396 });
3397 $subMenu_currentLayer->append($menuItem_currentLayer_moveTop);
3398  
3399 my $menuItem_currentLayer_moveBottom = Gtk3::MenuItem->new('Move to _bottom');
3400 $menuItem_currentLayer_moveBottom->signal_connect('activate' => sub {
3401  
3402 $self->winObj->visibleSession->pseudoCmd('setlayer 0', $mode);
3403 });
3404 $subMenu_currentLayer->append($menuItem_currentLayer_moveBottom);
3405  
3406 $subMenu_currentLayer->append(Gtk3::SeparatorMenuItem->new()); # Separator
3407  
3408 my $menuItem_currentLayer_setLayer = Gtk3::MenuItem->new('_Set layer...');
3409 $menuItem_currentLayer_setLayer->signal_connect('activate' => sub {
3410  
3411 my ($gridObj, $result);
3412  
3413 $gridObj = $self->winObj->workspaceObj->findWorkspaceGrid($self->visibleSession);
3414  
3415 if ($gridObj) {
3416  
3417 # Display a dialogue to choose the new layer
3418 $result = $self->winObj->showEntryDialogue(
3419 'Set layer',
3420 'Enter the new layer (in the range 0-' . ($gridObj->maxLayers - 1) . ')',
3421 );
3422  
3423 if ($result) {
3424  
3425 # Set the layer
3426 $self->winObj->visibleSession->pseudoCmd('setlayer ' . $result, $mode);
3427 }
3428 }
3429 });
3430 $subMenu_currentLayer->append($menuItem_currentLayer_setLayer);
3431  
3432 my $menuItem_currentLayer = Gtk3::MenuItem->new('Current _layer');
3433 $menuItem_currentLayer->set_submenu($subMenu_currentLayer);
3434 $menuColumn_display->append($menuItem_currentLayer);
3435 # (Requires a visible session whose status is 'connected' or 'offline')
3436 $self->ivAdd('menuItemHash', 'current_layer', $menuItem_currentLayer);
3437  
3438 # 'Window storage' submenu
3439 my $subMenu_windowStorage = Gtk3::Menu->new();
3440  
3441 my $menuItem_autoStore
3442 = Gtk3::CheckMenuItem->new('_Automatically store sizes/positions');
3443 $menuItem_autoStore->signal_connect('toggled' => sub {
3444  
3445 $self->winObj->visibleSession->pseudoCmd('togglewindowstorage', $mode);
3446 });
3447 $subMenu_windowStorage->append($menuItem_autoStore);
3448  
3449 my $menuItem_storeCurrent = Gtk3::MenuItem->new('_Store current sizes/positions');
3450 $menuItem_storeCurrent->signal_connect('activate' => sub {
3451  
3452 $self->winObj->visibleSession->pseudoCmd('applywindowstorage', $mode);
3453 });
3454 $subMenu_windowStorage->append($menuItem_storeCurrent);
3455  
3456 $subMenu_windowStorage->append(Gtk3::SeparatorMenuItem->new()); # Separator
3457  
3458 my $menuItem_resetStorage = Gtk3::MenuItem->new('_Clear stored sizes/positions');
3459 $menuItem_resetStorage->signal_connect('activate' => sub {
3460  
3461 $self->winObj->visibleSession->pseudoCmd('clearwindowstorage', $mode);
3462 });
3463 $subMenu_windowStorage->append($menuItem_resetStorage);
3464  
3465 my $menuItem_windowStorage = Gtk3::MenuItem->new('\'Grid\' _window storage');
3466 $menuItem_windowStorage->set_submenu($subMenu_windowStorage);
3467 $menuColumn_display->append($menuItem_windowStorage);
3468 # (Requires a visible session whose status is 'connected' or 'offline')
3469 $self->ivAdd('menuItemHash', 'window_storage', $menuItem_windowStorage);
3470  
3471 $menuColumn_display->append(Gtk3::SeparatorMenuItem->new()); # Separator
3472  
3473 my $menuItem_testControls = Gtk3::MenuItem->new('_Test window controls');
3474 $menuItem_testControls->signal_connect('activate' => sub {
3475  
3476 $self->winObj->visibleSession->pseudoCmd('testwindowcontrols', $mode);
3477 });
3478 $menuColumn_display->append($menuItem_testControls);
3479 # (Requires a visible session whose status is 'connected' or 'offline')
3480 $self->ivAdd('menuItemHash', 'test_controls', $menuItem_testControls);
3481  
3482 my $menuItem_testPanels = Gtk3::MenuItem->new('T_est panels');
3483 $menuItem_testPanels->signal_connect('activate' => sub {
3484  
3485 $self->winObj->visibleSession->pseudoCmd('testpanel', $mode);
3486 });
3487 $menuColumn_display->append($menuItem_testPanels);
3488 # (Requires a visible session whose status is 'connected' or 'offline')
3489 $self->ivAdd('menuItemHash', 'test_panels', $menuItem_testPanels);
3490  
3491 # Setup complete
3492 return $menuColumn_display;
3493 }
3494  
3495 sub drawCommandsColumn {
3496  
3497 # Called by $self->enableMenu
3498 # Sets up the menu's 'Commands' column
3499 #
3500 # Expected arguments
3501 # (none besides $self)
3502 #
3503 # Return values
3504 # 'undef' on improper arguments, or if the menu can't be created
3505 # Otherwise returns the Gtk3::Menu created
3506  
3507 my ($self, $check) = @_;
3508  
3509 # Local variables
3510 my $mode;
3511  
3512 # Check for improper arguments
3513 if (defined $check) {
3514  
3515 return $axmud::CLIENT->writeImproper($self->_objClass . '->drawCommandsColumn', @_);
3516 }
3517  
3518 # Import IVs (for convenience)
3519 $mode = $self->winObj->pseudoCmdMode;
3520  
3521 # Set up column
3522 my $menuColumn_commands = Gtk3::Menu->new();
3523 if (! $menuColumn_commands) {
3524  
3525 return undef;
3526 }
3527  
3528 my $menuItem_repeat = Gtk3::ImageMenuItem->new('_Repeat...');
3529 my $menuImg_repeat = Gtk3::Image->new_from_stock('gtk-redo', 'menu');
3530 $menuItem_repeat->set_image($menuImg_repeat);
3531 $menuItem_repeat->signal_connect('activate' => sub {
3532  
3533 # Display a 'dialogue' window so the user can choose the command to repeat, and how
3534 # often
3535 my ($cmd, $number);
3536  
3537 # Display the dialogue
3538 ($cmd, $number) = $self->winObj->showDoubleEntryDialogue(
3539 'Repeat command',
3540 'Enter a world command to repeat',
3541 'Enter how often to repeat it',
3542 );
3543  
3544 if ($cmd && $number) {
3545  
3546 # Issue the command
3547 $self->winObj->visibleSession->pseudoCmd('repeat ' . $number . ' ' . $cmd, $mode);
3548 }
3549 });
3550 $menuColumn_commands->append($menuItem_repeat);
3551 # (Requires a visible session whose status is 'connected' or 'offline')
3552 $self->ivAdd('menuItemHash', 'repeat_cmd', $menuItem_repeat);
3553  
3554 my $menuItem_repeatSecond = Gtk3::ImageMenuItem->new('Repeat each _second...');
3555 my $menuImg_repeatSecond = Gtk3::Image->new_from_stock('gtk-redo', 'menu');
3556 $menuItem_repeatSecond->set_image($menuImg_repeatSecond);
3557 $menuItem_repeatSecond->signal_connect('activate' => sub {
3558  
3559 # Display a 'dialogue' window so the user can choose the command to repeat, and how
3560 # often
3561 my ($cmd, $number);
3562  
3563 # Display the dialogue
3564 ($cmd, $number) = $self->winObj->showDoubleEntryDialogue(
3565 'Repeat command',
3566 'Enter a world command to repeat once a second',
3567 'Enter how often to repeat it',
3568 );
3569  
3570 if ($cmd && $number) {
3571  
3572 # Issue the command
3573 $self->winObj->visibleSession->pseudoCmd(
3574 'intervalrepeat ' . $number . ' 1 ' . $cmd,
3575 $mode,
3576 );
3577 }
3578 });
3579 $menuColumn_commands->append($menuItem_repeatSecond);
3580 # (Requires a visible session whose status is 'connected' or 'offline')
3581 $self->ivAdd('menuItemHash', 'repeat_second', $menuItem_repeatSecond);
3582  
3583 my $menuItem_repeatInterval = Gtk3::ImageMenuItem->new('Repeat at _intervals...');
3584 my $menuImg_repeatInterval = Gtk3::Image->new_from_stock('gtk-redo', 'menu');
3585 $menuItem_repeatInterval->set_image($menuImg_repeatInterval);
3586 $menuItem_repeatInterval->signal_connect('activate' => sub {
3587  
3588 # Display a 'dialogue' window so the user can choose the command to repeat, and how
3589 # often
3590 my ($cmd, $number, $interval);
3591  
3592 # Display the dialogue
3593 ($cmd, $number) = $self->winObj->showDoubleEntryDialogue(
3594 'Repeat command',
3595 'Enter a world command to repeat',
3596 'Enter how often to repeat it',
3597 );
3598  
3599 if ($cmd && $number) {
3600  
3601 # Display a second dialogue to get the interval
3602 $interval = $self->winObj->showEntryDialogue(
3603 'Repeat command',
3604 'Enter an interval (in seconds) between repetitions',
3605 );
3606  
3607 if ($interval) {
3608  
3609 # Issue the command
3610 $self->winObj->visibleSession->pseudoCmd(
3611 'intervalrepeat ' . $number . ' ' . $interval . ' ' . $cmd,
3612 $mode,
3613 );
3614 }
3615 }
3616 });
3617 $menuColumn_commands->append($menuItem_repeatInterval);
3618 # (Requires a visible session whose status is 'connected' or 'offline')
3619 $self->ivAdd('menuItemHash', 'repeat_interval', $menuItem_repeatInterval);
3620  
3621 $menuColumn_commands->append(Gtk3::SeparatorMenuItem->new()); # Separator
3622  
3623 my $menuItem_cancelRepeat = Gtk3::ImageMenuItem->new('_Cancel repeating commands');
3624 my $menuImg_cancelRepeat = Gtk3::Image->new_from_stock('gtk-cancel', 'menu');
3625 $menuItem_cancelRepeat->set_image($menuImg_cancelRepeat);
3626 $menuItem_cancelRepeat->signal_connect('activate' => sub {
3627  
3628 $self->winObj->visibleSession->pseudoCmd('stopcommand', $mode);
3629 });
3630 $menuColumn_commands->append($menuItem_cancelRepeat);
3631 # (Requires a visible session whose status is 'connected' or 'offline')
3632 $self->ivAdd('menuItemHash', 'cancel_repeat', $menuItem_cancelRepeat);
3633  
3634 # Setup complete
3635 return $menuColumn_commands;
3636 }
3637  
3638 sub drawRecordingsColumn {
3639  
3640 # Called by $self->enableMenu
3641 # Sets up the menu's 'Recordings' column
3642 #
3643 # Expected arguments
3644 # (none besides $self)
3645 #
3646 # Return values
3647 # 'undef' on improper arguments, or if the menu can't be created
3648 # Otherwise returns the Gtk3::Menu created
3649  
3650 my ($self, $check) = @_;
3651  
3652 # Local variables
3653 my $mode;
3654  
3655 # Check for improper arguments
3656 if (defined $check) {
3657  
3658 return $axmud::CLIENT->writeImproper($self->_objClass . '->drawRecordingsColumn', @_);
3659 }
3660  
3661 # Import IVs (for convenience)
3662 $mode = $self->winObj->pseudoCmdMode;
3663  
3664 # Set up column
3665 my $menuColumn_recordings = Gtk3::Menu->new();
3666 if (! $menuColumn_recordings) {
3667  
3668 return undef;
3669 }
3670  
3671 my $menuItem_startStop = Gtk3::ImageMenuItem->new('_Start/stop recording');
3672 my $menuImg_startStop = Gtk3::Image->new_from_stock('gtk-media-record', 'menu');
3673 $menuItem_startStop->set_image($menuImg_startStop);
3674 $menuItem_startStop->signal_connect('activate' => sub {
3675  
3676 $self->winObj->visibleSession->pseudoCmd('record', $mode);
3677 });
3678 $menuColumn_recordings->append($menuItem_startStop);
3679 # (Requires a visible session whose status is 'connected' or 'offline', and
3680 # GA::Session->recordingPausedFlag set to FALSE)
3681 $self->ivAdd('menuItemHash', 'start_stop_recording', $menuItem_startStop);
3682  
3683 my $menuItem_pauseResume = Gtk3::ImageMenuItem->new('_Pause/resume recording');
3684 my $menuImg_pauseResume = Gtk3::Image->new_from_stock('gtk-media-pause', 'menu');
3685 $menuItem_pauseResume->set_image($menuImg_pauseResume);
3686 $menuItem_pauseResume->signal_connect('activate' => sub {
3687  
3688 $self->winObj->visibleSession->pseudoCmd('pauserecording', $mode);
3689 });
3690 $menuColumn_recordings->append($menuItem_pauseResume);
3691 # (Requires a visible session whose status is 'connected' or 'offline', and
3692 # GA::Session->recordingFlag set to TRUE)
3693 $self->ivAdd('menuItemHash', 'pause_recording', $menuItem_pauseResume);
3694  
3695 $menuColumn_recordings->append(Gtk3::SeparatorMenuItem->new()); # Separator
3696  
3697 # 'Add line' submenu
3698 my $subMenu_addLine = Gtk3::Menu->new();
3699  
3700 my $menuItem_addWorldCmd = Gtk3::MenuItem->new('Add _world command...');
3701 $menuItem_addWorldCmd->signal_connect('activate' => sub {
3702  
3703 # Display a 'dialogue' window, so the user can choose the command to add
3704 my $text = $self->winObj->showEntryDialogue(
3705 'Recording',
3706 'Enter a world command to add at this point in the recording',
3707 );
3708  
3709 if ($text) {
3710  
3711 # Add the world command
3712 $self->winObj->visibleSession->pseudoCmd(
3713 'worldcommand <' . $text . '>',
3714 $mode,
3715 );
3716 }
3717 });
3718 $subMenu_addLine->append($menuItem_addWorldCmd);
3719  
3720 my $menuItem_addClientCmd = Gtk3::MenuItem->new('Add _client command...');
3721 $menuItem_addClientCmd->signal_connect('activate' => sub {
3722  
3723 # Display a 'dialogue' window, so the user can choose the command to add
3724 my $text = $self->winObj->showEntryDialogue(
3725 'Recording',
3726 'Enter a client command to add at this point in the recording',
3727 );
3728  
3729 if ($text) {
3730  
3731 # Add the client command
3732 $self->winObj->visibleSession->pseudoCmd(
3733 'clientcommand <' . $text . '>',
3734 $mode,
3735 );
3736 }
3737 });
3738 $subMenu_addLine->append($menuItem_addClientCmd);
3739  
3740 my $menuItem_addComment = Gtk3::MenuItem->new('Add co_mment...');
3741 $menuItem_addComment->signal_connect('activate' => sub {
3742  
3743 # Display a 'dialogue' window, so the user can choose the comment to add
3744 my $text = $self->winObj->showEntryDialogue(
3745 'Recording',
3746 'Enter a comment to add at this point in the recording',
3747 );
3748  
3749 if ($text) {
3750  
3751 # Add the comment
3752 $self->winObj->visibleSession->pseudoCmd(
3753 'comment <' . $text . '>',
3754 $mode,
3755 );
3756 }
3757 });
3758 $subMenu_addLine->append($menuItem_addComment);
3759  
3760 my $menuItem_addLine = Gtk3::MenuItem->new('Add _line');
3761 $menuItem_addLine->set_submenu($subMenu_addLine);
3762 $menuColumn_recordings->append($menuItem_addLine);
3763 # (Requires a visible session whose status is 'connected' or 'offline' and a visible session
3764 # whose ->recordingFlag set to TRUE)
3765 $self->ivAdd('menuItemHash', 'recording_add_line', $menuItem_addLine);
3766  
3767 # 'Add break' submenu
3768 my $subMenu_addBreak = Gtk3::Menu->new();
3769  
3770 my $menuItem_ordinaryBreak = Gtk3::MenuItem->new('Add _ordinary break');
3771 $menuItem_ordinaryBreak->signal_connect('activate' => sub {
3772  
3773 $self->winObj->visibleSession->pseudoCmd('break', $mode);
3774 });
3775 $subMenu_addBreak->append($menuItem_ordinaryBreak);
3776  
3777 my $menuItem_triggerBreak = Gtk3::MenuItem->new('Add _trigger break...');
3778 $menuItem_triggerBreak->signal_connect('activate' => sub {
3779  
3780 # Display a 'dialogue' window, so the user can choose the trigger pattern to add
3781 my $text = $self->winObj->showEntryDialogue(
3782 'Recording',
3783 'Enter a trigger pattern to add at this point in the recording',
3784 );
3785  
3786 if ($text) {
3787  
3788 # Add the trigger break
3789 $self->winObj->visibleSession->pseudoCmd('break -t ' . $text, $mode);
3790 }
3791 });
3792 $subMenu_addBreak->append($menuItem_triggerBreak);
3793  
3794 my $menuItem_pauseBreak = Gtk3::MenuItem->new('Add _pause break...');
3795 $menuItem_pauseBreak->signal_connect('activate' => sub {
3796  
3797 # Display a 'dialogue' window, so the user can choose the pause interval to add
3798 my $text = $self->winObj->showEntryDialogue(
3799 'Recording',
3800 'Enter the length of the pause break to add at this point in the recording',
3801 );
3802  
3803 if ($text) {
3804  
3805 # Add the pause break
3806 $self->winObj->visibleSession->pseudoCmd('break -p ' . $text, $mode);
3807 }
3808 });
3809 $subMenu_addBreak->append($menuItem_pauseBreak);
3810  
3811 my $menuItem_locatorBreak = Gtk3::MenuItem->new('Add _Locator task break');
3812 $menuItem_locatorBreak->signal_connect('activate' => sub {
3813  
3814 $self->winObj->visibleSession->pseudoCmd('break -l', $mode);
3815 });
3816 $subMenu_addBreak->append($menuItem_locatorBreak);
3817  
3818 my $menuItem_addBreak = Gtk3::MenuItem->new('Add _break');
3819 $menuItem_addBreak->set_submenu($subMenu_addBreak);
3820 $menuColumn_recordings->append($menuItem_addBreak);
3821 # (Requires a visible session whose status is 'connected' or 'offline' and a visible session
3822 # whose ->recordingFlag set to TRUE)
3823 $self->ivAdd('menuItemHash', 'recording_add_break', $menuItem_addBreak);
3824  
3825 $menuColumn_recordings->append(Gtk3::SeparatorMenuItem->new()); # Separator
3826  
3827 my $menuItem_insertPoint = Gtk3::MenuItem->new('Set _insertion point...');
3828 $menuItem_insertPoint->signal_connect('activate' => sub {
3829  
3830 # Display a 'dialogue' window, so the user can choose the insertion point
3831 my $text = $self->winObj->showEntryDialogue(
3832 'Recording',
3833 'Enter the line number at which to continue the recording',
3834 );
3835  
3836 if ($text) {
3837  
3838 # Set the insertion point
3839 $self->winObj->visibleSession->pseudoCmd('insertrecording ' . $text, $mode);
3840 }
3841 });
3842 $menuColumn_recordings->append($menuItem_insertPoint);
3843 # (Requires a visible session whose status is 'connected' or 'offline' and a visible session
3844 # whose ->recordingFlag set to TRUE)
3845 $self->ivAdd('menuItemHash', 'recording_set_insertion', $menuItem_insertPoint);
3846  
3847 my $menuItem_cancelInsert = Gtk3::MenuItem->new('_Cancel insertion point');
3848 $menuItem_cancelInsert->signal_connect('activate' => sub {
3849  
3850 $self->winObj->visibleSession->pseudoCmd('insertrecording', $mode);
3851 });
3852 $menuColumn_recordings->append($menuItem_cancelInsert);
3853 # (Requires a visible session whose status is 'connected' or 'offline' and a visible session
3854 # whose ->recordingFlag set to TRUE)
3855 $self->ivAdd('menuItemHash', 'recording_cancel_insertion', $menuItem_cancelInsert);
3856  
3857 $menuColumn_recordings->append(Gtk3::SeparatorMenuItem->new()); # Separator
3858  
3859 my $menuItem_deleteLine = Gtk3::MenuItem->new('_Delete line...');
3860 $menuItem_deleteLine->signal_connect('activate' => sub {
3861  
3862 # Display a 'dialogue' window, so the user can choose the line to delete
3863 my $text = $self->winObj->showEntryDialogue(
3864 'Recording',
3865 'Enter the number of the line to delete',
3866 );
3867  
3868 if ($text) {
3869  
3870 # Delete the line
3871 $self->winObj->visibleSession->pseudoCmd('deleterecording ' . $text, $mode);
3872 }
3873 });
3874 $menuColumn_recordings->append($menuItem_deleteLine);
3875 # (Requires a visible session whose status is 'connected' or 'offline' and a visible session
3876 # whose ->recordingFlag set to TRUE)
3877 $self->ivAdd('menuItemHash', 'recording_delete_line', $menuItem_deleteLine);
3878  
3879 my $menuItem_deleteMulti = Gtk3::MenuItem->new('D_elete lines...');
3880 $menuItem_deleteMulti->signal_connect('activate' => sub {
3881  
3882 # Display a 'dialogue' window, so the user can choose the lines to delete
3883 my ($start, $stop) = $self->winObj->showDoubleEntryDialogue(
3884 'Recording',
3885 'Enter the number of the first line to be deleted',
3886 'Enter the number of the last line to be deleted',
3887 );
3888  
3889 if (defined $start && defined $stop) {
3890  
3891 # Delete the line
3892 $self->winObj->visibleSession->pseudoCmd(
3893 'deleterecording ' . $start . ' ' . $stop,
3894 $mode,
3895 );
3896 }
3897 });
3898 $menuColumn_recordings->append($menuItem_deleteMulti);
3899 # (Requires a visible session whose status is 'connected' or 'offline' and a visible session
3900 # whose ->recordingFlag set to TRUE)
3901 $self->ivAdd('menuItemHash', 'recording_delete_multi', $menuItem_deleteMulti);
3902  
3903 my $menuItem_deleteLast = Gtk3::MenuItem->new('Delete l_ast line');
3904 $menuItem_deleteLast->signal_connect('activate' => sub {
3905  
3906 $self->winObj->visibleSession->pseudoCmd('deleterecording', $mode);
3907  
3908 });
3909 $menuColumn_recordings->append($menuItem_deleteLast);
3910 # (Requires a visible session whose status is 'connected' or 'offline' and a visible session
3911 # whose ->recordingFlag set to TRUE)
3912 $self->ivAdd('menuItemHash', 'recording_delete_last', $menuItem_deleteLast);
3913  
3914 $menuColumn_recordings->append(Gtk3::SeparatorMenuItem->new()); # Separator
3915  
3916 my $menuItem_showRecording = Gtk3::MenuItem->new('S_how recording');
3917 $menuItem_showRecording->signal_connect('activate' => sub {
3918  
3919 $self->winObj->visibleSession->pseudoCmd('listrecording', $mode);
3920 });
3921 $menuColumn_recordings->append($menuItem_showRecording);
3922 # (Requires a visible session whose status is 'connected' or 'offline' and a visible session
3923 # whose ->recordingFlag set to TRUE or whose ->recordingList is not empty)
3924 $self->ivAdd('menuItemHash', 'show_recording', $menuItem_showRecording);
3925  
3926 my $menuItem_copyRecording = Gtk3::MenuItem->new('C_opy recording');
3927 $menuItem_copyRecording->signal_connect('activate' => sub {
3928  
3929 $self->winObj->visibleSession->pseudoCmd('copyrecording', $mode);
3930 });
3931 $menuColumn_recordings->append($menuItem_copyRecording);
3932 # (Requires a visible session whose status is 'connected' or 'offline' and a visible session
3933 # whose ->recordingFlag set to TRUE or whose ->recordingList is not empty)
3934 $self->ivAdd('menuItemHash', 'copy_recording', $menuItem_copyRecording);
3935  
3936 # Setup complete
3937 return $menuColumn_recordings;
3938 }
3939  
3940 sub drawAxbasicColumn {
3941  
3942 # Called by $self->enableMenu
3943 # Sets up the menu's 'Axbasic' column
3944 #
3945 # Expected arguments
3946 # (none besides $self)
3947 #
3948 # Return values
3949 # 'undef' on improper arguments, or if the menu can't be created
3950 # Otherwise returns the Gtk3::Menu created
3951  
3952 my ($self, $check) = @_;
3953  
3954 # Local variables
3955 my $mode;
3956  
3957 # Check for improper arguments
3958 if (defined $check) {
3959  
3960 return $axmud::CLIENT->writeImproper($self->_objClass . '->drawAxbasicColumn', @_);
3961 }
3962  
3963 # Import IVs (for convenience)
3964 $mode = $self->winObj->pseudoCmdMode;
3965  
3966 # Set up column
3967 my $menuColumn_basic = Gtk3::Menu->new();
3968 if (! $menuColumn_basic) {
3969  
3970 return undef;
3971 }
3972  
3973 my $menuItem_runScript = Gtk3::ImageMenuItem->new('_Run script...');
3974 my $menuImg_runScript = Gtk3::Image->new_from_stock('gtk-execute', 'menu');
3975 $menuItem_runScript->set_image($menuImg_runScript);
3976 $menuItem_runScript->signal_connect('activate' => sub {
3977  
3978 # Display a 'dialogue' window, so the user can choose the script to run
3979 my $text = $self->winObj->showEntryDialogue(
3980 'Run ' . $axmud::BASIC_NAME . ' script',
3981 'Enter the script to run (e.g. \'wumpus\')',
3982 );
3983  
3984 if ($text) {
3985  
3986 # Run the script
3987 $self->winObj->visibleSession->pseudoCmd('runscript ' . $text, $mode);
3988 }
3989 });
3990 $menuColumn_basic->append($menuItem_runScript);
3991 # (Requires a visible session whose status is 'connected' or 'offline')
3992 $self->ivAdd('menuItemHash', 'run_script', $menuItem_runScript);
3993  
3994 my $menuItem_runScriptTask = Gtk3::ImageMenuItem->new('Run script as _task...');
3995 my $menuImg_runScriptTask = Gtk3::Image->new_from_stock('gtk-execute', 'menu');
3996 $menuItem_runScriptTask->set_image($menuImg_runScriptTask);
3997 $menuItem_runScriptTask->signal_connect('activate' => sub {
3998  
3999 # Display a 'dialogue' window, so the user can choose the script to run
4000 my $text = $self->winObj->showEntryDialogue(
4001 'Run ' . $axmud::BASIC_NAME . ' script',
4002 'Enter the script to run as a task (e.g. \'wumpus\')',
4003 );
4004  
4005 if ($text) {
4006  
4007 # Run the script as a task
4008 $self->winObj->visibleSession->pseudoCmd('runscripttask ' . $text, $mode);
4009 }
4010 });
4011 $menuColumn_basic->append($menuItem_runScriptTask);
4012 # (Requires a visible session whose status is 'connected' or 'offline')
4013 $self->ivAdd('menuItemHash', 'run_script_task', $menuItem_runScriptTask);
4014  
4015 $menuColumn_basic->append(Gtk3::SeparatorMenuItem->new()); # Separator
4016  
4017 my $menuItem_checkScript = Gtk3::MenuItem->new('_Check script...');
4018 $menuItem_checkScript->signal_connect('activate' => sub {
4019  
4020 # Display a 'dialogue' window, so the user can choose the script to check
4021 my $text = $self->winObj->showEntryDialogue(
4022 'Check ' . $axmud::BASIC_NAME . ' script',
4023 'Enter the script to check (e.g. \'wumpus\')',
4024 );
4025  
4026 if ($text) {
4027  
4028 # Check the script
4029 $self->winObj->visibleSession->pseudoCmd('checkscript ' . $text, $mode);
4030 }
4031 });
4032 $menuColumn_basic->append($menuItem_checkScript);
4033 # (Requires a visible session)
4034 $self->ivAdd('menuItemHash', 'check_script', $menuItem_checkScript);
4035  
4036 my $menuItem_editScript = Gtk3::ImageMenuItem->new('_Edit script...');
4037 my $menuImg_editScript = Gtk3::Image->new_from_stock('gtk-edit', 'menu');
4038 $menuItem_editScript->set_image($menuImg_editScript);
4039 $menuItem_editScript->signal_connect('activate' => sub {
4040  
4041 # Display a 'dialogue' window, so the user can choose the script to check
4042 my $text = $self->winObj->showEntryDialogue(
4043 'Edit ' . $axmud::BASIC_NAME . ' script',
4044 'Enter the script to edit (e.g. \'wumpus\')',
4045 );
4046  
4047 if ($text) {
4048  
4049 # Edit the script
4050 $self->winObj->visibleSession->pseudoCmd('editscript ' . $text, $mode);
4051 }
4052 });
4053 $menuColumn_basic->append($menuItem_editScript);
4054 # (Requires a visible session)
4055 $self->ivAdd('menuItemHash', 'edit_script', $menuItem_editScript);
4056  
4057 # Setup complete
4058 return $menuColumn_basic;
4059 }
4060  
4061 sub drawPluginsColumn {
4062  
4063 # Called by $self->enableMenu
4064 # Sets up the menu's 'Plugins' column
4065 #
4066 # Expected arguments
4067 # (none besides $self)
4068 #
4069 # Return values
4070 # 'undef' on improper arguments, or if the menu can't be created
4071 # Otherwise returns the Gtk3::Menu created
4072  
4073 my ($self, $check) = @_;
4074  
4075 # Local variables
4076 my $mode;
4077  
4078 # Check for improper arguments
4079 if (defined $check) {
4080  
4081 return $axmud::CLIENT->writeImproper($self->_objClass . '->drawPluginsColumn', @_);
4082 }
4083  
4084 # Import IVs (for convenience)
4085 $mode = $self->winObj->pseudoCmdMode;
4086  
4087 # Set up column
4088 my $menuColumn_plugins = Gtk3::Menu->new();
4089 if (! $menuColumn_plugins) {
4090  
4091 return undef;
4092 }
4093  
4094 my $menuItem_loadPlugin = Gtk3::ImageMenuItem->new('_Load plugin...');
4095 my $menuImg_loadPlugin = Gtk3::Image->new_from_stock('gtk-open', 'menu');
4096 $menuItem_loadPlugin->set_image($menuImg_loadPlugin);
4097 $menuItem_loadPlugin->signal_connect('activate' => sub {
4098  
4099 # Load the plugin
4100 $self->winObj->visibleSession->pseudoCmd('loadplugin', $mode);
4101 });
4102 $menuColumn_plugins->append($menuItem_loadPlugin);
4103 # (Requires a visible session)
4104 $self->ivAdd('menuItemHash', 'load_plugin', $menuItem_loadPlugin);
4105  
4106 my $menuItem_showPlugins = Gtk3::MenuItem->new('_Show plugins...');
4107 $menuItem_showPlugins->signal_connect('activate' => sub {
4108  
4109 # Open the client preference window at the right page
4110 my $prefWin = $self->winObj->createFreeWin(
4111 'Games::Axmud::PrefWin::Client',
4112 $self->winObj,
4113 $self->winObj->visibleSession,
4114 'Client preferences',
4115 );
4116  
4117 if ($prefWin) {
4118  
4119 $prefWin->notebook->set_current_page(2);
4120 }
4121 });
4122 $menuColumn_plugins->append($menuItem_showPlugins);
4123 # (Requires a visible session)
4124 $self->ivAdd('menuItemHash', 'show_plugin', $menuItem_showPlugins);
4125  
4126 # Setup complete
4127 return $menuColumn_plugins;
4128 }
4129  
4130 sub drawHelpColumn {
4131  
4132 # Called by $self->enableMenu
4133 # Sets up the menu's 'Help' column
4134 #
4135 # Expected arguments
4136 # (none besides $self)
4137 #
4138 # Return values
4139 # 'undef' on improper arguments, or if the menu can't be created
4140 # Otherwise returns the Gtk3::Menu created
4141  
4142 my ($self, $check) = @_;
4143  
4144 # Local variables
4145 my $mode;
4146  
4147 # Check for improper arguments
4148 if (defined $check) {
4149  
4150 return $axmud::CLIENT->writeImproper($self->_objClass . '->drawHelpColumn', @_);
4151 }
4152  
4153 # Import IVs (for convenience)
4154 $mode = $self->winObj->pseudoCmdMode;
4155  
4156 # Set up column
4157 my $menuColumn_help = Gtk3::Menu->new();
4158 if (! $menuColumn_help) {
4159  
4160 return undef;
4161 }
4162  
4163 my $menuItem_help = Gtk3::ImageMenuItem->new('_Help...');
4164 my $menuImg_help = Gtk3::Image->new_from_stock('gtk-help', 'menu');
4165 $menuItem_help->set_image($menuImg_help);
4166 $menuItem_help->signal_connect('activate' => sub {
4167  
4168 # Check that the About window isn't already open
4169 if ($axmud::CLIENT->aboutWin) {
4170  
4171 # Only one About window can be open at a time
4172 $axmud::CLIENT->aboutWin->restoreFocus();
4173 # Open it at the right page
4174 $axmud::CLIENT->aboutWin->notebook->set_current_page(2);
4175  
4176 } else {
4177  
4178 # Open the About window
4179 my $winObj = $self->winObj->quickFreeWin(
4180 'Games::Axmud::OtherWin::About',
4181 $self->winObj->visibleSession,
4182 # Config
4183 'first_tab' => 'help',
4184 );
4185  
4186 if ($winObj) {
4187  
4188 $axmud::CLIENT->set_aboutWin($winObj);
4189 }
4190 }
4191 });
4192 $menuColumn_help->append($menuItem_help);
4193 # (Desensitised only when the setup wizwin is open)
4194 $self->ivAdd('menuItemHash', 'help', $menuItem_help);
4195  
4196 $menuColumn_help->append(Gtk3::SeparatorMenuItem->new()); # Separator
4197  
4198 my $menuItem_about = Gtk3::ImageMenuItem->new('_About...');
4199 my $menuImg_about = Gtk3::Image->new_from_stock('gtk-about', 'menu');
4200 $menuItem_about->set_image($menuImg_about);
4201 $menuItem_about->signal_connect('activate' => sub {
4202  
4203 # Check that the About window isn't already open
4204 if ($axmud::CLIENT->aboutWin) {
4205  
4206 # Window already open; draw attention to the fact by 'present'ing it
4207 $axmud::CLIENT->aboutWin->restoreFocus();
4208 # Open it at the right page
4209 $axmud::CLIENT->aboutWin->notebook->set_current_page(0);
4210  
4211 } else {
4212  
4213 # Open the About window
4214 my $winObj = $self->winObj->quickFreeWin(
4215 'Games::Axmud::OtherWin::About',
4216 $self->winObj->visibleSession,
4217 # Config
4218 'first_tab' => 'about',
4219 );
4220  
4221 if ($winObj) {
4222  
4223 # Only one About window can be open at a time
4224 $axmud::CLIENT->set_aboutWin($winObj);
4225 }
4226 }
4227 });
4228 $menuColumn_help->append($menuItem_about);
4229 # (Desensitised only when the setup wizwin is open)
4230 $self->ivAdd('menuItemHash', 'about', $menuItem_about);
4231  
4232 my $menuItem_credits = Gtk3::MenuItem->new('_Credits...');
4233 $menuItem_credits->signal_connect('activate' => sub {
4234  
4235 # Check that the About window isn't already open
4236 if ($axmud::CLIENT->aboutWin) {
4237  
4238 # Window already open; draw attention to the fact by 'present'ing it
4239 $axmud::CLIENT->aboutWin->restoreFocus();
4240 # Open it at the right page
4241 $axmud::CLIENT->aboutWin->notebook->set_current_page(1);
4242  
4243 } else {
4244  
4245 # Open the About window
4246 my $winObj = $self->winObj->quickFreeWin(
4247 'Games::Axmud::OtherWin::About',
4248 $self->winObj->visibleSession,
4249 # Config
4250 'first_tab' => 'credits',
4251 );
4252  
4253 if ($winObj) {
4254  
4255 # Only one About window can be open at a time
4256 $axmud::CLIENT->set_aboutWin($winObj);
4257 }
4258 }
4259 });
4260 $menuColumn_help->append($menuItem_credits);
4261 # (Desensitised only when the setup wizwin is open)
4262 $self->ivAdd('menuItemHash', 'credits', $menuItem_credits);
4263  
4264 my $menuItem_license = Gtk3::MenuItem->new('_Licenses...');
4265 $menuItem_license->signal_connect('activate' => sub {
4266  
4267 # Check that the About window isn't already open
4268 if ($axmud::CLIENT->aboutWin) {
4269  
4270 # Window already open; draw attention to the fact by 'present'ing it
4271 $axmud::CLIENT->aboutWin->restoreFocus();
4272 # Open it at the right page
4273 $axmud::CLIENT->aboutWin->notebook->set_current_page(3);
4274  
4275 } else {
4276  
4277 # Open the About window
4278 my $winObj = $self->winObj->quickFreeWin(
4279 'Games::Axmud::OtherWin::About',
4280 $self->winObj->visibleSession,
4281 # Config
4282 'first_tab' => 'license',
4283 );
4284  
4285 if ($winObj) {
4286  
4287 # Only one About window can be open at a time
4288 $axmud::CLIENT->set_aboutWin($winObj);
4289 }
4290 }
4291 });
4292 $menuColumn_help->append($menuItem_license);
4293 # (Desensitised only when the setup wizwin is open)
4294 $self->ivAdd('menuItemHash', 'license', $menuItem_license);
4295  
4296 $menuColumn_help->append(Gtk3::SeparatorMenuItem->new()); # Separator
4297  
4298 my $menuItem_website = Gtk3::MenuItem->new($axmud::SCRIPT . ' _website...');
4299 $menuItem_website->signal_connect('activate' => sub {
4300  
4301 $axmud::CLIENT->openURL($axmud::URL);
4302 });
4303 $menuColumn_help->append($menuItem_website);
4304 # (Requires GA::Client->browserCmd)
4305 $self->ivAdd('menuItemHash', 'go_website', $menuItem_website);
4306  
4307 # Setup complete
4308 return $menuColumn_help;
4309 }
4310  
4311 sub addPluginWidgets {
4312  
4313 # Called by GA::Client->addPluginMenus to add a sub-menu in the 'plugins' column, for the
4314 # benefit of a loaded plugin
4315 # Also called by $self->objEnable to add plugin sub-menus for 'internal' windows that are
4316 # created after the plugins are loaded
4317 #
4318 # Expected arguments
4319 # $plugin - The plugin name
4320 #
4321 # Return values
4322 # 'undef' on improper arguments
4323 # Otherwise, returns the sub-menu to which the plugin's code can add new menu items
4324  
4325 my ($self, $plugin, $check) = @_;
4326  
4327 # Check for improper arguments
4328 if (! defined $plugin || defined $check) {
4329  
4330 return $axmud::CLIENT->writeImproper($self->_objClass . '->addPluginWidgets', @_);
4331 }
4332  
4333 # Create a sub-menu for this plugin. If this is the first plugin to add menu items, add a
4334 # separator
4335 if (! $self->pluginHash) {
4336  
4337 $self->pluginMenu->append(Gtk3::SeparatorMenuItem->new());
4338 }
4339  
4340 # Add a sub-menu
4341 my $subMenu = Gtk3::Menu->new();
4342  
4343 my $menuItem = Gtk3::MenuItem->new('_' . $plugin . ' plugin');
4344 $menuItem->set_submenu($subMenu);
4345 $self->pluginMenu->append($menuItem);
4346  
4347 # Update IVs
4348 $self->ivAdd('pluginHash', $plugin, $subMenu);
4349 $self->ivAdd('pluginMenuItemHash', $plugin, $menuItem);
4350  
4351 return $subMenu;
4352 }
4353  
4354 sub sensitiseWidgets {
4355  
4356 # Can be called by anything, but usually called by GA::Win::Internal->restrictMenuBars
4357 # Given a list of Gtk3 widgets (all of them menu bar items), sets them as sensitive
4358 #
4359 # Expected arguments
4360 # (none besides $self)
4361 #
4362 # Optional arguments
4363 # @widgetList - A list of widget names, matching keys in $self->menuItemHash
4364 # (e.g. 'move_up_level')
4365 #
4366 # Return values
4367 # 1
4368  
4369 my ($self, @widgetList) = @_;
4370  
4371 # (No improper arguments to check)
4372  
4373 foreach my $widgetName (@widgetList) {
4374  
4375 my $widget = $self->ivShow('menuItemHash', $widgetName);
4376 if ($widget) {
4377  
4378 $widget->set_sensitive(TRUE);
4379 }
4380 }
4381  
4382 return 1;
4383 }
4384  
4385 sub desensitiseWidgets {
4386  
4387 # Can be called by anything, but usually called by GA::Win::Internal->restrictMenuBars
4388 # Given a list of Gtk3 widgets (all of them menu bar items), sets them as insensitive
4389 #
4390 # Expected arguments
4391 # (none besides $self)
4392 #
4393 # Optional arguments
4394 # @widgetList - A list of widget names, matching keys in $self->menuItemHash
4395 # (e.g. 'move_up_level')
4396 #
4397 # Return values
4398 # 1
4399  
4400 my ($self, @widgetList) = @_;
4401  
4402 # (No improper arguments to check)
4403  
4404 foreach my $widgetName (@widgetList) {
4405  
4406 my $widget = $self->ivShow('menuItemHash', $widgetName);
4407 if ($widget) {
4408  
4409 $widget->set_sensitive(FALSE);
4410 }
4411 }
4412  
4413 return 1;
4414 }
4415  
4416 # Menu bar support functions
4417  
4418 sub promptUser {
4419  
4420 # Called by most menu items in $self->drawWorldColumn
4421 # Before doing an action that will lead to the current connection being closed (e.g. 'Stop
4422 # client', which runs the ';stopclient' command), prompt the user for confirmation
4423 # We don't want the user to lose their connection after accidentally clicking on a menu
4424 # item; at the same time, we usually don't ask for confirmation when the user types the
4425 # equivalent client command, because they are much less likely to make a mistake while
4426 # typing, than while clicking
4427 #
4428 # Expected arguments
4429 # $title - The 'dialogue' window title
4430 # $msg - A message to display in the 'dialogue' window
4431 #
4432 # Return values
4433 # 'undef' on improper arguments or if the user clicks 'No' in the 'dialogue' window (or
4434 # closes it without clicking 'Yes'
4435 # 1 if the user clicks on 'Yes' in the 'dialogue' window
4436  
4437 my ($self, $title, $msg, $check) = @_;
4438  
4439 # Local variables
4440 my $choice;
4441  
4442 # Check for improper arguments
4443 if (! defined $title || ! defined $msg || defined $check) {
4444  
4445 return $axmud::CLIENT->writeImproper($self->_objClass . '->promptUser', @_);
4446 }
4447  
4448 # Prompt the user
4449 $choice = $self->winObj->showMsgDialogue(
4450 $title,
4451 'question',
4452 $msg,
4453 'yes-no',
4454 );
4455  
4456 if ($choice eq 'yes') {
4457 return 1;
4458 } else {
4459 return undef;
4460 }
4461 }
4462  
4463 sub getWorldList {
4464  
4465 # Called by $self->drawFileColumn
4466 # Compiles an ordered list of world profile names, with the visible session's current world
4467 # as the first item in the list
4468 #
4469 # Expected arguments
4470 # (none besides $self)
4471 #
4472 # Return values
4473 # An empty list on improper arguments
4474 # Otherwise, the sorted list of world profile names
4475  
4476 my ($self, $check) = @_;
4477  
4478 # Local variables
4479 my (@emptyList, @worldList);
4480  
4481 # Check for improper arguments
4482 if (defined $check) {
4483  
4484 $axmud::CLIENT->writeImproper($self->_objClass . '->getWorldList', @_);
4485 return @emptyList;
4486 }
4487  
4488 foreach my $profObj ($axmud::CLIENT->ivValues('worldProfHash')) {
4489  
4490 if ($profObj ne $self->winObj->visibleSession->currentWorld) {
4491  
4492 push (@worldList, $profObj->name);
4493 }
4494 }
4495  
4496 # Now sort the list alphabetically, but put the current world (if any) at the top
4497 @worldList = sort {lc($a) cmp lc($b)} (@worldList);
4498 unshift (@worldList, $self->winObj->visibleSession->currentWorld->name);
4499  
4500 # Operation complete
4501 return @worldList;
4502 }
4503  
4504 sub getOtherProfList {
4505  
4506 # Called by $self->drawFileColumn
4507 # Compiles an ordered list of non-world profile names
4508 #
4509 # Expected arguments
4510 # (none besides $self)
4511 #
4512 # Return values
4513 # An empty list on improper arguments
4514 # Otherwise, the sorted list of non-world profile names
4515  
4516 my ($self, $check) = @_;
4517  
4518 # Local variables
4519 my (@emptyList, @profList);
4520  
4521 # Check for improper arguments
4522 if (defined $check) {
4523  
4524 $axmud::CLIENT->writeImproper($self->_objClass . '->getOtherProfList', @_);
4525 return @emptyList;
4526 }
4527  
4528 foreach my $profObj ($self->winObj->visibleSession->ivValues('profHash')) {
4529  
4530 if ($profObj->category ne 'world') {
4531  
4532 push (@profList, $profObj->name);
4533 }
4534 }
4535  
4536 # Now sort the list alphabetically
4537 @profList = sort {lc($a) cmp lc($b)} (@profList);
4538  
4539 # Operation complete
4540 return @profList;
4541 }
4542  
4543 sub getDictList {
4544  
4545 # Called by $self->drawFileColumn
4546 # Compiles an ordered list of dictionary names, with the current dictionary the first item
4547 # on the list
4548 #
4549 # Expected arguments
4550 # (none besides $self)
4551 #
4552 # Return values
4553 # An empty list on improper arguments
4554 # Otherwise, the sorted list of dictionary names
4555  
4556 my ($self, $check) = @_;
4557  
4558 # Local variables
4559 my (@emptyList, @dictList);
4560  
4561 # Check for improper arguments
4562 if (defined $check) {
4563  
4564 $axmud::CLIENT->writeImproper($self->_objClass . '->getDictList', @_);
4565 return @emptyList;
4566 }
4567  
4568 foreach my $dictName ($axmud::CLIENT->ivKeys('dictHash')) {
4569  
4570 if ($dictName ne $self->winObj->visibleSession->currentDict->name) {
4571  
4572 push (@dictList, $dictName);
4573 }
4574 }
4575  
4576 # Now sort the list alphabetically, and insert the current dictionary at the top of the list
4577 @dictList = sort {lc($a) cmp lc($b)} (@dictList);
4578 unshift (@dictList, $self->winObj->visibleSession->currentDict->name);
4579  
4580 # Operation complete
4581 return @dictList;
4582 }
4583  
4584 sub getFileObjList {
4585  
4586 # Called by $self->drawFileColumn
4587 # Compiles an ordered list of file object names
4588 #
4589 # Expected arguments
4590 # (none besides $self)
4591 #
4592 # Return values
4593 # An empty list on improper arguments
4594 # Otherwise, returns a list in the form (list_reference, hash_reference):
4595 # 'list_reference' - list of items to display in a combo box, e.g.
4596 # 'deathmud (worldprof)'
4597 # 'hash_reference' - hash in which each key is an item in 'list_reference', and
4598 # the corresponding value is the name of the file object
4599 # Otherwise, the sorted list of file object names
4600  
4601 my ($self, $check) = @_;
4602  
4603 # Local variables
4604 my (
4605 @emptyList, @list, @sortedList,
4606 %regHash, %checkHash, %returnHash,
4607 );
4608  
4609 # Check for improper arguments
4610 if (defined $check) {
4611  
4612 $axmud::CLIENT->writeImproper($self->_objClass . '->getDictList', @_);
4613 return @emptyList;
4614 }
4615  
4616 # Get a list of client file objects, and sort them alphabetically
4617 %regHash = $axmud::CLIENT->fileObjHash;
4618 @list = sort {
4619 if ($a->fileType ne $b->fileType) {
4620 $a->fileType cmp $b->fileType
4621 } else {
4622 lc($a->name) cmp lc($b->name)
4623 }
4624 } (values %regHash);
4625  
4626 foreach my $obj (@list) {
4627  
4628 my $string;
4629  
4630 if ($obj->fileType eq 'worldprof') {
4631 $string = $obj->name . ' (type: worldprof)';
4632 } else {
4633 $string = $obj->name;
4634 }
4635  
4636 # Don't add the same file object more than once
4637 if (! exists $checkHash{$obj}) {
4638  
4639 push (@sortedList, $string);
4640 $returnHash{$string} = $obj;
4641 $checkHash{$obj} = undef;
4642 }
4643 }
4644  
4645 # Get a list of session file objects, and sort them alphabetically
4646 %regHash = $self->winObj->visibleSession->sessionFileObjHash;
4647 @list = sort {lc($a->name) cmp lc($b->name)} (values %regHash);
4648  
4649 foreach my $obj (@list) {
4650  
4651 my $string = $obj->name . ' (parent: ' . $obj->assocWorldProf . ')';
4652  
4653 # Don't add the same file object more than once
4654 if (! exists $checkHash{$obj}) {
4655  
4656 push (@sortedList, $string);
4657 $returnHash{$string} = $obj->name;
4658 $checkHash{$obj} = undef;
4659 }
4660 }
4661  
4662 # Operation complete
4663 return (\@sortedList, \%returnHash);
4664 }
4665  
4666 ##################
4667 # Accessors - set
4668  
4669 ##################
4670 # Accessors - get
4671  
4672 sub menuBar
4673 { $_[0]->{menuBar} }
4674  
4675 sub menuItemHash
4676 { my $self = shift; return %{$self->{menuItemHash}}; }
4677  
4678 sub pluginMenu
4679 { $_[0]->{pluginMenu} }
4680 sub pluginHash
4681 { my $self = shift; return %{$self->{pluginHash}}; }
4682 sub pluginMenuItemHash
4683 { my $self = shift; return %{$self->{pluginMenuItemHash}}; }
4684  
4685 sub saveAllSessionsFlag
4686 { $_[0]->{saveAllSessionsFlag} }
4687 }
4688  
4689 { package Games::Axmud::Strip::Toolbar;
4690  
4691 use strict;
4692 use warnings;
4693 use diagnostics;
4694  
4695 use Glib qw(TRUE FALSE);
4696  
4697 our @ISA = qw(Games::Axmud::Generic::Strip Games::Axmud);
4698  
4699 ##################
4700 # Constructors
4701  
4702 sub new {
4703  
4704 # Called by GA::Win::Internal->drawWidgets or ->addStripObj
4705 # Creates the GA::Strip::Toolbar - a non-compulsory strip object containing a Gtk3::Toolbar
4706 #
4707 # Expected arguments
4708 # $number - The strip object's number within the parent window (matches
4709 # GA::Win::Internal->stripCount, or -1 for a temporary strip object
4710 # created to access its default IVs)
4711 # $winObj - The parent window object (GA::Win::Internal). 'temp' for temporary strip
4712 # objects
4713 #
4714 # Optional arguments
4715 # %initHash - A hash containing arbitrary data to use as the strip object's
4716 # initialisation settings. The strip object should use default
4717 # initialisation settings unless it can succesfully interpret one or more
4718 # of the key-value pairs in the hash, if there are any
4719 # - (This type of strip object requires no initialisation settings)
4720 #
4721 # Return values
4722 # 'undef' on improper arguments
4723 # Blessed reference to the newly-created object on success
4724  
4725 my ($class, $number, $winObj, %initHash) = @_;
4726  
4727 # Local variables
4728 my %modHash;
4729  
4730 # Check for improper arguments
4731 if (! defined $class || ! defined $number || ! defined $winObj) {
4732  
4733 return $axmud::CLIENT->writeImproper($class . '->new', @_);
4734 }
4735  
4736 # Setup
4737 my $self = {
4738 _objName => 'strip_' . $number,
4739 _objClass => $class,
4740 _parentFile => undef, # No parent file object
4741 _parentWorld => undef, # No parent file object
4742 _privFlag => TRUE, # All IVs are private
4743  
4744 # Standard strip object IVs
4745 # -------------------------
4746  
4747 # The strip object's number within the parent window (matches
4748 # GA::Win::Internal->stripCount, or -1 for a temporary strip object created to access
4749 # its default IVs)
4750 number => $number,
4751 # The type of strip object (custom strip objects should use a ->type starting with
4752 # 'custom_' to avoid clashing with future built-in strip objects)
4753 type => 'toolbar',
4754 # The parent window object (GA::Win::Internal). 'temp' for temporary strip objects
4755 winObj => $winObj,
4756  
4757 # Flag set to TRUE if the strip object is visible (has actually drawn widgets in the
4758 # window), set to FALSE if it is not visible (has drawn no widgets in the window, but
4759 # still exists in GA::Win::Internal->stripHash, etc)
4760 # The flag might be set to FALSE in strip objects like GA::Strip::GaugeBox, which might
4761 # have gauges to draw, or not, depending on current conditions. (Most strip objects
4762 # have this flag set to TRUE all the time)
4763 # If FALSE, GA::Win::Internal->drawWidgets and ->addStripObj don't draw any widgets when
4764 # called by this object's functions
4765 # NB Strip objects are created with this flag set to TRUE or FALSE, but once created,
4766 # the flag's value shouldn't be modified by anything other than
4767 # GA::Win::Internal->hideStripObj and ->revealStripObj (which in turn call
4768 # $self->set_visibleFlag)
4769 visibleFlag => TRUE,
4770 # Flag set to TRUE is the strip object should be given its share of any extra space
4771 # within the packing box (the extra space is divided equally between all children of
4772 # the box whose ->expandFlag is TRUE)
4773 expandFlag => FALSE,
4774 # Flag set to TRUE if any space given to the strip object by the 'expand' option is
4775 # actually allocated within the strip object, FALSE if it is used as padding outside
4776 # it (on both sides)
4777 fillFlag => FALSE,
4778 # Flag set to TRUE if the strip object should be packed into its window with a small
4779 # gap between strip objects to either side; FALSE if not (can be set to FALSE if the
4780 # the strip object's widgets are drawn in a way, such that a gap is not necessary,
4781 # for example in the toolbar strip object)
4782 spacingFlag => FALSE,
4783 # Flag set to TRUE if only one instance of this strip object should be added to the
4784 # parent window, set to FALSE if any number of instances can be added
4785 jealousyFlag => TRUE,
4786 # Flag set to TRUE if this strip object can be added when $axmud::BLIND_MODE_FLAG is
4787 # TRUE, FALSE if it can't be added (because it's not useful for visually-impaired
4788 # users)
4789 blindFlag => FALSE,
4790 # Flag set to TRUE if the main container widget, stored in $self->packingBox, should be
4791 # allowed to accept the focus, FALSE if not. The restriction is applied during the
4792 # call to GA::Win::Internal->drawWidgets and ->addStripObj. Even if FALSE, widgets in
4793 # the container widget can be set to accept the focus (e.g. the Gtk3::Entry in
4794 # GA::Strip::MenuBar)
4795 allowFocusFlag => FALSE,
4796  
4797 # Initialisation settings stored as a hash (see the comments above)
4798 initHash => \%modHash,
4799 # Reference to a function to call when some widget is used. This IV is set only when
4800 # required by this type of strip object. It can be set by a call to
4801 # $self->set_func() or by some setting in $self->initHash, which is applied in the
4802 # call to $self->objEnable(). To obtain a reference to an OOP method, you can use the
4803 # generic object function Games::Axmud->getMethodRef()
4804 funcRef => undef,
4805 # A value passed to ->funcRef when it is called which identifies this strip object and
4806 # its widget(s). Can be any value, including 'undef'. It can be set by a call to
4807 # $self->set_id() or by some setting in $self->initHash, which is applied in the call
4808 # to $self->objEnable()
4809 funcID => undef,
4810  
4811 # The container widget for this strip object (usually a Gtk3::HBox or Gtk3::VBox). This
4812 # widget is the one added to the window's main Gtk3::HBox or Gtk3::VBox
4813 packingBox => undef, # Gtk3::VBox
4814  
4815 # Other IVs
4816 # ---------
4817  
4818 # Widgets
4819 toolbar => undef, # Gtk3::Toolbar
4820 toolbarWidgetList => [], # Various
4821  
4822 # Toolbar buttons which will be sensitised or desensitised, depending on whether the
4823 # session is connected to a world (or if it's in 'offline' mode). Hash in the form
4824 # $requireConnectHash{'button_name'} = Gtk3_widget
4825 requireConnectHash => {},
4826 # Toolbar buttons which will be sensitised or desensitised, depending on whether there
4827 # is a visible session for this window. Hash in the form
4828 # $requireSessionHash{'button_name'} = Gtk3_widget
4829 requireSessionHash => {},
4830 };
4831  
4832 # Bless the object into existence
4833 bless $self, $class;
4834  
4835 return $self;
4836 }
4837  
4838 ##################
4839 # Methods
4840  
4841 # Standard strip object functions
4842  
4843 sub objEnable {
4844  
4845 # Called by GA::Win::Internal->drawWidgets or ->addStripObj
4846 # Sets up the strip object's widgets
4847 #
4848 # Expected arguments
4849 # $winmapObj - The winmap object (GA::Obj::Winmap) that specifies the layout of the
4850 # parent window
4851 #
4852 # Return values
4853 # 'undef' on improper arguments
4854 # 1 on success
4855  
4856 my ($self, $winmapObj, $check) = @_;
4857  
4858 # Check for improper arguments
4859 if (! defined $winmapObj || defined $check) {
4860  
4861 return $axmud::CLIENT->writeImproper($self->_objClass . '->objEnable', @_);
4862 }
4863  
4864 # Create a packing box
4865 my $vBox = Gtk3::VBox->new(FALSE, 0);
4866 $vBox->set_border_width(0);
4867  
4868 # Create a Gtk3::Toolbar
4869 my $toolbar = Gtk3::Toolbar->new();
4870 $vBox->pack_start($toolbar, TRUE, TRUE, 0);
4871  
4872 # Update IVs
4873 $self->ivPoke('packingBox', $vBox);
4874 $self->ivPoke('toolbar', $toolbar);
4875  
4876 # Draw a set of buttons and separators
4877 $self->fillToolbar();
4878  
4879 return 1;
4880 }
4881  
4882 sub objDestroy {
4883  
4884 # Called by GA::Win::Internal->removeStripObj, just before the strip is removed from its
4885 # parent window, and also by ->winDestroy and ->resetWinmap, to give this object a chance
4886 # to do any necessary tidying up
4887 #
4888 # Expected arguments
4889 # (none besides $self)
4890 #
4891 # Return values
4892 # 'undef' on improper arguments
4893 # 1 otherwise
4894  
4895 my ($self, $check) = @_;
4896  
4897 # Check for improper arguments
4898 if (defined $check) {
4899  
4900 return $axmud::CLIENT->writeImproper($self->_objClass . '->objDestroy', @_);
4901 }
4902  
4903 # (No tidying up required for this type of strip object)
4904 # ...
4905  
4906 return 1;
4907 }
4908  
4909 # sub setWidgetsIfSession {} # Inherited from GA::Generic::Strip
4910  
4911 # sub setWidgetsChangeSession {} # Inherited from GA::Generic::Strip
4912  
4913 # ->signal_connects are stored in $self->fillToolbar
4914  
4915 # Other functions
4916  
4917 sub fillToolbar {
4918  
4919 # Called by $self->objEnable and ->resetToolbar
4920 # Draws a set of toolbar buttons and separators, and adds them to the existing toolbar
4921 #
4922 # Expected arguments
4923 # (none besides $self)
4924 #
4925 # Return values
4926 # 'undef' on improper arguments
4927 # 1 otherwise
4928  
4929 my ($self, $check) = @_;
4930  
4931 # Local variables
4932 my (
4933 $winObj,
4934 @widgetList,
4935 );
4936  
4937 # Check for improper arguments
4938 if (defined $check) {
4939  
4940 return $axmud::CLIENT->writeImproper($self->_objClass . '->fillToolbar', @_);
4941 }
4942  
4943 # Each toolbar button is a GA::Obj::Toolbar object
4944 foreach my $buttonName ($axmud::CLIENT->toolbarList) {
4945  
4946 my ($separator, $buttonObj, $path, $label, $iconName, $choice);
4947  
4948 if ($buttonName eq 'separator') {
4949  
4950 # # Add a separator to the toolbar
4951 # my $separator = Gtk3::SeparatorToolItem->new();
4952 #
4953 # $self->toolbar->insert($separator, -1);
4954 # push (@widgetList, $separator);
4955  
4956 # DEBUG
4957 # Temporary fix for Gtk problems: on MSWin, don't show separators
4958 if ($^O ne 'MSWin32') {
4959  
4960 # Add a separator to the toolbar
4961 my $separator = Gtk3::SeparatorToolItem->new();
4962  
4963 $self->toolbar->insert($separator, -1);
4964 push (@widgetList, $separator);
4965 }
4966  
4967 } else {
4968  
4969 $buttonObj = $axmud::CLIENT->ivShow('toolbarHash', $buttonName);
4970  
4971 # Set the path of the icon file. If it doesn't exist, use an emergency fallback icon
4972 if ($buttonObj->customFlag) {
4973 $path = $buttonObj->iconPath;
4974 } else {
4975 $path = $axmud::SHARE_DIR . '/icons/main/' . $buttonObj->iconPath;
4976 }
4977  
4978 if (! (-e $path)) {
4979  
4980 # Spare icon
4981 $path = $axmud::SHARE_DIR . '/icons/main/drop.png';
4982 }
4983  
4984 if ($axmud::CLIENT->toolbarLabelFlag) {
4985  
4986 # Otherwise, $label remains as 'undef', which is what Gtk3::ToolButton is
4987 # expecting
4988 $label = $buttonObj->descrip;
4989 }
4990  
4991 # Create the toolbar button itself
4992 my $toolButton_item = Gtk3::ToolButton->new(
4993 Gtk3::Image->new_from_file($path),
4994 $label,
4995 );
4996 $toolButton_item->set_tooltip_text($buttonObj->descrip);
4997 $toolButton_item->signal_connect('clicked' => sub {
4998  
4999 # The icons for ';connect', ';openaboutwindow -h' and ';stopsession' are
5000 # sensitised even when there is no current session. Since we can't call
5001 # ->doInstruct, process those commands directly
5002  
5003 # Special case: prompt the user before stopping an active session (if the flag
5004 # is set)
5005 if ($buttonObj->instruct eq ';stopsession') {
5006  
5007 if ($self->winObj->visibleSession) {
5008  
5009 if (
5010 $self->winObj->visibleSession->status eq 'connected'
5011 && $axmud::CLIENT->confirmCloseToolButtonFlag
5012 ) {
5013 $choice = $self->winObj->showMsgDialogue(
5014 'Close tab',
5015 'question',
5016 'This session is connected to a world. Are you sure you want'
5017 . ' to close it?',
5018 'yes-no',
5019 );
5020  
5021 if ($choice eq 'yes') {
5022  
5023 $self->winObj->visibleSession->pseudoCmd(
5024 'stopsession',
5025 $self->winObj->pseudoCmdMode,
5026 );
5027 }
5028  
5029 } else {
5030  
5031 $self->winObj->visibleSession->pseudoCmd(
5032 'stopsession',
5033 $self->winObj->pseudoCmdMode,
5034 );
5035 }
5036  
5037 } else {
5038  
5039 # No sessions open, so terminate the client
5040 $axmud::CLIENT->stop();
5041 }
5042  
5043 # If a session is open, then we can call ->doInstruct, as normal
5044 } elsif ($self->winObj->visibleSession) {
5045  
5046 $self->winObj->visibleSession->doInstruct($buttonObj->instruct);
5047  
5048 # Process commands directly
5049 } elsif ($buttonObj->instruct eq ';connect') {
5050  
5051 # Check that the Connections window isn't already open
5052 if ($axmud::CLIENT->connectWin) {
5053  
5054 # Window already open; draw attention to the fact by 'present'ing it
5055 $axmud::CLIENT->connectWin->restoreFocus();
5056  
5057 } else {
5058  
5059 # Open the Connections window
5060 $winObj = $self->winObj->quickFreeWin(
5061 'Games::Axmud::OtherWin::Connect',
5062 $self->winObj->visibleSession,
5063 );
5064  
5065 if ($winObj) {
5066  
5067 # Only one Connections window can be open at a time
5068 $axmud::CLIENT->set_connectWin($winObj);
5069 }
5070 }
5071  
5072 } elsif ($buttonObj->instruct eq ';openaboutwindow -h') {
5073  
5074 # Check that the About window isn't already open
5075 if ($axmud::CLIENT->aboutWin) {
5076  
5077 # Window already open; draw attention to the fact by 'present'ing it
5078 $axmud::CLIENT->aboutWin->restoreFocus();
5079  
5080 } else {
5081  
5082 # Open the About window
5083 $winObj = $self->winObj->quickFreeWin(
5084 'Games::Axmud::OtherWin::About',
5085 $self->winObj->visibleSession,
5086 # Config
5087 'first_tab' => 'help',
5088 );
5089  
5090 if ($winObj) {
5091  
5092 # Only one About window can be open at a time
5093 $axmud::CLIENT->set_aboutWin($winObj);
5094 }
5095 }
5096 }
5097  
5098 # Sensitise/desensitise menu bar/toolbar items, depending on current conditions
5099 $axmud::CLIENT->desktopObj->restrictWidgets();
5100 });
5101  
5102 $iconName = 'icon_' . $buttonObj->name;
5103 if ($buttonObj->requireConnectFlag) {
5104  
5105 # (Button requires a connection to a world, even if it's in 'offline' mode)
5106 $self->ivAdd('requireConnectHash', $iconName, $toolButton_item);
5107  
5108 } elsif ($buttonObj->requireSessionFlag) {
5109  
5110 # (Button requires a current session)
5111 $self->ivAdd('requireSessionHash', $iconName, $toolButton_item);
5112  
5113 } else {
5114  
5115 # (Button always sensitised)
5116 $self->ivDelete('requireConnectHash', $iconName);
5117 $self->ivDelete('requireSessionHash', $iconName);
5118 }
5119  
5120 # Add the toolbar button to the toolbar
5121 $self->toolbar->insert($toolButton_item, -1);
5122 push (@widgetList, $toolButton_item);
5123 }
5124 }
5125  
5126 $self->toolbar->show_all();
5127  
5128 # Store the list of buttons and separators
5129 $self->ivPoke('toolbarWidgetList', @widgetList);
5130  
5131 # Sensitise/desensitise menu bar/toolbar items, depending on current conditions
5132 $axmud::CLIENT->desktopObj->restrictWidgets();
5133  
5134 # Setup complete
5135 return 1;
5136 }
5137  
5138 sub resetToolbar {
5139  
5140 # Called by GA::PrefWin::Client->toolbarTab to re-draw the list of toolbar buttons, after
5141 # the GA::Client->toolbarHash and ->toolbarList have been modified
5142 #
5143 # Expected arguments
5144 # (none besides $self)
5145 #
5146 # Return values
5147 # 'undef' on improper arguments
5148 # 1 otherwise
5149  
5150 my ($self, $check) = @_;
5151  
5152 # Check for improper arguments
5153 if (defined $check) {
5154  
5155 return $axmud::CLIENT->writeImproper($self->_objClass . '->resetToolbar', @_);
5156 }
5157  
5158 # Remove the existing buttons and separators
5159 foreach my $widget ($self->toolbarWidgetList) {
5160  
5161 $axmud::CLIENT->desktopObj->removeWidget($self->toolbar, $widget);
5162 }
5163  
5164 # Draw a new set of buttons and separators
5165 $self->fillToolbar();
5166  
5167 return 1;
5168 }
5169  
5170 sub sensitiseWidgets {
5171  
5172 # Can be called by anything, but usually called by GA::Win::Internal->restrictToolbars
5173 # Given a list of Gtk3 widgets (all of them toolbar items), sets them as sensitive
5174 #
5175 # Expected arguments
5176 # (none besides $self)
5177 #
5178 # Optional arguments
5179 # @widgetList - A list of widget names from $self->toolbarWidgetList (e.g. 'connect_me')
5180 #
5181 # Return values
5182 # 1
5183  
5184 my ($self, @widgetList) = @_;
5185  
5186 # (No improper arguments to check)
5187  
5188 foreach my $widgetName (@widgetList) {
5189  
5190 my $widget;
5191  
5192 $widget = $self->ivShow('requireConnectHash', $widgetName);
5193 if (! $widget) {
5194  
5195 $widget = $self->ivShow('requireSessionHash', $widgetName);
5196 }
5197  
5198 if ($widget) {
5199  
5200 $widget->set_sensitive(TRUE);
5201 }
5202 }
5203  
5204 return 1;
5205 }
5206  
5207 sub desensitiseWidgets {
5208  
5209 # Can be called by anything, but usually called by GA::Win::Internal->restrictToolbars
5210 # Given a list of Gtk3 widgets (all of them toolbar items), sets them as insensitive
5211 #
5212 # Expected arguments
5213 # (none besides $self)
5214 #
5215 # Optional arguments
5216 # @widgetList - A list of widget names from $self->toolbarWidgetList (e.g. 'connect_me')
5217 #
5218 # Return values
5219 # 1
5220  
5221 my ($self, @widgetList) = @_;
5222  
5223 # (No improper arguments to check)
5224  
5225 foreach my $widgetName (@widgetList) {
5226  
5227 my $widget;
5228  
5229 $widget = $self->ivShow('requireConnectHash', $widgetName);
5230 if (! $widget) {
5231  
5232 $widget = $self->ivShow('requireSessionHash', $widgetName);
5233 }
5234  
5235 if ($widget) {
5236  
5237 $widget->set_sensitive(FALSE);
5238 }
5239 }
5240  
5241 return 1;
5242 }
5243  
5244 ##################
5245 # Accessors - set
5246  
5247 ##################
5248 # Accessors - get
5249  
5250 sub toolbar
5251 { $_[0]->{toolbar} }
5252 sub toolbarWidgetList
5253 { my $self = shift; return @{$self->{toolbarWidgetList}}; }
5254  
5255 sub requireConnectHash
5256 { my $self = shift; return %{$self->{requireConnectHash}}; }
5257 sub requireSessionHash
5258 { my $self = shift; return %{$self->{requireSessionHash}}; }
5259 }
5260  
5261 { package Games::Axmud::Strip::Table;
5262  
5263 use strict;
5264 use warnings;
5265 use diagnostics;
5266  
5267 use Glib qw(TRUE FALSE);
5268  
5269 our @ISA = qw(Games::Axmud::Generic::Strip Games::Axmud);
5270  
5271 ##################
5272 # Constructors
5273  
5274 sub new {
5275  
5276 # Called by GA::Win::Internal->drawWidgets or ->addStripObj
5277 # Creates the GA::Strip::Table - a compulsory strip object containing a Gtk3::Grid, onto
5278 # which widgets can be drawn
5279 #
5280 # Expected arguments
5281 # $number - The strip object's number within the parent window (matches
5282 # GA::Win::Internal->stripCount, or -1 for a temporary strip object
5283 # created to access its default IVs)
5284 # $winObj - The parent window object (GA::Win::Internal). 'temp' for temporary strip
5285 # objects
5286 #
5287 # Optional arguments
5288 # %initHash - A hash containing arbitrary data to use as the strip object's
5289 # initialisation settings. The strip object should use default
5290 # initialisation settings unless it can succesfully interpret one or more
5291 # of the key-value pairs in the hash, if there are any
5292 #
5293 # 'spacing' - The number of pixels between table objects. If
5294 # specified, can be any integer value in the range 0-10. If not
5295 # specified, an invalid value or 'undef',
5296 # GA::Client->constMainSpacingPixels or ->constGridSpacingPixels
5297 # is used
5298 # 'border' - The number of pixels between table objects and the edge
5299 # of the table. If specified, can be any integer value in the
5300 # range 0-10. If not specified, an invalid value or 'undef', 0 is
5301 # used
5302 #
5303 # Return values
5304 # 'undef' on improper arguments
5305 # Blessed reference to the newly-created object on success
5306  
5307 my ($class, $number, $winObj, %initHash) = @_;
5308  
5309 # Local variables
5310 my (
5311 $spacing,
5312 %modHash,
5313 );
5314  
5315 # Check for improper arguments
5316 if (! defined $class || ! defined $number || ! defined $winObj) {
5317  
5318 return $axmud::CLIENT->writeImproper($class . '->new', @_);
5319 }
5320  
5321 # Default initialisation settings
5322 if ($winObj ne 'temp' && $winObj->winType eq 'main') {
5323 $spacing = $axmud::CLIENT->constMainSpacingPixels;
5324 } else {
5325 $spacing = $axmud::CLIENT->constGridSpacingPixels;
5326 }
5327  
5328 %modHash = (
5329 'spacing' => $spacing,
5330 'border' => 0,
5331 );
5332  
5333 # Interpret the initialisation settings in %initHash, if any
5334 foreach my $key (keys %modHash) {
5335  
5336 if (exists $initHash{$key}) {
5337  
5338 $modHash{$key} = $initHash{$key};
5339 }
5340 }
5341  
5342 # Setup
5343 my $self = {
5344 _objName => 'strip_' . $number,
5345 _objClass => $class,
5346 _parentFile => undef, # No parent file object
5347 _parentWorld => undef, # No parent file object
5348 _privFlag => TRUE, # All IVs are private
5349  
5350 # Standard strip object IVs
5351 # -------------------------
5352  
5353 # The strip object's number within the parent window (matches
5354 # GA::Win::Internal->stripCount, or -1 for a temporary strip object created to access
5355 # its default IVs)
5356 number => $number,
5357 # The type of strip object (custom strip objects should use a ->type starting with
5358 # 'custom_' to avoid clashing with future built-in strip objects)
5359 type => 'table',
5360 # The parent window object (GA::Win::Internal). 'temp' for temporary strip objects
5361 winObj => $winObj,
5362  
5363 # Flag set to TRUE if the strip object is visible (has actually drawn widgets in the
5364 # window), set to FALSE if it is not visible (has drawn no widgets in the window, but
5365 # still exists in GA::Win::Internal->stripHash, etc)
5366 # The flag might be set to FALSE in strip objects like GA::Strip::GaugeBox, which might
5367 # have gauges to draw, or not, depending on current conditions. (Most strip objects
5368 # have this flag set to TRUE all the time)
5369 # If FALSE, GA::Win::Internal->drawWidgets and ->addStripObj don't draw any widgets when
5370 # called by this object's functions
5371 # NB Strip objects are created with this flag set to TRUE or FALSE, but once created,
5372 # the flag's value shouldn't be modified by anything other than
5373 # GA::Win::Internal->hideStripObj and ->revealStripObj (which in turn call
5374 # $self->set_visibleFlag)
5375 visibleFlag => TRUE,
5376 # Flag set to TRUE is the strip object should be given its share of any extra space
5377 # within the packing box (the extra space is divided equally between all children of
5378 # the box whose ->expandFlag is TRUE)
5379 expandFlag => TRUE,
5380 # Flag set to TRUE if any space given to the strip object by the 'expand' option is
5381 # actually allocated within the strip object, FALSE if it is used as padding outside
5382 # it (on both sides)
5383 fillFlag => TRUE,
5384 # Flag set to TRUE if the strip object should be packed into its window with a small
5385 # gap between strip objects to either side; FALSE if not (can be set to FALSE if the
5386 # the strip object's widgets are drawn in a way, such that a gap is not necessary,
5387 # for example in the toolbar strip object)
5388 spacingFlag => TRUE,
5389 # Flag set to TRUE if only one instance of this strip object should be added to the
5390 # parent window, set to FALSE if any number of instances can be added
5391 jealousyFlag => TRUE,
5392 # Flag set to TRUE if this strip object can be added when $axmud::BLIND_MODE_FLAG is
5393 # TRUE, FALSE if it can't be added (because it's not useful for visually-impaired
5394 # users)
5395 blindFlag => TRUE,
5396 # Flag set to TRUE if the main container widget, stored in $self->packingBox, should be
5397 # allowed to accept the focus, FALSE if not. The restriction is applied during the
5398 # call to GA::Win::Internal->drawWidgets and ->addStripObj. Even if FALSE, widgets in
5399 # the container widget can be set to accept the focus (e.g. the Gtk3::Entry in
5400 # GA::Strip::MenuBar)
5401 allowFocusFlag => FALSE,
5402  
5403 # Initialisation settings stored as a hash (see the comments above)
5404 initHash => \%modHash,
5405 # Reference to a function to call when some widget is used. This IV is set only when
5406 # required by this type of strip object. It can be set by a call to
5407 # $self->set_func() or by some setting in $self->initHash, which is applied in the
5408 # call to $self->objEnable(). To obtain a reference to an OOP method, you can use the
5409 # generic object function Games::Axmud->getMethodRef()
5410 funcRef => undef,
5411 # A value passed to ->funcRef when it is called which identifies this strip object and
5412 # its widget(s). Can be any value, including 'undef'. It can be set by a call to
5413 # $self->set_id() or by some setting in $self->initHash, which is applied in the call
5414 # to $self->objEnable()
5415 funcID => undef,
5416  
5417 # The container widget for this strip object (usually a Gtk3::HBox or Gtk3::VBox). This
5418 # widget is the one added to the window's main Gtk3::HBox or Gtk3::VBox
5419 packingBox => undef, # Gtk3::ScrolledWindow
5420  
5421 # Other IVs
5422 # ---------
5423  
5424 # Gtk3 widgets to draw the table
5425 table => undef, # Gtk3::Grid
5426  
5427 # The table size actually used
5428 tableSize => undef,
5429  
5430 # Hash of tablezone objects (GA::Obj::Tablezone), each of which marks out an area of
5431 # Gtk3::Grid for a single table object. Hash in the form
5432 # $zoneHash{number} = blessed_reference_to_tablezone_object
5433 tablezoneHash => {},
5434 # Number of tablezones ever created for this Gtk3::Grid (used to give every tablezone
5435 # object a number unique to the Gtk3::Grid)
5436 tablezoneCount => 0,
5437 # Hash of table objects (inheriting from GA::Generic::Table) which occupy the space
5438 # marked out by a single tablezone. Hash in the form
5439 # $tableObjHash{number} = blessed_reference_to_table_object
5440 tableObjHash => {},
5441 # Number of table objects ever created for this Gtk3::Grid (used to give every table
5442 # object a number unique to the Gtk3::Grid)
5443 tableObjCount => 0,
5444  
5445 # The current value for spacing between table objects (actually applied as a border
5446 # around each table object; set from $self->initHash by $self->objEnable)
5447 currentSpacing => 0,
5448 # The current value for the border at the edge of the table (set from $self->initHash by
5449 # $self->objEnable)
5450 currentBorder => 0,
5451 };
5452  
5453 # Bless the object into existence
5454 bless $self, $class;
5455  
5456 return $self;
5457 }
5458  
5459 ##################
5460 # Methods
5461  
5462 # Standard strip object functions
5463  
5464 sub objEnable {
5465  
5466 # Called by GA::Win::Internal->drawWidgets or ->addStripObj
5467 # Sets up the strip object's widgets
5468 #
5469 # Expected arguments
5470 # $winmapObj - The winmap object (GA::Obj::Winmap) that specifies the layout of the
5471 # parent window
5472 #
5473 # Return values
5474 # 'undef' on improper arguments
5475 # 1 on success
5476  
5477 my ($self, $winmapObj, $check) = @_;
5478  
5479 # Local variables
5480 my ($spacing, $border);
5481  
5482 # Check for improper arguments
5483 if (! defined $winmapObj || defined $check) {
5484  
5485 return $axmud::CLIENT->writeImproper($self->_objClass . '->objEnable', @_);
5486 }
5487  
5488 # Interpret $self->initHash, replacing any invalid values
5489 $spacing = $self->ivShow('initHash', 'spacing');
5490 if (defined $spacing && $axmud::CLIENT->intCheck($spacing, 0, 10)) {
5491  
5492 $self->ivPoke('currentSpacing', $spacing);
5493 }
5494  
5495 $border = $self->ivShow('initHash', 'border');
5496 if (defined $border && $axmud::CLIENT->intCheck($border, 0, 10)) {
5497  
5498 $self->ivPoke('currentBorder', $border);
5499 }
5500  
5501 # Create a packing box (a scroller rather than a VBox/HBox, in this case)
5502 my $scroller = Gtk3::ScrolledWindow->new();
5503 $scroller->set_policy('automatic', 'automatic');
5504  
5505 # Create a Gtk3::Grid
5506 my $grid = Gtk3::Grid->new();
5507 $scroller->add_with_viewport($grid);
5508 $grid->set_border_width($border);
5509 $grid->set_column_spacing(0);
5510 $grid->set_row_spacing(0);
5511  
5512 # Update IVs
5513 $self->ivPoke('packingBox', $scroller);
5514 $self->ivPoke('table', $grid);
5515 $self->ivPoke('tableSize', $winmapObj->tableSize);
5516  
5517 return 1;
5518 }
5519  
5520 sub objDestroy {
5521  
5522 # Called by GA::Win::Internal->removeStripObj, just before the strip is removed from its
5523 # parent window, and also by ->winDestroy and ->resetWinmap, to give this object a chance
5524 # to do any necessary tidying up
5525 #
5526 # Expected arguments
5527 # (none besides $self)
5528 #
5529 # Return values
5530 # 'undef' on improper arguments
5531 # 1 otherwise
5532  
5533 my ($self, $check) = @_;
5534  
5535 # Check for improper arguments
5536 if (defined $check) {
5537  
5538 return $axmud::CLIENT->writeImproper($self->_objClass . '->objDestroy', @_);
5539 }
5540  
5541 # No tidying up required for this type of strip object, but we do call the same function for
5542 # any table objects
5543 foreach my $tableObj ($self->ivValues('tableObjHash')) {
5544  
5545 $tableObj->objDestroy();
5546 }
5547  
5548 return 1;
5549 }
5550  
5551 sub setWidgetsIfSession {
5552  
5553 # Called by GA::Win::Internal->setWidgetsIfSession
5554 # Allows this strip object to sensitise or desensitise its widgets, depending on whether
5555 # the parent window has a ->visibleSession at the moment
5556 # (NB Only 'main' windows have a ->visibleSession; for other 'grid' windows, the flag
5557 # argument will be FALSE)
5558 #
5559 # Expected arguments
5560 # $flag - TRUE if the parent window has a visible session, FALSE if not
5561 #
5562 # Return values
5563 # 'undef' on improper arguments
5564 # 1 otherwise
5565  
5566 my ($self, $flag, $check) = @_;
5567  
5568 # Check for improper arguments
5569 if (! defined $flag || defined $check) {
5570  
5571 return $axmud::CLIENT->writeImproper($self->_objClass . '->setWidgetsIfSession', @_);
5572 }
5573  
5574 # Pass on the message to every table object
5575 foreach my $tableObj ($self->ivValues('tableObjHash')) {
5576  
5577 $tableObj->setWidgetsIfSession($flag);
5578 }
5579  
5580 return 1;
5581 }
5582  
5583 sub setWidgetsChangeSession {
5584  
5585 # Called by GA::Win::Internal->setWidgetsChangeSession
5586 # Allows this strip object to update its widgets whenever the visible session in any 'main'
5587 # window changes
5588 #
5589 # Expected arguments
5590 # (none besides $self)
5591 #
5592 # Return values
5593 # 'undef' on improper arguments
5594 # 1 otherwise
5595  
5596 my ($self, $check) = @_;
5597  
5598 # Check for improper arguments
5599 if (defined $check) {
5600  
5601 return $axmud::CLIENT->writeImproper(
5602 $self->_objClass . '->setWidgetsChangeSession',
5603 @_,
5604 );
5605 }
5606  
5607 # Pass on the message to every table object
5608 foreach my $tableObj ($self->ivValues('tableObjHash')) {
5609  
5610 $tableObj->setWidgetsChangeSession();
5611 }
5612  
5613 return 1;
5614 }
5615  
5616 # ->signal_connects
5617  
5618 # Other functions
5619  
5620 sub addTableObj {
5621  
5622 # Called by GA::Win::Internal->drawWidgets or any other code
5623 # Adds a table object (inheriting GA::Generic::Table) to this strip object's Gtk3::Grid
5624 #
5625 # Expected arguments
5626 # $packageName
5627 # - The package name of the table object to add, e.g. 'Games::Axmud::Table::Pane'
5628 # $left, $right, $top, $bottom
5629 # - The coordinates of the top-left ($left, $top) and bottom-right ($right, $bottom)
5630 # corners of the table object on the table
5631 #
5632 # Optional arguments
5633 # $objName
5634 # - An optional name to give to the table object, when it is created. If not
5635 # specified, the table object's ->objName is given the same value as its ->number.
5636 # If specified, $objName can be any string (avoid using short strings or numbers.
5637 # No part of the code checks that table object names are unique; if two or more
5638 # table objects share the same ->objName, usually the one with the lowest ->number
5639 # 'wins')
5640 # %initHash
5641 # - A hash containing arbitrary data to use as the table object's initialisation
5642 # settings. The table object should use default initialisation settings unless it
5643 # can succesfully interpret one or more of the key-value pairs in the hash, if
5644 # there are any
5645 #
5646 # Return values
5647 # 'undef' on improper arguments, if the specified space on the table is invalid or already
5648 # occupied by a tablezone, or if the table object can't be created
5649 # Otherwise returns the blessed reference to the new table object
5650  
5651 my ($self, $packageName, $left, $right, $top, $bottom, $objName, %initHash) = @_;
5652  
5653 # Local variables
5654 my ($string, $zoneObj, $tableObj);
5655  
5656 # Check for improper arguments
5657 if (
5658 ! defined $packageName || ! defined $left || ! defined $right || ! defined $top
5659 || ! defined $bottom
5660 ) {
5661 return $axmud::CLIENT->writeImproper($self->_objClass . '->addTableObj', @_);
5662 }
5663  
5664 # Table objects must inherit from GA::Generic::Table and must exist (in the case of table
5665 # objects loaded from a plugin)
5666 if (
5667 ! $packageName =~ m/^Games\:\:Axmud\:\:Table\:\:/
5668 || ! $axmud::CLIENT->ivExists('customTableHash', $packageName)
5669 ) {
5670 if ($axmud::CLIENT->debugTableFitFlag) {
5671  
5672 $self->writeError(
5673 'Unrecognised table object package \'' . $packageName . '\'',
5674 $self->_objClass . '->addTableObj',
5675 )
5676 }
5677  
5678 return undef;
5679 }
5680  
5681 # Check that the specified area is not outside the bounds of the table
5682 $string = '(X ' . $left . '-' . $right . ', Y ' . $top . '-' . $bottom . ')';
5683 if (
5684 $left < 0 || $right <= $left || $right >= $self->tableSize
5685 || $top < 0 || $bottom <= $top || $bottom >= $self->tableSize
5686 ) {
5687 if ($axmud::CLIENT->debugTableFitFlag) {
5688  
5689 $self->writeError(
5690 'Specified area ' . $string . ' is outside the bounds of the table',
5691 $self->_objClass . '->addTableObj',
5692 )
5693 }
5694  
5695 return undef;
5696 }
5697  
5698 # Check that the specified area on the table is not already occupied by a tablezone
5699 foreach my $otherZoneObj ($self->ivValues('tablezoneHash')) {
5700  
5701 if (
5702 (
5703 ($left >= $otherZoneObj->left && $left <= $otherZoneObj->right)
5704 || ($right >= $otherZoneObj->left && $right <= $otherZoneObj->right)
5705 ) && (
5706 ($top >= $otherZoneObj->top && $top <= $otherZoneObj->bottom)
5707 || ($bottom >= $otherZoneObj->top && $bottom <= $otherZoneObj->bottom)
5708 )
5709 ) {
5710 if ($axmud::CLIENT->debugTableFitFlag) {
5711  
5712 $self->writeError(
5713 'Specified area ' . $string . ' is occupied by an existing table object',
5714 $self->_objClass . '->addTableObj',
5715 )
5716 }
5717  
5718 return undef;
5719 }
5720 }
5721  
5722 # Create a tablezone, which marks out an area on the Gtk3::Grid as being in use by a single
5723 # table object
5724 $zoneObj = Games::Axmud::Obj::Tablezone->new(
5725 $self->tablezoneCount,
5726 $packageName,
5727 $left,
5728 $top,
5729 $right,
5730 $bottom,
5731 );
5732  
5733 if (! $zoneObj) {
5734  
5735 if ($axmud::CLIENT->debugTableFitFlag) {
5736  
5737 $self->writeError(
5738 'Could not allocate space for the table object at the specified position '
5739 . $string,
5740 $self->_objClass . '->addTableObj',
5741 )
5742 }
5743  
5744 return undef;
5745 }
5746  
5747 # If no $objName was specified, the table object's ->objName IV is the same as its ->number
5748 # IV
5749 if (! defined $objName || $objName eq '') {
5750  
5751 $objName = $self->tableObjCount;
5752 }
5753  
5754 # Create table object
5755 $tableObj = $packageName->new($self->tableObjCount, $objName, $self, $zoneObj, %initHash);
5756 if (! $tableObj) {
5757  
5758 if ($axmud::CLIENT->debugTableFitFlag) {
5759  
5760 $self->writeError(
5761 'Failed to create table object',
5762 $self->_objClass . '->addTableObj',
5763 )
5764 }
5765  
5766 return undef;
5767 }
5768  
5769 # Set up the table object's widgets
5770 if (! $tableObj->objEnable()) {
5771  
5772 if ($axmud::CLIENT->debugTableFitFlag) {
5773  
5774 $self->writeError(
5775 'Failed to set up the table object\'s widgets',
5776 $self->_objClass . '->addTableObj',
5777 )
5778 }
5779  
5780 return undef;
5781 }
5782  
5783 $self->table->attach(
5784 $tableObj->packingBox,
5785 $zoneObj->left,
5786 $zoneObj->top,
5787 # Axmud uses 59,59, but Gtk expects 60,60
5788 ($zoneObj->right - $zoneObj->left + 1),
5789 ($zoneObj->bottom - $zoneObj->top + 1),
5790 );
5791  
5792 # Update IVs
5793 $self->ivAdd('tablezoneHash', $zoneObj->number, $zoneObj);
5794 $self->ivIncrement('tablezoneCount');
5795 $self->ivAdd('tableObjHash', $tableObj->number, $tableObj);
5796 $self->ivIncrement('tableObjCount');
5797  
5798 # Cannot call $self->table->set_column_spacing(), etc, as that would add spacing to all
5799 # 60 columns (etc). Instead, add a border area around the table widget
5800 # In certain circumstances, approve the aesthetics by not using a border at all
5801 if (
5802 $self->ivPairs('tableObjHash') < 2
5803 && (
5804 $self->winObj->winType eq 'main'
5805 || $self->winObj->ivPairs('stripHash') < 2
5806 )
5807 ) {
5808 $tableObj->packingBox->set_border_width(0);
5809 } else {
5810 $tableObj->packingBox->set_border_width($self->currentSpacing);
5811 }
5812  
5813 # Notify all of this window's strip objects of the new table object's birth
5814 foreach my $stripObj (
5815 sort {$a->number <=> $b->number} ($self->winObj->ivValues('stripHash'))
5816 ) {
5817 $stripObj->notify_addTableObj($tableObj);
5818 }
5819  
5820 # Notify all of this strip's table objects of the new table object's birth
5821 foreach my $otherTableObj (
5822 sort {$a->number <=> $b->number} ($self->ivValues('tableObjHash'))
5823 ) {
5824 if ($otherTableObj ne $tableObj) {
5825  
5826 $otherTableObj->notify_addTableObj($tableObj);
5827 }
5828 }
5829  
5830 return $tableObj;
5831 }
5832  
5833 sub removeTableObj {
5834  
5835 # Can be called by anything
5836 # Removes a table object (inheriting GA::Generic::Table) from this strip object's Gtk3::Grid
5837 #
5838 # Expected arguments
5839 # $tableObj - The table object to remove
5840 #
5841 # Return values
5842 # 'undef' on improper arguments, if the table object is protected from removal or if the
5843 # table object no longer exists on this strip
5844 # 1 otherwise
5845  
5846 my ($self, $tableObj, $check) = @_;
5847  
5848 # Local variables
5849 my ($existFlag, $matchFlag, $count);
5850  
5851 # Check for improper arguments
5852 if (! defined $tableObj || defined $check) {
5853  
5854 return $axmud::CLIENT->writeImproper($self->_objClass . '->removeTableObj', @_);
5855 }
5856  
5857 # Don't remove the table object if it's protected
5858 if (! $tableObj->allowRemoveFlag) {
5859  
5860 if ($axmud::CLIENT->debugTableFitFlag) {
5861  
5862 $self->writeError(
5863 'Can\'t remove table object \'' . $tableObj->type . '\' as it is protected',
5864 $self->_objClass . '->removeTableObj',
5865 )
5866 }
5867  
5868 return undef;
5869 }
5870  
5871 # Check the table object still exists on this strip
5872 OUTER: foreach my $obj ($self->ivValues('tableObjHash')) {
5873  
5874 if ($obj eq $tableObj) {
5875  
5876 $existFlag = TRUE;
5877 last OUTER;
5878 }
5879 }
5880  
5881 if (! $existFlag) {
5882  
5883 if ($axmud::CLIENT->debugTableFitFlag) {
5884  
5885 $self->writeError(
5886 'Specified table object doesn\'t exist (or no longer exists)',
5887 $self->_objClass . '->removeTableObj',
5888 )
5889 }
5890  
5891 return undef;
5892 }
5893  
5894  
5895 # Remove the table object
5896 $axmud::CLIENT->desktopObj->removeWidget($self->table, $tableObj->packingBox);
5897  
5898 # Update IVs
5899 $self->ivDelete('tableObjHash', $tableObj->number);
5900 $self->ivDelete('tablezoneHash', $tableObj->zoneObj->number);
5901  
5902 # Notify all of this window's strip objects of the table object's demise
5903 foreach my $stripObj (
5904 sort {$a->number <=> $b->number} ($self->winObj->ivValues('stripHash'))
5905 ) {
5906 $stripObj->notify_removeTableObj($tableObj);
5907 }
5908  
5909 # Notify all of this strip's table objects of the table object's demise
5910 foreach my $otherTableObj (
5911 sort {$a->number <=> $b->number} ($self->ivValues('tableObjHash'))
5912 ) {
5913 if ($otherTableObj ne $tableObj) {
5914  
5915 $otherTableObj->notify_removeTableObj($tableObj);
5916 }
5917 }
5918  
5919 return 1;
5920 }
5921  
5922 sub removeAllTableObjs {
5923  
5924 # Can be called by anything
5925 # Removes all table objects (inheriting GA::Generic::Table) from this strip object's
5926 # Gtk3::Grid
5927 #
5928 # Expected arguments
5929 # (none besides $self)
5930 #
5931 # Return values
5932 # 'undef' on improper arguments or if any of the removal operations fail
5933 # Otherwise returns the number of objects removed (may be zero)
5934  
5935 my ($self, $check) = @_;
5936  
5937 # Local variables
5938 my ($count, $failFlag);
5939  
5940 # Check for improper arguments
5941 if (defined $check) {
5942  
5943 return $axmud::CLIENT->writeImproper($self->_objClass . '->removeAllTableObjs', @_);
5944 }
5945  
5946 # Remove all table objects
5947 $count = 0;
5948 foreach my $tableObj (
5949 sort {$a->number <=> $b->number} ($self->ivValues('tableObjHash'))
5950 ) {
5951 if (! $self->removeTableObj($tableObj)) {
5952 $failFlag = TRUE;
5953 } else {
5954 $count++;
5955 }
5956 }
5957  
5958 if ($failFlag) {
5959 return undef;
5960 } else {
5961 return $count;
5962 }
5963 }
5964  
5965 sub resizeTableObj {
5966  
5967 # Can be called by anything
5968 # Resizes a table object (inheriting GA::Generic::Table) on this strip object's Gtk3::Grid
5969 #
5970 # Expected arguments
5971 # $tableObj - The table object to resize
5972 # $left, $right, $top, $bottom
5973 # - The coordinates of the top-left ($left, $top) and bottom-right ($right, $bottom)
5974 # corners of the table object on the table
5975 #
5976 # Return values
5977 # 'undef' on improper arguments, if the table object is protected from resizing, if the
5978 # table object no longer exists on this strip, if the specified space on the table is
5979 # invalid or already occupied by a tablezone, or if the resize operation fails
5980 # 1 otherwise
5981  
5982 my ($self, $tableObj, $left, $right, $top, $bottom, $check) = @_;
5983  
5984 # Local variables
5985 my ($flag, $string, $zoneObj);
5986  
5987 # Check for improper arguments
5988 if (
5989 ! defined $tableObj || ! defined $left || ! defined $right || ! defined $top
5990 || ! defined $bottom || defined $check
5991 ) {
5992 return $axmud::CLIENT->writeImproper($self->_objClass . '->resizeTableObj', @_);
5993 }
5994  
5995 # Don't resize the table object if it's protected
5996 if (! $tableObj->allowResizeFlag) {
5997  
5998 if ($axmud::CLIENT->debugTableFitFlag) {
5999  
6000 $self->writeError(
6001 'Can\'t resize table object \'' . $tableObj->type . '\' as it is protected',
6002 $self->_objClass . '->resizeTableObj',
6003 )
6004 }
6005  
6006 return undef;
6007 }
6008  
6009 # Check the table object still exists on this strip
6010 OUTER: foreach my $obj ($self->ivValues('tableObjHash')) {
6011  
6012 if ($obj eq $tableObj) {
6013  
6014 $flag = TRUE;
6015 last OUTER;
6016 }
6017 }
6018  
6019 if (! $flag) {
6020  
6021 if ($axmud::CLIENT->debugTableFitFlag) {
6022  
6023 $self->writeError(
6024 'Specified table object doesn\'t exist (or no longer exists)',
6025 $self->_objClass . '->resizeTableObj',
6026 )
6027 }
6028  
6029 return undef;
6030 }
6031  
6032 # Check that the specified area is not outside the bounds of the table
6033 $string = '(X ' . $left . '-' . $right . ', Y ' . $top . '-' . $bottom . ')';
6034 if (
6035 $left < 0 || $right <= $left || $right >= $self->tableSize
6036 || $top < 0 || $bottom <= $top || $bottom >= $self->tableSize
6037 ) {
6038 if ($axmud::CLIENT->debugTableFitFlag) {
6039  
6040 $self->writeError(
6041 'Specified area ' . $string . ' is outside the bounds of the table',
6042 $self->_objClass . '->resizeTableObj',
6043 )
6044 }
6045  
6046 return undef;
6047 }
6048  
6049 # Check that the specified space on the table is not already occupied by a tablezone
6050 foreach my $otherZoneObj ($self->ivValues('tablezoneHash')) {
6051  
6052 if (
6053 $tableObj->zoneObj ne $otherZoneObj
6054 && (
6055 ($left >= $otherZoneObj->left && $left <= $otherZoneObj->right)
6056 || ($right >= $otherZoneObj->left && $right <= $otherZoneObj->right)
6057 ) && (
6058 ($top >= $otherZoneObj->top && $top <= $otherZoneObj->bottom)
6059 || ($bottom >= $otherZoneObj->top && $bottom <= $otherZoneObj->bottom)
6060 )
6061 ) {
6062 if ($axmud::CLIENT->debugTableFitFlag) {
6063  
6064 $self->writeError(
6065 'Specified area ' . $string . ' is occupied by an existing table object',
6066 $self->_objClass . '->resizeTableObj',
6067 )
6068 }
6069  
6070 return undef;
6071 }
6072 }
6073  
6074 # Remove the old tablezone...
6075 $self->ivDelete('tablezoneHash', $tableObj->zoneObj->number);
6076  
6077 # ...and create a new one, assigning it to the table object
6078 $zoneObj = Games::Axmud::Obj::Tablezone->new(
6079 $self->tablezoneCount,
6080 $tableObj->_objClass,
6081 $left,
6082 $top,
6083 $right,
6084 $bottom,
6085 );
6086  
6087 if (! $zoneObj) {
6088  
6089 if ($axmud::CLIENT->debugTableFitFlag) {
6090  
6091 $self->writeError(
6092 'Could not allocate space for the table object at the specified position '
6093 . $string,
6094 $self->_objClass . '->resizeTableObj',
6095 )
6096 }
6097  
6098 return undef;
6099  
6100 } else {
6101  
6102 $self->ivAdd('tablezoneHash', $zoneObj->number, $zoneObj);
6103 $self->ivIncrement('tablezoneCount');
6104  
6105 $tableObj->set_zoneObj($zoneObj);
6106 }
6107  
6108 # Resize the table object
6109 $axmud::CLIENT->desktopObj->removeWidget($self->table, $tableObj->packingBox);
6110  
6111 $self->table->attach(
6112 $tableObj->packingBox,
6113 $zoneObj->left,
6114 $zoneObj->top,
6115 # Axmud uses 59,59, but Gtk expects 60,60
6116 ($zoneObj->right - $zoneObj->left + 1),
6117 ($zoneObj->bottom - $zoneObj->top + 1),
6118 );
6119  
6120 # Inform the table object that it's been resized
6121 $tableObj->setWidgetsOnResize(
6122 $zoneObj->left,
6123 $zoneObj->right,
6124 $zoneObj->top,
6125 $zoneObj->bottom,
6126 );
6127  
6128 return 1;
6129 }
6130  
6131 sub replaceHolder {
6132  
6133 # Called by any code
6134 # Looks for a holder table object (GA::Table::Holder) with a specified ->id. If one is
6135 # found, removes it and adds a different table object using the same size/position. If
6136 # one is not found, returns 'undef'
6137 # (The calling code can call this function as often as it needs to, looking for various
6138 # holders, and if none are found, can then call $self->addTableObj directly)
6139 #
6140 # Expected arguments
6141 # $id - The holder ID; can be any non-empty string. If any holders have an ->id with this
6142 # value, that is replaced. Values might include types of 'grid' window such as
6143 # 'map', or 'task' for task windows in general, or 'status_task' for the Status
6144 # task in particular. If not specified, 'undef' or an empty string, 'task' is
6145 # used as a default value
6146 # $packageName
6147 # - The package name of the replacement table object, e.g. GA::Table::Pane
6148 #
6149 # Optional arguments
6150 # $objName
6151 # - An optional name to give to the replacement table object, when it is created. If
6152 # not specified, the table object's ->objName is given the same value as its
6153 # ->number. If specified, $objName can be any string (avoid using short strings or
6154 # numbers. No part of the code checks that table object names are unique; if two
6155 # or more table objects share the same ->objName, usually the one with the lowest
6156 # ->number 'wins')
6157 # %initHash
6158 # - A hash containing arbitrary data to use as the table object's initialisation
6159 # settings. The table object should use default initialisation settings unless it
6160 # can succesfully interpret one or more of the key-value pairs in the hash, if
6161 # there are any
6162 #
6163 # Return values
6164 # 'undef' on improper arguments, if no holders with a matching ->id are found or if the
6165 # replacement table object can't be created
6166 # Otherwise returns the blessed reference to the replacement table object
6167  
6168 my ($self, $id, $packageName, $objName, %initHash) = @_;
6169  
6170 # Check for improper arguments
6171 if (! defined $id || ! defined $packageName) {
6172  
6173 return $axmud::CLIENT->writeImproper($self->_objClass . '->replaceHolder', @_);
6174 }
6175  
6176 foreach my $tableObj (sort {$a->number <=> $b->number} ($self->ivValues('tableObjHash'))) {
6177  
6178 if (
6179 $tableObj->type eq 'holder'
6180 && $tableObj->id
6181 && $tableObj->id eq $id
6182 ) {
6183 # Matching holder found. Remove it from the table
6184 if (! $self->removeTableObj($tableObj)) {
6185  
6186 if ($axmud::CLIENT->debugTableFitFlag) {
6187  
6188 $self->writeError(
6189 'Could not replace holder table object due to internal error',
6190 $self->_objClass . '->replaceHolder',
6191 )
6192 }
6193  
6194 return undef;
6195 }
6196  
6197 # Add the replacement table object
6198 return $self->addTableObj(
6199 $packageName,
6200 $tableObj->zoneObj->left,
6201 $tableObj->zoneObj->right,
6202 $tableObj->zoneObj->top,
6203 $tableObj->zoneObj->bottom,
6204 $objName,
6205 %initHash,
6206 );
6207 }
6208 }
6209  
6210 # No matching holder found
6211 if ($axmud::CLIENT->debugTableFitFlag) {
6212  
6213 $self->writeError(
6214 'Could not replace holder table object - no matching holder found',
6215 $self->_objClass . '->replaceHolder',
6216 )
6217 }
6218  
6219 return undef;
6220 }
6221  
6222 sub findPosn {
6223  
6224 # The parent window's winmap (GA::Obj::Winmap) specified a default size for new table
6225 # objects, added to this strip object after its creation
6226 # This function checks the table, looking for an unoccupied space of the right size. If a
6227 # space is found, the calling function can then call $self->addTableObj to create a
6228 # table object in that space
6229 #
6230 # Expected arguments
6231 # (none besides $self)
6232 #
6233 # Return values
6234 # An empty list on improper arguments
6235 # Otherwise, returns a list in the form
6236 # (left, right, top, bottom)
6237 # ...matching the table coordinates that can be used in the subsequent call to
6238 # $self->addTableObj
6239  
6240 my ($self, $check) = @_;
6241  
6242 # Local variables
6243 my (
6244 $winmapObj, $width, $height,
6245 @emptyList,
6246 );
6247  
6248 # Check for improper arguments
6249 if (defined $check) {
6250  
6251 $axmud::CLIENT->writeImproper($self->_objClass . '->findPosn', @_);
6252 return @emptyList;
6253 }
6254  
6255 # Get the parent window's winmap and, from that, get the default size
6256 if ($self->winObj->winmap) {
6257  
6258 $winmapObj = $axmud::CLIENT->ivShow('winmapHash', $self->winObj->winmap);
6259 if ($winmapObj) {
6260  
6261 $width = $winmapObj->zoneWidth;
6262 $height = $winmapObj->zoneHeight;
6263 }
6264 }
6265  
6266 if (! defined $width) {
6267  
6268 # (Most standard winmaps use 30x30)
6269 $width = 30;
6270 $height = 30;
6271 }
6272  
6273 # Search left-to-right, then top-to-bottom
6274 OUTER: for (my $top = 0; $top < $self->tableSize; $top += $height) {
6275  
6276 INNER: for (my $left = 0; $left < $self->tableSize; $left += $width) {
6277  
6278 my ($right, $bottom);
6279  
6280 $right = $left + $width - 1;
6281 $bottom = $top + $height - 1;
6282  
6283 # Check that the specified position on the table is not already occupied by a
6284 # tablezone
6285 foreach my $zoneObj ($self->ivValues('tablezoneHash')) {
6286  
6287 if (
6288 (
6289 ($left >= $zoneObj->left && $left <= $zoneObj->right)
6290 || ($right >= $zoneObj->left && $right <= $zoneObj->right)
6291 ) && (
6292 ($top >= $zoneObj->top && $top <= $zoneObj->bottom)
6293 || ($bottom >= $zoneObj->top && $bottom <= $zoneObj->bottom)
6294 )
6295 ) {
6296 # This position is occupied
6297 next INNER;
6298 }
6299 }
6300  
6301 # This position is free
6302 return ($left, $right, $top, $bottom);
6303 }
6304 }
6305  
6306 # All positions are occupied
6307 return @emptyList;
6308 }
6309  
6310 sub getPosn {
6311  
6312 # Can be called by anything
6313 # Returns the size and position of an existing table object
6314 #
6315 # Expected arguments
6316 # $tableObj - An existing table object
6317 #
6318 # Return values
6319 # An empty list on improper arguments or if the table object doesn't exist in this strip
6320 # object's table
6321 # Otherwise, returns a list in the form
6322 # (left, right, top, bottom)
6323  
6324 my ($self, $tableObj, $check) = @_;
6325  
6326 # Local variables
6327 my (
6328 $zoneObj,
6329 @emptyList,
6330 );
6331  
6332 # Check for improper arguments
6333 if (! defined $tableObj || defined $check) {
6334  
6335 $axmud::CLIENT->writeImproper($self->_objClass . '->getPosn', @_);
6336 return @emptyList;
6337 }
6338  
6339 # Check the table object exists on this strip object's table, and get the corresponding
6340 # tablezone object (GA::Obj::Tablezone)
6341 if (
6342 ! $self->ivExists('tableObjHash', $tableObj->number)
6343 || $self->ivShow('tableObjHash', $tableObj->number) ne $tableObj
6344 ) {
6345 return @emptyList;
6346  
6347 } else {
6348  
6349 $zoneObj = $self->ivShow('tablezoneHash', $tableObj->number);
6350  
6351 return ($zoneObj->left, $zoneObj->right, $zoneObj->top, $zoneObj->bottom);
6352 }
6353 }
6354  
6355 sub changeSpacing {
6356  
6357 # Can be called by anything to update the spacing around table objects. The same spacing is
6358 # added around future table objects, as they added
6359 #
6360 # Expected arguments
6361 # $spacing - The new spacing (should be an integer, 0 or above)
6362 #
6363 # Return values
6364 # 'undef' on improper arguments
6365 # 1 otherwise
6366  
6367 my ($self, $spacing, $check) = @_;
6368  
6369 # Check for improper arguments
6370 if (! defined $spacing || defined $check) {
6371  
6372 return $axmud::CLIENT->writeImproper($self->_objClass . '->changeSpacing', @_);
6373 }
6374  
6375 if (! ($spacing =~ m/\D/) && $spacing >= 0) {
6376  
6377 $self->ivPoke('currentSpacing', $spacing);
6378 foreach my $tableObj ($self->ivValues('tableObjHash')) {
6379  
6380 $tableObj->packingBox->set_border_width($spacing);
6381 }
6382 }
6383  
6384 return 1;
6385 }
6386  
6387 sub changeBorder {
6388  
6389 # Can be called by anything to update the border around the edge of the table
6390 #
6391 # Expected arguments
6392 # $border - The new border (should be an integer, 0-10)
6393 #
6394 # Return values
6395 # 'undef' on improper arguments
6396 # 1 otherwise
6397  
6398 my ($self, $border, $check) = @_;
6399  
6400 # Check for improper arguments
6401 if (! defined $border || defined $check) {
6402  
6403 return $axmud::CLIENT->writeImproper($self->_objClass . '->changeBorder', @_);
6404 }
6405  
6406 if (! ($border =~ m/\D/) && $border >= 0 && $border <= 10) {
6407  
6408 $self->ivPoke('currentBorder', $border);
6409 $self->table->set_border_width($border);
6410 }
6411  
6412 return 1;
6413 }
6414  
6415 ##################
6416 # Accessors - set
6417  
6418 ##################
6419 # Accessors - get
6420  
6421 sub table
6422 { $_[0]->{table} }
6423  
6424 sub tableSize
6425 { $_[0]->{tableSize} }
6426  
6427 sub tablezoneHash
6428 { my $self = shift; return %{$self->{tablezoneHash}}; }
6429 sub tablezoneCount
6430 { $_[0]->{tablezoneCount} }
6431 sub tableObjHash
6432 { my $self = shift; return %{$self->{tableObjHash}}; }
6433 sub tableObjCount
6434 { $_[0]->{tableObjCount} }
6435  
6436 sub currentSpacing
6437 { $_[0]->{currentSpacing} }
6438 sub currentBorder
6439 { $_[0]->{currentBorder} }
6440 }
6441  
6442 { package Games::Axmud::Strip::GaugeBox;
6443  
6444 use strict;
6445 use warnings;
6446 use diagnostics;
6447  
6448 use Glib qw(TRUE FALSE);
6449  
6450 our @ISA = qw(Games::Axmud::Generic::Strip Games::Axmud);
6451  
6452 ##################
6453 # Constructors
6454  
6455 sub new {
6456  
6457 # Called by GA::Win::Internal->drawWidgets or ->addStripObj
6458 # Creates the GA::Strip::GaugeBox - a non-compulsory strip object optionally containing one
6459 # or more gauge levels (or none, when this strip object is marked not visible)
6460 #
6461 # Expected arguments
6462 # $number - The strip object's number within the parent window (matches
6463 # GA::Win::Internal->stripCount, or -1 for a temporary strip object
6464 # created to access its default IVs)
6465 # $winObj - The parent window object (GA::Win::Internal). 'temp' for temporary strip
6466 # objects
6467 #
6468 # Optional arguments
6469 # %initHash - A hash containing arbitrary data to use as the strip object's
6470 # initialisation settings. The strip object should use default
6471 # initialisation settings unless it can succesfully interpret one or more
6472 # of the key-value pairs in the hash, if there are any
6473 # - (This type of strip object requires no initialisation settings)
6474 #
6475 # Return values
6476 # 'undef' on improper arguments
6477 # Blessed reference to the newly-created object on success
6478  
6479 my ($class, $number, $winObj, %initHash) = @_;
6480  
6481 # Local variables
6482 my %modHash;
6483  
6484 # Check for improper arguments
6485 if (! defined $class || ! defined $number || ! defined $winObj) {
6486  
6487 return $axmud::CLIENT->writeImproper($class . '->new', @_);
6488 }
6489  
6490 # Setup
6491 my $self = {
6492 _objName => 'strip_' . $number,
6493 _objClass => $class,
6494 _parentFile => undef, # No parent file object
6495 _parentWorld => undef, # No parent file object
6496 _privFlag => TRUE, # All IVs are private
6497  
6498 # Standard strip object IVs
6499 # -------------------------
6500  
6501 # The strip object's number within the parent window (matches
6502 # GA::Win::Internal->stripCount, or -1 for a temporary strip object created to access
6503 # its default IVs)
6504 number => $number,
6505 # The type of strip object (custom strip objects should use a ->type starting with
6506 # 'custom_' to avoid clashing with future built-in strip objects)
6507 type => 'gauge_box',
6508 # The parent window object (GA::Win::Internal). 'temp' for temporary strip objects
6509 winObj => $winObj,
6510  
6511 # Flag set to TRUE if the strip object is visible (has actually drawn widgets in the
6512 # window), set to FALSE if it is not visible (has drawn no widgets in the window, but
6513 # still exists in GA::Win::Internal->stripHash, etc)
6514 # The flag might be set to FALSE in strip objects like GA::Strip::GaugeBox, which might
6515 # have gauges to draw, or not, depending on current conditions. (Most strip objects
6516 # have this flag set to TRUE all the time)
6517 # If FALSE, GA::Win::Internal->drawWidgets and ->addStripObj don't draw any widgets when
6518 # called by this object's functions
6519 # NB Strip objects are created with this flag set to TRUE or FALSE, but once created,
6520 # the flag's value shouldn't be modified by anything other than
6521 # GA::Win::Internal->hideStripObj and ->revealStripObj (which in turn call
6522 # $self->set_visibleFlag)
6523 visibleFlag => FALSE, # Wait until the first gauge is drawn
6524 # Flag set to TRUE is the strip object should be given its share of any extra space
6525 # within the packing box (the extra space is divided equally between all children of
6526 # the box whose ->expandFlag is TRUE)
6527 expandFlag => FALSE,
6528 # Flag set to TRUE if any space given to the strip object by the 'expand' option is
6529 # actually allocated within the strip object, FALSE if it is used as padding outside
6530 # it (on both sides)
6531 fillFlag => TRUE, # Force canvas to use available width
6532 # Flag set to TRUE if the strip object should be packed into its window with a small
6533 # gap between strip objects to either side; FALSE if not (can be set to FALSE if the
6534 # the strip object's widgets are drawn in a way, such that a gap is not necessary,
6535 # for example in the toolbar strip object)
6536 spacingFlag => TRUE,
6537 # Flag set to TRUE if only one instance of this strip object should be added to the
6538 # parent window, set to FALSE if any number of instances can be added
6539 jealousyFlag => TRUE,
6540 # Flag set to TRUE if this strip object can be added when $axmud::BLIND_MODE_FLAG is
6541 # TRUE, FALSE if it can't be added (because it's not useful for visually-impaired
6542 # users)
6543 blindFlag => FALSE,
6544 # Flag set to TRUE if the main container widget, stored in $self->packingBox, should be
6545 # allowed to accept the focus, FALSE if not. The restriction is applied during the
6546 # call to GA::Win::Internal->drawWidgets and ->addStripObj. Even if FALSE, widgets in
6547 # the container widget can be set to accept the focus (e.g. the Gtk3::Entry in
6548 # GA::Strip::MenuBar)
6549 allowFocusFlag => FALSE,
6550  
6551 # Initialisation settings stored as a hash (see the comments above)
6552 initHash => \%modHash,
6553 # Reference to a function to call when some widget is used. This IV is set only when
6554 # required by this type of strip object. It can be set by a call to
6555 # $self->set_func() or by some setting in $self->initHash, which is applied in the
6556 # call to $self->objEnable(). To obtain a reference to an OOP method, you can use the
6557 # generic object function Games::Axmud->getMethodRef()
6558 funcRef => undef,
6559 # A value passed to ->funcRef when it is called which identifies this strip object and
6560 # its widget(s). Can be any value, including 'undef'. It can be set by a call to
6561 # $self->set_id() or by some setting in $self->initHash, which is applied in the call
6562 # to $self->objEnable()
6563 funcID => undef,
6564  
6565 # The container widget for this strip object (usually a Gtk3::HBox or Gtk3::VBox). This
6566 # widget is the one added to the window's main Gtk3::HBox or Gtk3::VBox
6567 packingBox => undef, # Gtk3::VBox
6568  
6569 # Other IVs
6570 # ---------
6571  
6572 # Widgets
6573 frame => undef, # Gtk3::Frame
6574 canvas => undef, # GooCanvas2::Canvas
6575 # A list of GooCanvas2::CanvasRect and GooCanvas2::CanvasText objects drawn in the gauge
6576 # box, which are destroyed every time $self->drawGauges is called
6577 gaugeCanvasList => [], # GooCanvas2::CanvasRect/::CanvasText
6578  
6579 # The size of the available area inside the frame containing the canvas, set whenever
6580 # the frame's size-allocate signal is emitted (this is the only way to guarantee that
6581 # that the correct size is available to $self->drawGauges)
6582 canvasFrameWidth => 1,
6583 canvasFrameHeight => 1,
6584  
6585 # The size of the GooCanvas2::Canvas used to display gauges (width is the same as the
6586 # available space, so only height specified here)
6587 # The height (in pixels) of gauges. The total height of the gauge will be this value,
6588 # plus the spacing above and below it. (Width is the same as the available space, so
6589 # only height specified here)
6590 gaugeHeight => 16,
6591 # The size of the rounded corner (in pixels)
6592 gaugeCorner => 5,
6593 # Spacing (padding) used between the gauges, and between the edges of the gauge box
6594 gaugeSpacingX => 8,
6595 gaugeSpacingY => 4,
6596 # The font and size to use for gauge labels. These default values produce a font that's
6597 # about the right the size for a gauge of height $self->gaugeHeight
6598 gaugeLabelFont => 'Monospace',
6599 gaugeLabelFontSize => 10,
6600 # Registry hash of GA::Obj::GaugeLevel objects, one for each gauge level drawn in the
6601 # gauge box for a single session
6602 # Hash in the form
6603 # $gaugeLevelHash{unique_number} = gauge_level_object
6604 # ...where 'unique_number' is unique across all sessions
6605 gaugeLevelHash => {},
6606 # The number of gauge levels ever created (used to provide the unique number)
6607 gaugeLevelCount => 0,
6608 # Maximum number of gauge levels (sanity check)
6609 gaugeLevelMax => 8,
6610 # Number of GA::Obj::Gauge objects ever created (used to give each object a unique
6611 # number)
6612 gaugeCount => 0,
6613 # Maximum number of gauges per level (sanity check)
6614 gaugeMax => 10,
6615 # A list of GA::Obj::Gauge objects that were drawn, the last time $self->updateGauges
6616 # was called (may be an empty list)
6617 gaugeDrawnList => [],
6618 # Calls to $self->updateGauges should be allowed to finish, before another call to
6619 # the same function is allowed. This flag is set to TRUE at the beginning of a call,
6620 # and FALSE at the end of it
6621 gaugeUpdateFlag => FALSE,
6622 # Colour used to draw blank gauges
6623 gaugeBlankColour => '#CDCDBA',
6624 # Default colour for the empty portion of gauges
6625 gaugeEmptyColour => '#000000',
6626 # Default colour used for the full portion of gauges
6627 gaugeFullColour => '#FFFFFF',
6628 # Default colour used for gauge labels
6629 gaugeLabelColour => '#FF0000',
6630 # Colour (always) used to draw the borders of gauges
6631 gaugeBorderColour => '#000000',
6632 # When the last gauge is removed, we should wait a few seconds before removing the
6633 # gauge box entirely. For example, if the Status task resets, its gauges are
6634 # removed for a moment, and re-drawn as soon as the task is ready
6635 # If defined, the time (matches GA::Client->clientTime) at which the gauge box should
6636 # be removed, if no new gauges have been drawn in the mean time
6637 gaugeCheckTime => undef,
6638 # The time to wait (in seconds)
6639 gaugeWaitTime => 1,
6640 # When $self->addGaugeLevel is called with the no-redraw flag set to TRUE, this flag is
6641 # set to TRUE. Then, the next time $self->updateGauges is called, that function knows
6642 # that it needs to call $self->replaceStripObj to redraw the gauge box. (This flag is
6643 # then set back to FALSE)
6644 gaugeNoDrawFlag => FALSE,
6645 };
6646  
6647 # Bless the object into existence
6648 bless $self, $class;
6649  
6650 return $self;
6651 }
6652  
6653 ##################
6654 # Methods
6655  
6656 # Standard strip object functions
6657  
6658 sub objEnable {
6659  
6660 # Called by GA::Win::Internal->drawWidgets or ->addStripObj
6661 # Sets up the strip object's widgets
6662 #
6663 # Expected arguments
6664 # $winmapObj - The winmap object (GA::Obj::Winmap) that specifies the layout of the
6665 # parent window
6666 #
6667 # Return values
6668 # 'undef' on improper arguments
6669 # 1 on success
6670  
6671 my ($self, $winmapObj, $check) = @_;
6672  
6673 # Check for improper arguments
6674 if (! defined $winmapObj || defined $check) {
6675  
6676 return $axmud::CLIENT->writeImproper($self->_objClass . '->objEnable', @_);
6677 }
6678  
6679 # (IVs normally updated here are updated by $self->drawGaugeBox, when it is called)
6680  
6681 return 1;
6682 }
6683  
6684 sub objDestroy {
6685  
6686 # Called by GA::Win::Internal->removeStripObj, just before the strip is removed from its
6687 # parent window, and also by ->winDestroy and ->resetWinmap, to give this object a chance
6688 # to do any necessary tidying up
6689 #
6690 # Expected arguments
6691 # (none besides $self)
6692 #
6693 # Return values
6694 # 'undef' on improper arguments
6695 # 1 otherwise
6696  
6697 my ($self, $check) = @_;
6698  
6699 # Check for improper arguments
6700 if (defined $check) {
6701  
6702 return $axmud::CLIENT->writeImproper($self->_objClass . '->objDestroy', @_);
6703 }
6704  
6705 if ($self->visibleFlag) {
6706  
6707 # Only polite to destroy GooCanvas2 canvas objects when they're no longer needed
6708 foreach my $canvasObj ($self->gaugeCanvasList) {
6709  
6710 $canvasObj->remove();
6711 }
6712 }
6713  
6714 return 1;
6715 }
6716  
6717 # sub setWidgetsIfSession {} # Inherited from GA::Generic::Strip
6718  
6719 # sub setWidgetsChangeSession {} # Inherited from GA::Generic::Strip
6720  
6721 # ->signal_connects
6722  
6723 # Other functions
6724  
6725 sub drawGaugeBox {
6726  
6727 # Called by $self->objEnable and ->addGaugeLevel
6728 # Draws a Gtk3::HBox to contain gauge levels
6729 #
6730 # Expected arguments
6731 # (none besides $self)
6732 #
6733 # Return values
6734 # 'undef' on improper arguments
6735 # 1 otherwise
6736  
6737 my ($self, $check) = @_;
6738  
6739 # Local variables
6740 my (
6741 $levelCount,
6742 %sessionHash,
6743 );
6744  
6745 # Check for improper arguments
6746 if (defined $check) {
6747  
6748 return $axmud::CLIENT->writeImproper($self->_objClass . '->drawGaugeBox', @_);
6749 }
6750  
6751 # Create a packing box, if one doesn't exist already
6752 my $packingBox;
6753 if (! $self->packingBox) {
6754  
6755 # This function is being called for the first time
6756 $packingBox = Gtk3::VBox->new(FALSE, 0);
6757 $packingBox->set_border_width(0);
6758  
6759 } else {
6760  
6761 # This function is being called for a subsequent time. Remove its current contents, so
6762 # new widgets can be created
6763 $packingBox = $self->packingBox;
6764 $axmud::CLIENT->desktopObj->removeWidget($packingBox, $self->frame);
6765 }
6766  
6767 # Different sessions might be using different numbers of gauge levels. Find the highest
6768 # number of gauge levels used by the greediest session (might be 0, if there are no gauge
6769 # levels at the moment)
6770 $levelCount = 0;
6771 foreach my $gaugeLevelObj ($self->ivValues('gaugeLevelHash')) {
6772  
6773 my $num = $gaugeLevelObj->session->number;
6774  
6775 if (! exists $sessionHash{$num}) {
6776 $sessionHash{$num} = 1;
6777 } else {
6778 $sessionHash{$num} = $sessionHash{$num} + 1;
6779 }
6780  
6781 if ($levelCount < $sessionHash{$num}) {
6782  
6783 $levelCount = $sessionHash{$num};
6784 }
6785 }
6786  
6787 # If there are no gauges visible, draw a gauge box with room for one gauge level anyway, in
6788 # the expectation that the first gauge might be added a moment from now
6789 if (! $levelCount) {
6790  
6791 $levelCount = 1;
6792 }
6793  
6794 # Add a frame
6795 my $frame = Gtk3::Frame->new(undef);
6796 $frame->set_border_width(0);
6797 $frame->set_size_request(
6798 -1,
6799 (
6800 2 # Size of frame border
6801 + $self->gaugeSpacingY
6802 + ($levelCount * ($self->gaugeHeight + $self->gaugeSpacingY))
6803 ),
6804 );
6805  
6806 $packingBox->pack_start($frame, TRUE, TRUE, 0);
6807  
6808 # The only way to detect the frame's size reliably is to store the frame's size allocation
6809 # whenever it is set
6810 $frame->signal_connect('size-allocate' => sub {
6811  
6812 my ($widget, $hashRef) = @_;
6813  
6814 $self->ivPoke('canvasFrameWidth', $$hashRef{width});
6815 $self->ivPoke('canvasFrameHeight', $$hashRef{height});
6816  
6817 if ($self->canvas) {
6818  
6819 $self->updateGauges();
6820  
6821 # The resized canvas won't be visible until a Gtk main loop occurs
6822 $axmud::CLIENT->desktopObj->updateWidgets($self->_objClass . '->drawGaugeBox');
6823 }
6824 });
6825  
6826 # Add a drawing canvas, inside the frame
6827 my $canvas = GooCanvas2::Canvas->new();
6828 $frame->add($canvas);
6829  
6830 # Update IVs
6831 $self->ivPoke('packingBox', $packingBox);
6832 $self->ivPoke('frame', $frame);
6833 $self->ivPoke('canvas', $canvas);
6834  
6835 # Setup complete
6836 return 1;
6837 }
6838  
6839 sub removeGaugeBox {
6840  
6841 # Called by GA::Client->spinClientLoop or $self->removeSessionGauges
6842 # If this window's gauge box has been empty for too long, remove the gauge box entirely
6843 # (By waiting for a few seconds, we don't have to remove then re-draw the gauge box within
6844 # the space of a second if, for example, the Status task resets)
6845 #
6846 # Expected arguments
6847 # (none besides $self)
6848 #
6849 # Return values
6850 # 'undef' on improper arguments
6851 # 1 otherwise
6852  
6853 my ($self, $check) = @_;
6854  
6855 # Check for improper arguments
6856 if (defined $check) {
6857  
6858 return $axmud::CLIENT->writeImproper($self->_objClass . '->removeGaugeBox', @_);
6859 }
6860  
6861 # Check that gauge box is actually drawn and doesn't currently contain any gauges
6862 if ($self->visibleFlag && ! $self->gaugeLevelHash) {
6863  
6864 # Destroy canvas objects
6865 foreach my $canvasObj ($self->gaugeCanvasList) {
6866  
6867 $canvasObj->remove();
6868 }
6869  
6870 # Update IVs
6871 $self->ivUndef('gaugeCheckTime');
6872  
6873 # Mark the strip object as hidden
6874 $self->winObj->hideStripObj($self);
6875 }
6876  
6877 return 1;
6878 }
6879  
6880 sub addGaugeLevel {
6881  
6882 # Can be called by anything
6883 # Adds a new gauge level to this window's gauge box (a horizontal band of gauges, of which
6884 # there can be 1 or more bands within the gauge box)
6885 # Updates IVs and redraws the gauge box (if it's not currently visible, draws it in the
6886 # expectation that a gauge is about to be added)
6887 #
6888 # Expected arguments
6889 # $session - The calling GA::Session
6890 #
6891 # Optional arguments
6892 # $noDrawFlag - If set to TRUE, $self->drawGaugeBox is not called immediately (in the
6893 # expectation that the calling function has not finished modifying its
6894 # gauges yet). Otherwise set to FALSE (or 'undef'). If adding gauges
6895 # on multiple levels, all at the same time, set this flag to TRUE for
6896 # a better visual effect
6897 #
6898 # Return values
6899 # 'undef' on improper arguments or on failure
6900 # Otherwise, returns the unique number of the gauge level created (the first one ever
6901 # created, but not necessarily the first one visible currently, is 0)
6902  
6903 my ($self, $session, $noDrawFlag, $check) = @_;
6904  
6905 # Local variables
6906 my ($count, $newObj);
6907  
6908 # Check for improper arguments
6909 if (! defined $session || defined $check) {
6910  
6911 return $axmud::CLIENT->writeImproper($self->_objClass . '->addGaugeLevel', @_);
6912 }
6913  
6914 # Count the number of gauge levels for this session. If we're already at the maximum, do
6915 # nothing
6916 $count = 0;
6917 foreach my $gaugeLevelObj ($self->ivValues('gaugeLevelHash')) {
6918  
6919 if ($gaugeLevelObj->session eq $session) {
6920  
6921 $count++;
6922 }
6923 }
6924  
6925 if ($count >= $self->gaugeLevelMax) {
6926  
6927 return undef;
6928 }
6929  
6930 # If the gauge box was due to be removed because it's been empty too long, we can now keep
6931 # it (on the understanding that a new gauge is about to be added)
6932 $self->ivUndef('gaugeCheckTime');
6933  
6934 # Create a new gauge level object
6935 $newObj = Games::Axmud::Obj::GaugeLevel->new($session, $self->gaugeLevelCount);
6936 if (! $newObj) {
6937  
6938 return undef;
6939 }
6940  
6941 # Update IVs
6942 $self->ivAdd('gaugeLevelHash', $newObj->number, $newObj);
6943 $self->ivIncrement('gaugeLevelCount');
6944  
6945 # Redraw the gauge box at the right size
6946 if (! $noDrawFlag) {
6947  
6948 # Redraw the gauge box now
6949 $self->drawGaugeBox();
6950 if (! $self->visibleFlag) {
6951 $self->winObj->revealStripObj($self);
6952 } else {
6953 $self->winObj->replaceStripObj($self);
6954 }
6955  
6956 } else {
6957  
6958 # Redraw the gauge box the next time $self->updateGauges is called
6959 $self->ivPoke('gaugeNoDrawFlag', TRUE);
6960 }
6961  
6962 return $newObj->number;
6963 }
6964  
6965 sub removeGaugeLevel {
6966  
6967 # Can be called by anything
6968 # Removes an existing gauge level from this window's gauge box (a horizontal band of gauges,
6969 # of which there can be 1 or more bands within the gauge box)
6970 # Any gauges that are currently drawn on that level are destroyed
6971 # Updates IVs. Redraws the gauge box, or removes it altogether if there are no gauge levels
6972 # left
6973 #
6974 # Expected arguments
6975 # $session - The calling GA::Session
6976 # $level - The unique number of the gauge level to remove (matches a key in
6977 # $self->gaugeLevelHash). The gauge level must belong to the specified
6978 # $session
6979 #
6980 # Optional arguments
6981 # $noDrawFlag - If set to TRUE, $self->updateGauges is not called immediately (in the
6982 # expectation that the calling function has not finished modifying its
6983 # gauges yet). Otherwise set to FALSE (or 'undef')
6984 #
6985 # Return values
6986 # 'undef' on improper arguments or on failure
6987 # Otherwise returns the number of gauges removed (might be 0)
6988  
6989 my ($self, $session, $level, $noDrawFlag, $check) = @_;
6990  
6991 # Local variables
6992 my (
6993 $gaugeLevelObj, $count,
6994 @list,
6995 );
6996  
6997 # Check for improper arguments
6998 if (! defined $level || defined $check) {
6999  
7000 return $axmud::CLIENT->writeImproper($self->_objClass . '->removeGaugeLevel', @_);
7001 }
7002  
7003 # Do nothing if the gauge level doesn't exist or if it doesn't match the specified session
7004 $gaugeLevelObj = $self->ivShow('gaugeLevelHash', $level);
7005 if (! defined $gaugeLevelObj || $gaugeLevelObj->session ne $session) {
7006  
7007 return undef;
7008 }
7009  
7010 # Update IVs
7011 $count = $gaugeLevelObj->ivPairs('gaugeHash');
7012 $self->ivDelete('gaugeLevelHash', $level);
7013  
7014 # If there are no gauges levels left (in any session), set the time (shortly in the future)
7015 # when the gauge box will be removed entirely, if no new gauges have been drawn in the
7016 # mean time
7017 if (! $self->gaugeLevelHash) {
7018  
7019 $self->ivPoke('gaugeCheckTime', ($axmud::CLIENT->clientTime + $self->gaugeWaitTime));
7020 }
7021  
7022 # If the strip object itself is marked visible ($self->visibleFlag), redraw the gauge box as
7023 # the right size (even if it contains no gauges at this precise moment)
7024 $self->drawGaugeBox();
7025 if ($self->visibleFlag) {
7026  
7027 $self->winObj->replaceStripObj($self);
7028 if (! $noDrawFlag) {
7029  
7030 $self->updateGauges();
7031 }
7032 }
7033  
7034 return $count;
7035 }
7036  
7037 sub addGauge {
7038  
7039 # Can be called by anything
7040 # Adds a new graphical gauge to this window's gauge box, visible only when the calling
7041 # GA::Session is the window's visible session. (Text gauges are added with a call to
7042 # $self->addTextGauge)
7043 # If the gauge box itself is not yet visible, draws it
7044 #
7045 # Expected arguments
7046 # $session - The calling GA::Session
7047 #
7048 # Optional arguments
7049 # $level - The unique number of the GA::Obj::GaugeLevel object to use
7050 # (representing a horizontal band of gauges, of which there can be
7051 # 1 or more bands within the gauge box). If the $level number has
7052 # not been added via a call to $self->addGaugeLevel, the gauge is not
7053 # drawn (as a precaution against buggy code). However, if 'undef', the
7054 # gauge is added to the first visible level for the specified
7055 # GA::Session; if none exist for the session, one is created for it
7056 # - NB Ideally, anything that displays gauges (such as a task) should
7057 # create its own gauge level via a call to $self->addGaugeLevel
7058 # $value - The value to display (>= 0)...
7059 # $maxValue - ...and the maximum value (must be >= $value). If either $value or
7060 # $maxValue is undefined, the gauge is drawn a different colour than
7061 # usual
7062 # $addFlag - If TRUE, the total size of the gauge is ($value + $maxValue). If
7063 # FALSE (or 'undef'), the total size is $maxValue
7064 # $label - The label to use with the gauge. If 'undef' or an empty string, no
7065 # label is used
7066 # $fullColour - The colour to use in the 'full' part of the gauge - an Axmud colour
7067 # tag (standard, Xterm or RGB). If 'undef', an empty string or an
7068 # unrecognised colour tag, '#FFFFFF' is used
7069 # $emptyColour - The colour to use in the 'empty' part of the gauge - an Axmud colour
7070 # tag (standard, Xterm or RGB). If 'undef', an empty string or an
7071 # unrecognised colour tag, '#000000' is used
7072 # $labelColour - The label colour to use - - an Axmud colour tag (standard, Xterm or
7073 # RGB). If 'undef', an empty string or an unrecognised colour tag,
7074 # '#FF0000' is used
7075 # $labelFlag - If set to TRUE, the label text (if displayed) is supplemented with the
7076 # values; e.g. 'HP: 37/100'. If FALSE (or 'undef'), only the text in
7077 # $label is visible
7078 #
7079 # Return values
7080 # 'undef' on improper arguments or on failure
7081 # Otherwise returns the GA::Obj::Gauge created to store details about the new gauge
7082  
7083 my (
7084 $self, $session, $level, $value, $maxValue, $addFlag, $label, $fullColour, $emptyColour,
7085 $labelColour, $labelFlag, $check,
7086 ) = @_;
7087  
7088 # Local variables
7089 my (
7090 $gaugeLevelObj, $newObj,
7091 @list, @gaugeList,
7092 );
7093  
7094 # Check for improper arguments
7095 if (! defined $session || defined $check) {
7096  
7097 return $axmud::CLIENT->writeImproper($self->_objClass . '->addGauge', @_);
7098 }
7099  
7100 if (! defined $level) {
7101  
7102 # If no level was specified, use the first available one. If there are none, create a
7103 # new one
7104 # The first available level is the one with the lowest level number that belongs to
7105 # the calling session
7106 foreach my $gaugeLevelObj ($self->ivValues('gaugeLevelHash')) {
7107  
7108 if (
7109 $gaugeLevelObj->session eq $session
7110 && (
7111 ! defined $level
7112 || $level > $gaugeLevelObj->number
7113 )
7114 ) {
7115 $level = $gaugeLevelObj->number;
7116 }
7117 }
7118  
7119 if (! defined $level) {
7120  
7121 $level = $self->addGaugeLevel($session);
7122 if (! defined $level) {
7123  
7124 return undef;
7125 }
7126 }
7127  
7128 } elsif (! $self->ivExists('gaugeLevelHash', $level)) {
7129  
7130 # Specfied level has not been created, so as a precaution against buggy code, don't draw
7131 # the gauge
7132 return undef;
7133 }
7134  
7135 # (For other parts of the code, it's more convenient that $self->addGaugeLevel returns the
7136 # gauge level object's unique number, rather than the blessed reference itself. However,
7137 # we need the blessed reference)
7138 $gaugeLevelObj = $self->ivShow('gaugeLevelHash', $level);
7139  
7140 # Apply a check on the maximum number of gauges per level
7141 if ($gaugeLevelObj->ivPairs('gaugeHash') >= $self->gaugeMax) {
7142  
7143 return undef;
7144 }
7145  
7146 # If the gauge box isn't currently visible, draw it
7147 if (! $self->visibleFlag) {
7148  
7149 $self->drawGaugeBox();
7150 $self->winObj->revealStripObj($self);
7151 }
7152  
7153 # If the gauge box was due to be removed because it's been empty too long, we can now keep
7154 # it
7155 $self->ivUndef('gaugeCheckTime');
7156  
7157 # Set default values, translating any colour tags in RGB colour tags
7158 if ($fullColour) {
7159  
7160 $fullColour = $axmud::CLIENT->returnRGBColour($fullColour);
7161 }
7162  
7163 if (! $fullColour) {
7164  
7165 $fullColour = $self->gaugeFullColour;
7166 }
7167  
7168 if ($emptyColour) {
7169  
7170 $emptyColour = $axmud::CLIENT->returnRGBColour($emptyColour);
7171 }
7172  
7173 if (! $emptyColour) {
7174  
7175 $emptyColour = $self->gaugeEmptyColour;
7176 }
7177  
7178 if (! $addFlag) {
7179 $addFlag = FALSE;
7180 } else {
7181 $addFlag = TRUE;
7182 }
7183  
7184 if ($labelColour) {
7185  
7186 $labelColour = $axmud::CLIENT->returnRGBColour($labelColour);
7187 }
7188  
7189 if (! $labelColour) {
7190  
7191 $labelColour = $self->gaugeLabelColour;
7192 }
7193  
7194 if (! $labelFlag) {
7195 $labelFlag = FALSE;
7196 } else {
7197 $labelFlag = TRUE;
7198 }
7199  
7200 # Sanity check: $value and/or $maxValue can be 'undef', but if they're specified, they must
7201 # be a valid floating-point number
7202 if (defined $value && ! $axmud::CLIENT->floatCheck($value)) {
7203  
7204 $value = undef;
7205 }
7206  
7207 if (defined $maxValue && ! $axmud::CLIENT->floatCheck($maxValue)) {
7208  
7209 $maxValue = undef;
7210 }
7211  
7212 # Create a new GA::Obj::Gauge object for this gauge (do this before drawing the gauge,
7213 # because if $session isn't the current session, we don't draw it yet)
7214 # NB The FALSE argument means this is a graphical gauge, not a text gauge
7215 $newObj = Games::Axmud::Obj::Gauge->new(
7216 $session,
7217 $self->ivIncrement('gaugeCount'),
7218 $level,
7219 FALSE,
7220 );
7221  
7222 if (! $newObj) {
7223  
7224 return undef;
7225  
7226 } else {
7227  
7228 $gaugeLevelObj->ivAdd('gaugeHash', $newObj->number, $newObj);
7229  
7230 $newObj->ivPoke('value', $value);
7231 $newObj->ivPoke('maxValue', $maxValue);
7232 $newObj->ivPoke('addFlag', $addFlag);
7233 $newObj->ivPoke('label', $label);
7234  
7235 $newObj->ivPoke('fullColour', $fullColour);
7236 $newObj->ivPoke('emptyColour', $emptyColour);
7237 $newObj->ivPoke('labelColour', $labelColour);
7238 $newObj->ivPoke('labelFlag', $labelFlag);
7239 }
7240  
7241 # If $session is the visible one, redraw all of that session's gauges now
7242 if ($self->winObj->visibleSession && $self->winObj->visibleSession eq $session) {
7243  
7244 $self->updateGauges();
7245 }
7246  
7247 return $newObj;
7248 }
7249  
7250 sub addTextGauge {
7251  
7252 # Can be called by anything
7253 # Adds a new text gauge to the 'main' window's gauge box, visible only when the calling
7254 # GA::Session is the current session. (Graphical gauges are added with a call to
7255 # $self->addGauge)
7256 # If the gauge box itself is not yet visible, draws it
7257 #
7258 # Expected arguments
7259 # $session - The calling GA::Session
7260 #
7261 # Optional arguments
7262 # $level - The unique number of the GA::Obj::GaugeLevel object to use
7263 # (representing a horizontal band of gauges, of which there can be
7264 # 1 or more band within the gauge box). If the $level number has
7265 # not been added via a call to $self->addGaugeLevel, the gauge is not
7266 # drawn (as a precaution against buggy code). However, if 'undef', the
7267 # gauge is added to the first visible level for the specified
7268 # GA::Session; if none exist for the session, one is created for it
7269 # - NB Ideally, anything that displays gauges (such as a task) should
7270 # create its own gauge level via a call to $self->addGaugeLevel
7271 # $value - The value to display (>= 0)...
7272 # $maxValue - ...and the maximum value (must be >= $value). If either $value or
7273 # $maxValue is undefined, the gauge is drawn a different colour than
7274 # usual
7275 # $addFlag - If TRUE, the total size of the gauge is ($value + $maxValue). If
7276 # FALSE (or 'undef'), the total size is $maxValue
7277 # $label - The label to use with the gauge. If 'undef' or an empty string, no
7278 # label is used
7279 #
7280 # Return values
7281 # 'undef' on improper arguments or on failure
7282 # Otherwise returns the GA::Obj::Gauge created to store details about the new gauge
7283  
7284 my ($self, $session, $level, $value, $maxValue, $addFlag, $label, $check) = @_;
7285  
7286 # Local variables
7287 my (
7288 $gaugeLevelObj, $newObj,
7289 @list, @gaugeList,
7290 );
7291  
7292 # Check for improper arguments
7293 if (! defined $session || defined $check) {
7294  
7295 return $axmud::CLIENT->writeImproper($self->_objClass . '->addTextGauge', @_);
7296 }
7297  
7298 if (! defined $level) {
7299  
7300 # If no level was specified, use the first available one. If there are none, create a
7301 # new one
7302 # The first available level is the one with the lowest level number that belongs to
7303 # the calling session
7304 foreach my $gaugeLevelObj ($self->ivValues('gaugeLevelHash')) {
7305  
7306 if (
7307 $gaugeLevelObj->session eq $session
7308 && (
7309 ! defined $level
7310 || $level > $gaugeLevelObj->number
7311 )
7312 ) {
7313 $level = $gaugeLevelObj->number;
7314 }
7315 }
7316  
7317 if (! defined $level) {
7318  
7319 $level = $self->addGaugeLevel($session);
7320 if (! defined $level) {
7321  
7322 return undef;
7323 }
7324 }
7325  
7326 } elsif (! $self->ivExists('gaugeLevelHash', $level)) {
7327  
7328 # Specfied level has not been created, so as a precaution against buggy code, don't draw
7329 # the gauge
7330 return undef;
7331 }
7332  
7333 # (For other parts of the code, it's more convenient that $self->addGaugeLevel returns the
7334 # gauge level object's unique number, rather than the blessed reference itself. However,
7335 # we need the blessed reference)
7336 $gaugeLevelObj = $self->ivShow('gaugeLevelHash', $level);
7337  
7338 # Apply a check on the maximum number of gauges per level
7339 if ($gaugeLevelObj->ivPairs('gaugeHash') >= $self->gaugeMax) {
7340  
7341 return undef;
7342 }
7343  
7344 # If the gauge box isn't currently visible, draw it
7345 if (! $self->visibleFlag) {
7346  
7347 $self->drawGaugeBox();
7348 $self->winObj->revealStripObj($self);
7349 }
7350  
7351 # If the gauge box was due to be removed because it's been empty too long, we can now keep
7352 # it
7353 $self->ivUndef('gaugeCheckTime');
7354  
7355 # Set default values
7356 if (! $addFlag) {
7357 $addFlag = FALSE;
7358 } else {
7359 $addFlag = TRUE;
7360 }
7361  
7362 # Sanity check: $value and/or $maxValue can be 'undef', but if they're specified, they must
7363 # be a valid decimal number
7364 if (defined $value && ! $axmud::CLIENT->floatCheck($value)) {
7365  
7366 $value = undef;
7367 }
7368  
7369 if (defined $maxValue && ! $axmud::CLIENT->floatCheck($maxValue)) {
7370  
7371 $maxValue = undef;
7372 }
7373  
7374 # Create a new GA::Obj::Gauge object for this gauge (do this before drawing the gauge,
7375 # because if $session isn't the current session, we don't draw it yet)
7376 # NB The TRUE argument means this is a text gauge, not a graphical gauge
7377 $newObj = Games::Axmud::Obj::Gauge->new(
7378 $session,
7379 $self->ivIncrement('gaugeCount'),
7380 $level,
7381 TRUE,
7382 );
7383  
7384 if (! $newObj) {
7385  
7386 return undef;
7387  
7388 } else {
7389  
7390 $gaugeLevelObj->ivAdd('gaugeHash', $newObj->number, $newObj);
7391  
7392 $newObj->ivPoke('value', $value);
7393 $newObj->ivPoke('maxValue', $maxValue);
7394 $newObj->ivPoke('addFlag', $addFlag);
7395 $newObj->ivPoke('label', $label);
7396 }
7397  
7398 # If $session is the visible one, redraw all of that session's gauges now
7399 if ($self->winObj->visibleSession && $self->winObj->visibleSession eq $session) {
7400  
7401 $self->updateGauges();
7402 }
7403  
7404 return $newObj;
7405 }
7406  
7407 sub removeGauges {
7408  
7409 # Can be called by anything
7410 # Removes one or more gauges. If the calling GA::Session is the visible one, redraws
7411 # everything in the gauge box. If all gauges have now been removed, sets the time at
7412 # which the gauge box itself is made invisible
7413 #
7414 # Expected arguments
7415 # $session - The calling GA::Session
7416 # $keepLevelFlag - Flag set to TRUE if the gauge level should not be destroyed, if all
7417 # its gauges are removed (probably because the calling code wants to
7418 # add new gauges to it in a moment); set to FALSE if the gauge level
7419 # should be destroyed if all its gauges are removed
7420 #
7421 # Optional arguments
7422 # @objList - A list of GA::Obj::Gauge objects (which don't have to belong to the
7423 # calling GA::Session). If it's an empty list, nothing is removed
7424 #
7425 # Return values
7426 # 'undef' on improper arguments or if we're not allowed to draw gauges at all
7427 # Otherwise returns the number of gauges removed (might be 0)
7428  
7429 my ($self, $session, $keepLevelFlag, @objList) = @_;
7430  
7431 # Local variables
7432 my (
7433 $removeCount, $redrawFlag, $redrawAllFlag,
7434 @drawList,
7435 );
7436  
7437 # Check for improper arguments
7438 if (! defined $session) {
7439  
7440 return $axmud::CLIENT->writeImproper($self->_objClass . '->removeGauges', @_);
7441 }
7442  
7443 # Update registries
7444 $removeCount = 0;
7445 foreach my $gaugeObj (@objList) {
7446  
7447 my $gaugeLevelObj = $self->ivShow('gaugeLevelHash', $gaugeObj->level);
7448  
7449 # Remove the gauge from its gauge level
7450 if ($gaugeLevelObj && $gaugeLevelObj->ivExists('gaugeHash', $gaugeObj->number)) {
7451  
7452 $gaugeLevelObj->ivDelete('gaugeHash', $gaugeObj->number);
7453 $removeCount++;
7454  
7455 # If the calling GA::Session is the visible one, redraw everything in the gauge
7456 # box
7457 if (
7458 $self->winObj->visibleSession
7459 && $self->winObj->visibleSession eq $session
7460 && $gaugeObj->session eq $session
7461 ) {
7462 $redrawFlag = TRUE;
7463  
7464 # If the gauge level is now empty, remove it (unless the calling function told
7465 # us not to do that)
7466 if (! $keepLevelFlag && ! $gaugeLevelObj->gaugeHash) {
7467  
7468 $self->ivDelete('gaugeLevelHash', $gaugeLevelObj->number);
7469 $redrawAllFlag = TRUE;
7470 }
7471 }
7472 }
7473 }
7474  
7475 # Redraw widgets, as required
7476 if ($redrawAllFlag) {
7477  
7478 # Redraw the gauge box as the right size (even if it contains no gauges at this precise
7479 # moment)
7480 $self->drawGaugeBox();
7481 $self->winObj->replaceStripObj($self);
7482  
7483 } elsif ($redrawFlag) {
7484  
7485 # Redraw the gauges themselves
7486 $self->updateGauges();
7487 }
7488  
7489 # If there are no gauges left (in any session), set the time (shortly in the future) when
7490 # the gauge box will be removed entirely, if no new gauges have been drawn in the mean
7491 # time
7492 if ($redrawFlag || $redrawAllFlag) {
7493  
7494 if (! $self->gaugeLevelHash) {
7495  
7496 $self->ivPoke(
7497 'gaugeCheckTime',
7498 ($axmud::CLIENT->clientTime + $self->gaugeWaitTime),
7499 );
7500 }
7501 }
7502  
7503 return $removeCount;
7504 }
7505  
7506 sub removeSessionGauges {
7507  
7508 # Can be called by anything
7509 # Complementing $self->removeGauges, this is a short-cut which removes all gauges for a
7510 # particular session, without the need for the calling function to specify the gauges
7511 # to remove
7512 # (If the specified session isn't this window's visible session, then no visible gauges are
7513 # removed, but IVs are still updated)
7514 #
7515 # Expected arguments
7516 # $session - The GA::Session whose gauges should be removed
7517 #
7518 # Optional arguments
7519 # $boxFlag - Set to TRUE when called by GA::Session->reactDisconnect. If there are
7520 # no gauges left, the 'main' window code normally waits a few seconds
7521 # before removing the gauge box. However, that won't work if the only
7522 # session has just disconnected, as its timer loop has terminated.
7523 # When the flag is TRUE, the gauge box is removed immediately. Set to
7524 # FALSE (or 'undef') otherwise
7525 #
7526 # Return values
7527 # 'undef' on improper arguments or if we're not allowed to draw gauges at all
7528 # Otherwise returns the number of gauges removed (might be 0)
7529  
7530 my ($self, $session, $boxFlag, $check) = @_;
7531  
7532 # Local variables
7533 my (
7534 $result,
7535 @removeList,
7536 );
7537  
7538 # Check for improper arguments
7539 if (! defined $session || defined $check) {
7540  
7541 return $axmud::CLIENT->writeImproper($self->_objClass . '->removeSessionGauges', @_);
7542 }
7543  
7544 # Get a list of gauges belonging to the specified session
7545 foreach my $gaugeLevelObj ($self->ivValues('gaugeLevelHash')) {
7546  
7547 if ($gaugeLevelObj->session eq $session) {
7548  
7549 push (@removeList, $gaugeLevelObj->ivValues('gaugeHash'));
7550 }
7551 }
7552  
7553 # The FALSE argument means 'don't keep an empty gauge level'
7554 $result = $self->removeGauges($session, FALSE, @removeList);
7555  
7556 # Remove the gauge box immediately, if instructed
7557 if (! $self->gaugeLevelHash && $boxFlag) {
7558  
7559 $self->removeGaugeBox();
7560 }
7561  
7562 return $result;
7563 }
7564  
7565 sub updateGauges {
7566  
7567 # Can be called by anything
7568 # Updates the gauges currently drawn in the gauge box, redrawing them. If this window's
7569 # visible session has changed, a new set of gauges is drawn, replacing the previous ones
7570 #
7571 # Expected arguments
7572 # (none besides $self)
7573 #
7574 # Return values
7575 # 'undef' on improper arguments
7576 # 1 otherwise
7577  
7578 my ($self, $check) = @_;
7579  
7580 # Local variables
7581 my (
7582 $result,
7583 @drawList,
7584 );
7585  
7586 # Check for improper arguments
7587 if (defined $check) {
7588  
7589 return $axmud::CLIENT->writeImproper($self->_objClass . '->updateGauges', @_);
7590 }
7591  
7592 # Do nothing if the gauge box isn't actually visible (because no gauges have been drawn by
7593 # any session), or if another call to this function is still being processed
7594 if (! $self->visibleFlag || $self->gaugeUpdateFlag) {
7595 return undef;
7596 } else {
7597 $self->ivPoke('gaugeUpdateFlag', TRUE);
7598 }
7599  
7600 # If a recent call to $self->addGaugeLevel specified that the gauge box shouldn't be
7601 # redrawn yet, then redraw it now
7602 if ($self->gaugeNoDrawFlag) {
7603  
7604 $self->drawGaugeBox();
7605 $self->winObj->replaceStripObj($self);
7606 $self->ivPoke('gaugeNoDrawFlag', FALSE);
7607 }
7608  
7609 # Compile an ordered list of gauges that should be visible (so that gauge levels and gauges
7610 # are always drawn in the same order)
7611 foreach my $gaugeLevelObj (
7612 sort {$a->number <=> $b->number} ($self->ivValues('gaugeLevelHash'))
7613 ) {
7614 if (
7615 $self->winObj->visibleSession
7616 && $self->winObj->visibleSession eq $gaugeLevelObj->session
7617 ) {
7618 push (
7619 @drawList,
7620 sort {$a->number <=> $b->number} ($gaugeLevelObj->ivValues('gaugeHash')),
7621 );
7622 }
7623 }
7624  
7625 $result = $self->drawGauges(@drawList);
7626 # Subsequent calls to this function are now allowed again
7627 $self->ivPoke('gaugeUpdateFlag', FALSE);
7628  
7629 return $result;
7630 }
7631  
7632 sub drawGauges {
7633  
7634 # Called by $self->updateGauges or ->removeGauges (but not by any other code)
7635 # Draws 0, 1 or more gauges in the gauge box, destroying any canvas objects that were drawn
7636 # on the previous call to this function
7637 # The calling function should ensure that only the current session's gauges are specified
7638 # as arguments, and that all gauges belonging to that session are specified
7639 #
7640 # Expected arguments
7641 # (none besides $self)
7642 #
7643 # Optional arguments
7644 # @drawList - A list of GA::Obj::Gauge objects (which must belong to the current
7645 # GA::Session). If it's an empty list, no new gauges are drawn
7646 #
7647 # Return values
7648 # 'undef' on improper arguments
7649 # 1 otherwise
7650  
7651 my ($self, @drawList) = @_;
7652  
7653 # Local variables
7654 my (
7655 $root, $visLevel, $count,
7656 @canvasObjList,
7657 %levelHash, %widthHash, %checkHash,
7658 );
7659  
7660 # (No improper arguments to check)
7661  
7662 # Destroy any existing canvas objects
7663 foreach my $canvasObj ($self->gaugeCanvasList) {
7664  
7665 $canvasObj->remove;
7666 }
7667  
7668 $self->ivEmpty('gaugeCanvasList');
7669  
7670 # If there are no gauges to be drawn, end here
7671 # Also, don't try to draw gauges in a very small space
7672 if (! @drawList || $self->canvasFrameWidth < 100) {
7673  
7674 return undef;
7675 }
7676  
7677 # Reset the size of the canvas
7678 $self->canvas->set_bounds(
7679 0,
7680 0,
7681 $self->canvasFrameWidth,
7682 $self->canvasFrameHeight,
7683 );
7684  
7685 # Sort the gauges first by level, and then by the order they were created, so they are
7686 # always drawn in the same order, top to bottom and then left to right
7687 @drawList = sort {
7688  
7689 if ($a->level != $b->level) {
7690 $a->level <=> $b->level
7691 } else {
7692 $a->number <=> $b->number
7693 }
7694  
7695 } (@drawList);
7696  
7697 # Count the number of gauges for each level...
7698 foreach my $gaugeObj (@drawList) {
7699  
7700 if (! exists ($levelHash{$gaugeObj->level})) {
7701 $levelHash{$gaugeObj->level} = 1;
7702 } else {
7703 $levelHash{$gaugeObj->level} += 1;
7704 }
7705 }
7706  
7707 # ...and then work out the gauge width for each level. Every gauge on the same level should
7708 # be the same width. We leave $self->gaugeSpacingX pixels clear on one end of the gauge
7709 # box, and $self->gaugeSpacingX pixels clear at the opposite end of each gauge we draw, so
7710 # they appear equally-spaced
7711 foreach my $level (keys %levelHash) {
7712  
7713 $widthHash{$level}
7714 = int(($self->canvasFrameWidth - $self->gaugeSpacingX) / ($levelHash{$level}));
7715 }
7716  
7717 # Draw each gauge in turn
7718 $root = $self->canvas->get_root_item();
7719 $visLevel = -1;
7720  
7721 foreach my $gaugeObj (@drawList) {
7722  
7723 my (
7724 $blankFlag, $ratio, $w, $corrW, $f, $e, $x1, $x2, $x3, $x4, $l, $y1, $y2, $obj,
7725 $lText, $lCol,
7726 );
7727  
7728 if (! exists $checkHash{$gaugeObj->level}) {
7729  
7730 # First gauge drawn on this level
7731 $count = 0;
7732 $checkHash{$gaugeObj->level} = undef;
7733 $visLevel++;
7734  
7735 } else {
7736  
7737 # Not the first
7738 $count++;
7739 }
7740  
7741 if (! $gaugeObj->textFlag) {
7742  
7743 # How full/empty is the gauge?
7744 if (
7745 ! defined $gaugeObj->value
7746 || ! $axmud::CLIENT->floatCheck($gaugeObj->value)
7747 || ! defined $gaugeObj->maxValue
7748 || ! $axmud::CLIENT->floatCheck($gaugeObj->maxValue)
7749 ) {
7750 # If either value is not defined, or if the values aren't numerical (for some
7751 # reason), then draw the gauge a different colour
7752 $blankFlag = TRUE;
7753 $ratio = 0;
7754  
7755 } elsif ($gaugeObj->maxValue <= 0 && $gaugeObj->value > 0) {
7756  
7757 # The value is bigger than the maximum value, for some reason. Draw the gauge as
7758 # full
7759 $ratio = 1;
7760  
7761 } elsif ($gaugeObj->value <= 0 || $gaugeObj->maxValue <= 0) {
7762  
7763 # Otherwise, if either value is 0, gauge should definitely be drawn empty (and
7764 # this also avoids division by zero in the next code block)
7765 $ratio = 0;
7766  
7767 } else {
7768  
7769 if (! $gaugeObj->addFlag) {
7770 $ratio = $gaugeObj->value / $gaugeObj->maxValue;
7771 } else {
7772 $ratio = $gaugeObj->value / ($gaugeObj->value + $gaugeObj->maxValue);
7773 }
7774 }
7775  
7776 # (Sanity check)
7777 if ($ratio > 1) {
7778  
7779 $ratio = 1;
7780 }
7781 }
7782  
7783 # Total gauge width
7784 $w = $widthHash{$gaugeObj->level};
7785 # Edge correction - if this gauge is almost at the far right side of the gauge box, but
7786 # not quite (because of rounding errors introduced by int() in the setting of $f),
7787 # make it a bit larger, so as to fill the whole gauge box
7788 $corrW = $w;
7789 $x4 = $w * ($count + 1);
7790 if (
7791 $x4 < ($self->canvasFrameWidth - $self->gaugeSpacingX)
7792 && $x4 >= ($self->canvasFrameWidth - $self->gaugeSpacingX - $count)
7793 ) {
7794 $corrW += $self->canvasFrameWidth - $self->gaugeSpacingX - ($w * ($count + 1));
7795 }
7796  
7797 if (! $gaugeObj->textFlag) {
7798  
7799 # Full/empty widths
7800 $f = int(($corrW - $self->gaugeSpacingX) * $ratio);
7801 $e = $w - $f;
7802  
7803 # Full gauge portion
7804 $x1 = $self->gaugeSpacingX + ($count * $w) - 2;
7805 $x2 = $x1 + $f;
7806 # Empty gauge portion
7807 $x3 = $x2; # By moving $x3 1 pixel left, we avoid double black line
7808 $x4 = $x1 + $corrW - $self->gaugeSpacingX;
7809  
7810 # Special case: if the ratio is very close to 0 (but not enough to draw a pixel in
7811 # the 'full' portion of the gauge), then draw at least one pixel
7812 # (Actually, we need $x2 to be at least 2 pixels bigger than $x1, otherwise only the
7813 # border of the 'full' portion of the gauge is visible
7814 if ($ratio > 0 && ($x2 - $x1) <= 1) {
7815  
7816 $x2 = $x3 = $x1 + 2;
7817  
7818 # Likewise, if the ratio is very close to 1 (but not enough to draw a pixel in the
7819 # 'empty' portion of the gauge), then draw at least one pixel
7820 } elsif ($ratio < 1 && ($x4 - $x3) <= 1) {
7821  
7822 $x2 = $x3 = $x4 - 2;
7823 }
7824  
7825 # Vertical position depends only on the level, and is the same for both portions
7826 # (NB the visible level isn't necessarily the same as the GA::Obj::GaugeLevel
7827 # object's unique number)
7828 $y1 = $self->gaugeSpacingY
7829 + ($visLevel * ($self->gaugeHeight + $self->gaugeSpacingY));
7830 $y2 = $y1 + $self->gaugeHeight - 1;
7831  
7832 if ($blankFlag) {
7833  
7834 # Draw a blank gauge, because one or more values are unspecified (the labels are
7835 # still drawn, though)
7836 $obj = GooCanvas2::CanvasRect->new(
7837 'parent' => $root,
7838 'x' => $x1,
7839 'y' => $y1,
7840 'width' => ($x4 - $x1 + 1),
7841 'height' => ($y2 - $y1 + 1),
7842 'radius-x' => $self->gaugeCorner,
7843 'radius-y' => $self->gaugeCorner,
7844 'line-width' => 1,
7845 'stroke-color' => $self->gaugeBorderColour,
7846 'fill-color' => $self->gaugeBlankColour,
7847 );
7848  
7849 $obj->raise();
7850 push (@canvasObjList, $obj);
7851  
7852 } else {
7853  
7854 # Full gauge portion (don't draw, if empty)
7855 if (($x2 - $x1 + 1) > 1) {
7856  
7857 $obj = GooCanvas2::CanvasRect->new(
7858 'parent' => $root,
7859 'x' => $x1,
7860 'y' => $y1,
7861 'width' => ($x2 - $x1 + 1),
7862 'height' => ($y2 - $y1 + 1),
7863 'radius-x' => $self->gaugeCorner,
7864 'radius-y' => $self->gaugeCorner,
7865 'line-width' => 1,
7866 'stroke-color' => $self->gaugeBorderColour,
7867 'fill-color' => $gaugeObj->fullColour,
7868 );
7869  
7870 $obj->raise();
7871 push (@canvasObjList, $obj);
7872 }
7873  
7874 # Empty gauge portion (don't draw, if empty)
7875 if (($x4 - $x3 + 1) > 1) {
7876  
7877 $obj = GooCanvas2::CanvasRect->new(
7878 'parent' => $root,
7879 'x' => $x3,
7880 'y' => $y1,
7881 'width' => ($x4 - $x3 + 1),
7882 'height' => ($y2 - $y1 + 1),
7883 'radius-x' => $self->gaugeCorner,
7884 'radius-y' => $self->gaugeCorner,
7885 'line-width' => 1,
7886 'stroke-color' => $self->gaugeBorderColour,
7887 'fill-color' => $gaugeObj->emptyColour,
7888 );
7889  
7890 $obj->raise();
7891 push (@canvasObjList, $obj);
7892 }
7893 }
7894  
7895 # Draw a label over the gauge, if one is specified
7896 if ($gaugeObj->label) {
7897  
7898 if (! $gaugeObj->labelFlag) {
7899  
7900 $lText = $gaugeObj->label;
7901  
7902 } else {
7903  
7904 $lText = $gaugeObj->label . ': ';
7905 if (! defined $gaugeObj->value) {
7906 $lText .= '?';
7907 } else {
7908 $lText .= $gaugeObj->value;
7909 }
7910  
7911 if ($gaugeObj->addFlag) {
7912 $lText .= '-';
7913 } else {
7914 $lText .= '/';
7915 }
7916  
7917 if (! defined $gaugeObj->maxValue) {
7918 $lText .= '?';
7919 } else {
7920 $lText .= $gaugeObj->maxValue;
7921 }
7922 }
7923  
7924 if ($blankFlag) {
7925 $lCol = $self->gaugeLabelColour;
7926 } else {
7927 $lCol = $gaugeObj->labelColour;
7928 }
7929  
7930 $obj = GooCanvas2::CanvasText->new(
7931 'parent' => $root,
7932 # 'anchor' => 'nw',
7933 'x' => $x1 + $self->gaugeSpacingX,
7934 'y' => $y1,
7935 'font' => $self->gaugeLabelFont . ' ' . $self->gaugeLabelFontSize,
7936 'use-markup' => FALSE,
7937 'text' => $lText,
7938 'width' => -1,
7939 'fill-color' => $lCol,
7940 );
7941  
7942 $obj->raise();
7943 push (@canvasObjList, $obj);
7944 }
7945  
7946 } else {
7947  
7948 # Text gauges use the full available width
7949 $x1 = $self->gaugeSpacingX + ($count * $w);
7950 $y1 = $self->gaugeSpacingY
7951 + ($visLevel * ($self->gaugeHeight + $self->gaugeSpacingY));
7952  
7953 $lText = '';
7954 if ($gaugeObj->label) {
7955  
7956 $lText .= $gaugeObj->label . ': ';
7957 }
7958  
7959 if (! defined $gaugeObj->value) {
7960 $lText .= '?';
7961 } else {
7962 $lText .= $gaugeObj->value;
7963 }
7964  
7965 # (Don't show a maximum value if the world isn't supplying one)
7966 if (defined $gaugeObj->maxValue) {
7967  
7968 if ($gaugeObj->addFlag) {
7969 $lText .= '-';
7970 } else {
7971 $lText .= '/';
7972 }
7973  
7974 $lText .= $gaugeObj->maxValue;
7975 }
7976  
7977 $obj = GooCanvas2::CanvasText->new(
7978 'parent' => $root,
7979 # 'anchor' => 'nw',
7980 'x' => $x1,
7981 'y' => $y1,
7982 'font' => $self->gaugeLabelFont . ' ' . $self->gaugeLabelFontSize,
7983 'use-markup' => FALSE,
7984 'text' => $lText,
7985 'width' => -1,
7986 # 'fill-color' => $lCol,
7987 );
7988  
7989 $obj->raise();
7990 push (@canvasObjList, $obj);
7991 }
7992 }
7993  
7994 # Store the canvas objects drawn, so they can be destroyed on the next call to this
7995 # function
7996 $self->ivPoke('gaugeDrawnList', @drawList);
7997 $self->ivPoke('gaugeCanvasList', @canvasObjList);
7998  
7999 return 1;
8000 }
8001  
8002 ##################
8003 # Accessors - set
8004  
8005 ##################
8006 # Accessors - get
8007  
8008 sub frame
8009 { $_[0]->{frame} }
8010 sub canvas
8011 { $_[0]->{canvas} }
8012 sub gaugeCanvasList
8013 { my $self = shift; return @{$self->{gaugeCanvasList}}; }
8014  
8015 sub canvasFrameWidth
8016 { $_[0]->{canvasFrameWidth} }
8017 sub canvasFrameHeight
8018 { $_[0]->{canvasFrameHeight} }
8019  
8020 sub gaugeHeight
8021 { $_[0]->{gaugeHeight} }
8022 sub gaugeCorner
8023 { $_[0]->{gaugeCorner} }
8024 sub gaugeSpacingX
8025 { $_[0]->{gaugeSpacingX} }
8026 sub gaugeSpacingY
8027 { $_[0]->{gaugeSpacingY} }
8028 sub gaugeLabelFont
8029 { $_[0]->{gaugeLabelFont} }
8030 sub gaugeLabelFontSize
8031 { $_[0]->{gaugeLabelFontSize} }
8032 sub gaugeLevelHash
8033 { my $self = shift; return %{$self->{gaugeLevelHash}}; }
8034 sub gaugeLevelCount
8035 { $_[0]->{gaugeLevelCount} }
8036 sub gaugeLevelMax
8037 { $_[0]->{gaugeLevelMax} }
8038 sub gaugeCount
8039 { $_[0]->{gaugeCount} }
8040 sub gaugeMax
8041 { $_[0]->{gaugeMax} }
8042 sub gaugeDrawnList
8043 { my $self = shift; return @{$self->{gaugeDrawnList}}; }
8044 sub gaugeUpdateFlag
8045 { $_[0]->{gaugeUpdateFlag} }
8046 sub gaugeBlankColour
8047 { $_[0]->{gaugeBlankColour} }
8048 sub gaugeEmptyColour
8049 { $_[0]->{gaugeEmptyColour} }
8050 sub gaugeFullColour
8051 { $_[0]->{gaugeFullColour} }
8052 sub gaugeLabelColour
8053 { $_[0]->{gaugeLabelColour} }
8054 sub gaugeBorderColour
8055 { $_[0]->{gaugeBorderColour} }
8056 sub gaugeCheckTime
8057 { $_[0]->{gaugeCheckTime} }
8058 sub gaugeWaitTime
8059 { $_[0]->{gaugeWaitTime} }
8060 sub gaugeNoDrawFlag
8061 { $_[0]->{gaugeNoDrawFlag} }
8062 }
8063  
8064 { package Games::Axmud::Strip::SearchBox;
8065  
8066 use strict;
8067 use warnings;
8068 use diagnostics;
8069  
8070 use Glib qw(TRUE FALSE);
8071  
8072 our @ISA = qw(Games::Axmud::Generic::Strip Games::Axmud);
8073  
8074 ##################
8075 # Constructors
8076  
8077 sub new {
8078  
8079 # Called by GA::Win::Internal->drawWidgets or ->addStripObj
8080 # Creates the GA::Strip::SearchBox - a non-compulsory strip object optionally containing
8081 # widgets for searching text in the window's current pane
8082 #
8083 # Expected arguments
8084 # $number - The strip object's number within the parent window (matches
8085 # GA::Win::Internal->stripCount, or -1 for a temporary strip object
8086 # created to access its default IVs)
8087 # $winObj - The parent window object (GA::Win::Internal). 'temp' for temporary strip
8088 # objects
8089 #
8090 # Optional arguments
8091 # %initHash - A hash containing arbitrary data to use as the strip object's
8092 # initialisation settings. The strip object should use default
8093 # initialisation settings unless it can succesfully interpret one or more
8094 # of the key-value pairs in the hash, if there are any
8095 # - (This type of strip object requires no initialisation settings)
8096 #
8097 # Return values
8098 # 'undef' on improper arguments
8099 # Blessed reference to the newly-created object on success
8100  
8101 my ($class, $number, $winObj, %initHash) = @_;
8102  
8103 # Local variables
8104 my %modHash;
8105  
8106 # Check for improper arguments
8107 if (! defined $class || ! defined $number || ! defined $winObj) {
8108  
8109 return $axmud::CLIENT->writeImproper($class . '->new', @_);
8110 }
8111  
8112 # Setup
8113 my $self = {
8114 _objName => 'strip_' . $number,
8115 _objClass => $class,
8116 _parentFile => undef, # No parent file object
8117 _parentWorld => undef, # No parent file object
8118 _privFlag => TRUE, # All IVs are private
8119  
8120 # Standard strip object IVs
8121 # -------------------------
8122  
8123 # The strip object's number within the parent window (matches
8124 # GA::Win::Internal->stripCount, or -1 for a temporary strip object created to access
8125 # its default IVs)
8126 number => $number,
8127 # The type of strip object (custom strip objects should use a ->type starting with
8128 # 'custom_' to avoid clashing with future built-in strip objects)
8129 type => 'search_box',
8130 # The parent window object (GA::Win::Internal). 'temp' for temporary strip objects
8131 winObj => $winObj,
8132  
8133 # Flag set to TRUE if the strip object is visible (has actually drawn widgets in the
8134 # window), set to FALSE if it is not visible (has drawn no widgets in the window, but
8135 # still exists in GA::Win::Internal->stripHash, etc)
8136 # The flag might be set to FALSE in strip objects like GA::Strip::GaugeBox, which might
8137 # have gauges to draw, or not, depending on current conditions. (Most strip objects
8138 # have this flag set to TRUE all the time)
8139 # If FALSE, GA::Win::Internal->drawWidgets and ->addStripObj don't draw any widgets when
8140 # called by this object's functions
8141 # NB Strip objects are created with this flag set to TRUE or FALSE, but once created,
8142 # the flag's value shouldn't be modified by anything other than
8143 # GA::Win::Internal->hideStripObj and ->revealStripObj (which in turn call
8144 # $self->set_visibleFlag)
8145 visibleFlag => FALSE, # Wait until the search box needs to be drawn
8146 # Flag set to TRUE is the strip object should be given its share of any extra space
8147 # within the packing box (the extra space is divided equally between all children of
8148 # the box whose ->expandFlag is TRUE)
8149 expandFlag => FALSE,
8150 # Flag set to TRUE if any space given to the strip object by the 'expand' option is
8151 # actually allocated within the strip object, FALSE if it is used as padding outside
8152 # it (on both sides)
8153 fillFlag => TRUE, # Force canvas to use available width
8154 # Flag set to TRUE if the strip object should be packed into its window with a small
8155 # gap between strip objects to either side; FALSE if not (can be set to FALSE if the
8156 # the strip object's widgets are drawn in a way, such that a gap is not necessary,
8157 # for example in the toolbar strip object)
8158 spacingFlag => TRUE,
8159 # Flag set to TRUE if only one instance of this strip object should be added to the
8160 # parent window, set to FALSE if any number of instances can be added
8161 jealousyFlag => TRUE,
8162 # Flag set to TRUE if this strip object can be added when $axmud::BLIND_MODE_FLAG is
8163 # TRUE, FALSE if it can't be added (because it's not useful for visually-impaired
8164 # users)
8165 blindFlag => FALSE,
8166 # Flag set to TRUE if the main container widget, stored in $self->packingBox, should be
8167 # allowed to accept the focus, FALSE if not. The restriction is applied during the
8168 # call to GA::Win::Internal->drawWidgets and ->addStripObj. Even if FALSE, widgets in
8169 # the container widget can be set to accept the focus (e.g. the Gtk3::Entry in
8170 # GA::Strip::MenuBar)
8171 allowFocusFlag => FALSE,
8172  
8173 # Initialisation settings stored as a hash (see the comments above)
8174 initHash => \%modHash,
8175 # Reference to a function to call when some widget is used. This IV is set only when
8176 # required by this type of strip object. It can be set by a call to
8177 # $self->set_func() or by some setting in $self->initHash, which is applied in the
8178 # call to $self->objEnable(). To obtain a reference to an OOP method, you can use the
8179 # generic object function Games::Axmud->getMethodRef()
8180 funcRef => undef,
8181 # A value passed to ->funcRef when it is called which identifies this strip object and
8182 # its widget(s). Can be any value, including 'undef'. It can be set by a call to
8183 # $self->set_id() or by some setting in $self->initHash, which is applied in the call
8184 # to $self->objEnable()
8185 funcID => undef,
8186  
8187 # The container widget for this strip object (usually a Gtk3::HBox or Gtk3::VBox). This
8188 # widget is the one added to the window's main Gtk3::HBox or Gtk3::VBox
8189 packingBox => undef, # Gtk3::VBox
8190  
8191 # Other IVs
8192 # ---------
8193  
8194 # Widgets
8195 findEntry => undef, # Gtk3::Entry
8196 prevButton => undef, # Gtk3::Button
8197 nextButton => undef, # Gtk3::Button
8198 resetButton => undef, # Gtk3::Button
8199 caseButton => undef, # Gtk3::ToggleButton
8200 regexButton => undef, # Gtk3::ToggleButton
8201 splitButton => undef, # Gtk3::ToggleButton
8202  
8203 # Flags set to TRUE when the 'Case senstive', 'Use regex' and 'Split screen' buttons are
8204 # selected, FALSE when they are not selected
8205 caseFlag => FALSE,
8206 regexFlag => FALSE,
8207 splitFlag => FALSE,
8208  
8209 # The number of the textview object (GA::Obj::TextView) that was last search; required
8210 # in case the window's current pane is changed (when the user clicks a button in the
8211 # entry strip object)
8212 textViewNum => undef,
8213 };
8214  
8215 # Bless the object into existence
8216 bless $self, $class;
8217  
8218 return $self;
8219 }
8220  
8221 ##################
8222 # Methods
8223  
8224 # Standard strip object functions
8225  
8226 sub objEnable {
8227  
8228 # Called by GA::Win::Internal->drawWidgets or ->addStripObj
8229 # Sets up the strip object's widgets
8230 #
8231 # Expected arguments
8232 # $winmapObj - The winmap object (GA::Obj::Winmap) that specifies the layout of the
8233 # parent window
8234 #
8235 # Return values
8236 # 'undef' on improper arguments
8237 # 1 on success
8238  
8239 my ($self, $winmapObj, $check) = @_;
8240  
8241 # Check for improper arguments
8242 if (! defined $winmapObj || defined $check) {
8243  
8244 return $axmud::CLIENT->writeImproper($self->_objClass . '->objEnable', @_);
8245 }
8246  
8247 # (IVs normally updated here are updated by $self->drawSearchBox, when it is called)
8248  
8249 return 1;
8250 }
8251  
8252 # sub objDestroy {} # Inherited from GA::Generic::Strip
8253  
8254 # sub setWidgetsIfSession {} # Inherited from GA::Generic::Strip
8255  
8256 # sub setWidgetsChangeSession {} # Inherited from GA::Generic::Strip
8257  
8258 # ->signal_connects
8259  
8260 # Other functions
8261  
8262 sub drawSearchBox {
8263  
8264 # Called by $self->toggleBox
8265 # Draws a Gtk3::HBox to contain various widgets
8266 #
8267 # Expected arguments
8268 # (none besides $self)
8269 #
8270 # Return values
8271 # 'undef' on improper arguments
8272 # 1 otherwise
8273  
8274 my ($self, $check) = @_;
8275  
8276 # Check for improper arguments
8277 if (defined $check) {
8278  
8279 return $axmud::CLIENT->writeImproper($self->_objClass . '->drawSearchBox', @_);
8280 }
8281  
8282 # Create a packing box
8283 my $packingBox = Gtk3::HBox->new(FALSE, 0);
8284 $packingBox->set_border_width(0);
8285  
8286 # Add some widgets for performing searches
8287 my $findLabel = Gtk3::Label->new();
8288 $packingBox->pack_start($findLabel, FALSE, FALSE, 5);
8289 $findLabel->set_markup('Find:');
8290  
8291 my $findEntry = Gtk3::Entry->new();
8292 $packingBox->pack_start($findEntry, TRUE, TRUE, 5);
8293 # ->signal_connects appear below
8294  
8295 my $prevButton = Gtk3::ToolButton->new(
8296 Gtk3::Image->new_from_file(
8297 $axmud::SHARE_DIR . $axmud::CLIENT->constUpIconPath,
8298 ),
8299 'Previous match',
8300 );
8301 $packingBox->pack_start($prevButton, FALSE, FALSE, 0);
8302 $prevButton->set_tooltip_text('Previous match');
8303 $prevButton->set_sensitive(FALSE);
8304 $prevButton->signal_connect('clicked' => sub {
8305  
8306 $self->doSearch(FALSE);
8307 });
8308  
8309 my $nextButton = Gtk3::ToolButton->new(
8310 Gtk3::Image->new_from_file(
8311 $axmud::SHARE_DIR . $axmud::CLIENT->constDownIconPath,
8312 ),
8313 'Next match',
8314 );
8315 $packingBox->pack_start($nextButton, FALSE, FALSE, 0);
8316 $nextButton->set_tooltip_text('Next match');
8317 $nextButton->set_sensitive(FALSE);
8318 $nextButton->signal_connect('clicked' => sub {
8319  
8320 $self->doSearch(TRUE);
8321 });
8322  
8323 my $separator = Gtk3::SeparatorToolItem->new();
8324 $packingBox->pack_start($separator, FALSE, FALSE, 0);
8325  
8326 my $resetButton = Gtk3::ToolButton->new(
8327 Gtk3::Image->new_from_file(
8328 $axmud::SHARE_DIR . $axmud::CLIENT->constResetIconPath,
8329 ),
8330 'Reset search box',
8331 );
8332 $packingBox->pack_start($resetButton, FALSE, FALSE, 0);
8333 $resetButton->set_tooltip_text('Reset search box');
8334 $resetButton->set_sensitive(FALSE);
8335 $resetButton->signal_connect('clicked' => sub {
8336  
8337 $self->doReset();
8338 });
8339  
8340 my $separator2 = Gtk3::SeparatorToolItem->new();
8341 $packingBox->pack_start($separator2, FALSE, FALSE, 0);
8342  
8343 my $caseButton = Gtk3::ToggleButton->new();
8344 $packingBox->pack_start($caseButton, FALSE, FALSE, 0);
8345 $caseButton->set_image(
8346 Gtk3::Image->new_from_file(
8347 $axmud::SHARE_DIR . $axmud::CLIENT->constCaseIconPath,
8348 )
8349 );
8350 $caseButton->set_tooltip_text('Case-sensitive searches');
8351 if ($self->caseFlag) {
8352  
8353 $caseButton->set_active(TRUE);
8354 }
8355 $caseButton->signal_connect('toggled' => sub {
8356  
8357 if (! $caseButton->get_active()) {
8358 $self->ivPoke('caseFlag', FALSE);
8359 } else {
8360 $self->ivPoke('caseFlag', TRUE);
8361 }
8362 });
8363  
8364 my $regexButton = Gtk3::ToggleButton->new();
8365 $packingBox->pack_start($regexButton, FALSE, FALSE, 0);
8366 $regexButton->set_image(
8367 Gtk3::Image->new_from_file(
8368 $axmud::SHARE_DIR . $axmud::CLIENT->constRegexIconPath,
8369 )
8370 );
8371 $regexButton->set_tooltip_text('Use patterns/regular expressions');
8372 if ($self->regexFlag) {
8373  
8374 $regexButton->set_active(TRUE);
8375 }
8376 $regexButton->signal_connect('toggled' => sub {
8377  
8378 if (! $regexButton->get_active()) {
8379 $self->ivPoke('regexFlag', FALSE);
8380 } else {
8381 $self->ivPoke('regexFlag', TRUE);
8382 }
8383 });
8384  
8385 my $splitButton = Gtk3::ToggleButton->new();
8386 $packingBox->pack_start($splitButton, FALSE, FALSE, 0);
8387 $splitButton->set_image(
8388 Gtk3::Image->new_from_file(
8389 $axmud::SHARE_DIR . $axmud::CLIENT->constDivideIconPath,
8390 )
8391 );
8392 $splitButton->set_tooltip_text('Split screen after a search');
8393 if ($self->splitFlag) {
8394  
8395 $splitButton->set_active(TRUE);
8396 }
8397 $splitButton->signal_connect('toggled' => sub {
8398  
8399 $self->toggleSplit($splitButton->get_active());
8400 });
8401  
8402 # ->signal_connects from above
8403 $findEntry->signal_connect('activate' => sub {
8404  
8405 # (Same as clicking the 'Previous' button)
8406 $findEntry->grab_focus();
8407 $self->doSearch(FALSE);
8408 });
8409 $findEntry->signal_connect('changed' => sub {
8410  
8411 my $text = $findEntry->get_text();
8412  
8413 if ($text eq '') {
8414  
8415 $prevButton->set_sensitive(FALSE);
8416 $nextButton->set_sensitive(FALSE);
8417 $resetButton->set_sensitive(FALSE);
8418  
8419 } else {
8420  
8421 $prevButton->set_sensitive(TRUE);
8422 $nextButton->set_sensitive(TRUE);
8423 $resetButton->set_sensitive(TRUE);
8424 }
8425 });
8426  
8427 # Update IVs
8428 $self->ivPoke('packingBox', $packingBox);
8429 $self->ivPoke('findEntry', $findEntry);
8430 $self->ivPoke('prevButton', $prevButton);
8431 $self->ivPoke('nextButton', $nextButton);
8432 $self->ivPoke('resetButton', $resetButton);
8433 $self->ivPoke('caseButton', $caseButton);
8434 $self->ivPoke('regexButton', $regexButton);
8435 $self->ivPoke('splitButton', $splitButton);
8436 # Previous searches are not relevant
8437 $self->ivUndef('textViewNum');
8438  
8439 # Setup complete
8440 return 1;
8441 }
8442  
8443 sub doSearch {
8444  
8445 # Called by various ->signal_connects in $self->drawSearchBox
8446 # Checks that the entry box contains some text and, if so, performs a search
8447 #
8448 # Expected arguments
8449 # $nextFlag - FALSE to search backwards in a textview object; TRUE to search forwards
8450 # in a textview
8451 #
8452 # Return values
8453 # 'undef' on improper arguments or if the user hasn't entered any text in the entry box
8454 # 1 otherwise
8455  
8456 my ($self, $nextFlag, $check) = @_;
8457  
8458 # Local variables
8459 my ($text, $entryStripObj, $paneObj, $tabObj, $textViewObj, $matchLine);
8460  
8461 # Check for improper arguments
8462 if (! defined $nextFlag || defined $check) {
8463  
8464 return $axmud::CLIENT->writeImproper($self->_objClass . '->doSearch', @_);
8465 }
8466  
8467 # Get the text to search
8468 if ($self->findEntry) {
8469  
8470 $text = $self->findEntry->get_text();
8471 }
8472  
8473 if (! defined $text || $text eq '') {
8474  
8475 return undef;
8476 }
8477  
8478 # Get the current pane, i.e. the first pane object in this window's
8479 # GA::Strip::Entry->paneObjList
8480 $entryStripObj = $self->winObj->getStrip('entry');
8481 if ($entryStripObj) {
8482  
8483 $paneObj = $entryStripObj->ivIndex('paneObjList', 0);
8484 }
8485  
8486 if (! $paneObj) {
8487  
8488 # There are no window panes, therefore there is no text to search
8489 return undef;
8490 }
8491  
8492 # Get the textview object in the pane object's visible tab
8493 $tabObj = $paneObj->getVisibleTab();
8494 if ($tabObj) {
8495  
8496 $textViewObj = $tabObj->textViewObj;
8497 }
8498  
8499 if (! $textViewObj) {
8500  
8501 # No textview object found, therefore there is no text to search
8502 return undef;
8503 }
8504  
8505 # If the previous search was conducted on a different textview (or if this is the first
8506 # search), start searching from the bottom (or top)
8507 if (! defined $self->textViewNum || $self->textViewNum != $textViewObj->number) {
8508  
8509 $self->ivPoke('textViewNum', $textViewObj->number);
8510  
8511 # Create a search mark at the end of the buffer, which moves up and down the buffer
8512 # every time the use clicks the 'Previous' or 'Next' buttons
8513 $textViewObj->setSearchMark();
8514 }
8515  
8516 # Split the screen, if required
8517 if ($self->splitFlag && $textViewObj->splitScreenMode ne 'split') {
8518  
8519 $paneObj->toggleSplitScreen()
8520 }
8521  
8522 # Convert a simple string to a regex, if required (otherwise, assume that $text is already
8523 # a regex)
8524 if (! $self->regexFlag) {
8525  
8526 $text = quotemeta($text);
8527 }
8528  
8529 # Perform the search. The TRUE argument means to select and scroll to the matching text
8530 ($matchLine) = $textViewObj->searchBuffer($text, $nextFlag, TRUE, $self->caseFlag);
8531 if (! defined $matchLine) {
8532 $self->findEntry->set_icon_from_stock('secondary', 'gtk-no');
8533 } else {
8534 $self->findEntry->set_icon_from_stock('secondary', 'gtk-yes');
8535 }
8536  
8537 return 1;
8538 }
8539  
8540 sub doReset {
8541  
8542 # Called by a ->signal_connect in $self->drawSearchBox, and by $self->doReset
8543 # Resets the search box and the textview object's search position. Unselects any selected
8544 # text
8545 #
8546 # Expected arguments
8547 # (none besides $self)
8548 #
8549 # Return values
8550 # 'undef' on improper arguments
8551 # 1 otherwise
8552  
8553 my ($self, $check) = @_;
8554  
8555 # Local variables
8556 my ($entryStripObj, $paneObj, $tabObj, $textViewObj);
8557  
8558 # Check for improper arguments
8559 if (defined $check) {
8560  
8561 return $axmud::CLIENT->writeImproper($self->_objClass . '->doReset', @_);
8562 }
8563  
8564 # Update widgets
8565 $self->findEntry->set_text('');
8566 $self->findEntry->set_icon_from_stock('secondary', undef);
8567  
8568 # Get the current pane, i.e. the first pane object in this window's
8569 # GA::Strip::Entry->paneObjList
8570 $entryStripObj = $self->winObj->getStrip('entry');
8571 if ($entryStripObj) {
8572  
8573 $paneObj = $entryStripObj->ivIndex('paneObjList', 0);
8574 }
8575  
8576 if (! $paneObj) {
8577  
8578 # There are no window panes, therefore there is no search position to reset
8579 return 1;
8580 }
8581  
8582 # Get the textview object in the pane object's visible tab
8583 $tabObj = $paneObj->getVisibleTab();
8584 if ($tabObj) {
8585  
8586 $textViewObj = $tabObj->textViewObj;
8587 }
8588  
8589 if (! $textViewObj) {
8590  
8591 # No textview object found, therefore there is no search position to reset
8592 return 1;
8593 }
8594  
8595 # Reset the textview's search position, so that the next search starts from the bottom (or
8596 # top)
8597 $textViewObj->setSearchMark();
8598 # Un-select any selected text
8599 $textViewObj->unselectText();
8600  
8601 # If split-screen mode is enabled, disable it
8602 if ($textViewObj->splitScreenMode eq 'split') {
8603  
8604 $paneObj->toggleSplitScreen();
8605 }
8606  
8607 return 1;
8608 }
8609  
8610 sub toggleSplit {
8611  
8612 # Called by a ->signal_connect in $self->drawSearchBox after the 'Split screen' is clicked
8613 # Updates the value of the IV. If the current textview's split screen mode is on, turn it
8614 # off
8615 #
8616 # Expected arguments
8617 # $flag - TRUE if the button has been selected, FALSE if it has been deselected
8618 #
8619 # Return values
8620 # 'undef' on improper arguments
8621 # 1 otherwise
8622  
8623 my ($self, $flag, $check) = @_;
8624  
8625 # Local variables
8626 my ($entryStripObj, $paneObj, $tabObj, $textViewObj);
8627  
8628 # Check for improper arguments
8629 if (! defined $flag || defined $check) {
8630  
8631 return $axmud::CLIENT->writeImproper($self->_objClass . '->toggleSplit', @_);
8632 }
8633  
8634 if (! $flag) {
8635  
8636 $self->ivPoke('splitFlag', FALSE);
8637  
8638 # Get the current pane, i.e. the first pane object in this window's
8639 # GA::Strip::Entry->paneObjList
8640 $entryStripObj = $self->winObj->getStrip('entry');
8641 if ($entryStripObj) {
8642  
8643 $paneObj = $entryStripObj->ivIndex('paneObjList', 0);
8644 if ($paneObj) {
8645  
8646 # Get the textview object in the pane object's visible tab
8647 $tabObj = $paneObj->getVisibleTab();
8648 if ($tabObj) {
8649  
8650 $textViewObj = $tabObj->textViewObj;
8651 }
8652 }
8653 }
8654  
8655 if ($textViewObj && $textViewObj->splitScreenMode eq 'split') {
8656  
8657 $paneObj->toggleSplitScreen();
8658 }
8659  
8660 } else {
8661  
8662 $self->ivPoke('splitFlag', TRUE);
8663 }
8664  
8665 return 1;
8666 }
8667  
8668 sub toggleBox {
8669  
8670 # Called by GA::Strip::Entry->setInputSignals
8671 # If the strip object is visible, hide it (and vice-versa)
8672 #
8673 # Expected arguments
8674 # (none besides $self)
8675 #
8676 # Return values
8677 # 'undef' on improper arguments
8678 # 1 otherwise
8679  
8680 my ($self, $check) = @_;
8681  
8682 # Check for improper arguments
8683 if (defined $check) {
8684  
8685 return $axmud::CLIENT->writeImproper($self->_objClass . '->toggleBox', @_);
8686 }
8687  
8688 if (! $self->visibleFlag) {
8689  
8690 # Reveal the search box
8691 $self->drawSearchBox();
8692 $self->winObj->revealStripObj($self);
8693  
8694 } else {
8695  
8696 # Hide the search box
8697 $self->doReset();
8698 $self->winObj->hideStripObj($self);
8699 }
8700  
8701 return 1;
8702 }
8703  
8704 ##################
8705 # Accessors - set
8706  
8707 ##################
8708 # Accessors - get
8709  
8710 sub findEntry
8711 { $_[0]->{findEntry} }
8712 sub prevButton
8713 { $_[0]->{prevButton} }
8714 sub nextButton
8715 { $_[0]->{nextButton} }
8716 sub resetButton
8717 { $_[0]->{resetButton} }
8718 sub caseButton
8719 { $_[0]->{caseButton} }
8720 sub regexButton
8721 { $_[0]->{regexButton} }
8722 sub splitButton
8723 { $_[0]->{splitButton} }
8724  
8725 sub caseFlag
8726 { $_[0]->{caseFlag} }
8727 sub regexFlag
8728 { $_[0]->{regexFlag} }
8729 sub splitFlag
8730 { $_[0]->{splitFlag} }
8731  
8732 sub textViewNum
8733 { $_[0]->{textViewNum} }
8734 }
8735  
8736 { package Games::Axmud::Strip::Entry;
8737  
8738 use strict;
8739 use warnings;
8740 use diagnostics;
8741  
8742 use Glib qw(TRUE FALSE);
8743  
8744 our @ISA = qw(Games::Axmud::Generic::Strip Games::Axmud);
8745  
8746 ##################
8747 # Constructors
8748  
8749 sub new {
8750  
8751 # Called by GA::Win::Internal->drawWidgets or ->addStripObj
8752 # Creates the GA::Strip::Entry - a non-compulsory strip object containing a Gtk3::Entry
8753 #
8754 # Expected arguments
8755 # $number - The strip object's number within the parent window (matches
8756 # GA::Win::Internal->stripCount, or -1 for a temporary strip object
8757 # created to access its default IVs)
8758 # $winObj - The parent window object (GA::Win::Internal). 'temp' for temporary strip
8759 # objects
8760 #
8761 # Optional arguments
8762 # %initHash - A hash containing arbitrary data to use as the strip object's
8763 # initialisation settings. The strip object should use default
8764 # initialisation settings unless it can succesfully interpret one or more
8765 # of the key-value pairs in the hash, if there are any
8766 # - This type of strip object recognises these initialisation settings:
8767 #
8768 # 'func' - Reference to a function to call when the user types something
8769 # in the entry box and presses 'return'. If not specified or 'undef',
8770 # it's up to the calling code to create its own ->signal_connect.
8771 # Ignored in 'main' windows, for which a ->signal_connect is always
8772 # created by this strip object. To obtain a reference to an OOP
8773 # method, you can use the generic object function
8774 # Games::Axmud->getMethodRef()
8775 # 'id' - A value passed to the function which identifies the button. If
8776 # specified, can be any value except 'undef'. It's up to the
8777 # calling code to keep track of the widgets it has created and their
8778 # corresponding 'id' values
8779 # 'wipe_flag' - TRUE if a 'wipe entry' button should be drawn to the left
8780 # of the entry box, FALSE if not (default is FALSE)
8781 # 'add_flag' - TRUE if an 'add entry' button should be drawn to the left
8782 # of the entry box, FALSE if not (default is FALSE)
8783 # 'console_flag' - TRUE if a 'toggle console' button should be drawn to
8784 # the right of the entry box, FALSE if not (default is FALSE)
8785 # 'input_flag' - TRUE if a 'toggle expand' button (for opening the quick
8786 # input window) should be drawn to the right of the entry box, FALSE
8787 # if not (default is FALSE)
8788 # 'search_flag' - TRUE if a 'search' button (for opening the search box
8789 # strip object) shown be drawn to the right of the entry box, FALSE if
8790 # not (default is FALSE)
8791 # 'cancel_flag' - TRUE if a 'cancel repeating/excess commands' button
8792 # should be drawn to the right of the entry box, FALSE if not (default
8793 # is FALSE)
8794 # 'switch_flag' - TRUE if a 'switch active pane' button should be drawn to
8795 # the right of the entry box, FALSE if not (default is FALSE)
8796 # 'scroll_flag' - TRUE if a 'scroll lock' button should be drawn to the
8797 # right of the entry box, FALSE if not (default is FALSE)
8798 # 'split_flag' - TRUE if a 'split screen' button should be drawn to the
8799 # right of the entry box, FALSE if not (default is FALSE)
8800 #
8801 # Return values
8802 # 'undef' on improper arguments
8803 # Blessed reference to the newly-created object on success
8804  
8805 my ($class, $number, $winObj, %initHash) = @_;
8806  
8807 # Local variables
8808 my %modHash;
8809  
8810 # Check for improper arguments
8811 if (! defined $class || ! defined $number || ! defined $winObj) {
8812  
8813 return $axmud::CLIENT->writeImproper($class . '->new', @_);
8814 }
8815  
8816 # Default initialisation settings
8817 %modHash = (
8818 'func' => undef,
8819 'id' => '',
8820 'wipe_flag' => FALSE,
8821 'add_flag' => FALSE,
8822 'console_flag' => FALSE,
8823 'input_flag' => FALSE,
8824 'search_flag' => FALSE,
8825 'cancel_flag' => FALSE,
8826 'switch_flag' => FALSE,
8827 'scroll_flag' => FALSE,
8828 'split_flag' => FALSE,
8829 );
8830  
8831 # Interpret the initialisation settings in %initHash, if any
8832 foreach my $key (keys %modHash) {
8833  
8834 if ($key eq 'id' && ! defined $initHash{$key}) {
8835  
8836 $modHash{$key} = ''; # 'id' value must not be 'undef'
8837  
8838 } elsif ($key eq 'func' || $key eq 'id') {
8839  
8840 $modHash{$key} = $initHash{$key};
8841  
8842 } elsif (exists $initHash{$key}) {
8843  
8844 if ($initHash{$key}) {
8845 $modHash{$key} = TRUE;
8846 } else {
8847 $modHash{$key} = FALSE;
8848 }
8849 }
8850 }
8851  
8852 # Setup
8853 my $self = {
8854 _objName => 'strip_' . $number,
8855 _objClass => $class,
8856 _parentFile => undef, # No parent file object
8857 _parentWorld => undef, # No parent file object
8858 _privFlag => TRUE, # All IVs are private
8859  
8860 # Standard strip object IVs
8861 # -------------------------
8862  
8863 # The strip object's number within the parent window (matches
8864 # GA::Win::Internal->stripCount, or -1 for a temporary strip object created to
8865 # access its default IVs)
8866 number => $number,
8867 # The type of strip object (custom strip objects should use a ->type starting with
8868 # 'custom_' to avoid clashing with future built-in strip objects)
8869 type => 'entry',
8870 # The parent window object (GA::Win::Internal). 'temp' for temporary strip objects
8871 winObj => $winObj,
8872  
8873 # Flag set to TRUE if the strip object is visible (has actually drawn widgets in the
8874 # window), set to FALSE if it is not visible (has drawn no widgets in the window, but
8875 # still exists in GA::Win::Internal->stripHash, etc)
8876 # The flag might be set to FALSE in strip objects like GA::Strip::GaugeBox, which might
8877 # have gauges to draw, or not, depending on current conditions. (Most strip objects
8878 # have this flag set to TRUE all the time)
8879 # If FALSE, GA::Win::Internal->drawWidgets and ->addStripObj don't draw any widgets when
8880 # called by this object's functions
8881 # NB Strip objects are created with this flag set to TRUE or FALSE, but once created,
8882 # the flag's value shouldn't be modified by anything other than
8883 # GA::Win::Internal->hideStripObj and ->revealStripObj (which in turn call
8884 # $self->set_visibleFlag)
8885 visibleFlag => TRUE,
8886 # Flag set to TRUE is the strip object should be given its share of any extra space
8887 # within the packing box (the extra space is divided equally between all children of
8888 # the box whose ->expandFlag is TRUE)
8889 expandFlag => FALSE,
8890 # Flag set to TRUE if any space given to the strip object by the 'expand' option is
8891 # actually allocated within the strip object, FALSE if it is used as padding outside
8892 # it (on both sides)
8893 fillFlag => FALSE,
8894 # Flag set to TRUE if the strip object should be packed into its window with a small
8895 # gap between strip objects to either side; FALSE if not (can be set to FALSE if the
8896 # the strip object's widgets are drawn in a way, such that a gap is not necessary,
8897 # for example in the toolbar strip object)
8898 spacingFlag => TRUE,
8899 # Flag set to TRUE if only one instance of this strip object should be added to the
8900 # parent window, set to FALSE if any number of instances can be added
8901 jealousyFlag => TRUE,
8902 # Flag set to TRUE if this strip object can be added when $axmud::BLIND_MODE_FLAG is
8903 # TRUE, FALSE if it can't be added (because it's not useful for visually-impaired
8904 # users)
8905 blindFlag => TRUE,
8906 # Flag set to TRUE if the main container widget, stored in $self->packingBox, should be
8907 # allowed to accept the focus, FALSE if not. The restriction is applied during the
8908 # call to GA::Win::Internal->drawWidgets and ->addStripObj. Even if FALSE, widgets in
8909 # the container widget can be set to accept the focus (e.g. the Gtk3::Entry in
8910 # GA::Strip::MenuBar)
8911 allowFocusFlag => FALSE,
8912  
8913 # Initialisation settings stored as a hash (see the comments above)
8914 initHash => \%modHash,
8915 # Reference to a function to call when some widget is used. This IV is set only when
8916 # required by this type of strip object. It can be set by a call to
8917 # $self->set_func() or by some setting in $self->initHash, which is applied in the
8918 # call to $self->objEnable(). To obtain a reference to an OOP method, you can use the
8919 # generic object function Games::Axmud->getMethodRef()
8920 funcRef => undef,
8921 # A value passed to ->funcRef when it is called which identifies this strip object and
8922 # its widget(s). Can be any value, including 'undef'. It can be set by a call to
8923 # $self->set_id() or by some setting in $self->initHash, which is applied in the call
8924 # to $self->objEnable()
8925 funcID => undef,
8926  
8927 # The container widget for this strip object (usually a Gtk3::HBox or Gtk3::VBox). This
8928 # widget is the one added to the window's main Gtk3::HBox or Gtk3::VBox
8929 packingBox => undef, # Gtk3::HBox
8930  
8931 # Other IVs
8932 # ---------
8933  
8934 # Widgets
8935 entry => undef, # Gtk3::Entry
8936 preEntry => undef, # Gtk3::Entry
8937 postEntry => undef, # Gtk3::Entry
8938 wipeButton => undef, # Gtk3::ToolButton
8939 addButton => undef, # Gtk3::ToolButton
8940 consoleButton => undef, # Gtk3::ToolButton
8941 inputButton => undef, # Gtk3::ToolButton
8942 searchButton => undef, # Gtk3::ToolButton
8943 cancelButton => undef, # Gtk3::ToolButton
8944 switchButton => undef, # Gtk3::ToolButton
8945 scrollButton => undef, # Gtk3::ToolButton
8946 splitButton => undef, # Gtk3::ToolButton
8947  
8948 # List of currently-existing pane objects. New pane objects are added to the end of the
8949 # list. The first pane object in the list is the one to which the scroll and split
8950 # buttons apply. Clicking the switch buttons moves the first pane in the list to the
8951 # end, so that the next pane object becomes the one to which the scroll and split
8952 # buttons apply
8953 # Keypresses captured by GA::Win::Internal are also applied to the first pane object
8954 # in the list
8955 paneObjList => [],
8956  
8957 # The strip can contain one, two or three entry boxes; a main one (stored in
8958 # $self->entry), a small box whose contents is prepended to every world commmand
8959 # ($self->preEntry), and a small box whose contents is appended to every world
8960 # command ($self->postEntry). Click $self->addButton cycles through different
8961 # combinations of these boxes; this IV stores the state we're in at the moment:
8962 # 'default' - show only the main entry box
8963 # 'pre' - show the prepending and main entry boxes
8964 # 'post' - show the main and appending entry boxes
8965 # 'both' - show all three boxes
8966 entryBoxMode => 'default',
8967 # For 'main' windows, when GA::Client->autoCompleteMode = 'auto', the first time the
8968 # user presses the 'up' or 'down' arrow key, this IV is set to the contents of the
8969 # entry box (even if it's an empty string). The IV is set back to 'undef' as soon as
8970 # the user presses the ENTER key
8971 originalEntryText => undef,
8972 # Any code can temporarily desensitise the entry box(es), when required, by calling
8973 # $self->captureEntry, which adds an entry to this hash IV
8974 # The entry box remains potentially desensitised until the next call to
8975 # $self->captureEntry removes the entry in the hash IV
8976 # 'Potentially desensitised' means that the entry box is desensitised when any of the
8977 # sessions in this hash IV are the parent window's visible session, but is
8978 # sensitised when some other session is the parent window's visible session
8979 # Hash in the form
8980 # $captureHash{session_number} = undef
8981 captureHash => {},
8982 # The current state of the console button, representing the icon to use when the button
8983 # isn't flashing. Set to 'empty', 'system', 'debug' or 'error' (or 'undef' if the
8984 # button isn't visible)
8985 consoleIconType => undef,
8986 # The temporary state of the console button, representing the icon to use when the
8987 # button is flashing. Set to 'system', 'debug' or 'error' (or 'undef' if the button
8988 # isn't visible)
8989 consoleIconTempType => undef,
8990 # When a system message is waiting to be displayed in a Session Console window, the
8991 # button may be made to flash by periodic calls to $self->set_consoleIconFlash. When
8992 # not flashing, this value is set to TRUE; when flashing, it is alternately set to
8993 # FALSE and TRUE
8994 consoleIconFlashFlag => TRUE,
8995  
8996 # Special echo mode. This flag is set by a call to $self->set_specialEchoFlag
8997 # When TRUE, characters are sent to the world, one at a time, as soon as they're typed
8998 # When false, instructions aren't executed until the user presses their RETURN key
8999 specialEchoFlag => FALSE,
9000 # When special echo mode is enabled and the entry box contains a non-world command (for
9001 # example, a client command), this is flag is set to TRUE (so that the escape, tab,
9002 # backspace and delete keys are applied to the contents of the entry, not sent to the
9003 # world directly)
9004 specialPreserveFlag => FALSE,
9005 # When special echo mode is enabled and ->specialPreserveFlag is TRUE, meaning that a
9006 # world command is being typed in the entry box (one letter at a time), the world
9007 # command is stored here, so it can be passed to the GA::Session
9008 # At all other times, this IV is set to an empty string
9009 specialWorldCmd => '',
9010  
9011 # The primary Gtk stock icon currently used in the (main) entry box (e.g. 'gtk-yes',
9012 # 'gtk-media-pause'). 'undef' if no icon used
9013 # The seceondary icon is reset whenever the visible session changes anyway, so is not
9014 # stored as an IV
9015 primaryIcon => undef,
9016  
9017 # When a 'main' window switches between visible sessions, we need to preserve the
9018 # current values of those IVs
9019 # Hash in the form
9020 # $sessionHash{session_number} = list_reference
9021 # ...where 'list_reference' is a list in the form
9022 # (special_echo_flag, special_preserve_flag, special_world_cmd, primary_icon)
9023 sessionHash => {},
9024 # IV set whenever $self->setWidgetsChangeSession is called, recording the visible
9025 # session's unique number (if there is one), or set to 'undef' (if there is no visible
9026 # session)
9027 # The next call to ->setWidgetsChangeSession can then update the hash just above, using
9028 # the previous visible session's settings
9029 prevVisibleSession => undef,
9030 };
9031  
9032 # Bless the object into existence
9033 bless $self, $class;
9034  
9035 return $self;
9036 }
9037  
9038 ##################
9039 # Methods
9040  
9041 # Standard strip object functions
9042  
9043 sub objEnable {
9044  
9045 # Called by GA::Win::Internal->drawWidgets or ->addStripObj
9046 # Sets up the strip object's widgets
9047 #
9048 # Expected arguments
9049 # $winmapObj - The winmap object (GA::Obj::Winmap) that specifies the layout of the
9050 # parent window
9051 #
9052 # Return values
9053 # 'undef' on improper arguments
9054 # 1 on success
9055  
9056 my ($self, $winmapObj, $check) = @_;
9057  
9058 # Local variables
9059 my ($mainText, $preText, $postText);
9060  
9061 # Check for improper arguments
9062 if (! defined $winmapObj || defined $check) {
9063  
9064 return $axmud::CLIENT->writeImproper($self->_objClass . '->objEnable', @_);
9065 }
9066  
9067 # Create a packing box, if one doesn't exist already
9068 my $packingBox;
9069 if (! $self->packingBox) {
9070  
9071 # This function is being called for the first time
9072 $packingBox = Gtk3::HBox->new(FALSE, 0);
9073 $packingBox->set_border_width(0);
9074  
9075 } else {
9076  
9077 # This function is being called for a subsequent time. Temporarily store the contents
9078 # of the entry box(es), so they can be replaced
9079 $mainText = $self->entry->get_text();
9080 if ($self->preEntry) {
9081  
9082 $preText = $self->preEntry->get_text();
9083 }
9084  
9085 if ($self->postEntry) {
9086  
9087 $postText = $self->postEntry->get_text();
9088 }
9089  
9090 # Remove the packing box's current contents, so new widgets can be created
9091 $packingBox = $self->packingBox;
9092 foreach my $child ($self->packingBox->get_children()) {
9093  
9094 $axmud::CLIENT->desktopObj->removeWidget($self->packingBox, $child);
9095 }
9096 }
9097  
9098 # Draw a Gtk3::Entry box (compulsory) and any buttons specified by $self->initHash
9099 # (->signal_connects for each appear later in the function)
9100  
9101 # Draw a 'wipe entry' icon as a toolbutton (optional)
9102 my $wipeButton;
9103 if ($self->ivShow('initHash', 'wipe_flag') && ! $axmud::BLIND_MODE_FLAG) {
9104  
9105 $wipeButton = Gtk3::ToolButton->new(
9106 Gtk3::Image->new_from_file($axmud::SHARE_DIR . $axmud::CLIENT->constWipeIconPath),
9107 'Clear command entry box',
9108 );
9109 $packingBox->pack_start($wipeButton, FALSE, FALSE, 0);
9110 $wipeButton->set_tooltip_text('Clear command entry box');
9111 }
9112  
9113 # Draw an 'add entries' icon as a toolbutton (optional)
9114 my $addButton;
9115 if ($self->ivShow('initHash', 'add_flag') && ! $axmud::BLIND_MODE_FLAG) {
9116  
9117 $addButton = Gtk3::ToolButton->new(
9118 Gtk3::Image->new_from_file($axmud::SHARE_DIR . $axmud::CLIENT->constAddIconPath),
9119 'Use additional entry boxes',
9120 );
9121 $packingBox->pack_start($addButton, FALSE, FALSE, 0);
9122 $addButton->set_tooltip_text('Use additional entry boxes');
9123 }
9124  
9125 # Draw one or more entry boxes, depending on the value of $self->entryBoxMode
9126 my ($entry, $preEntry, $postEntry);
9127  
9128 # Draw the prepending entry box, if allowed
9129 if ($self->entryBoxMode eq 'pre' || $self->entryBoxMode eq 'both') {
9130  
9131 $preEntry = Gtk3::Entry->new();
9132 $packingBox->pack_start($preEntry, FALSE, FALSE, 0);
9133 $preEntry->set_tooltip_text('Add to beginning of world commands');
9134 if (defined $preText && $preText ne '') {
9135  
9136 $preEntry->set_text($preText);
9137 }
9138 }
9139  
9140 # Draw the main entry box
9141 $entry = Gtk3::Entry->new();
9142 $packingBox->pack_start($entry, TRUE, TRUE, 0);
9143 $entry->set_tooltip_text('Command entry box');
9144 if (defined $mainText && $mainText ne '') {
9145  
9146 $entry->set_text($mainText);
9147 }
9148  
9149 # Draw the appending entry box, if allowed
9150 if ($self->entryBoxMode eq 'post' || $self->entryBoxMode eq 'both') {
9151  
9152 $postEntry = Gtk3::Entry->new();
9153 $packingBox->pack_start($postEntry, FALSE, FALSE, 0);
9154 $postEntry->set_tooltip_text('Add to end of world commands');
9155 if (defined $postText && $postText ne '') {
9156  
9157 $postEntry->set_text($postText);
9158 }
9159 }
9160  
9161 # The main entry is the only 'internal' window widget which can accept focus
9162 $entry->set_can_focus(TRUE);
9163 # For 'main' windows, the entries start desensitised. Afterwards, they are sensitised or
9164 # desensitised (as appropriate) by $self->setWidgetsIfSession. For other kinds of
9165 # 'internal' window, the entries start sensitised
9166 # Any other parts of the code which need to desensitise the entries temporarily should call
9167 # $self->captureEntry
9168 if ($self->winObj->winType eq 'main') {
9169  
9170 $entry->set_sensitive(FALSE);
9171 if ($preEntry) {
9172  
9173 $preEntry->set_sensitive(FALSE);
9174 }
9175  
9176 if ($postEntry) {
9177  
9178 $postEntry->set_sensitive(FALSE);
9179 }
9180 }
9181  
9182 # Draw a 'toggle console' icon as a toolbutton (optional)
9183 my $consoleButton;
9184 if ($self->ivShow('initHash', 'console_flag') && ! $axmud::BLIND_MODE_FLAG) {
9185  
9186 $consoleButton = Gtk3::ToolButton->new(
9187 Gtk3::Image->new_from_file(
9188 $axmud::SHARE_DIR . $axmud::CLIENT->constEmptyIconPath,
9189 ),
9190 'Open Session Console window',
9191 );
9192 $packingBox->pack_start($consoleButton, FALSE, FALSE, 0);
9193 $consoleButton->set_tooltip_text('Open Session Console window');
9194 $consoleButton->set_sensitive(FALSE);
9195  
9196 $self->ivPoke('consoleIconType', 'empty');
9197 $self->ivPoke('consoleIconTempType', 'empty');
9198 }
9199  
9200 # Draw a 'toggle expand' icon as a toolbutton (optional)
9201 my $inputButton;
9202 if ($self->ivShow('initHash', 'input_flag') && ! $axmud::BLIND_MODE_FLAG) {
9203  
9204 $inputButton = Gtk3::ToolButton->new(
9205 Gtk3::Image->new_from_file($axmud::SHARE_DIR . $axmud::CLIENT->constMultiIconPath),
9206 'Open Quick Input window',
9207 );
9208 $packingBox->pack_start($inputButton, FALSE, FALSE, 0);
9209 $inputButton->set_tooltip_text('Open Quick Input window');
9210 $inputButton->set_sensitive(FALSE);
9211 }
9212  
9213 # Draw a 'toggle search' icon as a toolbutton (optional)
9214 my $searchButton;
9215 if ($self->ivShow('initHash', 'search_flag') && ! $axmud::BLIND_MODE_FLAG) {
9216  
9217 $searchButton = Gtk3::ToolButton->new(
9218 Gtk3::Image->new_from_file($axmud::SHARE_DIR . $axmud::CLIENT->constSearchIconPath),
9219 'Open search box',
9220 );
9221 $packingBox->pack_start($searchButton, FALSE, FALSE, 0);
9222 $searchButton->set_tooltip_text('Open search box');
9223 $searchButton->set_sensitive(FALSE);
9224 }
9225  
9226 # Draw a 'cancel repeating/excess commands' icon as a toolbutton (optional)
9227 my $cancelButton;
9228 if ($self->ivShow('initHash', 'cancel_flag') && ! $axmud::BLIND_MODE_FLAG) {
9229  
9230 $cancelButton = Gtk3::ToolButton->new(
9231 Gtk3::Image->new_from_file($axmud::SHARE_DIR . $axmud::CLIENT->constCancelIconPath),
9232 'Cancel repeating/excess commands',
9233 );
9234 $packingBox->pack_start($cancelButton, FALSE, FALSE, 0);
9235 $cancelButton->set_tooltip_text('Cancel repeating/excess commands');
9236 $cancelButton->set_sensitive(FALSE);
9237 }
9238  
9239 # Draw a 'switch active pane' icon as a toolbutton (optional)
9240 my $switchButton;
9241 if ($self->ivShow('initHash', 'switch_flag') && ! $axmud::BLIND_MODE_FLAG) {
9242  
9243 $switchButton = Gtk3::ToolButton->new(
9244 Gtk3::Image->new_from_file($axmud::SHARE_DIR . $axmud::CLIENT->constSwitchIconPath),
9245 'Switch active pane',
9246 );
9247 $packingBox->pack_start($switchButton, FALSE, FALSE, 0);
9248 $switchButton->set_tooltip_text('Switch active pane');
9249 $switchButton->set_sensitive(FALSE);
9250 }
9251  
9252 # Draw a 'scroll lock' icon as a toolbutton (optional)
9253 my $scrollButton;
9254 if ($self->ivShow('initHash', 'scroll_flag') && ! $axmud::BLIND_MODE_FLAG) {
9255  
9256 $scrollButton = Gtk3::ToolButton->new(
9257 Gtk3::Image->new_from_file($axmud::SHARE_DIR . $axmud::CLIENT->constLockIconPath),
9258 'Apply/release scroll lock',
9259 );
9260 $packingBox->pack_start($scrollButton, FALSE, FALSE, 0);
9261 $scrollButton->set_tooltip_text('Apply/release scroll lock');
9262 $scrollButton->set_sensitive(FALSE);
9263 }
9264  
9265 # Draw a 'split screen' icon as a toolbutton, and place it in the HBox (optional)
9266 my $splitButton;
9267 if ($self->ivShow('initHash', 'split_flag') && ! $axmud::BLIND_MODE_FLAG) {
9268  
9269 $splitButton = Gtk3::ToolButton->new(
9270 Gtk3::Image->new_from_file(
9271 $axmud::SHARE_DIR . $axmud::CLIENT->constRestoreIconPath,
9272 ),
9273 'Split/restore screen',
9274 );
9275 $packingBox->pack_start($splitButton, FALSE, FALSE, 0);
9276 $splitButton->set_tooltip_text('Split/restore screen');
9277 $splitButton->set_sensitive(FALSE);
9278 }
9279  
9280 # Update IVs
9281 $self->ivPoke('funcRef', $self->ivShow('initHash', 'func'));
9282 $self->ivPoke('funcID', $self->ivShow('initHash', 'id'));
9283 $self->ivPoke('packingBox', $packingBox);
9284 $self->ivPoke('entry', $entry);
9285 $self->ivPoke('preEntry', $preEntry);
9286 $self->ivPoke('postEntry', $postEntry);
9287 $self->ivPoke('wipeButton', $wipeButton);
9288 $self->ivPoke('addButton', $addButton);
9289 $self->ivPoke('consoleButton', $consoleButton);
9290 $self->ivPoke('inputButton', $inputButton);
9291 $self->ivPoke('searchButton', $searchButton);
9292 $self->ivPoke('cancelButton', $cancelButton);
9293 $self->ivPoke('switchButton', $switchButton);
9294 $self->ivPoke('scrollButton', $scrollButton);
9295 $self->ivPoke('splitButton', $splitButton);
9296  
9297 # Get a list of pane objects that already exist, and update our list of pane objects in
9298 # this window
9299 # (New panes are added to this list via a call to $self->notify_addTableObj, and old panes
9300 # are removed from it via a call to $self->notify_removeTableObj)
9301 if ($self->winObj->tableStripObj) {
9302  
9303 foreach my $tableObj (
9304 sort {$a->number <=> $b->number}
9305 ($self->winObj->tableStripObj->ivValues('tableObjHash'))
9306 ) {
9307 if ($tableObj->type eq 'pane') {
9308  
9309 $self->ivPush('paneObjList', $tableObj);
9310 }
9311 }
9312 }
9313  
9314 # Create ->signal_connects for each ($wipeButton manipulates $entry, and perhaps others will
9315 # in the future too, so we'll wait until now to do ->signal_connects)
9316 $self->setEntrySignals(); # 'activate'
9317 $self->setWipeSignals(); # 'clicked'
9318 $self->setAddSignals(); # 'clicked'
9319 $self->setConsoleSignals(); # 'clicked'
9320 $self->setInputSignals(); # 'clicked'
9321 $self->setSearchSignals(); # 'clicked'
9322 $self->setCancelSignals(); # 'clicked'
9323 $self->setSwitchSignals(); # 'clicked'
9324 $self->setScrollSignals(); # 'clicked'
9325 $self->setSplitSignals(); # 'clicked'
9326  
9327 return 1;
9328 }
9329  
9330 sub objDestroy {
9331  
9332 # Called by GA::Win::Internal->removeStripObj, just before the strip is removed from its
9333 # parent window, and also by ->winDestroy and ->resetWinmap, to give this object a chance
9334 # to do any necessary tidying up
9335 #
9336 # Expected arguments
9337 # (none besides $self)
9338 #
9339 # Return values
9340 # 'undef' on improper arguments
9341 # 1 otherwise
9342  
9343 my ($self, $check) = @_;
9344  
9345 # Check for improper arguments
9346 if (defined $check) {
9347  
9348 return $axmud::CLIENT->writeImproper($self->_objClass . '->objDestroy', @_);
9349 }
9350  
9351 # (No tidying up required for this type of strip object)
9352 # ...
9353  
9354 return 1;
9355 }
9356  
9357 sub setWidgetsIfSession {
9358  
9359 # Called by GA::Win::Internal->setWidgetsIfSession. (Also called by $self->setAddSignals)
9360 # Allows this strip object to sensitise or desensitise its widgets, depending on whether
9361 # the parent window has a ->visibleSession at the moment
9362 # (NB Only 'main' windows have a ->visibleSession; for other 'grid' windows, the flag
9363 # argument will be FALSE)
9364 #
9365 # Expected arguments
9366 # $flag - TRUE if the parent window has a visible session, FALSE if not
9367 #
9368 # Return values
9369 # 'undef' on improper arguments
9370 # 1 otherwise
9371  
9372 my ($self, $flag, $check) = @_;
9373  
9374 # Check for improper arguments
9375 if (! defined $flag || defined $check) {
9376  
9377 return $axmud::CLIENT->writeImproper($self->_objClass . '->setWidgetsIfSession', @_);
9378 }
9379  
9380 # Sensitise/desensitise entry box(es)
9381 if ($self->entry) {
9382  
9383 if ($flag) {
9384  
9385 if ($self->ivExists('captureHash', $self->winObj->visibleSession->number)) {
9386  
9387 $self->entry->set_sensitive(FALSE);
9388 if ($self->preEntry) {
9389  
9390 $self->preEntry->set_sensitive(FALSE);
9391 }
9392  
9393 if ($self->postEntry) {
9394  
9395 $self->postEntry->set_sensitive(FALSE);
9396 }
9397  
9398 } else {
9399  
9400 $self->entry->set_sensitive(TRUE);
9401 $self->entry->grab_focus();
9402  
9403 if ($self->preEntry) {
9404  
9405 $self->preEntry->set_sensitive(TRUE);
9406 }
9407  
9408 if ($self->postEntry) {
9409  
9410 $self->postEntry->set_sensitive(TRUE);
9411 }
9412 }
9413  
9414 } else {
9415  
9416 $self->entry->set_sensitive(FALSE);
9417 if ($self->preEntry) {
9418  
9419 $self->preEntry->set_sensitive(FALSE);
9420 }
9421  
9422 if ($self->postEntry) {
9423  
9424 $self->postEntry->set_sensitive(FALSE);
9425 }
9426 }
9427 }
9428  
9429 # Sensitise/desensitise buttons
9430 if ($self->wipeButton) {
9431  
9432 $self->wipeButton->set_sensitive($flag);
9433 }
9434  
9435 if ($self->inputButton) {
9436  
9437 $self->inputButton->set_sensitive($flag);
9438 }
9439  
9440 if ($self->searchButton) {
9441  
9442 $self->searchButton->set_sensitive($flag);
9443 }
9444  
9445 if ($self->consoleButton) {
9446  
9447 $self->consoleButton->set_sensitive($flag);
9448 }
9449  
9450 if ($self->cancelButton) {
9451  
9452 $self->cancelButton->set_sensitive($flag);
9453 }
9454  
9455 if ($self->switchButton) {
9456  
9457 $self->switchButton->set_sensitive($flag);
9458 }
9459  
9460 if ($self->scrollButton) {
9461  
9462 $self->scrollButton->set_sensitive($flag);
9463 # Restore default icon, too
9464 $self->scrollButton->set_icon_widget(
9465 Gtk3::Image->new_from_file($axmud::SHARE_DIR . $axmud::CLIENT->constLockIconPath),
9466 );
9467 }
9468  
9469 if ($self->splitButton) {
9470  
9471 $self->splitButton->set_sensitive($flag);
9472 # Restore default icon, too
9473 $self->splitButton->set_icon_widget(
9474 Gtk3::Image->new_from_file(
9475 $axmud::SHARE_DIR . $axmud::CLIENT->constRestoreIconPath,
9476 ),
9477 );
9478 }
9479  
9480 return 1;
9481 }
9482  
9483 sub setWidgetsChangeSession {
9484  
9485 # Called by GA::Win::Internal->setWidgetsChangeSession
9486 # Allows this strip object to update its widgets whenever the visible session in any 'main'
9487 # window changes
9488 #
9489 # Expected arguments
9490 # (none besides $self)
9491 #
9492 # Return values
9493 # 'undef' on improper arguments
9494 # 1 otherwise
9495  
9496 my ($self, $check) = @_;
9497  
9498 # Local variables
9499 my (
9500 $listRef, $specialEchoFlag, $specialPreserveFlag, $specialWorldCmd, $primaryIcon,
9501 $textViewObj, $iv,
9502 );
9503  
9504 # Check for improper arguments
9505 if (defined $check) {
9506  
9507 return $axmud::CLIENT->writeImproper(
9508 $self->_objClass . '->setWidgetsChangeSession',
9509 @_,
9510 );
9511 }
9512  
9513 # Update IVs that store settings for the previous visible session (if any)
9514 if (defined $self->prevVisibleSession) {
9515  
9516 $self->ivAdd(
9517 'sessionHash',
9518 $self->prevVisibleSession,
9519 [
9520 $self->specialEchoFlag,
9521 $self->specialPreserveFlag,
9522 $self->specialWorldCmd,
9523 $self->primaryIcon,
9524 ],
9525 );
9526  
9527 $self->ivUndef('prevVisibleSession');
9528 }
9529  
9530 # Update button icons to match the visible session
9531 if ($self->winObj->visibleSession) {
9532  
9533 # Retrieve settings used the last time this was the visible session
9534 $listRef = $self->ivShow('sessionHash', $self->winObj->visibleSession->number);
9535 if (! defined $listRef) {
9536  
9537 # Use default settings for the new visible session. ->primaryIcon has a default
9538 # value of 'undef' anyway
9539 $specialEchoFlag = FALSE;
9540 $specialPreserveFlag = FALSE;
9541 $specialWorldCmd = '';
9542  
9543 } else {
9544  
9545 # Use the previous settings
9546 ($specialEchoFlag, $specialPreserveFlag, $specialWorldCmd, $primaryIcon)
9547 = @$listRef;
9548 }
9549  
9550 $self->ivPoke('specialEchoFlag', $specialEchoFlag);
9551 $self->ivPoke('specialPreserveFlag', $specialPreserveFlag);
9552 $self->ivPoke('specialWorldCmd', $specialWorldCmd);
9553 $self->ivPoke('primaryIcon', $primaryIcon);
9554 $self->ivPoke('prevVisibleSession', $self->winObj->visibleSession->number);
9555  
9556 # (->defaultTabObj won't be set yet, if GA::Session->start is still executing)
9557 if ($self->winObj->visibleSession->defaultTabObj) {
9558  
9559 $textViewObj = $self->winObj->visibleSession->defaultTabObj->textViewObj;
9560 }
9561  
9562 if ($self->addButton) {
9563  
9564 $self->addButton->set_sensitive(! $self->specialEchoFlag);
9565 }
9566  
9567 if ($self->consoleButton) {
9568  
9569 # e.g. constEmptyIconPath
9570 $iv = 'const' . ucfirst($self->winObj->visibleSession->systemMsgMode) . 'IconPath';
9571  
9572 $self->consoleButton->set_icon_widget(
9573 Gtk3::Image->new_from_file($axmud::SHARE_DIR . $axmud::CLIENT->$iv),
9574 );
9575  
9576 $self->ivPoke('consoleIconType', $self->winObj->visibleSession->systemMsgMode);
9577 $self->ivPoke('consoleIconFlashFlag', TRUE);
9578 }
9579  
9580 if ($self->scrollButton) {
9581  
9582 if (! $textViewObj || $textViewObj->scrollLockFlag) {
9583  
9584 $self->scrollButton->set_icon_widget(
9585 Gtk3::Image->new_from_file(
9586 $axmud::SHARE_DIR . $axmud::CLIENT->constLockIconPath
9587 ),
9588 );
9589  
9590 } else {
9591  
9592 $self->scrollButton->set_icon_widget(
9593 Gtk3::Image->new_from_file(
9594 $axmud::SHARE_DIR . $axmud::CLIENT->constScrollIconPath
9595 ),
9596 );
9597 }
9598 }
9599  
9600 if ($self->splitButton) {
9601  
9602 if (! $textViewObj || $textViewObj->splitScreenMode eq 'split') {
9603  
9604 $self->splitButton->set_icon_widget(
9605 Gtk3::Image->new_from_file(
9606 $axmud::SHARE_DIR . $axmud::CLIENT->constRestoreIconPath,
9607 ),
9608 );
9609  
9610 } else {
9611  
9612 $self->splitButton->set_icon_widget(
9613 Gtk3::Image->new_from_file(
9614 $axmud::SHARE_DIR . $axmud::CLIENT->constSplitIconPath,
9615 ),
9616 );
9617 }
9618 }
9619  
9620 if ($self->entry) {
9621  
9622 # If the current current session's server has suggested that the client stop
9623 # ECHOing, and the client has agreed, text in the entry box(es) must be obscured
9624 # If not, or if special echo mode is on, it must be un-obscured (in case it was
9625 # obscured by the previous session)
9626 # In either case, text in the entry box is removed when switching sessions
9627 if (
9628 $self->winObj->visibleSession->echoMode eq 'client_agree'
9629 && ! $self->specialEchoFlag
9630 ) {
9631 $self->obscureEntry(TRUE);
9632 } else {
9633 $self->obscureEntry(FALSE);
9634 }
9635  
9636 # Set (or reset) entry box icons. Those associated with recordings may have changed
9637 # since the last time the session was the visible session
9638 $self->entry->set_icon_from_stock('primary', $self->primaryIcon);
9639  
9640 if ($self->winObj->visibleSession->recordingPausedFlag) {
9641 $self->entry->set_icon_from_stock('secondary', 'gtk-media-pause');
9642 } elsif ($self->winObj->visibleSession->recordingFlag) {
9643 $self->entry->set_icon_from_stock('secondary', 'gtk-media-record');
9644 } else {
9645 $self->entry->set_icon_from_stock('secondary', undef);
9646 }
9647 }
9648  
9649 } else {
9650  
9651 # No visible session; use the default settings
9652 $self->ivPoke('specialEchoFlag', FALSE);
9653 $self->ivPoke('specialPreserveFlag', FALSE);
9654 $self->ivPoke('specialWorldCmd', '');
9655 $self->ivPoke('primaryIcon', undef);
9656 $self->ivPoke('prevVisibleSession', undef);
9657  
9658 if ($self->entry) {
9659  
9660 if (! $axmud::CLIENT->sessionHash) {
9661  
9662 # If there are no sessions at all, the main entry box must be empty, and the
9663 # minor entry boxes must be removed entirely
9664 $self->entry->set_text('');
9665 if ($self->preEntry) {
9666  
9667 $axmud::CLIENT->desktopObj->removeWidget(
9668 $self->packingBox,
9669 $self->preEntry,
9670 );
9671  
9672 $self->ivUndef('preEntry');
9673 }
9674  
9675 if ($self->postEntry) {
9676  
9677 $axmud::CLIENT->desktopObj->removeWidget(
9678 $self->packingBox,
9679 $self->postEntry,
9680 );
9681  
9682 $self->ivUndef('postEntry');
9683 }
9684 }
9685 }
9686 }
9687  
9688 return 1;
9689 }
9690  
9691 # ->signal_connects
9692  
9693 sub setEntrySignals {
9694  
9695 # Called by $self->objEnable
9696 # Set up a ->signal_connect to watch out for the user input in the entry box
9697 #
9698 # Expected arguments
9699 # (none besides $self)
9700 #
9701 # Return values
9702 # 'undef' on improper arguments
9703 # 1 otherwise
9704  
9705 my ($self, $check) = @_;
9706  
9707 # Local variables
9708 my %shortHash;
9709  
9710 # Check for improper arguments
9711 if (defined $check) {
9712  
9713 return $axmud::CLIENT->writeImproper($self->_objClass . '->setEntrySignals', @_);
9714 }
9715  
9716 # Deal with user pressing their ENTER key
9717 $self->entry->signal_connect('activate' => sub {
9718  
9719 my (
9720 $instruct, $thisFuncRef, $preText, $postText, $successFlag, $type,
9721 @instructList,
9722 );
9723  
9724 $instruct = $self->entry->get_text();
9725 $thisFuncRef = $self->funcRef;
9726  
9727 # The entry box's behaviour depends on whether the parent window is a 'main' window, or
9728 # not
9729 if ($self->winObj->winType eq 'main') {
9730  
9731 if (
9732 $self->specialEchoFlag
9733 && ! $self->specialPreserveFlag
9734 && $self->specialWorldCmd
9735 && $self->winObj->visibleSession
9736 ) {
9737 # Pass the stored world command to the visible session, calling ->dispatchCmd
9738 # directly, since it already checks for special echo mode
9739 $self->winObj->visibleSession->dispatchCmd($self->specialWorldCmd);
9740 # Also update the instruction buffer, since we bypassed GA::Session->doInstruct
9741 $self->winObj->visibleSession->updateInstructBuffer(
9742 $self->specialWorldCmd,
9743 'world',
9744 );
9745  
9746 } elsif ($self->winObj->visibleSession) {
9747  
9748 # Pass the typed instruction to the visible session, along with any pre- or
9749 # post-world command strings that exist
9750 if ($self->preEntry) {
9751  
9752 $preText = $self->preEntry->get_text();
9753 if ($preText eq '') {
9754  
9755 $preText = undef;
9756 }
9757 }
9758  
9759 if ($self->postEntry) {
9760  
9761 $postText = $self->postEntry->get_text();
9762 if ($postText eq '') {
9763  
9764 $postText = undef;
9765 }
9766 }
9767  
9768 # The user may have copied a set of instructions, separated by newline
9769 # characters (for example from a text editor). If so, split them up into
9770 # indiviual instructions
9771 # Because $instruct might well be an empty string (if the user just pressed
9772 # RETURN), then we cannot do a Perl split in all cases
9773 if ($instruct =~ m/\n/) {
9774 @instructList = split(/\n/, $instruct);
9775 } else {
9776 push (@instructList, $instruct);
9777 }
9778  
9779 foreach my $thisInstruct (@instructList) {
9780  
9781 ($successFlag, $type) = $self->winObj->visibleSession->doInstruct(
9782 $thisInstruct,
9783 undef,
9784 $preText,
9785 $postText,
9786 );
9787 }
9788  
9789 # Deal with the new contents of the entry box
9790 if (
9791 defined $type
9792 # (If $instruct was ';stopsession', there will be no visible session now)
9793 && $self->winObj->visibleSession
9794 && $self->winObj->visibleSession->echoMode ne 'client_agree'
9795 && (
9796 (
9797 $axmud::CLIENT->preserveWorldCmdFlag
9798 && (
9799 $type eq 'world' || $type eq 'multi' || $type eq 'speed'
9800 || $type eq 'bypass'
9801 )
9802 ) || (
9803 $axmud::CLIENT->preserveOtherCmdFlag
9804 && (
9805 $type ne 'world' && $type ne 'multi' && $type ne 'speed'
9806 && $type ne 'bypass'
9807 )
9808 )
9809 )
9810 ) {
9811 # Preserve the typed command and select all of the text
9812 $self->entry->grab_focus();
9813  
9814 } else {
9815  
9816 # Empty the entry box
9817 $self->entry->set_text('');
9818 }
9819  
9820 # Reset the text stored for the benefit of GA::Session->autoCompleteBuffer
9821 $self->ivUndef('originalEntryText');
9822  
9823 } else {
9824  
9825 $self->entry->set_text('');
9826  
9827 # Reset the text stored for the benefit of GA::Session->autoCompleteBuffer
9828 $self->ivUndef('originalEntryText');
9829 }
9830  
9831 # For other 'internal' windows, redirect the entry box's contents to the specified
9832 # function (if any)
9833 } elsif ($thisFuncRef) {
9834  
9835 &$thisFuncRef($self, $self->entry, $self->funcID, $instruct);
9836  
9837 $self->entry->set_text('');
9838 }
9839  
9840 # Update IVs
9841 $self->entry->set_icon_from_stock('primary', undef);
9842 $self->ivUndef('primaryIcon');
9843 $self->ivPoke('specialPreserveFlag', FALSE);
9844 $self->ivPoke('specialWorldCmd', '');
9845  
9846 return 1;
9847 });
9848  
9849 # Deal with user entering or removing any character(s) from the entry box, during special
9850 # echo mode
9851 # In special echo mode, world commands are sent to the world immediately, one character at a
9852 # time; but non-world commands (such as client commands) behave as normal. Forced client
9853 # commands also behave as normal
9854 # To implement this we need to work out when the user is typing an instruction that begins
9855 # with a recognised instruction sigil, and when they're not
9856  
9857 # Most instruction sigils are one character long, but GA::Client->constForcedSigil is two.
9858 # In any case, some user might edit GA::Client->new to alter the literal values
9859 # Save a bit of time by compiling a hash of strings that start a multi-character sigil
9860 # (for example, for the forced world command sigil ',,' add an entry for ',')
9861 # We assume that the user has followed the instructions in GA::Client->new, and has made
9862 # sure each sigil starts with a different character
9863 foreach my $type (qw(client forced echo perl script multi speed bypass)) {
9864  
9865 my $iv = 'const' . ucfirst($type) . 'Sigil'; # e.g. 'constClientSigil'
9866  
9867 if (length ($axmud::CLIENT->$iv) > 1) {
9868  
9869 for (my $num = 1; $num <= length($axmud::CLIENT->$iv); $num++) {
9870  
9871 $shortHash{substr($axmud::CLIENT->$iv, 0, $num)} = undef;
9872 }
9873 }
9874 }
9875  
9876 $self->entry->signal_connect('changed' => sub {
9877  
9878 my $instruct = $self->entry->get_text();
9879  
9880 if (! $self->specialEchoFlag || $instruct eq '') {
9881  
9882 # Special echo mode is off or the command entry box is empty, so do nothing with
9883 # ordinary keypresses
9884 return undef;
9885  
9886 } else {
9887  
9888 # Special echo mode is on. Trim initial whitespace, so we can work out whether
9889 # $instruct starts with an instruction sigil, or not; but if $instruct actually
9890 # contains just space character(s), don't trim it
9891 $instruct =~ s/^\s*(\S.*)/$1/;
9892  
9893 # Is the whole of instruct a partial multi-character sigil (for example, a single
9894 # comma from the forced world command sigil ',,') ?
9895 foreach my $short (keys %shortHash) {
9896  
9897 if ($instruct eq $short) {
9898  
9899 # Decide what to do once the the user has typed another character
9900 # Meanwhile, set the entry icon for non-world commands
9901 $self->entry->set_icon_from_stock('primary', 'gtk-disconnect');
9902 $self->ivPoke('primaryIcon', 'gtk-disconnect');
9903 # Don't let GA::Win::Internal->setKeyPressEvent intercept the escape, tab,
9904 # backspace and delete keys, which should instead apply to our entry box
9905 $self->ivPoke('specialPreserveFlag', TRUE);
9906 $self->ivPoke('specialWorldCmd', '');
9907  
9908 return undef;
9909 }
9910 }
9911  
9912 # Now check that $instruct begins with an instruction sigil that's currently
9913 # enabled
9914 foreach my $type (qw(client forced echo perl script multi speed bypass)) {
9915  
9916 my ($constIV, $flagIV);
9917  
9918 $constIV = 'const' . ucfirst($type) . 'Sigil'; # e.g. 'constClientSigil'
9919 $flagIV = $type . 'SigilFlag'; # e.g. 'echoSigilFlag'
9920  
9921 if (
9922 index($instruct, $axmud::CLIENT->$constIV) == 0
9923 && (
9924 # The IVs ->clientSigilFlag and ->forcedSigilFlag don't exist
9925 $type eq 'client'
9926 || $type eq 'forced'
9927 || $axmud::CLIENT->$flagIV
9928 )
9929 ) {
9930 # $instruct begins with an instruction sigil that's enabled. Set the entry
9931 # icon for non-world commands
9932 $self->entry->set_icon_from_stock('primary', 'gtk-disconnect');
9933 $self->ivPoke('primaryIcon', 'gtk-disconnect');
9934 # Don't let GA::Win::Internal->setKeyPressEvent intercept the escape, tab,
9935 # backspace and delete keys, which should instead apply to our entry box
9936 $self->ivPoke('specialPreserveFlag', TRUE);
9937 $self->ivPoke('specialWorldCmd', '');
9938  
9939 return undef;
9940 }
9941 }
9942  
9943 # $instruct is part of a world command, so send it to the world immediately (the
9944 # TRUE argument means to encode $instruct using the session's current character
9945 # set)
9946 $self->winObj->visibleSession->put($instruct, TRUE);
9947 # Reset the entry box, and set the icon for world commands
9948 $self->entry->set_text('');
9949 $self->entry->set_icon_from_stock('primary', 'gtk-connect');
9950 $self->ivPoke('primaryIcon', 'gtk-connect');
9951 # Update IVs
9952 $self->ivPoke('specialPreserveFlag', FALSE);
9953 $self->ivPoke('specialWorldCmd', $self->specialWorldCmd . $instruct);
9954  
9955 return undef;
9956 }
9957 });
9958  
9959 return 1;
9960 }
9961  
9962 sub setWipeSignals {
9963  
9964 # Called by $self->objEnable
9965 # Set up a ->signal_connect to watch out for the button being clicked
9966 #
9967 # Expected arguments
9968 # (none besides $self)
9969 #
9970 # Return values
9971 # 'undef' on improper arguments
9972 # 1 otherwise
9973  
9974 my ($self, $check) = @_;
9975  
9976 # Check for improper arguments
9977 if (defined $check) {
9978  
9979 return $axmud::CLIENT->writeImproper($self->_objClass . '->setWipeSignals', @_);
9980 }
9981  
9982 if ($self->wipeButton) {
9983  
9984 $self->wipeButton->signal_connect('clicked' => sub {
9985  
9986 $self->entry->set_text('');
9987  
9988 # Update IVs. Clicking the button means that the user wants to start typing a new
9989 # world command, without having pressed their RETURN key (for example, if they've
9990 # just been navigating menus)
9991 $self->ivPoke('specialPreserveFlag', FALSE);
9992 $self->ivPoke('specialWorldCmd', '');
9993 # Remove the icon, too
9994 $self->entry->set_icon_from_stock('primary', undef);
9995 $self->ivUndef('primaryIcon');
9996 });
9997 }
9998  
9999 return 1;
10000 }
10001  
10002 sub setAddSignals {
10003  
10004 # Called by $self->objEnable
10005 # Set up a ->signal_connect to watch out for the button being clicked
10006 #
10007 # Expected arguments
10008 # (none besides $self)
10009 #
10010 # Return values
10011 # 'undef' on improper arguments
10012 # 1 otherwise
10013  
10014 my ($self, $check) = @_;
10015  
10016 # Check for improper arguments
10017 if (defined $check) {
10018  
10019 return $axmud::CLIENT->writeImproper($self->_objClass . '->setAddSignals', @_);
10020 }
10021  
10022 if ($self->addButton) {
10023  
10024 $self->addButton->signal_connect('clicked' => sub {
10025  
10026 # Update IVs, cycling through various modes, in which one or more entry boxes are
10027 # drawn
10028 if ($self->entryBoxMode eq 'default') {
10029 $self->ivPoke('entryBoxMode', 'pre');
10030 } elsif ($self->entryBoxMode eq 'pre') {
10031 $self->ivPoke('entryBoxMode', 'both');
10032 } elsif ($self->entryBoxMode eq 'both') {
10033 $self->ivPoke('entryBoxMode', 'post');
10034 } elsif ($self->entryBoxMode eq 'post') {
10035 $self->ivPoke('entryBoxMode', 'default');
10036 }
10037  
10038 # Redraw the whole strip, which draws the right number of entries
10039 $self->objEnable($axmud::CLIENT->ivShow('winmapHash', $self->winObj->winmap));
10040 if ($self->winObj->winType ne 'main') {
10041 $self->setWidgetsIfSession(FALSE);
10042 } else {
10043 $self->setWidgetsIfSession(TRUE);
10044 }
10045  
10046 $self->winObj->replaceStripObj($self);
10047 $self->entry->grab_focus();
10048 });
10049 }
10050  
10051 return 1;
10052 }
10053  
10054 sub setConsoleSignals {
10055  
10056 # Called by $self->objEnable
10057 # Set up a ->signal_connect to watch out for the button being clicked
10058 #
10059 # Expected arguments
10060 # (none besides $self)
10061 #
10062 # Return values
10063 # 'undef' on improper arguments
10064 # 1 otherwise
10065  
10066 my ($self, $check) = @_;
10067  
10068 # Check for improper arguments
10069 if (defined $check) {
10070  
10071 return $axmud::CLIENT->writeImproper($self->_objClass . '->setInputSignals', @_);
10072 }
10073  
10074 if ($self->consoleButton) {
10075  
10076 $self->consoleButton->signal_connect('clicked' => sub {
10077  
10078 if ($self->winObj->visibleSession) {
10079  
10080 if (! $self->winObj->visibleSession->consoleWin) {
10081  
10082 # Open an Session Console window
10083 $self->winObj->createFreeWin(
10084 'Games::Axmud::OtherWin::SessionConsole',
10085 $self->winObj,
10086 $self->winObj->visibleSession,
10087 undef, # Let the window set its own title
10088 );
10089  
10090 } else {
10091  
10092 # Close the existing window
10093 $self->winObj->visibleSession->consoleWin->winDestroy();
10094 }
10095 }
10096 });
10097 }
10098  
10099 return 1;
10100 }
10101  
10102 sub setInputSignals {
10103  
10104 # Called by $self->objEnable
10105 # Set up a ->signal_connect to watch out for the button being clicked
10106 #
10107 # Expected arguments
10108 # (none besides $self)
10109 #
10110 # Return values
10111 # 'undef' on improper arguments
10112 # 1 otherwise
10113  
10114 my ($self, $check) = @_;
10115  
10116 # Check for improper arguments
10117 if (defined $check) {
10118  
10119 return $axmud::CLIENT->writeImproper($self->_objClass . '->setInputSignals', @_);
10120 }
10121  
10122 if ($self->inputButton) {
10123  
10124 $self->inputButton->signal_connect('clicked' => sub {
10125  
10126 if ($self->winObj->visibleSession) {
10127  
10128 $self->winObj->visibleSession->pseudoCmd('quickinput');
10129 }
10130 });
10131 }
10132  
10133 return 1;
10134 }
10135  
10136 sub setSearchSignals {
10137  
10138 # Called by $self->objEnable
10139 # Set up a ->signal_connect to watch out for the button being clicked
10140 #
10141 # Expected arguments
10142 # (none besides $self)
10143 #
10144 # Return values
10145 # 'undef' on improper arguments
10146 # 1 otherwise
10147  
10148 my ($self, $check) = @_;
10149  
10150 # Check for improper arguments
10151 if (defined $check) {
10152  
10153 return $axmud::CLIENT->writeImproper($self->_objClass . '->setSearchSignals', @_);
10154 }
10155  
10156 if ($self->searchButton) {
10157  
10158 $self->searchButton->signal_connect('clicked' => sub {
10159  
10160 my $searchStripObj = $self->winObj->getStrip('search');
10161  
10162 if ($searchStripObj) {
10163  
10164 $searchStripObj->toggleBox();
10165 $searchStripObj->findEntry->grab_focus();
10166 }
10167 });
10168 }
10169  
10170 return 1;
10171 }
10172  
10173 sub setCancelSignals {
10174  
10175 # Called by $self->objEnable
10176 # Set up a ->signal_connect to watch out for the button being clicked
10177 #
10178 # Expected arguments
10179 # (none besides $self)
10180 #
10181 # Return values
10182 # 'undef' on improper arguments
10183 # 1 otherwise
10184  
10185 my ($self, $check) = @_;
10186  
10187 # Check for improper arguments
10188 if (defined $check) {
10189  
10190 return $axmud::CLIENT->writeImproper($self->_objClass . '->setCancelSignals', @_);
10191 }
10192  
10193 if ($self->cancelButton) {
10194  
10195 $self->cancelButton->signal_connect('clicked' => sub {
10196  
10197 if (
10198 $self->winObj->visibleSession
10199 && (
10200 $self->winObj->visibleSession->status eq 'connected'
10201 || $self->winObj->visibleSession->status eq 'offline'
10202 )
10203 ) {
10204 $self->winObj->visibleSession->pseudoCmd('stopcommand');
10205 }
10206 });
10207 }
10208  
10209 return 1;
10210 }
10211  
10212 sub setSwitchSignals {
10213  
10214 # Called by $self->objEnable
10215 # Set up a ->signal_connect to watch out for the button being clicked
10216 #
10217 # Expected arguments
10218 # (none besides $self)
10219 #
10220 # Return values
10221 # 'undef' on improper arguments
10222 # 1 otherwise
10223  
10224 my ($self, $check) = @_;
10225  
10226 # Check for improper arguments
10227 if (defined $check) {
10228  
10229 return $axmud::CLIENT->writeImproper($self->_objClass . '->setSwitchSignals', @_);
10230 }
10231  
10232 if ($self->switchButton) {
10233  
10234 $self->switchButton->signal_connect('clicked' => sub {
10235  
10236 # The first pane object in $self->paneObjList is the new 'active' pane object, to
10237 # which the scroll and split buttons are applied
10238 if ($self->paneObjList) {
10239  
10240 my $paneObj = $self->ivShift('paneObjList');
10241 $self->ivPush('paneObjList', $paneObj);
10242  
10243 # Briefly increase the size of the 'active' pane object's border width, so the
10244 # user can see which one it is
10245 $axmud::CLIENT->paneModifyBorder($self->ivFirst('paneObjList'));
10246 }
10247 });
10248 }
10249  
10250 return 1;
10251 }
10252  
10253 sub setScrollSignals {
10254  
10255 # Called by $self->objEnable
10256 # Set up a ->signal_connect to watch out for the button being clicked
10257 #
10258 # Expected arguments
10259 # (none besides $self)
10260 #
10261 # Return values
10262 # 'undef' on improper arguments
10263 # 1 otherwise
10264  
10265 my ($self, $check) = @_;
10266  
10267 # Check for improper arguments
10268 if (defined $check) {
10269  
10270 return $axmud::CLIENT->writeImproper($self->_objClass . '->setScrollSignals', @_);
10271 }
10272  
10273 if ($self->scrollButton) {
10274  
10275 $self->scrollButton->signal_connect('clicked' => sub {
10276  
10277 my $paneObj;
10278  
10279 # Get the active pane object and toggle the scroll lock for the visible tab
10280 if ($self->paneObjList) {
10281  
10282 $paneObj = $self->ivFirst('paneObjList');
10283 $paneObj->toggleScrollLock();
10284 }
10285 });
10286 }
10287  
10288 return 1;
10289 }
10290  
10291 sub setSplitSignals {
10292  
10293 # Called by $self->objEnable
10294 # Set up a ->signal_connect to watch out for the button being clicked
10295 #
10296 # Expected arguments
10297 # (none besides $self)
10298 #
10299 # Return values
10300 # 'undef' on improper arguments
10301 # 1 otherwise
10302  
10303 my ($self, $check) = @_;
10304  
10305 # Check for improper arguments
10306 if (defined $check) {
10307  
10308 return $axmud::CLIENT->writeImproper($self->_objClass . '->setSplitSignals', @_);
10309 }
10310  
10311 if ($self->splitButton) {
10312  
10313 $self->splitButton->signal_connect('clicked' => sub {
10314  
10315 my $paneObj;
10316  
10317 # Get the active pane object and toggle the split screen for the visible tab
10318 if ($self->paneObjList) {
10319  
10320 $paneObj = $self->ivFirst('paneObjList');
10321 $paneObj->toggleSplitScreen();
10322 }
10323 });
10324 }
10325  
10326 return 1;
10327 }
10328  
10329 # Other functions
10330  
10331 sub captureEntry {
10332  
10333 # Can be called by any code which wants to make temporarily set the Gtk3::Entry as
10334 # insensitive, and called again to restore its previous state (which might be
10335 # sensitive, or not)
10336 #
10337 # Expected arguments
10338 # $session - The calling GA::Session
10339 # $flag - Set to TRUE to desensitise the entry, FALSE to restore it to its previous
10340 # state (which might be insensitive) by calling $self->setWidgetsIfSession
10341 #
10342 # Return values
10343 # 'undef' on improper arguments or if the entry is already captured (or not captured) by
10344 # the calling session
10345 # 1 otherwise
10346  
10347 my ($self, $session, $flag, $check) = @_;
10348  
10349 # Check for improper arguments
10350 if (! defined $session || ! defined $flag || defined $check) {
10351  
10352 return $axmud::CLIENT->writeImproper($self->_objClass . '->captureEntry', @_);
10353 }
10354  
10355 if (
10356 $flag eq TRUE && $self->ivExists('captureHash', $session->number)
10357 || $flag eq FALSE && ! $self->ivExists('captureHash', $session->number)
10358 ) {
10359 # No changes to make
10360 return undef;
10361 }
10362  
10363 if ($flag) {
10364 $self->ivAdd('captureHash', $session->number, undef);
10365 } else {
10366 $self->ivDelete('captureHash', $session->number);
10367 }
10368  
10369 $self->seWidgetsIfSession();
10370  
10371 return 1;
10372 }
10373  
10374 sub obscureEntry {
10375  
10376 # Called by GA::Session->updateEcho and ->setWidgetsChangeSession
10377 # Empties the entry box, and modifies the box so that any text typed into it is either
10378 # obscured, or not (as required)
10379 #
10380 # Expected arguments
10381 # (none besides $self)
10382 #
10383 # Optional arguments
10384 # $flag - Flag set to TRUE if the entry box should be obscured, FALSE (or 'undef') if it
10385 # should be shown
10386 #
10387 # Return values
10388 # 'undef' on improper arguments
10389 # 1 otherwise
10390  
10391 my ($self, $flag, $check) = @_;
10392  
10393 # Check for improper arguments
10394 if (defined $check) {
10395  
10396 return $axmud::CLIENT->writeImproper($self->_objClass . '->obscureEntry', @_);
10397 }
10398  
10399 if ($self->entry) {
10400  
10401 $self->entry->set_text('');
10402 if ($flag) {
10403 $self->entry->set_visibility(FALSE);
10404 } else {
10405 $self->entry->set_visibility(TRUE);
10406 }
10407 }
10408  
10409 if ($self->preEntry) {
10410  
10411 $self->preEntry->set_text('');
10412 if ($flag) {
10413 $self->preEntry->set_visibility(FALSE);
10414 } else {
10415 $self->preEntry->set_visibility(TRUE);
10416 }
10417 }
10418  
10419 if ($self->postEntry) {
10420  
10421 $self->postEntry->set_text('');
10422 if ($flag) {
10423 $self->postEntry->set_visibility(FALSE);
10424 } else {
10425 $self->postEntry->set_visibility(TRUE);
10426 }
10427 }
10428  
10429 # (If $self->entry doesn't exist, the other two entry boxes don't exist either)
10430 if ($self->entry) {
10431  
10432 $self->winObj->winShowAll($self->_objClass . '->obscureEntry');
10433 }
10434  
10435 return 1;
10436 }
10437  
10438 sub commandeerEntry {
10439  
10440 # Called by GA::Obj::TextView->setButtonPressEvent and ->createPopupMenu
10441 # When an MXP <SEND>..</SEND> construction (or any other code) wants to insert a command
10442 # into the client's command line (instead of sending it to the world directly), this
10443 # function is called
10444 # The command is copied into the entry box (but only if the calling session is this window's
10445 # visible session, which it almost certainly is)
10446 #
10447 # Expected arguments
10448 # $session - The calling GA::Session
10449 # $cmd - The command to display in the entry box
10450 #
10451 # Return values
10452 # 'undef' on improper arguments, if $session is not this window's visible session or if
10453 # the $cmd is not displayed
10454 # 1 if the $cmd is displayed
10455  
10456 my ($self, $session, $cmd, $check) = @_;
10457  
10458 # Check for improper arguments
10459 if (! defined $session || ! defined $cmd || defined $check) {
10460  
10461 return $axmud::CLIENT->writeImproper($self->_objClass . '->commandeerEntry', @_);
10462 }
10463  
10464 if (! $self->winObj->visibleSession || $self->winObj->visibleSession ne $session) {
10465  
10466 # Do nothing
10467 return undef;
10468  
10469 } else {
10470  
10471 $self->entry->set_text($cmd);
10472 $self->entry->set_visibility(TRUE);
10473 $self->entry->grab_focus();
10474  
10475 $self->winObj->winShowAll($self->_objClass . '->commandeerEntry');
10476  
10477 return 1;
10478 }
10479 }
10480  
10481 sub applyBackspace {
10482  
10483 # Called by GA::Win::Internal->setKeyPressEvent when the user presses the backspace key in
10484 # special echo mode
10485 # $self->specialWorldCmd stores a copy of the world command that's being sent to the world,
10486 # one character at a time; amend the copy by removing its final character
10487 # (This doesn't guarantee that the world command stored in ->specialWorldCmd is exactly the
10488 # same as the command the world thinks it's receiving, but it should be close enough)
10489 #
10490 # Expected arguments
10491 # (none besides $self)
10492 #
10493 # Return values
10494 # 'undef' on improper arguments
10495 # 1 otherwise
10496  
10497 my ($self, $check) = @_;
10498  
10499 # Check for improper arguments
10500 if (defined $check) {
10501  
10502 return $axmud::CLIENT->writeImproper($self->_objClass . '->applyBackspace', @_);
10503 }
10504  
10505 # The calling function has done most of the checking, so just update ->specialWorldCmd
10506 if ($self->specialWorldCmd ne '') {
10507  
10508 $self->ivPoke(
10509 'specialWorldCmd',
10510 substr($self->specialWorldCmd, 0, ((length ($self->specialWorldCmd)) - 1)),
10511 );
10512 }
10513  
10514 return 1;
10515 }
10516  
10517 sub updateScrollButton {
10518  
10519 # Called by GA::Table::Pane->toggleScrollLock and ->toggleSplitScreen, and by
10520 # $self->setScrollSignals
10521 # Updates the icon shown on the 'scroll lock' button, which indicates whether the scroll
10522 # lock is applied to the active textview, or not
10523 #
10524 # Expected arguments
10525 # (none besides $self)
10526 #
10527 # Optional arguments
10528 # $flag - TRUE if the scroll lock is applied on the active textview, FALSE if it is not.
10529 # Set to 'undef' if the calling function doesn't know whether the scroll lock
10530 # is applied in the active textview, or not
10531 #
10532 # Return values
10533 # 'undef' on improper arguments
10534 # 1 otherwise
10535  
10536 my ($self, $flag, $check) = @_;
10537  
10538 # Local variables
10539 my ($paneObj, $tabNum, $tabObj);
10540  
10541 # Check for improper arguments
10542 if (defined $check) {
10543  
10544 return $axmud::CLIENT->writeImproper($self->_objClass . '->updateScrollButton', @_);
10545 }
10546  
10547 if (! defined $flag) {
10548  
10549 # Is there an active textview, and is its scroll lock applied?
10550 if ($self->paneObjList) {
10551  
10552 $paneObj = $self->ivFirst('paneObjList');
10553 if ($paneObj) {
10554  
10555 if (! $paneObj->notebook) {
10556 $tabNum = 0;
10557 } else {
10558 $tabNum = $paneObj->notebook->get_current_page();
10559 }
10560  
10561 if (defined $tabNum) {
10562  
10563 $tabObj = $paneObj->ivShow('tabObjHash', $tabNum);
10564 $flag = $tabObj->textViewObj->scrollLockFlag;
10565 }
10566 }
10567 }
10568 }
10569  
10570 # Do nothing if the button isn't visible...
10571 if ($self->scrollButton) {
10572  
10573 if (! $flag) {
10574  
10575 $self->scrollButton->set_icon_widget(
10576 Gtk3::Image->new_from_file(
10577 $axmud::SHARE_DIR . $axmud::CLIENT->constScrollIconPath
10578 ),
10579 );
10580  
10581 } else {
10582  
10583 # (Default)
10584 $self->scrollButton->set_icon_widget(
10585 Gtk3::Image->new_from_file(
10586 $axmud::SHARE_DIR . $axmud::CLIENT->constLockIconPath
10587 ),
10588 );
10589 }
10590  
10591 $self->winObj->winShowAll($self->_objClass . '->updateScrollButton');
10592 }
10593  
10594 return 1;
10595 }
10596  
10597 sub updateSplitButton {
10598  
10599 # Called by GA::Table::Pane->toggleSplitScreen
10600 # Updates the icon shown on the 'split screen' button, which indicates whether the split
10601 # screen is applied to the active textview, or not
10602 #
10603 # Expected arguments
10604 # (none besides $self)
10605 #
10606 # Optional arguments
10607 # $flag - TRUE if the split screen is applied on the active textview, FALSE if it is
10608 # not. Set to 'undef' if the calling function doesn't know whether the split
10609 # screen lock is applied in the active textview, or not
10610 #
10611 # Return values
10612 # 'undef' on improper arguments
10613 # 1 otherwise
10614  
10615 my ($self, $flag, $check) = @_;
10616  
10617 # Local variables
10618 my ($paneObj, $tabNum, $tabObj);
10619  
10620 # Check for improper arguments
10621 if (defined $check) {
10622  
10623 return $axmud::CLIENT->writeImproper($self->_objClass . '->updateSplitButton', @_);
10624 }
10625  
10626 if (! defined $flag) {
10627  
10628 # Is there an active textview, and is its split screen applied?
10629 if ($self->paneObjList) {
10630  
10631 $paneObj = $self->ivFirst('paneObjList');
10632 if ($paneObj) {
10633  
10634 if (! $paneObj->notebook) {
10635 $tabNum = 0;
10636 } else {
10637 $tabNum = $paneObj->notebook->get_current_page();
10638 }
10639  
10640 if (defined $tabNum) {
10641  
10642 $tabObj = $paneObj->ivShow('tabObjHash', $tabNum);
10643 if ($tabObj->textViewObj->splitScreenMode eq 'split') {
10644 $flag = TRUE;
10645 } else {
10646 $flag = FALSE;
10647 }
10648 }
10649 }
10650 }
10651 }
10652  
10653 # Do nothing if the button isn't visible...
10654 if ($self->splitButton) {
10655  
10656 if (! $flag) {
10657  
10658 $self->splitButton->set_icon_widget(
10659 Gtk3::Image->new_from_file(
10660 $axmud::SHARE_DIR . $axmud::CLIENT->constRestoreIconPath
10661 ),
10662 );
10663  
10664 } else {
10665  
10666 # (Default)
10667 $self->splitButton->set_icon_widget(
10668 Gtk3::Image->new_from_file(
10669 $axmud::SHARE_DIR . $axmud::CLIENT->constSplitIconPath
10670 ),
10671 );
10672 }
10673  
10674 $self->winObj->winShowAll($self->_objClass . '->updateSplitButton');
10675 }
10676  
10677 return 1;
10678 }
10679  
10680 sub updateConsoleButton {
10681  
10682 # Called by GA::Session->add_systemMsg and ->reset_systemMsg
10683 # The argument corresponds to the icon to draw on the console button
10684 #
10685 # Expected arguments
10686 # $type - One of the strings 'empty', 'system', 'debug' or 'error', corresponding to
10687 # one of the icons in ../share/icons/button that's used to draw the
10688 # button when it's not flashing
10689 #
10690 # Optional arguments
10691 # $tempType - One of the strings 'system', 'debug' or 'error', corresponding to the icon
10692 # that's used to draw the button when it's flashing ('undef' when $type is
10693 # 'empty')
10694 #
10695 # Return values
10696 # 'undef' on improper arguments
10697 # 1 otherwise
10698  
10699 my ($self, $type, $tempType, $check) = @_;
10700  
10701 # Local variables
10702 my $iv;
10703  
10704 # Check for improper arguments
10705 if (
10706 ! defined $type
10707 || ($type ne 'empty' && $type ne 'system' && $type ne 'debug' && $type ne 'error')
10708 || (
10709 defined $tempType && $tempType ne 'system' && $tempType ne 'debug'
10710 && $tempType ne 'error'
10711 )
10712 || defined $check
10713 ) {
10714 return $axmud::CLIENT->writeImproper($self->_objClass . '->updateConsoleButton', @_);
10715 }
10716  
10717 if ($self->consoleButton) {
10718  
10719 if (! $self->consoleIconFlashFlag) {
10720 $iv = 'constEmptyIconPath';
10721 } elsif ($tempType) {
10722 $iv = 'const' . ucfirst($tempType) . 'IconPath';
10723 } else {
10724 $iv = 'const' . ucfirst($type) . 'IconPath';
10725 }
10726  
10727 $self->consoleButton->set_icon_widget(
10728 Gtk3::Image->new_from_file($axmud::SHARE_DIR . $axmud::CLIENT->$iv),
10729 );
10730  
10731 $self->ivPoke('consoleIconType', $type);
10732 $self->ivPoke('consoleIconTempType', $tempType);
10733 $self->ivPoke('consoleIconFlashFlag', TRUE);
10734  
10735 $self->winObj->winShowAll($self->_objClass . '->updateConsoleButton');
10736 }
10737  
10738 return 1;
10739 }
10740  
10741 ##################
10742 # Accessors - set
10743  
10744 sub notify_addTableObj {
10745  
10746 # Called by GA::Strip::Table->addTableObj whenever a table object is added to the window's
10747 # Gtk3::Grid
10748  
10749 my ($self, $tableObj, $check) = @_;
10750  
10751 # Check for improper arguments
10752 if (! defined $tableObj || defined $check) {
10753  
10754 return $axmud::CLIENT->writeImproper($self->_objClass . '->notify_addTableObj', @_);
10755 }
10756  
10757 if ($tableObj->type eq 'pane') {
10758  
10759 # Add the pane object to the list of pane objects which can be made active with the
10760 # switch button
10761 $self->ivPush('paneObjList', $tableObj);
10762 }
10763  
10764 return 1;
10765 }
10766  
10767 sub set_consoleIconFlash {
10768  
10769 # Called by GA::Client->spinClientLoop to flash the console button
10770  
10771 my ($self, $check) = @_;
10772  
10773 # Local variables
10774 my $iv;
10775  
10776 # Check for improper arguments
10777 if (defined $check) {
10778  
10779 return $axmud::CLIENT->writeImproper($self->_objClass . '->set_consoleIconFlash', @_);
10780 }
10781  
10782 # (The calling function has already compared IVs against this window's visible session)
10783  
10784 if ($self->consoleButton && $self->consoleIconType) {
10785  
10786 if ($self->consoleIconFlashFlag) {
10787  
10788 $self->consoleButton->set_icon_widget(
10789 Gtk3::Image->new_from_file(
10790 $axmud::SHARE_DIR . $axmud::CLIENT->constEmptyIconPath,
10791 ),
10792 );
10793  
10794 $self->ivPoke('consoleIconFlashFlag', FALSE);
10795  
10796 } else {
10797  
10798 $iv = 'const' . ucfirst($self->consoleIconTempType) . 'IconPath';
10799  
10800 $self->consoleButton->set_icon_widget(
10801 Gtk3::Image->new_from_file($axmud::SHARE_DIR . $axmud::CLIENT->$iv),
10802 );
10803  
10804 $self->ivPoke('consoleIconFlashFlag', TRUE);
10805 }
10806  
10807 $self->consoleButton->show_all();
10808 }
10809  
10810 return 1;
10811 }
10812  
10813 sub reset_consoleIconFlash {
10814  
10815 # Called by GA::Session->spinMaintainLoop to stop the console button's flashing
10816  
10817 my ($self, $check) = @_;
10818  
10819 # Local variables
10820 my $iv;
10821  
10822 # Check for improper arguments
10823 if (defined $check) {
10824  
10825 return $axmud::CLIENT->writeImproper($self->_objClass . '->reset_consoleIconFlash', @_);
10826 }
10827  
10828 if ($self->consoleButton && $self->consoleIconType) {
10829  
10830 $iv = 'const' . ucfirst($self->consoleIconType) . 'IconPath';
10831  
10832 $self->consoleButton->set_icon_widget(
10833 Gtk3::Image->new_from_file($axmud::SHARE_DIR . $axmud::CLIENT->$iv),
10834 );
10835  
10836 $self->consoleButton->show_all();
10837  
10838 $self->ivPoke('consoleIconTempType', 'empty');
10839 $self->ivPoke('consoleIconFlashFlag', TRUE);
10840 }
10841  
10842 return 1;
10843 }
10844  
10845 sub set_originalEntryText {
10846  
10847 # Called by GA::Win::Internal->setKeyPressEvent
10848  
10849 my ($self, $text, $check) = @_;
10850  
10851 # Check for improper arguments
10852 if (defined $check) {
10853  
10854 return $axmud::CLIENT->writeImproper($self->_objClass . '->set_originalEntryText', @_);
10855 }
10856  
10857 $self->ivPoke('originalEntryText', $text);
10858  
10859 return 1;
10860 }
10861  
10862 sub set_recordIcon {
10863  
10864 # Called by Games::Axmud::Cmd::Record->do, etc
10865 # Updates the entry icon showing the session's recording status (but only if it's the
10866 # visible session)
10867  
10868 my ($self, $session, $check) = @_;
10869  
10870 # Check for improper arguments
10871 if (! defined $session || defined $check) {
10872  
10873 return $axmud::CLIENT->writeImproper($self->_objClass . '->set_recordIcon', @_);
10874 }
10875  
10876 if (
10877 $self->entry
10878 && $self->winObj->visibleSession
10879 && $self->winObj->visibleSession eq $session
10880 ) {
10881 if ($session->recordingPausedFlag) {
10882 $self->entry->set_icon_from_stock('secondary', 'gtk-media-pause');
10883 } elsif ($session->recordingFlag) {
10884 $self->entry->set_icon_from_stock('secondary', 'gtk-media-record');
10885 } else {
10886 $self->entry->set_icon_from_stock('secondary', undef);
10887 }
10888 }
10889  
10890 # (No IVs to update)
10891  
10892 return 1;
10893 }
10894  
10895 sub notify_removeTableObj {
10896  
10897 # Called by GA::Strip::Table->removeTableObj whenever a table object is removed from the
10898 # window's Gtk3::Grid
10899  
10900 my ($self, $tableObj, $check) = @_;
10901  
10902 # Local variables
10903 my @list;
10904  
10905 # Check for improper arguments
10906 if (! defined $tableObj || defined $check) {
10907  
10908 return $axmud::CLIENT->writeImproper($self->_objClass . '->notify_removeTableObj', @_);
10909 }
10910  
10911 # Remove the pane object from the list of pane objects which can be made active with the
10912 # switch button
10913 foreach my $paneObj ($self->paneObjList) {
10914  
10915 if ($paneObj ne $tableObj) {
10916  
10917 push (@list, $paneObj);
10918 }
10919 }
10920  
10921 $self->ivPoke('paneObjList', @list);
10922  
10923 return 1;
10924 }
10925  
10926 sub set_specialEchoFlag {
10927  
10928 # Called by GA::Session->updateSpecialEcho
10929  
10930 my ($self, $flag, $check) = @_;
10931  
10932 # Check for improper arguments
10933 if (! defined $flag || defined $check) {
10934  
10935 return $axmud::CLIENT->writeImproper($self->_objClass . '->set_specialEchoFlag', @_);
10936 }
10937  
10938 if (! $flag) {
10939  
10940 $self->ivPoke('specialEchoFlag', FALSE);
10941 $self->ivPoke('specialPreserveFlag', FALSE);
10942 $self->ivPoke('specialWorldCmd', '');
10943  
10944 } else {
10945  
10946 $self->ivPoke('specialEchoFlag', TRUE);
10947 }
10948  
10949 if ($self->addButton) {
10950  
10951 $self->addButton->set_sensitive(! $self->specialEchoFlag);
10952 }
10953  
10954 if ($self->entry) {
10955  
10956 $self->entry->set_text('');
10957 $self->entry->set_icon_from_stock('primary', undef);
10958 $self->ivUndef('primaryIcon');
10959 }
10960  
10961 return 1;
10962 }
10963  
10964 ##################
10965 # Accessors - get
10966  
10967 sub entry
10968 { $_[0]->{entry} }
10969 sub preEntry
10970 { $_[0]->{preEntry} }
10971 sub postEntry
10972 { $_[0]->{postEntry} }
10973 sub wipeButton
10974 { $_[0]->{wipeButton} }
10975 sub addButton
10976 { $_[0]->{addButton} }
10977 sub consoleButton
10978 { $_[0]->{consoleButton} }
10979 sub inputButton
10980 { $_[0]->{inputButton} }
10981 sub searchButton
10982 { $_[0]->{searchButton} }
10983 sub cancelButton
10984 { $_[0]->{cancelButton} }
10985 sub switchButton
10986 { $_[0]->{switchButton} }
10987 sub scrollButton
10988 { $_[0]->{scrollButton} }
10989 sub splitButton
10990 { $_[0]->{splitButton} }
10991  
10992 sub paneObjList
10993 { my $self = shift; return @{$self->{paneObjList}}; }
10994  
10995 sub entryBoxMode
10996 { $_[0]->{entryBoxMode} }
10997 sub originalEntryText
10998 { $_[0]->{originalEntryText} }
10999 sub captureHash
11000 { my $self = shift; return %{$self->{captureHash}}; }
11001 sub consoleIconType
11002 { $_[0]->{consoleIconType} }
11003 sub consoleIconTempType
11004 { $_[0]->{consoleIconTempType} }
11005 sub consoleIconFlashFlag
11006 { $_[0]->{consoleIconFlashFlag} }
11007  
11008 sub specialEchoFlag
11009 { $_[0]->{specialEchoFlag} }
11010 sub specialPreserveFlag
11011 { $_[0]->{specialPreserveFlag} }
11012 sub specialWorldCmd
11013 { $_[0]->{specialWorldCmd} }
11014  
11015 sub primaryIcon
11016 { $_[0]->{primaryIcon} }
11017  
11018 sub sessionHash
11019 { my $self = shift; return %{$self->{sessionHash}}; }
11020 sub prevVisibleSession
11021 { $_[0]->{prevVisibleSession} }
11022 }
11023  
11024 { package Games::Axmud::Strip::ConnectInfo;
11025  
11026 use strict;
11027 use warnings;
11028 use diagnostics;
11029  
11030 use Glib qw(TRUE FALSE);
11031  
11032 our @ISA = qw(Games::Axmud::Generic::Strip Games::Axmud);
11033  
11034 ##################
11035 # Constructors
11036  
11037 sub new {
11038  
11039 # Called by GA::Win::Internal->drawWidgets or ->addStripObj
11040 # Creates the GA::Strip::ConnectInfo - a non-compulsory strip object containing
11041 # Gtk3::Labels and blinkers
11042 #
11043 # Expected arguments
11044 # $number - The strip object's number within the parent window (matches
11045 # GA::Win::Internal->stripCount, or -1 for a temporary strip object
11046 # created to access its default IVs)
11047 # $winObj - The parent window object (GA::Win::Internal). 'temp' for temporary strip
11048 # objects
11049 #
11050 # Optional arguments
11051 # %initHash - A hash containing arbitrary data to use as the strip object's
11052 # initialisation settings. The strip object should use default
11053 # initialisation settings unless it can succesfully interpret one or more
11054 # of the key-value pairs in the hash, if there are any
11055 # - (This type of strip object requires no initialisation settings)
11056 #
11057 # Return values
11058 # 'undef' on improper arguments
11059 # Blessed reference to the newly-created object on success
11060  
11061 my ($class, $number, $winObj, %initHash) = @_;
11062  
11063 # Local variables
11064 my %modHash;
11065  
11066 # Check for improper arguments
11067 if (! defined $class || ! defined $number || ! defined $winObj) {
11068  
11069 return $axmud::CLIENT->writeImproper($class . '->new', @_);
11070 }
11071  
11072 # Setup
11073 my $self = {
11074 _objName => 'strip_' . $number,
11075 _objClass => $class,
11076 _parentFile => undef, # No parent file object
11077 _parentWorld => undef, # No parent file object
11078 _privFlag => TRUE, # All IVs are private
11079  
11080 # Standard strip object IVs
11081 # -------------------------
11082  
11083 # The strip object's number within the parent window (matches
11084 # GA::Win::Internal->stripCount, or -1 for a temporary strip object created to access
11085 # its default IVs)
11086 number => $number,
11087 # The type of strip object (custom strip objects should use a ->type starting with
11088 # 'custom_' to avoid clashing with future built-in strip objects)
11089 type => 'connect_info',
11090 # The parent window object (GA::Win::Internal). 'temp' for temporary strip objects
11091 winObj => $winObj,
11092  
11093 # Flag set to TRUE if the strip object is visible (has actually drawn widgets in the
11094 # window), set to FALSE if it is not visible (has drawn no widgets in the window, but
11095 # still exists in GA::Win::Internal->stripHash, etc)
11096 # The flag might be set to FALSE in strip objects like GA::Strip::GaugeBox, which might
11097 # have gauges to draw, or not, depending on current conditions. (Most strip objects
11098 # have this flag set to TRUE all the time)
11099 # If FALSE, GA::Win::Internal->drawWidgets and ->addStripObj don't draw any widgets when
11100 # called by this object's functions
11101 # NB Strip objects are created with this flag set to TRUE or FALSE, but once created,
11102 # the flag's value shouldn't be modified by anything other than
11103 # GA::Win::Internal->hideStripObj and ->revealStripObj (which in turn call
11104 # $self->set_visibleFlag)
11105 visibleFlag => TRUE,
11106 # Flag set to TRUE is the strip object should be given its share of any extra space
11107 # within the packing box (the extra space is divided equally between all children of
11108 # the box whose ->expandFlag is TRUE)
11109 expandFlag => FALSE,
11110 # Flag set to TRUE if any space given to the strip object by the 'expand' option is
11111 # actually allocated within the strip object, FALSE if it is used as padding outside
11112 # it (on both sides)
11113 fillFlag => FALSE,
11114 # Flag set to TRUE if the strip object should be packed into its window with a small
11115 # gap between strip objects to either side; FALSE if not (can be set to FALSE if the
11116 # the strip object's widgets are drawn in a way, such that a gap is not necessary,
11117 # for example in the toolbar strip object)
11118 spacingFlag => TRUE,
11119 # Flag set to TRUE if only one instance of this strip object should be added to the
11120 # parent window, set to FALSE if any number of instances can be added
11121 jealousyFlag => TRUE,
11122 # Flag set to TRUE if this strip object can be added when $axmud::BLIND_MODE_FLAG is
11123 # TRUE, FALSE if it can't be added (because it's not useful for visually-impaired
11124 # users)
11125 blindFlag => FALSE,
11126 # Flag set to TRUE if the main container widget, stored in $self->packingBox, should be
11127 # allowed to accept the focus, FALSE if not. The restriction is applied during the
11128 # call to GA::Win::Internal->drawWidgets and ->addStripObj. Even if FALSE, widgets in
11129 # the container widget can be set to accept the focus (e.g. the Gtk3::Entry in
11130 # GA::Strip::MenuBar)
11131 allowFocusFlag => FALSE,
11132  
11133 # Initialisation settings stored as a hash (see the comments above)
11134 initHash => \%modHash,
11135 # Reference to a function to call when some widget is used. This IV is set only when
11136 # required by this type of strip object. It can be set by a call to
11137 # $self->set_func() or by some setting in $self->initHash, which is applied in the
11138 # call to $self->objEnable(). To obtain a reference to an OOP method, you can use the
11139 # generic object function Games::Axmud->getMethodRef()
11140 funcRef => undef,
11141 # A value passed to ->funcRef when it is called which identifies this strip object and
11142 # its widget(s). Can be any value, including 'undef'. It can be set by a call to
11143 # $self->set_id() or by some setting in $self->initHash, which is applied in the call
11144 # to $self->objEnable()
11145 funcID => undef,
11146  
11147 # The container widget for this strip object (usually a Gtk3::HBox or Gtk3::VBox). This
11148 # widget is the one added to the window's main Gtk3::HBox or Gtk3::VBox
11149 packingBox => undef, # Gtk3::HBox or Gtk3::VBox
11150  
11151 # Other IVs
11152 # ---------
11153  
11154 # Widgets
11155 hostLabel => undef, # Gtk3::Label
11156 frame => undef, # Gtk3::Frame
11157 canvas => undef, # GooCanvas2::Canvas
11158 timeLabel => undef, # Gtk3::Label
11159  
11160 # The GooCanvas2::CanvasRect objects that are drawn as blinkers - little blobs of colour
11161 # which are lit up (briefly) when data is sent to and forth from the world
11162 # This version of Axmud implements the following blinker numbers:
11163 # 0 - blinker turned on when data is received from the world
11164 # 1 - blinker turned on when telnet option/protocol data (invisible to users) is
11165 # received from the world
11166 # 2 - blinker turned on when a world command is sent
11167 # In each window, only the window object's ->visibleSession can light up blinkers; when
11168 # the visible session changes, all blinkers are reset
11169 #
11170 # Hash of blinker objects (GA::Obj::Blinker), one for each blinker, in the form
11171 # $blinkerHash{number} = blessed_reference_to_blinker_object
11172 blinkerHash => {},
11173 # Number of blinker objects created
11174 blinkerCount => 3,
11175 # The portion of the GooCanvas2::Canvas required for each blinker, in pixels
11176 blinkerWidth => 20,
11177 blinkerHeight => 15,
11178 };
11179  
11180 # Bless the object into existence
11181 bless $self, $class;
11182  
11183 return $self;
11184 }
11185  
11186 ##################
11187 # Methods
11188  
11189 # Standard strip object functions
11190  
11191 sub objEnable {
11192  
11193 # Called by GA::Win::Internal->drawWidgets or ->addStripObj
11194 # Sets up the strip object's widgets
11195 #
11196 # Expected arguments
11197 # $winmapObj - The winmap object (GA::Obj::Winmap) that specifies the layout of the
11198 # parent window
11199 #
11200 # Return values
11201 # 'undef' on improper arguments
11202 # 1 on success
11203  
11204 my ($self, $winmapObj, $check) = @_;
11205  
11206 # Check for improper arguments
11207 if (! defined $winmapObj || defined $check) {
11208  
11209 return $axmud::CLIENT->writeImproper($self->_objClass . '->objEnable', @_);
11210 }
11211  
11212 # Create a packing box
11213 my $hBox = Gtk3::HBox->new(FALSE, 0);
11214 $hBox->set_border_width(0);
11215  
11216 # Add two labels and a Gtk3::Canvas for drawing blinkers
11217 my $hostLabel = Gtk3::Label->new();
11218 $hBox->pack_start($hostLabel, FALSE, FALSE, 0);
11219 $hostLabel->set_markup($self->winObj->hostLabelText);
11220  
11221 my $frame = Gtk3::Frame->new(undef);
11222 $hBox->pack_end($frame, FALSE, FALSE, 0);
11223 $frame->set_border_width(0);
11224 $frame->set_tooltip_text("Command sent | Out-of-bounds data | Text received");
11225  
11226 my $canvas = GooCanvas2::Canvas->new();
11227 $frame->add($canvas);
11228 $canvas->set_size_request(
11229 ($self->blinkerCount * $self->blinkerWidth),
11230 $self->blinkerHeight,
11231 );
11232 $canvas->set_bounds(
11233 0,
11234 0,
11235 ($self->blinkerCount * $self->blinkerWidth),
11236 $self->blinkerHeight,
11237 );
11238  
11239 my $timeLabel = Gtk3::Label->new();
11240 $hBox->pack_end($timeLabel, FALSE, FALSE, 0);
11241 $timeLabel->set_markup($self->winObj->timeLabelText);
11242 $timeLabel->set_tooltip_text("Connected | delayed Quit\nWorld idle | User idle");
11243  
11244 # Update IVs
11245 $self->ivPoke('packingBox', $hBox);
11246 $self->ivPoke('hostLabel', $hostLabel);
11247 $self->ivPoke('frame', $frame);
11248 $self->ivPoke('canvas', $canvas);
11249 $self->ivPoke('timeLabel', $timeLabel);
11250  
11251 # Create blinker objects (GA::Obj::Blinker)
11252 $self->createStandardBlinkers();
11253  
11254 # Draw the blinkers for the first time to set their 'off' colours
11255 $self->drawBlinker(
11256 -1, # Draw all three blinkers
11257 FALSE, # ...using their 'off' colour
11258 );
11259  
11260 return 1;
11261 }
11262  
11263 sub objDestroy {
11264  
11265 # Called by GA::Win::Internal->removeStripObj, just before the strip is removed from its
11266 # parent window, and also by ->winDestroy and ->resetWinmap, to give this object a chance
11267 # to do any necessary tidying up
11268 #
11269 # Expected arguments
11270 # (none besides $self)
11271 #
11272 # Return values
11273 # 'undef' on improper arguments
11274 # 1 otherwise
11275  
11276 my ($self, $check) = @_;
11277  
11278 # Check for improper arguments
11279 if (defined $check) {
11280  
11281 return $axmud::CLIENT->writeImproper($self->_objClass . '->objDestroy', @_);
11282 }
11283  
11284 # Only polite to destroy the GooCanvas2::Canvas and its items
11285 if ($self->canvas) {
11286  
11287 foreach my $blinkerObj ($self->ivValues('blinkerHash')) {
11288  
11289 if (defined $blinkerObj->canvasObj) {
11290  
11291 $blinkerObj->canvasObj->remove();
11292 }
11293 }
11294  
11295 $self->canvas->destroy();
11296 }
11297  
11298 return 1;
11299 }
11300  
11301 # sub setWidgetsIfSession {} # Inherited from GA::Generic::Strip
11302  
11303 # sub setWidgetsChangeSession {} # Inherited from GA::Generic::Strip
11304  
11305 # ->signal_connects
11306  
11307 # Other functions
11308  
11309 sub createStandardBlinkers {
11310  
11311 # Called by $self->objEnable
11312 # Creates blinker objects (GA::Obj::Blinker)
11313 #
11314 # Expected arguments
11315 # (none besides $self)
11316 #
11317 # Return values
11318 # 'undef'
11319  
11320 my ($self, $check) = @_;
11321  
11322 # Check for improper arguments
11323 if (defined $check) {
11324  
11325 return $axmud::CLIENT->writeImproper($self->_objClass . '->createStandardBlinkers', @_);
11326 }
11327  
11328 for (my $count = 0; $count < $self->blinkerCount; $count++) {
11329  
11330 my $blinkerObj = Games::Axmud::Obj::Blinker->new($count);
11331 if ($blinkerObj) {
11332  
11333 $self->ivAdd('blinkerHash', $blinkerObj->number, $blinkerObj);
11334 }
11335 }
11336  
11337 return 1;
11338 }
11339  
11340 sub drawBlinker {
11341  
11342 # Called by GA::Client->spinClientLoop or GA::Win::Internal->resetBlinkers
11343 # Draws one (or all) of the blinkers in this strip object
11344 #
11345 # Expected arguments
11346 # $choice - Which blinker to draw. -1 to draw all blinkers, or one of the keys in
11347 # $self->blinkerHash (matching GA::Obj::Blinker->number)
11348 #
11349 # Optional arguments
11350 # $onFlag - TRUE if the blinker(s) should be drawn 'on', FALSE (or 'undef') if the
11351 # blinker(s) should be drawn 'off'
11352 #
11353 # Return values
11354 # 'undef'
11355  
11356 my ($self, $choice, $onFlag, $check) = @_;
11357  
11358 # Local variables
11359 my @list;
11360  
11361 # Check for improper arguments
11362 if (! defined $choice || defined $check) {
11363  
11364 return $axmud::CLIENT->writeImproper($self->_objClass . '->drawBlinker', @_);
11365 }
11366  
11367 # Check that the blinker widgets are actually drawn (unlikely that they aren't)
11368 if (! $self->canvas) {
11369  
11370 return undef;
11371 }
11372  
11373 # Compile a list of blinkers to draw
11374 if ($choice == -1) {
11375  
11376 for (my $count = 0; $count < $self->blinkerCount; $count++) {
11377  
11378 push (@list, $count);
11379 }
11380  
11381 } else {
11382  
11383 push (@list, $choice);
11384 }
11385  
11386 # Draw each blinker in turn
11387 foreach my $number (@list) {
11388  
11389 my ($blinkerObj, $colour, $canvasObj);
11390  
11391 # Draw this blinker
11392 $blinkerObj = $self->ivShow('blinkerHash', $number);
11393 if ($blinkerObj) {
11394  
11395 # Set the colour to use
11396 if (! $onFlag) {
11397 $colour = $blinkerObj->offColour;
11398 } else {
11399 $colour = $blinkerObj->onColour;
11400 }
11401  
11402 # Destroy the old canvas item, so it can be replaced
11403 if ($blinkerObj->canvasObj) {
11404  
11405 $blinkerObj->canvasObj->remove();
11406 }
11407  
11408 $canvasObj = GooCanvas2::CanvasRect->new(
11409 'parent' => $self->canvas->get_root_item(),
11410 'x' => (($self->blinkerWidth * $number) + 3), # 2 / 22 / 42...
11411 'y' => 3, # 2
11412 'width' => $self->blinkerWidth - 6,
11413 'height' => $self->blinkerHeight - 6,
11414 # line_width = 1 looks a little harsh - doing this improves the aesthetic a bit
11415 'line_width' => 0.8,
11416 'stroke-color' => '#000000',
11417 'fill-color' => $colour,
11418 );
11419  
11420 $canvasObj->raise();
11421  
11422 # Update IVs
11423 $blinkerObj->ivPoke('canvasObj', $canvasObj);
11424 if (! $onFlag) {
11425 $blinkerObj->ivPoke('onFlag', FALSE);
11426 } else {
11427 $blinkerObj->ivPoke('onFlag', TRUE);
11428 }
11429 }
11430 }
11431  
11432 return undef;
11433 }
11434  
11435 ##################
11436 # Accessors - set
11437  
11438 sub set_hostLabel {
11439  
11440 my ($self, $text, $tooltip, $check) = @_;
11441  
11442 # Check for improper arguments
11443 if (! defined $text || defined $check) {
11444  
11445 return $axmud::CLIENT->writeImproper($self->_objClass . '->set_hostLabel', @_);
11446 }
11447  
11448 $self->hostLabel->set_markup($text);
11449 if (defined $tooltip) {
11450  
11451 $self->hostLabel->set_tooltip_text($tooltip);
11452  
11453 } else {
11454  
11455 # Make sure any earlier tooltip is no longer visible
11456 $self->hostLabel->set_tooltip_text('');
11457 }
11458  
11459 return 1;
11460 }
11461  
11462 sub set_timeLabel {
11463  
11464 my ($self, $text, $check) = @_;
11465  
11466 # Check for improper arguments
11467 if (! defined $text || defined $check) {
11468  
11469 return $axmud::CLIENT->writeImproper($self->_objClass . '->set_timeLabel', @_);
11470 }
11471  
11472 $self->timeLabel->set_markup($text);
11473  
11474 return 1;
11475 }
11476  
11477 ##################
11478 # Accessors - get
11479  
11480 sub hostLabel
11481 { $_[0]->{hostLabel} }
11482 sub frame
11483 { $_[0]->{frame} }
11484 sub canvas
11485 { $_[0]->{canvas} }
11486 sub timeLabel
11487 { $_[0]->{timeLabel} }
11488  
11489 sub blinkerHash
11490 { my $self = shift; return %{$self->{blinkerHash}}; }
11491 sub blinkerCount
11492 { $_[0]->{blinkerCount} }
11493 sub blinkerWidth
11494 { $_[0]->{blinkerWidth} }
11495 sub blinkerHeight
11496 { $_[0]->{blinkerHeight} }
11497 }
11498  
11499 { package Games::Axmud::Strip::Custom;
11500  
11501 # Any user-written strip objects should inherit from this object
11502  
11503 use strict;
11504 use warnings;
11505 use diagnostics;
11506  
11507 use Glib qw(TRUE FALSE);
11508  
11509 our @ISA = qw(Games::Axmud::Generic::Strip Games::Axmud);
11510  
11511 ##################
11512 # Constructors
11513  
11514 # sub new {} # Inherited from GA::Generic::Strip
11515  
11516 ##################
11517 # Methods
11518  
11519 # Standard strip object functions
11520  
11521 # sub objEnable {} # Inherited from GA::Generic::Strip
11522  
11523 # sub objDestroy {} # Inherited from GA::Generic::Strip
11524  
11525 # sub setWidgetsIfSession {} # Inherited from GA::Generic::Strip
11526  
11527 # sub setWidgetsChangeSession {} # Inherited from GA::Generic::Strip
11528  
11529 # ->signal_connects
11530  
11531 # Other functions
11532  
11533 ##################
11534 # Accessors - set
11535  
11536 ##################
11537 # Accessors - get
11538 }
11539  
11540 # Package must return a true value
11541 1