« blib/lib/auto/share/dist/Games-Axmud/plugins/_wilderness_cmds.pm
↑ Summary
blib/lib/Games/Axmud/Buffer.pm »
| 1 | # Copyright (C) 2011-2022 A S Lewis | ||
| 2 | # | ||
| 3 | # This program is free software: you can redistribute it and/or modify it under the terms of the GNU | ||
| 4 | # General Public License as published by the Free Software Foundation, either version 3 of the | ||
| 5 | # License, or (at your option) any later version. | ||
| 6 | # | ||
| 7 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
| 8 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 9 | # General Public License for more details. | ||
| 10 | # | ||
| 11 | # You should have received a copy of the GNU General Public License along with this program. If not, | ||
| 12 | # see <http://www.gnu.org/licenses/>. | ||
| 13 | # | ||
| 14 | # | ||
| 15 | # Games:Axmud::OtherWin::About | ||
| 16 | # The About window, showing Axmud quick help, licenses, etc | ||
| 17 | # | ||
| 18 | # Games::Axmud::OtherWin::Connect | ||
| 19 | # The Connections window, allowing the user to open a connection to a world | ||
| 20 | # | ||
| 21 | # Games::Axmud::OtherWin::ClientConsole | ||
| 22 | # The Client Console window, which can display system messages when there is no session running | ||
| 23 | # | ||
| 24 | # Games::Axmud::OtherWin::LabelDelete | ||
| 25 | # The Quick Label Deletion window, which displays labels in a region (or the whole world model), and | ||
| 26 | # invites the user to select any that should be deleted | ||
| 27 | # | ||
| 28 | # Games::Axmud::OtherWin::McpSimpleEdit | ||
| 29 | # The MCP Simple Edit window, containing a textview in which the user can type text, and some | ||
| 30 | # widgets that specify what should be done with the text | ||
| 31 | # | ||
| 32 | # Games::Axmud::OtherWin::PatternTest | ||
| 33 | # The Pattern Test window, allowing the user to check patterns/regular expressions/regexes | ||
| 34 | # | ||
| 35 | # Games::Axmud::OtherWin::QuickInput | ||
| 36 | # The Quick Input window, containing a textview in which the user can type text, and some widgets to | ||
| 37 | # specify what should be done with the text | ||
| 38 | # | ||
| 39 | # Games::Axmud::OtherWin::QuickWord | ||
| 40 | # The Quick Word window, containing various widgets for adding words to the current dictionary | ||
| 41 | # | ||
| 42 | # Games::Axmud::OtherWin::SessionConsole | ||
| 43 | # The Session Console window, which can display system messages when it's not possible to display | ||
| 44 | # them in the 'main' window | ||
| 45 | # | ||
| 46 | # Games::Axmud::OtherWin::Simulate | ||
| 47 | # The Simulate window, allowing the user to simulates various things, such as receiving text from a | ||
| 48 | # world | ||
| 49 | # | ||
| 50 | # Games::Axmud::OtherWin::SourceCode | ||
| 51 | # The Source Code Viewer window, containing a textview to show the source code for a world model | ||
| 52 | # object | ||
| 53 | # | ||
| 54 | # Games::Axmud::OtherWin::Viewer | ||
| 55 | # The object viewer window | ||
| 56 | |||
| 57 | { package Games::Axmud::OtherWin::About; | ||
| 58 | |||
| 59 | use strict; | ||
| 60 | use warnings; | ||
| 61 | use diagnostics; | ||
| 62 | |||
| 63 | use Glib qw(TRUE FALSE); | ||
| 64 | |||
| 65 | our @ISA = qw( | ||
| 66 | Games::Axmud::Generic::OtherWin Games::Axmud::Generic::FreeWin Games::Axmud::Generic::Win | ||
| 67 | Games::Axmud | ||
| 68 | ); | ||
| 69 | |||
| 70 | ################## | ||
| 71 | # Constructors | ||
| 72 | |||
| 73 | sub new { | ||
| 74 | |||
| 75 | # Called by GA::Generic::Win->createFreeWin | ||
| 76 | # Creates a new instance of the About window, which displays information usually displayed | ||
| 77 | # by the ';about' command, as well as credits, quick help and the GPL/LGPL licenses | ||
| 78 | # | ||
| 79 | # Expected arguments | ||
| 80 | # $number - Unique number for this window object | ||
| 81 | # $workspaceObj - The GA::Obj::Workspace handling the workspace in which this window | ||
| 82 | # should be created | ||
| 83 | # $owner - The owner; a 'grid' window object (but not an 'external' window) or a | ||
| 84 | # 'free' window object. When this window opens/closes, the owner is | ||
| 85 | # informed via calls to its ->add_childFreeWin / ->del_childFreeWin | ||
| 86 | # functions | ||
| 87 | # | ||
| 88 | # Optional arguments | ||
| 89 | # $session - The GA::Session from which this function was called. 'undef' if the | ||
| 90 | # calling function didn't specify a session and $owner's ->session IV | ||
| 91 | # is also 'undef' | ||
| 92 | # $title - Ignored if set (all 'other' windows define their own title) | ||
| 93 | # $editObj - Ignored if set | ||
| 94 | # $tempFlag - Ignored if set | ||
| 95 | # %configHash - Hash containing any number of key-value pairs needed for this | ||
| 96 | # particular 'other' window; set to an empty hash if not required | ||
| 97 | # - This type of window object recognises these initialisation settings: | ||
| 98 | # | ||
| 99 | # 'first_tab' => The tab to open when the window is created - 'about', | ||
| 100 | # 'credits', 'help', 'license' or 'license_2'. If not specified or | ||
| 101 | # 'undef', the first tab is opened | ||
| 102 | # | ||
| 103 | # Return values | ||
| 104 | # 'undef' on improper arguments | ||
| 105 | # Blessed reference to the newly-created object on success | ||
| 106 | |||
| 107 | my ( | ||
| 108 | $class, $number, $workspaceObj, $owner, $session, $title, $editObj, $tempFlag, | ||
| 109 | %configHash, | ||
| 110 | ) = @_; | ||
| 111 | |||
| 112 | # Local variables | ||
| 113 | my ($widthPixels, $heightPixels); | ||
| 114 | |||
| 115 | # Check for improper arguments | ||
| 116 | if (! defined $class || ! defined $number || ! defined $workspaceObj || ! defined $owner) { | ||
| 117 | |||
| 118 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 119 | } | ||
| 120 | |||
| 121 | # Only one About window can be open at a time | ||
| 122 | if ($axmud::CLIENT->aboutWin) { | ||
| 123 | |||
| 124 | $axmud::CLIENT->aboutWin->restoreFocus(); | ||
| 125 | return undef; | ||
| 126 | } | ||
| 127 | |||
| 128 | # Set the window size. Use a slightly larger window than the default, unless the user has | ||
| 129 | # specified their own default size, in which case use that | ||
| 130 | if ($axmud::CLIENT->customFreeWinWidth == $axmud::CLIENT->constFreeWinWidth) { | ||
| 131 | $widthPixels = $axmud::CLIENT->constFreeWinWidth + 50; | ||
| 132 | } else { | ||
| 133 | $widthPixels = $axmud::CLIENT->customFreeWinWidth; | ||
| 134 | } | ||
| 135 | |||
| 136 | if ($axmud::CLIENT->customFreeWinHeight == $axmud::CLIENT->constFreeWinHeight) { | ||
| 137 | $heightPixels = $axmud::CLIENT->constFreeWinHeight + 50; | ||
| 138 | } else { | ||
| 139 | $heightPixels = $axmud::CLIENT->customFreeWinHeight; | ||
| 140 | } | ||
| 141 | |||
| 142 | # Setup | ||
| 143 | my $self = { | ||
| 144 | _objName => 'other_win_' . $number, | ||
| 145 | _objClass => $class, | ||
| 146 | _parentFile => undef, # No parent file object | ||
| 147 | _parentWorld => undef, # No parent file object | ||
| 148 | _privFlag => TRUE, # All IVs are private | ||
| 149 | |||
| 150 | # Standard window object IVs | ||
| 151 | # -------------------------- | ||
| 152 | |||
| 153 | # Unique number for this window object | ||
| 154 | number => $number, | ||
| 155 | # The window category - 'grid' or 'free' | ||
| 156 | winCategory => 'free', | ||
| 157 | # The window type, any of the keys in GA::Client->constFreeWinTypeHash | ||
| 158 | winType => 'other', | ||
| 159 | # A name for the window (for some 'free' windows, the same as the window type) | ||
| 160 | winName => 'about', | ||
| 161 | # The GA::Obj::Workspace object for the workspace in which this window is created | ||
| 162 | workspaceObj => $workspaceObj, | ||
| 163 | # The owner; a 'grid' window object (but not an 'external' window) or a 'free' window | ||
| 164 | # object. When this window opens/closes, the owner is informed via calls to its | ||
| 165 | # ->add_childFreeWin / ->del_childFreeWin functions | ||
| 166 | owner => $owner, | ||
| 167 | # The GA::Session from which this function was called. 'undef' if the calling function | ||
| 168 | # didn't specify a session and $owner's ->session IV is also 'undef' | ||
| 169 | session => $session, | ||
| 170 | # When GA::Session->pseudoCmd is called to execute a client command, the mode in which | ||
| 171 | # it should be called (usually 'win_error' or 'win_only', which causes errors to be | ||
| 172 | # displayed in a 'dialogue' window) | ||
| 173 | pseudoCmdMode => 'win_error', | ||
| 174 | |||
| 175 | # The window widget. For most window objects, the Gtk3::Window. For pseudo-windows, the | ||
| 176 | # parent 'main' window's Gtk3::Window | ||
| 177 | # The code should use this IV when it wants to do something to the window itself | ||
| 178 | # (minimise it, make it active, etc) | ||
| 179 | winWidget => undef, | ||
| 180 | # The window container. For most window objects, the Gtk3::Window. For pseudo-windows, | ||
| 181 | # the parent GA::Table::PseudoWin table object | ||
| 182 | # The code should use this IV when it wants to add, modify or remove widgets inside the | ||
| 183 | # window itself | ||
| 184 | winBox => undef, | ||
| 185 | # Flag set to TRUE if the window actually exists (after a call to $self->winEnable), | ||
| 186 | # FALSE if not | ||
| 187 | enabledFlag => FALSE, | ||
| 188 | # Flag set to TRUE if the Gtk3 window itself is visible (after a call to | ||
| 189 | # $self->setVisible), FALSE if it is not visible (after a call to $self->setInvisible) | ||
| 190 | visibleFlag => TRUE, | ||
| 191 | # Registry hash of 'free' windows (excluding 'dialogue' windows) for which this window | ||
| 192 | # is the parent, a subset of GA::Obj::Desktop->freeWinHash. Hash in the form | ||
| 193 | # $childFreeWinHash{unique_number} = blessed_reference_to_window_object | ||
| 194 | childFreeWinHash => {}, | ||
| 195 | |||
| 196 | # The container widget into which all other widgets are packed (usually a Gtk3::VBox or | ||
| 197 | # Gtk3::HBox, but any container widget can be used; takes up the whole window client | ||
| 198 | # area) | ||
| 199 | packingBox => undef, # Gtk3::VBox | ||
| 200 | |||
| 201 | # Standard IVs for 'free' windows | ||
| 202 | |||
| 203 | # The window's default size, in pixels | ||
| 204 | widthPixels => $widthPixels, | ||
| 205 | heightPixels => $heightPixels, | ||
| 206 | # Default border/item spacing sizes used in the window, in pixels | ||
| 207 | borderPixels => $axmud::CLIENT->constFreeBorderPixels, | ||
| 208 | spacingPixels => $axmud::CLIENT->constFreeSpacingPixels, | ||
| 209 | |||
| 210 | # A string to use as the window title. If 'undef', a generic title is used | ||
| 211 | title => $axmud::SCRIPT . ' information', | ||
| 212 | # Hash containing any number of key-value pairs needed for this particular 'config' | ||
| 213 | # window; for example, for example, GA::PrefWin::TaskStart uses it to specify a task | ||
| 214 | # name and type. Set to an empty hash if not required | ||
| 215 | configHash => {%configHash}, | ||
| 216 | |||
| 217 | # IVs for this type of window | ||
| 218 | |||
| 219 | # Widgets | ||
| 220 | notebook => undef, # Gtk3::Notebook | ||
| 221 | button => undef, # Gtk3::Button | ||
| 222 | }; | ||
| 223 | |||
| 224 | # Bless the object into existence | ||
| 225 | bless $self, $class; | ||
| 226 | |||
| 227 | return $self; | ||
| 228 | } | ||
| 229 | |||
| 230 | ################## | ||
| 231 | # Methods | ||
| 232 | |||
| 233 | # Standard window object functions | ||
| 234 | |||
| 235 | # sub winSetup {} # Inherited from GA::Generic::FreeWin | ||
| 236 | |||
| 237 | sub winEnable { | ||
| 238 | |||
| 239 | # Called by GA::Generic::Win->createFreeWin, after the call to $self->winSetup | ||
| 240 | # After the Gtk3::Window has been setup and moved into position, makes it visible | ||
| 241 | # | ||
| 242 | # Expected arguments | ||
| 243 | # (none besides $self) | ||
| 244 | # | ||
| 245 | # Return values | ||
| 246 | # 'undef' on improper arguments | ||
| 247 | # 1 on success | ||
| 248 | |||
| 249 | my ($self, $check) = @_; | ||
| 250 | |||
| 251 | # Local variables | ||
| 252 | my $firstTab; | ||
| 253 | |||
| 254 | # Check for improper arguments | ||
| 255 | if (defined $check) { | ||
| 256 | |||
| 257 | return $axmud::CLIENT->writeImproper($self->_objClass . '->winEnable', @_); | ||
| 258 | } | ||
| 259 | |||
| 260 | # Make the window appear on the desktop | ||
| 261 | $self->winShowAll($self->_objClass . '->winEnable'); | ||
| 262 | $self->ivPoke('enabledFlag', TRUE); | ||
| 263 | |||
| 264 | # This type of window is unique (only one can be open at any time); inform the GA::Client | ||
| 265 | # it has opened | ||
| 266 | $axmud::CLIENT->set_aboutWin($self); | ||
| 267 | |||
| 268 | # If a tab to show on startup was specified, open it | ||
| 269 | $firstTab = $self->ivShow('configHash', 'first_tab'); | ||
| 270 | if (defined $firstTab) { | ||
| 271 | |||
| 272 | # (Window is open at the 'about' tab by default, so we don't have to check that | ||
| 273 | # $firstTab is set to 'about') | ||
| 274 | if ($firstTab eq 'credits') { | ||
| 275 | $self->notebook->set_current_page(1); | ||
| 276 | } elsif ($firstTab eq 'help') { | ||
| 277 | $self->notebook->set_current_page(2); | ||
| 278 | } elsif ($firstTab eq 'peek') { | ||
| 279 | $self->notebook->set_current_page(3); | ||
| 280 | } elsif ($firstTab eq 'changes') { | ||
| 281 | $self->notebook->set_current_page(4); | ||
| 282 | } elsif ($firstTab eq 'install') { | ||
| 283 | $self->notebook->set_current_page(5); | ||
| 284 | } elsif ($firstTab eq 'license') { | ||
| 285 | $self->notebook->set_current_page(6); | ||
| 286 | } elsif ($firstTab eq 'license_2') { | ||
| 287 | $self->notebook->set_current_page(7); | ||
| 288 | } | ||
| 289 | } | ||
| 290 | |||
| 291 | return 1; | ||
| 292 | } | ||
| 293 | |||
| 294 | # sub winDesengage {} # Inherited from GA::Generic::FreeWin | ||
| 295 | |||
| 296 | sub winDestroy { | ||
| 297 | |||
| 298 | # Can be called by anything | ||
| 299 | # Updates IVs | ||
| 300 | # | ||
| 301 | # Expected arguments | ||
| 302 | # (none besides $self) | ||
| 303 | # | ||
| 304 | # Return values | ||
| 305 | # 'undef' on improper arguments, if the window can't be destroyed or if it has already | ||
| 306 | # been destroyed | ||
| 307 | # 1 on success | ||
| 308 | |||
| 309 | my ($self, $check) = @_; | ||
| 310 | |||
| 311 | # Check for improper arguments | ||
| 312 | if (defined $check) { | ||
| 313 | |||
| 314 | return $axmud::CLIENT->writeImproper($self->_objClass . '->winDestroy', @_); | ||
| 315 | } | ||
| 316 | |||
| 317 | if (! $self->winBox) { | ||
| 318 | |||
| 319 | # Window already destroyed in a previous call to this function | ||
| 320 | return undef; | ||
| 321 | } | ||
| 322 | |||
| 323 | # Close any 'free' windows for which this window is a parent | ||
| 324 | foreach my $winObj ($self->ivValues('childFreeWinHash')) { | ||
| 325 | |||
| 326 | $winObj->winDestroy(); | ||
| 327 | } | ||
| 328 | |||
| 329 | # Destroy the Gtk3::Window | ||
| 330 | eval { $self->winBox->destroy(); }; | ||
| 331 | if ($@) { | ||
| 332 | |||
| 333 | # Window can't be destroyed | ||
| 334 | return undef; | ||
| 335 | |||
| 336 | } else { | ||
| 337 | |||
| 338 | $self->ivUndef('winWidget'); | ||
| 339 | $self->ivUndef('winBox'); | ||
| 340 | } | ||
| 341 | |||
| 342 | # Inform the owner and the desktop object of this 'free' window's demise | ||
| 343 | $axmud::CLIENT->desktopObj->del_freeWin($self); | ||
| 344 | if ($self->owner) { | ||
| 345 | |||
| 346 | $self->owner->del_childFreeWin($self); | ||
| 347 | } | ||
| 348 | |||
| 349 | # This type of window is unique (only one can be open at any time); inform the GA::Client | ||
| 350 | # it has closed | ||
| 351 | $axmud::CLIENT->set_aboutWin(); | ||
| 352 | |||
| 353 | return 1; | ||
| 354 | } | ||
| 355 | |||
| 356 | # sub winShowAll {} # Inherited from GA::Generic::Win | ||
| 357 | |||
| 358 | sub drawWidgets { | ||
| 359 | |||
| 360 | # Called by $self->winSetup | ||
| 361 | # Sets up the About window with its standard widgets | ||
| 362 | # | ||
| 363 | # Expected arguments | ||
| 364 | # (none besides $self) | ||
| 365 | # | ||
| 366 | # Return values | ||
| 367 | # 'undef' on improper arguments | ||
| 368 | # 1 otherwise | ||
| 369 | |||
| 370 | my ($self, $check) = @_; | ||
| 371 | |||
| 372 | # Local variables | ||
| 373 | my ( | ||
| 374 | $file, $fileHandle, | ||
| 375 | @aboutList, @helpList, @peekList, @changesList, @installList, @licenseList, | ||
| 376 | @license2List, | ||
| 377 | ); | ||
| 378 | |||
| 379 | # Check for improper arguments | ||
| 380 | if (defined $check) { | ||
| 381 | |||
| 382 | return $axmud::CLIENT->writeImproper($self->_objClass . '->drawWidgets', @_); | ||
| 383 | } | ||
| 384 | |||
| 385 | # Create a packing box | ||
| 386 | my $packingBox = Gtk3::VBox->new(FALSE, 0); | ||
| 387 | $self->winBox->add($packingBox); | ||
| 388 | $packingBox->set_border_width(0); | ||
| 389 | |||
| 390 | # Create an image on the left | ||
| 391 | my $hBox = Gtk3::HBox->new(FALSE, 0); | ||
| 392 | $packingBox->pack_start($hBox, TRUE, TRUE, 0); | ||
| 393 | |||
| 394 | my $vBox = Gtk3::VBox->new(FALSE, 0); | ||
| 395 | $hBox->pack_start($vBox, FALSE, FALSE, 0); | ||
| 396 | |||
| 397 | my $frame = Gtk3::Frame->new(undef); | ||
| 398 | $vBox->pack_start($frame, FALSE, FALSE, 0); | ||
| 399 | $frame->set_size_request(64, 64); | ||
| 400 | $frame->set_shadow_type($axmud::CLIENT->constShadowType); | ||
| 401 | |||
| 402 | my $image = Gtk3::Image->new_from_file($axmud::CLIENT->getDialogueIcon()); | ||
| 403 | $frame->add($image); | ||
| 404 | |||
| 405 | # Create a notebook on the right | ||
| 406 | my $notebook = Gtk3::Notebook->new(); | ||
| 407 | $hBox->pack_start($notebook, TRUE, TRUE, $self->spacingPixels); | ||
| 408 | $notebook->set_scrollable(TRUE); | ||
| 409 | $notebook->popup_enable(); | ||
| 410 | |||
| 411 | # Create a button at the bottom | ||
| 412 | my $hBox2 = Gtk3::HBox->new(FALSE, 0); | ||
| 413 | $packingBox->pack_end($hBox2, FALSE, FALSE, $self->spacingPixels); | ||
| 414 | |||
| 415 | # The button's label includes some extra space characters to make it a little easier to | ||
| 416 | # click on | ||
| 417 | my $button = Gtk3::Button->new(' OK '); | ||
| 418 | $hBox2->pack_end($button, FALSE, FALSE, 0); | ||
| 419 | $button->get_child->set_width_chars(10); | ||
| 420 | $button->signal_connect('clicked' => sub { | ||
| 421 | |||
| 422 | $self->winDestroy(); | ||
| 423 | }); | ||
| 424 | |||
| 425 | # Add the 'about' tab to the notebook | ||
| 426 | push (@aboutList, | ||
| 427 | $axmud::SCRIPT . ' v' . $axmud::VERSION . ' (' . $axmud::DATE . ') by ' | ||
| 428 | . $axmud::AUTHORS, | ||
| 429 | $axmud::COPYRIGHT, | ||
| 430 | 'Website: ' . $axmud::URL, | ||
| 431 | ' ', # Empty line | ||
| 432 | @axmud::LICENSE_LIST, | ||
| 433 | ); | ||
| 434 | |||
| 435 | $self->addTab($notebook, '_About', TRUE, @aboutList); | ||
| 436 | |||
| 437 | # Add the 'credits' tab to the notebook | ||
| 438 | $self->addTab($notebook, '_Credits', TRUE, @axmud::CREDIT_LIST); | ||
| 439 | |||
| 440 | # Load the quick help file | ||
| 441 | $file = $axmud::SHARE_DIR . '/help/misc/quickhelp'; | ||
| 442 | if (! (-e $file)) { | ||
| 443 | |||
| 444 | push (@helpList, 'Quick help file missing'); | ||
| 445 | |||
| 446 | } else { | ||
| 447 | |||
| 448 | if (! open($fileHandle, $file)) { | ||
| 449 | |||
| 450 | push (@helpList, 'Unable to read quick help file'); | ||
| 451 | |||
| 452 | } else { | ||
| 453 | |||
| 454 | @helpList = <$fileHandle>; | ||
| 455 | close($fileHandle); | ||
| 456 | } | ||
| 457 | } | ||
| 458 | |||
| 459 | # Add the 'help' tab to the notebook | ||
| 460 | $self->addTab($notebook, 'Quick _help', FALSE, @helpList); | ||
| 461 | |||
| 462 | # Load the peek/poke help file | ||
| 463 | $file = $axmud::SHARE_DIR . '/help/misc/peekpoke'; | ||
| 464 | if (! (-e $file)) { | ||
| 465 | |||
| 466 | push (@peekList, 'Peek/poke help file missing'); | ||
| 467 | |||
| 468 | } else { | ||
| 469 | |||
| 470 | if (! open($fileHandle, $file)) { | ||
| 471 | |||
| 472 | push (@peekList, 'Unable to read peek/poke help file'); | ||
| 473 | |||
| 474 | } else { | ||
| 475 | |||
| 476 | @peekList = <$fileHandle>; | ||
| 477 | close($fileHandle); | ||
| 478 | } | ||
| 479 | } | ||
| 480 | |||
| 481 | # Add the 'peek/poke' tab to the notebook | ||
| 482 | $self->addTab($notebook, '_Peek/Poke', FALSE, @peekList); | ||
| 483 | |||
| 484 | # Load the CHANGES file | ||
| 485 | $file = $axmud::SHARE_DIR . '/../CHANGES'; | ||
| 486 | if (! (-e $file)) { | ||
| 487 | |||
| 488 | push (@peekList, 'Changes file missing'); | ||
| 489 | |||
| 490 | } else { | ||
| 491 | |||
| 492 | if (! open($fileHandle, $file)) { | ||
| 493 | |||
| 494 | push ( | ||
| 495 | @changesList, | ||
| 496 | 'Unable to read changes file', | ||
| 497 | ); | ||
| 498 | |||
| 499 | } else { | ||
| 500 | |||
| 501 | @changesList = <$fileHandle>; | ||
| 502 | close($fileHandle); | ||
| 503 | } | ||
| 504 | } | ||
| 505 | |||
| 506 | # Add the 'changes' tab to the notebook | ||
| 507 | $self->addTab($notebook, 'Cha_nges', FALSE, @changesList); | ||
| 508 | |||
| 509 | # Load the GPL license file | ||
| 510 | $file = $axmud::SHARE_DIR . '/../COPYING'; | ||
| 511 | if (! (-e $file)) { | ||
| 512 | |||
| 513 | push (@licenseList, 'License file missing. Go to <http://www.gnu.org/licenses/>'); | ||
| 514 | |||
| 515 | } else { | ||
| 516 | |||
| 517 | if (! open($fileHandle, $file)) { | ||
| 518 | |||
| 519 | push ( | ||
| 520 | @licenseList, | ||
| 521 | 'Unable to read license file. Go to <http://www.gnu.org/licenses/>', | ||
| 522 | ); | ||
| 523 | |||
| 524 | } else { | ||
| 525 | |||
| 526 | @licenseList = <$fileHandle>; | ||
| 527 | close($fileHandle); | ||
| 528 | } | ||
| 529 | } | ||
| 530 | |||
| 531 | # Add the 'license' tab to the notebook | ||
| 532 | $self->addTab($notebook, '_GPL License', FALSE, @licenseList); | ||
| 533 | |||
| 534 | # Load the LGPL license file | ||
| 535 | $file = $axmud::SHARE_DIR . '/../COPYING.LESSER'; | ||
| 536 | if (! (-e $file)) { | ||
| 537 | |||
| 538 | push (@license2List, 'License file missing. Go to <http://www.gnu.org/licenses/>'); | ||
| 539 | |||
| 540 | } else { | ||
| 541 | |||
| 542 | if (! open($fileHandle, $file)) { | ||
| 543 | |||
| 544 | push ( | ||
| 545 | @license2List, | ||
| 546 | 'Unable to read license file. Go to <http://www.gnu.org/licenses/>', | ||
| 547 | ); | ||
| 548 | |||
| 549 | } else { | ||
| 550 | |||
| 551 | @license2List = <$fileHandle>; | ||
| 552 | close($fileHandle); | ||
| 553 | } | ||
| 554 | } | ||
| 555 | |||
| 556 | # Add the 'license' tab to the notebook | ||
| 557 | $self->addTab($notebook, '_LGPL License', FALSE, @license2List); | ||
| 558 | |||
| 559 | # Update IVs | ||
| 560 | $self->ivPoke('packingBox', $packingBox); | ||
| 561 | $self->ivPoke('notebook', $notebook); | ||
| 562 | $self->ivPoke('button', $button); | ||
| 563 | |||
| 564 | return 1; | ||
| 565 | } | ||
| 566 | |||
| 567 | # sub redrawWidgets {} # Inherited from GA::Generic::Win | ||
| 568 | |||
| 569 | # ->signal_connects | ||
| 570 | |||
| 571 | # Other functions | ||
| 572 | |||
| 573 | sub addTab { | ||
| 574 | |||
| 575 | # Called by $self->drawWidgets | ||
| 576 | # Adds a tab to the About window's notebook | ||
| 577 | # | ||
| 578 | # Expected arguments | ||
| 579 | # $notebook - The Gtk3::Notebook to which the tab must be added | ||
| 580 | # $label - The tab's label text | ||
| 581 | # | ||
| 582 | # Optional arguments | ||
| 583 | # $newlineFlag - TRUE if a newline character should be added to every line in @list, | ||
| 584 | # FALSE if not (because the contents of @list were loaded from a file | ||
| 585 | # and already contain newline characters) | ||
| 586 | # @list - A list of lines to add to the Gtk3::TextView (can be an empty list) | ||
| 587 | # | ||
| 588 | # Return values | ||
| 589 | # 'undef' on improper arguments | ||
| 590 | # 1 otherwise | ||
| 591 | |||
| 592 | my ($self, $notebook, $label, $newlineFlag, @list) = @_; | ||
| 593 | |||
| 594 | # Check for improper arguments | ||
| 595 | if (! defined $notebook || ! defined $label) { | ||
| 596 | |||
| 597 | return $axmud::CLIENT->writeImproper($self->_objClass . '->addTab', @_); | ||
| 598 | } | ||
| 599 | |||
| 600 | # Add the tab | ||
| 601 | my $tab = Gtk3::Label->new_with_mnemonic($label); | ||
| 602 | |||
| 603 | my $scroller = Gtk3::ScrolledWindow->new(); | ||
| 604 | $notebook->append_page($scroller, $tab); | ||
| 605 | $scroller->set_policy('automatic', 'automatic'); | ||
| 606 | |||
| 607 | # Create a textview using the system's preferred colours and fonts | ||
| 608 | my $textView = Gtk3::TextView->new(); | ||
| 609 | $scroller->add_with_viewport($textView); | ||
| 610 | my $buffer = Gtk3::TextBuffer->new(); | ||
| 611 | $textView->set_buffer($buffer); | ||
| 612 | $textView->set_editable(FALSE); | ||
| 613 | $textView->set_cursor_visible(FALSE); | ||
| 614 | $axmud::CLIENT->desktopObj->setTextViewStyle($self->winType, $textView); | ||
| 615 | |||
| 616 | # Fill the textview | ||
| 617 | if (! $newlineFlag) { | ||
| 618 | $buffer->set_text(join("", @list)); | ||
| 619 | } else { | ||
| 620 | $buffer->set_text(join("\n", @list)); | ||
| 621 | } | ||
| 622 | |||
| 623 | return 1 | ||
| 624 | } | ||
| 625 | |||
| 626 | ################## | ||
| 627 | # Accessors - set | ||
| 628 | |||
| 629 | ################## | ||
| 630 | # Accessors - get | ||
| 631 | |||
| 632 | sub notebook | ||
| 633 | { $_[0]->{notebook} } | ||
| 634 | sub button | ||
| 635 | { $_[0]->{button} } | ||
| 636 | } | ||
| 637 | |||
| 638 | { package Games::Axmud::OtherWin::Connect; | ||
| 639 | |||
| 640 | use strict; | ||
| 641 | use warnings; | ||
| 642 | use diagnostics; | ||
| 643 | |||
| 644 | use Glib qw(TRUE FALSE); | ||
| 645 | |||
| 646 | our @ISA = qw( | ||
| 647 | Games::Axmud::Generic::OtherWin Games::Axmud::Generic::FreeWin Games::Axmud::Generic::Win | ||
| 648 | Games::Axmud | ||
| 649 | ); | ||
| 650 | |||
| 651 | ################## | ||
| 652 | # Constructors | ||
| 653 | |||
| 654 | sub new { | ||
| 655 | |||
| 656 | # Called by GA::Generic::Win->createFreeWin | ||
| 657 | # Creates a new instance of the Connections window, which displays a list of world | ||
| 658 | # profiles and invites the user to connect to one of them | ||
| 659 | # | ||
| 660 | # Expected arguments | ||
| 661 | # $number - Unique number for this window object | ||
| 662 | # $workspaceObj - The GA::Obj::Workspace handling the workspace in which this window | ||
| 663 | # should be created | ||
| 664 | # $owner - The owner; a 'grid' window object (but not an 'external' window) or a | ||
| 665 | # 'free' window object. When this window opens/closes, the owner is | ||
| 666 | # informed via calls to its ->add_childFreeWin / ->del_childFreeWin | ||
| 667 | # functions | ||
| 668 | # | ||
| 669 | # Optional arguments | ||
| 670 | # $session - The GA::Session from which this function was called. 'undef' if the | ||
| 671 | # calling function didn't specify a session and $owner's ->session IV | ||
| 672 | # is also 'undef' | ||
| 673 | # $title - Ignored if set (all 'other' windows define their own title) | ||
| 674 | # $editObj - Ignored if set | ||
| 675 | # $tempFlag - Ignored if set | ||
| 676 | # %configHash - Hash containing any number of key-value pairs needed for this | ||
| 677 | # particular 'other' window; set to an empty hash if not required | ||
| 678 | # - This type of window object recognises these initialisation settings: | ||
| 679 | # | ||
| 680 | # ... | ||
| 681 | # | ||
| 682 | # Return values | ||
| 683 | # 'undef' on improper arguments | ||
| 684 | # Blessed reference to the newly-created object on success | ||
| 685 | |||
| 686 | my ( | ||
| 687 | $class, $number, $workspaceObj, $owner, $session, $title, $editObj, $tempFlag, | ||
| 688 | %configHash, | ||
| 689 | ) = @_; | ||
| 690 | |||
| 691 | # Local variables | ||
| 692 | my ($widthPixels, $heightPixels); | ||
| 693 | |||
| 694 | # Check for improper arguments | ||
| 695 | if (! defined $class || ! defined $number || ! defined $workspaceObj || ! defined $owner) { | ||
| 696 | |||
| 697 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 698 | } | ||
| 699 | |||
| 700 | # Only one Connections window can be open at a time | ||
| 701 | if ($axmud::CLIENT->connectWin) { | ||
| 702 | |||
| 703 | $axmud::CLIENT->connectWin->restoreFocus(); | ||
| 704 | return undef; | ||
| 705 | } | ||
| 706 | |||
| 707 | # Set the window size. Use a slightly larger window than the default, unless the user has | ||
| 708 | # specified their own default size, in which case use that | ||
| 709 | if ($axmud::CLIENT->customFreeWinWidth == $axmud::CLIENT->constFreeWinWidth) { | ||
| 710 | $widthPixels = $axmud::CLIENT->constFreeWinWidth + 100; | ||
| 711 | } else { | ||
| 712 | $widthPixels = $axmud::CLIENT->customFreeWinWidth; | ||
| 713 | } | ||
| 714 | |||
| 715 | if ($axmud::CLIENT->customFreeWinHeight == $axmud::CLIENT->constFreeWinHeight) { | ||
| 716 | $heightPixels = $axmud::CLIENT->constFreeWinHeight + 50; | ||
| 717 | } else { | ||
| 718 | $heightPixels = $axmud::CLIENT->customFreeWinHeight; | ||
| 719 | } | ||
| 720 | |||
| 721 | # Setup | ||
| 722 | my $self = { | ||
| 723 | _objName => 'other_win_' . $number, | ||
| 724 | _objClass => $class, | ||
| 725 | _parentFile => undef, # No parent file object | ||
| 726 | _parentWorld => undef, # No parent file object | ||
| 727 | _privFlag => TRUE, # All IVs are private | ||
| 728 | |||
| 729 | # Standard window object IVs | ||
| 730 | # -------------------------- | ||
| 731 | |||
| 732 | # Unique number for this window object | ||
| 733 | number => $number, | ||
| 734 | # The window category - 'grid' or 'free' | ||
| 735 | winCategory => 'free', | ||
| 736 | # The window type, any of the keys in GA::Client->constFreeWinTypeHash | ||
| 737 | winType => 'other', | ||
| 738 | # A name for the window (for some 'free' windows, the same as the window type) | ||
| 739 | winName => 'connect' , | ||
| 740 | # The GA::Obj::Workspace object for the workspace in which this window is created | ||
| 741 | workspaceObj => $workspaceObj, | ||
| 742 | # The owner; a 'grid' window object (but not an 'external' window) or a 'free' window | ||
| 743 | # object. When this window opens/closes, the owner is informed via calls to its | ||
| 744 | # ->add_childFreeWin / ->del_childFreeWin functions | ||
| 745 | owner => $owner, | ||
| 746 | # The GA::Session from which this function was called. 'undef' if the calling function | ||
| 747 | # didn't specify a session and $owner's ->session IV is also 'undef' | ||
| 748 | session => $session, | ||
| 749 | # When GA::Session->pseudoCmd is called to execute a client command, the mode in which | ||
| 750 | # it should be called (usually 'win_error' or 'win_only', which causes errors to be | ||
| 751 | # displayed in a 'dialogue' window) | ||
| 752 | pseudoCmdMode => 'win_error', | ||
| 753 | |||
| 754 | # The window widget. For most window objects, the Gtk3::Window. For pseudo-windows, the | ||
| 755 | # parent 'main' window's Gtk3::Window | ||
| 756 | # The code should use this IV when it wants to do something to the window itself | ||
| 757 | # (minimise it, make it active, etc) | ||
| 758 | winWidget => undef, | ||
| 759 | # The window container. For most window objects, the Gtk3::Window. For pseudo-windows, | ||
| 760 | # the parent GA::Table::PseudoWin table object | ||
| 761 | # The code should use this IV when it wants to add, modify or remove widgets inside the | ||
| 762 | # window itself | ||
| 763 | winBox => undef, | ||
| 764 | # Flag set to TRUE if the window actually exists (after a call to $self->winEnable), | ||
| 765 | # FALSE if not | ||
| 766 | enabledFlag => FALSE, | ||
| 767 | # Flag set to TRUE if the Gtk3 window itself is visible (after a call to | ||
| 768 | # $self->setVisible), FALSE if it is not visible (after a call to $self->setInvisible) | ||
| 769 | visibleFlag => TRUE, | ||
| 770 | # Registry hash of 'free' windows (excluding 'dialogue' windows) for which this window | ||
| 771 | # is the parent, a subset of GA::Obj::Desktop->freeWinHash. Hash in the form | ||
| 772 | # $childFreeWinHash{unique_number} = blessed_reference_to_window_object | ||
| 773 | childFreeWinHash => {}, | ||
| 774 | # When a child 'free' window (excluding 'dialogue' windows) is destroyed, this parent | ||
| 775 | # window is informed via a call to $self->del_childFreeWin | ||
| 776 | # When the child is destroyed, this window might want to call some of its own functions | ||
| 777 | # to update various widgets and/or IVs, in which case this window adds an entry to | ||
| 778 | # this hash; a hash in the form | ||
| 779 | # $childDestroyHash{unique_number} = list_reference | ||
| 780 | # ...where 'unique_number' is the child window's ->number, and 'list_reference' is a | ||
| 781 | # reference to a list in groups of 2, in the form | ||
| 782 | # (sub_name, argument_list_ref, sub_name, argument_list_ref...) | ||
| 783 | childDestroyHash => {}, | ||
| 784 | |||
| 785 | # The container widget into which all other widgets are packed (usually a Gtk3::VBox or | ||
| 786 | # Gtk3::HBox, but any container widget can be used; takes up the whole window client | ||
| 787 | # area) | ||
| 788 | packingBox => undef, | ||
| 789 | |||
| 790 | # Standard IVs for 'free' windows | ||
| 791 | |||
| 792 | # The window's default size, in pixels | ||
| 793 | widthPixels => $widthPixels, | ||
| 794 | heightPixels => $heightPixels, | ||
| 795 | # Default border/item spacing sizes used in the window, in pixels | ||
| 796 | borderPixels => $axmud::CLIENT->constFreeBorderPixels, | ||
| 797 | spacingPixels => $axmud::CLIENT->constFreeSpacingPixels, | ||
| 798 | |||
| 799 | # A string to use as the window title. If 'undef', a generic title is used | ||
| 800 | title => $axmud::SCRIPT . ' Connections', | ||
| 801 | # Hash containing any number of key-value pairs needed for this particular 'config' | ||
| 802 | # window; for example, for example, GA::PrefWin::TaskStart uses it to specify a task | ||
| 803 | # name and type. Set to an empty hash if not required | ||
| 804 | configHash => {%configHash}, | ||
| 805 | |||
| 806 | # IVs for this type of window | ||
| 807 | |||
| 808 | # Widgets | ||
| 809 | hPaned => undef, # Gtk3::HPaned | ||
| 810 | # Left section widgets | ||
| 811 | vBox => undef, # Gtk3::VBox | ||
| 812 | frame => undef, # Gtk3::Frame | ||
| 813 | image => undef, # Gtk3::Image | ||
| 814 | hBox => undef, # Gtk3::HBox | ||
| 815 | objModel => undef, # Gtk3::TreeStore | ||
| 816 | treeView => undef, # Gtk3::TreeView | ||
| 817 | treeViewColumn => undef, # Gtk3::TreeViewColumn | ||
| 818 | frame2 => undef, # Gtk3::Frame | ||
| 819 | scroller => undef, # Gtk3::ScrolledWindow | ||
| 820 | # Right section widgets | ||
| 821 | frame3 => undef, # Gtk3::Frame | ||
| 822 | scroller2 => undef, # Gtk3::ScrolledWindow | ||
| 823 | grid => undef, # Gtk3::Grid | ||
| 824 | # Strip widgets | ||
| 825 | preConfigButton => undef, # Gtk3::RadioToolButton | ||
| 826 | otherWorldButton => undef, # Gtk3::RadioToolButton | ||
| 827 | sortAzButton => undef, # Gtk3::RadioToolButton | ||
| 828 | sortZaButton => undef, # Gtk3::RadioToolButton | ||
| 829 | sortRandButton => undef, # Gtk3::RadioToolButton | ||
| 830 | searchButton => undef, # Gtk3::Button | ||
| 831 | cancelSearchButton => undef, # Gtk3::Button | ||
| 832 | consoleButton => undef, # Gtk3::Button | ||
| 833 | # Grid widgets | ||
| 834 | entry => undef, # Gtk3::Entry | ||
| 835 | entry2 => undef, # Gtk3::Entry | ||
| 836 | entry3 => undef, # Gtk3::Entry | ||
| 837 | radioButton => undef, # Gtk3::RadioButton | ||
| 838 | radioButton2 => undef, # Gtk3::RadioButton | ||
| 839 | radioButton3 => undef, # Gtk3::RadioButton | ||
| 840 | radioButton4 => undef, # Gtk3::RadioButton | ||
| 841 | checkButton => undef, # Gtk3::CheckButton | ||
| 842 | comboBox => undef, # Gtk3::ComboBox | ||
| 843 | addCharButton => undef, # Gtk3::Button | ||
| 844 | editPwdButton => undef, # Gtk3::Button | ||
| 845 | editAccButton => undef, # Gtk3::Button | ||
| 846 | websiteLabel => undef, # Gtk3::Label | ||
| 847 | connectionLabel => undef, # Gtk3::Label | ||
| 848 | descripTextView => undef, # Gtk3::TextView | ||
| 849 | descripBuffer => undef, # Gtk3::TextBuffer | ||
| 850 | createWorldButton => undef, # Gtk3::Button | ||
| 851 | resetWorldButton => undef, # Gtk3::Button | ||
| 852 | offlineButton => undef, # Gtk3::Button | ||
| 853 | connectButton => undef, # Gtk3::Button | ||
| 854 | |||
| 855 | # Path to the default icon to use in the top-left corner | ||
| 856 | defaultIcon => $axmud::CLIENT->getClientLogo(), | ||
| 857 | # The size of the image containing each world's icon (or the default icon) | ||
| 858 | imageWidth => 300, | ||
| 859 | imageHeight => 200, | ||
| 860 | # Standard size of the Gtk3::Grid used (a 12x12 grid, with a spare cell around every | ||
| 861 | # border) | ||
| 862 | gridWidth => 13, | ||
| 863 | gridHeight => 13, | ||
| 864 | |||
| 865 | # A hash linking all the world names listed in the treeview to their corresponding | ||
| 866 | # world profile object. Hash in the form | ||
| 867 | # $worldHash{name} = blessed_reference_to_world_profile | ||
| 868 | # ...where 'name' can be the world's ->name or its ->longName, depending on how it was | ||
| 869 | # displayed in the treeview | ||
| 870 | # NB ->worldHash also contains an entry in the form | ||
| 871 | # $worldHash{create_new_world_string} = undef; | ||
| 872 | worldHash => {}, | ||
| 873 | # A hash of GA::Obj::MiniWorld objects, which store changes made to the profiles in the | ||
| 874 | # Connections window until it's time to copy them into the main world profile object. | ||
| 875 | # Hash in the form | ||
| 876 | # $miniWorldHash{profile} = blessed_reference_to_the_mini_world_object | ||
| 877 | miniWorldHash => {}, | ||
| 878 | # The GA::Profile::World that's currently displayed in the window. If the user is | ||
| 879 | # creating a new world from here, set to 'undef' (even if the entry box for the new | ||
| 880 | # world's name contains text) | ||
| 881 | worldObj => undef, | ||
| 882 | # The GA::Obj::MiniWorld that stores the changes being made by the user to the grid | ||
| 883 | # widgets. For an existing world profile, the mini-world exists in $self->worldHash; | ||
| 884 | # otherwise it's a temporary GA::Obj::MiniWorld that might (or might not) be stored as | ||
| 885 | # a world profile, at some point | ||
| 886 | miniWorldObj => undef, | ||
| 887 | # Flag set to TRUE when $self->resetGridWidgets or $self->updateGridWidgets are | ||
| 888 | # changing the value displayed in the grid widgets; this stops the mini-world object | ||
| 889 | # from being modified (the mini-world object should only store changes made by the | ||
| 890 | # user) | ||
| 891 | updateFlag => undef, | ||
| 892 | |||
| 893 | # First line displayed in the Gtk3::TreeView | ||
| 894 | newWorldString => '<b><i>Create new world</i></b>', | ||
| 895 | # First line displayed in the Gtk3::ComboBox | ||
| 896 | noCharString => '<no character>', | ||
| 897 | # First line displayed in 'information' section | ||
| 898 | noWebsiteString => 'Websites: (no websites)', | ||
| 899 | # Second line | ||
| 900 | noConnectString => 'Connections: 0', | ||
| 901 | |||
| 902 | # Current search terms. If 'undef', all worlds are listed; otherwise, only those worlds | ||
| 903 | # matching one or both search terms are listed | ||
| 904 | searchRegex => undef, | ||
| 905 | searchLanguage => undef, | ||
| 906 | }; | ||
| 907 | |||
| 908 | # Bless the object into existence | ||
| 909 | bless $self, $class; | ||
| 910 | |||
| 911 | return $self; | ||
| 912 | } | ||
| 913 | |||
| 914 | ################## | ||
| 915 | # Methods | ||
| 916 | |||
| 917 | # Standard window object functions | ||
| 918 | |||
| 919 | # sub winSetup {} # Inherited from GA::Generic::FreeWin | ||
| 920 | |||
| 921 | sub winEnable { | ||
| 922 | |||
| 923 | # Called by GA::Generic::Win->createFreeWin, after the call to $self->winSetup | ||
| 924 | # After the Gtk3::Window has been setup and moved into position, makes it visible | ||
| 925 | # | ||
| 926 | # Expected arguments | ||
| 927 | # (none besides $self) | ||
| 928 | # | ||
| 929 | # Return values | ||
| 930 | # 'undef' on improper arguments | ||
| 931 | # 1 on success | ||
| 932 | |||
| 933 | my ($self, $check) = @_; | ||
| 934 | |||
| 935 | # Check for improper arguments | ||
| 936 | if (defined $check) { | ||
| 937 | |||
| 938 | return $axmud::CLIENT->writeImproper($self->_objClass . '->winEnable', @_); | ||
| 939 | } | ||
| 940 | |||
| 941 | # Make the window appear on the desktop | ||
| 942 | $self->winShowAll($self->_objClass . '->winEnable'); | ||
| 943 | $self->ivPoke('enabledFlag', TRUE); | ||
| 944 | |||
| 945 | # Fill the treeview | ||
| 946 | $self->resetTreeView($self->treeView); | ||
| 947 | |||
| 948 | # The 'connect' button should have focus | ||
| 949 | $self->connectButton->grab_focus(); | ||
| 950 | |||
| 951 | # This type of window is unique (only one can be open at any time); inform the GA::Client | ||
| 952 | # it has opened | ||
| 953 | $axmud::CLIENT->set_connectWin($self); | ||
| 954 | |||
| 955 | return 1; | ||
| 956 | } | ||
| 957 | |||
| 958 | # sub winDesengage {} # Inherited from GA::Generic::FreeWin | ||
| 959 | |||
| 960 | sub winDestroy { | ||
| 961 | |||
| 962 | # Can be called by anything | ||
| 963 | # Updates IVs | ||
| 964 | # | ||
| 965 | # Expected arguments | ||
| 966 | # (none besides $self) | ||
| 967 | # | ||
| 968 | # Return values | ||
| 969 | # 'undef' on improper arguments, if the window can't be destroyed or if it has already | ||
| 970 | # been destroyed | ||
| 971 | # 1 on success | ||
| 972 | |||
| 973 | my ($self, $check) = @_; | ||
| 974 | |||
| 975 | # Check for improper arguments | ||
| 976 | if (defined $check) { | ||
| 977 | |||
| 978 | return $axmud::CLIENT->writeImproper($self->_objClass . '->winDestroy', @_); | ||
| 979 | } | ||
| 980 | |||
| 981 | if (! $self->winBox) { | ||
| 982 | |||
| 983 | # Window already destroyed in a previous call to this function | ||
| 984 | return undef; | ||
| 985 | } | ||
| 986 | |||
| 987 | # Close any 'free' windows for which this window is a parent | ||
| 988 | foreach my $winObj ($self->ivValues('childFreeWinHash')) { | ||
| 989 | |||
| 990 | $winObj->winDestroy(); | ||
| 991 | } | ||
| 992 | |||
| 993 | # Destroy the Gtk3::Window | ||
| 994 | eval { $self->winBox->destroy(); }; | ||
| 995 | if ($@) { | ||
| 996 | |||
| 997 | # Window can't be destroyed | ||
| 998 | return undef; | ||
| 999 | |||
| 1000 | } else { | ||
| 1001 | |||
| 1002 | $self->ivUndef('winWidget'); | ||
| 1003 | $self->ivUndef('winBox'); | ||
| 1004 | } | ||
| 1005 | |||
| 1006 | # Inform the owner and the desktop object of this 'free' window's demise | ||
| 1007 | $axmud::CLIENT->desktopObj->del_freeWin($self); | ||
| 1008 | if ($self->owner) { | ||
| 1009 | |||
| 1010 | $self->owner->del_childFreeWin($self); | ||
| 1011 | } | ||
| 1012 | |||
| 1013 | # This type of window is unique (only one can be open at any time); inform the GA::Client | ||
| 1014 | # it has closed | ||
| 1015 | $axmud::CLIENT->set_connectWin(); | ||
| 1016 | |||
| 1017 | return 1; | ||
| 1018 | } | ||
| 1019 | |||
| 1020 | # sub winShowAll {} # Inherited from GA::Generic::Win | ||
| 1021 | |||
| 1022 | sub drawWidgets { | ||
| 1023 | |||
| 1024 | # Called by $self->winSetup | ||
| 1025 | # Sets up the Connections window with its standard widgets | ||
| 1026 | # | ||
| 1027 | # Expected arguments | ||
| 1028 | # (none besides $self) | ||
| 1029 | # | ||
| 1030 | # Return values | ||
| 1031 | # 'undef' on improper arguments | ||
| 1032 | # 1 otherwise | ||
| 1033 | |||
| 1034 | my ($self, $check) = @_; | ||
| 1035 | |||
| 1036 | # Check for improper arguments | ||
| 1037 | if (defined $check) { | ||
| 1038 | |||
| 1039 | return $axmud::CLIENT->writeImproper($self->_objClass . '->drawWidgets', @_); | ||
| 1040 | } | ||
| 1041 | |||
| 1042 | # Create a packing box | ||
| 1043 | my $packingBox = Gtk3::VBox->new(FALSE, $self->spacingPixels); | ||
| 1044 | $self->winBox->add($packingBox); | ||
| 1045 | $packingBox->set_border_width(0); | ||
| 1046 | |||
| 1047 | # Update IVs immediately, for the benefit of any functions called | ||
| 1048 | $self->ivPoke('packingBox', $packingBox); | ||
| 1049 | |||
| 1050 | # Create a horizontal pane to divide the window in two, with an image/treeview on the | ||
| 1051 | # left, and everything else on the right | ||
| 1052 | my $hPaned = Gtk3::HPaned->new(); | ||
| 1053 | $packingBox->pack_start($hPaned, TRUE, TRUE, 0); | ||
| 1054 | $hPaned->set_wide_handle(TRUE); | ||
| 1055 | |||
| 1056 | # On the left, create a vertical packing box, with an image at the top, a strip of buttons | ||
| 1057 | # in the middle and a treeview at the bottom | ||
| 1058 | my $vBox = Gtk3::VBox->new(FALSE, $self->spacingPixels); | ||
| 1059 | $hPaned->add1($vBox); | ||
| 1060 | |||
| 1061 | # Create a frame containing an image | ||
| 1062 | my $frame = Gtk3::Frame->new(undef); | ||
| 1063 | $vBox->pack_start($frame, FALSE, FALSE, 0); | ||
| 1064 | $frame->set_shadow_type($axmud::CLIENT->constShadowType); | ||
| 1065 | |||
| 1066 | my $image = Gtk3::Image->new_from_file($self->defaultIcon); | ||
| 1067 | $frame->add($image); | ||
| 1068 | |||
| 1069 | # Create a strip of buttons | ||
| 1070 | my $hBox = Gtk3::HBox->new(FALSE, FALSE); | ||
| 1071 | $vBox->pack_start($hBox, FALSE, FALSE, 0); | ||
| 1072 | |||
| 1073 | # Create a treeview | ||
| 1074 | my $objModel = Gtk3::TreeStore->new( ['Glib::String', 'Glib::Uint'] ); | ||
| 1075 | my $treeView = Gtk3::TreeView->new($objModel); | ||
| 1076 | $treeView->set_enable_search(FALSE); | ||
| 1077 | $treeView->get_selection->signal_connect('changed' => sub { | ||
| 1078 | |||
| 1079 | if (! $self->updateFlag) { | ||
| 1080 | |||
| 1081 | my ($selection) = @_; | ||
| 1082 | |||
| 1083 | $self->selectWorldCallback($selection); | ||
| 1084 | } | ||
| 1085 | }); | ||
| 1086 | |||
| 1087 | # Append a single column to the treeview | ||
| 1088 | my $treeViewColumn = Gtk3::TreeViewColumn->new_with_attributes( | ||
| 1089 | 'Pre-configured and played worlds', | ||
| 1090 | Gtk3::CellRendererText->new, | ||
| 1091 | markup => 0, | ||
| 1092 | ); | ||
| 1093 | |||
| 1094 | $treeView->append_column($treeViewColumn); | ||
| 1095 | |||
| 1096 | # Make the treeview scrollable | ||
| 1097 | my $frame2 = Gtk3::Frame->new(undef); | ||
| 1098 | $vBox->pack_start($frame2, TRUE, TRUE, 0); | ||
| 1099 | $frame2->set_shadow_type($axmud::CLIENT->constShadowType); | ||
| 1100 | |||
| 1101 | my $scroller = Gtk3::ScrolledWindow->new(); | ||
| 1102 | $frame2->add($scroller); | ||
| 1103 | $scroller->add($treeView); | ||
| 1104 | $scroller->set_policy(qw/automatic automatic/); | ||
| 1105 | |||
| 1106 | # Respond to clicks on the treeview | ||
| 1107 | $treeView->get_selection->set_mode('browse'); | ||
| 1108 | |||
| 1109 | # Add a grid on the right of the window, inside a scroller | ||
| 1110 | my $frame3 = Gtk3::Frame->new(undef); | ||
| 1111 | $hPaned->add2($frame3); | ||
| 1112 | $frame3->set_shadow_type($axmud::CLIENT->constShadowType); | ||
| 1113 | |||
| 1114 | my $scroller2 = Gtk3::ScrolledWindow->new(); | ||
| 1115 | $frame3->add($scroller2); | ||
| 1116 | $scroller2->set_policy(qw/automatic automatic/); | ||
| 1117 | $scroller2->set_border_width($self->spacingPixels); | ||
| 1118 | |||
| 1119 | my $grid = Gtk3::Grid->new(); | ||
| 1120 | $scroller2->add_with_viewport($grid); | ||
| 1121 | $grid->set_column_spacing($self->spacingPixels); | ||
| 1122 | $grid->set_row_spacing($self->spacingPixels); | ||
| 1123 | |||
| 1124 | # Store the widgets as IVs | ||
| 1125 | $self->ivPoke('packingBox', $packingBox); | ||
| 1126 | $self->ivPoke('hPaned', $hPaned); | ||
| 1127 | $self->ivPoke('vBox', $vBox); | ||
| 1128 | $self->ivPoke('frame', $frame); | ||
| 1129 | $self->ivPoke('image', $image); | ||
| 1130 | $self->ivPoke('hBox', $hBox); | ||
| 1131 | $self->ivPoke('objModel', $objModel); | ||
| 1132 | $self->ivPoke('treeView', $treeView); | ||
| 1133 | $self->ivPoke('treeViewColumn', $treeViewColumn); | ||
| 1134 | $self->ivPoke('frame2', $frame2); | ||
| 1135 | $self->ivPoke('scroller', $scroller); | ||
| 1136 | $self->ivPoke('frame3', $frame3); | ||
| 1137 | $self->ivPoke('scroller2', $scroller2); | ||
| 1138 | $self->ivPoke('grid', $grid); | ||
| 1139 | |||
| 1140 | # Add buttons to the button strip | ||
| 1141 | $self->createStripButtons(); | ||
| 1142 | # Add various widgets to the Gtk3::Grid | ||
| 1143 | $self->createGridWidgets(); | ||
| 1144 | |||
| 1145 | return 1; | ||
| 1146 | } | ||
| 1147 | |||
| 1148 | # sub redrawWidgets {} # Inherited from GA::Generic::Win | ||
| 1149 | |||
| 1150 | # ->signal_connects | ||
| 1151 | |||
| 1152 | # Other functions | ||
| 1153 | |||
| 1154 | sub createStripButtons { | ||
| 1155 | |||
| 1156 | # Called by $self->drawWidgets | ||
| 1157 | # Draws widgets in the button strip on the left of the window | ||
| 1158 | # | ||
| 1159 | # Expected arguments | ||
| 1160 | # (none besides $self) | ||
| 1161 | # | ||
| 1162 | # Return values | ||
| 1163 | # 'undef' on improper arguments | ||
| 1164 | # 1 otherwise | ||
| 1165 | |||
| 1166 | my ($self, $check) = @_; | ||
| 1167 | |||
| 1168 | # Local variables | ||
| 1169 | my ( | ||
| 1170 | $allString, | ||
| 1171 | @comboList, | ||
| 1172 | %hash, | ||
| 1173 | ); | ||
| 1174 | |||
| 1175 | # Check for improper arguments | ||
| 1176 | if (defined $check) { | ||
| 1177 | |||
| 1178 | return $axmud::CLIENT->writeImproper($self->_objClass . '->createStripButtons', @_); | ||
| 1179 | } | ||
| 1180 | |||
| 1181 | # Compile a list of languages used by all basic world objects. Put 'English' at the top | ||
| 1182 | # because most basic worlds use it | ||
| 1183 | foreach my $basicObj ($axmud::CLIENT->ivValues('constBasicWorldHash')) { | ||
| 1184 | |||
| 1185 | if ($basicObj->language && $basicObj->language ne 'English') { | ||
| 1186 | |||
| 1187 | $hash{$basicObj->language} = undef; | ||
| 1188 | } | ||
| 1189 | } | ||
| 1190 | |||
| 1191 | @comboList = sort {lc($a) cmp lc($b)} (keys %hash); | ||
| 1192 | unshift (@comboList, 'English'); | ||
| 1193 | |||
| 1194 | $allString = '<all languages>'; | ||
| 1195 | unshift (@comboList, $allString); | ||
| 1196 | |||
| 1197 | # Add widgets | ||
| 1198 | my $button = Gtk3::RadioToolButton->new(undef); | ||
| 1199 | $self->hBox->pack_start($button, FALSE, FALSE, 0); | ||
| 1200 | $button->set_active(TRUE); | ||
| 1201 | $button->set_icon_widget( | ||
| 1202 | Gtk3::Image->new_from_file($axmud::SHARE_DIR . '/icons/connect/icon_config.png') | ||
| 1203 | ); | ||
| 1204 | $button->set_label('PC'); | ||
| 1205 | $button->set_tooltip_text('Pre-configured and played worlds'); | ||
| 1206 | $button->signal_connect('toggled' => sub { | ||
| 1207 | |||
| 1208 | if ($button->get_active()) { | ||
| 1209 | |||
| 1210 | $self->resetTreeView(); | ||
| 1211 | } | ||
| 1212 | }); | ||
| 1213 | |||
| 1214 | my $button2 = Gtk3::RadioToolButton->new_from_widget($button); | ||
| 1215 | $self->hBox->pack_start($button2, FALSE, FALSE, 0); | ||
| 1216 | $button2->set_icon_widget( | ||
| 1217 | Gtk3::Image->new_from_file($axmud::SHARE_DIR . '/icons/connect/icon_other.png') | ||
| 1218 | ); | ||
| 1219 | $button2->set_label('Other'); | ||
| 1220 | $button2->set_tooltip_text('Other worlds'); | ||
| 1221 | $button2->signal_connect('toggled' => sub { | ||
| 1222 | |||
| 1223 | if ($button2->get_active()) { | ||
| 1224 | |||
| 1225 | $self->resetTreeView(); | ||
| 1226 | } | ||
| 1227 | }); | ||
| 1228 | |||
| 1229 | my $separator = Gtk3::Separator->new('vertical'); | ||
| 1230 | $self->hBox->pack_start($separator, TRUE, FALSE, 0); | ||
| 1231 | |||
| 1232 | my $button3 = Gtk3::RadioToolButton->new(undef); | ||
| 1233 | $self->hBox->pack_start($button3, FALSE, FALSE, 0); | ||
| 1234 | $button3->set_icon_widget( | ||
| 1235 | Gtk3::Image->new_from_file($axmud::SHARE_DIR . '/icons/connect/icon_sort_a.png') | ||
| 1236 | ); | ||
| 1237 | $button3->set_active(TRUE); | ||
| 1238 | $button3->set_label('az'); | ||
| 1239 | $button3->set_tooltip_text('Sort A-Z'); | ||
| 1240 | $button3->signal_connect('toggled' => sub { | ||
| 1241 | |||
| 1242 | if ($button3->get_active()) { | ||
| 1243 | |||
| 1244 | $self->resetTreeView(); | ||
| 1245 | } | ||
| 1246 | }); | ||
| 1247 | |||
| 1248 | my $button4 = Gtk3::RadioToolButton->new_from_widget($button3); | ||
| 1249 | $self->hBox->pack_start($button4, FALSE, FALSE, 0); | ||
| 1250 | $button4->set_icon_widget( | ||
| 1251 | Gtk3::Image->new_from_file($axmud::SHARE_DIR . '/icons/connect/icon_sort_z.png') | ||
| 1252 | ); | ||
| 1253 | $button4->set_label('za'); | ||
| 1254 | $button4->set_tooltip_text('Sort Z-A'); | ||
| 1255 | $button4->signal_connect('toggled' => sub { | ||
| 1256 | |||
| 1257 | if ($button4->get_active()) { | ||
| 1258 | |||
| 1259 | $self->resetTreeView(); | ||
| 1260 | } | ||
| 1261 | }); | ||
| 1262 | |||
| 1263 | my $button5 = Gtk3::RadioToolButton->new_from_widget($button4); | ||
| 1264 | $self->hBox->pack_start($button5, FALSE, FALSE, 0); | ||
| 1265 | $button5->set_icon_widget( | ||
| 1266 | Gtk3::Image->new_from_file($axmud::SHARE_DIR . '/icons/connect/icon_sort_random.png') | ||
| 1267 | ); | ||
| 1268 | $button5->set_label('rnd'); | ||
| 1269 | $button5->set_tooltip_text('Sort randomly'); | ||
| 1270 | $button5->signal_connect('toggled' => sub { | ||
| 1271 | |||
| 1272 | if ($button5->get_active()) { | ||
| 1273 | |||
| 1274 | $self->resetTreeView(); | ||
| 1275 | } | ||
| 1276 | }); | ||
| 1277 | # (Allow multiple re-clicking of the random button) | ||
| 1278 | $button5->signal_connect('clicked' => sub { | ||
| 1279 | |||
| 1280 | if ($button5->get_active()) { | ||
| 1281 | |||
| 1282 | $self->resetTreeView(); | ||
| 1283 | } | ||
| 1284 | }); | ||
| 1285 | |||
| 1286 | my $separator2 = Gtk3::Separator->new('vertical'); | ||
| 1287 | $self->hBox->pack_start($separator2, TRUE, FALSE, 0); | ||
| 1288 | |||
| 1289 | my $button6 = Gtk3::Button->new(); | ||
| 1290 | $self->hBox->pack_start($button6, FALSE, FALSE, 0); | ||
| 1291 | $button6->set_image( | ||
| 1292 | Gtk3::Image->new_from_file($axmud::SHARE_DIR . '/icons/connect/icon_search.png') | ||
| 1293 | ); | ||
| 1294 | $button6->set_tooltip_text('Search worlds'); | ||
| 1295 | $button6->signal_connect('clicked' => sub { | ||
| 1296 | |||
| 1297 | # Open a dialogue window | ||
| 1298 | my ($regex, $language) = $self->showEntryComboDialogue( | ||
| 1299 | 'Search worlds', | ||
| 1300 | 'Enter a search pattern', | ||
| 1301 | 'Search by language', | ||
| 1302 | \@comboList, | ||
| 1303 | undef, # No maximum characters | ||
| 1304 | undef, # Don't reverse widget order | ||
| 1305 | TRUE, # Close the window early if user presses ENTER key | ||
| 1306 | ); | ||
| 1307 | |||
| 1308 | if (! defined $regex) { | ||
| 1309 | |||
| 1310 | # Cancel search terms | ||
| 1311 | $self->ivUndef('searchRegex'); | ||
| 1312 | $self->ivUndef('searchLanguage'); | ||
| 1313 | |||
| 1314 | } else { | ||
| 1315 | |||
| 1316 | # Apply search terms | ||
| 1317 | if ($regex eq '') { | ||
| 1318 | $self->ivUndef('searchRegex'); | ||
| 1319 | } else { | ||
| 1320 | $self->ivPoke('searchRegex', $regex); | ||
| 1321 | } | ||
| 1322 | |||
| 1323 | if ($language eq $allString) { | ||
| 1324 | $self->ivUndef('searchLanguage'); | ||
| 1325 | } else { | ||
| 1326 | $self->ivPoke('searchLanguage', $language); | ||
| 1327 | } | ||
| 1328 | } | ||
| 1329 | |||
| 1330 | # Update the treeview | ||
| 1331 | $self->resetTreeView(); | ||
| 1332 | |||
| 1333 | # Update the button icon | ||
| 1334 | if (! defined $self->searchRegex && ! defined $self->searchLanguage) { | ||
| 1335 | |||
| 1336 | $button6->set_image( | ||
| 1337 | Gtk3::Image->new_from_file($axmud::SHARE_DIR . '/icons/connect/icon_search.png') | ||
| 1338 | ); | ||
| 1339 | |||
| 1340 | } else { | ||
| 1341 | |||
| 1342 | $button6->set_image( | ||
| 1343 | Gtk3::Image->new_from_file($axmud::SHARE_DIR . '/icons/connect/icon_apply.png') | ||
| 1344 | ); | ||
| 1345 | } | ||
| 1346 | }); | ||
| 1347 | |||
| 1348 | my $button7 = Gtk3::Button->new(); | ||
| 1349 | $self->hBox->pack_start($button7, FALSE, FALSE, 0); | ||
| 1350 | $button7->set_image( | ||
| 1351 | Gtk3::Image->new_from_file($axmud::SHARE_DIR . '/icons/connect/icon_clear.png') | ||
| 1352 | ); | ||
| 1353 | $button7->set_tooltip_text('Cancel search'); | ||
| 1354 | $button7->signal_connect('clicked' => sub { | ||
| 1355 | |||
| 1356 | # Cancel search terms | ||
| 1357 | $self->ivUndef('searchRegex'); | ||
| 1358 | $self->ivUndef('searchLanguage'); | ||
| 1359 | |||
| 1360 | # Update the treeview | ||
| 1361 | $self->resetTreeView(); | ||
| 1362 | |||
| 1363 | # Update the button icon | ||
| 1364 | $button6->set_image( | ||
| 1365 | Gtk3::Image->new_from_file($axmud::SHARE_DIR . '/icons/connect/icon_search.png') | ||
| 1366 | ); | ||
| 1367 | }); | ||
| 1368 | |||
| 1369 | my $button8 = Gtk3::Button->new(); | ||
| 1370 | $self->hBox->pack_start($button8, FALSE, FALSE, 0); | ||
| 1371 | |||
| 1372 | if (! $axmud::CLIENT->systemMsgList) { | ||
| 1373 | |||
| 1374 | $button8->set_image( | ||
| 1375 | Gtk3::Image->new_from_file($axmud::SHARE_DIR . '/icons/connect/icon_console.png') | ||
| 1376 | ); | ||
| 1377 | |||
| 1378 | } else { | ||
| 1379 | |||
| 1380 | $button8->set_image( | ||
| 1381 | Gtk3::Image->new_from_file( | ||
| 1382 | $axmud::SHARE_DIR . '/icons/connect/icon_console_alert.png', | ||
| 1383 | ) | ||
| 1384 | ); | ||
| 1385 | } | ||
| 1386 | |||
| 1387 | $button8->set_tooltip_text('Show Client Console window'); | ||
| 1388 | $button8->signal_connect('clicked' => sub { | ||
| 1389 | |||
| 1390 | # Open an Client Console window | ||
| 1391 | $self->createFreeWin( | ||
| 1392 | 'Games::Axmud::OtherWin::ClientConsole', | ||
| 1393 | $self, | ||
| 1394 | undef, # No GA::Session | ||
| 1395 | undef, # Let the window set its own title | ||
| 1396 | ); | ||
| 1397 | }); | ||
| 1398 | |||
| 1399 | # Store the widgets as IVs | ||
| 1400 | $self->ivPoke('preConfigButton', $button); | ||
| 1401 | $self->ivPoke('otherWorldButton', $button2); | ||
| 1402 | $self->ivPoke('sortAzButton', $button3); | ||
| 1403 | $self->ivPoke('sortZaButton', $button4); | ||
| 1404 | $self->ivPoke('sortRandButton', $button5); | ||
| 1405 | $self->ivPoke('searchButton', $button6); | ||
| 1406 | $self->ivPoke('cancelSearchButton', $button7); | ||
| 1407 | $self->ivPoke('consoleButton', $button8); | ||
| 1408 | |||
| 1409 | return 1; | ||
| 1410 | } | ||
| 1411 | |||
| 1412 | sub createGridWidgets { | ||
| 1413 | |||
| 1414 | # Called by $self->drawWidgets | ||
| 1415 | # Draws widgets in the grid on the right of the window | ||
| 1416 | # | ||
| 1417 | # Expected arguments | ||
| 1418 | # (none besides $self) | ||
| 1419 | # | ||
| 1420 | # Return values | ||
| 1421 | # 'undef' on improper arguments | ||
| 1422 | # 1 otherwise | ||
| 1423 | |||
| 1424 | my ($self, $check) = @_; | ||
| 1425 | |||
| 1426 | # Check for improper arguments | ||
| 1427 | if (defined $check) { | ||
| 1428 | |||
| 1429 | return $axmud::CLIENT->writeImproper($self->_objClass . '->createGridWidgets', @_); | ||
| 1430 | } | ||
| 1431 | |||
| 1432 | $self->addLabel($self->grid, '<i><u>Connection settings</u></i>', | ||
| 1433 | 1, 8, 1, 2); | ||
| 1434 | if (@axmud::TEST_MODE_LOGIN_LIST) { | ||
| 1435 | |||
| 1436 | # Button used for Axmud development, and only visible if the user has edited the | ||
| 1437 | # contents of /scripts/axmud.pl or /scripts/baxmud.pl, in order to modify the global | ||
| 1438 | # variable @TEST_MODE_LOGIN_LIST | ||
| 1439 | my $testButton = $self->addButton( | ||
| 1440 | $self->grid, | ||
| 1441 | \&testModeCallback, | ||
| 1442 | 'TEST MODE SETUP', | ||
| 1443 | 'Use @TEST_MODE_LOGIN_LIST values', | ||
| 1444 | 8, 12, 1, 2); | ||
| 1445 | } | ||
| 1446 | |||
| 1447 | # GA::Profile::World ->name | ||
| 1448 | $self->addLabel($self->grid, 'Name', | ||
| 1449 | 1, 4, 2, 3); | ||
| 1450 | |||
| 1451 | my $entry = $self->addEntry($self->grid, undef, undef, TRUE, | ||
| 1452 | 4, 12, 2, 3); | ||
| 1453 | $entry->signal_connect('changed' => sub { | ||
| 1454 | |||
| 1455 | # If the text inside the entry changes, we record that fact by creating (or replacing) a | ||
| 1456 | # key-value pair in $self->miniWorldObj. If the entry is emptied, we record that by | ||
| 1457 | # removing the key-value pair. | ||
| 1458 | # However, when $self->resetGridWidgets and ->updateGridWidgets are changing all the | ||
| 1459 | # grid widgets (after the user selects a world from the treeview), $self->updateFlag | ||
| 1460 | # is set to TRUE, and we don't make any changes to the mini-world object | ||
| 1461 | if (! $self->updateFlag) { | ||
| 1462 | |||
| 1463 | my $text = $axmud::CLIENT->trimWhitespace($entry->get_text()); | ||
| 1464 | |||
| 1465 | if ($text ne '') { | ||
| 1466 | $self->miniWorldObj->ivAdd('propHash', 'name', $text); | ||
| 1467 | } else { | ||
| 1468 | $self->miniWorldObj->ivDelete('propHash', 'name'); | ||
| 1469 | } | ||
| 1470 | } | ||
| 1471 | }); | ||
| 1472 | $entry->set_tooltip_text( | ||
| 1473 | 'World profile name: maximum 16 characters; A-Z, a-z, 0-9 and underlines (not first' | ||
| 1474 | . ' character); must not be ' . $axmud::NAME_ARTICLE . ' reserved word', | ||
| 1475 | ); | ||
| 1476 | |||
| 1477 | # ->dns, ->ipv4 or ->ipv6 | ||
| 1478 | $self->addLabel($self->grid, 'Host', | ||
| 1479 | 1, 4, 3, 4); | ||
| 1480 | my $entry2 = $self->addEntry($self->grid, undef, undef, TRUE, | ||
| 1481 | 4, 12, 3, 4); | ||
| 1482 | $entry2->signal_connect('changed' => sub { | ||
| 1483 | |||
| 1484 | if (! $self->updateFlag) { | ||
| 1485 | |||
| 1486 | my $text = $axmud::CLIENT->trimWhitespace($entry2->get_text()); | ||
| 1487 | |||
| 1488 | if ($text ne '') { | ||
| 1489 | |||
| 1490 | $self->miniWorldObj->ivAdd('propHash', 'host', $text); | ||
| 1491 | $self->addCharButton->set_sensitive(TRUE); | ||
| 1492 | $self->offlineButton->set_sensitive(TRUE); | ||
| 1493 | $self->connectButton->set_sensitive(TRUE); | ||
| 1494 | |||
| 1495 | } else { | ||
| 1496 | |||
| 1497 | $self->miniWorldObj->ivDelete('propHash', 'host'); | ||
| 1498 | $self->addCharButton->set_sensitive(FALSE); | ||
| 1499 | $self->offlineButton->set_sensitive(FALSE); | ||
| 1500 | $self->connectButton->set_sensitive(FALSE); | ||
| 1501 | } | ||
| 1502 | } | ||
| 1503 | }); | ||
| 1504 | $entry2->set_tooltip_text('e.g. \'deathmud.com\'; using IPV4, IPV6 or DNS'); | ||
| 1505 | |||
| 1506 | # ->port | ||
| 1507 | $self->addLabel($self->grid, 'Port', | ||
| 1508 | 1, 4, 4, 5); | ||
| 1509 | my $entry3 = $self->addEntry($self->grid, undef, undef, TRUE, | ||
| 1510 | 4, 6, 4, 5, 5, 5); | ||
| 1511 | $entry3->set_tooltip_text('e.g. 5000'); | ||
| 1512 | $entry3->signal_connect('changed' => sub { | ||
| 1513 | |||
| 1514 | if (! $self->updateFlag) { | ||
| 1515 | |||
| 1516 | my $text = $axmud::CLIENT->trimWhitespace($entry3->get_text()); | ||
| 1517 | |||
| 1518 | if ($text ne '') { | ||
| 1519 | $self->miniWorldObj->ivAdd('propHash', 'port', $text); | ||
| 1520 | } else { | ||
| 1521 | $self->miniWorldObj->ivDelete('propHash', 'port'); | ||
| 1522 | } | ||
| 1523 | } | ||
| 1524 | }); | ||
| 1525 | |||
| 1526 | $self->addLabel($self->grid, 'Protocol', | ||
| 1527 | 1, 4, 5, 6); | ||
| 1528 | my ($group, $radioButton) = $self->addRadioButton( | ||
| 1529 | $self->grid, undef, undef, 'Default', TRUE, TRUE, | ||
| 1530 | 4, 6, 5, 6); | ||
| 1531 | |||
| 1532 | my ($group2, $radioButton2) = $self->addRadioButton( | ||
| 1533 | $self->grid, undef, $group, 'Telnet', FALSE, TRUE, | ||
| 1534 | 6, 7, 5, 6); | ||
| 1535 | |||
| 1536 | my ($group3, $radioButton3) = $self->addRadioButton( | ||
| 1537 | $self->grid, undef, $group2, 'SSH', FALSE, TRUE, | ||
| 1538 | 7, 8, 5, 6); | ||
| 1539 | |||
| 1540 | my ($group4, $radioButton4) = $self->addRadioButton( | ||
| 1541 | $self->grid, undef, $group3, 'SSL', FALSE, TRUE, | ||
| 1542 | 8, 12, 5, 6); | ||
| 1543 | # If SSL is disabled, don't allow that button to be selected | ||
| 1544 | if ($axmud::NO_SSL_FLAG) { | ||
| 1545 | |||
| 1546 | $radioButton4->set_sensitive(FALSE); | ||
| 1547 | $radioButton4->set_label('(SSL unavailable)'); | ||
| 1548 | } | ||
| 1549 | |||
| 1550 | # ->passwordHash, ->accountHash, ->lastConnectChar, ->loginMode (etc) | ||
| 1551 | $self->addLabel($self->grid, '<i><u>Optional settings</u></i>', | ||
| 1552 | 1, 8, 6, 7); | ||
| 1553 | |||
| 1554 | $self->addLabel($self->grid, 'Character', | ||
| 1555 | 1, 4, 7, 8); | ||
| 1556 | my $comboBox = $self->resetComboBox(); | ||
| 1557 | |||
| 1558 | my $checkButton = $self->addCheckButton( | ||
| 1559 | $self->grid, 'No auto-login', undef, FALSE, TRUE, | ||
| 1560 | 8, 12, 7, 8); | ||
| 1561 | $checkButton->signal_connect('toggled' => sub { | ||
| 1562 | |||
| 1563 | if (! $self->updateFlag) { | ||
| 1564 | |||
| 1565 | # (The state of the checkbutton isn't stored as an IV in a world profile, so the | ||
| 1566 | # mini-world object has a separate IV to store it) | ||
| 1567 | $self->miniWorldObj->ivPoke('noAutoLoginFlag', $checkButton->get_active()); | ||
| 1568 | } | ||
| 1569 | }); | ||
| 1570 | |||
| 1571 | my $addCharButton = $self->addButton( | ||
| 1572 | $self->grid, | ||
| 1573 | \&addCharCallback, | ||
| 1574 | 'Add', | ||
| 1575 | 'Add a new character profile', | ||
| 1576 | 4, 6, 8, 9); | ||
| 1577 | |||
| 1578 | my $editPwdButton = $self->addButton( | ||
| 1579 | $self->grid, | ||
| 1580 | \&editPasswordCallback, | ||
| 1581 | 'Set password', | ||
| 1582 | 'Edit the selected character\'s password', | ||
| 1583 | 6, 8, 8, 9); | ||
| 1584 | |||
| 1585 | my $editAccButton = $self->addButton( | ||
| 1586 | $self->grid, | ||
| 1587 | \&editAccountCallback, | ||
| 1588 | 'Set account name', | ||
| 1589 | 'Edit the selected character\'s associated account name', | ||
| 1590 | 8, 12, 8, 9); | ||
| 1591 | |||
| 1592 | $self->addLabel($self->grid, '<i><u>World information</u></i>', | ||
| 1593 | 1, 8, 9, 10); | ||
| 1594 | |||
| 1595 | my $websiteLabel = $self->addLabel($self->grid, $self->noWebsiteString, | ||
| 1596 | 1, 12, 10, 11); | ||
| 1597 | $websiteLabel->signal_connect('activate-link' => sub { | ||
| 1598 | |||
| 1599 | my $link = $websiteLabel->get_current_uri(); | ||
| 1600 | if ($link) { | ||
| 1601 | |||
| 1602 | $axmud::CLIENT->openURL($link); | ||
| 1603 | } | ||
| 1604 | }); | ||
| 1605 | |||
| 1606 | my $connectionLabel = $self->addLabel($self->grid, $self->noConnectString, | ||
| 1607 | 1, 12, 11, 12); | ||
| 1608 | |||
| 1609 | # ->worldDescrip | ||
| 1610 | my $descripTextView = $self->addTextView( | ||
| 1611 | $self->grid, | ||
| 1612 | undef, | ||
| 1613 | undef, | ||
| 1614 | undef, | ||
| 1615 | FALSE, | ||
| 1616 | 1, 12, 12, 13); | ||
| 1617 | $descripTextView->set_vexpand(TRUE); | ||
| 1618 | my $descripBuffer = $descripTextView->get_buffer(); | ||
| 1619 | # Don't want horizontal scrolling | ||
| 1620 | $descripTextView->set_wrap_mode('word-char'); | ||
| 1621 | |||
| 1622 | my $createWorldButton = $self->addButton( | ||
| 1623 | $self->grid, | ||
| 1624 | undef, | ||
| 1625 | 'Create world', | ||
| 1626 | 'Create a world profile', | ||
| 1627 | 1, 7, 13, 14); | ||
| 1628 | $createWorldButton->signal_connect('clicked' => sub { | ||
| 1629 | |||
| 1630 | if (! $self->worldObj || $self->otherWorldButton->get_active()) { | ||
| 1631 | $self->createWorldCallback(); | ||
| 1632 | } else { | ||
| 1633 | $self->applyChangesCallback(); | ||
| 1634 | } | ||
| 1635 | }); | ||
| 1636 | |||
| 1637 | my $resetWorldButton = $self->addButton( | ||
| 1638 | $self->grid, | ||
| 1639 | \&resetWorldCallback, | ||
| 1640 | 'Reset world', | ||
| 1641 | "Reset the values displayed in this window to those\nactually stored by the selected" | ||
| 1642 | . " world profile", | ||
| 1643 | 1, 7, 14, 15); | ||
| 1644 | |||
| 1645 | my $offlineButton = $self->addButton( | ||
| 1646 | $self->grid, | ||
| 1647 | undef, | ||
| 1648 | 'Connect offline', | ||
| 1649 | 'Connect to this world in \'offline\' mode', | ||
| 1650 | 7, 12, 13, 14); | ||
| 1651 | $offlineButton->signal_connect('clicked' => sub { | ||
| 1652 | |||
| 1653 | $self->connectWorldCallback(TRUE); | ||
| 1654 | }); | ||
| 1655 | |||
| 1656 | my $connectButton = $self->addButton( | ||
| 1657 | $self->grid, | ||
| 1658 | undef, | ||
| 1659 | 'Connect', | ||
| 1660 | 'Connect to this world', | ||
| 1661 | 7, 12, 14, 15); | ||
| 1662 | # (Add a bit of padding, so the Connect button isn't much smaller than the other three) | ||
| 1663 | $connectButton->get_child->set_width_chars(10); | ||
| 1664 | $connectButton->signal_connect('clicked' => sub { | ||
| 1665 | |||
| 1666 | $self->connectWorldCallback(FALSE); | ||
| 1667 | }); | ||
| 1668 | |||
| 1669 | # Store the widgets as IVs | ||
| 1670 | $self->ivPoke('entry', $entry); | ||
| 1671 | $self->ivPoke('entry2', $entry2); | ||
| 1672 | $self->ivPoke('entry3', $entry3); | ||
| 1673 | $self->ivPoke('radioButton', $radioButton); | ||
| 1674 | $self->ivPoke('radioButton2', $radioButton2); | ||
| 1675 | $self->ivPoke('radioButton3', $radioButton3); | ||
| 1676 | $self->ivPoke('radioButton4', $radioButton4); | ||
| 1677 | $self->ivPoke('checkButton', $checkButton); | ||
| 1678 | $self->ivPoke('comboBox', $comboBox); | ||
| 1679 | $self->ivPoke('addCharButton', $addCharButton); | ||
| 1680 | $self->ivPoke('editPwdButton', $editPwdButton); | ||
| 1681 | $self->ivPoke('editAccButton', $editAccButton); | ||
| 1682 | $self->ivPoke('websiteLabel', $websiteLabel); | ||
| 1683 | $self->ivPoke('connectionLabel', $connectionLabel); | ||
| 1684 | $self->ivPoke('descripTextView', $descripTextView); | ||
| 1685 | $self->ivPoke('descripBuffer', $descripBuffer); | ||
| 1686 | $self->ivPoke('createWorldButton', $createWorldButton); | ||
| 1687 | $self->ivPoke('resetWorldButton', $resetWorldButton); | ||
| 1688 | $self->ivPoke('offlineButton', $offlineButton); | ||
| 1689 | $self->ivPoke('connectButton', $connectButton); | ||
| 1690 | |||
| 1691 | return 1; | ||
| 1692 | } | ||
| 1693 | |||
| 1694 | sub resetTreeView { | ||
| 1695 | |||
| 1696 | # Called by $self->winEnable, ->createWorldCallback, ->applyChangesCallback and | ||
| 1697 | # ->resetWorldCallback | ||
| 1698 | # Fills the object tree on the left of the window | ||
| 1699 | # | ||
| 1700 | # Expected arguments | ||
| 1701 | # (none besides $self) | ||
| 1702 | # | ||
| 1703 | # Optional arguments | ||
| 1704 | # $treeView - The GTK::TreeView object just created (if 'undef', $self->treeView is | ||
| 1705 | # used) | ||
| 1706 | # $selectWorld - The world to select (if 'undef', this function chooses which world to | ||
| 1707 | # select). Only applied when the list of pre-configured worlds is | ||
| 1708 | # displayed | ||
| 1709 | # | ||
| 1710 | # Return values | ||
| 1711 | # 'undef' on improper arguments | ||
| 1712 | # 1 otherwise | ||
| 1713 | |||
| 1714 | my ($self, $treeView, $selectWorld, $check) = @_; | ||
| 1715 | |||
| 1716 | # Local variables | ||
| 1717 | my ( | ||
| 1718 | $displayFlag, $sortMode, $regex, $model, $matchPointer, $treeSelection, | ||
| 1719 | @faveList, @otherList, @objList, @initList, @displayList, | ||
| 1720 | %worldHash, %nameHash, %checkHash, %displayHash, %miniWorldHash, | ||
| 1721 | ); | ||
| 1722 | |||
| 1723 | # Check for improper arguments | ||
| 1724 | if (defined $check) { | ||
| 1725 | |||
| 1726 | return $axmud::CLIENT->writeImproper($self->_objClass . '->resetTreeView', @_); | ||
| 1727 | } | ||
| 1728 | |||
| 1729 | # Set the Gtk3::TreeView, if not specified | ||
| 1730 | if (! $treeView) { | ||
| 1731 | |||
| 1732 | $treeView = $self->treeView; | ||
| 1733 | } | ||
| 1734 | |||
| 1735 | # Decide which list should be displayed. Default display mode is 'undef', representing | ||
| 1736 | # a list of world profiles | ||
| 1737 | if ($self->otherWorldButton->get_active()) { | ||
| 1738 | |||
| 1739 | $displayFlag = TRUE; | ||
| 1740 | } | ||
| 1741 | |||
| 1742 | # Update the treeview's title | ||
| 1743 | if (! $displayFlag) { | ||
| 1744 | $self->treeViewColumn->set_title('Pre-configured and played worlds'); | ||
| 1745 | } else { | ||
| 1746 | $self->treeViewColumn->set_title('Other worlds'); | ||
| 1747 | } | ||
| 1748 | |||
| 1749 | # Decide how the worlds should be sorted | ||
| 1750 | if ($self->sortZaButton->get_active()) { | ||
| 1751 | $sortMode = 'za'; | ||
| 1752 | } elsif ($self->sortRandButton->get_active()) { | ||
| 1753 | $sortMode = 'rand'; | ||
| 1754 | } else { | ||
| 1755 | $sortMode = 'az'; | ||
| 1756 | } | ||
| 1757 | |||
| 1758 | if (! $displayFlag) { | ||
| 1759 | |||
| 1760 | # Display list of world profiles | ||
| 1761 | |||
| 1762 | # Import the hash of world profiles. If search terms have been applied, remove any | ||
| 1763 | # worlds that don't match | ||
| 1764 | $regex = $self->searchRegex; | ||
| 1765 | foreach my $worldObj ($axmud::CLIENT->ivValues('worldProfHash')) { | ||
| 1766 | |||
| 1767 | my ($dictObj, $language); | ||
| 1768 | |||
| 1769 | if ($worldObj->dict) { | ||
| 1770 | |||
| 1771 | $dictObj = $axmud::CLIENT->ivShow('dictHash', $worldObj->dict); | ||
| 1772 | if ($dictObj) { | ||
| 1773 | |||
| 1774 | $language = $dictObj->language; | ||
| 1775 | } | ||
| 1776 | } | ||
| 1777 | |||
| 1778 | if ( | ||
| 1779 | ( | ||
| 1780 | ! defined $regex | ||
| 1781 | || $worldObj->name =~ m/$regex/i | ||
| 1782 | || (defined $worldObj->longName && $worldObj->longName =~ m/$regex/i) | ||
| 1783 | ) && ( | ||
| 1784 | ! defined $self->searchLanguage | ||
| 1785 | || ($language && (lc($language) eq lc($self->searchLanguage))) | ||
| 1786 | ) | ||
| 1787 | ) { | ||
| 1788 | $worldHash{$worldObj->name} = $worldObj; | ||
| 1789 | } | ||
| 1790 | } | ||
| 1791 | |||
| 1792 | # For each world, decide which name to use. Create a hash in the form | ||
| 1793 | # $nameHash{profile_name} = displayed_name | ||
| 1794 | # (where 'displayed_name' is the long name, if available, or the profile name, if not) | ||
| 1795 | # At the same time, create a parallel hash to check for duplicate long names, in the | ||
| 1796 | # form | ||
| 1797 | # $checkHash{long_name} = profile_name | ||
| 1798 | # If duplicate long names are found, 'displayed_name' should include both the long name | ||
| 1799 | # and the profile name | ||
| 1800 | foreach my $worldObj (values %worldHash) { | ||
| 1801 | |||
| 1802 | my ($otherWorld, $otherWorldObj); | ||
| 1803 | |||
| 1804 | if ($worldObj->longName) { | ||
| 1805 | |||
| 1806 | if ($worldObj->longName eq $self->newWorldString) { | ||
| 1807 | |||
| 1808 | $nameHash{$worldObj->name} | ||
| 1809 | = $worldObj->longName . ' (' . $worldObj->name . ')'; | ||
| 1810 | $checkHash{$worldObj->longName} = $worldObj->name; | ||
| 1811 | |||
| 1812 | } elsif (exists $checkHash{$worldObj->longName}) { | ||
| 1813 | |||
| 1814 | # Amend both entries to include the long name and the profile name | ||
| 1815 | $otherWorld = $checkHash{$worldObj->longName}; | ||
| 1816 | $otherWorldObj = $worldHash{$otherWorld}; | ||
| 1817 | |||
| 1818 | $nameHash{$worldObj->name} | ||
| 1819 | = $worldObj->longName . ' (' . $worldObj->name . ')'; | ||
| 1820 | # (There's already an entry in $checkHash matching ->longName) | ||
| 1821 | $nameHash{$otherWorld} | ||
| 1822 | = $otherWorldObj->longName . ' (' . $otherWorldObj->name . ')'; | ||
| 1823 | |||
| 1824 | } else { | ||
| 1825 | |||
| 1826 | # Not a duplicate, so just display the long name | ||
| 1827 | $nameHash{$worldObj->name} = $worldObj->longName; | ||
| 1828 | $checkHash{$worldObj->longName} = $worldObj->name; | ||
| 1829 | } | ||
| 1830 | |||
| 1831 | } else { | ||
| 1832 | |||
| 1833 | # Just display the profile name | ||
| 1834 | $nameHash{$worldObj->name} = $worldObj->name; | ||
| 1835 | } | ||
| 1836 | } | ||
| 1837 | |||
| 1838 | # Remove all favourite worlds from %worldHash, so they can be displayed first | ||
| 1839 | foreach my $name ($axmud::CLIENT->favouriteWorldList) { | ||
| 1840 | |||
| 1841 | if (exists $worldHash{$name}) { | ||
| 1842 | |||
| 1843 | push (@faveList, $worldHash{$name}); | ||
| 1844 | delete $worldHash{$name}; | ||
| 1845 | |||
| 1846 | # If $selectWorld was not specified, the first world in the favourite world list | ||
| 1847 | # should be selected | ||
| 1848 | if (! $selectWorld) { | ||
| 1849 | |||
| 1850 | $selectWorld = $name; | ||
| 1851 | } | ||
| 1852 | } | ||
| 1853 | } | ||
| 1854 | |||
| 1855 | # Now sort the remaining world profiles by frequency of usage (and then, alphabetically | ||
| 1856 | # or randomly, depending on which radio buttons are active) | ||
| 1857 | @otherList = sort { | ||
| 1858 | |||
| 1859 | my $aName = lc($nameHash{$a->name}); | ||
| 1860 | my $bName = lc($nameHash{$b->name}); | ||
| 1861 | |||
| 1862 | # Sort, ignoring initial articles. Don't bother ignoring articles in languages other | ||
| 1863 | # than English, because the basic mudlist contains only a couple of items that | ||
| 1864 | # would be affected | ||
| 1865 | $aName =~ s/^(the|a)\s//; | ||
| 1866 | $bName =~ s/^(the|a)\s//; | ||
| 1867 | |||
| 1868 | if ($a->numberConnects > $b->numberConnects) { | ||
| 1869 | -1; | ||
| 1870 | } elsif ($b->numberConnects > $a->numberConnects) { | ||
| 1871 | 1; | ||
| 1872 | } elsif ($sortMode eq 'az') { | ||
| 1873 | $aName cmp $bName; | ||
| 1874 | } elsif ($sortMode eq 'za') { | ||
| 1875 | $bName cmp $aName; | ||
| 1876 | } elsif (int(rand(2))) { | ||
| 1877 | -1; | ||
| 1878 | } else { | ||
| 1879 | 1; | ||
| 1880 | } | ||
| 1881 | |||
| 1882 | } (values %worldHash); | ||
| 1883 | |||
| 1884 | # Combine the two lists, with favourite worlds first, followed by everything else | ||
| 1885 | @objList = (@faveList, @otherList); | ||
| 1886 | |||
| 1887 | # Worlds that have never been connected should be shown in italics | ||
| 1888 | foreach my $worldObj (@objList) { | ||
| 1889 | |||
| 1890 | my $displayName = $nameHash{$worldObj->name}; | ||
| 1891 | |||
| 1892 | if (! $worldObj->numberConnects) { | ||
| 1893 | |||
| 1894 | $displayName = "<i>" . $displayName . "</i>"; | ||
| 1895 | } | ||
| 1896 | |||
| 1897 | push (@displayList, $displayName); | ||
| 1898 | $displayHash{$displayName} = $worldObj; | ||
| 1899 | } | ||
| 1900 | |||
| 1901 | } else { | ||
| 1902 | |||
| 1903 | # Display basic mudlist | ||
| 1904 | |||
| 1905 | # Display basic mudlist, sorted alphabetically or randomly, depending on which radio | ||
| 1906 | # buttons are active) | ||
| 1907 | @initList = sort { | ||
| 1908 | |||
| 1909 | my $aName = lc($a->longName); | ||
| 1910 | my $bName = lc($b->longName); | ||
| 1911 | |||
| 1912 | # Sort, ignoring initial articles. Don't bother ignoring articles in languages other | ||
| 1913 | # than English, because the basic mudlist contains only a couple of items that | ||
| 1914 | # would be affected | ||
| 1915 | $aName =~ s/^(the|a)\s//; | ||
| 1916 | $bName =~ s/^(the|a)\s//; | ||
| 1917 | |||
| 1918 | if ($sortMode eq 'az') { | ||
| 1919 | $aName cmp $bName; | ||
| 1920 | } elsif ($sortMode eq 'za') { | ||
| 1921 | $bName cmp $aName; | ||
| 1922 | } elsif (int(rand(2))) { | ||
| 1923 | -1; | ||
| 1924 | } else { | ||
| 1925 | 1; | ||
| 1926 | } | ||
| 1927 | |||
| 1928 | } ($axmud::CLIENT->ivValues('constBasicWorldHash')); | ||
| 1929 | |||
| 1930 | # Remove any worlds for which a world profile actually exists (the same world shouldn't | ||
| 1931 | # appear in both lists) | ||
| 1932 | # If any search terms have been applied, remove any worlds that don't match | ||
| 1933 | $regex = $self->searchRegex; | ||
| 1934 | foreach my $obj (@initList) { | ||
| 1935 | |||
| 1936 | if ( | ||
| 1937 | ( | ||
| 1938 | ! $axmud::CLIENT->ivExists('worldProfHash', $obj->name) | ||
| 1939 | ) && ( | ||
| 1940 | ! defined $regex | ||
| 1941 | || $obj->name =~ m/$regex/i | ||
| 1942 | || $obj->longName =~ m/$regex/i | ||
| 1943 | ) && ( | ||
| 1944 | ! defined $self->searchLanguage | ||
| 1945 | || lc($obj->language) eq lc($self->searchLanguage) | ||
| 1946 | ) | ||
| 1947 | ) { | ||
| 1948 | push (@objList, $obj); | ||
| 1949 | } | ||
| 1950 | } | ||
| 1951 | |||
| 1952 | # All worlds should be in italics | ||
| 1953 | foreach my $obj (@objList) { | ||
| 1954 | |||
| 1955 | my $displayName = "<i>" . $obj->longName . "</i>"; | ||
| 1956 | |||
| 1957 | push (@displayList, $displayName); | ||
| 1958 | $displayHash{$displayName} = $obj; | ||
| 1959 | } | ||
| 1960 | } | ||
| 1961 | |||
| 1962 | # The first item in the list should be a 'create new world' string | ||
| 1963 | unshift (@displayList, $self->newWorldString); | ||
| 1964 | $displayHash{$self->newWorldString} = undef; # Not linked to a world profile | ||
| 1965 | |||
| 1966 | # If the treeview already exists, stop it from calling $self->selectWorldCallback while | ||
| 1967 | # we're modifying its contents | ||
| 1968 | $self->ivPoke('updateFlag', TRUE); | ||
| 1969 | |||
| 1970 | # Fill a model of the tree, not the tree itself | ||
| 1971 | if (! $treeView) { | ||
| 1972 | $model = $self->treeView->get_model(); | ||
| 1973 | } else { | ||
| 1974 | $model = $treeView->get_model(); | ||
| 1975 | } | ||
| 1976 | |||
| 1977 | # Empty the treeview | ||
| 1978 | $model->clear(); | ||
| 1979 | |||
| 1980 | # Display each world in the treeview | ||
| 1981 | foreach my $displayName (@displayList) { | ||
| 1982 | |||
| 1983 | my ($pointer, $displayObj); | ||
| 1984 | |||
| 1985 | $pointer = $model->append(undef); | ||
| 1986 | $displayObj = $displayHash{$displayName}; | ||
| 1987 | |||
| 1988 | $model->set($pointer, [0], [$displayName]); | ||
| 1989 | |||
| 1990 | if ($selectWorld && $displayObj && $selectWorld eq $displayObj->name) { | ||
| 1991 | |||
| 1992 | # This line must be selected | ||
| 1993 | $matchPointer = $pointer; | ||
| 1994 | } | ||
| 1995 | } | ||
| 1996 | |||
| 1997 | # For each world, create a GA::Obj::MiniWorld, which stores any changes made to the world's | ||
| 1998 | # data in the Connections window, so that they can be copied into the main world | ||
| 1999 | # profile at the right time | ||
| 2000 | # However, don't replace an existing GA::Obj::MiniWorld | ||
| 2001 | foreach my $obj (@objList) { | ||
| 2002 | |||
| 2003 | my ( | ||
| 2004 | $miniWorldObj, | ||
| 2005 | %passwordHash, | ||
| 2006 | %accountHash, | ||
| 2007 | ); | ||
| 2008 | |||
| 2009 | if ($self->ivExists('miniWorldHash', $obj->name)) { | ||
| 2010 | |||
| 2011 | # Use the existing mini-world object | ||
| 2012 | $miniWorldObj = $self->ivShow('miniWorldHash', $obj->name); | ||
| 2013 | |||
| 2014 | } elsif (! $displayFlag) { | ||
| 2015 | |||
| 2016 | # Create a new mini-world object corresponding to an existing world profile | ||
| 2017 | # The object requires a copy of the world profile's ->passwordHash and ->accountHash | ||
| 2018 | %passwordHash = $obj->passwordHash; | ||
| 2019 | %accountHash = $obj->accountHash; | ||
| 2020 | |||
| 2021 | # Create the object | ||
| 2022 | $miniWorldObj = Games::Axmud::Obj::MiniWorld->new( | ||
| 2023 | $obj, | ||
| 2024 | $obj->lastConnectChar, # May be 'undef' | ||
| 2025 | $obj->loginAccountMode, | ||
| 2026 | \%passwordHash, | ||
| 2027 | \%accountHash, | ||
| 2028 | ); | ||
| 2029 | |||
| 2030 | } else { | ||
| 2031 | |||
| 2032 | # Create a new mini-world object NOT corresponding to an existing world profile | ||
| 2033 | $miniWorldObj = Games::Axmud::Obj::MiniWorld->new($obj); | ||
| 2034 | } | ||
| 2035 | |||
| 2036 | if ($miniWorldObj) { | ||
| 2037 | |||
| 2038 | $miniWorldHash{$miniWorldObj->name} = $miniWorldObj; | ||
| 2039 | } | ||
| 2040 | } | ||
| 2041 | |||
| 2042 | # Store the hashes as IVs | ||
| 2043 | $self->ivPoke('worldHash', %displayHash); | ||
| 2044 | $self->ivPoke('miniWorldHash', %miniWorldHash); | ||
| 2045 | |||
| 2046 | # Update complete | ||
| 2047 | $self->ivPoke('updateFlag', FALSE); | ||
| 2048 | |||
| 2049 | # Select a world, if one was specified in the calling functions; otherwise select the | ||
| 2050 | # 'Create new world' line. This automatically causes $self->updateGridWidgets or | ||
| 2051 | # $self->resetGridWidgets to be called | ||
| 2052 | $treeSelection = $self->treeView->get_selection(); | ||
| 2053 | if ($matchPointer) { | ||
| 2054 | $treeSelection->select_iter($matchPointer); | ||
| 2055 | } else { | ||
| 2056 | $treeSelection->select_iter($model->get_iter_first()); | ||
| 2057 | } | ||
| 2058 | |||
| 2059 | return 1; | ||
| 2060 | } | ||
| 2061 | |||
| 2062 | sub resetGridWidgets { | ||
| 2063 | |||
| 2064 | # Called by $self->selectWorldCallback when the user clicks on the 'Create new world' line | ||
| 2065 | # in the treeview | ||
| 2066 | # Resets IVs and resets the widgets in the window's Gtk3::Grid, ready for the user to enter | ||
| 2067 | # details for a new world | ||
| 2068 | # | ||
| 2069 | # Expected arguments | ||
| 2070 | # (none besides $self) | ||
| 2071 | # | ||
| 2072 | # Return values | ||
| 2073 | # 'undef' on improper arguments | ||
| 2074 | # 1 otherwise | ||
| 2075 | |||
| 2076 | my ($self, $check) = @_; | ||
| 2077 | |||
| 2078 | # Check for improper arguments | ||
| 2079 | if (defined $check) { | ||
| 2080 | |||
| 2081 | return $axmud::CLIENT->writeImproper($self->_objClass . '->resetGridWidgets', @_); | ||
| 2082 | } | ||
| 2083 | |||
| 2084 | # Reset the IV which stores the currently displayed world | ||
| 2085 | $self->ivUndef('worldObj'); | ||
| 2086 | # Create a temporary GA::Obj::MiniWorld to store the changes | ||
| 2087 | $self->ivPoke('miniWorldObj', Games::Axmud::Obj::MiniWorld->new()); | ||
| 2088 | # Set a flag to TRUE to stop the mini-world object being updated, as we change the values | ||
| 2089 | # displayed in the grid's widgets | ||
| 2090 | $self->ivPoke('updateFlag', TRUE); | ||
| 2091 | |||
| 2092 | # Reset the 'create world' button's label (it gets modified by $self->updateGridWidgets) | ||
| 2093 | $self->createWorldButton->set_label('Create world'); | ||
| 2094 | $self->createWorldButton->set_tooltip_text('Create a world profile'); | ||
| 2095 | |||
| 2096 | # Reset the grid widgets | ||
| 2097 | $self->entry->set_text(''); | ||
| 2098 | $self->entry2->set_text(''); | ||
| 2099 | $self->entry3->set_text(''); | ||
| 2100 | $self->checkButton->set_active(FALSE); | ||
| 2101 | |||
| 2102 | $self->radioButton->set_active(TRUE); | ||
| 2103 | |||
| 2104 | my $comboBox = $self->resetComboBox(TRUE); | ||
| 2105 | $self->ivPoke('comboBox', $comboBox); | ||
| 2106 | |||
| 2107 | $self->websiteLabel->set_text($self->noWebsiteString); | ||
| 2108 | $self->connectionLabel->set_text($self->noConnectString); | ||
| 2109 | $self->descripBuffer->set_text(''); | ||
| 2110 | |||
| 2111 | # (These calls eliminate flashing when the screenshot is updated rapidly, for example when | ||
| 2112 | # the user scrolls through the list of worlds) | ||
| 2113 | $self->winShowAll($self->_objClass . '->resetGridWidgets'); | ||
| 2114 | $axmud::CLIENT->desktopObj->updateWidgets($self->_objClass . '->resetGridWidgets'); | ||
| 2115 | |||
| 2116 | # Update the world screenshot, using the default logo | ||
| 2117 | # If a logo for this world exists, use it; otherwise use the default logo | ||
| 2118 | my $image = Gtk3::Image->new_from_file($self->defaultIcon); | ||
| 2119 | $axmud::CLIENT->desktopObj->removeWidget($self->frame, $self->image); | ||
| 2120 | $self->frame->add($image); | ||
| 2121 | $self->ivPoke('image', $image); | ||
| 2122 | |||
| 2123 | # (A repeat of those calls eliminates it entirely) | ||
| 2124 | $self->winShowAll($self->_objClass . '->resetGridWidgets'); | ||
| 2125 | $axmud::CLIENT->desktopObj->updateWidgets($self->_objClass . '->resetGridWidgets'); | ||
| 2126 | |||
| 2127 | # The entry box for the world's name must be made editable | ||
| 2128 | $self->entry->set_editable(TRUE); | ||
| 2129 | # The 'pwd' / 'account' buttons start insensitive, but can be sensitised if the user selects | ||
| 2130 | # a character | ||
| 2131 | $self->editPwdButton->set_sensitive(FALSE); | ||
| 2132 | $self->editAccButton->set_sensitive(FALSE); | ||
| 2133 | # The 'reset world' button must be insensitive when there isn't a corresponding world | ||
| 2134 | # profile | ||
| 2135 | $self->resetWorldButton->set_sensitive(FALSE); | ||
| 2136 | # The 'add', 'connect offline' and 'connect to world' buttons must be insensitive until the | ||
| 2137 | # user at least types something in the 'host address' entry box | ||
| 2138 | $self->addCharButton->set_sensitive(FALSE); | ||
| 2139 | $self->offlineButton->set_sensitive(FALSE); | ||
| 2140 | $self->connectButton->set_sensitive(FALSE); | ||
| 2141 | |||
| 2142 | # Update complete | ||
| 2143 | $self->ivPoke('updateFlag', FALSE); | ||
| 2144 | |||
| 2145 | # The call to ->show_all() causes the image to appear | ||
| 2146 | $self->winShowAll($self->_objClass . '->resetGridWidgets'); | ||
| 2147 | |||
| 2148 | return 1; | ||
| 2149 | } | ||
| 2150 | |||
| 2151 | sub updateGridWidgets { | ||
| 2152 | |||
| 2153 | # Called by $self->selectWorldCallback when the user clicks on a line in the treeview | ||
| 2154 | # corresponding to a world profile | ||
| 2155 | # Also called by $self->testModeLoginCallback | ||
| 2156 | # | ||
| 2157 | # Updates IVs and updates the widgets in the window's Gtk3::Grid, so they show details about | ||
| 2158 | # the world | ||
| 2159 | # | ||
| 2160 | # Expected arguments | ||
| 2161 | # $worldObj - The GA::Profile::World object corresponding to the clicked line | ||
| 2162 | # $line - The text of the treeview line that the user clicked | ||
| 2163 | # | ||
| 2164 | # Return values | ||
| 2165 | # 'undef' on improper arguments | ||
| 2166 | # 1 otherwise | ||
| 2167 | |||
| 2168 | my ($self, $worldObj, $line, $check) = @_; | ||
| 2169 | |||
| 2170 | # Local variables | ||
| 2171 | my ( | ||
| 2172 | $displayFlag, $modName, $host, $port, $website, $connections, $logoPath, | ||
| 2173 | @charList, | ||
| 2174 | ); | ||
| 2175 | |||
| 2176 | # Check for improper arguments | ||
| 2177 | if (! defined $worldObj || ! defined $line || defined $check) { | ||
| 2178 | |||
| 2179 | return $axmud::CLIENT->writeImproper($self->_objClass . '->updateGridWidgets', @_); | ||
| 2180 | } | ||
| 2181 | |||
| 2182 | # Decide which list should be displayed. Default display mode is 'undef', representing | ||
| 2183 | # a list of world profiles | ||
| 2184 | if ($self->otherWorldButton->get_active()) { | ||
| 2185 | |||
| 2186 | $displayFlag = TRUE; | ||
| 2187 | } | ||
| 2188 | |||
| 2189 | # Set the IV which stores the currently displayed world | ||
| 2190 | $self->ivPoke('worldObj', $worldObj); | ||
| 2191 | # Get the equivalent GA::Obj::MiniWorld | ||
| 2192 | $self->ivPoke('miniWorldObj', $self->ivShow('miniWorldHash', $worldObj->name)); | ||
| 2193 | # Set a flag to TRUE to stop the mini-world object being updated, as we change the values | ||
| 2194 | # displayed in the grid's widgets | ||
| 2195 | $self->ivPoke('updateFlag', TRUE); | ||
| 2196 | |||
| 2197 | # Modify the 'create world' button's label (it gets reset by $self->resetGridWidgets) | ||
| 2198 | if (! $displayFlag) { | ||
| 2199 | |||
| 2200 | $self->createWorldButton->set_label('Apply changes'); | ||
| 2201 | $self->createWorldButton->set_tooltip_text('Apply changes to this world profile'); | ||
| 2202 | |||
| 2203 | } else { | ||
| 2204 | |||
| 2205 | $self->createWorldButton->set_label('Create world'); | ||
| 2206 | $self->createWorldButton->set_tooltip_text('Create a world profile'); | ||
| 2207 | } | ||
| 2208 | |||
| 2209 | # Display details about the world. For each IV, if there's an entry in the mini-world | ||
| 2210 | # object, then use its value; otherwise use the value stored in the world profile itself | ||
| 2211 | |||
| 2212 | # 'World name' (we don't consult the mini-world object - the world name can't be changed, | ||
| 2213 | # once a world profile is created) | ||
| 2214 | $modName = '<i>' . $worldObj->name . '</i>'; # Matches $line for a world never connected | ||
| 2215 | if ( | ||
| 2216 | $self->preConfigButton->get_active() | ||
| 2217 | && $worldObj->name ne $line | ||
| 2218 | && $worldObj->name ne $modName | ||
| 2219 | && $worldObj->longName | ||
| 2220 | ) { | ||
| 2221 | $self->entry->set_text($worldObj->longName . ' (' . $worldObj->name . ')'); | ||
| 2222 | } else { | ||
| 2223 | $self->entry->set_text($worldObj->name); | ||
| 2224 | } | ||
| 2225 | |||
| 2226 | # 'Host address', 'Port' | ||
| 2227 | if (! $displayFlag) { | ||
| 2228 | |||
| 2229 | ($host, $port) = $worldObj->getConnectDetails(); | ||
| 2230 | |||
| 2231 | } else { | ||
| 2232 | |||
| 2233 | $host = $worldObj->host; | ||
| 2234 | $port = $worldObj->port; | ||
| 2235 | } | ||
| 2236 | |||
| 2237 | if ($self->miniWorldObj->ivExists('propHash', 'host')) { | ||
| 2238 | $self->entry2->set_text($self->miniWorldObj->ivShow('propHash', 'host')); | ||
| 2239 | } else { | ||
| 2240 | $self->entry2->set_text($host); | ||
| 2241 | } | ||
| 2242 | |||
| 2243 | if ($self->miniWorldObj->ivExists('propHash', 'port')) { | ||
| 2244 | $self->entry3->set_text($self->miniWorldObj->ivShow('propHash', 'port')); | ||
| 2245 | } else { | ||
| 2246 | $self->entry3->set_text($port); | ||
| 2247 | } | ||
| 2248 | |||
| 2249 | # 'Auto-login' | ||
| 2250 | if (! $displayFlag && $self->miniWorldObj->noAutoLoginFlag) { | ||
| 2251 | $self->checkButton->set_active(TRUE); | ||
| 2252 | } else { | ||
| 2253 | $self->checkButton->set_active(FALSE); | ||
| 2254 | } | ||
| 2255 | |||
| 2256 | # 'Character' | ||
| 2257 | if (! $displayFlag) { | ||
| 2258 | |||
| 2259 | @charList = sort {lc($a) cmp lc($b)} ($self->miniWorldObj->ivKeys('passwordHash')); | ||
| 2260 | } | ||
| 2261 | |||
| 2262 | my $comboBox = $self->resetComboBox(TRUE, @charList); | ||
| 2263 | $self->ivPoke('comboBox', $comboBox); | ||
| 2264 | |||
| 2265 | # 'Websites' | ||
| 2266 | $website = 'Websites:'; | ||
| 2267 | |||
| 2268 | if (! $displayFlag) { | ||
| 2269 | |||
| 2270 | if (! $worldObj->worldURL && ! $worldObj->referURL) { | ||
| 2271 | |||
| 2272 | $website .= ' (no websites)'; | ||
| 2273 | |||
| 2274 | } else { | ||
| 2275 | |||
| 2276 | if ($worldObj->worldURL) { | ||
| 2277 | |||
| 2278 | $website .= ' <a href="' . $self->escapeHtml($worldObj->worldURL) | ||
| 2279 | . '">Website</a>'; | ||
| 2280 | } | ||
| 2281 | |||
| 2282 | if ($worldObj->referURL) { | ||
| 2283 | |||
| 2284 | $website .= ' <a href="' . $self->escapeHtml($worldObj->referURL) | ||
| 2285 | . '">Referrer</a>'; | ||
| 2286 | } | ||
| 2287 | } | ||
| 2288 | |||
| 2289 | } else { | ||
| 2290 | |||
| 2291 | $website .= ' (n/a)'; | ||
| 2292 | } | ||
| 2293 | |||
| 2294 | $self->websiteLabel->set_markup($website); | ||
| 2295 | |||
| 2296 | # 'Connections' | ||
| 2297 | if (! $displayFlag) { | ||
| 2298 | |||
| 2299 | $connections = 'Connections: ' . $worldObj->numberConnects; | ||
| 2300 | if ($worldObj->lastConnectDate && $worldObj->lastConnectTime) { | ||
| 2301 | |||
| 2302 | $connections .= ', most recent: ' . $worldObj->lastConnectDate . ' at ' | ||
| 2303 | . $worldObj->lastConnectTime; | ||
| 2304 | } | ||
| 2305 | |||
| 2306 | } else { | ||
| 2307 | |||
| 2308 | $connections = 'Connections: (n/a)'; | ||
| 2309 | } | ||
| 2310 | |||
| 2311 | $self->connectionLabel->set_markup($connections); | ||
| 2312 | |||
| 2313 | # (Descrip) | ||
| 2314 | if ($self->miniWorldObj->ivExists('propHash', 'descrip')) { | ||
| 2315 | |||
| 2316 | $self->descripBuffer->set_text($self->miniWorldObj->ivShow('propHash', 'descrip')); | ||
| 2317 | |||
| 2318 | } elsif (! $displayFlag && $worldObj->worldDescrip) { | ||
| 2319 | |||
| 2320 | $self->descripBuffer->set_text($worldObj->worldDescrip); | ||
| 2321 | |||
| 2322 | } elsif (! $displayFlag) { | ||
| 2323 | |||
| 2324 | $self->descripBuffer->set_text(''); | ||
| 2325 | |||
| 2326 | } else { | ||
| 2327 | |||
| 2328 | $self->descripBuffer->set_text( | ||
| 2329 | 'This world profile won\'t be created until you click one of the buttons below', | ||
| 2330 | ) | ||
| 2331 | } | ||
| 2332 | |||
| 2333 | # Move the 'descrip' textview's scrollbar to the top, in case the user has been browsing | ||
| 2334 | # another world's description | ||
| 2335 | $self->descripTextView->scroll_to_iter( | ||
| 2336 | $self->descripBuffer->get_start_iter(), | ||
| 2337 | 0.0, | ||
| 2338 | TRUE, | ||
| 2339 | 0, | ||
| 2340 | 1, | ||
| 2341 | ); | ||
| 2342 | |||
| 2343 | # If a logo for this world exists, use it; otherwise use the default logo | ||
| 2344 | if (! $displayFlag) { | ||
| 2345 | |||
| 2346 | $logoPath = $axmud::DATA_DIR . '/logos/' . $worldObj->name . '.png'; | ||
| 2347 | } | ||
| 2348 | |||
| 2349 | if ($displayFlag || ! (-e $logoPath)) { | ||
| 2350 | |||
| 2351 | $logoPath = $axmud::CLIENT->getClientLogo($worldObj->adultFlag); | ||
| 2352 | } | ||
| 2353 | |||
| 2354 | # (These calls eliminate flashing when the screenshot is updated rapidly, for example when | ||
| 2355 | # the user scrolls through the list of worlds) | ||
| 2356 | $self->winShowAll($self->_objClass . '->updateGridWidgets'); | ||
| 2357 | $axmud::CLIENT->desktopObj->updateWidgets($self->_objClass . '->updateGridWidgets'); | ||
| 2358 | |||
| 2359 | # Update the world screenshot | ||
| 2360 | my $image = Gtk3::Image->new_from_file($logoPath); | ||
| 2361 | $axmud::CLIENT->desktopObj->removeWidget($self->frame, $self->image); | ||
| 2362 | $self->frame->add($image); | ||
| 2363 | $self->ivPoke('image', $image); | ||
| 2364 | |||
| 2365 | # (A repeat of those calls eliminates it entirely) | ||
| 2366 | $self->winShowAll($self->_objClass . '->updateGridWidgets'); | ||
| 2367 | $axmud::CLIENT->desktopObj->updateWidgets($self->_objClass . '->updateGridWidgets'); | ||
| 2368 | |||
| 2369 | # The entry box for the world's name must not be changed | ||
| 2370 | $self->entry->set_editable(FALSE); | ||
| 2371 | # The 'add' button must be sensitive | ||
| 2372 | $self->addCharButton->set_sensitive(TRUE); | ||
| 2373 | # The 'pwd'/'account' buttons start sensitised if there's a selected character, but | ||
| 2374 | # desensitised if not | ||
| 2375 | if ($self->miniWorldObj->selectChar) { | ||
| 2376 | |||
| 2377 | $self->editPwdButton->set_sensitive(TRUE); | ||
| 2378 | $self->editAccButton->set_sensitive(TRUE); | ||
| 2379 | |||
| 2380 | } else { | ||
| 2381 | |||
| 2382 | $self->editPwdButton->set_sensitive(FALSE); | ||
| 2383 | $self->editAccButton->set_sensitive(FALSE); | ||
| 2384 | } | ||
| 2385 | |||
| 2386 | # The 'reset world' button must be sensitive | ||
| 2387 | $self->resetWorldButton->set_sensitive(TRUE); | ||
| 2388 | # If the world profile doesn't have a ->dns, ->ipv4 or ->ipv6 value, Axmud obviously won't | ||
| 2389 | # be able to connect to the world. Make the connect buttons desensitised until the user | ||
| 2390 | # types something in the 'host address' entry box | ||
| 2391 | if (! $host) { | ||
| 2392 | |||
| 2393 | $self->offlineButton->set_sensitive(FALSE); | ||
| 2394 | $self->connectButton->set_sensitive(FALSE); | ||
| 2395 | |||
| 2396 | } else { | ||
| 2397 | |||
| 2398 | # Otherwise, these two buttons start sensitised | ||
| 2399 | $self->offlineButton->set_sensitive(TRUE); | ||
| 2400 | $self->connectButton->set_sensitive(TRUE); | ||
| 2401 | } | ||
| 2402 | |||
| 2403 | # Update complete | ||
| 2404 | $self->ivPoke('updateFlag', FALSE); | ||
| 2405 | |||
| 2406 | # The call to ->show_all() causes the image to appear | ||
| 2407 | $self->winShowAll($self->_objClass . '->updateGridWidgets'); | ||
| 2408 | |||
| 2409 | return 1; | ||
| 2410 | } | ||
| 2411 | |||
| 2412 | sub resetComboBox { | ||
| 2413 | |||
| 2414 | # Called by $self->createGridWidgets, ->resetGridWidgets and ->updateGridWidgets | ||
| 2415 | # Not sure how to empty a Gtk3::ComboBox, so we'll just destroy the old one, and replace it | ||
| 2416 | # with a new one | ||
| 2417 | # | ||
| 2418 | # Expected arguments | ||
| 2419 | # (none besides $self) | ||
| 2420 | # | ||
| 2421 | # Optional arguments | ||
| 2422 | # $destroyFlag - If TRUE, a combobox already exists, and must be deleted. If FALSE (or | ||
| 2423 | # 'undef'), the combobox is being drawn for the first time | ||
| 2424 | # @charList - A list of characters to display in the combobpx. If empty, the | ||
| 2425 | # combobox will contain only the '<no character>' string. If not | ||
| 2426 | # empty, the '<no character>' is added to @charList as the first item | ||
| 2427 | # | ||
| 2428 | # Return values | ||
| 2429 | # 'undef' on improper arguments | ||
| 2430 | # Otherwise returns the Gtk3::ComboBox created | ||
| 2431 | |||
| 2432 | my ($self, $destroyFlag, @charList) = @_; | ||
| 2433 | |||
| 2434 | # Local variables | ||
| 2435 | my ($count, $index); | ||
| 2436 | |||
| 2437 | # (No improper arguments to check) | ||
| 2438 | |||
| 2439 | # If a Gtk3::ComboBox already exists, destroy it | ||
| 2440 | if ($destroyFlag) { | ||
| 2441 | |||
| 2442 | $axmud::CLIENT->desktopObj->removeWidget($self->grid, $self->comboBox); | ||
| 2443 | } | ||
| 2444 | |||
| 2445 | # Create a new combobox | ||
| 2446 | unshift (@charList, $self->noCharString); | ||
| 2447 | my $comboBox = $self->addComboBox($self->grid, undef, \@charList, undef, | ||
| 2448 | 4, 8, 7, 8); | ||
| 2449 | |||
| 2450 | # If the current mini-world object specifies a character, make that the combobox's active | ||
| 2451 | # item. Otherwise, make the '<no character>' string the active item | ||
| 2452 | $index = 0; | ||
| 2453 | if ($self->miniWorldObj && $self->miniWorldObj->selectChar) { | ||
| 2454 | |||
| 2455 | $count = -1; | ||
| 2456 | OUTER: foreach my $string (@charList) { | ||
| 2457 | |||
| 2458 | $count++; | ||
| 2459 | |||
| 2460 | if ($string eq $self->miniWorldObj->selectChar) { | ||
| 2461 | |||
| 2462 | $index = $count; | ||
| 2463 | last OUTER; | ||
| 2464 | } | ||
| 2465 | } | ||
| 2466 | } | ||
| 2467 | |||
| 2468 | $comboBox->set_active($index); | ||
| 2469 | # Also, the 'pwd'/'account' buttons should only be sensitised when there's a selected | ||
| 2470 | # character | ||
| 2471 | if ($self->miniWorldObj) { | ||
| 2472 | |||
| 2473 | if ($self->miniWorldObj->selectChar) { | ||
| 2474 | |||
| 2475 | $self->editPwdButton->set_sensitive(TRUE); | ||
| 2476 | $self->editAccButton->set_sensitive(TRUE); | ||
| 2477 | |||
| 2478 | } else { | ||
| 2479 | |||
| 2480 | $self->editPwdButton->set_sensitive(FALSE); | ||
| 2481 | $self->editAccButton->set_sensitive(FALSE); | ||
| 2482 | } | ||
| 2483 | } | ||
| 2484 | |||
| 2485 | # Now we can add the combobox's ->signal_connect, which updates the mini-world object when | ||
| 2486 | # a character is selected | ||
| 2487 | $comboBox->signal_connect('changed' => sub { | ||
| 2488 | |||
| 2489 | my $char = $comboBox->get_active_text(); | ||
| 2490 | |||
| 2491 | if ($char eq $self->noCharString) { | ||
| 2492 | |||
| 2493 | $self->miniWorldObj->ivUndef('selectChar'); | ||
| 2494 | # When no character is selected, the 'pwd'/'account' buttons must be desensitised | ||
| 2495 | $self->editPwdButton->set_sensitive(FALSE); | ||
| 2496 | $self->editAccButton->set_sensitive(FALSE); | ||
| 2497 | |||
| 2498 | } else { | ||
| 2499 | |||
| 2500 | $self->miniWorldObj->ivPoke('selectChar', $char); | ||
| 2501 | # When no character is selected, the 'pwd'/'account' buttons must be desensitised | ||
| 2502 | $self->editPwdButton->set_sensitive(TRUE); | ||
| 2503 | $self->editAccButton->set_sensitive(TRUE); | ||
| 2504 | } | ||
| 2505 | }); | ||
| 2506 | |||
| 2507 | # The call to ->show_all() makes the new combobox visible | ||
| 2508 | $self->winShowAll($self->_objClass . '->resetComboBox'); | ||
| 2509 | |||
| 2510 | return $comboBox; | ||
| 2511 | } | ||
| 2512 | |||
| 2513 | sub updateProfile { | ||
| 2514 | |||
| 2515 | # Called by $self->applyChangesCallback and ->connectWorldCallback | ||
| 2516 | # Copies changes to values, stored in the specified mini-world object, to the corresponding | ||
| 2517 | # world profile (if it exists) | ||
| 2518 | # | ||
| 2519 | # Expected arguments | ||
| 2520 | # $miniWorldObj - A GA::Obj::MiniWorld | ||
| 2521 | # | ||
| 2522 | # Return values | ||
| 2523 | # 'undef' on improper arguments or if there is no world profile to update | ||
| 2524 | # 1 otherwise | ||
| 2525 | |||
| 2526 | my ($self, $miniWorldObj, $check) = @_; | ||
| 2527 | |||
| 2528 | # Local variables | ||
| 2529 | my ( | ||
| 2530 | $worldObj, $profFlag, $host, $port, $descrip, | ||
| 2531 | %newHash, | ||
| 2532 | ); | ||
| 2533 | |||
| 2534 | # Check for improper arguments | ||
| 2535 | if (! defined $miniWorldObj || defined $check) { | ||
| 2536 | |||
| 2537 | return $axmud::CLIENT->writeImproper($self->_objClass . '->updateProfile', @_); | ||
| 2538 | } | ||
| 2539 | |||
| 2540 | # Import the equivalent world profile object, for convenience | ||
| 2541 | $worldObj = $miniWorldObj->worldObj; | ||
| 2542 | # Is it actually a world profile, or is it a basic world object (GA::Obj::BasicWorld), which | ||
| 2543 | # has different IVs? | ||
| 2544 | if (! $worldObj->isa('Games::Axmud::Profile::World')) { | ||
| 2545 | |||
| 2546 | # It's a basic world object; nothing for this function to do | ||
| 2547 | return undef; | ||
| 2548 | } | ||
| 2549 | |||
| 2550 | # (We can't change the profile's ->name) | ||
| 2551 | |||
| 2552 | # ->host and ->port | ||
| 2553 | # If the host address is in the form 'deathmud.com:8888', then extract the port. Although | ||
| 2554 | # it technically possible to use ports with only one digit, don't recognise it | ||
| 2555 | # If, at the same time, the port was specified in the other entry box, ignore the other | ||
| 2556 | $host = $miniWorldObj->ivShow('propHash', 'host'); | ||
| 2557 | if ($host && $host =~ m/^(.*)\:(\d{2,5})\s*$/) { | ||
| 2558 | $host = $1; | ||
| 2559 | $port = $2; | ||
| 2560 | } else { | ||
| 2561 | $port = $miniWorldObj->ivShow('propHash', 'port'); | ||
| 2562 | } | ||
| 2563 | |||
| 2564 | if ($host && $host =~ m/\w/) { | ||
| 2565 | |||
| 2566 | $host = $axmud::CLIENT->trimWhitespace($host); | ||
| 2567 | |||
| 2568 | if ($profFlag) { | ||
| 2569 | |||
| 2570 | if ($axmud::CLIENT->ipv6Check($host)) { | ||
| 2571 | $worldObj->ivPoke('ipv6', $host); | ||
| 2572 | } elsif ($axmud::CLIENT->ipv4Check($host)) { | ||
| 2573 | $worldObj->ivPoke('ipv4', $host); | ||
| 2574 | } else { | ||
| 2575 | $worldObj->ivPoke('dns', $host); | ||
| 2576 | } | ||
| 2577 | |||
| 2578 | } else { | ||
| 2579 | |||
| 2580 | $worldObj->ivPoke('dns', $host); | ||
| 2581 | } | ||
| 2582 | } | ||
| 2583 | |||
| 2584 | if ($port && $port =~ m/\w/) { | ||
| 2585 | |||
| 2586 | $port = $axmud::CLIENT->trimWhitespace($port); | ||
| 2587 | $worldObj->ivPoke('port', $port); | ||
| 2588 | } | ||
| 2589 | |||
| 2590 | $descrip = $miniWorldObj->ivShow('propHash', 'descrip'); | ||
| 2591 | if ($descrip) { | ||
| 2592 | |||
| 2593 | $worldObj->ivPoke('worldDescrip', $descrip); | ||
| 2594 | } | ||
| 2595 | |||
| 2596 | # Characters, now. The data stored in the mini-world object's ->newPasswordHash (consisting | ||
| 2597 | # of new characters, and existing characters with new passwords) is copied into the world | ||
| 2598 | # profile's ->newPasswordHash; it's up to GA::Session->setupProfiles to create new | ||
| 2599 | # character profiles, the next time this world is a current world | ||
| 2600 | %newHash = $miniWorldObj->newPasswordHash; | ||
| 2601 | foreach my $char (keys %newHash) { | ||
| 2602 | |||
| 2603 | my $pass = $newHash{$char}; # May be 'undef' | ||
| 2604 | |||
| 2605 | $worldObj->ivAdd('newPasswordHash', $char, $pass); | ||
| 2606 | } | ||
| 2607 | |||
| 2608 | # The same applies to the mini-world object's ->newAccountHash | ||
| 2609 | %newHash = $miniWorldObj->newAccountHash; | ||
| 2610 | foreach my $char (keys %newHash) { | ||
| 2611 | |||
| 2612 | my $account = $newHash{$char}; # May be 'undef' | ||
| 2613 | |||
| 2614 | $worldObj->ivAdd('newAccountHash', $char, $account); | ||
| 2615 | } | ||
| 2616 | |||
| 2617 | # In test mode, set the number of connections to at least one | ||
| 2618 | if ($miniWorldObj->testModeFlag && $worldObj->numberConnects == 0) { | ||
| 2619 | |||
| 2620 | $worldObj->ivPoke('numberConnects', 1); | ||
| 2621 | } | ||
| 2622 | |||
| 2623 | return 1; | ||
| 2624 | } | ||
| 2625 | |||
| 2626 | sub escapeHtml { | ||
| 2627 | |||
| 2628 | # Called by $self->updateGridWidgets | ||
| 2629 | # Before displaying a random URL in a label, escape &, < and > characters by replacing them | ||
| 2630 | # with HTML entities &, > and < | ||
| 2631 | # | ||
| 2632 | # Expected arguments | ||
| 2633 | # $url - A URL to be displayed in a Gtk3::Label | ||
| 2634 | # | ||
| 2635 | # Return values | ||
| 2636 | # 'undef' on impropert arguments | ||
| 2637 | # Otherwise return the $url, with any problematic characters escaped | ||
| 2638 | |||
| 2639 | my ($self, $url, $check) = @_; | ||
| 2640 | |||
| 2641 | # Check for improper arguments | ||
| 2642 | if (! defined $url || defined $check) { | ||
| 2643 | |||
| 2644 | return $axmud::CLIENT->writeImproper($self->_objClass . '->escapeHtml', @_); | ||
| 2645 | } | ||
| 2646 | |||
| 2647 | $url =~ s/\&/&/g; | ||
| 2648 | $url =~ s/\</>/g; | ||
| 2649 | $url =~ s/\>/</g; | ||
| 2650 | |||
| 2651 | return $url; | ||
| 2652 | } | ||
| 2653 | |||
| 2654 | # Response methods | ||
| 2655 | |||
| 2656 | sub selectWorldCallback { | ||
| 2657 | |||
| 2658 | # Callback, called by anonymous subroutine in $self->drawWidgets when the user clicks on | ||
| 2659 | # any world in the treeview | ||
| 2660 | # Copies information from the selected world profile into the grid widgets on the right | ||
| 2661 | # side of the window | ||
| 2662 | # | ||
| 2663 | # Expected arguments | ||
| 2664 | # $selection - A Gtk3::TreeSelection corresponding to the selected item in the treeview | ||
| 2665 | # | ||
| 2666 | # Return values | ||
| 2667 | # 'undef' on improper arguments or if the selection can't be matched to something in | ||
| 2668 | # $self->worldList | ||
| 2669 | # 1 otherwise | ||
| 2670 | |||
| 2671 | my ($self, $selection, $check) = @_; | ||
| 2672 | |||
| 2673 | # Local variables | ||
| 2674 | my ($model, $iter, $line, $worldObj); | ||
| 2675 | |||
| 2676 | # Check for improper arguments | ||
| 2677 | if (! defined $selection || defined $check) { | ||
| 2678 | |||
| 2679 | return $axmud::CLIENT->writeImproper($self->_objClass . '->selectWorldCallback', @_); | ||
| 2680 | } | ||
| 2681 | |||
| 2682 | # Get the text of the selected line | ||
| 2683 | ($model, $iter) = $selection->get_selected(); | ||
| 2684 | if (! $iter) { | ||
| 2685 | |||
| 2686 | return undef; | ||
| 2687 | |||
| 2688 | } else { | ||
| 2689 | |||
| 2690 | $line = $model->get($iter, 0); | ||
| 2691 | if (! $self->ivExists('worldHash', $line)) { | ||
| 2692 | |||
| 2693 | return undef; | ||
| 2694 | |||
| 2695 | } else { | ||
| 2696 | |||
| 2697 | $worldObj = $self->ivShow('worldHash', $line); | ||
| 2698 | if (! $worldObj) { | ||
| 2699 | |||
| 2700 | # The user has clicked on the 'Create new world' line | ||
| 2701 | $self->resetGridWidgets(); | ||
| 2702 | |||
| 2703 | } else { | ||
| 2704 | |||
| 2705 | $self->updateGridWidgets($worldObj, $line); | ||
| 2706 | } | ||
| 2707 | |||
| 2708 | return 1; | ||
| 2709 | } | ||
| 2710 | } | ||
| 2711 | } | ||
| 2712 | |||
| 2713 | sub addCharCallback { | ||
| 2714 | |||
| 2715 | # Callback, called by anonymous subroutine in $self->createGridWidgets when the user clicks | ||
| 2716 | # on the 'add' button | ||
| 2717 | # Adds a character (and optionally a password) to ->passwordHash in the GA::Obj::MiniWorld | ||
| 2718 | # corresponding to the current world | ||
| 2719 | # | ||
| 2720 | # Expected arguments | ||
| 2721 | # $widget - The Gtk3::Button clicked | ||
| 2722 | # | ||
| 2723 | # Return values | ||
| 2724 | # 'undef' on improper arguments or if an invalid character name is supplied | ||
| 2725 | # 1 otherwise | ||
| 2726 | |||
| 2727 | my ($self, $widget, $check) = @_; | ||
| 2728 | |||
| 2729 | # Local variables | ||
| 2730 | my ( | ||
| 2731 | $string, $char, $pass, $account, | ||
| 2732 | @charList, | ||
| 2733 | ); | ||
| 2734 | |||
| 2735 | # Check for improper arguments | ||
| 2736 | if (! defined $widget || defined $check) { | ||
| 2737 | |||
| 2738 | return $axmud::CLIENT->writeImproper($self->_objClass . '->addCharCallback', @_); | ||
| 2739 | } | ||
| 2740 | |||
| 2741 | # Prompt the user to enter a username/password/account. The password/account are optional | ||
| 2742 | $string = 'Associated account name'; | ||
| 2743 | if ($self->miniWorldObj->loginAccountMode eq 'unknown') { | ||
| 2744 | $string .= ' (if required)'; | ||
| 2745 | } elsif ($self->miniWorldObj->loginAccountMode eq 'not_required') { | ||
| 2746 | $string .= ' (not required)'; | ||
| 2747 | } elsif ($self->miniWorldObj->loginAccountMode eq 'required') { | ||
| 2748 | $string .= ' (recommended)'; | ||
| 2749 | } | ||
| 2750 | |||
| 2751 | ($char, $pass, $account) = $self->showTripleEntryDialogue( | ||
| 2752 | 'Add character', | ||
| 2753 | 'Enter a username', | ||
| 2754 | 'Enter a password (optional)', | ||
| 2755 | $string, | ||
| 2756 | undef, # No maximum chars | ||
| 2757 | 2, # Obscure password text (only) | ||
| 2758 | ); | ||
| 2759 | |||
| 2760 | if ($char) { | ||
| 2761 | |||
| 2762 | # Trim leading/trailing whitespace from the name, password and account name | ||
| 2763 | $char = $axmud::CLIENT->trimWhitespace($char); | ||
| 2764 | if ($pass) { | ||
| 2765 | |||
| 2766 | $pass = $axmud::CLIENT->trimWhitespace($pass); | ||
| 2767 | } | ||
| 2768 | |||
| 2769 | if ($account) { | ||
| 2770 | |||
| 2771 | $account = $axmud::CLIENT->trimWhitespace($account); | ||
| 2772 | } | ||
| 2773 | |||
| 2774 | # Check that the name is be a valid profile name | ||
| 2775 | if ( | ||
| 2776 | ! $axmud::CLIENT->nameCheck($char, 16) | ||
| 2777 | || $axmud::CLIENT->ivExists('worldProfHash', $char) | ||
| 2778 | ) { | ||
| 2779 | $self->showMsgDialogue( | ||
| 2780 | 'Add character', | ||
| 2781 | 'error', | ||
| 2782 | '\'' . $char . '\' is not a valid character profile name', | ||
| 2783 | 'ok', | ||
| 2784 | ); | ||
| 2785 | |||
| 2786 | return undef; | ||
| 2787 | } | ||
| 2788 | |||
| 2789 | # Update the current mini-world object | ||
| 2790 | if ($pass) { | ||
| 2791 | |||
| 2792 | $self->miniWorldObj->ivAdd('passwordHash', $char, $pass); | ||
| 2793 | $self->miniWorldObj->ivAdd('newPasswordHash', $char, $pass); | ||
| 2794 | |||
| 2795 | } else { | ||
| 2796 | |||
| 2797 | $self->miniWorldObj->ivAdd('passwordHash', $char, undef); | ||
| 2798 | $self->miniWorldObj->ivAdd('newPasswordHash', $char, undef); | ||
| 2799 | } | ||
| 2800 | |||
| 2801 | if ($account) { | ||
| 2802 | |||
| 2803 | $self->miniWorldObj->ivAdd('accountHash', $char, $account); | ||
| 2804 | $self->miniWorldObj->ivAdd('newAccountHash', $char, $account); | ||
| 2805 | |||
| 2806 | } else { | ||
| 2807 | |||
| 2808 | $self->miniWorldObj->ivAdd('accountHash', $char, undef); | ||
| 2809 | $self->miniWorldObj->ivAdd('newAccountHash', $char, undef); | ||
| 2810 | } | ||
| 2811 | |||
| 2812 | $self->miniWorldObj->ivPoke('selectChar', $char); | ||
| 2813 | |||
| 2814 | # Redraw the combobox | ||
| 2815 | @charList = sort {lc($a) cmp lc($b)} ($self->miniWorldObj->ivKeys('passwordHash')); | ||
| 2816 | my $comboBox = $self->resetComboBox(TRUE, @charList); | ||
| 2817 | $self->ivPoke('comboBox', $comboBox); | ||
| 2818 | } | ||
| 2819 | |||
| 2820 | return 1; | ||
| 2821 | } | ||
| 2822 | |||
| 2823 | sub editPasswordCallback { | ||
| 2824 | |||
| 2825 | # Callback, called by anonymous subroutine in $self->createGridWidgets when the user clicks | ||
| 2826 | # on the 'pwd' button | ||
| 2827 | # Edits the password of an existing character, storing the changes in the current mini-world | ||
| 2828 | # object's ->passwordHash and ->newPasswordHash | ||
| 2829 | # | ||
| 2830 | # Expected arguments | ||
| 2831 | # $widget - The Gtk3::Button clicked | ||
| 2832 | # | ||
| 2833 | # Return values | ||
| 2834 | # 'undef' on improper arguments or if no character is selected | ||
| 2835 | # 1 otherwise | ||
| 2836 | |||
| 2837 | my ($self, $widget, $check) = @_; | ||
| 2838 | |||
| 2839 | # Local variables | ||
| 2840 | my ($char, $currentPass, $newPass); | ||
| 2841 | |||
| 2842 | # Check for improper arguments | ||
| 2843 | if (! defined $widget || defined $check) { | ||
| 2844 | |||
| 2845 | return $axmud::CLIENT->writeImproper($self->_objClass . '->editPasswordCallback', @_); | ||
| 2846 | } | ||
| 2847 | |||
| 2848 | # Get the character displayed in the combobox | ||
| 2849 | $char = $self->comboBox->get_active_text(); | ||
| 2850 | if (! $char || $char eq $self->noCharString) { | ||
| 2851 | |||
| 2852 | # No character to edit | ||
| 2853 | return undef; | ||
| 2854 | } | ||
| 2855 | |||
| 2856 | # Get the current password for this character (if any) | ||
| 2857 | $currentPass = $self->miniWorldObj->ivShow('passwordHash', $char); | ||
| 2858 | |||
| 2859 | # Prompt the user to enter a new password | ||
| 2860 | $newPass = $self->showEntryDialogue( | ||
| 2861 | 'Edit password', | ||
| 2862 | 'Enter a new password for the \'' . $char . '\' character', | ||
| 2863 | undef, # No maximum chars | ||
| 2864 | $currentPass, | ||
| 2865 | TRUE, # Obscure text in the entry box | ||
| 2866 | ); | ||
| 2867 | |||
| 2868 | # If the user didn't close the window manually... | ||
| 2869 | if (defined $newPass) { | ||
| 2870 | |||
| 2871 | if ($newPass) { | ||
| 2872 | |||
| 2873 | $self->miniWorldObj->ivAdd('passwordHash', $char, $newPass); | ||
| 2874 | $self->miniWorldObj->ivAdd('newPasswordHash', $char, $newPass); | ||
| 2875 | |||
| 2876 | } else { | ||
| 2877 | |||
| 2878 | $self->miniWorldObj->ivAdd('passwordHash', $char, undef); | ||
| 2879 | $self->miniWorldObj->ivAdd('newPasswordHash', $char, undef); | ||
| 2880 | } | ||
| 2881 | } | ||
| 2882 | |||
| 2883 | return 1; | ||
| 2884 | } | ||
| 2885 | |||
| 2886 | sub editAccountCallback { | ||
| 2887 | |||
| 2888 | # Callback, called by anonymous subroutine in $self->createGridWidgets when the user clicks | ||
| 2889 | # on the 'account' button | ||
| 2890 | # Edits the associated account for an existing character, storing the changes in the current | ||
| 2891 | # mini-world object's ->accountHash and ->newAccountHash | ||
| 2892 | # | ||
| 2893 | # Expected arguments | ||
| 2894 | # $widget - The Gtk3::Button clicked | ||
| 2895 | # | ||
| 2896 | # Return values | ||
| 2897 | # 'undef' on improper arguments or if no character is selected | ||
| 2898 | # 1 otherwise | ||
| 2899 | |||
| 2900 | my ($self, $widget, $check) = @_; | ||
| 2901 | |||
| 2902 | # Local variables | ||
| 2903 | my ($string, $char, $currentAccount, $newAccount); | ||
| 2904 | |||
| 2905 | # Check for improper arguments | ||
| 2906 | if (! defined $widget || defined $check) { | ||
| 2907 | |||
| 2908 | return $axmud::CLIENT->writeImproper($self->_objClass . '->editAccountCallback', @_); | ||
| 2909 | } | ||
| 2910 | |||
| 2911 | # Get the character displayed in the combobox | ||
| 2912 | $char = $self->comboBox->get_active_text(); | ||
| 2913 | if (! $char || $char eq $self->noCharString) { | ||
| 2914 | |||
| 2915 | # No character to edit | ||
| 2916 | return undef; | ||
| 2917 | } | ||
| 2918 | |||
| 2919 | # Get the current account for this character (if any) | ||
| 2920 | $currentAccount = $self->miniWorldObj->ivShow('accountHash', $char); | ||
| 2921 | |||
| 2922 | # Prompt the user to enter a new password | ||
| 2923 | $string = 'Enter the new account name associated with the \'' . $char . '\' character'; | ||
| 2924 | if ($self->miniWorldObj->loginAccountMode eq 'not_required') { | ||
| 2925 | $string .= ' (not required for this world)'; | ||
| 2926 | } elsif ($self->miniWorldObj->loginAccountMode eq 'required') { | ||
| 2927 | $string .= ' (recommended for this world)'; | ||
| 2928 | } else { | ||
| 2929 | $string .= ' (if required for this world)'; | ||
| 2930 | } | ||
| 2931 | |||
| 2932 | $newAccount = $self->showEntryDialogue( | ||
| 2933 | 'Edit account', | ||
| 2934 | $string, | ||
| 2935 | undef, # No maximum chars | ||
| 2936 | $currentAccount, | ||
| 2937 | ); | ||
| 2938 | |||
| 2939 | # If the user didn't close the window manually... | ||
| 2940 | if (defined $newAccount) { | ||
| 2941 | |||
| 2942 | if ($newAccount) { | ||
| 2943 | |||
| 2944 | $self->miniWorldObj->ivAdd('accountHash', $char, $newAccount); | ||
| 2945 | $self->miniWorldObj->ivAdd('newAccountHash', $char, $newAccount); | ||
| 2946 | |||
| 2947 | } else { | ||
| 2948 | |||
| 2949 | $self->miniWorldObj->ivAdd('accountHash', $char, undef); | ||
| 2950 | $self->miniWorldObj->ivAdd('newAccountHash', $char, undef); | ||
| 2951 | } | ||
| 2952 | } | ||
| 2953 | |||
| 2954 | return 1; | ||
| 2955 | } | ||
| 2956 | |||
| 2957 | sub createWorldCallback { | ||
| 2958 | |||
| 2959 | # Callback, called by anonymous subroutine in $self->createGridWidgets when the user clicks | ||
| 2960 | # the 'create world' button (only visible when 'Create new world' is selected in the list | ||
| 2961 | # of worlds) | ||
| 2962 | # When the currently-selected treeview item is 'create new world', creates a new world | ||
| 2963 | # profile, and updates it with the data stored in $self->miniWorldObj | ||
| 2964 | # | ||
| 2965 | # Expected arguments | ||
| 2966 | # (none besides $self) | ||
| 2967 | # | ||
| 2968 | # Return values | ||
| 2969 | # 'undef' on improper arguments or if there is an error | ||
| 2970 | # 1 otherwise | ||
| 2971 | |||
| 2972 | my ($self, $check) = @_; | ||
| 2973 | |||
| 2974 | # Local variables | ||
| 2975 | my ( | ||
| 2976 | $invalidString, $generalString, $name, $host, $port, $worldObj, $fileObj, $dictObj, | ||
| 2977 | $miniObj, | ||
| 2978 | %pwdHash, %accHash, | ||
| 2979 | ); | ||
| 2980 | |||
| 2981 | # Check for improper arguments | ||
| 2982 | if (defined $check) { | ||
| 2983 | |||
| 2984 | return $axmud::CLIENT->writeImproper($self->_objClass . '->createWorldCallback', @_); | ||
| 2985 | } | ||
| 2986 | |||
| 2987 | if ($self->worldObj && $self->preConfigButton->get_active()) { | ||
| 2988 | |||
| 2989 | # This function shouldn't have been called (->applyChangesCallback should have been | ||
| 2990 | # called instead) | ||
| 2991 | return undef; | ||
| 2992 | } | ||
| 2993 | |||
| 2994 | # Set a few strings to use in 'dialogue' windows | ||
| 2995 | $invalidString = ' can contain letters, numbers and underline characters (except the first' | ||
| 2996 | . ' character), but not spaces. Reserved names like \'' . $axmud::SCRIPT | ||
| 2997 | . '\' are not allowed. The maximum length is 16 characters.'; | ||
| 2998 | $generalString = 'Failed to create the new world profile (many apologies)'; | ||
| 2999 | |||
| 3000 | # Check that the name specified by the user is valid | ||
| 3001 | $name = $axmud::CLIENT->trimWhitespace($self->entry->get_text()); | ||
| 3002 | if ($name eq '') { | ||
| 3003 | |||
| 3004 | $self->showMsgDialogue( | ||
| 3005 | 'Missing name', | ||
| 3006 | 'error', | ||
| 3007 | 'You must specify a name for this world. World profile names' . $invalidString, | ||
| 3008 | 'ok', | ||
| 3009 | ); | ||
| 3010 | |||
| 3011 | return undef; | ||
| 3012 | |||
| 3013 | } elsif (! $axmud::CLIENT->nameCheck($name, 16)) { | ||
| 3014 | |||
| 3015 | $self->showMsgDialogue( | ||
| 3016 | 'Invalid name', | ||
| 3017 | 'error', | ||
| 3018 | '\'' . $name . '\' is an invalid world profile name. Names' . $invalidString, | ||
| 3019 | 'ok', | ||
| 3020 | ); | ||
| 3021 | |||
| 3022 | return undef; | ||
| 3023 | } | ||
| 3024 | |||
| 3025 | # Check that the user entered a host address | ||
| 3026 | $host = $axmud::CLIENT->trimWhitespace($self->entry2->get_text()); | ||
| 3027 | if ($host eq '') { | ||
| 3028 | |||
| 3029 | $self->showMsgDialogue( | ||
| 3030 | 'Missing host address', | ||
| 3031 | 'error', | ||
| 3032 | 'You must specify a host address, e.g. \'dead-souls.net\'. IPV4, IPV6 or DNS' | ||
| 3033 | . ' addresses can be used.', | ||
| 3034 | 'ok', | ||
| 3035 | ); | ||
| 3036 | |||
| 3037 | return undef; | ||
| 3038 | } | ||
| 3039 | |||
| 3040 | # If the host address is in the form 'deathmud.com:8888', then extract the port. Although | ||
| 3041 | # it technically possible to use ports with only one digit, don't recognise it | ||
| 3042 | # If, at the same time, the port was specified in the other entry box, ignore the other | ||
| 3043 | # entry box | ||
| 3044 | if ($host && $host =~ m/^(.*)\:(\d{2,5})\s*$/) { | ||
| 3045 | $host = $1; | ||
| 3046 | $port = $2; | ||
| 3047 | } else { | ||
| 3048 | $port = $axmud::CLIENT->trimWhitespace($self->entry3->get_text()); | ||
| 3049 | } | ||
| 3050 | |||
| 3051 | # If the port was specified, check that it is valid. If the port was left empty, the generic | ||
| 3052 | # port will be used anyway | ||
| 3053 | if ($port ne '' && $port =~ m/\S/ && ! $axmud::CLIENT->intCheck($port, 0, 65535)) { | ||
| 3054 | |||
| 3055 | $self->showMsgDialogue( | ||
| 3056 | 'Invalid port', | ||
| 3057 | 'error', | ||
| 3058 | '\'' . $port . '\' is an invalid port. Specify a value in the range 0-65535, or' | ||
| 3059 | . ' leave the box empty to use the default port.', | ||
| 3060 | 'ok', | ||
| 3061 | ); | ||
| 3062 | |||
| 3063 | return undef; | ||
| 3064 | } | ||
| 3065 | |||
| 3066 | # Create the new world profile. Cheat a bit by pretending the GA::Client is a | ||
| 3067 | # GA::Session. (Rest of this function adapted from code in GA::Cmd::AddWorld->do) | ||
| 3068 | $worldObj = Games::Axmud::Profile::World->new($axmud::CLIENT, $name); | ||
| 3069 | if ($worldObj) { | ||
| 3070 | |||
| 3071 | # Create a file object for the world profile | ||
| 3072 | $fileObj = Games::Axmud::Obj::File->new('worldprof', $name); | ||
| 3073 | } | ||
| 3074 | |||
| 3075 | if (! $worldObj || ! $fileObj) { | ||
| 3076 | |||
| 3077 | $self->showMsgDialogue( | ||
| 3078 | 'General error', | ||
| 3079 | 'error', | ||
| 3080 | $generalString, | ||
| 3081 | 'ok', | ||
| 3082 | ); | ||
| 3083 | |||
| 3084 | return undef; | ||
| 3085 | } | ||
| 3086 | |||
| 3087 | # If a dictionary object with the same name as the world doesn't already exist, create it. | ||
| 3088 | # Otherwise use the existing one | ||
| 3089 | if (! $axmud::CLIENT->ivExists('dictHash', $name)) { | ||
| 3090 | |||
| 3091 | # (Again, cheat a bit by pretending the GA::Client is a GA::Session) | ||
| 3092 | $dictObj = Games::Axmud::Obj::Dict->new($axmud::CLIENT, $name); | ||
| 3093 | if (! $dictObj) { | ||
| 3094 | |||
| 3095 | $self->showMsgDialogue( | ||
| 3096 | 'General error', | ||
| 3097 | 'error', | ||
| 3098 | $generalString, | ||
| 3099 | 'ok', | ||
| 3100 | ); | ||
| 3101 | |||
| 3102 | return undef; | ||
| 3103 | |||
| 3104 | } else { | ||
| 3105 | |||
| 3106 | # Update client IVs with the new dictionary | ||
| 3107 | $axmud::CLIENT->add_dict($dictObj); | ||
| 3108 | } | ||
| 3109 | } | ||
| 3110 | |||
| 3111 | # Update client IVs with the new profile and file object | ||
| 3112 | $axmud::CLIENT->add_fileObj($fileObj); | ||
| 3113 | $axmud::CLIENT->add_worldProf($worldObj); | ||
| 3114 | |||
| 3115 | # Update the world profile's IVs using the values stored in the mini-world object | ||
| 3116 | if ($axmud::CLIENT->ipv6Check($host)) { | ||
| 3117 | $worldObj->ivPoke('ipv6', $host); | ||
| 3118 | } elsif ($axmud::CLIENT->ipv4Check($host)) { | ||
| 3119 | $worldObj->ivPoke('ipv4', $host); | ||
| 3120 | } else { | ||
| 3121 | $worldObj->ivPoke('dns', $host); | ||
| 3122 | } | ||
| 3123 | |||
| 3124 | if ($port) { | ||
| 3125 | |||
| 3126 | # (Otherwise the world profile continues using the generic port, 23) | ||
| 3127 | $worldObj->ivPoke('port', $port); | ||
| 3128 | } | ||
| 3129 | |||
| 3130 | # If the basic mudlist is displayed, we can set a couple of other IVs, too | ||
| 3131 | if ($self->worldObj && $self->otherWorldButton->get_active()) { | ||
| 3132 | |||
| 3133 | $worldObj->ivPoke('longName', $self->worldObj->longName); | ||
| 3134 | $worldObj->ivPoke('adultFlag', $self->worldObj->adultFlag); | ||
| 3135 | } | ||
| 3136 | |||
| 3137 | # Create a new mini-world object, replacing the temporary one stored in $self->miniWorldObj, | ||
| 3138 | # and store it in the hash of mini-world objects which have corresponding world | ||
| 3139 | # profiles | ||
| 3140 | %pwdHash = $self->miniWorldObj->passwordHash; | ||
| 3141 | %accHash = $self->miniWorldObj->accountHash; | ||
| 3142 | $miniObj = Games::Axmud::Obj::MiniWorld->new( | ||
| 3143 | $worldObj, | ||
| 3144 | $self->miniWorldObj->selectChar, | ||
| 3145 | $self->miniWorldObj->loginAccountMode, | ||
| 3146 | \%pwdHash, | ||
| 3147 | \%accHash, | ||
| 3148 | ); | ||
| 3149 | |||
| 3150 | if ($miniObj) { | ||
| 3151 | |||
| 3152 | $self->ivAdd('miniWorldHash', $worldObj->name, $miniObj); | ||
| 3153 | } | ||
| 3154 | |||
| 3155 | # Reset the treeview, specifying that the new world profile should be selected (the call to | ||
| 3156 | # ->resetTreeView also creates a new mini-world object corresponding to $worldObj) | ||
| 3157 | if ($self->otherWorldButton->get_active()) { | ||
| 3158 | |||
| 3159 | # Make sure the list of pre-configured worlds is now visible | ||
| 3160 | $self->preConfigButton->set_active(TRUE); | ||
| 3161 | } | ||
| 3162 | |||
| 3163 | $self->resetTreeView(undef, $worldObj->name); | ||
| 3164 | |||
| 3165 | return 1; | ||
| 3166 | } | ||
| 3167 | |||
| 3168 | sub applyChangesCallback { | ||
| 3169 | |||
| 3170 | # Callback, called by anonymous subroutine in $self->createGridWidgets when the user clicks | ||
| 3171 | # the 'apply changes' button (only visibile when 'Create new world' is not selected in the | ||
| 3172 | # list of worlds) | ||
| 3173 | # | ||
| 3174 | # When the currently-selected treeview item is not 'create new world', updates the current | ||
| 3175 | # world profile with any user-entered values stored in the current mini-world object | ||
| 3176 | # | ||
| 3177 | # Expected arguments | ||
| 3178 | # (none besides $self) | ||
| 3179 | # | ||
| 3180 | # Return values | ||
| 3181 | # 'undef' on improper arguments or if there is an error | ||
| 3182 | # 1 otherwise | ||
| 3183 | |||
| 3184 | my ($self, $check) = @_; | ||
| 3185 | |||
| 3186 | # Local variables | ||
| 3187 | my $name; | ||
| 3188 | |||
| 3189 | # Check for improper arguments | ||
| 3190 | if (defined $check) { | ||
| 3191 | |||
| 3192 | return $axmud::CLIENT->writeImproper($self->_objClass . '->applyChangesCallback', @_); | ||
| 3193 | } | ||
| 3194 | |||
| 3195 | if (! $self->worldObj) { | ||
| 3196 | |||
| 3197 | # This function shouldn't have been called (->createWorldCallback should have been | ||
| 3198 | # called instead) | ||
| 3199 | return undef; | ||
| 3200 | } | ||
| 3201 | |||
| 3202 | # Copy changes from the current mini-world object into the corresponding world profile | ||
| 3203 | $self->updateProfile($self->miniWorldObj); | ||
| 3204 | |||
| 3205 | # Reset the mini-world object - the empty IVs mean that the world profile stores the | ||
| 3206 | # same data | ||
| 3207 | $self->miniWorldObj->reset(); | ||
| 3208 | |||
| 3209 | # Reset the treeview, specifying that the existing world profile should still be selected | ||
| 3210 | # this updates grid widgets) | ||
| 3211 | $name = $self->worldObj->name; | ||
| 3212 | $self->resetTreeView(undef, $name); | ||
| 3213 | |||
| 3214 | # Display a confirmation | ||
| 3215 | $self->showMsgDialogue( | ||
| 3216 | 'World updated', | ||
| 3217 | 'info', | ||
| 3218 | 'The \'' . $name . '\' world profile has been updated (but data files have not been' | ||
| 3219 | . ' saved - use the \';save\' command when you start a new session)', | ||
| 3220 | 'ok', | ||
| 3221 | ); | ||
| 3222 | |||
| 3223 | return 1; | ||
| 3224 | } | ||
| 3225 | |||
| 3226 | sub resetWorldCallback { | ||
| 3227 | |||
| 3228 | # Callback, called by anonymous subroutine in $self->createGridWidgets when the user clicks | ||
| 3229 | # the 'reset world' button | ||
| 3230 | # Creates a new mini-world object to replace the old one, then resets the treeview which | ||
| 3231 | # causes all the grid widgets to display the values actually stored in the world profile | ||
| 3232 | # | ||
| 3233 | # Expected arguments | ||
| 3234 | # $widget - The Gtk3::Button clicked | ||
| 3235 | # | ||
| 3236 | # Return values | ||
| 3237 | # 'undef' on improper arguments or if there is an error | ||
| 3238 | # 1 otherwise | ||
| 3239 | |||
| 3240 | my ($self, $widget, $check) = @_; | ||
| 3241 | |||
| 3242 | # Local variables | ||
| 3243 | my ( | ||
| 3244 | $miniObj, | ||
| 3245 | %pwdHash, %accHash, | ||
| 3246 | ); | ||
| 3247 | |||
| 3248 | # Check for improper arguments | ||
| 3249 | if (! defined $widget || defined $check) { | ||
| 3250 | |||
| 3251 | return $axmud::CLIENT->writeImproper($self->_objClass . '->resetWorldCallback', @_); | ||
| 3252 | } | ||
| 3253 | |||
| 3254 | if (! $self->worldObj) { | ||
| 3255 | |||
| 3256 | # This function shouldn't have been called (->createWorldCallback should have been | ||
| 3257 | # called instead) | ||
| 3258 | return undef; | ||
| 3259 | } | ||
| 3260 | |||
| 3261 | if ($self->preConfigButton->get_active()) { | ||
| 3262 | |||
| 3263 | # Create a new mini-world object corresponding to an existing world profile | ||
| 3264 | %pwdHash = $self->worldObj->passwordHash; | ||
| 3265 | %accHash = $self->worldObj->accountHash; | ||
| 3266 | $miniObj = Games::Axmud::Obj::MiniWorld->new( | ||
| 3267 | $self->worldObj, | ||
| 3268 | $self->worldObj->lastConnectChar, # May be undef | ||
| 3269 | $self->worldObj->loginAccountMode, | ||
| 3270 | \%pwdHash, | ||
| 3271 | \%accHash, | ||
| 3272 | ); | ||
| 3273 | |||
| 3274 | } else { | ||
| 3275 | |||
| 3276 | # Create a new mini-world object NOT corresponding to an existing world profile | ||
| 3277 | $miniObj = Games::Axmud::Obj::MiniWorld->new($self->worldObj); | ||
| 3278 | } | ||
| 3279 | |||
| 3280 | if ($miniObj) { | ||
| 3281 | |||
| 3282 | $self->ivAdd('miniWorldHash', $self->worldObj->name, $miniObj); | ||
| 3283 | } | ||
| 3284 | |||
| 3285 | # Reset the treeview, specifying that the same world profile should be selected (the call to | ||
| 3286 | # ->resetTreeView also creates a new mini-world object corresponding to $worldObj) | ||
| 3287 | $self->resetTreeView(undef, $self->worldObj->name); | ||
| 3288 | |||
| 3289 | return 1; | ||
| 3290 | } | ||
| 3291 | |||
| 3292 | sub connectWorldCallback { | ||
| 3293 | |||
| 3294 | # Callback, called by anonymous subroutine in $self->createGridWidgets when the user clicks | ||
| 3295 | # the 'connect to world' or 'connect offline' buttons | ||
| 3296 | # Starts a new GA::Session, passing it information from this window (such as the selected | ||
| 3297 | # world and character) | ||
| 3298 | # | ||
| 3299 | # Expected arguments | ||
| 3300 | # $offlineFlag - Set to TRUE if the user clicked on the 'connect offline' button; set | ||
| 3301 | # to FALSE if the user clicked on the 'connect to world' button | ||
| 3302 | # | ||
| 3303 | # Return values | ||
| 3304 | # 'undef' on improper arguments or if there is an error | ||
| 3305 | # 1 otherwise | ||
| 3306 | |||
| 3307 | my ($self, $offlineFlag, $check) = @_; | ||
| 3308 | |||
| 3309 | # Local variables | ||
| 3310 | my ( | ||
| 3311 | $displayFlag, $applyFlag, $msg, $response, $worldName, $tempFlag, $altHost, $altPort, | ||
| 3312 | $altChar, $altPass, $altAccount, $host, $port, $pass, $char, $account, $protocol, | ||
| 3313 | @miniList, | ||
| 3314 | ); | ||
| 3315 | |||
| 3316 | # Check for improper arguments | ||
| 3317 | if (! defined $offlineFlag || defined $check) { | ||
| 3318 | |||
| 3319 | return $axmud::CLIENT->writeImproper($self->_objClass . '->connectWorldCallback', @_); | ||
| 3320 | } | ||
| 3321 | |||
| 3322 | # Remember which list was displayed, as the Connections window is about to be destroyed | ||
| 3323 | if ($self->otherWorldButton->get_active()) { | ||
| 3324 | |||
| 3325 | $displayFlag = TRUE; | ||
| 3326 | } | ||
| 3327 | |||
| 3328 | # Before doing anything, check that the maximum number of sessions hasn't already been | ||
| 3329 | # reached | ||
| 3330 | if ($axmud::CLIENT->ivPairs('sessionHash') >= $axmud::CLIENT->sessionMax) { | ||
| 3331 | |||
| 3332 | if ($axmud::CLIENT->sessionMax == 1) { | ||
| 3333 | |||
| 3334 | $self->showMsgDialogue( | ||
| 3335 | 'Session limit reached', | ||
| 3336 | 'error', | ||
| 3337 | 'Can\'t open a new session (only one session allowed - use the' | ||
| 3338 | . ' \';maxsession\' command to change this)', | ||
| 3339 | 'ok', | ||
| 3340 | ); | ||
| 3341 | |||
| 3342 | } else { | ||
| 3343 | |||
| 3344 | $self->showMsgDialogue( | ||
| 3345 | 'Session limit reached', | ||
| 3346 | 'error', | ||
| 3347 | 'Can\'t open a new session (' . $axmud::SCRIPT . ' has reached its limit of ' | ||
| 3348 | . $self->sessionMax . ' sessions)', | ||
| 3349 | 'ok', | ||
| 3350 | ); | ||
| 3351 | } | ||
| 3352 | |||
| 3353 | return undef; | ||
| 3354 | } | ||
| 3355 | |||
| 3356 | # If the user has made any changes to the values displayed in grid widgets, that would be | ||
| 3357 | # applied to the world profile when the 'store changes' button is clicked, we need to ask | ||
| 3358 | # the user if they want to apply those changes now | ||
| 3359 | |||
| 3360 | # Compile a list of mini-world objects whose values have been modified, but not stored in | ||
| 3361 | # the corresponding world profiles. Also set a flag if the selected mini-world has been | ||
| 3362 | # modified, but not stored | ||
| 3363 | foreach my $miniObj ($self->ivValues('miniWorldHash')) { | ||
| 3364 | |||
| 3365 | if ($miniObj->propHash || $miniObj->newPasswordHash || $miniObj->newAccountHash) { | ||
| 3366 | |||
| 3367 | push (@miniList, $miniObj); | ||
| 3368 | |||
| 3369 | if ($miniObj eq $self->miniWorldObj) { | ||
| 3370 | |||
| 3371 | $applyFlag = TRUE; | ||
| 3372 | } | ||
| 3373 | } | ||
| 3374 | } | ||
| 3375 | |||
| 3376 | if (@miniList) { | ||
| 3377 | |||
| 3378 | # Unstored values; prompt the user to ask if they'd like to apply them before continuing | ||
| 3379 | $msg = 'You haven\'t applied your changes to '; | ||
| 3380 | if (! $applyFlag) { | ||
| 3381 | |||
| 3382 | if (@miniList == 1) { | ||
| 3383 | $msg .= '1 world' | ||
| 3384 | } else { | ||
| 3385 | $msg .= scalar @miniList . ' worlds' | ||
| 3386 | } | ||
| 3387 | |||
| 3388 | } else { | ||
| 3389 | |||
| 3390 | if (@miniList == 1) { | ||
| 3391 | $msg .= 'the selected world'; | ||
| 3392 | } else { | ||
| 3393 | $msg .= scalar @miniList . ' worlds (including the selected one)'; | ||
| 3394 | } | ||
| 3395 | } | ||
| 3396 | |||
| 3397 | $msg .= '. Do you want to apply them now?'; | ||
| 3398 | |||
| 3399 | $response = $self->showMsgDialogue( | ||
| 3400 | 'Apply changes', | ||
| 3401 | 'question', | ||
| 3402 | $msg, | ||
| 3403 | 'yes-no', | ||
| 3404 | 'yes', | ||
| 3405 | ); | ||
| 3406 | |||
| 3407 | if ($response && $response eq 'yes') { | ||
| 3408 | |||
| 3409 | # Apply the changes for each modified mini-world object | ||
| 3410 | foreach my $miniObj (@miniList) { | ||
| 3411 | |||
| 3412 | $self->updateProfile($miniObj); | ||
| 3413 | } | ||
| 3414 | |||
| 3415 | if (! $self->worldObj) { | ||
| 3416 | |||
| 3417 | # Earlier there was no corresponding world profile object, but now there is one. | ||
| 3418 | # Use it | ||
| 3419 | $self->ivPoke( | ||
| 3420 | 'worldObj', | ||
| 3421 | $axmud::CLIENT->ivShow('worldProfHash', $self->miniWorldObj->name), | ||
| 3422 | ); | ||
| 3423 | } | ||
| 3424 | } | ||
| 3425 | } | ||
| 3426 | |||
| 3427 | # Set the chosen $protocol, or leave 'undef' to use the world profile's default protocol | ||
| 3428 | if ($self->radioButton2->get_active()) { | ||
| 3429 | $protocol = 'telnet'; | ||
| 3430 | } elsif ($self->radioButton3->get_active()) { | ||
| 3431 | $protocol = 'ssh'; | ||
| 3432 | } elsif ($self->radioButton4->get_active()) { | ||
| 3433 | $protocol = 'ssl'; | ||
| 3434 | } | ||
| 3435 | |||
| 3436 | if ($self->worldObj) { | ||
| 3437 | |||
| 3438 | if (! $displayFlag) { | ||
| 3439 | |||
| 3440 | # The user has selected a world with an existing world profile | ||
| 3441 | $tempFlag = FALSE; | ||
| 3442 | $worldName = $self->worldObj->name; | ||
| 3443 | |||
| 3444 | # Get the world profile's usual connection details, in case the mini-world object | ||
| 3445 | # doesn't specify them | ||
| 3446 | ($altHost, $altPort, $altChar, $altPass, $altAccount) | ||
| 3447 | = $self->worldObj->getConnectDetails($self->miniWorldObj->selectChar); | ||
| 3448 | |||
| 3449 | # Decide which connection details to use | ||
| 3450 | $host = $self->miniWorldObj->ivShow('propHash', 'host'); | ||
| 3451 | if (! $host) { | ||
| 3452 | |||
| 3453 | $host = $altHost; | ||
| 3454 | } | ||
| 3455 | |||
| 3456 | $port = $self->miniWorldObj->ivShow('propHash', 'port'); | ||
| 3457 | if (! $port) { | ||
| 3458 | |||
| 3459 | $port = $altPort; | ||
| 3460 | } | ||
| 3461 | |||
| 3462 | |||
| 3463 | } else { | ||
| 3464 | |||
| 3465 | # The user has selected a world from the basic mudlist, for which no world profile | ||
| 3466 | # exists yet | ||
| 3467 | $tempFlag = FALSE; | ||
| 3468 | $worldName = $self->worldObj->name; | ||
| 3469 | $host = $self->worldObj->host; | ||
| 3470 | $port = $self->worldObj->port; | ||
| 3471 | } | ||
| 3472 | |||
| 3473 | $char = $self->miniWorldObj->selectChar; # May be 'undef' | ||
| 3474 | if ($char) { | ||
| 3475 | |||
| 3476 | $pass = $self->miniWorldObj->ivShow( | ||
| 3477 | 'passwordHash', | ||
| 3478 | $self->miniWorldObj->selectChar, | ||
| 3479 | ); | ||
| 3480 | |||
| 3481 | $account = $self->miniWorldObj->ivShow( | ||
| 3482 | 'accountHash', | ||
| 3483 | $self->miniWorldObj->selectChar, | ||
| 3484 | ); | ||
| 3485 | } | ||
| 3486 | |||
| 3487 | # If the user selected no auto-login, reset the password and account name (the | ||
| 3488 | # GA::Session won't attempt an auto-login, without knowing the password) | ||
| 3489 | if ($self->miniWorldObj->noAutoLoginFlag) { | ||
| 3490 | |||
| 3491 | $pass = undef; | ||
| 3492 | $account = undef; | ||
| 3493 | } | ||
| 3494 | |||
| 3495 | } else { | ||
| 3496 | |||
| 3497 | # The user has selected a world without an existing world profile, and has declined | ||
| 3498 | # to create a profile in the earlier 'dialogue' window (if one was presented) | ||
| 3499 | $worldName = $self->miniWorldObj->ivShow('propHash', 'name'); | ||
| 3500 | if ($worldName ne '') { | ||
| 3501 | |||
| 3502 | if (! $axmud::CLIENT->nameCheck($worldName, 16)) { | ||
| 3503 | |||
| 3504 | $self->showMsgDialogue( | ||
| 3505 | 'Invalid name', | ||
| 3506 | 'error', | ||
| 3507 | '\'' . $worldName . '\' is an invalid world profile name. Names can contain' | ||
| 3508 | . ' letters, numbers and underline characters (except the first character),' | ||
| 3509 | . ' but not spaces. Reserved names like \'' . $axmud::SCRIPT | ||
| 3510 | . '\' are not allowed. The maximum length is 16 characters.', | ||
| 3511 | 'ok', | ||
| 3512 | ); | ||
| 3513 | |||
| 3514 | return undef; | ||
| 3515 | |||
| 3516 | } else { | ||
| 3517 | |||
| 3518 | $tempFlag = FALSE; | ||
| 3519 | } | ||
| 3520 | |||
| 3521 | } else { | ||
| 3522 | |||
| 3523 | # The user didn't specify a world name. Ask the GA::Client to supply us with a name | ||
| 3524 | # for a temporary profile | ||
| 3525 | $tempFlag = TRUE; | ||
| 3526 | $worldName = $axmud::CLIENT->getTempProfName(); | ||
| 3527 | if (! $worldName) { | ||
| 3528 | |||
| 3529 | # No available names (an extremely unlikely situation) | ||
| 3530 | $axmud::CLIENT->mainWin->showMsgDialogue( | ||
| 3531 | 'Failed connection', | ||
| 3532 | 'error', | ||
| 3533 | 'General error while connection to the world', | ||
| 3534 | 'ok', | ||
| 3535 | ); | ||
| 3536 | |||
| 3537 | return undef; | ||
| 3538 | } | ||
| 3539 | } | ||
| 3540 | |||
| 3541 | # Decide which connection details to use (the 'host' value is always defined when this | ||
| 3542 | # function is called) | ||
| 3543 | $host = $self->miniWorldObj->ivShow('propHash', 'host'); | ||
| 3544 | # If the host address is in the form 'deathmud.com:8888', then extract the port. | ||
| 3545 | # Although it technically possible to use ports with only one digit, don't recognise | ||
| 3546 | # it | ||
| 3547 | # If, at the same time, the port was specified in the other entry box, ignore the other | ||
| 3548 | # entry box | ||
| 3549 | if ($host =~ m/^(.*)\:(\d{2,5})\s*$/) { | ||
| 3550 | |||
| 3551 | $host = $1; | ||
| 3552 | $port = $2; | ||
| 3553 | |||
| 3554 | } else { | ||
| 3555 | |||
| 3556 | $port = $self->miniWorldObj->ivShow('propHash', 'port'); | ||
| 3557 | if (! defined $port || $port eq '') { | ||
| 3558 | |||
| 3559 | $port = 23; | ||
| 3560 | |||
| 3561 | } elsif (! $axmud::CLIENT->intCheck($port, 0, 65535)) { | ||
| 3562 | |||
| 3563 | $self->showMsgDialogue( | ||
| 3564 | 'Invalid port', | ||
| 3565 | 'error', | ||
| 3566 | '\'' . $port . '\' is an invalid port. Specify a value in the range' | ||
| 3567 | . ' 0-65535, or leave the box empty to use the default port.', | ||
| 3568 | 'ok', | ||
| 3569 | ); | ||
| 3570 | |||
| 3571 | return undef; | ||
| 3572 | } | ||
| 3573 | } | ||
| 3574 | |||
| 3575 | $char = $self->miniWorldObj->selectChar; # May be 'undef' | ||
| 3576 | |||
| 3577 | if ($char) { | ||
| 3578 | |||
| 3579 | $pass = $self->miniWorldObj->ivShow( | ||
| 3580 | 'passwordHash', | ||
| 3581 | $self->miniWorldObj->selectChar, | ||
| 3582 | ); | ||
| 3583 | |||
| 3584 | $account = $self->miniWorldObj->ivShow( | ||
| 3585 | 'accountHash', | ||
| 3586 | $self->miniWorldObj->selectChar, | ||
| 3587 | ); | ||
| 3588 | } | ||
| 3589 | |||
| 3590 | # If the user selected no auto-login, reset the password/account name (the GA::Session | ||
| 3591 | # won't attempt an auto-login, without knowing the password) | ||
| 3592 | if ($self->miniWorldObj->noAutoLoginFlag) { | ||
| 3593 | |||
| 3594 | $pass = undef; | ||
| 3595 | $account = undef; | ||
| 3596 | } | ||
| 3597 | } | ||
| 3598 | |||
| 3599 | # Now we can connect to the world. Close this window, so it doesn't get in the way | ||
| 3600 | $self->winDestroy(); | ||
| 3601 | |||
| 3602 | # Start the session | ||
| 3603 | if ( | ||
| 3604 | ! $axmud::CLIENT->startSession( | ||
| 3605 | $worldName, | ||
| 3606 | $host, | ||
| 3607 | $port, | ||
| 3608 | $char, | ||
| 3609 | $pass, | ||
| 3610 | $account, | ||
| 3611 | $protocol, # If 'undef', default protocol used | ||
| 3612 | undef, # No login mode | ||
| 3613 | $offlineFlag, | ||
| 3614 | $tempFlag, | ||
| 3615 | ) | ||
| 3616 | ) { | ||
| 3617 | # Display a confirmation | ||
| 3618 | $axmud::CLIENT->mainWin->showMsgDialogue( | ||
| 3619 | 'Failed connection', | ||
| 3620 | 'error', | ||
| 3621 | 'General error while connecting to \'' . $worldName . '\'', | ||
| 3622 | 'ok', | ||
| 3623 | ); | ||
| 3624 | |||
| 3625 | return undef; | ||
| 3626 | |||
| 3627 | } else { | ||
| 3628 | |||
| 3629 | # This GA::OtherWin::Connect is now finished | ||
| 3630 | return 1; | ||
| 3631 | } | ||
| 3632 | } | ||
| 3633 | |||
| 3634 | sub testModeCallback { | ||
| 3635 | |||
| 3636 | # Function used for Axmud development | ||
| 3637 | # $self->createGridWidgets creates a button that's only visible if the user has edited the | ||
| 3638 | # contents of /scripts/axmud.pl or /scripts/baxmud.pl, in order to modify the global | ||
| 3639 | # variable @TEST_MODE_LOGIN_LIST | ||
| 3640 | # The button, if visible and if clicked, calls this function, which uses the contents of | ||
| 3641 | # the global variable to set the visible world, address, port, character and password, as | ||
| 3642 | # if the user had entered those values manually | ||
| 3643 | # | ||
| 3644 | # Expected arguments | ||
| 3645 | # $testButton - The Gtk3::Button that was clicked | ||
| 3646 | # | ||
| 3647 | # Return values | ||
| 3648 | # 'undef' on improper arguments or if there is an error | ||
| 3649 | # 1 otherwise | ||
| 3650 | |||
| 3651 | my ($self, $testButton, $check) = @_; | ||
| 3652 | |||
| 3653 | # Local variables | ||
| 3654 | my ( | ||
| 3655 | $worldObj, | ||
| 3656 | @testList, @charList, | ||
| 3657 | ); | ||
| 3658 | |||
| 3659 | # Check for improper arguments | ||
| 3660 | if (! defined $testButton || defined $check) { | ||
| 3661 | |||
| 3662 | return $axmud::CLIENT->writeImproper($self->_objClass . '->testModeCallback', @_); | ||
| 3663 | } | ||
| 3664 | |||
| 3665 | # Import the global variable (for convenience) | ||
| 3666 | @testList = @axmud::TEST_MODE_LOGIN_LIST; | ||
| 3667 | |||
| 3668 | # If the global variable refers to a world, for which a world profile already exists, | ||
| 3669 | # update grid widgets as if the user had entered the global variable's value manually | ||
| 3670 | if (defined $testList[0]) { | ||
| 3671 | |||
| 3672 | $worldObj = $axmud::CLIENT->ivShow('worldProfHash', $testList[0]); | ||
| 3673 | if ($worldObj) { | ||
| 3674 | |||
| 3675 | # Update grid widgets for this world, unless that world is already the visible one | ||
| 3676 | if (! $self->worldObj || $worldObj ne $self->worldObj) { | ||
| 3677 | |||
| 3678 | $self->updateGridWidgets($worldObj, $worldObj->longName); | ||
| 3679 | } | ||
| 3680 | |||
| 3681 | # Update grid widgets again, using the values stored in @TEST_MODE_LOGIN_LIST | ||
| 3682 | |||
| 3683 | # World DNS/IP address | ||
| 3684 | if (defined $testList[1]) { | ||
| 3685 | |||
| 3686 | $self->entry2->set_text($testList[1]); | ||
| 3687 | } | ||
| 3688 | |||
| 3689 | # World port | ||
| 3690 | if (defined $testList[2]) { | ||
| 3691 | |||
| 3692 | $self->entry3->set_text($testList[2]); | ||
| 3693 | } | ||
| 3694 | |||
| 3695 | # Character name and password | ||
| 3696 | if (defined $testList[3] && defined $testList[4]) { | ||
| 3697 | |||
| 3698 | $self->miniWorldObj->ivAdd('passwordHash', $testList[3], $testList[4]); | ||
| 3699 | $self->miniWorldObj->ivAdd('newPasswordHash', $testList[3], $testList[4]); | ||
| 3700 | |||
| 3701 | $self->miniWorldObj->ivPoke('selectChar', $testList[3]); | ||
| 3702 | |||
| 3703 | # Redraw the combobox | ||
| 3704 | @charList | ||
| 3705 | = sort {lc($a) cmp lc($b)} ($self->miniWorldObj->ivKeys('passwordHash')); | ||
| 3706 | |||
| 3707 | my $comboBox = $self->resetComboBox(TRUE, @charList); | ||
| 3708 | $self->ivPoke('comboBox', $comboBox); | ||
| 3709 | } | ||
| 3710 | |||
| 3711 | # Mark the number of connections to be set to at least 1 | ||
| 3712 | $self->miniWorldObj->ivPoke('testModeFlag', TRUE); | ||
| 3713 | } | ||
| 3714 | } | ||
| 3715 | |||
| 3716 | return 1; | ||
| 3717 | } | ||
| 3718 | |||
| 3719 | ################## | ||
| 3720 | # Accessors - set | ||
| 3721 | |||
| 3722 | sub set_consoleButton { | ||
| 3723 | |||
| 3724 | my ($self, $flag, $check) = @_; | ||
| 3725 | |||
| 3726 | # Check for improper arguments | ||
| 3727 | if (defined $check) { | ||
| 3728 | |||
| 3729 | return $axmud::CLIENT->writeImproper($self->_objClass . '->set_consoleButton', @_); | ||
| 3730 | } | ||
| 3731 | |||
| 3732 | if (! $flag) { | ||
| 3733 | |||
| 3734 | # No system messages to display in the Client Console window | ||
| 3735 | $self->consoleButton->set_image( | ||
| 3736 | Gtk3::Image->new_from_file($axmud::SHARE_DIR . '/icons/connect/icon_console.png'), | ||
| 3737 | ); | ||
| 3738 | |||
| 3739 | } else { | ||
| 3740 | |||
| 3741 | # At least one system message to display in the Client Console window | ||
| 3742 | $self->consoleButton->set_image( | ||
| 3743 | Gtk3::Image->new_from_file( | ||
| 3744 | $axmud::SHARE_DIR . '/icons/connect/icon_console_alert.png', | ||
| 3745 | ), | ||
| 3746 | ); | ||
| 3747 | } | ||
| 3748 | |||
| 3749 | return 1; | ||
| 3750 | } | ||
| 3751 | |||
| 3752 | ################## | ||
| 3753 | # Accessors - get | ||
| 3754 | |||
| 3755 | sub hPaned | ||
| 3756 | { $_[0]->{hPaned} } | ||
| 3757 | sub vBox | ||
| 3758 | { $_[0]->{vBox} } | ||
| 3759 | sub frame | ||
| 3760 | { $_[0]->{frame} } | ||
| 3761 | sub image | ||
| 3762 | { $_[0]->{image} } | ||
| 3763 | sub hBox | ||
| 3764 | { $_[0]->{hBox} } | ||
| 3765 | sub objModel | ||
| 3766 | { $_[0]->{objModel} } | ||
| 3767 | sub treeView | ||
| 3768 | { $_[0]->{treeView} } | ||
| 3769 | sub treeViewColumn | ||
| 3770 | { $_[0]->{treeViewColumn} } | ||
| 3771 | sub frame2 | ||
| 3772 | { $_[0]->{frame2} } | ||
| 3773 | sub scroller | ||
| 3774 | { $_[0]->{scroller} } | ||
| 3775 | sub frame3 | ||
| 3776 | { $_[0]->{frame3} } | ||
| 3777 | sub scroller2 | ||
| 3778 | { $_[0]->{scroller2} } | ||
| 3779 | sub grid | ||
| 3780 | { $_[0]->{grid} } | ||
| 3781 | sub preConfigButton | ||
| 3782 | { $_[0]->{preConfigButton} } | ||
| 3783 | sub otherWorldButton | ||
| 3784 | { $_[0]->{otherWorldButton} } | ||
| 3785 | sub sortAzButton | ||
| 3786 | { $_[0]->{sortAzButton} } | ||
| 3787 | sub sortZaButton | ||
| 3788 | { $_[0]->{sortZaButton} } | ||
| 3789 | sub sortRandButton | ||
| 3790 | { $_[0]->{sortRandButton} } | ||
| 3791 | sub searchButton | ||
| 3792 | { $_[0]->{searchButton} } | ||
| 3793 | sub cancelSearchButton | ||
| 3794 | { $_[0]->{cancelSearchButton} } | ||
| 3795 | sub consoleButton | ||
| 3796 | { $_[0]->{consoleButton} } | ||
| 3797 | sub entry | ||
| 3798 | { $_[0]->{entry} } | ||
| 3799 | sub entry2 | ||
| 3800 | { $_[0]->{entry2} } | ||
| 3801 | sub entry3 | ||
| 3802 | { $_[0]->{entry3} } | ||
| 3803 | sub checkButton | ||
| 3804 | { $_[0]->{checkButton} } | ||
| 3805 | sub radioButton | ||
| 3806 | { $_[0]->{radioButton} } | ||
| 3807 | sub radioButton2 | ||
| 3808 | { $_[0]->{radioButton2} } | ||
| 3809 | sub radioButton3 | ||
| 3810 | { $_[0]->{radioButton3} } | ||
| 3811 | sub radioButton4 | ||
| 3812 | { $_[0]->{radioButton4} } | ||
| 3813 | sub comboBox | ||
| 3814 | { $_[0]->{comboBox} } | ||
| 3815 | sub addCharButton | ||
| 3816 | { $_[0]->{addCharButton} } | ||
| 3817 | sub editPwdButton | ||
| 3818 | { $_[0]->{editPwdButton} } | ||
| 3819 | sub editAccButton | ||
| 3820 | { $_[0]->{editAccButton} } | ||
| 3821 | sub websiteLabel | ||
| 3822 | { $_[0]->{websiteLabel} } | ||
| 3823 | sub connectionLabel | ||
| 3824 | { $_[0]->{connectionLabel} } | ||
| 3825 | sub descripTextView | ||
| 3826 | { $_[0]->{descripTextView} } | ||
| 3827 | sub descripBuffer | ||
| 3828 | { $_[0]->{descripBuffer} } | ||
| 3829 | sub createWorldButton | ||
| 3830 | { $_[0]->{createWorldButton} } | ||
| 3831 | sub resetWorldButton | ||
| 3832 | { $_[0]->{resetWorldButton} } | ||
| 3833 | sub offlineButton | ||
| 3834 | { $_[0]->{offlineButton} } | ||
| 3835 | sub connectButton | ||
| 3836 | { $_[0]->{connectButton} } | ||
| 3837 | |||
| 3838 | sub defaultIcon | ||
| 3839 | { $_[0]->{defaultIcon} } | ||
| 3840 | sub imageWidth | ||
| 3841 | { $_[0]->{imageWidth} } | ||
| 3842 | sub imageHeight | ||
| 3843 | { $_[0]->{imageHeight} } | ||
| 3844 | sub tableWidth | ||
| 3845 | { $_[0]->{tableWidth} } | ||
| 3846 | sub tableHeight | ||
| 3847 | { $_[0]->{tableHeight} } | ||
| 3848 | |||
| 3849 | sub worldHash | ||
| 3850 | { my $self = shift; return %{$self->{worldHash}}; } | ||
| 3851 | sub miniWorldHash | ||
| 3852 | { my $self = shift; return %{$self->{miniWorldHash}}; } | ||
| 3853 | sub worldObj | ||
| 3854 | { $_[0]->{worldObj} } | ||
| 3855 | sub miniWorldObj | ||
| 3856 | { $_[0]->{miniWorldObj} } | ||
| 3857 | sub updateFlag | ||
| 3858 | { $_[0]->{updateFlag} } | ||
| 3859 | |||
| 3860 | sub newWorldString | ||
| 3861 | { $_[0]->{newWorldString} } | ||
| 3862 | sub noCharString | ||
| 3863 | { $_[0]->{noCharString} } | ||
| 3864 | sub noWebsiteString | ||
| 3865 | { $_[0]->{noWebsiteString} } | ||
| 3866 | sub noConnectString | ||
| 3867 | { $_[0]->{noConnectString} } | ||
| 3868 | |||
| 3869 | sub searchRegex | ||
| 3870 | { $_[0]->{searchRegex} } | ||
| 3871 | sub searchLanguage | ||
| 3872 | { $_[0]->{searchLanguage} } | ||
| 3873 | } | ||
| 3874 | |||
| 3875 | { package Games::Axmud::OtherWin::ClientConsole; | ||
| 3876 | |||
| 3877 | use strict; | ||
| 3878 | use warnings; | ||
| 3879 | use diagnostics; | ||
| 3880 | |||
| 3881 | use Glib qw(TRUE FALSE); | ||
| 3882 | |||
| 3883 | our @ISA = qw( | ||
| 3884 | Games::Axmud::Generic::OtherWin Games::Axmud::Generic::FreeWin Games::Axmud::Generic::Win | ||
| 3885 | Games::Axmud | ||
| 3886 | ); | ||
| 3887 | |||
| 3888 | ################## | ||
| 3889 | # Constructors | ||
| 3890 | |||
| 3891 | sub new { | ||
| 3892 | |||
| 3893 | # Called by GA::Generic::Win->createFreeWin | ||
| 3894 | # Creates a new instance of the Client Console window, which can display system messages | ||
| 3895 | # when there is no session running | ||
| 3896 | # | ||
| 3897 | # Expected arguments | ||
| 3898 | # $number - Unique number for this window object | ||
| 3899 | # $workspaceObj - The GA::Obj::Workspace handling the workspace in which this window | ||
| 3900 | # should be created | ||
| 3901 | # $owner - The owner; a 'grid' window object (but not an 'external' window) or a | ||
| 3902 | # 'free' window object. When this window opens/closes, the owner is | ||
| 3903 | # informed via calls to its ->add_childFreeWin / ->del_childFreeWin | ||
| 3904 | # functions | ||
| 3905 | # | ||
| 3906 | # Optional arguments | ||
| 3907 | # $session - The GA::Session from which this function was called. 'undef' if the | ||
| 3908 | # calling function didn't specify a session and $owner's ->session IV | ||
| 3909 | # is also 'undef' | ||
| 3910 | # $title - Ignored if set (all 'other' windows define their own title) | ||
| 3911 | # $editObj - Ignored if set | ||
| 3912 | # $tempFlag - Ignored if set | ||
| 3913 | # %configHash - Hash containing any number of key-value pairs needed for this | ||
| 3914 | # particular 'other' window; set to an empty hash if not required | ||
| 3915 | # - This type of window object recognises these initialisation settings: | ||
| 3916 | # | ||
| 3917 | # ... | ||
| 3918 | # | ||
| 3919 | # Return values | ||
| 3920 | # 'undef' on improper arguments | ||
| 3921 | # Blessed reference to the newly-created object on success | ||
| 3922 | |||
| 3923 | my ( | ||
| 3924 | $class, $number, $workspaceObj, $owner, $session, $title, $editObj, $tempFlag, | ||
| 3925 | %configHash, | ||
| 3926 | ) = @_; | ||
| 3927 | |||
| 3928 | # Check for improper arguments | ||
| 3929 | if (! defined $class || ! defined $number || ! defined $workspaceObj || ! defined $owner) { | ||
| 3930 | |||
| 3931 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 3932 | } | ||
| 3933 | |||
| 3934 | # Only one Client Console window can be open at a time | ||
| 3935 | if ($axmud::CLIENT->consoleWin) { | ||
| 3936 | |||
| 3937 | $axmud::CLIENT->consoleWin->restoreFocus(); | ||
| 3938 | return undef; | ||
| 3939 | } | ||
| 3940 | |||
| 3941 | # Setup | ||
| 3942 | my $self = { | ||
| 3943 | _objName => 'other_win_' . $number, | ||
| 3944 | _objClass => $class, | ||
| 3945 | _parentFile => undef, # No parent file object | ||
| 3946 | _parentWorld => undef, # No parent file object | ||
| 3947 | _privFlag => TRUE, # All IVs are private | ||
| 3948 | |||
| 3949 | # Standard window object IVs | ||
| 3950 | # -------------------------- | ||
| 3951 | |||
| 3952 | # Unique number for this window object | ||
| 3953 | number => $number, | ||
| 3954 | # The window category - 'grid' or 'free' | ||
| 3955 | winCategory => 'free', | ||
| 3956 | # The window type, any of the keys in GA::Client->constFreeWinTypeHash | ||
| 3957 | winType => 'other', | ||
| 3958 | # A name for the window (for some 'free' windows, the same as the window type) | ||
| 3959 | winName => 'console', | ||
| 3960 | # The GA::Obj::Workspace object for the workspace in which this window is created | ||
| 3961 | workspaceObj => $workspaceObj, | ||
| 3962 | # The owner; a 'grid' window object (but not an 'external' window) or a 'free' window | ||
| 3963 | # object. When this window opens/closes, the owner is informed via calls to its | ||
| 3964 | # ->add_childFreeWin / ->del_childFreeWin functions | ||
| 3965 | owner => $owner, | ||
| 3966 | # The GA::Session from which this function was called. 'undef' if the calling function | ||
| 3967 | # didn't specify a session and $owner's ->session IV is also 'undef' | ||
| 3968 | session => $session, | ||
| 3969 | # When GA::Session->pseudoCmd is called to execute a client command, the mode in which | ||
| 3970 | # it should be called (usually 'win_error' or 'win_only', which causes errors to be | ||
| 3971 | # displayed in a 'dialogue' window) | ||
| 3972 | pseudoCmdMode => 'win_error', | ||
| 3973 | |||
| 3974 | # The window widget. For most window objects, the Gtk3::Window. For pseudo-windows, the | ||
| 3975 | # parent 'main' window's Gtk3::Window | ||
| 3976 | # The code should use this IV when it wants to do something to the window itself | ||
| 3977 | # (minimise it, make it active, etc) | ||
| 3978 | winWidget => undef, | ||
| 3979 | # The window container. For most window objects, the Gtk3::Window. For pseudo-windows, | ||
| 3980 | # the parent GA::Table::PseudoWin table object | ||
| 3981 | # The code should use this IV when it wants to add, modify or remove widgets inside the | ||
| 3982 | # window itself | ||
| 3983 | winBox => undef, | ||
| 3984 | # Flag set to TRUE if the window actually exists (after a call to $self->winEnable), | ||
| 3985 | # FALSE if not | ||
| 3986 | enabledFlag => FALSE, | ||
| 3987 | # Flag set to TRUE if the Gtk3 window itself is visible (after a call to | ||
| 3988 | # $self->setVisible), FALSE if it is not visible (after a call to $self->setInvisible) | ||
| 3989 | visibleFlag => TRUE, | ||
| 3990 | # Registry hash of 'free' windows (excluding 'dialogue' windows) for which this window | ||
| 3991 | # is the parent, a subset of GA::Obj::Desktop->freeWinHash. Hash in the form | ||
| 3992 | # $childFreeWinHash{unique_number} = blessed_reference_to_window_object | ||
| 3993 | childFreeWinHash => {}, | ||
| 3994 | |||
| 3995 | # The container widget into which all other widgets are packed (usually a Gtk3::VBox or | ||
| 3996 | # Gtk3::HBox, but any container widget can be used; takes up the whole window client | ||
| 3997 | # area) | ||
| 3998 | packingBox => undef, # Gtk3::VBox | ||
| 3999 | |||
| 4000 | # Standard IVs for 'free' windows | ||
| 4001 | |||
| 4002 | # The window's default size, in pixels | ||
| 4003 | widthPixels => 600, | ||
| 4004 | heightPixels => 300, | ||
| 4005 | # Default border/item spacing sizes used in the window, in pixels | ||
| 4006 | borderPixels => $axmud::CLIENT->constFreeBorderPixels, | ||
| 4007 | spacingPixels => $axmud::CLIENT->constFreeSpacingPixels, | ||
| 4008 | |||
| 4009 | # A string to use as the window title. If 'undef', a generic title is used | ||
| 4010 | title => $axmud::SCRIPT . ' client console', | ||
| 4011 | # Hash containing any number of key-value pairs needed for this particular 'config' | ||
| 4012 | # window; for example, for example, GA::PrefWin::TaskStart uses it to specify a task | ||
| 4013 | # name and type. Set to an empty hash if not required | ||
| 4014 | configHash => {%configHash}, | ||
| 4015 | |||
| 4016 | # IVs for this window | ||
| 4017 | textView => undef, # Gtk3::TextView | ||
| 4018 | buffer => undef, # Gtk3::TextBuffer | ||
| 4019 | }; | ||
| 4020 | |||
| 4021 | # Bless the object into existence | ||
| 4022 | bless $self, $class; | ||
| 4023 | |||
| 4024 | return $self; | ||
| 4025 | } | ||
| 4026 | |||
| 4027 | ################## | ||
| 4028 | # Methods | ||
| 4029 | |||
| 4030 | # Standard window object functions | ||
| 4031 | |||
| 4032 | # sub winSetup {} # Inherited from GA::Generic::FreeWin | ||
| 4033 | |||
| 4034 | sub winEnable { | ||
| 4035 | |||
| 4036 | # Called by GA::Generic::Win->createFreeWin, after the call to $self->winSetup | ||
| 4037 | # After the Gtk3::Window has been setup and moved into position, makes it visible | ||
| 4038 | # | ||
| 4039 | # Expected arguments | ||
| 4040 | # (none besides $self) | ||
| 4041 | # | ||
| 4042 | # Return values | ||
| 4043 | # 'undef' on improper arguments | ||
| 4044 | # 1 on success | ||
| 4045 | |||
| 4046 | my ($self, $check) = @_; | ||
| 4047 | |||
| 4048 | # Local variables | ||
| 4049 | my @list; | ||
| 4050 | |||
| 4051 | # Check for improper arguments | ||
| 4052 | if (defined $check) { | ||
| 4053 | |||
| 4054 | return $axmud::CLIENT->writeImproper($self->_objClass . '->winEnable', @_); | ||
| 4055 | } | ||
| 4056 | |||
| 4057 | # Make the window appear on the desktop | ||
| 4058 | $self->winShowAll($self->_objClass . '->winEnable'); | ||
| 4059 | $self->ivPoke('enabledFlag', TRUE); | ||
| 4060 | |||
| 4061 | # This type of window is unique (only one can be open at any time); inform the GA::Client | ||
| 4062 | # it has opened | ||
| 4063 | $axmud::CLIENT->set_consoleWin($self); | ||
| 4064 | |||
| 4065 | # If any system messages have been stored, we can display them now | ||
| 4066 | @list = $axmud::CLIENT->systemMsgList; | ||
| 4067 | if (@list) { | ||
| 4068 | |||
| 4069 | do { | ||
| 4070 | |||
| 4071 | my ($type, $msg); | ||
| 4072 | |||
| 4073 | $type = shift @list; | ||
| 4074 | $msg = shift @list; | ||
| 4075 | |||
| 4076 | $self->update($type, $msg); | ||
| 4077 | |||
| 4078 | } until (! @list); | ||
| 4079 | } | ||
| 4080 | |||
| 4081 | # Each system message is displayed here only once | ||
| 4082 | $axmud::CLIENT->reset_systemMsg(); | ||
| 4083 | |||
| 4084 | return 1; | ||
| 4085 | } | ||
| 4086 | |||
| 4087 | # sub winDesengage {} # Inherited from GA::Generic::FreeWin | ||
| 4088 | |||
| 4089 | sub winDestroy { | ||
| 4090 | |||
| 4091 | # Can be called by anything | ||
| 4092 | # Updates IVs | ||
| 4093 | # | ||
| 4094 | # Expected arguments | ||
| 4095 | # (none besides $self) | ||
| 4096 | # | ||
| 4097 | # Return values | ||
| 4098 | # 'undef' on improper arguments, if the window can't be destroyed or if it has already | ||
| 4099 | # been destroyed | ||
| 4100 | # 1 on success | ||
| 4101 | |||
| 4102 | my ($self, $check) = @_; | ||
| 4103 | |||
| 4104 | # Check for improper arguments | ||
| 4105 | if (defined $check) { | ||
| 4106 | |||
| 4107 | return $axmud::CLIENT->writeImproper($self->_objClass . '->winDestroy', @_); | ||
| 4108 | } | ||
| 4109 | |||
| 4110 | if (! $self->winBox) { | ||
| 4111 | |||
| 4112 | # Window already destroyed in a previous call to this function | ||
| 4113 | return undef; | ||
| 4114 | } | ||
| 4115 | |||
| 4116 | # Close any 'free' windows for which this window is a parent | ||
| 4117 | foreach my $winObj ($self->ivValues('childFreeWinHash')) { | ||
| 4118 | |||
| 4119 | $winObj->winDestroy(); | ||
| 4120 | } | ||
| 4121 | |||
| 4122 | # Destroy the Gtk3::Window | ||
| 4123 | eval { $self->winBox->destroy(); }; | ||
| 4124 | if ($@) { | ||
| 4125 | |||
| 4126 | # Window can't be destroyed | ||
| 4127 | return undef; | ||
| 4128 | |||
| 4129 | } else { | ||
| 4130 | |||
| 4131 | $self->ivUndef('winWidget'); | ||
| 4132 | $self->ivUndef('winBox'); | ||
| 4133 | } | ||
| 4134 | |||
| 4135 | # Inform the owner and the desktop object of this 'free' window's demise | ||
| 4136 | $axmud::CLIENT->desktopObj->del_freeWin($self); | ||
| 4137 | if ($self->owner) { | ||
| 4138 | |||
| 4139 | $self->owner->del_childFreeWin($self); | ||
| 4140 | } | ||
| 4141 | |||
| 4142 | # This type of window is unique (only one can be open at any time); inform the GA::Client | ||
| 4143 | # it has closed | ||
| 4144 | $axmud::CLIENT->set_consoleWin(); | ||
| 4145 | |||
| 4146 | return 1; | ||
| 4147 | } | ||
| 4148 | |||
| 4149 | # sub winShowAll {} # Inherited from GA::Generic::Win | ||
| 4150 | |||
| 4151 | sub drawWidgets { | ||
| 4152 | |||
| 4153 | # Called by $self->winSetup | ||
| 4154 | # Sets up the Client Console window with its standard widgets | ||
| 4155 | # | ||
| 4156 | # Expected arguments | ||
| 4157 | # (none besides $self) | ||
| 4158 | # | ||
| 4159 | # Return values | ||
| 4160 | # 'undef' on improper arguments | ||
| 4161 | # 1 otherwise | ||
| 4162 | |||
| 4163 | my ($self, $check) = @_; | ||
| 4164 | |||
| 4165 | # Check for improper arguments | ||
| 4166 | if (defined $check) { | ||
| 4167 | |||
| 4168 | return $axmud::CLIENT->writeImproper($self->_objClass . '->drawWidgets', @_); | ||
| 4169 | } | ||
| 4170 | |||
| 4171 | # Create a packing box | ||
| 4172 | my $packingBox = Gtk3::VBox->new(FALSE, 0); | ||
| 4173 | $self->winBox->add($packingBox); | ||
| 4174 | $packingBox->set_border_width(0); | ||
| 4175 | |||
| 4176 | # Create a textview | ||
| 4177 | my $scroller = Gtk3::ScrolledWindow->new(undef, undef); | ||
| 4178 | $packingBox->pack_start($scroller, TRUE, TRUE, 0); | ||
| 4179 | $scroller->set_shadow_type($axmud::CLIENT->constShadowType); | ||
| 4180 | $scroller->set_policy('automatic', 'automatic'); | ||
| 4181 | $scroller->set_border_width(5); | ||
| 4182 | |||
| 4183 | # Use a textview with default colours/fonts | ||
| 4184 | my $textView = Gtk3::TextView->new(); | ||
| 4185 | $scroller->add($textView); | ||
| 4186 | my $buffer = Gtk3::TextBuffer->new(); | ||
| 4187 | $textView->set_buffer($buffer); | ||
| 4188 | $textView->set_editable(FALSE); | ||
| 4189 | $textView->set_cursor_visible(FALSE); | ||
| 4190 | $textView->set_can_focus(FALSE); | ||
| 4191 | $textView->set_wrap_mode('word-char'); # Wrap words if possible, characters if not | ||
| 4192 | $axmud::CLIENT->desktopObj->setTextViewStyle('main', $textView); | ||
| 4193 | |||
| 4194 | # Create a mark at the end of the buffer, with right gravity, so that whenever text is | ||
| 4195 | # inserted, we can scroll to that mark (and the mark stays at the end) | ||
| 4196 | my $endMark = $buffer->create_mark('end', $buffer->get_end_iter(), FALSE); | ||
| 4197 | |||
| 4198 | # Update IVs | ||
| 4199 | $self->ivPoke('packingBox', $packingBox); | ||
| 4200 | $self->ivPoke('textView', $textView); | ||
| 4201 | $self->ivPoke('buffer', $buffer); | ||
| 4202 | |||
| 4203 | # Create some colour tags, so that system messages can be displayed in their usual colours | ||
| 4204 | $self->createColourTags(); | ||
| 4205 | |||
| 4206 | return 1; | ||
| 4207 | } | ||
| 4208 | |||
| 4209 | # sub redrawWidgets {} # Inherited from GA::Generic::Win | ||
| 4210 | |||
| 4211 | # ->signal_connects | ||
| 4212 | |||
| 4213 | # Other functions | ||
| 4214 | |||
| 4215 | sub createColourTags { | ||
| 4216 | |||
| 4217 | # Called by $self->drawWidgets | ||
| 4218 | # Create some Gtk3::TextTags, so that system messages can be shown in their usual colours | ||
| 4219 | # | ||
| 4220 | # Expected arguments | ||
| 4221 | # (none besides $self) | ||
| 4222 | # | ||
| 4223 | # Return values | ||
| 4224 | # 'undef' on improper arguments | ||
| 4225 | # 1 otherwise | ||
| 4226 | |||
| 4227 | my ($self, $check) = @_; | ||
| 4228 | |||
| 4229 | # Check for improper arguments | ||
| 4230 | if (defined $check) { | ||
| 4231 | |||
| 4232 | return $axmud::CLIENT->writeImproper($self->_objClass . '->update', @_); | ||
| 4233 | } | ||
| 4234 | |||
| 4235 | $self->buffer->create_tag( | ||
| 4236 | 'system', | ||
| 4237 | 'foreground' | ||
| 4238 | => $axmud::CLIENT->returnRGBColour($axmud::CLIENT->customShowSystemTextColour), | ||
| 4239 | ); | ||
| 4240 | |||
| 4241 | $self->buffer->create_tag( | ||
| 4242 | 'error', | ||
| 4243 | 'foreground' | ||
| 4244 | => $axmud::CLIENT->returnRGBColour($axmud::CLIENT->customShowErrorColour), | ||
| 4245 | ); | ||
| 4246 | |||
| 4247 | $self->buffer->create_tag( | ||
| 4248 | 'warning', | ||
| 4249 | 'foreground' | ||
| 4250 | => $axmud::CLIENT->returnRGBColour($axmud::CLIENT->customShowWarningColour), | ||
| 4251 | ); | ||
| 4252 | |||
| 4253 | $self->buffer->create_tag( | ||
| 4254 | 'debug', | ||
| 4255 | 'foreground' | ||
| 4256 | => $axmud::CLIENT->returnRGBColour($axmud::CLIENT->customShowDebugColour), | ||
| 4257 | ); | ||
| 4258 | |||
| 4259 | $self->buffer->create_tag( | ||
| 4260 | 'improper', | ||
| 4261 | 'foreground' | ||
| 4262 | => $axmud::CLIENT->returnRGBColour($axmud::CLIENT->customShowImproperColour), | ||
| 4263 | ); | ||
| 4264 | |||
| 4265 | return 1; | ||
| 4266 | } | ||
| 4267 | |||
| 4268 | sub update { | ||
| 4269 | |||
| 4270 | # Called by $self->winEnable and $axmud::CLIENT->add_systemMsg | ||
| 4271 | # Adds a system message to the window's textview | ||
| 4272 | # | ||
| 4273 | # Expected arguments | ||
| 4274 | # $type - The type of message (which determines the colour in which it's displayed) - | ||
| 4275 | # 'system', 'error', 'warning', 'debug' or 'improper'. If an invalid value or | ||
| 4276 | # 'undef', then the error message colour is used | ||
| 4277 | # $msg - The message to display. If 'undef' (for some reason), nothing is displayed | ||
| 4278 | # | ||
| 4279 | # Return values | ||
| 4280 | # 'undef' on improper arguments | ||
| 4281 | # 1 otherwise | ||
| 4282 | |||
| 4283 | my ($self, $type, $msg, $check) = @_; | ||
| 4284 | |||
| 4285 | # Check for improper arguments | ||
| 4286 | if (defined $check) { | ||
| 4287 | |||
| 4288 | return $axmud::CLIENT->writeImproper($self->_objClass . '->update', @_); | ||
| 4289 | } | ||
| 4290 | |||
| 4291 | if ($self->enabledFlag && defined $msg) { | ||
| 4292 | |||
| 4293 | if ( | ||
| 4294 | ! defined $type | ||
| 4295 | || ( | ||
| 4296 | $type ne 'system' && $type ne 'error' && $type ne 'warning' && $type ne 'debug' | ||
| 4297 | && $type ne 'improper' | ||
| 4298 | ) | ||
| 4299 | ) { | ||
| 4300 | $type = 'error'; | ||
| 4301 | } | ||
| 4302 | |||
| 4303 | # Only one newline character at the end of the message | ||
| 4304 | chomp $msg; | ||
| 4305 | $self->buffer->insert_with_tags_by_name( | ||
| 4306 | $self->buffer->get_end_iter(), | ||
| 4307 | $msg . "\n", | ||
| 4308 | $type, | ||
| 4309 | ); | ||
| 4310 | |||
| 4311 | # Scroll to the bottom | ||
| 4312 | $self->textView->scroll_to_mark($self->buffer->get_mark('end'), 0.0, TRUE, 0, 0); | ||
| 4313 | |||
| 4314 | $self->winShowAll($self->_objClass . '->update'); | ||
| 4315 | } | ||
| 4316 | |||
| 4317 | return 1; | ||
| 4318 | } | ||
| 4319 | |||
| 4320 | ################## | ||
| 4321 | # Accessors - set | ||
| 4322 | |||
| 4323 | ################## | ||
| 4324 | # Accessors - get | ||
| 4325 | |||
| 4326 | sub textView | ||
| 4327 | { $_[0]->{textView} } | ||
| 4328 | sub buffer | ||
| 4329 | { $_[0]->{buffer} } | ||
| 4330 | } | ||
| 4331 | |||
| 4332 | { package Games::Axmud::OtherWin::LabelDelete; | ||
| 4333 | |||
| 4334 | use strict; | ||
| 4335 | use warnings; | ||
| 4336 | use diagnostics; | ||
| 4337 | |||
| 4338 | use Glib qw(TRUE FALSE); | ||
| 4339 | |||
| 4340 | our @ISA = qw( | ||
| 4341 | Games::Axmud::Generic::OtherWin Games::Axmud::Generic::FreeWin Games::Axmud::Generic::Win | ||
| 4342 | Games::Axmud | ||
| 4343 | ); | ||
| 4344 | |||
| 4345 | ################## | ||
| 4346 | # Constructors | ||
| 4347 | |||
| 4348 | sub new { | ||
| 4349 | |||
| 4350 | # Called by GA::Generic::Win->createFreeWin | ||
| 4351 | # Creates a new instance of the Label Deletion window (an 'other' window). The window | ||
| 4352 | # contains a simple list in which the user can select labels to delete | ||
| 4353 | # | ||
| 4354 | # Expected arguments | ||
| 4355 | # $number - Unique number for this window object | ||
| 4356 | # $workspaceObj - The GA::Obj::Workspace handling the workspace in which this window | ||
| 4357 | # should be created | ||
| 4358 | # $owner - The owner; a 'grid' window object (but not an 'external' window) or a | ||
| 4359 | # 'free' window object. When this window opens/closes, the owner is | ||
| 4360 | # informed via calls to its ->add_childFreeWin / ->del_childFreeWin | ||
| 4361 | # functions | ||
| 4362 | # | ||
| 4363 | # Optional arguments | ||
| 4364 | # $session - The GA::Session from which this function was called. 'undef' if the | ||
| 4365 | # calling function didn't specify a session and $owner's ->session IV | ||
| 4366 | # is also 'undef' | ||
| 4367 | # $title - Ignored if set (all 'other' windows define their own title) | ||
| 4368 | # $editObj - Ignored if set | ||
| 4369 | # $tempFlag - Ignored if set | ||
| 4370 | # %configHash - Hash containing any number of key-value pairs needed for this | ||
| 4371 | # particular 'other' window; set to an empty hash if not required | ||
| 4372 | # - This type of window object recognises these initialisation settings: | ||
| 4373 | # | ||
| 4374 | # ... | ||
| 4375 | # | ||
| 4376 | # Return values | ||
| 4377 | # 'undef' on improper arguments | ||
| 4378 | # Blessed reference to the newly-created object on success | ||
| 4379 | |||
| 4380 | my ( | ||
| 4381 | $class, $number, $workspaceObj, $owner, $session, $title, $editObj, $tempFlag, | ||
| 4382 | %configHash, | ||
| 4383 | ) = @_; | ||
| 4384 | |||
| 4385 | # Check for improper arguments | ||
| 4386 | if (! defined $class || ! defined $number || ! defined $workspaceObj || ! defined $owner) { | ||
| 4387 | |||
| 4388 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 4389 | } | ||
| 4390 | |||
| 4391 | # Setup | ||
| 4392 | my $self = { | ||
| 4393 | _objName => 'other_win_' . $number, | ||
| 4394 | _objClass => $class, | ||
| 4395 | _parentFile => undef, # No parent file object | ||
| 4396 | _parentWorld => undef, # No parent file object | ||
| 4397 | _privFlag => TRUE, # All IVs are private | ||
| 4398 | |||
| 4399 | # Standard window object IVs | ||
| 4400 | # -------------------------- | ||
| 4401 | |||
| 4402 | # Unique number for this window object | ||
| 4403 | number => $number, | ||
| 4404 | # The window category - 'grid' or 'free' | ||
| 4405 | winCategory => 'free', | ||
| 4406 | # The window type, any of the keys in GA::Client->constFreeWinTypeHash | ||
| 4407 | winType => 'other', | ||
| 4408 | # A name for the window (can be unique to this type of window object, or can be the | ||
| 4409 | # same as ->winType) | ||
| 4410 | winName => 'quick_label_delete', | ||
| 4411 | # The GA::Obj::Workspace object for the workspace in which this window is created | ||
| 4412 | workspaceObj => $workspaceObj, | ||
| 4413 | # The owner; a 'grid' window object (but not an 'external' window) or a 'free' window | ||
| 4414 | # object. When this window opens/closes, the owner is informed via calls to its | ||
| 4415 | # ->add_childFreeWin / ->del_childFreeWin functions | ||
| 4416 | owner => $owner, | ||
| 4417 | # The GA::Session from which this function was called. 'undef' if the calling function | ||
| 4418 | # didn't specify a session and $owner's ->session IV is also 'undef' | ||
| 4419 | session => $session, | ||
| 4420 | # When GA::Session->pseudoCmd is called to execute a client command, the mode in which | ||
| 4421 | # it should be called (usually 'win_error' or 'win_only', which causes errors to be | ||
| 4422 | # displayed in a 'dialogue' window) | ||
| 4423 | pseudoCmdMode => 'win_error', | ||
| 4424 | |||
| 4425 | # The window widget. For most window objects, the Gtk3::Window. For pseudo-windows, the | ||
| 4426 | # parent 'main' window's Gtk3::Window | ||
| 4427 | # The code should use this IV when it wants to do something to the window itself | ||
| 4428 | # (minimise it, make it active, etc) | ||
| 4429 | winWidget => undef, | ||
| 4430 | # The window container. For most window objects, the Gtk3::Window. For pseudo-windows, | ||
| 4431 | # the parent GA::Table::PseudoWin table object | ||
| 4432 | # The code should use this IV when it wants to add, modify or remove widgets inside the | ||
| 4433 | # window itself | ||
| 4434 | winBox => undef, | ||
| 4435 | # Flag set to TRUE if the window actually exists (after a call to $self->winEnable), | ||
| 4436 | # FALSE if not | ||
| 4437 | enabledFlag => FALSE, | ||
| 4438 | # Flag set to TRUE if the Gtk3 window itself is visible (after a call to | ||
| 4439 | # $self->setVisible), FALSE if it is not visible (after a call to $self->setInvisible) | ||
| 4440 | visibleFlag => TRUE, | ||
| 4441 | # Registry hash of 'free' windows (excluding 'dialogue' windows) for which this window | ||
| 4442 | # is the parent, a subset of GA::Obj::Desktop->freeWinHash. Hash in the form | ||
| 4443 | # $childFreeWinHash{unique_number} = blessed_reference_to_window_object | ||
| 4444 | childFreeWinHash => {}, | ||
| 4445 | # When a child 'free' window (excluding 'dialogue' windows) is destroyed, this parent | ||
| 4446 | # window is informed via a call to $self->del_childFreeWin | ||
| 4447 | # When the child is destroyed, this window might want to call some of its own functions | ||
| 4448 | # to update various widgets and/or IVs, in which case this window adds an entry to | ||
| 4449 | # this hash; a hash in the form | ||
| 4450 | # $childDestroyHash{unique_number} = list_reference | ||
| 4451 | # ...where 'unique_number' is the child window's ->number, and 'list_reference' is a | ||
| 4452 | # reference to a list in groups of 2, in the form | ||
| 4453 | # (sub_name, argument_list_ref, sub_name, argument_list_ref...) | ||
| 4454 | childDestroyHash => {}, | ||
| 4455 | |||
| 4456 | # The container widget into which all other widgets are packed (usually a Gtk3::VBox or | ||
| 4457 | # Gtk3::HBox, but any container widget can be used; takes up the whole window client | ||
| 4458 | # area) | ||
| 4459 | packingBox => undef, | ||
| 4460 | |||
| 4461 | # Standard IVs for 'free' windows | ||
| 4462 | |||
| 4463 | # The window's default size, in pixels | ||
| 4464 | widthPixels => $axmud::CLIENT->constFreeWinWidth, | ||
| 4465 | heightPixels => $axmud::CLIENT->constFreeWinHeight, | ||
| 4466 | # Default border/item spacing sizes used in the window, in pixels | ||
| 4467 | borderPixels => $axmud::CLIENT->constFreeBorderPixels, | ||
| 4468 | spacingPixels => $axmud::CLIENT->constFreeSpacingPixels, | ||
| 4469 | |||
| 4470 | # A string to use as the window title | ||
| 4471 | title => 'Label deletion window', | ||
| 4472 | # Hash containing any number of key-value pairs needed for this particular 'config' | ||
| 4473 | # window; for example, for example, GA::PrefWin::TaskStart uses it to specify a task | ||
| 4474 | # name and type. Set to an empty hash if not required | ||
| 4475 | configHash => {%configHash}, | ||
| 4476 | |||
| 4477 | # IVs for this type of window | ||
| 4478 | # ... | ||
| 4479 | }; | ||
| 4480 | |||
| 4481 | # Bless the object into existence | ||
| 4482 | bless $self, $class; | ||
| 4483 | |||
| 4484 | return $self; | ||
| 4485 | } | ||
| 4486 | |||
| 4487 | ################## | ||
| 4488 | # Methods | ||
| 4489 | |||
| 4490 | # Standard window object functions | ||
| 4491 | |||
| 4492 | # sub winSetup {} # Inherited from GA::Generic::FreeWin | ||
| 4493 | |||
| 4494 | # sub winEnable {} # Inherited from GA::Generic::FreeWin | ||
| 4495 | |||
| 4496 | # sub winDesengage {} # Inherited from GA::Generic::FreeWin | ||
| 4497 | |||
| 4498 | # sub winDestroy {} # Inherited from GA::Generic::FreeWin | ||
| 4499 | |||
| 4500 | # sub winShowAll {} # Inherited from GA::Generic::Win | ||
| 4501 | |||
| 4502 | sub drawWidgets { | ||
| 4503 | |||
| 4504 | # Called by $self->winSetup | ||
| 4505 | # Sets up the Gtk3::Window by drawing the window's widgets | ||
| 4506 | # | ||
| 4507 | # Expected arguments | ||
| 4508 | # (none besides $self) | ||
| 4509 | # | ||
| 4510 | # Return values | ||
| 4511 | # 'undef' on improper arguments | ||
| 4512 | # 1 otherwise | ||
| 4513 | |||
| 4514 | my ($self, $check) = @_; | ||
| 4515 | |||
| 4516 | # Local variables | ||
| 4517 | my @columnList; | ||
| 4518 | |||
| 4519 | # Check for improper arguments | ||
| 4520 | if (defined $check) { | ||
| 4521 | |||
| 4522 | return $axmud::CLIENT->writeImproper($self->_objClass . '->drawWidgets', @_); | ||
| 4523 | } | ||
| 4524 | |||
| 4525 | # Create a packing box | ||
| 4526 | my $packingBox = Gtk3::VBox->new(FALSE, 0); | ||
| 4527 | $self->winBox->add($packingBox); | ||
| 4528 | $packingBox->set_border_width(0); | ||
| 4529 | |||
| 4530 | # Update IVs immediately, for the benefit of any called functions | ||
| 4531 | $self->ivPoke('packingBox', $packingBox); | ||
| 4532 | |||
| 4533 | # Create an image on the left | ||
| 4534 | my $hBox = Gtk3::HBox->new(FALSE, 0); | ||
| 4535 | $packingBox->pack_start($hBox, TRUE, TRUE, 0); | ||
| 4536 | |||
| 4537 | my $vBox = Gtk3::VBox->new(FALSE, 0); | ||
| 4538 | $hBox->pack_start($vBox, FALSE, FALSE, 0); | ||
| 4539 | |||
| 4540 | my $frame = Gtk3::Frame->new(undef); | ||
| 4541 | $vBox->pack_start($frame, FALSE, FALSE, 0); | ||
| 4542 | $frame->set_size_request(64, 64); | ||
| 4543 | $frame->set_shadow_type($axmud::CLIENT->constShadowType); | ||
| 4544 | |||
| 4545 | my $image = Gtk3::Image->new_from_file($axmud::CLIENT->getDialogueIcon()); | ||
| 4546 | $frame->add($image); | ||
| 4547 | |||
| 4548 | # Add a simple list and some buttons on the right | ||
| 4549 | my $vBox2 = Gtk3::VBox->new(FALSE, 0); | ||
| 4550 | $hBox->pack_start($vBox2, TRUE, TRUE, $self->spacingPixels); | ||
| 4551 | |||
| 4552 | @columnList = ( | ||
| 4553 | 'Delete', 'bool', | ||
| 4554 | 'Region', 'text', | ||
| 4555 | '#', 'int', | ||
| 4556 | 'Label', 'text', | ||
| 4557 | ); | ||
| 4558 | |||
| 4559 | my $frame2 = Gtk3::Frame->new(undef); | ||
| 4560 | $vBox2->pack_start($frame2, TRUE, TRUE, 0); | ||
| 4561 | $frame2->set_border_width(0); | ||
| 4562 | |||
| 4563 | my $scroller = Gtk3::ScrolledWindow->new(); | ||
| 4564 | $frame2->add($scroller); | ||
| 4565 | $scroller->set_shadow_type('none'); | ||
| 4566 | $scroller->set_policy('automatic', 'automatic'); | ||
| 4567 | $scroller->set_border_width(0); | ||
| 4568 | |||
| 4569 | my $slWidget = Games::Axmud::Obj::SimpleList->new(@columnList); | ||
| 4570 | $scroller->add($slWidget); | ||
| 4571 | |||
| 4572 | # Add a horizontal strip with several buttons | ||
| 4573 | # Create an image on the left | ||
| 4574 | my $hBox2 = Gtk3::HBox->new(FALSE, 0); | ||
| 4575 | $vBox2->pack_start($hBox2, FALSE, FALSE, $self->spacingPixels); | ||
| 4576 | |||
| 4577 | my $button = Gtk3::Button->new('Select all'); | ||
| 4578 | $hBox2->pack_start($button, FALSE, FALSE, 0); | ||
| 4579 | $button->get_child->set_width_chars(12); | ||
| 4580 | $button->signal_connect('clicked' => sub { | ||
| 4581 | |||
| 4582 | foreach my $listRef (@{$slWidget->{data}}) { | ||
| 4583 | |||
| 4584 | $$listRef[0] = TRUE; | ||
| 4585 | } | ||
| 4586 | }); | ||
| 4587 | |||
| 4588 | my $button2 = Gtk3::Button->new('Select none'); | ||
| 4589 | $hBox2->pack_start($button2, FALSE, FALSE, $self->borderPixels); | ||
| 4590 | $button2->get_child->set_width_chars(12); | ||
| 4591 | $button2->signal_connect('clicked' => sub { | ||
| 4592 | |||
| 4593 | foreach my $listRef (@{$slWidget->{data}}) { | ||
| 4594 | |||
| 4595 | $$listRef[0] = FALSE; | ||
| 4596 | } | ||
| 4597 | }); | ||
| 4598 | |||
| 4599 | my $button3 = Gtk3::Button->new('Close window'); | ||
| 4600 | $hBox2->pack_end($button3, FALSE, FALSE, 0); | ||
| 4601 | $button3->get_child->set_width_chars(12); | ||
| 4602 | $button3->signal_connect('clicked' => sub { | ||
| 4603 | |||
| 4604 | $self->winDestroy(); | ||
| 4605 | }); | ||
| 4606 | |||
| 4607 | my $button4 = Gtk3::Button->new('Delete selected labels'); | ||
| 4608 | $hBox2->pack_end($button4, FALSE, FALSE, $self->borderPixels); | ||
| 4609 | $button4->get_child->set_width_chars(20); | ||
| 4610 | $button4->signal_connect('clicked' => sub { | ||
| 4611 | |||
| 4612 | my ( | ||
| 4613 | @deleteList, | ||
| 4614 | %regionmapHash, | ||
| 4615 | ); | ||
| 4616 | |||
| 4617 | # Import the hash of regionmaps for quick lookup | ||
| 4618 | %regionmapHash = $self->session->worldModelObj->regionmapHash; | ||
| 4619 | |||
| 4620 | # Compile a list of labels to delete | ||
| 4621 | foreach my $listRef (@{$slWidget->{data}}) { | ||
| 4622 | |||
| 4623 | my ($deleteFlag, $regionName, $labelNum, $regionmapObj, $labelObj); | ||
| 4624 | |||
| 4625 | ($deleteFlag, $regionName, $labelNum) = @$listRef; | ||
| 4626 | $regionmapObj = $regionmapHash{$regionName}; | ||
| 4627 | |||
| 4628 | if ($deleteFlag && $regionmapObj) { | ||
| 4629 | |||
| 4630 | $labelObj = $regionmapObj->ivShow('gridLabelHash', $labelNum); | ||
| 4631 | if ($labelObj) { | ||
| 4632 | |||
| 4633 | push (@deleteList, $labelObj); | ||
| 4634 | } | ||
| 4635 | } | ||
| 4636 | } | ||
| 4637 | |||
| 4638 | # Delete the selected labels. The TRUE argument means to update automapper windows now | ||
| 4639 | $self->session->worldModelObj->deleteLabels(TRUE, @deleteList); | ||
| 4640 | |||
| 4641 | # Refresh the simple list | ||
| 4642 | $self->refreshList($slWidget); | ||
| 4643 | }); | ||
| 4644 | |||
| 4645 | # Popuplate the simple list | ||
| 4646 | $self->refreshList($slWidget); | ||
| 4647 | |||
| 4648 | return 1; | ||
| 4649 | } | ||
| 4650 | |||
| 4651 | # sub redrawWidgets {} # Inherited from GA::Generic::Win | ||
| 4652 | |||
| 4653 | # ->signal_connects | ||
| 4654 | |||
| 4655 | # Other functions | ||
| 4656 | |||
| 4657 | sub refreshList { | ||
| 4658 | |||
| 4659 | # Called by $self->drawWidgets | ||
| 4660 | # Populates the simple list widget | ||
| 4661 | # | ||
| 4662 | # Expected arguments | ||
| 4663 | # $slWidget - The GA::Obj::SimpleList widget to populate | ||
| 4664 | # | ||
| 4665 | # Return values | ||
| 4666 | # 'undef' on improper arguments | ||
| 4667 | # 1 otherwise | ||
| 4668 | |||
| 4669 | my ($self, $slWidget, $check) = @_; | ||
| 4670 | |||
| 4671 | # Local variables | ||
| 4672 | my @dataList; | ||
| 4673 | |||
| 4674 | # Check for improper arguments | ||
| 4675 | if (! defined $slWidget || defined $check) { | ||
| 4676 | |||
| 4677 | return $axmud::CLIENT->writeImproper($self->_objClass . '->refreshList', @_); | ||
| 4678 | } | ||
| 4679 | |||
| 4680 | foreach my $regionmapObj ( | ||
| 4681 | sort {lc($a->name) cmp lc($b->name)} | ||
| 4682 | ($self->session->worldModelObj->ivValues('regionmapHash')) | ||
| 4683 | ) { | ||
| 4684 | my (%localHash, %modHash); | ||
| 4685 | |||
| 4686 | # Import the hash for speed | ||
| 4687 | %localHash = $regionmapObj->gridLabelHash; | ||
| 4688 | # When sorting alphabetically, remove non-alphanumeric characters so that '(Shop)' | ||
| 4689 | # doesn't appear in the list before 'Shop' | ||
| 4690 | foreach my $labelObj (values %localHash) { | ||
| 4691 | |||
| 4692 | my $modText = $labelObj->name; | ||
| 4693 | $modText =~ s/[^[:word:]\s]//g; | ||
| 4694 | $modHash{$labelObj->number} = lc($modText); | ||
| 4695 | } | ||
| 4696 | |||
| 4697 | foreach my $labelObj ( | ||
| 4698 | sort {$modHash{$a->number} cmp $modHash{$b->number}} (values %localHash) | ||
| 4699 | ) { | ||
| 4700 | push (@dataList, | ||
| 4701 | [ | ||
| 4702 | FALSE, | ||
| 4703 | $regionmapObj->name, | ||
| 4704 | $labelObj->number, | ||
| 4705 | $labelObj->name, | ||
| 4706 | ], | ||
| 4707 | ); | ||
| 4708 | } | ||
| 4709 | } | ||
| 4710 | |||
| 4711 | # Reset the simple list | ||
| 4712 | if (! @dataList) { | ||
| 4713 | |||
| 4714 | # Replacement data list is empty | ||
| 4715 | @{$slWidget->{data}} = (); | ||
| 4716 | |||
| 4717 | } else { | ||
| 4718 | |||
| 4719 | @{$slWidget->{data}} = @dataList; | ||
| 4720 | } | ||
| 4721 | |||
| 4722 | return 1; | ||
| 4723 | } | ||
| 4724 | |||
| 4725 | ################## | ||
| 4726 | # Accessors - set | ||
| 4727 | |||
| 4728 | ################## | ||
| 4729 | # Accessors - get | ||
| 4730 | } | ||
| 4731 | |||
| 4732 | { package Games::Axmud::OtherWin::McpSimpleEdit; | ||
| 4733 | |||
| 4734 | use strict; | ||
| 4735 | use warnings; | ||
| 4736 | use diagnostics; | ||
| 4737 | |||
| 4738 | use Glib qw(TRUE FALSE); | ||
| 4739 | |||
| 4740 | our @ISA = qw( | ||
| 4741 | Games::Axmud::Generic::OtherWin Games::Axmud::Generic::FreeWin Games::Axmud::Generic::Win | ||
| 4742 | Games::Axmud | ||
| 4743 | ); | ||
| 4744 | |||
| 4745 | ################## | ||
| 4746 | # Constructors | ||
| 4747 | |||
| 4748 | sub new { | ||
| 4749 | |||
| 4750 | # Called by GA::Mcp::SimpleEdit->msg | ||
| 4751 | # Creates a new instance of the MCP Simple Edit window (an 'other' window). The window | ||
| 4752 | # contains a textview in which the user can type text, and some widgets that specify what | ||
| 4753 | # should be done with the text | ||
| 4754 | # | ||
| 4755 | # Expected arguments | ||
| 4756 | # $number - Unique number for this window object | ||
| 4757 | # $workspaceObj - The GA::Obj::Workspace handling the workspace in which this window | ||
| 4758 | # should be created | ||
| 4759 | # $owner - The owner; a 'grid' window object (but not an 'external' window) or a | ||
| 4760 | # 'free' window object. When this window opens/closes, the owner is | ||
| 4761 | # informed via calls to its ->add_childFreeWin / ->del_childFreeWin | ||
| 4762 | # functions | ||
| 4763 | # | ||
| 4764 | # Optional arguments | ||
| 4765 | # $session - The GA::Session from which this function was called. 'undef' if the | ||
| 4766 | # calling function didn't specify a session and $owner's ->session IV | ||
| 4767 | # is also 'undef' | ||
| 4768 | # $title - Ignored if set (all 'other' windows define their own title) | ||
| 4769 | # $editObj - Ignored if set | ||
| 4770 | # $tempFlag - Ignored if set | ||
| 4771 | # %configHash - Hash containing any number of key-value pairs needed for this | ||
| 4772 | # particular 'other' window; set to an empty hash if not required | ||
| 4773 | # - This type of window object recognises these initialisation settings: | ||
| 4774 | # | ||
| 4775 | # 'mcp_reference' - Supplied by the server's MCP message; a machine- | ||
| 4776 | # readable string that identifies the text to be sent back to the | ||
| 4777 | # server | ||
| 4778 | # 'mcp_name' - Supplied by the server's MCP message; a human-readable | ||
| 4779 | # string to show the user what text is being edited | ||
| 4780 | # 'mcp_content' - Supplied by the server's MCP message; the text to | ||
| 4781 | # edit; a string containing one or more lines joined with single | ||
| 4782 | # newline characters | ||
| 4783 | # 'mcp_type' - The type of text being edited - 'string-list' or | ||
| 4784 | # 'moo-code' for multiple lines (this window isn't called for | ||
| 4785 | # 'string') | ||
| 4786 | # | ||
| 4787 | # Return values | ||
| 4788 | # 'undef' on improper arguments | ||
| 4789 | # Blessed reference to the newly-created object on success | ||
| 4790 | |||
| 4791 | my ( | ||
| 4792 | $class, $number, $workspaceObj, $owner, $session, $title, $editObj, $tempFlag, | ||
| 4793 | %configHash, | ||
| 4794 | ) = @_; | ||
| 4795 | |||
| 4796 | # Check for improper arguments | ||
| 4797 | if (! defined $class || ! defined $number || ! defined $workspaceObj || ! defined $owner) { | ||
| 4798 | |||
| 4799 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 4800 | } | ||
| 4801 | |||
| 4802 | # Setup | ||
| 4803 | my $self = { | ||
| 4804 | _objName => 'other_win_' . $number, | ||
| 4805 | _objClass => $class, | ||
| 4806 | _parentFile => undef, # No parent file object | ||
| 4807 | _parentWorld => undef, # No parent file object | ||
| 4808 | _privFlag => TRUE, # All IVs are private | ||
| 4809 | |||
| 4810 | # Standard window object IVs | ||
| 4811 | # -------------------------- | ||
| 4812 | |||
| 4813 | # Unique number for this window object | ||
| 4814 | number => $number, | ||
| 4815 | # The window category - 'grid' or 'free' | ||
| 4816 | winCategory => 'free', | ||
| 4817 | # The window type, any of the keys in GA::Client->constFreeWinTypeHash | ||
| 4818 | winType => 'other', | ||
| 4819 | # A name for the window (can be unique to this type of window object, or can be the | ||
| 4820 | # same as ->winType) | ||
| 4821 | winName => 'mcp_simple_edit', | ||
| 4822 | # The GA::Obj::Workspace object for the workspace in which this window is created | ||
| 4823 | workspaceObj => $workspaceObj, | ||
| 4824 | # The owner; a 'grid' window object (but not an 'external' window) or a 'free' window | ||
| 4825 | # object. When this window opens/closes, the owner is informed via calls to its | ||
| 4826 | # ->add_childFreeWin / ->del_childFreeWin functions | ||
| 4827 | owner => $owner, | ||
| 4828 | # The GA::Session from which this function was called. 'undef' if the calling function | ||
| 4829 | # didn't specify a session and $owner's ->session IV is also 'undef' | ||
| 4830 | session => $session, | ||
| 4831 | # When GA::Session->pseudoCmd is called to execute a client command, the mode in which | ||
| 4832 | # it should be called (usually 'win_error' or 'win_only', which causes errors to be | ||
| 4833 | # displayed in a 'dialogue' window) | ||
| 4834 | pseudoCmdMode => 'win_error', | ||
| 4835 | |||
| 4836 | # The window widget. For most window objects, the Gtk3::Window. For pseudo-windows, the | ||
| 4837 | # parent 'main' window's Gtk3::Window | ||
| 4838 | # The code should use this IV when it wants to do something to the window itself | ||
| 4839 | # (minimise it, make it active, etc) | ||
| 4840 | winWidget => undef, | ||
| 4841 | # The window container. For most window objects, the Gtk3::Window. For pseudo-windows, | ||
| 4842 | # the parent GA::Table::PseudoWin table object | ||
| 4843 | # The code should use this IV when it wants to add, modify or remove widgets inside the | ||
| 4844 | # window itself | ||
| 4845 | winBox => undef, | ||
| 4846 | # Flag set to TRUE if the window actually exists (after a call to $self->winEnable), | ||
| 4847 | # FALSE if not | ||
| 4848 | enabledFlag => FALSE, | ||
| 4849 | # Flag set to TRUE if the Gtk3 window itself is visible (after a call to | ||
| 4850 | # $self->setVisible), FALSE if it is not visible (after a call to $self->setInvisible) | ||
| 4851 | visibleFlag => TRUE, | ||
| 4852 | # Registry hash of 'free' windows (excluding 'dialogue' windows) for which this window | ||
| 4853 | # is the parent, a subset of GA::Obj::Desktop->freeWinHash. Hash in the form | ||
| 4854 | # $childFreeWinHash{unique_number} = blessed_reference_to_window_object | ||
| 4855 | childFreeWinHash => {}, | ||
| 4856 | # When a child 'free' window (excluding 'dialogue' windows) is destroyed, this parent | ||
| 4857 | # window is informed via a call to $self->del_childFreeWin | ||
| 4858 | # When the child is destroyed, this window might want to call some of its own functions | ||
| 4859 | # to update various widgets and/or IVs, in which case this window adds an entry to | ||
| 4860 | # this hash; a hash in the form | ||
| 4861 | # $childDestroyHash{unique_number} = list_reference | ||
| 4862 | # ...where 'unique_number' is the child window's ->number, and 'list_reference' is a | ||
| 4863 | # reference to a list in groups of 2, in the form | ||
| 4864 | # (sub_name, argument_list_ref, sub_name, argument_list_ref...) | ||
| 4865 | childDestroyHash => {}, | ||
| 4866 | |||
| 4867 | # The container widget into which all other widgets are packed (usually a Gtk3::VBox or | ||
| 4868 | # Gtk3::HBox, but any container widget can be used; takes up the whole window client | ||
| 4869 | # area) | ||
| 4870 | packingBox => undef, | ||
| 4871 | |||
| 4872 | # Standard IVs for 'free' windows | ||
| 4873 | |||
| 4874 | # The window's default size, in pixels | ||
| 4875 | widthPixels => int($axmud::CLIENT->constFreeWinWidth * 0.66), | ||
| 4876 | heightPixels => int($axmud::CLIENT->constFreeWinHeight * 0.66), | ||
| 4877 | # Default border/item spacing sizes used in the window, in pixels | ||
| 4878 | borderPixels => $axmud::CLIENT->constFreeBorderPixels, | ||
| 4879 | spacingPixels => $axmud::CLIENT->constFreeSpacingPixels, | ||
| 4880 | |||
| 4881 | # A string to use as the window title | ||
| 4882 | title => 'MCP edit: ' . $configHash{'mcp_name'}, | ||
| 4883 | # Hash containing any number of key-value pairs needed for this particular 'config' | ||
| 4884 | # window; for example, for example, GA::PrefWin::TaskStart uses it to specify a task | ||
| 4885 | # name and type. Set to an empty hash if not required | ||
| 4886 | configHash => {%configHash}, | ||
| 4887 | }; | ||
| 4888 | |||
| 4889 | # Bless the object into existence | ||
| 4890 | bless $self, $class; | ||
| 4891 | |||
| 4892 | return $self; | ||
| 4893 | } | ||
| 4894 | |||
| 4895 | ################## | ||
| 4896 | # Methods | ||
| 4897 | |||
| 4898 | # Standard window object functions | ||
| 4899 | |||
| 4900 | # sub winSetup {} # Inherited from GA::Generic::FreeWin | ||
| 4901 | |||
| 4902 | # sub winEnable {} # Inherited from GA::Generic::FreeWin | ||
| 4903 | |||
| 4904 | # sub winDesengage {} # Inherited from GA::Generic::FreeWin | ||
| 4905 | |||
| 4906 | # sub winDestroy {} # Inherited from GA::Generic::FreeWin | ||
| 4907 | |||
| 4908 | # sub winShowAll {} # Inherited from GA::Generic::Win | ||
| 4909 | |||
| 4910 | sub drawWidgets { | ||
| 4911 | |||
| 4912 | # Called by $self->winSetup | ||
| 4913 | # Sets up the Gtk3::Window by drawing the window's widgets | ||
| 4914 | # | ||
| 4915 | # Expected arguments | ||
| 4916 | # (none besides $self) | ||
| 4917 | # | ||
| 4918 | # Return values | ||
| 4919 | # 'undef' on improper arguments | ||
| 4920 | # 1 otherwise | ||
| 4921 | |||
| 4922 | my ($self, $check) = @_; | ||
| 4923 | |||
| 4924 | # Local variables | ||
| 4925 | my $title; | ||
| 4926 | |||
| 4927 | # Check for improper arguments | ||
| 4928 | if (defined $check) { | ||
| 4929 | |||
| 4930 | return $axmud::CLIENT->writeImproper($self->_objClass . '->drawWidgets', @_); | ||
| 4931 | } | ||
| 4932 | |||
| 4933 | # Create a packing box | ||
| 4934 | my $packingBox = Gtk3::VBox->new(FALSE, 0); | ||
| 4935 | $self->winBox->add($packingBox); | ||
| 4936 | $packingBox->set_border_width(0); | ||
| 4937 | |||
| 4938 | # At the top, create a textview | ||
| 4939 | my $scroller = Gtk3::ScrolledWindow->new(undef, undef); | ||
| 4940 | $packingBox->pack_start($scroller, TRUE, TRUE, 0); | ||
| 4941 | $scroller->set_shadow_type($axmud::CLIENT->constShadowType); | ||
| 4942 | $scroller->set_policy('automatic', 'automatic'); | ||
| 4943 | $scroller->set_border_width(0); | ||
| 4944 | |||
| 4945 | # Create a textview with default colours/fonts | ||
| 4946 | my $textView = Gtk3::TextView->new(); | ||
| 4947 | $scroller->add($textView); | ||
| 4948 | my $buffer = Gtk3::TextBuffer->new(); | ||
| 4949 | $textView->set_buffer($buffer); | ||
| 4950 | $textView->set_editable(TRUE); | ||
| 4951 | $textView->set_cursor_visible(TRUE); | ||
| 4952 | $axmud::CLIENT->desktopObj->setTextViewStyle($self->winType, $textView); | ||
| 4953 | # ->signal_connect appears below | ||
| 4954 | |||
| 4955 | # Set the initial contents of the textview | ||
| 4956 | $buffer->set_text($self->ivShow('configHash', 'mcp_content')); | ||
| 4957 | |||
| 4958 | # At the bottom, create a button strip in a horizontal packing box | ||
| 4959 | my $hBox = Gtk3::HBox->new(FALSE, 0); | ||
| 4960 | $packingBox->pack_end($hBox, FALSE, FALSE, $self->spacingPixels); | ||
| 4961 | |||
| 4962 | # Create some buttons | ||
| 4963 | my $cancelButton = Gtk3::Button->new('Cancel'); | ||
| 4964 | $hBox->pack_start($cancelButton, TRUE, TRUE, $self->borderPixels); | ||
| 4965 | $cancelButton->get_child->set_width_chars(10); | ||
| 4966 | $cancelButton->signal_connect('clicked' => sub { | ||
| 4967 | |||
| 4968 | $self->winDestroy(); | ||
| 4969 | }); | ||
| 4970 | $cancelButton->set_sensitive(FALSE); | ||
| 4971 | |||
| 4972 | my $saveButton = Gtk3::Button->new('Save'); | ||
| 4973 | $hBox->pack_start($saveButton, TRUE, TRUE, $self->borderPixels); | ||
| 4974 | $saveButton->get_child->set_width_chars(10); | ||
| 4975 | $saveButton->signal_connect('clicked' => sub { | ||
| 4976 | |||
| 4977 | $self->doSave($buffer); | ||
| 4978 | $cancelButton->set_sensitive(FALSE); | ||
| 4979 | }); | ||
| 4980 | |||
| 4981 | my $saveCloseButton = Gtk3::Button->new('Save and close'); | ||
| 4982 | $hBox->pack_end($saveCloseButton, TRUE, TRUE, $self->borderPixels); | ||
| 4983 | $saveCloseButton->get_child->set_width_chars(15); | ||
| 4984 | $saveCloseButton->signal_connect('clicked' => sub { | ||
| 4985 | |||
| 4986 | $self->doSave($buffer); | ||
| 4987 | $self->winDestroy(); | ||
| 4988 | }); | ||
| 4989 | |||
| 4990 | # ->signal_connect from above | ||
| 4991 | $buffer->signal_connect('changed' => sub { | ||
| 4992 | |||
| 4993 | $cancelButton->set_sensitive(TRUE); | ||
| 4994 | }); | ||
| 4995 | |||
| 4996 | # Update IVs (not worth storing widgets other than the main packing box) | ||
| 4997 | $self->ivPoke('packingBox', $packingBox); | ||
| 4998 | |||
| 4999 | return 1; | ||
| 5000 | } | ||
| 5001 | |||
| 5002 | # sub redrawWidgets {} # Inherited from GA::Generic::Win | ||
| 5003 | |||
| 5004 | # ->signal_connects | ||
| 5005 | |||
| 5006 | # Other functions | ||
| 5007 | |||
| 5008 | sub doSave { | ||
| 5009 | |||
| 5010 | # Called by $self->drawWidgets | ||
| 5011 | # 'Saves' the contents of the window by sending an MSP message to the world | ||
| 5012 | # | ||
| 5013 | # Expected arguments | ||
| 5014 | # $buffer - The window's Gtk3::Buffer | ||
| 5015 | # | ||
| 5016 | # Return values | ||
| 5017 | # 'undef' on improper arguments | ||
| 5018 | # 1 otherwise | ||
| 5019 | |||
| 5020 | my ($self, $buffer, $check) = @_; | ||
| 5021 | |||
| 5022 | # Local variables | ||
| 5023 | my ( | ||
| 5024 | $text, | ||
| 5025 | @list, | ||
| 5026 | ); | ||
| 5027 | |||
| 5028 | # Check for improper arguments | ||
| 5029 | if (defined $check) { | ||
| 5030 | |||
| 5031 | return $axmud::CLIENT->writeImproper($self->_objClass . '->doSave', @_); | ||
| 5032 | } | ||
| 5033 | |||
| 5034 | $text = $axmud::CLIENT->desktopObj->bufferGetText($buffer); | ||
| 5035 | @list = split(/\n/, $text); | ||
| 5036 | |||
| 5037 | # Send the MCP message (one or more multiline parts) | ||
| 5038 | $self->session->mcpSendMultiLine( | ||
| 5039 | 'dns-org-mud-moo-simpleedit-set', | ||
| 5040 | 'reference', | ||
| 5041 | $self->ivShow('configHash', 'mcp_reference'), | ||
| 5042 | 'content', | ||
| 5043 | \@list, | ||
| 5044 | 'type', | ||
| 5045 | $self->ivShow('configHash', 'mcp_type'), | ||
| 5046 | ); | ||
| 5047 | |||
| 5048 | return 1; | ||
| 5049 | } | ||
| 5050 | |||
| 5051 | ################## | ||
| 5052 | # Accessors - set | ||
| 5053 | |||
| 5054 | ################## | ||
| 5055 | # Accessors - get | ||
| 5056 | } | ||
| 5057 | |||
| 5058 | { package Games::Axmud::OtherWin::PatternTest; | ||
| 5059 | |||
| 5060 | use strict; | ||
| 5061 | use warnings; | ||
| 5062 | use diagnostics; | ||
| 5063 | |||
| 5064 | use Glib qw(TRUE FALSE); | ||
| 5065 | |||
| 5066 | our @ISA = qw( | ||
| 5067 | Games::Axmud::Generic::OtherWin Games::Axmud::Generic::FreeWin Games::Axmud::Generic::Win | ||
| 5068 | Games::Axmud | ||
| 5069 | ); | ||
| 5070 | |||
| 5071 | ################## | ||
| 5072 | # Constructors | ||
| 5073 | |||
| 5074 | sub new { | ||
| 5075 | |||
| 5076 | # Called by GA::Generic::Win->createFreeWin | ||
| 5077 | # Creates a new instance of the Pattern Test window, which allows the user to to test | ||
| 5078 | # patterns (regexes) on the fly | ||
| 5079 | # | ||
| 5080 | # Expected arguments | ||
| 5081 | # $number - Unique number for this window object | ||
| 5082 | # $workspaceObj - The GA::Obj::Workspace handling the workspace in which this window | ||
| 5083 | # should be created | ||
| 5084 | # $owner - The owner; a 'grid' window object (but not an 'external' window) or a | ||
| 5085 | # 'free' window object. When this window opens/closes, the owner is | ||
| 5086 | # informed via calls to its ->add_childFreeWin / ->del_childFreeWin | ||
| 5087 | # functions | ||
| 5088 | # | ||
| 5089 | # Optional arguments | ||
| 5090 | # $session - The GA::Session from which this function was called. 'undef' if the | ||
| 5091 | # calling function didn't specify a session and $owner's ->session IV | ||
| 5092 | # is also 'undef' | ||
| 5093 | # $title - Ignored if set (all 'other' windows define their own title) | ||
| 5094 | # $editObj - Ignored if set | ||
| 5095 | # $tempFlag - Ignored if set | ||
| 5096 | # %configHash - Hash containing any number of key-value pairs needed for this | ||
| 5097 | # particular 'other' window; set to an empty hash if not required | ||
| 5098 | # - This type of window object recognises these initialisation settings: | ||
| 5099 | # | ||
| 5100 | # ... | ||
| 5101 | # | ||
| 5102 | # Return values | ||
| 5103 | # 'undef' on improper arguments | ||
| 5104 | # Blessed reference to the newly-created object on success | ||
| 5105 | |||
| 5106 | my ( | ||
| 5107 | $class, $number, $workspaceObj, $owner, $session, $title, $editObj, $tempFlag, | ||
| 5108 | %configHash, | ||
| 5109 | ) = @_; | ||
| 5110 | |||
| 5111 | # Local variables | ||
| 5112 | my ($widthPixels, $heightPixels); | ||
| 5113 | |||
| 5114 | # Check for improper arguments | ||
| 5115 | if (! defined $class || ! defined $number || ! defined $workspaceObj || ! defined $owner) { | ||
| 5116 | |||
| 5117 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 5118 | } | ||
| 5119 | |||
| 5120 | # Setup | ||
| 5121 | my $self = { | ||
| 5122 | _objName => 'other_win_' . $number, | ||
| 5123 | _objClass => $class, | ||
| 5124 | _parentFile => undef, # No parent file object | ||
| 5125 | _parentWorld => undef, # No parent file object | ||
| 5126 | _privFlag => TRUE, # All IVs are private | ||
| 5127 | |||
| 5128 | # Standard window object IVs | ||
| 5129 | # -------------------------- | ||
| 5130 | |||
| 5131 | # Unique number for this window object | ||
| 5132 | number => $number, | ||
| 5133 | # The window category - 'grid' or 'free' | ||
| 5134 | winCategory => 'free', | ||
| 5135 | # The window type, any of the keys in GA::Client->constFreeWinTypeHash | ||
| 5136 | winType => 'other', | ||
| 5137 | # A name for the window (for some 'free' windows, the same as the window type) | ||
| 5138 | winName => 'pattern_test', | ||
| 5139 | # The GA::Obj::Workspace object for the workspace in which this window is created | ||
| 5140 | workspaceObj => $workspaceObj, | ||
| 5141 | # The owner; a 'grid' window object (but not an 'external' window) or a 'free' window | ||
| 5142 | # object. When this window opens/closes, the owner is informed via calls to its | ||
| 5143 | # ->add_childFreeWin / ->del_childFreeWin functions | ||
| 5144 | owner => $owner, | ||
| 5145 | # The GA::Session from which this function was called. 'undef' if the calling function | ||
| 5146 | # didn't specify a session and $owner's ->session IV is also 'undef' | ||
| 5147 | session => $session, | ||
| 5148 | # When GA::Session->pseudoCmd is called to execute a client command, the mode in which | ||
| 5149 | # it should be called (usually 'win_error' or 'win_only', which causes errors to be | ||
| 5150 | # displayed in a 'dialogue' window) | ||
| 5151 | pseudoCmdMode => 'win_error', | ||
| 5152 | |||
| 5153 | # The window widget. For most window objects, the Gtk3::Window. For pseudo-windows, the | ||
| 5154 | # parent 'main' window's Gtk3::Window | ||
| 5155 | # The code should use this IV when it wants to do something to the window itself | ||
| 5156 | # (minimise it, make it active, etc) | ||
| 5157 | winWidget => undef, | ||
| 5158 | # The window container. For most window objects, the Gtk3::Window. For pseudo-windows, | ||
| 5159 | # the parent GA::Table::PseudoWin table object | ||
| 5160 | # The code should use this IV when it wants to add, modify or remove widgets inside the | ||
| 5161 | # window itself | ||
| 5162 | winBox => undef, | ||
| 5163 | # Flag set to TRUE if the window actually exists (after a call to $self->winEnable), | ||
| 5164 | # FALSE if not | ||
| 5165 | enabledFlag => FALSE, | ||
| 5166 | # Flag set to TRUE if the Gtk3 window itself is visible (after a call to | ||
| 5167 | # $self->setVisible), FALSE if it is not visible (after a call to $self->setInvisible) | ||
| 5168 | visibleFlag => TRUE, | ||
| 5169 | # Registry hash of 'free' windows (excluding 'dialogue' windows) for which this window | ||
| 5170 | # is the parent, a subset of GA::Obj::Desktop->freeWinHash. Hash in the form | ||
| 5171 | # $childFreeWinHash{unique_number} = blessed_reference_to_window_object | ||
| 5172 | childFreeWinHash => {}, | ||
| 5173 | |||
| 5174 | # The container widget into which all other widgets are packed (usually a Gtk3::VBox or | ||
| 5175 | # Gtk3::HBox, but any container widget can be used; takes up the whole window client | ||
| 5176 | # area) | ||
| 5177 | packingBox => undef, # Gtk3::VBox | ||
| 5178 | |||
| 5179 | # Standard IVs for 'free' windows | ||
| 5180 | |||
| 5181 | # The window's default size, in pixels | ||
| 5182 | widthPixels => $axmud::CLIENT->customFreeWinWidth, | ||
| 5183 | heightPixels => $axmud::CLIENT->customFreeWinHeight, | ||
| 5184 | # Default border/item spacing sizes used in the window, in pixels | ||
| 5185 | borderPixels => $axmud::CLIENT->constFreeBorderPixels, | ||
| 5186 | spacingPixels => $axmud::CLIENT->constFreeSpacingPixels, | ||
| 5187 | |||
| 5188 | # A string to use as the window title. If 'undef', a generic title is used | ||
| 5189 | title => 'Pattern Test', | ||
| 5190 | # Hash containing any number of key-value pairs needed for this particular 'config' | ||
| 5191 | # window; for example, for example, GA::PrefWin::TaskStart uses it to specify a task | ||
| 5192 | # name and type. Set to an empty hash if not required | ||
| 5193 | configHash => {%configHash}, | ||
| 5194 | |||
| 5195 | # IVs for this type of window | ||
| 5196 | |||
| 5197 | # Standard size of the Gtk3::Grid used (a 12x12 grid, with a spare cell around every | ||
| 5198 | # border) | ||
| 5199 | gridWidth => 13, | ||
| 5200 | gridHeight => 13, | ||
| 5201 | }; | ||
| 5202 | |||
| 5203 | # Bless the object into existence | ||
| 5204 | bless $self, $class; | ||
| 5205 | |||
| 5206 | return $self; | ||
| 5207 | } | ||
| 5208 | |||
| 5209 | ################## | ||
| 5210 | # Methods | ||
| 5211 | |||
| 5212 | # Standard window object functions | ||
| 5213 | |||
| 5214 | # sub winSetup {} # Inherited from GA::Generic::FreeWin | ||
| 5215 | |||
| 5216 | # sub winEnable {} # Inherited from GA::Generic::FreeWin | ||
| 5217 | |||
| 5218 | # sub winDesengage {} # Inherited from GA::Generic::FreeWin | ||
| 5219 | |||
| 5220 | # sub winDestroy {} # Inherited from GA::Generic::FreeWin | ||
| 5221 | |||
| 5222 | # sub winShowAll {} # Inherited from GA::Generic::Win | ||
| 5223 | |||
| 5224 | sub drawWidgets { | ||
| 5225 | |||
| 5226 | # Called by $self->winSetup | ||
| 5227 | # Sets up the Pattern Test window with its standard widgets | ||
| 5228 | # | ||
| 5229 | # Expected arguments | ||
| 5230 | # (none besides $self) | ||
| 5231 | # | ||
| 5232 | # Return values | ||
| 5233 | # 'undef' on improper arguments | ||
| 5234 | # 1 otherwise | ||
| 5235 | |||
| 5236 | my ($self, $check) = @_; | ||
| 5237 | |||
| 5238 | # Local variables | ||
| 5239 | my @columnList; | ||
| 5240 | |||
| 5241 | # Check for improper arguments | ||
| 5242 | if (defined $check) { | ||
| 5243 | |||
| 5244 | return $axmud::CLIENT->writeImproper($self->_objClass . '->drawWidgets', @_); | ||
| 5245 | } | ||
| 5246 | |||
| 5247 | # Create a packing box | ||
| 5248 | my $packingBox = Gtk3::VBox->new(FALSE, 0); | ||
| 5249 | $self->winBox->add($packingBox); | ||
| 5250 | $packingBox->set_border_width(0); | ||
| 5251 | |||
| 5252 | # Update IVs immediately, for the benefit of any called functions | ||
| 5253 | $self->ivPoke('packingBox', $packingBox); | ||
| 5254 | |||
| 5255 | # Create an image on the left | ||
| 5256 | my $hBox = Gtk3::HBox->new(FALSE, 0); | ||
| 5257 | $packingBox->pack_start($hBox, TRUE, TRUE, 0); | ||
| 5258 | |||
| 5259 | my $vBox = Gtk3::VBox->new(FALSE, 0); | ||
| 5260 | $hBox->pack_start($vBox, FALSE, FALSE, 0); | ||
| 5261 | |||
| 5262 | my $frame = Gtk3::Frame->new(undef); | ||
| 5263 | $vBox->pack_start($frame, FALSE, FALSE, 0); | ||
| 5264 | $frame->set_size_request(64, 64); | ||
| 5265 | $frame->set_shadow_type($axmud::CLIENT->constShadowType); | ||
| 5266 | |||
| 5267 | my $image = Gtk3::Image->new_from_file($axmud::CLIENT->getDialogueIcon()); | ||
| 5268 | $frame->add($image); | ||
| 5269 | |||
| 5270 | # Create a grid inside a scroller on the right | ||
| 5271 | my $frame2 = Gtk3::Frame->new(undef); | ||
| 5272 | $hBox->pack_start($frame2, TRUE, TRUE, $self->spacingPixels); | ||
| 5273 | $frame2->set_shadow_type($axmud::CLIENT->constShadowType); | ||
| 5274 | |||
| 5275 | my $scroller = Gtk3::ScrolledWindow->new(); | ||
| 5276 | $frame2->add($scroller); | ||
| 5277 | $scroller->set_policy(qw/automatic automatic/); | ||
| 5278 | $scroller->set_border_width(5); | ||
| 5279 | |||
| 5280 | my $grid = Gtk3::Grid->new(); | ||
| 5281 | $scroller->add_with_viewport($grid); | ||
| 5282 | $grid->set_column_spacing($self->spacingPixels); | ||
| 5283 | $grid->set_row_spacing($self->spacingPixels); | ||
| 5284 | |||
| 5285 | # Create a button at the bottom to close the window | ||
| 5286 | my $hBox2 = Gtk3::HBox->new(FALSE, 0); | ||
| 5287 | $packingBox->pack_end($hBox2, FALSE, FALSE, $self->spacingPixels); | ||
| 5288 | |||
| 5289 | # The button's label includes some extra space characters to make it a little easier to | ||
| 5290 | # click on | ||
| 5291 | my $okButton = Gtk3::Button->new('OK'); | ||
| 5292 | $okButton->get_child->set_width_chars(10); | ||
| 5293 | $hBox2->pack_end($okButton, FALSE, FALSE, 0); | ||
| 5294 | $okButton->signal_connect('clicked' => sub { | ||
| 5295 | |||
| 5296 | $self->winDestroy(); | ||
| 5297 | }); | ||
| 5298 | |||
| 5299 | # Add some editing widgets. The ->signal_connect appear below | ||
| 5300 | $self->addLabel($grid, '<b>Pattern / regular expression / regex tester</b>', | ||
| 5301 | 1, 12, 1, 2); | ||
| 5302 | |||
| 5303 | $self->addLabel($grid, 'Pattern', | ||
| 5304 | 1, 3, 2, 3); | ||
| 5305 | my $entry = $self->addEntry($grid, undef, undef, TRUE, | ||
| 5306 | 3, 12, 2, 3); | ||
| 5307 | $entry->set_icon_from_stock('secondary', 'gtk-no'); | ||
| 5308 | |||
| 5309 | $self->addLabel($grid, 'Line', | ||
| 5310 | 1, 3, 3, 4); | ||
| 5311 | my $entry2 = $self->addEntry($grid, undef, undef, TRUE, | ||
| 5312 | 3, 12, 3, 4); | ||
| 5313 | |||
| 5314 | $self->addLabel($grid, 'Substitution', | ||
| 5315 | 1, 3, 4, 5); | ||
| 5316 | my $entry3 = $self->addEntry($grid, undef, undef, TRUE, | ||
| 5317 | 3, 12, 4, 5); | ||
| 5318 | |||
| 5319 | my $button = $self->addButton( | ||
| 5320 | $grid, | ||
| 5321 | undef, | ||
| 5322 | 'Test the pattern\'s validity', | ||
| 5323 | 'Test the pattern\'s validity', | ||
| 5324 | 1, 6, 5, 6); | ||
| 5325 | |||
| 5326 | my $button2 = $self->addButton( | ||
| 5327 | $grid, | ||
| 5328 | undef, | ||
| 5329 | 'Match the pattern against the line', | ||
| 5330 | 'i.e. $line =~ m/$pattern/', | ||
| 5331 | 6, 12, 5, 6); | ||
| 5332 | $button2->set_sensitive(FALSE); | ||
| 5333 | |||
| 5334 | my $button3 = $self->addButton( | ||
| 5335 | $grid, | ||
| 5336 | undef, | ||
| 5337 | 'Use the pattern to apply the substitution to the line', | ||
| 5338 | 'i.e. $line =~ s/$pattern/$substitution/', | ||
| 5339 | 1, 8, 6, 7); | ||
| 5340 | $button3->set_sensitive(FALSE); | ||
| 5341 | |||
| 5342 | my $button4 = $self->addButton( | ||
| 5343 | $grid, | ||
| 5344 | undef, | ||
| 5345 | 'Clear all', | ||
| 5346 | 'Clear all the entry boxes', | ||
| 5347 | 8, 12, 6, 7); | ||
| 5348 | |||
| 5349 | $self->addLabel($grid, 'Result', | ||
| 5350 | 1, 3, 7, 8); | ||
| 5351 | my $entry4 = $self->addEntry($grid, undef, undef, TRUE, | ||
| 5352 | 3, 12, 7, 8); | ||
| 5353 | $entry4->set_editable(FALSE); | ||
| 5354 | |||
| 5355 | # Add a simple list to show group substrings | ||
| 5356 | @columnList = ( | ||
| 5357 | 'Substring #', 'int', | ||
| 5358 | 'Matching substring', 'text', | ||
| 5359 | ); | ||
| 5360 | |||
| 5361 | my $frame3 = Gtk3::Frame->new(undef); | ||
| 5362 | $grid->attach($frame3, 1, 8, 11, 4); | ||
| 5363 | $frame3->set_border_width(0); | ||
| 5364 | $frame3->set_vexpand(TRUE); | ||
| 5365 | |||
| 5366 | my $scroller2 = Gtk3::ScrolledWindow->new(); | ||
| 5367 | $frame3->add($scroller2); | ||
| 5368 | $scroller2->set_shadow_type('none'); | ||
| 5369 | $scroller2->set_policy('automatic', 'automatic'); | ||
| 5370 | $scroller2->set_border_width(0); | ||
| 5371 | $scroller2->set_size_request(-1, 180); | ||
| 5372 | |||
| 5373 | my $slWidget = Games::Axmud::Obj::SimpleList->new(@columnList); | ||
| 5374 | $scroller2->add($slWidget); | ||
| 5375 | |||
| 5376 | # ->signal_connects | ||
| 5377 | $entry->signal_connect('changed' => sub { | ||
| 5378 | |||
| 5379 | my $regex = $entry->get_text(); | ||
| 5380 | |||
| 5381 | # GA::Client->regexCheck returns 'undef' for a valid regex, or an error message for an | ||
| 5382 | # invalid one | ||
| 5383 | if ( | ||
| 5384 | defined $regex | ||
| 5385 | && $regex ne '' | ||
| 5386 | && ! defined $axmud::CLIENT->regexCheck($regex) | ||
| 5387 | ) { | ||
| 5388 | $entry->set_icon_from_stock('secondary', 'gtk-yes'); | ||
| 5389 | |||
| 5390 | if (length $entry2->get_text() > 0) { | ||
| 5391 | $button2->set_sensitive(TRUE); | ||
| 5392 | } else { | ||
| 5393 | $button2->set_sensitive(FALSE); | ||
| 5394 | } | ||
| 5395 | |||
| 5396 | if (length $entry3->get_text() > 0) { | ||
| 5397 | $button3->set_sensitive(TRUE); | ||
| 5398 | } else { | ||
| 5399 | $button3->set_sensitive(FALSE); | ||
| 5400 | } | ||
| 5401 | |||
| 5402 | } else { | ||
| 5403 | |||
| 5404 | $entry->set_icon_from_stock('secondary', 'gtk-no'); | ||
| 5405 | $button2->set_sensitive(FALSE); | ||
| 5406 | $button3->set_sensitive(FALSE); | ||
| 5407 | } | ||
| 5408 | }); | ||
| 5409 | |||
| 5410 | $entry2->signal_connect('changed' => sub { | ||
| 5411 | |||
| 5412 | my ($regex, $line, $substitution); | ||
| 5413 | |||
| 5414 | $regex = $entry->get_text(); | ||
| 5415 | $line = $entry2->get_text(); | ||
| 5416 | $substitution = $entry3->get_text(); | ||
| 5417 | |||
| 5418 | if ( | ||
| 5419 | ! defined $axmud::CLIENT->regexCheck($regex) | ||
| 5420 | && length $line > 0 | ||
| 5421 | ) { | ||
| 5422 | $button2->set_sensitive(TRUE); | ||
| 5423 | if (length $substitution > 0) { | ||
| 5424 | $button3->set_sensitive(TRUE); | ||
| 5425 | } else { | ||
| 5426 | $button3->set_sensitive(FALSE); | ||
| 5427 | } | ||
| 5428 | |||
| 5429 | } else { | ||
| 5430 | |||
| 5431 | $button2->set_sensitive(FALSE); | ||
| 5432 | $button3->set_sensitive(FALSE); | ||
| 5433 | } | ||
| 5434 | }); | ||
| 5435 | |||
| 5436 | $entry3->signal_connect('changed' => sub { | ||
| 5437 | |||
| 5438 | my ($regex, $line, $substitution); | ||
| 5439 | |||
| 5440 | $regex = $entry->get_text(); | ||
| 5441 | $line = $entry2->get_text(); | ||
| 5442 | $substitution = $entry3->get_text(); | ||
| 5443 | |||
| 5444 | if ( | ||
| 5445 | ! defined $axmud::CLIENT->regexCheck($regex) | ||
| 5446 | && length $line > 0 | ||
| 5447 | && length $substitution > 0 | ||
| 5448 | ) { | ||
| 5449 | $button3->set_sensitive(TRUE); | ||
| 5450 | } else { | ||
| 5451 | $button3->set_sensitive(FALSE); | ||
| 5452 | } | ||
| 5453 | }); | ||
| 5454 | |||
| 5455 | $button->signal_connect('clicked' => sub { | ||
| 5456 | |||
| 5457 | my ($regex, $result); | ||
| 5458 | |||
| 5459 | $regex = $entry->get_text(); | ||
| 5460 | |||
| 5461 | if (! defined $regex || $regex eq '') { | ||
| 5462 | |||
| 5463 | $entry4->set_text(''); | ||
| 5464 | |||
| 5465 | } else { | ||
| 5466 | |||
| 5467 | $result = $axmud::CLIENT->regexCheck($regex); | ||
| 5468 | if (! defined $result) { | ||
| 5469 | |||
| 5470 | $entry4->set_text('<Pattern is valid>'); | ||
| 5471 | $entry4->set_icon_from_stock('secondary', 'gtk-yes'); | ||
| 5472 | |||
| 5473 | } else { | ||
| 5474 | |||
| 5475 | # Perl error message | ||
| 5476 | $entry4->set_text($result); | ||
| 5477 | $entry4->set_icon_from_stock('secondary', 'gtk-no'); | ||
| 5478 | } | ||
| 5479 | } | ||
| 5480 | }); | ||
| 5481 | |||
| 5482 | $button2->signal_connect('clicked' => sub { | ||
| 5483 | |||
| 5484 | my ( | ||
| 5485 | $regex, $line, $count, | ||
| 5486 | @grpStringList, @dataList, | ||
| 5487 | ); | ||
| 5488 | |||
| 5489 | $regex = $entry->get_text(); | ||
| 5490 | $line = $entry2->get_text(); | ||
| 5491 | |||
| 5492 | @grpStringList = ($line =~ m/$regex/); | ||
| 5493 | if (@grpStringList) { | ||
| 5494 | |||
| 5495 | if ((scalar @-) > 1) { | ||
| 5496 | |||
| 5497 | $count = 0; | ||
| 5498 | foreach my $grpString (@grpStringList) { | ||
| 5499 | |||
| 5500 | $count++; | ||
| 5501 | push (@dataList, [$count, $grpString]); | ||
| 5502 | } | ||
| 5503 | } | ||
| 5504 | |||
| 5505 | $entry4->set_text('<Pattern matches the line>'); | ||
| 5506 | $entry4->set_icon_from_stock('secondary', 'gtk-yes'); | ||
| 5507 | @{$slWidget->{data}} = @dataList; | ||
| 5508 | |||
| 5509 | } else { | ||
| 5510 | |||
| 5511 | $entry4->set_text('<Pattern does NOT match the line>'); | ||
| 5512 | $entry4->set_icon_from_stock('secondary', 'gtk-no'); | ||
| 5513 | @{$slWidget->{data}} = (); | ||
| 5514 | } | ||
| 5515 | }); | ||
| 5516 | |||
| 5517 | $button3->signal_connect('clicked' => sub { | ||
| 5518 | |||
| 5519 | my ($regex, $line, $substitution); | ||
| 5520 | |||
| 5521 | $regex = $entry->get_text(); | ||
| 5522 | $line = $entry2->get_text(); | ||
| 5523 | $substitution = $entry3->get_text(); | ||
| 5524 | |||
| 5525 | if ($line =~ s/$regex/$substitution/) { | ||
| 5526 | |||
| 5527 | $entry4->set_text($line); | ||
| 5528 | $entry4->set_icon_from_stock('secondary', 'gtk-yes'); | ||
| 5529 | @{$slWidget->{data}} = (); | ||
| 5530 | |||
| 5531 | } else { | ||
| 5532 | |||
| 5533 | $entry4->set_text('<Pattern does NOT match the line>'); | ||
| 5534 | $entry4->set_icon_from_stock('secondary', 'gtk-no'); | ||
| 5535 | @{$slWidget->{data}} = (); | ||
| 5536 | } | ||
| 5537 | }); | ||
| 5538 | |||
| 5539 | $button4->signal_connect('clicked' => sub { | ||
| 5540 | |||
| 5541 | $entry->set_text(''); | ||
| 5542 | $entry->set_icon_from_stock('secondary', undef); | ||
| 5543 | |||
| 5544 | $entry2->set_text(''); | ||
| 5545 | $entry3->set_text(''); | ||
| 5546 | |||
| 5547 | $entry4->set_icon_from_stock('secondary', undef); | ||
| 5548 | $entry4->set_text(''); | ||
| 5549 | |||
| 5550 | @{$slWidget->{data}} = (); | ||
| 5551 | }); | ||
| 5552 | |||
| 5553 | return 1; | ||
| 5554 | } | ||
| 5555 | |||
| 5556 | # sub redrawWidgets {} # Inherited from GA::Generic::Win | ||
| 5557 | |||
| 5558 | # ->signal_connects | ||
| 5559 | |||
| 5560 | # Other functions | ||
| 5561 | |||
| 5562 | ################## | ||
| 5563 | # Accessors - set | ||
| 5564 | |||
| 5565 | ################## | ||
| 5566 | # Accessors - get | ||
| 5567 | |||
| 5568 | sub gridWidth | ||
| 5569 | { $_[0]->{gridWidth} } | ||
| 5570 | sub gridHeight | ||
| 5571 | { $_[0]->{gridHeight} } | ||
| 5572 | } | ||
| 5573 | |||
| 5574 | { package Games::Axmud::OtherWin::QuickInput; | ||
| 5575 | |||
| 5576 | use strict; | ||
| 5577 | use warnings; | ||
| 5578 | use diagnostics; | ||
| 5579 | |||
| 5580 | use Glib qw(TRUE FALSE); | ||
| 5581 | |||
| 5582 | our @ISA = qw( | ||
| 5583 | Games::Axmud::Generic::OtherWin Games::Axmud::Generic::FreeWin Games::Axmud::Generic::Win | ||
| 5584 | Games::Axmud | ||
| 5585 | ); | ||
| 5586 | |||
| 5587 | ################## | ||
| 5588 | # Constructors | ||
| 5589 | |||
| 5590 | sub new { | ||
| 5591 | |||
| 5592 | # Called by GA::Generic::Win->createFreeWin | ||
| 5593 | # Creates a new instance of the Quick Input window (an 'other' window). The window contains | ||
| 5594 | # a textview in which the user can type text, and some widgets that specify what should be | ||
| 5595 | # done with the text | ||
| 5596 | # | ||
| 5597 | # Expected arguments | ||
| 5598 | # $number - Unique number for this window object | ||
| 5599 | # $workspaceObj - The GA::Obj::Workspace handling the workspace in which this window | ||
| 5600 | # should be created | ||
| 5601 | # $owner - The owner; a 'grid' window object (but not an 'external' window) or a | ||
| 5602 | # 'free' window object. When this window opens/closes, the owner is | ||
| 5603 | # informed via calls to its ->add_childFreeWin / ->del_childFreeWin | ||
| 5604 | # functions | ||
| 5605 | # | ||
| 5606 | # Optional arguments | ||
| 5607 | # $session - The GA::Session from which this function was called. 'undef' if the | ||
| 5608 | # calling function didn't specify a session and $owner's ->session IV | ||
| 5609 | # is also 'undef' | ||
| 5610 | # $title - Ignored if set (all 'other' windows define their own title) | ||
| 5611 | # $editObj - Ignored if set | ||
| 5612 | # $tempFlag - Ignored if set | ||
| 5613 | # %configHash - Hash containing any number of key-value pairs needed for this | ||
| 5614 | # particular 'other' window; set to an empty hash if not required | ||
| 5615 | # - This type of window object recognises these initialisation settings: | ||
| 5616 | # | ||
| 5617 | # ... | ||
| 5618 | # | ||
| 5619 | # Return values | ||
| 5620 | # 'undef' on improper arguments | ||
| 5621 | # Blessed reference to the newly-created object on success | ||
| 5622 | |||
| 5623 | my ( | ||
| 5624 | $class, $number, $workspaceObj, $owner, $session, $title, $editObj, $tempFlag, | ||
| 5625 | %configHash, | ||
| 5626 | ) = @_; | ||
| 5627 | |||
| 5628 | # Check for improper arguments | ||
| 5629 | if (! defined $class || ! defined $number || ! defined $workspaceObj || ! defined $owner) { | ||
| 5630 | |||
| 5631 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 5632 | } | ||
| 5633 | |||
| 5634 | # Setup | ||
| 5635 | my $self = { | ||
| 5636 | _objName => 'other_win_' . $number, | ||
| 5637 | _objClass => $class, | ||
| 5638 | _parentFile => undef, # No parent file object | ||
| 5639 | _parentWorld => undef, # No parent file object | ||
| 5640 | _privFlag => TRUE, # All IVs are private | ||
| 5641 | |||
| 5642 | # Standard window object IVs | ||
| 5643 | # -------------------------- | ||
| 5644 | |||
| 5645 | # Unique number for this window object | ||
| 5646 | number => $number, | ||
| 5647 | # The window category - 'grid' or 'free' | ||
| 5648 | winCategory => 'free', | ||
| 5649 | # The window type, any of the keys in GA::Client->constFreeWinTypeHash | ||
| 5650 | winType => 'other', | ||
| 5651 | # A name for the window (can be unique to this type of window object, or can be the | ||
| 5652 | # same as ->winType) | ||
| 5653 | winName => 'quick_input', | ||
| 5654 | # The GA::Obj::Workspace object for the workspace in which this window is created | ||
| 5655 | workspaceObj => $workspaceObj, | ||
| 5656 | # The owner; a 'grid' window object (but not an 'external' window) or a 'free' window | ||
| 5657 | # object. When this window opens/closes, the owner is informed via calls to its | ||
| 5658 | # ->add_childFreeWin / ->del_childFreeWin functions | ||
| 5659 | owner => $owner, | ||
| 5660 | # The GA::Session from which this function was called. 'undef' if the calling function | ||
| 5661 | # didn't specify a session and $owner's ->session IV is also 'undef' | ||
| 5662 | session => $session, | ||
| 5663 | # When GA::Session->pseudoCmd is called to execute a client command, the mode in which | ||
| 5664 | # it should be called (usually 'win_error' or 'win_only', which causes errors to be | ||
| 5665 | # displayed in a 'dialogue' window) | ||
| 5666 | pseudoCmdMode => 'win_error', | ||
| 5667 | |||
| 5668 | # The window widget. For most window objects, the Gtk3::Window. For pseudo-windows, the | ||
| 5669 | # parent 'main' window's Gtk3::Window | ||
| 5670 | # The code should use this IV when it wants to do something to the window itself | ||
| 5671 | # (minimise it, make it active, etc) | ||
| 5672 | winWidget => undef, | ||
| 5673 | # The window container. For most window objects, the Gtk3::Window. For pseudo-windows, | ||
| 5674 | # the parent GA::Table::PseudoWin table object | ||
| 5675 | # The code should use this IV when it wants to add, modify or remove widgets inside the | ||
| 5676 | # window itself | ||
| 5677 | winBox => undef, | ||
| 5678 | # Flag set to TRUE if the window actually exists (after a call to $self->winEnable), | ||
| 5679 | # FALSE if not | ||
| 5680 | enabledFlag => FALSE, | ||
| 5681 | # Flag set to TRUE if the Gtk3 window itself is visible (after a call to | ||
| 5682 | # $self->setVisible), FALSE if it is not visible (after a call to $self->setInvisible) | ||
| 5683 | visibleFlag => TRUE, | ||
| 5684 | # Registry hash of 'free' windows (excluding 'dialogue' windows) for which this window | ||
| 5685 | # is the parent, a subset of GA::Obj::Desktop->freeWinHash. Hash in the form | ||
| 5686 | # $childFreeWinHash{unique_number} = blessed_reference_to_window_object | ||
| 5687 | childFreeWinHash => {}, | ||
| 5688 | # When a child 'free' window (excluding 'dialogue' windows) is destroyed, this parent | ||
| 5689 | # window is informed via a call to $self->del_childFreeWin | ||
| 5690 | # When the child is destroyed, this window might want to call some of its own functions | ||
| 5691 | # to update various widgets and/or IVs, in which case this window adds an entry to | ||
| 5692 | # this hash; a hash in the form | ||
| 5693 | # $childDestroyHash{unique_number} = list_reference | ||
| 5694 | # ...where 'unique_number' is the child window's ->number, and 'list_reference' is a | ||
| 5695 | # reference to a list in groups of 2, in the form | ||
| 5696 | # (sub_name, argument_list_ref, sub_name, argument_list_ref...) | ||
| 5697 | childDestroyHash => {}, | ||
| 5698 | |||
| 5699 | # The container widget into which all other widgets are packed (usually a Gtk3::VBox or | ||
| 5700 | # Gtk3::HBox, but any container widget can be used; takes up the whole window client | ||
| 5701 | # area) | ||
| 5702 | packingBox => undef, | ||
| 5703 | |||
| 5704 | # Standard IVs for 'free' windows | ||
| 5705 | |||
| 5706 | # The window's default size, in pixels | ||
| 5707 | widthPixels => int($axmud::CLIENT->constFreeWinWidth * 0.66), | ||
| 5708 | heightPixels => int($axmud::CLIENT->constFreeWinHeight * 0.66), | ||
| 5709 | # Default border/item spacing sizes used in the window, in pixels | ||
| 5710 | borderPixels => $axmud::CLIENT->constFreeBorderPixels, | ||
| 5711 | spacingPixels => $axmud::CLIENT->constFreeSpacingPixels, | ||
| 5712 | |||
| 5713 | # A string to use as the window title | ||
| 5714 | title => 'Quick input window', | ||
| 5715 | # Hash containing any number of key-value pairs needed for this particular 'config' | ||
| 5716 | # window; for example, for example, GA::PrefWin::TaskStart uses it to specify a task | ||
| 5717 | # name and type. Set to an empty hash if not required | ||
| 5718 | configHash => {%configHash}, | ||
| 5719 | }; | ||
| 5720 | |||
| 5721 | # Bless the object into existence | ||
| 5722 | bless $self, $class; | ||
| 5723 | |||
| 5724 | return $self; | ||
| 5725 | } | ||
| 5726 | |||
| 5727 | ################## | ||
| 5728 | # Methods | ||
| 5729 | |||
| 5730 | # Standard window object functions | ||
| 5731 | |||
| 5732 | # sub winSetup {} # Inherited from GA::Generic::FreeWin | ||
| 5733 | |||
| 5734 | # sub winEnable {} # Inherited from GA::Generic::FreeWin | ||
| 5735 | |||
| 5736 | # sub winDesengage {} # Inherited from GA::Generic::FreeWin | ||
| 5737 | |||
| 5738 | # sub winDestroy {} # Inherited from GA::Generic::FreeWin | ||
| 5739 | |||
| 5740 | # sub winShowAll {} # Inherited from GA::Generic::Win | ||
| 5741 | |||
| 5742 | sub drawWidgets { | ||
| 5743 | |||
| 5744 | # Called by $self->winSetup | ||
| 5745 | # Sets up the Gtk3::Window by drawing the window's widgets | ||
| 5746 | # | ||
| 5747 | # Expected arguments | ||
| 5748 | # (none besides $self) | ||
| 5749 | # | ||
| 5750 | # Return values | ||
| 5751 | # 'undef' on improper arguments | ||
| 5752 | # 1 otherwise | ||
| 5753 | |||
| 5754 | my ($self, $check) = @_; | ||
| 5755 | |||
| 5756 | # Local variables | ||
| 5757 | my $title; | ||
| 5758 | |||
| 5759 | # Check for improper arguments | ||
| 5760 | if (defined $check) { | ||
| 5761 | |||
| 5762 | return $axmud::CLIENT->writeImproper($self->_objClass . '->drawWidgets', @_); | ||
| 5763 | } | ||
| 5764 | |||
| 5765 | # Create a packing box | ||
| 5766 | my $packingBox = Gtk3::VBox->new(FALSE, 0); | ||
| 5767 | $self->winBox->add($packingBox); | ||
| 5768 | $packingBox->set_border_width(0); | ||
| 5769 | |||
| 5770 | # At the top, create a textview | ||
| 5771 | my $scroller = Gtk3::ScrolledWindow->new(undef, undef); | ||
| 5772 | $packingBox->pack_start($scroller, TRUE, TRUE, 0); | ||
| 5773 | $scroller->set_shadow_type($axmud::CLIENT->constShadowType); | ||
| 5774 | $scroller->set_policy('automatic', 'automatic'); | ||
| 5775 | $scroller->set_border_width(0); | ||
| 5776 | |||
| 5777 | # Create a textview with default colours/fonts | ||
| 5778 | my $textView = Gtk3::TextView->new(); | ||
| 5779 | $scroller->add($textView); | ||
| 5780 | my $buffer = Gtk3::TextBuffer->new(); | ||
| 5781 | $textView->set_buffer($buffer); | ||
| 5782 | $textView->set_editable(TRUE); | ||
| 5783 | $textView->set_cursor_visible(TRUE); | ||
| 5784 | $axmud::CLIENT->desktopObj->setTextViewStyle($self->winType, $textView); | ||
| 5785 | |||
| 5786 | # At the bottom, create several horizontal packing boxes for various widgets | ||
| 5787 | my $hBox = Gtk3::HBox->new(FALSE, 0); | ||
| 5788 | $packingBox->pack_start($hBox, FALSE, FALSE, $self->spacingPixels); | ||
| 5789 | |||
| 5790 | my $radioButton = Gtk3::RadioButton->new_with_label(undef, 'Execute instructions'); | ||
| 5791 | $hBox->pack_start($radioButton, TRUE, TRUE, $self->spacingPixels); | ||
| 5792 | |||
| 5793 | my $checkButton = Gtk3::CheckButton->new_with_label('(ignore empty lines)'); | ||
| 5794 | $hBox->pack_start($checkButton, TRUE, TRUE, $self->spacingPixels); | ||
| 5795 | |||
| 5796 | my $radioButton2 = Gtk3::RadioButton->new_with_label( | ||
| 5797 | $radioButton->get_group(), | ||
| 5798 | 'Run as a script', | ||
| 5799 | ); | ||
| 5800 | |||
| 5801 | $hBox->pack_start($radioButton2, TRUE, TRUE, $self->spacingPixels); | ||
| 5802 | |||
| 5803 | # Second strip | ||
| 5804 | my $hBox2 = Gtk3::HBox->new(FALSE, 0); | ||
| 5805 | $packingBox->pack_start($hBox2, FALSE, FALSE, 0); | ||
| 5806 | |||
| 5807 | my $label = Gtk3::Label->new('Prepend:'); | ||
| 5808 | $hBox2->pack_start($label, FALSE, FALSE, $self->spacingPixels); | ||
| 5809 | |||
| 5810 | my $entry = Gtk3::Entry->new(); | ||
| 5811 | $hBox2->pack_start($entry, TRUE, TRUE, 0); | ||
| 5812 | $entry->set_tooltip_text('Prepend this to every world command'); | ||
| 5813 | |||
| 5814 | my $label2 = Gtk3::Label->new('Append:'); | ||
| 5815 | $hBox2->pack_start($label2, FALSE, FALSE, $self->spacingPixels); | ||
| 5816 | |||
| 5817 | my $entry2 = Gtk3::Entry->new(); | ||
| 5818 | $hBox2->pack_start($entry2, TRUE, TRUE, 0); | ||
| 5819 | $entry2->set_tooltip_text('Append this to every world command'); | ||
| 5820 | |||
| 5821 | # Third strip | ||
| 5822 | my $hBox3 = Gtk3::HBox->new(FALSE, 0); | ||
| 5823 | $packingBox->pack_end($hBox3, FALSE, FALSE, $self->spacingPixels); | ||
| 5824 | |||
| 5825 | my $okButton = Gtk3::Button->new('Send'); | ||
| 5826 | $hBox3->pack_start($okButton, TRUE, TRUE, 0); | ||
| 5827 | |||
| 5828 | my $clearButton = Gtk3::Button->new('Send and clear text'); | ||
| 5829 | $hBox3->pack_start($clearButton, FALSE, FALSE, $self->spacingPixels); | ||
| 5830 | $clearButton->get_child->set_width_chars(20); | ||
| 5831 | |||
| 5832 | my $closeButton = Gtk3::Button->new('Close window'); | ||
| 5833 | $hBox3->pack_start($closeButton, FALSE, FALSE, 0); | ||
| 5834 | $closeButton->get_child->set_width_chars(15); | ||
| 5835 | |||
| 5836 | # ->signal_connects for the buttons | ||
| 5837 | $radioButton->signal_connect('toggled' => sub { | ||
| 5838 | |||
| 5839 | if ($radioButton->get_active()) { | ||
| 5840 | |||
| 5841 | $checkButton->set_sensitive(TRUE); | ||
| 5842 | |||
| 5843 | $entry->set_sensitive(TRUE); | ||
| 5844 | $entry2->set_sensitive(TRUE); | ||
| 5845 | |||
| 5846 | $okButton->set_label('Send'); | ||
| 5847 | $clearButton->set_label(' Send and clear text '); | ||
| 5848 | } | ||
| 5849 | }); | ||
| 5850 | |||
| 5851 | $radioButton2->signal_connect('toggled' => sub { | ||
| 5852 | |||
| 5853 | if ($radioButton2->get_active()) { | ||
| 5854 | |||
| 5855 | $checkButton->set_active(FALSE); | ||
| 5856 | $checkButton->set_sensitive(FALSE); | ||
| 5857 | |||
| 5858 | $entry->set_sensitive(FALSE); | ||
| 5859 | $entry->set_text(''); | ||
| 5860 | $entry2->set_sensitive(FALSE); | ||
| 5861 | $entry2->set_text(''); | ||
| 5862 | |||
| 5863 | $okButton->set_label('Run'); | ||
| 5864 | $clearButton->set_label(' Run and clear text '); | ||
| 5865 | } | ||
| 5866 | }); | ||
| 5867 | |||
| 5868 | $okButton->signal_connect('clicked' => sub { | ||
| 5869 | |||
| 5870 | if ($radioButton->get_active()) { | ||
| 5871 | |||
| 5872 | # Execute instructions | ||
| 5873 | $self->executeInstructions( | ||
| 5874 | $axmud::CLIENT->desktopObj->bufferGetText($buffer), | ||
| 5875 | $entry->get_text(), | ||
| 5876 | $entry2->get_text(), | ||
| 5877 | $checkButton->get_active(), | ||
| 5878 | ); | ||
| 5879 | |||
| 5880 | } else { | ||
| 5881 | |||
| 5882 | # Save the script as a temporary file, and execute it | ||
| 5883 | $self->runScript($axmud::CLIENT->desktopObj->bufferGetText($buffer)); | ||
| 5884 | } | ||
| 5885 | }); | ||
| 5886 | |||
| 5887 | $clearButton->signal_connect('clicked' => sub { | ||
| 5888 | |||
| 5889 | if ($radioButton->get_active()) { | ||
| 5890 | |||
| 5891 | # Execute instructions | ||
| 5892 | $self->executeInstructions( | ||
| 5893 | $axmud::CLIENT->desktopObj->bufferGetText($buffer), | ||
| 5894 | $entry->get_text(), | ||
| 5895 | $entry2->get_text(), | ||
| 5896 | $checkButton->get_active(), | ||
| 5897 | ); | ||
| 5898 | |||
| 5899 | } else { | ||
| 5900 | |||
| 5901 | # Save the script as a temporary file, and execute it | ||
| 5902 | $self->runScript($axmud::CLIENT->desktopObj->bufferGetText($buffer)); | ||
| 5903 | } | ||
| 5904 | |||
| 5905 | $buffer->set_text(''); | ||
| 5906 | }); | ||
| 5907 | |||
| 5908 | $closeButton->signal_connect('clicked' => sub { | ||
| 5909 | |||
| 5910 | $self->winDestroy(); | ||
| 5911 | }); | ||
| 5912 | |||
| 5913 | # Update IVs (not worth storing widgets other than the main packing box) | ||
| 5914 | $self->ivPoke('packingBox', $packingBox); | ||
| 5915 | |||
| 5916 | return 1; | ||
| 5917 | } | ||
| 5918 | |||
| 5919 | # sub redrawWidgets {} # Inherited from GA::Generic::Win | ||
| 5920 | |||
| 5921 | # ->signal_connects | ||
| 5922 | |||
| 5923 | # Other functions | ||
| 5924 | |||
| 5925 | sub executeInstructions { | ||
| 5926 | |||
| 5927 | # Called by $self->drawWidgets when the user clicks the 'Send' button | ||
| 5928 | # Executes the contents of the window as instructions, one line at a time | ||
| 5929 | # | ||
| 5930 | # Expected arguments | ||
| 5931 | # $text - The contents of the Gtk3::TextBuffer | ||
| 5932 | # $preText - Text to prepend to any world commands (or an empty string) | ||
| 5933 | # $postText - Text to append to any world commands (or an empty string) | ||
| 5934 | # $ignoreFlag - TRUE if empty lines should be ignored, FALSE if they should be used (as | ||
| 5935 | # world commands) | ||
| 5936 | # | ||
| 5937 | # Return values | ||
| 5938 | # 'undef' on improper arguments | ||
| 5939 | # 1 otherwise | ||
| 5940 | |||
| 5941 | my ($self, $text, $preText, $postText, $ignoreFlag, $check) = @_; | ||
| 5942 | |||
| 5943 | # Local variables | ||
| 5944 | my (@cmdList, @finalList); | ||
| 5945 | |||
| 5946 | # Check for improper arguments | ||
| 5947 | if ( | ||
| 5948 | ! defined $text || ! defined $preText || ! defined $postText || ! defined $ignoreFlag | ||
| 5949 | || defined $check | ||
| 5950 | ) { | ||
| 5951 | return $axmud::CLIENT->writeImproper($self->_objClass . '->executeInstructions', @_); | ||
| 5952 | } | ||
| 5953 | |||
| 5954 | # Split $text into lines | ||
| 5955 | @cmdList = split(/\n/, $text); | ||
| 5956 | |||
| 5957 | # Ignore empty lines, if required | ||
| 5958 | if (! $ignoreFlag) { | ||
| 5959 | |||
| 5960 | @finalList = @cmdList; | ||
| 5961 | |||
| 5962 | } else { | ||
| 5963 | |||
| 5964 | # Remove empty lines | ||
| 5965 | foreach my $cmd (@cmdList) { | ||
| 5966 | |||
| 5967 | if (! ($cmd =~ m/^\s*$/)) { | ||
| 5968 | |||
| 5969 | push (@finalList, $cmd); | ||
| 5970 | } | ||
| 5971 | } | ||
| 5972 | } | ||
| 5973 | |||
| 5974 | # GA::Session->doInstruct expects 'undef' rather than an empty string | ||
| 5975 | if ($preText eq '') { | ||
| 5976 | |||
| 5977 | $preText = undef; | ||
| 5978 | } | ||
| 5979 | |||
| 5980 | if ($postText eq '') { | ||
| 5981 | |||
| 5982 | $postText = undef; | ||
| 5983 | } | ||
| 5984 | |||
| 5985 | # Execute every line as an instruction | ||
| 5986 | foreach my $instruct (@finalList) { | ||
| 5987 | |||
| 5988 | $self->session->doInstruct($instruct, undef, $preText, $postText); | ||
| 5989 | } | ||
| 5990 | |||
| 5991 | return 1; | ||
| 5992 | } | ||
| 5993 | |||
| 5994 | sub runScript { | ||
| 5995 | |||
| 5996 | # Called by $self->drawWidgets when the user clicks the 'Run' button | ||
| 5997 | # Runs the contents of the textview as an Axbasic script | ||
| 5998 | # | ||
| 5999 | # Expected arguments | ||
| 6000 | # $text - The contents of the Gtk3::TextBuffer | ||
| 6001 | # | ||
| 6002 | # Return values | ||
| 6003 | # 'undef' on improper arguments | ||
| 6004 | # 1 otherwise | ||
| 6005 | |||
| 6006 | my ($self, $text, $check) = @_; | ||
| 6007 | |||
| 6008 | # Local variables | ||
| 6009 | my ( | ||
| 6010 | $path, $fileHandle, | ||
| 6011 | @list, | ||
| 6012 | ); | ||
| 6013 | |||
| 6014 | # Check for improper arguments | ||
| 6015 | if (! defined $text || defined $check) { | ||
| 6016 | |||
| 6017 | return $axmud::CLIENT->writeImproper($self->_objClass . '->runScript', @_); | ||
| 6018 | } | ||
| 6019 | |||
| 6020 | # Split $text into lines | ||
| 6021 | @list = split(/\n/, $text); | ||
| 6022 | |||
| 6023 | # Save the script as a temporary file | ||
| 6024 | $path = $axmud::DATA_DIR . '/data/temp/quick.bas'; | ||
| 6025 | |||
| 6026 | # Open the file for writing, overwriting previous contents | ||
| 6027 | if (! open ($fileHandle, ">$path")) { | ||
| 6028 | |||
| 6029 | return undef; | ||
| 6030 | } | ||
| 6031 | |||
| 6032 | foreach my $line (@list) { | ||
| 6033 | |||
| 6034 | $line .= "\n"; | ||
| 6035 | } | ||
| 6036 | |||
| 6037 | print $fileHandle @list; | ||
| 6038 | |||
| 6039 | if (! close $fileHandle) { | ||
| 6040 | |||
| 6041 | return undef; | ||
| 6042 | } | ||
| 6043 | |||
| 6044 | # Run the script | ||
| 6045 | $self->session->pseudoCmd('runscript -p ' . $path, $self->pseudoCmdMode); | ||
| 6046 | |||
| 6047 | # Delete the temporary file | ||
| 6048 | unlink $path; | ||
| 6049 | |||
| 6050 | return 1; | ||
| 6051 | } | ||
| 6052 | |||
| 6053 | ################## | ||
| 6054 | # Accessors - set | ||
| 6055 | |||
| 6056 | ################## | ||
| 6057 | # Accessors - get | ||
| 6058 | } | ||
| 6059 | |||
| 6060 | { package Games::Axmud::OtherWin::QuickWord; | ||
| 6061 | |||
| 6062 | use strict; | ||
| 6063 | use warnings; | ||
| 6064 | use diagnostics; | ||
| 6065 | |||
| 6066 | use Glib qw(TRUE FALSE); | ||
| 6067 | |||
| 6068 | our @ISA = qw( | ||
| 6069 | Games::Axmud::Generic::OtherWin Games::Axmud::Generic::FreeWin Games::Axmud::Generic::Win | ||
| 6070 | Games::Axmud | ||
| 6071 | ); | ||
| 6072 | |||
| 6073 | ################## | ||
| 6074 | # Constructors | ||
| 6075 | |||
| 6076 | sub new { | ||
| 6077 | |||
| 6078 | # Called by GA::Generic::Win->createFreeWin | ||
| 6079 | # Creates a new instance of the Quick Word window (an 'other' window). The window contains | ||
| 6080 | # various widgets for adding words to the current dictionary | ||
| 6081 | # | ||
| 6082 | # Expected arguments | ||
| 6083 | # $number - Unique number for this window object | ||
| 6084 | # $workspaceObj - The GA::Obj::Workspace handling the workspace in which this window | ||
| 6085 | # should be created | ||
| 6086 | # $owner - The owner; a 'grid' window object (but not an 'external' window) or a | ||
| 6087 | # 'free' window object. When this window opens/closes, the owner is | ||
| 6088 | # informed via calls to its ->add_childFreeWin / ->del_childFreeWin | ||
| 6089 | # functions | ||
| 6090 | # | ||
| 6091 | # Optional arguments | ||
| 6092 | # $session - The GA::Session from which this function was called. 'undef' if the | ||
| 6093 | # calling function didn't specify a session and $owner's ->session IV | ||
| 6094 | # is also 'undef' | ||
| 6095 | # $title - Ignored if set (all 'other' windows define their own title) | ||
| 6096 | # $editObj - Ignored if set | ||
| 6097 | # $tempFlag - Ignored if set | ||
| 6098 | # %configHash - Hash containing any number of key-value pairs needed for this | ||
| 6099 | # particular 'other' window; set to an empty hash if not required | ||
| 6100 | # - This type of window object recognises these initialisation settings: | ||
| 6101 | # | ||
| 6102 | # ... | ||
| 6103 | # | ||
| 6104 | # Return values | ||
| 6105 | # 'undef' on improper arguments | ||
| 6106 | # Blessed reference to the newly-created object on success | ||
| 6107 | |||
| 6108 | my ( | ||
| 6109 | $class, $number, $workspaceObj, $owner, $session, $title, $editObj, $tempFlag, | ||
| 6110 | %configHash, | ||
| 6111 | ) = @_; | ||
| 6112 | |||
| 6113 | # Check for improper arguments | ||
| 6114 | if (! defined $class || ! defined $number || ! defined $workspaceObj || ! defined $owner) { | ||
| 6115 | |||
| 6116 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 6117 | } | ||
| 6118 | |||
| 6119 | # Setup | ||
| 6120 | my $self = { | ||
| 6121 | _objName => 'other_win_' . $number, | ||
| 6122 | _objClass => $class, | ||
| 6123 | _parentFile => undef, # No parent file object | ||
| 6124 | _parentWorld => undef, # No parent file object | ||
| 6125 | _privFlag => TRUE, # All IVs are private | ||
| 6126 | |||
| 6127 | # Standard window object IVs | ||
| 6128 | # -------------------------- | ||
| 6129 | |||
| 6130 | # Unique number for this window object | ||
| 6131 | number => $number, | ||
| 6132 | # The window category - 'grid' or 'free' | ||
| 6133 | winCategory => 'free', | ||
| 6134 | # The window type, any of the keys in GA::Client->constFreeWinTypeHash | ||
| 6135 | winType => 'other', | ||
| 6136 | # A name for the window (can be unique to this type of window object, or can be the | ||
| 6137 | # same as ->winType) | ||
| 6138 | winName => 'quick_word', | ||
| 6139 | # The GA::Obj::Workspace object for the workspace in which this window is created | ||
| 6140 | workspaceObj => $workspaceObj, | ||
| 6141 | # The owner; a 'grid' window object (but not an 'external' window) or a 'free' window | ||
| 6142 | # object. When this window opens/closes, the owner is informed via calls to its | ||
| 6143 | # ->add_childFreeWin / ->del_childFreeWin functions | ||
| 6144 | owner => $owner, | ||
| 6145 | # The GA::Session from which this function was called. 'undef' if the calling function | ||
| 6146 | # didn't specify a session and $owner's ->session IV is also 'undef' | ||
| 6147 | session => $session, | ||
| 6148 | # When GA::Session->pseudoCmd is called to execute a client command, the mode in which | ||
| 6149 | # it should be called (usually 'win_error' or 'win_only', which causes errors to be | ||
| 6150 | # displayed in a 'dialogue' window) | ||
| 6151 | pseudoCmdMode => 'win_error', | ||
| 6152 | |||
| 6153 | # The window widget. For most window objects, the Gtk3::Window. For pseudo-windows, the | ||
| 6154 | # parent 'main' window's Gtk3::Window | ||
| 6155 | # The code should use this IV when it wants to do something to the window itself | ||
| 6156 | # (minimise it, make it active, etc) | ||
| 6157 | winWidget => undef, | ||
| 6158 | # The window container. For most window objects, the Gtk3::Window. For pseudo-windows, | ||
| 6159 | # the parent GA::Table::PseudoWin table object | ||
| 6160 | # The code should use this IV when it wants to add, modify or remove widgets inside the | ||
| 6161 | # window itself | ||
| 6162 | winBox => undef, | ||
| 6163 | # Flag set to TRUE if the window actually exists (after a call to $self->winEnable), | ||
| 6164 | # FALSE if not | ||
| 6165 | enabledFlag => FALSE, | ||
| 6166 | # Flag set to TRUE if the Gtk3 window itself is visible (after a call to | ||
| 6167 | # $self->setVisible), FALSE if it is not visible (after a call to $self->setInvisible) | ||
| 6168 | visibleFlag => TRUE, | ||
| 6169 | # Registry hash of 'free' windows (excluding 'dialogue' windows) for which this window | ||
| 6170 | # is the parent, a subset of GA::Obj::Desktop->freeWinHash. Hash in the form | ||
| 6171 | # $childFreeWinHash{unique_number} = blessed_reference_to_window_object | ||
| 6172 | childFreeWinHash => {}, | ||
| 6173 | # When a child 'free' window (excluding 'dialogue' windows) is destroyed, this parent | ||
| 6174 | # window is informed via a call to $self->del_childFreeWin | ||
| 6175 | # When the child is destroyed, this window might want to call some of its own functions | ||
| 6176 | # to update various widgets and/or IVs, in which case this window adds an entry to | ||
| 6177 | # this hash; a hash in the form | ||
| 6178 | # $childDestroyHash{unique_number} = list_reference | ||
| 6179 | # ...where 'unique_number' is the child window's ->number, and 'list_reference' is a | ||
| 6180 | # reference to a list in groups of 2, in the form | ||
| 6181 | # (sub_name, argument_list_ref, sub_name, argument_list_ref...) | ||
| 6182 | childDestroyHash => {}, | ||
| 6183 | |||
| 6184 | # The container widget into which all other widgets are packed (usually a Gtk3::VBox or | ||
| 6185 | # Gtk3::HBox, but any container widget can be used; takes up the whole window client | ||
| 6186 | # area) | ||
| 6187 | packingBox => undef, # Gtk3::VBox | ||
| 6188 | |||
| 6189 | # Standard IVs for 'free' windows | ||
| 6190 | |||
| 6191 | # The window's default size, in pixels | ||
| 6192 | # (Actual width/height will be more, in order to fit in all the packed widgets) | ||
| 6193 | widthPixels => int($axmud::CLIENT->constFreeWinWidth * 0.33), | ||
| 6194 | heightPixels => int($axmud::CLIENT->constFreeWinHeight * 0.33), | ||
| 6195 | # Default border/item spacing sizes used in the window, in pixels | ||
| 6196 | borderPixels => $axmud::CLIENT->constFreeBorderPixels, | ||
| 6197 | spacingPixels => $axmud::CLIENT->constFreeSpacingPixels, | ||
| 6198 | |||
| 6199 | # A string to use as the window title | ||
| 6200 | title => $title, | ||
| 6201 | # Hash containing any number of key-value pairs needed for this particular 'config' | ||
| 6202 | # window; for example, for example, GA::PrefWin::TaskStart uses it to specify a task | ||
| 6203 | # name and type. Set to an empty hash if not required | ||
| 6204 | configHash => {%configHash}, | ||
| 6205 | }; | ||
| 6206 | |||
| 6207 | # Bless the object into existence | ||
| 6208 | bless $self, $class; | ||
| 6209 | |||
| 6210 | return $self; | ||
| 6211 | } | ||
| 6212 | |||
| 6213 | ################## | ||
| 6214 | # Methods | ||
| 6215 | |||
| 6216 | # Standard window object functions | ||
| 6217 | |||
| 6218 | # sub winSetup {} # Inherited from GA::Generic::FreeWin | ||
| 6219 | |||
| 6220 | # sub winEnable {} # Inherited from GA::Generic::FreeWin | ||
| 6221 | |||
| 6222 | # sub winDesengage {} # Inherited from GA::Generic::FreeWin | ||
| 6223 | |||
| 6224 | # sub winDestroy {} # Inherited from GA::Generic::FreeWin | ||
| 6225 | |||
| 6226 | # sub winShowAll {} # Inherited from GA::Generic::Win | ||
| 6227 | |||
| 6228 | sub drawWidgets { | ||
| 6229 | |||
| 6230 | # Called by $self->winSetup | ||
| 6231 | # Sets up the Gtk3::Window by drawing the window's widgets | ||
| 6232 | # | ||
| 6233 | # Expected arguments | ||
| 6234 | # (none besides $self) | ||
| 6235 | # | ||
| 6236 | # Return values | ||
| 6237 | # 'undef' on improper arguments | ||
| 6238 | # 1 otherwise | ||
| 6239 | |||
| 6240 | my ($self, $check) = @_; | ||
| 6241 | |||
| 6242 | # Local variables | ||
| 6243 | my ( | ||
| 6244 | $spacing, $dictObj, $comboBoxCount, | ||
| 6245 | @currentRoomList, @typeList, | ||
| 6246 | ); | ||
| 6247 | |||
| 6248 | # Check for improper arguments | ||
| 6249 | if (defined $check) { | ||
| 6250 | |||
| 6251 | return $axmud::CLIENT->writeImproper($self->_objClass . '->drawWidgets', @_); | ||
| 6252 | } | ||
| 6253 | |||
| 6254 | # Standard spacing | ||
| 6255 | $spacing = $axmud::CLIENT->constFreeSpacingPixels; | ||
| 6256 | # Import the current Locator task (if any) and current dictionary | ||
| 6257 | $dictObj = $self->session->currentDict; | ||
| 6258 | |||
| 6259 | # A list of word types in the order they'll appear in their combobox | ||
| 6260 | @typeList = ( | ||
| 6261 | 'sentient', | ||
| 6262 | 'creature', | ||
| 6263 | 'portable', | ||
| 6264 | 'decoration', | ||
| 6265 | 'race', | ||
| 6266 | 'guild', | ||
| 6267 | 'weapon', | ||
| 6268 | 'armour', | ||
| 6269 | 'garment', | ||
| 6270 | 'adjective', | ||
| 6271 | 'pseudo-noun', | ||
| 6272 | 'pseudo-adjective', | ||
| 6273 | 'pseudo-object', | ||
| 6274 | ); | ||
| 6275 | |||
| 6276 | # Create a packing box | ||
| 6277 | my $packingBox = Gtk3::VBox->new(FALSE, 0); | ||
| 6278 | $self->winBox->add($packingBox); | ||
| 6279 | $packingBox->set_border_width(0); | ||
| 6280 | |||
| 6281 | # Create an image on the left | ||
| 6282 | my $hBox = Gtk3::HBox->new(FALSE, $spacing); | ||
| 6283 | $packingBox->pack_start($hBox, FALSE, FALSE, 0); | ||
| 6284 | |||
| 6285 | my $vBox = Gtk3::VBox->new(FALSE, 0); | ||
| 6286 | $hBox->pack_start($vBox, FALSE, FALSE, 0); | ||
| 6287 | |||
| 6288 | my $frame = Gtk3::Frame->new(undef); | ||
| 6289 | $vBox->pack_start($frame, FALSE, FALSE, 0); | ||
| 6290 | $frame->set_size_request(64, 64); | ||
| 6291 | $frame->set_shadow_type($axmud::CLIENT->constShadowType); | ||
| 6292 | |||
| 6293 | my $image = Gtk3::Image->new_from_file($axmud::CLIENT->getDialogueIcon()); | ||
| 6294 | $frame->add($image); | ||
| 6295 | |||
| 6296 | # Create a VBox on the right, full of editing widgets | ||
| 6297 | my $vBox2 = Gtk3::VBox->new(FALSE, $spacing); | ||
| 6298 | $hBox->pack_start($vBox2, FALSE, FALSE, 0); | ||
| 6299 | |||
| 6300 | # Add three radio buttons and an entry box/combo for each (->signal_connects follow) | ||
| 6301 | my $radioButton = Gtk3::RadioButton->new_with_label(undef, 'Enter a word...'); | ||
| 6302 | my $radioGroup = $radioButton->get_group(); | ||
| 6303 | $vBox2->pack_start($radioButton, FALSE, FALSE, 0); | ||
| 6304 | |||
| 6305 | my $entry = Gtk3::Entry->new(); | ||
| 6306 | $vBox2->pack_start($entry, FALSE, FALSE, 0); | ||
| 6307 | |||
| 6308 | my $radioButton2 = Gtk3::RadioButton->new_with_label( | ||
| 6309 | $radioGroup, | ||
| 6310 | '...or select a word from the current room...', | ||
| 6311 | ); | ||
| 6312 | $vBox2->pack_start($radioButton2, FALSE, FALSE, 0); | ||
| 6313 | |||
| 6314 | my $comboBox = Gtk3::ComboBoxText->new(); | ||
| 6315 | $vBox2->pack_start($comboBox, FALSE, FALSE, 0); | ||
| 6316 | $comboBox->set_active(0); | ||
| 6317 | # Starts desensitised | ||
| 6318 | $comboBox->set_sensitive(FALSE); | ||
| 6319 | |||
| 6320 | my $radioButton3 = Gtk3::RadioButton->new_with_label( | ||
| 6321 | $radioGroup, | ||
| 6322 | '...or select an unknown word', | ||
| 6323 | ); | ||
| 6324 | $vBox2->pack_start($radioButton3, FALSE, FALSE, 0); | ||
| 6325 | |||
| 6326 | my $comboBox2 = Gtk3::ComboBoxText->new(); | ||
| 6327 | $vBox2->pack_start($comboBox2, FALSE, FALSE, 0); | ||
| 6328 | $comboBox2->set_active(0); | ||
| 6329 | # Starts desensitised | ||
| 6330 | $comboBox2->set_sensitive(FALSE); | ||
| 6331 | |||
| 6332 | my $separator = Gtk3::HSeparator->new(); | ||
| 6333 | $vBox2->pack_start($separator, FALSE, FALSE, 0); | ||
| 6334 | |||
| 6335 | # Add a fourth widget group, comboboxes to select the types of word | ||
| 6336 | my $label = Gtk3::Label->new('What kind of word is this?'); | ||
| 6337 | $vBox2->pack_start($label, FALSE, FALSE, 0); | ||
| 6338 | $label->set_alignment(0, 0.5); | ||
| 6339 | |||
| 6340 | my $hBox2 = Gtk3::HBox->new(FALSE, 0); | ||
| 6341 | $vBox2->pack_start($hBox2, FALSE, FALSE, 5); | ||
| 6342 | |||
| 6343 | my $comboBox3 = Gtk3::ComboBoxText->new(); | ||
| 6344 | $hBox2->pack_start($comboBox3, TRUE, TRUE, 0); | ||
| 6345 | foreach my $type (@typeList) { | ||
| 6346 | |||
| 6347 | $comboBox3->append_text($type); | ||
| 6348 | } | ||
| 6349 | $comboBox3->set_active(0); | ||
| 6350 | |||
| 6351 | my $comboBox4 = Gtk3::ComboBoxText->new(); | ||
| 6352 | $hBox2->pack_end($comboBox4, TRUE, TRUE, 0); | ||
| 6353 | $comboBox4->set_active(0); | ||
| 6354 | $comboBox4->set_sensitive(FALSE); | ||
| 6355 | |||
| 6356 | # And a fifth group to specify replacement strings for pseudo nouns, adjectives and objects | ||
| 6357 | my $label2 = Gtk3::Label->new('Replacement string (if any)'); | ||
| 6358 | $vBox2->pack_start($label2, FALSE, FALSE, 0); | ||
| 6359 | $label2->set_alignment(0, 0.5); | ||
| 6360 | |||
| 6361 | my $entry2 = Gtk3::Entry->new(); | ||
| 6362 | $vBox2->pack_start($entry2, FALSE, FALSE, 0); | ||
| 6363 | # Entry starts insensitive | ||
| 6364 | $entry2->set_sensitive(FALSE); | ||
| 6365 | |||
| 6366 | my $separator2 = Gtk3::HSeparator->new(); | ||
| 6367 | $vBox2->pack_start($separator2, FALSE, FALSE, 0); | ||
| 6368 | |||
| 6369 | # Finally, at buttons at the bottom of the window | ||
| 6370 | my $label3 = Gtk3::Label->new(''); | ||
| 6371 | $vBox2->pack_start($label3, FALSE, FALSE, 0); | ||
| 6372 | $label3->set_alignment(0, 0.5); | ||
| 6373 | |||
| 6374 | my $hBox3 = Gtk3::HBox->new(FALSE, 0); | ||
| 6375 | $vBox2->pack_start($hBox3, FALSE, FALSE, $self->spacingPixels); | ||
| 6376 | |||
| 6377 | my $button = Gtk3::Button->new('Add word'); | ||
| 6378 | $hBox3->pack_start($button, TRUE, TRUE, 0); | ||
| 6379 | $button->set_tooltip_text('Add this word'); | ||
| 6380 | |||
| 6381 | my $button2 = Gtk3::Button->new('Ignore word'); | ||
| 6382 | $hBox3->pack_start($button2, TRUE, TRUE, 0); | ||
| 6383 | $button2->set_sensitive(FALSE); # Starts desensitised | ||
| 6384 | $button2->set_tooltip_text('Ignore (don\'t use) this word'); | ||
| 6385 | |||
| 6386 | my $button3 = Gtk3::Button->new('Refresh'); | ||
| 6387 | $hBox3->pack_start($button3, TRUE, TRUE, 0); | ||
| 6388 | $button3->signal_connect('clicked' => sub { | ||
| 6389 | |||
| 6390 | $self->refreshCombos($dictObj, $comboBox, $comboBox2); | ||
| 6391 | }); | ||
| 6392 | |||
| 6393 | my $button4 = Gtk3::Button->new('Close'); | ||
| 6394 | $hBox3->pack_end($button4, TRUE, TRUE, 0); | ||
| 6395 | $button4->signal_connect('clicked' => sub { | ||
| 6396 | |||
| 6397 | $self->winDestroy(); | ||
| 6398 | }); | ||
| 6399 | $button4->set_tooltip_text('Close the window'); | ||
| 6400 | |||
| 6401 | # Set the initial contents of the first two comboboxes | ||
| 6402 | $self->refreshCombos($dictObj, $comboBox, $comboBox2); | ||
| 6403 | |||
| 6404 | # ->signal_connects | ||
| 6405 | |||
| 6406 | # Radio buttons. Toggling them sensitises/desensitises the first three widgets | ||
| 6407 | $radioButton->signal_connect('toggled' => sub { | ||
| 6408 | |||
| 6409 | if ($radioButton->get_active()) { | ||
| 6410 | |||
| 6411 | $entry->set_sensitive(TRUE); | ||
| 6412 | $comboBox->set_sensitive(FALSE); | ||
| 6413 | $comboBox2->set_sensitive(FALSE); | ||
| 6414 | $button2->set_sensitive(FALSE); | ||
| 6415 | } | ||
| 6416 | }); | ||
| 6417 | |||
| 6418 | $radioButton2->signal_connect('toggled' => sub { | ||
| 6419 | |||
| 6420 | if ($radioButton2->get_active()) { | ||
| 6421 | |||
| 6422 | $entry->set_sensitive(FALSE); | ||
| 6423 | $comboBox->set_sensitive(TRUE); | ||
| 6424 | $comboBox2->set_sensitive(FALSE); | ||
| 6425 | $button2->set_sensitive(FALSE); | ||
| 6426 | } | ||
| 6427 | }); | ||
| 6428 | |||
| 6429 | $radioButton3->signal_connect('toggled' => sub { | ||
| 6430 | |||
| 6431 | if ($radioButton3->get_active()) { | ||
| 6432 | |||
| 6433 | $entry->set_sensitive(FALSE); | ||
| 6434 | $comboBox->set_sensitive(FALSE); | ||
| 6435 | $comboBox2->set_sensitive(TRUE); | ||
| 6436 | $button2->set_sensitive(TRUE); | ||
| 6437 | } | ||
| 6438 | }); | ||
| 6439 | |||
| 6440 | # Fourth group | ||
| 6441 | $comboBox3->signal_connect('changed' => sub { | ||
| 6442 | |||
| 6443 | my $type = $comboBox3->get_active_text(); | ||
| 6444 | if ($type) { | ||
| 6445 | |||
| 6446 | # Empty the 'type of portable/decoration' combobox, in case we need to refill it | ||
| 6447 | if ($comboBoxCount) { | ||
| 6448 | |||
| 6449 | for (my $count = ($comboBoxCount - 1); $count >= 0; $count--) { | ||
| 6450 | |||
| 6451 | $comboBox4->remove_text($count); | ||
| 6452 | } | ||
| 6453 | } | ||
| 6454 | |||
| 6455 | # Refill the lower combobox, if necessary | ||
| 6456 | if ($type eq 'portable') { | ||
| 6457 | |||
| 6458 | foreach my $custom ($dictObj->portableTypeList) { | ||
| 6459 | |||
| 6460 | $comboBox4->append_text($custom); | ||
| 6461 | } | ||
| 6462 | |||
| 6463 | $comboBox4->set_active(0); | ||
| 6464 | $comboBox4->set_sensitive(TRUE); | ||
| 6465 | $comboBoxCount = scalar $dictObj->portableTypeList; | ||
| 6466 | |||
| 6467 | } elsif ($type eq 'decoration') { | ||
| 6468 | |||
| 6469 | foreach my $custom ($dictObj->decorationTypeList) { | ||
| 6470 | |||
| 6471 | $comboBox4->append_text($custom); | ||
| 6472 | } | ||
| 6473 | |||
| 6474 | $comboBox4->set_active(0); | ||
| 6475 | $comboBox4->set_sensitive(TRUE); | ||
| 6476 | $comboBoxCount = scalar $dictObj->decorationTypeList; | ||
| 6477 | |||
| 6478 | } else { | ||
| 6479 | |||
| 6480 | # If it's not a portable or decoration, the lower combobox must be insensitive | ||
| 6481 | $comboBox4->set_sensitive(FALSE); | ||
| 6482 | $comboBoxCount = 0; | ||
| 6483 | } | ||
| 6484 | |||
| 6485 | if ( | ||
| 6486 | $type eq 'pseudo-noun' | ||
| 6487 | || $type eq 'pseudo-adjective' | ||
| 6488 | || $type eq 'pseudo-object' | ||
| 6489 | ) { | ||
| 6490 | # Make the replacement string entry sensitive | ||
| 6491 | $entry2->set_sensitive(TRUE); | ||
| 6492 | |||
| 6493 | } else { | ||
| 6494 | |||
| 6495 | # Empty the box and make it insensitive | ||
| 6496 | $entry2->set_text(''); | ||
| 6497 | $entry2->set_sensitive(FALSE); | ||
| 6498 | } | ||
| 6499 | } | ||
| 6500 | }); | ||
| 6501 | |||
| 6502 | # 'Add word' button | ||
| 6503 | $button->signal_connect('clicked' => sub { | ||
| 6504 | |||
| 6505 | my ( | ||
| 6506 | $word, $wordType, $category, $replace, $cmd, $result, $msg, | ||
| 6507 | @newList, | ||
| 6508 | ); | ||
| 6509 | |||
| 6510 | # Get the word to add | ||
| 6511 | if ($radioButton->get_active()) { | ||
| 6512 | $word = $entry->get_text(); | ||
| 6513 | } elsif ($radioButton2->get_active()) { | ||
| 6514 | $word = $comboBox->get_active_text(); | ||
| 6515 | } elsif ($radioButton3->get_active()) { | ||
| 6516 | $word = $comboBox2->get_active_text(); | ||
| 6517 | } | ||
| 6518 | |||
| 6519 | # Get the type of word, and the category (for portables/decorations) | ||
| 6520 | $wordType = $comboBox3->get_active_text(); | ||
| 6521 | $category = $comboBox4->get_active_text(); | ||
| 6522 | |||
| 6523 | # Get the replacement string for pseudos | ||
| 6524 | $replace = $entry2->get_text(); | ||
| 6525 | |||
| 6526 | if ($word && $wordType) { | ||
| 6527 | |||
| 6528 | # Prepare the client command to use | ||
| 6529 | $cmd = 'addword '; | ||
| 6530 | |||
| 6531 | if ($wordType eq 'sentient') { | ||
| 6532 | $cmd .= '-s <' . $word . '>'; | ||
| 6533 | } elsif ($wordType eq 'creature') { | ||
| 6534 | $cmd .= '-k <' . $word . '>'; | ||
| 6535 | } elsif ($wordType eq 'race') { | ||
| 6536 | $cmd .= '-r <' . $word . '>'; | ||
| 6537 | } elsif ($wordType eq 'guild') { | ||
| 6538 | $cmd .= '-g <' . $word . '>'; | ||
| 6539 | } elsif ($wordType eq 'weapon') { | ||
| 6540 | $cmd .= '-w <' . $word . '>'; | ||
| 6541 | } elsif ($wordType eq 'armour') { | ||
| 6542 | $cmd .= '-a <' . $word . '>'; | ||
| 6543 | } elsif ($wordType eq 'garment') { | ||
| 6544 | $cmd .= '-e <' . $word . '>'; | ||
| 6545 | } elsif ($wordType eq 'adjective') { | ||
| 6546 | $cmd .= '-j <' . $word . '>'; | ||
| 6547 | } elsif ($wordType eq 'portable' && $category) { | ||
| 6548 | $cmd .= '-p <' . $word . '> <' . $category . '>'; | ||
| 6549 | } elsif ($wordType eq 'decoration' && $category) { | ||
| 6550 | $cmd .= '-d <' . $word . '> <' . $category . '>'; | ||
| 6551 | } elsif ($wordType eq 'pseudo-noun' && $replace) { | ||
| 6552 | |||
| 6553 | # Replacement string compulsory for pseudo-nouns | ||
| 6554 | $cmd .= '-x <' . $replace . '> <' . $word . '>'; | ||
| 6555 | |||
| 6556 | } elsif ($wordType eq 'pseudo-adjective') { | ||
| 6557 | |||
| 6558 | # Replacement optional for pseudo-adjectives | ||
| 6559 | $cmd .= '-y <' . $replace . '> <' . $word . '>'; | ||
| 6560 | |||
| 6561 | } elsif ($wordType eq 'pseudo-object') { | ||
| 6562 | |||
| 6563 | # Replacement optional for pseudo-objects | ||
| 6564 | $cmd .= '-v <' . $word . '> <' . $replace . '>'; | ||
| 6565 | } | ||
| 6566 | |||
| 6567 | # Add the word | ||
| 6568 | $result = $self->session->pseudoCmd($cmd, $self->pseudoCmdMode); | ||
| 6569 | |||
| 6570 | # Prepare a confirmation to show in the last Gtk3::Label | ||
| 6571 | if ($result) { | ||
| 6572 | |||
| 6573 | if ($wordType eq 'portable' || $wordType eq 'decoration') { | ||
| 6574 | |||
| 6575 | $msg = '<i>Added ' . $wordType . ' (' . $category . ') \'' . $word | ||
| 6576 | . '\'</i>'; | ||
| 6577 | |||
| 6578 | } else { | ||
| 6579 | |||
| 6580 | $msg = '<i>Added ' . $wordType . ' \'' . $word . '\'</i>'; | ||
| 6581 | } | ||
| 6582 | |||
| 6583 | } else { | ||
| 6584 | |||
| 6585 | $msg = '<i>Failed to add ' . $wordType . ' \'' . $word . '\'</i>'; | ||
| 6586 | } | ||
| 6587 | |||
| 6588 | } else { | ||
| 6589 | |||
| 6590 | # Clear the confirmation label | ||
| 6591 | $msg = ''; | ||
| 6592 | } | ||
| 6593 | |||
| 6594 | # Show the confirmation message | ||
| 6595 | $label3->set_markup($msg); | ||
| 6596 | |||
| 6597 | if ($result) { | ||
| 6598 | |||
| 6599 | # If we've just added a word from the room, it should be removed from the combo | ||
| 6600 | # If we've just added an unknown word, the dictionary's list of unknown words will | ||
| 6601 | # have changed. Update the combo | ||
| 6602 | if ( | ||
| 6603 | $radioButton2->get_active() | ||
| 6604 | || $radioButton3->get_active() | ||
| 6605 | ) { | ||
| 6606 | $self->refreshCombos($dictObj, $comboBox, $comboBox2); | ||
| 6607 | } | ||
| 6608 | } | ||
| 6609 | }); | ||
| 6610 | |||
| 6611 | # 'Ignore word' button | ||
| 6612 | $button2->signal_connect('clicked' => sub { | ||
| 6613 | |||
| 6614 | my $word = $comboBox2->get_active_text(); | ||
| 6615 | if ($word) { | ||
| 6616 | |||
| 6617 | $label3->set_markup('Ignoring \'' . $word . '\''); | ||
| 6618 | |||
| 6619 | # Remove this word from the current dictionary's unknown word collection | ||
| 6620 | $self->session->currentDict->ivDelete('unknownWordHash', $word); | ||
| 6621 | |||
| 6622 | # Update the combos | ||
| 6623 | $self->refreshCombos($dictObj, $comboBox, $comboBox2); | ||
| 6624 | } | ||
| 6625 | }); | ||
| 6626 | |||
| 6627 | # Update IVs (not worth storing widgets other than the main packing box) | ||
| 6628 | $self->ivPoke('packingBox', $packingBox); | ||
| 6629 | |||
| 6630 | return 1; | ||
| 6631 | } | ||
| 6632 | |||
| 6633 | # sub redrawWidgets {} # Inherited from GA::Generic::Win | ||
| 6634 | |||
| 6635 | # ->signal_connects | ||
| 6636 | |||
| 6637 | # Other functions | ||
| 6638 | |||
| 6639 | sub refreshCombos { | ||
| 6640 | |||
| 6641 | # Called by $self->drawWidgets | ||
| 6642 | # Refreshes the contents of the first two comboboxes | ||
| 6643 | # | ||
| 6644 | # Expected arguments | ||
| 6645 | # $dictObj - The current dictionary | ||
| 6646 | # $comboBox, $comboBox2 | ||
| 6647 | # - The comboboxes to refresh | ||
| 6648 | # | ||
| 6649 | # Return values | ||
| 6650 | # 'undef' on improper arguments | ||
| 6651 | # 1 otherwise | ||
| 6652 | |||
| 6653 | my ($self, $dictObj, $comboBox, $comboBox2, $check) = @_; | ||
| 6654 | |||
| 6655 | # Local variables | ||
| 6656 | my ( | ||
| 6657 | $taskObj, | ||
| 6658 | @unknownList, @collectedList, | ||
| 6659 | %wordHash, | ||
| 6660 | ); | ||
| 6661 | |||
| 6662 | # Check for improper arguments | ||
| 6663 | if (! defined $dictObj || ! defined $comboBox || ! defined $comboBox2 || defined $check) { | ||
| 6664 | |||
| 6665 | return $axmud::CLIENT->writeImproper($self->_objClass . '->refreshCombos', @_); | ||
| 6666 | } | ||
| 6667 | |||
| 6668 | # Import the current Locator task (if any) | ||
| 6669 | $taskObj = $self->session->locatorTask; | ||
| 6670 | |||
| 6671 | # Compile a list of words (which aren't already in the dictionary) from objects in the | ||
| 6672 | # Locator task's current room | ||
| 6673 | if ( | ||
| 6674 | $taskObj | ||
| 6675 | && $taskObj->roomObj | ||
| 6676 | && $taskObj->roomObj->tempObjList | ||
| 6677 | ) { | ||
| 6678 | OUTER: foreach my $obj ($taskObj->roomObj->tempObjList) { | ||
| 6679 | |||
| 6680 | my @wordList; | ||
| 6681 | |||
| 6682 | push (@wordList, | ||
| 6683 | $obj->noun, | ||
| 6684 | $obj->otherNounList, | ||
| 6685 | $obj->adjList, | ||
| 6686 | $obj->pseudoAdjList, | ||
| 6687 | $obj->unknownWordList, | ||
| 6688 | ); | ||
| 6689 | |||
| 6690 | foreach my $word (@wordList) { | ||
| 6691 | |||
| 6692 | # If the word isn't in the current dictionary, mark it to be added to the | ||
| 6693 | # combobox. Use a hash to eliminate duplicates | ||
| 6694 | if ( | ||
| 6695 | ! $dictObj->ivExists('combNounHash', $word) | ||
| 6696 | && ! $dictObj->ivExists('combAdjHash', $word) | ||
| 6697 | ) { | ||
| 6698 | $wordHash{$word} = undef; | ||
| 6699 | } | ||
| 6700 | } | ||
| 6701 | } | ||
| 6702 | |||
| 6703 | # Convert the hash to a sorted list | ||
| 6704 | @unknownList = sort {lc($a) cmp lc($b)} (keys %wordHash); | ||
| 6705 | } | ||
| 6706 | |||
| 6707 | # Import the list of unknown words collected by the Locator task and stored in the current | ||
| 6708 | # dictionary | ||
| 6709 | @collectedList = sort {lc($a) cmp lc($b)} ($dictObj->ivKeys('unknownWordHash')); | ||
| 6710 | |||
| 6711 | # Refresh the combos | ||
| 6712 | my $treeModel = $comboBox->get_model(); | ||
| 6713 | $treeModel->clear(); | ||
| 6714 | |||
| 6715 | foreach my $item (@unknownList) { | ||
| 6716 | |||
| 6717 | $comboBox->append_text($item); | ||
| 6718 | } | ||
| 6719 | |||
| 6720 | $comboBox->set_active(0); | ||
| 6721 | |||
| 6722 | my $treeModel2 = $comboBox2->get_model(); | ||
| 6723 | $treeModel2->clear(); | ||
| 6724 | |||
| 6725 | foreach my $item (@collectedList) { | ||
| 6726 | |||
| 6727 | $comboBox2->append_text($item); | ||
| 6728 | } | ||
| 6729 | |||
| 6730 | $comboBox2->set_active(0); | ||
| 6731 | |||
| 6732 | return 1; | ||
| 6733 | } | ||
| 6734 | |||
| 6735 | ################## | ||
| 6736 | # Accessors - set | ||
| 6737 | |||
| 6738 | ################## | ||
| 6739 | # Accessors - get | ||
| 6740 | } | ||
| 6741 | |||
| 6742 | { package Games::Axmud::OtherWin::SessionConsole; | ||
| 6743 | |||
| 6744 | use strict; | ||
| 6745 | use warnings; | ||
| 6746 | use diagnostics; | ||
| 6747 | |||
| 6748 | use Glib qw(TRUE FALSE); | ||
| 6749 | |||
| 6750 | our @ISA = qw( | ||
| 6751 | Games::Axmud::OtherWin::ClientConsole Games::Axmud::Generic::OtherWin | ||
| 6752 | Games::Axmud::Generic::FreeWin Games::Axmud::Generic::Win Games::Axmud | ||
| 6753 | ); | ||
| 6754 | |||
| 6755 | ################## | ||
| 6756 | # Constructors | ||
| 6757 | |||
| 6758 | sub new { | ||
| 6759 | |||
| 6760 | # Called by GA::Generic::Win->createFreeWin | ||
| 6761 | # Creates a new instance of the Session Console window, which can display system messages | ||
| 6762 | # when it's not possible to display them in the 'main' window | ||
| 6763 | # | ||
| 6764 | # Expected arguments | ||
| 6765 | # $number - Unique number for this window object | ||
| 6766 | # $workspaceObj - The GA::Obj::Workspace handling the workspace in which this window | ||
| 6767 | # should be created | ||
| 6768 | # $owner - The owner; a 'grid' window object (but not an 'external' window) or a | ||
| 6769 | # 'free' window object. When this window opens/closes, the owner is | ||
| 6770 | # informed via calls to its ->add_childFreeWin / ->del_childFreeWin | ||
| 6771 | # functions | ||
| 6772 | # | ||
| 6773 | # Optional arguments | ||
| 6774 | # $session - The GA::Session from which this function was called. 'undef' if the | ||
| 6775 | # calling function didn't specify a session and $owner's ->session IV | ||
| 6776 | # is also 'undef' | ||
| 6777 | # $title - Ignored if set (all 'other' windows define their own title) | ||
| 6778 | # $editObj - Ignored if set | ||
| 6779 | # $tempFlag - Ignored if set | ||
| 6780 | # %configHash - Hash containing any number of key-value pairs needed for this | ||
| 6781 | # particular 'other' window; set to an empty hash if not required | ||
| 6782 | # - This type of window object recognises these initialisation settings: | ||
| 6783 | # | ||
| 6784 | # ... | ||
| 6785 | # | ||
| 6786 | # Return values | ||
| 6787 | # 'undef' on improper arguments | ||
| 6788 | # Blessed reference to the newly-created object on success | ||
| 6789 | |||
| 6790 | my ( | ||
| 6791 | $class, $number, $workspaceObj, $owner, $session, $title, $editObj, $tempFlag, | ||
| 6792 | %configHash, | ||
| 6793 | ) = @_; | ||
| 6794 | |||
| 6795 | # Check for improper arguments | ||
| 6796 | if (! defined $class || ! defined $number || ! defined $workspaceObj || ! defined $owner) { | ||
| 6797 | |||
| 6798 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 6799 | } | ||
| 6800 | |||
| 6801 | # Only one Session Console window can be open per session | ||
| 6802 | if (! $session) { | ||
| 6803 | |||
| 6804 | return undef; | ||
| 6805 | |||
| 6806 | } elsif ($session->consoleWin) { | ||
| 6807 | |||
| 6808 | $session->consoleWin->restoreFocus(); | ||
| 6809 | return undef; | ||
| 6810 | } | ||
| 6811 | |||
| 6812 | # Setup | ||
| 6813 | my $self = { | ||
| 6814 | _objName => 'other_win_' . $number, | ||
| 6815 | _objClass => $class, | ||
| 6816 | _parentFile => undef, # No parent file object | ||
| 6817 | _parentWorld => undef, # No parent file object | ||
| 6818 | _privFlag => TRUE, # All IVs are private | ||
| 6819 | |||
| 6820 | # Standard window object IVs | ||
| 6821 | # -------------------------- | ||
| 6822 | |||
| 6823 | # Unique number for this window object | ||
| 6824 | number => $number, | ||
| 6825 | # The window category - 'grid' or 'free' | ||
| 6826 | winCategory => 'free', | ||
| 6827 | # The window type, any of the keys in GA::Client->constFreeWinTypeHash | ||
| 6828 | winType => 'other', | ||
| 6829 | # A name for the window (for some 'free' windows, the same as the window type) | ||
| 6830 | winName => 'console', | ||
| 6831 | # The GA::Obj::Workspace object for the workspace in which this window is created | ||
| 6832 | workspaceObj => $workspaceObj, | ||
| 6833 | # The owner; a 'grid' window object (but not an 'external' window) or a 'free' window | ||
| 6834 | # object. When this window opens/closes, the owner is informed via calls to its | ||
| 6835 | # ->add_childFreeWin / ->del_childFreeWin functions | ||
| 6836 | owner => $owner, | ||
| 6837 | # The GA::Session from which this function was called. 'undef' if the calling function | ||
| 6838 | # didn't specify a session and $owner's ->session IV is also 'undef' | ||
| 6839 | session => $session, | ||
| 6840 | # When GA::Session->pseudoCmd is called to execute a client command, the mode in which | ||
| 6841 | # it should be called (usually 'win_error' or 'win_only', which causes errors to be | ||
| 6842 | # displayed in a 'dialogue' window) | ||
| 6843 | pseudoCmdMode => 'win_error', | ||
| 6844 | |||
| 6845 | # The window widget. For most window objects, the Gtk3::Window. For pseudo-windows, the | ||
| 6846 | # parent 'main' window's Gtk3::Window | ||
| 6847 | # The code should use this IV when it wants to do something to the window itself | ||
| 6848 | # (minimise it, make it active, etc) | ||
| 6849 | winWidget => undef, | ||
| 6850 | # The window container. For most window objects, the Gtk3::Window. For pseudo-windows, | ||
| 6851 | # the parent GA::Table::PseudoWin table object | ||
| 6852 | # The code should use this IV when it wants to add, modify or remove widgets inside the | ||
| 6853 | # window itself | ||
| 6854 | winBox => undef, | ||
| 6855 | # Flag set to TRUE if the window actually exists (after a call to $self->winEnable), | ||
| 6856 | # FALSE if not | ||
| 6857 | enabledFlag => FALSE, | ||
| 6858 | # Flag set to TRUE if the Gtk3 window itself is visible (after a call to | ||
| 6859 | # $self->setVisible), FALSE if it is not visible (after a call to $self->setInvisible) | ||
| 6860 | visibleFlag => TRUE, | ||
| 6861 | # Registry hash of 'free' windows (excluding 'dialogue' windows) for which this window | ||
| 6862 | # is the parent, a subset of GA::Obj::Desktop->freeWinHash. Hash in the form | ||
| 6863 | # $childFreeWinHash{unique_number} = blessed_reference_to_window_object | ||
| 6864 | childFreeWinHash => {}, | ||
| 6865 | |||
| 6866 | # The container widget into which all other widgets are packed (usually a Gtk3::VBox or | ||
| 6867 | # Gtk3::HBox, but any container widget can be used; takes up the whole window client | ||
| 6868 | # area) | ||
| 6869 | packingBox => undef, # Gtk3::VBox | ||
| 6870 | |||
| 6871 | # Standard IVs for 'free' windows | ||
| 6872 | |||
| 6873 | # The window's default size, in pixels | ||
| 6874 | widthPixels => 600, | ||
| 6875 | heightPixels => 300, | ||
| 6876 | # Default border/item spacing sizes used in the window, in pixels | ||
| 6877 | borderPixels => $axmud::CLIENT->constFreeBorderPixels, | ||
| 6878 | spacingPixels => $axmud::CLIENT->constFreeSpacingPixels, | ||
| 6879 | |||
| 6880 | # A string to use as the window title. If 'undef', a generic title is used | ||
| 6881 | title => $axmud::SCRIPT . ' session console #' . $session->number, | ||
| 6882 | # Hash containing any number of key-value pairs needed for this particular 'config' | ||
| 6883 | # window; for example, for example, GA::PrefWin::TaskStart uses it to specify a task | ||
| 6884 | # name and type. Set to an empty hash if not required | ||
| 6885 | configHash => {%configHash}, | ||
| 6886 | |||
| 6887 | # IVs for this window | ||
| 6888 | textView => undef, # Gtk3::TextView | ||
| 6889 | buffer => undef, # Gtk3::TextBuffer | ||
| 6890 | }; | ||
| 6891 | |||
| 6892 | # Bless the object into existence | ||
| 6893 | bless $self, $class; | ||
| 6894 | |||
| 6895 | return $self; | ||
| 6896 | } | ||
| 6897 | |||
| 6898 | ################## | ||
| 6899 | # Methods | ||
| 6900 | |||
| 6901 | # Standard window object functions | ||
| 6902 | |||
| 6903 | # sub winSetup {} # Inherited from GA::Generic::FreeWin | ||
| 6904 | |||
| 6905 | sub winEnable { | ||
| 6906 | |||
| 6907 | # Called by GA::Generic::Win->createFreeWin, after the call to $self->winSetup | ||
| 6908 | # After the Gtk3::Window has been setup and moved into position, makes it visible | ||
| 6909 | # | ||
| 6910 | # Expected arguments | ||
| 6911 | # (none besides $self) | ||
| 6912 | # | ||
| 6913 | # Return values | ||
| 6914 | # 'undef' on improper arguments | ||
| 6915 | # 1 on success | ||
| 6916 | |||
| 6917 | my ($self, $check) = @_; | ||
| 6918 | |||
| 6919 | # Local variables | ||
| 6920 | my @list; | ||
| 6921 | |||
| 6922 | # Check for improper arguments | ||
| 6923 | if (defined $check) { | ||
| 6924 | |||
| 6925 | return $axmud::CLIENT->writeImproper($self->_objClass . '->winEnable', @_); | ||
| 6926 | } | ||
| 6927 | |||
| 6928 | # Make the window appear on the desktop | ||
| 6929 | $self->winShowAll($self->_objClass . '->winEnable'); | ||
| 6930 | $self->ivPoke('enabledFlag', TRUE); | ||
| 6931 | |||
| 6932 | # This type of window is unique (only one can be open per session); inform the GA::Session | ||
| 6933 | # it has opened | ||
| 6934 | $self->session->set_consoleWin($self); | ||
| 6935 | |||
| 6936 | # If any system messages have been stored, we can display them now | ||
| 6937 | @list = $self->session->systemMsgList; | ||
| 6938 | if (@list) { | ||
| 6939 | |||
| 6940 | do { | ||
| 6941 | |||
| 6942 | my ($type, $msg); | ||
| 6943 | |||
| 6944 | $type = shift @list; | ||
| 6945 | $msg = shift @list; | ||
| 6946 | |||
| 6947 | $self->update($type, $msg); | ||
| 6948 | |||
| 6949 | } until (! @list); | ||
| 6950 | } | ||
| 6951 | |||
| 6952 | # Each system message is displayed here only once | ||
| 6953 | $self->session->reset_systemMsg(); | ||
| 6954 | |||
| 6955 | return 1; | ||
| 6956 | } | ||
| 6957 | |||
| 6958 | # sub winDesengage {} # Inherited from GA::Generic::FreeWin | ||
| 6959 | |||
| 6960 | sub winDestroy { | ||
| 6961 | |||
| 6962 | # Can be called by anything | ||
| 6963 | # Updates IVs | ||
| 6964 | # | ||
| 6965 | # Expected arguments | ||
| 6966 | # (none besides $self) | ||
| 6967 | # | ||
| 6968 | # Return values | ||
| 6969 | # 'undef' on improper arguments, if the window can't be destroyed or if it has already | ||
| 6970 | # been destroyed | ||
| 6971 | # 1 on success | ||
| 6972 | |||
| 6973 | my ($self, $check) = @_; | ||
| 6974 | |||
| 6975 | # Check for improper arguments | ||
| 6976 | if (defined $check) { | ||
| 6977 | |||
| 6978 | return $axmud::CLIENT->writeImproper($self->_objClass . '->winDestroy', @_); | ||
| 6979 | } | ||
| 6980 | |||
| 6981 | if (! $self->winBox) { | ||
| 6982 | |||
| 6983 | # Window already destroyed in a previous call to this function | ||
| 6984 | return undef; | ||
| 6985 | } | ||
| 6986 | |||
| 6987 | # Close any 'free' windows for which this window is a parent | ||
| 6988 | foreach my $winObj ($self->ivValues('childFreeWinHash')) { | ||
| 6989 | |||
| 6990 | $winObj->winDestroy(); | ||
| 6991 | } | ||
| 6992 | |||
| 6993 | # Destroy the Gtk3::Window | ||
| 6994 | eval { $self->winBox->destroy(); }; | ||
| 6995 | if ($@) { | ||
| 6996 | |||
| 6997 | # Window can't be destroyed | ||
| 6998 | return undef; | ||
| 6999 | |||
| 7000 | } else { | ||
| 7001 | |||
| 7002 | $self->ivUndef('winWidget'); | ||
| 7003 | $self->ivUndef('winBox'); | ||
| 7004 | } | ||
| 7005 | |||
| 7006 | # Inform the owner and the desktop object of this 'free' window's demise | ||
| 7007 | $axmud::CLIENT->desktopObj->del_freeWin($self); | ||
| 7008 | if ($self->owner) { | ||
| 7009 | |||
| 7010 | $self->owner->del_childFreeWin($self); | ||
| 7011 | } | ||
| 7012 | |||
| 7013 | # This type of window is unique (only one can be open per session); inform the GA::Session | ||
| 7014 | # it has closed | ||
| 7015 | $self->session->set_consoleWin(); | ||
| 7016 | |||
| 7017 | return 1; | ||
| 7018 | } | ||
| 7019 | |||
| 7020 | # sub winShowAll {} # Inherited from GA::Generic::Win | ||
| 7021 | |||
| 7022 | # sub drawWidgets {} # Inherited from GA::OtherWin::ClientConsole | ||
| 7023 | |||
| 7024 | # sub redrawWidgets {} # Inherited from GA::Generic::Win | ||
| 7025 | |||
| 7026 | # ->signal_connects | ||
| 7027 | |||
| 7028 | # Other functions | ||
| 7029 | |||
| 7030 | # sub createColourTags {} # Inherited from GA::OtherWin::ClientConsole | ||
| 7031 | |||
| 7032 | # sub update {} # Inherited from GA::OtherWin::ClientConsole | ||
| 7033 | |||
| 7034 | ################## | ||
| 7035 | # Accessors - set | ||
| 7036 | |||
| 7037 | ################## | ||
| 7038 | # Accessors - get | ||
| 7039 | } | ||
| 7040 | |||
| 7041 | { package Games::Axmud::OtherWin::Simulate; | ||
| 7042 | |||
| 7043 | use strict; | ||
| 7044 | use warnings; | ||
| 7045 | use diagnostics; | ||
| 7046 | |||
| 7047 | use Glib qw(TRUE FALSE); | ||
| 7048 | |||
| 7049 | our @ISA = qw( | ||
| 7050 | Games::Axmud::Generic::OtherWin Games::Axmud::Generic::FreeWin Games::Axmud::Generic::Win | ||
| 7051 | Games::Axmud | ||
| 7052 | ); | ||
| 7053 | |||
| 7054 | ################## | ||
| 7055 | # Constructors | ||
| 7056 | |||
| 7057 | sub new { | ||
| 7058 | |||
| 7059 | # Called by GA::Generic::Win->createFreeWin | ||
| 7060 | # Creates a new instance of the Simulate window (an 'other' window). The window contains a | ||
| 7061 | # textview in which the user can type text. When the 'Simulate' button is clicked, the | ||
| 7062 | # contents of the textview (if any) is combined into a single string (with multiple lines | ||
| 7063 | # separated by newline characters). The string is then used in a ';simulateworld' command, | ||
| 7064 | # and appears in the session's default textview, as if it had been received from the world | ||
| 7065 | # | ||
| 7066 | # Expected arguments | ||
| 7067 | # $number - Unique number for this window object | ||
| 7068 | # $workspaceObj - The GA::Obj::Workspace handling the workspace in which this window | ||
| 7069 | # should be created | ||
| 7070 | # $owner - The owner; a 'grid' window object (but not an 'external' window) or a | ||
| 7071 | # 'free' window object. When this window opens/closes, the owner is | ||
| 7072 | # informed via calls to its ->add_childFreeWin / ->del_childFreeWin | ||
| 7073 | # functions | ||
| 7074 | # | ||
| 7075 | # Optional arguments | ||
| 7076 | # $session - The GA::Session from which this function was called. 'undef' if the | ||
| 7077 | # calling function didn't specify a session and $owner's ->session IV | ||
| 7078 | # is also 'undef' | ||
| 7079 | # $title - Ignored if set (all 'other' windows define their own title) | ||
| 7080 | # $editObj - Ignored if set | ||
| 7081 | # $tempFlag - Ignored if set | ||
| 7082 | # %configHash - Hash containing any number of key-value pairs needed for this | ||
| 7083 | # particular 'other' window; set to an empty hash if not required | ||
| 7084 | # - This type of window object recognises these initialisation settings: | ||
| 7085 | # | ||
| 7086 | # 'type' => Which client command to use with the contents of the | ||
| 7087 | # textview, when the 'Simulate' button is clicked - 'world' or | ||
| 7088 | # 'prompt'. If not specified, 'world' is used | ||
| 7089 | # | ||
| 7090 | # Return values | ||
| 7091 | # 'undef' on improper arguments | ||
| 7092 | # Blessed reference to the newly-created object on success | ||
| 7093 | |||
| 7094 | my ( | ||
| 7095 | $class, $number, $workspaceObj, $owner, $session, $title, $editObj, $tempFlag, | ||
| 7096 | %configHash, | ||
| 7097 | ) = @_; | ||
| 7098 | |||
| 7099 | # Check for improper arguments | ||
| 7100 | if (! defined $class || ! defined $number || ! defined $workspaceObj || ! defined $owner) { | ||
| 7101 | |||
| 7102 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 7103 | } | ||
| 7104 | |||
| 7105 | # Set the values to use for some standard window IVs | ||
| 7106 | if (defined $configHash{'type'} && $configHash{'type'} eq 'prompt') { | ||
| 7107 | $title = 'Simulate prompt'; | ||
| 7108 | } else { | ||
| 7109 | $title = 'Simulate world'; | ||
| 7110 | } | ||
| 7111 | |||
| 7112 | # Setup | ||
| 7113 | my $self = { | ||
| 7114 | _objName => 'other_win_' . $number, | ||
| 7115 | _objClass => $class, | ||
| 7116 | _parentFile => undef, # No parent file object | ||
| 7117 | _parentWorld => undef, # No parent file object | ||
| 7118 | _privFlag => TRUE, # All IVs are private | ||
| 7119 | |||
| 7120 | # Standard window object IVs | ||
| 7121 | # -------------------------- | ||
| 7122 | |||
| 7123 | # Unique number for this window object | ||
| 7124 | number => $number, | ||
| 7125 | # The window category - 'grid' or 'free' | ||
| 7126 | winCategory => 'free', | ||
| 7127 | # The window type, any of the keys in GA::Client->constFreeWinTypeHash | ||
| 7128 | winType => 'other', | ||
| 7129 | # A name for the window (can be unique to this type of window object, or can be the | ||
| 7130 | # same as ->winType) | ||
| 7131 | winName => 'simulate', | ||
| 7132 | # The GA::Obj::Workspace object for the workspace in which this window is created | ||
| 7133 | workspaceObj => $workspaceObj, | ||
| 7134 | # The owner; a 'grid' window object (but not an 'external' window) or a 'free' window | ||
| 7135 | # object. When this window opens/closes, the owner is informed via calls to its | ||
| 7136 | # ->add_childFreeWin / ->del_childFreeWin functions | ||
| 7137 | owner => $owner, | ||
| 7138 | # The GA::Session from which this function was called. 'undef' if the calling function | ||
| 7139 | # didn't specify a session and $owner's ->session IV is also 'undef' | ||
| 7140 | session => $session, | ||
| 7141 | # When GA::Session->pseudoCmd is called to execute a client command, the mode in which | ||
| 7142 | # it should be called (usually 'win_error' or 'win_only', which causes errors to be | ||
| 7143 | # displayed in a 'dialogue' window) | ||
| 7144 | pseudoCmdMode => 'win_error', | ||
| 7145 | |||
| 7146 | # The window widget. For most window objects, the Gtk3::Window. For pseudo-windows, the | ||
| 7147 | # parent 'main' window's Gtk3::Window | ||
| 7148 | # The code should use this IV when it wants to do something to the window itself | ||
| 7149 | # (minimise it, make it active, etc) | ||
| 7150 | winWidget => undef, | ||
| 7151 | # The window container. For most window objects, the Gtk3::Window. For pseudo-windows, | ||
| 7152 | # the parent GA::Table::PseudoWin table object | ||
| 7153 | # The code should use this IV when it wants to add, modify or remove widgets inside the | ||
| 7154 | # window itself | ||
| 7155 | winBox => undef, | ||
| 7156 | # Flag set to TRUE if the window actually exists (after a call to $self->winEnable), | ||
| 7157 | # FALSE if not | ||
| 7158 | enabledFlag => FALSE, | ||
| 7159 | # Flag set to TRUE if the Gtk3 window itself is visible (after a call to | ||
| 7160 | # $self->setVisible), FALSE if it is not visible (after a call to $self->setInvisible) | ||
| 7161 | visibleFlag => TRUE, | ||
| 7162 | # Registry hash of 'free' windows (excluding 'dialogue' windows) for which this window | ||
| 7163 | # is the parent, a subset of GA::Obj::Desktop->freeWinHash. Hash in the form | ||
| 7164 | # $childFreeWinHash{unique_number} = blessed_reference_to_window_object | ||
| 7165 | childFreeWinHash => {}, | ||
| 7166 | # When a child 'free' window (excluding 'dialogue' windows) is destroyed, this parent | ||
| 7167 | # window is informed via a call to $self->del_childFreeWin | ||
| 7168 | # When the child is destroyed, this window might want to call some of its own functions | ||
| 7169 | # to update various widgets and/or IVs, in which case this window adds an entry to | ||
| 7170 | # this hash; a hash in the form | ||
| 7171 | # $childDestroyHash{unique_number} = list_reference | ||
| 7172 | # ...where 'unique_number' is the child window's ->number, and 'list_reference' is a | ||
| 7173 | # reference to a list in groups of 2, in the form | ||
| 7174 | # (sub_name, argument_list_ref, sub_name, argument_list_ref...) | ||
| 7175 | childDestroyHash => {}, | ||
| 7176 | |||
| 7177 | # The container widget into which all other widgets are packed (usually a Gtk3::VBox or | ||
| 7178 | # Gtk3::HBox, but any container widget can be used; takes up the whole window client | ||
| 7179 | # area) | ||
| 7180 | packingBox => undef, | ||
| 7181 | |||
| 7182 | # Standard IVs for 'free' windows | ||
| 7183 | |||
| 7184 | # The window's default size, in pixels | ||
| 7185 | widthPixels => int($axmud::CLIENT->constFreeWinWidth * 0.66), | ||
| 7186 | heightPixels => int($axmud::CLIENT->constFreeWinHeight * 0.66), | ||
| 7187 | # Default border/item spacing sizes used in the window, in pixels | ||
| 7188 | borderPixels => $axmud::CLIENT->constFreeBorderPixels, | ||
| 7189 | spacingPixels => $axmud::CLIENT->constFreeSpacingPixels, | ||
| 7190 | |||
| 7191 | # A string to use as the window title | ||
| 7192 | title => $title, | ||
| 7193 | # Hash containing any number of key-value pairs needed for this particular 'config' | ||
| 7194 | # window; for example, for example, GA::PrefWin::TaskStart uses it to specify a task | ||
| 7195 | # name and type. Set to an empty hash if not required | ||
| 7196 | configHash => {%configHash}, | ||
| 7197 | }; | ||
| 7198 | |||
| 7199 | # Bless the object into existence | ||
| 7200 | bless $self, $class; | ||
| 7201 | |||
| 7202 | return $self; | ||
| 7203 | } | ||
| 7204 | |||
| 7205 | ################## | ||
| 7206 | # Methods | ||
| 7207 | |||
| 7208 | # Standard window object functions | ||
| 7209 | |||
| 7210 | # sub winSetup {} # Inherited from GA::Generic::FreeWin | ||
| 7211 | |||
| 7212 | # sub winEnable {} # Inherited from GA::Generic::FreeWin | ||
| 7213 | |||
| 7214 | # sub winDesengage {} # Inherited from GA::Generic::FreeWin | ||
| 7215 | |||
| 7216 | # sub winDestroy {} # Inherited from GA::Generic::FreeWin | ||
| 7217 | |||
| 7218 | # sub winShowAll {} # Inherited from GA::Generic::Win | ||
| 7219 | |||
| 7220 | sub drawWidgets { | ||
| 7221 | |||
| 7222 | # Called by $self->winSetup | ||
| 7223 | # Sets up the Gtk3::Window by drawing the window's widgets | ||
| 7224 | # | ||
| 7225 | # Expected arguments | ||
| 7226 | # (none besides $self) | ||
| 7227 | # | ||
| 7228 | # Return values | ||
| 7229 | # 'undef' on improper arguments | ||
| 7230 | # 1 otherwise | ||
| 7231 | |||
| 7232 | my ($self, $check) = @_; | ||
| 7233 | |||
| 7234 | # Local variables | ||
| 7235 | my ( | ||
| 7236 | $width, $height, $title, $sampleText, $sampleUnderlay, | ||
| 7237 | @tagList, | ||
| 7238 | %prettyHash, %reversePrettyHash, %ansiHash, | ||
| 7239 | ); | ||
| 7240 | |||
| 7241 | # Check for improper arguments | ||
| 7242 | if (defined $check) { | ||
| 7243 | |||
| 7244 | return $axmud::CLIENT->writeImproper($self->_objClass . '->drawWidgets', @_); | ||
| 7245 | } | ||
| 7246 | |||
| 7247 | # Import the list of Axmud standard colour/style tags (which also includes the dummy tags | ||
| 7248 | # like 'bold', 'reverse_off' and 'attribs_off') | ||
| 7249 | @tagList = $axmud::CLIENT->constColourStyleList; | ||
| 7250 | # (For convenience, add 'attribs_off' to both the beginning and end of the list) | ||
| 7251 | unshift(@tagList, 'attribs_off'); | ||
| 7252 | # Also import the hash of pretty names for each standard tag, in which the keys are the | ||
| 7253 | # items in @tagList | ||
| 7254 | %prettyHash = $axmud::CLIENT->constPrettyTagHash; | ||
| 7255 | # Use a reverse hash too, so we can work out which combobox item was selected | ||
| 7256 | %reversePrettyHash = reverse %prettyHash; | ||
| 7257 | |||
| 7258 | # Prepare a hash of ANSI escape sequences which the user can insert at any place in the | ||
| 7259 | # textview, in the form | ||
| 7260 | # $ansiHash{tag} = number_of_ANSI_escape_sequence | ||
| 7261 | %ansiHash = ( | ||
| 7262 | (reverse $axmud::CLIENT->constANSIColourHash), | ||
| 7263 | (reverse $axmud::CLIENT->constANSIStyleHash), | ||
| 7264 | ); | ||
| 7265 | |||
| 7266 | $ansiHash{'bold'} = 1; | ||
| 7267 | $ansiHash{'bold_off'} = 22; | ||
| 7268 | $ansiHash{'reverse'} = 7; | ||
| 7269 | $ansiHash{'reverse_off'} = 27; | ||
| 7270 | $ansiHash{'conceal'} = 8; | ||
| 7271 | $ansiHash{'conceal_off'} = 28; | ||
| 7272 | $ansiHash{'attribs_off'} = 0; | ||
| 7273 | |||
| 7274 | # Create a packing box | ||
| 7275 | my $packingBox = Gtk3::VBox->new(FALSE, 0); | ||
| 7276 | $self->winBox->add($packingBox); | ||
| 7277 | $packingBox->set_border_width(0); | ||
| 7278 | |||
| 7279 | # At the top, create a textview | ||
| 7280 | my $scroller = Gtk3::ScrolledWindow->new(undef, undef); | ||
| 7281 | $packingBox->pack_start($scroller, TRUE, TRUE, 0); | ||
| 7282 | $scroller->set_shadow_type($axmud::CLIENT->constShadowType); | ||
| 7283 | $scroller->set_policy('automatic', 'automatic'); | ||
| 7284 | $scroller->set_border_width(0); | ||
| 7285 | |||
| 7286 | # Create a textview with default colours/fonts | ||
| 7287 | my $textView = Gtk3::TextView->new(); | ||
| 7288 | $scroller->add($textView); | ||
| 7289 | my $buffer = Gtk3::TextBuffer->new(); | ||
| 7290 | $textView->set_buffer($buffer); | ||
| 7291 | $textView->set_editable(TRUE); | ||
| 7292 | $textView->set_cursor_visible(TRUE); | ||
| 7293 | $axmud::CLIENT->desktopObj->setTextViewStyle($self->winType, $textView); | ||
| 7294 | |||
| 7295 | # At the bottom, create a button strip in a horizontal packing box | ||
| 7296 | my $hBox = Gtk3::HBox->new(FALSE, 0); | ||
| 7297 | $packingBox->pack_end($hBox, FALSE, FALSE, $self->spacingPixels); | ||
| 7298 | |||
| 7299 | # Create a combo | ||
| 7300 | my $comboBox = Gtk3::ComboBoxText->new(); | ||
| 7301 | $hBox->pack_start($comboBox, FALSE, FALSE, $self->borderPixels); | ||
| 7302 | $title = 'Add an ANSI escape sequence:'; | ||
| 7303 | $sampleText = 'Sample xterm-256 text colour'; | ||
| 7304 | $sampleUnderlay = 'Sample xterm-256 underlay colour'; | ||
| 7305 | $comboBox->append_text($title); | ||
| 7306 | foreach my $tag (@tagList) { | ||
| 7307 | |||
| 7308 | $comboBox->append_text($prettyHash{$tag}); | ||
| 7309 | |||
| 7310 | # GA::Client->constColourStyleList doesn't include xterm colour tags, so we'll insert | ||
| 7311 | # a sample text and a sample underlay colour right just before the style tags | ||
| 7312 | if ($tag eq 'ul_white') { | ||
| 7313 | |||
| 7314 | $comboBox->append_text($sampleText); | ||
| 7315 | $comboBox->append_text($sampleUnderlay); | ||
| 7316 | } | ||
| 7317 | } | ||
| 7318 | |||
| 7319 | $comboBox->set_active(0); | ||
| 7320 | |||
| 7321 | # Create the 'Apply' button | ||
| 7322 | my $addButton = Gtk3::Button->new('Apply'); | ||
| 7323 | $hBox->pack_start($addButton, FALSE, FALSE, 0); | ||
| 7324 | $addButton->get_child->set_width_chars(8); | ||
| 7325 | $addButton->signal_connect('clicked' => sub { | ||
| 7326 | |||
| 7327 | my ($prettyTag, $tag, $ansi); | ||
| 7328 | |||
| 7329 | $prettyTag = $comboBox->get_active_text(); | ||
| 7330 | if ($prettyTag) { | ||
| 7331 | |||
| 7332 | if ($prettyTag eq $sampleText) { | ||
| 7333 | |||
| 7334 | # Use an example xterm-256 text colour (dark grey) | ||
| 7335 | $ansi = chr(27) . '[38;5;234m'; | ||
| 7336 | |||
| 7337 | } elsif ($prettyTag eq $sampleUnderlay) { | ||
| 7338 | |||
| 7339 | # Use an example xterm-256 underlay colour (light orange) | ||
| 7340 | $ansi = chr(27) . '[48;5;214m'; | ||
| 7341 | |||
| 7342 | } elsif ($prettyTag ne $title) { | ||
| 7343 | |||
| 7344 | # Get an Axmud colour/style tag (or one of the dummy tags like 'bold', | ||
| 7345 | # 'reverse_off' and 'attribs_off') | ||
| 7346 | $tag = $reversePrettyHash{$prettyTag}; | ||
| 7347 | # Convert it to an ANSI escape sequence | ||
| 7348 | $ansi = chr(27) . '[' . $ansiHash{$tag} . 'm'; | ||
| 7349 | } | ||
| 7350 | |||
| 7351 | if ($ansi) { | ||
| 7352 | |||
| 7353 | $buffer->insert_at_cursor($ansi); | ||
| 7354 | } | ||
| 7355 | } | ||
| 7356 | }); | ||
| 7357 | |||
| 7358 | # Create the 'Simulate' button | ||
| 7359 | my $okButton = Gtk3::Button->new('Simulate'); | ||
| 7360 | $hBox->pack_end($okButton, FALSE, FALSE, 0); | ||
| 7361 | $okButton->get_child->set_width_chars(8); | ||
| 7362 | $okButton->signal_connect('clicked' => sub { | ||
| 7363 | |||
| 7364 | my ($text, $type); | ||
| 7365 | |||
| 7366 | $text = $axmud::CLIENT->desktopObj->bufferGetText($buffer); | ||
| 7367 | $type = $self->ivShow('configHash', 'type'); | ||
| 7368 | |||
| 7369 | # If the textview contains some text, and if the calling GA::Session still exists... | ||
| 7370 | if ($text && $axmud::CLIENT->ivExists('sessionHash', $self->session->number)) { | ||
| 7371 | |||
| 7372 | if ($type eq 'prompt') { | ||
| 7373 | |||
| 7374 | # Simulate a prompt received from the world. The TRUE argument means that the | ||
| 7375 | # 'main' window's blinker shouldn't be turned on. | ||
| 7376 | chomp $text; | ||
| 7377 | $self->session->processIncomingData($text, TRUE); | ||
| 7378 | |||
| 7379 | } else { | ||
| 7380 | |||
| 7381 | # Simulate text received from the world. The TRUE argument means that the main | ||
| 7382 | # window's blinker shouldn't be turned on. | ||
| 7383 | $self->session->processIncomingData($text, TRUE); | ||
| 7384 | } | ||
| 7385 | } | ||
| 7386 | }); | ||
| 7387 | |||
| 7388 | # Create the 'Close' button | ||
| 7389 | my $cancelButton = Gtk3::Button->new('Close'); | ||
| 7390 | $hBox->pack_end($cancelButton, FALSE, FALSE, $self->spacingPixels); | ||
| 7391 | $cancelButton->get_child->set_width_chars(8); | ||
| 7392 | $cancelButton->signal_connect('clicked' => sub { | ||
| 7393 | |||
| 7394 | $self->winDestroy(); | ||
| 7395 | }); | ||
| 7396 | |||
| 7397 | # Update IVs (not worth storing widgets other than the main packing box) | ||
| 7398 | $self->ivPoke('packingBox', $packingBox); | ||
| 7399 | |||
| 7400 | return 1; | ||
| 7401 | } | ||
| 7402 | |||
| 7403 | # sub redrawWidgets {} # Inherited from GA::Generic::Win | ||
| 7404 | |||
| 7405 | # ->signal_connects | ||
| 7406 | |||
| 7407 | # Other functions | ||
| 7408 | |||
| 7409 | ################## | ||
| 7410 | # Accessors - set | ||
| 7411 | |||
| 7412 | ################## | ||
| 7413 | # Accessors - get | ||
| 7414 | } | ||
| 7415 | |||
| 7416 | { package Games::Axmud::OtherWin::SourceCode; | ||
| 7417 | |||
| 7418 | use strict; | ||
| 7419 | use warnings; | ||
| 7420 | use diagnostics; | ||
| 7421 | |||
| 7422 | use Glib qw(TRUE FALSE); | ||
| 7423 | |||
| 7424 | our @ISA = qw( | ||
| 7425 | Games::Axmud::Generic::OtherWin Games::Axmud::Generic::FreeWin Games::Axmud::Generic::Win | ||
| 7426 | Games::Axmud | ||
| 7427 | ); | ||
| 7428 | |||
| 7429 | ################## | ||
| 7430 | # Constructors | ||
| 7431 | |||
| 7432 | sub new { | ||
| 7433 | |||
| 7434 | # Called by GA::Generic::Win->createFreeWin | ||
| 7435 | # Creates a new instance of the Source Code Viewer (an 'other' window). The window contains | ||
| 7436 | # a textview in which the source code for a world model object can be displayed (but not | ||
| 7437 | # edited) | ||
| 7438 | # | ||
| 7439 | # Expected arguments | ||
| 7440 | # $number - Unique number for this window object | ||
| 7441 | # $workspaceObj - The GA::Obj::Workspace handling the workspace in which this window | ||
| 7442 | # should be created | ||
| 7443 | # $owner - The owner; a 'grid' window object (but not an 'external' window) or a | ||
| 7444 | # 'free' window object. When this window opens/closes, the owner is | ||
| 7445 | # informed via calls to its ->add_childFreeWin / ->del_childFreeWin | ||
| 7446 | # functions | ||
| 7447 | # | ||
| 7448 | # Optional arguments | ||
| 7449 | # $session - The GA::Session from which this function was called. 'undef' if the | ||
| 7450 | # calling function didn't specify a session and $owner's ->session IV | ||
| 7451 | # is also 'undef' | ||
| 7452 | # $title - Ignored if set (all 'other' windows define their own title) | ||
| 7453 | # $editObj - Ignored if set | ||
| 7454 | # $tempFlag - Ignored if set | ||
| 7455 | # %configHash - Hash containing any number of key-value pairs needed for this | ||
| 7456 | # particular 'other' window; set to an empty hash if not required | ||
| 7457 | # - This type of window object recognises these initialisation settings: | ||
| 7458 | # | ||
| 7459 | # 'model_obj' => Blessed reference to the model object whose source | ||
| 7460 | # code should be shown (GA::ModelObj::Room, etc). If not | ||
| 7461 | # specified, the window doesn't open | ||
| 7462 | # 'virtual_flag' => If TRUE, the model is a room object, and we need | ||
| 7463 | # to view the file stored in the object's ->virtualAreaPath IV. | ||
| 7464 | # If not specified, FALSE (or 'undef'), we need to view the file | ||
| 7465 | # stored in the object's ->sourceCodePath IV | ||
| 7466 | # 'path' => If defined, the filepath to use (which may be different to | ||
| 7467 | # the one stored in the object's ->virtualAreaPath). If not | ||
| 7468 | # specified, an empty string or 'undef', the object's | ||
| 7469 | # ->sourceCodePath is used. Ignored if 'virtual_flag' is TRUE | ||
| 7470 | # | ||
| 7471 | # Return values | ||
| 7472 | # 'undef' on improper arguments | ||
| 7473 | # Blessed reference to the newly-created object on success | ||
| 7474 | |||
| 7475 | my ( | ||
| 7476 | $class, $number, $workspaceObj, $owner, $session, $title, $editObj, $tempFlag, | ||
| 7477 | %configHash, | ||
| 7478 | ) = @_; | ||
| 7479 | |||
| 7480 | # Check for improper arguments | ||
| 7481 | if (! defined $class || ! defined $number || ! defined $workspaceObj || ! defined $owner) { | ||
| 7482 | |||
| 7483 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 7484 | } | ||
| 7485 | |||
| 7486 | # Setup | ||
| 7487 | my $self = { | ||
| 7488 | _objName => 'other_win_' . $number, | ||
| 7489 | _objClass => $class, | ||
| 7490 | _parentFile => undef, # No parent file object | ||
| 7491 | _parentWorld => undef, # No parent file object | ||
| 7492 | _privFlag => TRUE, # All IVs are private | ||
| 7493 | |||
| 7494 | # Standard window object IVs | ||
| 7495 | # -------------------------- | ||
| 7496 | |||
| 7497 | # Unique number for this window object | ||
| 7498 | number => $number, | ||
| 7499 | # The window category - 'grid' or 'free' | ||
| 7500 | winCategory => 'free', | ||
| 7501 | # The window type, any of the keys in GA::Client->constFreeWinTypeHash | ||
| 7502 | winType => 'other', | ||
| 7503 | # A name for the window (can be unique to this type of window object, or can be the | ||
| 7504 | # same as ->winType) | ||
| 7505 | winName => 'source_code', | ||
| 7506 | # The GA::Obj::Workspace object for the workspace in which this window is created | ||
| 7507 | workspaceObj => $workspaceObj, | ||
| 7508 | # The owner; a 'grid' window object (but not an 'external' window) or a 'free' window | ||
| 7509 | # object. When this window opens/closes, the owner is informed via calls to its | ||
| 7510 | # ->add_childFreeWin / ->del_childFreeWin functions | ||
| 7511 | owner => $owner, | ||
| 7512 | # The GA::Session from which this function was called. 'undef' if the calling function | ||
| 7513 | # didn't specify a session and $owner's ->session IV is also 'undef' | ||
| 7514 | session => $session, | ||
| 7515 | # When GA::Session->pseudoCmd is called to execute a client command, the mode in which | ||
| 7516 | # it should be called (usually 'win_error' or 'win_only', which causes errors to be | ||
| 7517 | # displayed in a 'dialogue' window) | ||
| 7518 | pseudoCmdMode => 'win_error', | ||
| 7519 | |||
| 7520 | # The window widget. For most window objects, the Gtk3::Window. For pseudo-windows, the | ||
| 7521 | # parent 'main' window's Gtk3::Window | ||
| 7522 | # The code should use this IV when it wants to do something to the window itself | ||
| 7523 | # (minimise it, make it active, etc) | ||
| 7524 | winWidget => undef, | ||
| 7525 | # The window container. For most window objects, the Gtk3::Window. For pseudo-windows, | ||
| 7526 | # the parent GA::Table::PseudoWin table object | ||
| 7527 | # The code should use this IV when it wants to add, modify or remove widgets inside the | ||
| 7528 | # window itself | ||
| 7529 | winBox => undef, | ||
| 7530 | # Flag set to TRUE if the window actually exists (after a call to $self->winEnable), | ||
| 7531 | # FALSE if not | ||
| 7532 | enabledFlag => FALSE, | ||
| 7533 | # Flag set to TRUE if the Gtk3 window itself is visible (after a call to | ||
| 7534 | # $self->setVisible), FALSE if it is not visible (after a call to $self->setInvisible) | ||
| 7535 | visibleFlag => TRUE, | ||
| 7536 | # Registry hash of 'free' windows (excluding 'dialogue' windows) for which this window | ||
| 7537 | # is the parent, a subset of GA::Obj::Desktop->freeWinHash. Hash in the form | ||
| 7538 | # $childFreeWinHash{unique_number} = blessed_reference_to_window_object | ||
| 7539 | childFreeWinHash => {}, | ||
| 7540 | # When a child 'free' window (excluding 'dialogue' windows) is destroyed, this parent | ||
| 7541 | # window is informed via a call to $self->del_childFreeWin | ||
| 7542 | # When the child is destroyed, this window might want to call some of its own functions | ||
| 7543 | # to update various widgets and/or IVs, in which case this window adds an entry to | ||
| 7544 | # this hash; a hash in the form | ||
| 7545 | # $childDestroyHash{unique_number} = list_reference | ||
| 7546 | # ...where 'unique_number' is the child window's ->number, and 'list_reference' is a | ||
| 7547 | # reference to a list in groups of 2, in the form | ||
| 7548 | # (sub_name, argument_list_ref, sub_name, argument_list_ref...) | ||
| 7549 | childDestroyHash => {}, | ||
| 7550 | |||
| 7551 | # The container widget into which all other widgets are packed (usually a Gtk3::VBox or | ||
| 7552 | # Gtk3::HBox, but any container widget can be used; takes up the whole window client | ||
| 7553 | # area) | ||
| 7554 | packingBox => undef, | ||
| 7555 | |||
| 7556 | # Standard IVs for 'free' windows | ||
| 7557 | |||
| 7558 | # The window's default size, in pixels | ||
| 7559 | widthPixels => $axmud::CLIENT->customFreeWinWidth, | ||
| 7560 | heightPixels => $axmud::CLIENT->customFreeWinHeight, | ||
| 7561 | # Default border/item spacing sizes used in the window, in pixels | ||
| 7562 | borderPixels => $axmud::CLIENT->constFreeBorderPixels, | ||
| 7563 | spacingPixels => $axmud::CLIENT->constFreeSpacingPixels, | ||
| 7564 | |||
| 7565 | # A string to use as the window title | ||
| 7566 | title => 'Source code viewer', | ||
| 7567 | # Hash containing any number of key-value pairs needed for this particular 'config' | ||
| 7568 | # window; for example, for example, GA::PrefWin::TaskStart uses it to specify a task | ||
| 7569 | # name and type. Set to an empty hash if not required | ||
| 7570 | configHash => {%configHash}, | ||
| 7571 | |||
| 7572 | # IVs for this window | ||
| 7573 | |||
| 7574 | # Full path to the file loaded | ||
| 7575 | file => undef, | ||
| 7576 | # The model object whose corresponding source code should be displayed | ||
| 7577 | modelObj => undef, | ||
| 7578 | # The contents of the source code file, once read by $self->readFile | ||
| 7579 | lineList => [], | ||
| 7580 | }; | ||
| 7581 | |||
| 7582 | # Bless the object into existence | ||
| 7583 | bless $self, $class; | ||
| 7584 | |||
| 7585 | return $self; | ||
| 7586 | } | ||
| 7587 | |||
| 7588 | ################## | ||
| 7589 | # Methods | ||
| 7590 | |||
| 7591 | # Standard window object functions | ||
| 7592 | |||
| 7593 | sub winSetup { | ||
| 7594 | |||
| 7595 | # Called by GA::Generic::Win->createFreeWin, after the call to $self->new | ||
| 7596 | # Creates the Gtk3::Window itself | ||
| 7597 | # | ||
| 7598 | # Expected arguments | ||
| 7599 | # (none besides $self) | ||
| 7600 | # | ||
| 7601 | # Return values | ||
| 7602 | # 'undef' on improper arguments or if the window can't be opened | ||
| 7603 | # 1 on success | ||
| 7604 | |||
| 7605 | my ($self, $check) = @_; | ||
| 7606 | |||
| 7607 | # Local variables | ||
| 7608 | my $iv; | ||
| 7609 | |||
| 7610 | # Check for improper arguments | ||
| 7611 | if (defined $check) { | ||
| 7612 | |||
| 7613 | return $axmud::CLIENT->writeImproper($self->_objClass . '->winSetup', @_); | ||
| 7614 | } | ||
| 7615 | |||
| 7616 | # Before doing anything, try to read the file (and don't open this window if it can't be | ||
| 7617 | # done) | ||
| 7618 | if (! $self->readFile()) { | ||
| 7619 | |||
| 7620 | return undef; | ||
| 7621 | } | ||
| 7622 | |||
| 7623 | # Create the Gtk3::Window | ||
| 7624 | my $winWidget = Gtk3::Window->new('toplevel'); | ||
| 7625 | if (! $winWidget) { | ||
| 7626 | |||
| 7627 | return undef; | ||
| 7628 | |||
| 7629 | } else { | ||
| 7630 | |||
| 7631 | # Store the IV now, as subsequent code needs it | ||
| 7632 | $self->ivPoke('winWidget', $winWidget); | ||
| 7633 | $self->ivPoke('winBox', $winWidget); | ||
| 7634 | } | ||
| 7635 | |||
| 7636 | # Set up ->signal_connects | ||
| 7637 | $self->setDeleteEvent(); # 'delete-event' | ||
| 7638 | |||
| 7639 | # Set the window title | ||
| 7640 | $winWidget->set_title($self->title); | ||
| 7641 | |||
| 7642 | # Set the window's default size and position | ||
| 7643 | $winWidget->set_default_size($self->widthPixels, $self->heightPixels); | ||
| 7644 | $winWidget->set_border_width($self->borderPixels); | ||
| 7645 | $winWidget->set_position('center'); | ||
| 7646 | |||
| 7647 | # Set the icon list for this window | ||
| 7648 | $iv = $self->winType . 'WinIconList'; | ||
| 7649 | $winWidget->set_icon_list($axmud::CLIENT->desktopObj->{$iv}); | ||
| 7650 | |||
| 7651 | # Draw the widgets used by this window | ||
| 7652 | if (! $self->drawWidgets()) { | ||
| 7653 | |||
| 7654 | return undef; | ||
| 7655 | } | ||
| 7656 | |||
| 7657 | # The calling function can now call $self->winEnable to make the window visible | ||
| 7658 | return 1; | ||
| 7659 | } | ||
| 7660 | |||
| 7661 | # sub winEnable {} # Inherited from GA::Generic::FreeWin | ||
| 7662 | |||
| 7663 | # sub winDesengage {} # Inherited from GA::Generic::FreeWin | ||
| 7664 | |||
| 7665 | # sub winDestroy {} # Inherited from GA::Generic::FreeWin | ||
| 7666 | |||
| 7667 | # sub winShowAll {} # Inherited from GA::Generic::Win | ||
| 7668 | |||
| 7669 | sub drawWidgets { | ||
| 7670 | |||
| 7671 | # Called by $self->winSetup | ||
| 7672 | # Sets up the Gtk3::Window by drawing the window's widgets | ||
| 7673 | # | ||
| 7674 | # Expected arguments | ||
| 7675 | # (none besides $self) | ||
| 7676 | # | ||
| 7677 | # Return values | ||
| 7678 | # 'undef' on improper arguments | ||
| 7679 | # 1 otherwise | ||
| 7680 | |||
| 7681 | my ($self, $check) = @_; | ||
| 7682 | |||
| 7683 | # Check for improper arguments | ||
| 7684 | if (defined $check) { | ||
| 7685 | |||
| 7686 | return $axmud::CLIENT->writeImproper($self->_objClass . '->drawWidgets', @_); | ||
| 7687 | } | ||
| 7688 | |||
| 7689 | # Create a packing box | ||
| 7690 | my $packingBox = Gtk3::VBox->new(FALSE, 0); | ||
| 7691 | $self->winBox->add($packingBox); | ||
| 7692 | $packingBox->set_border_width(0); | ||
| 7693 | |||
| 7694 | # At the top, create a textview | ||
| 7695 | my $frame = Gtk3::Frame->new($self->title); | ||
| 7696 | $packingBox->pack_start($frame, TRUE, TRUE, 0); | ||
| 7697 | # Update the frame label | ||
| 7698 | $frame->set_label( | ||
| 7699 | 'World model room #' . $self->modelObj->number . ' (' . $self->file . ')', | ||
| 7700 | ); | ||
| 7701 | $frame->set_border_width(0); | ||
| 7702 | |||
| 7703 | my $scroller = Gtk3::ScrolledWindow->new(undef, undef); | ||
| 7704 | $frame->add($scroller); | ||
| 7705 | $scroller->set_shadow_type($axmud::CLIENT->constShadowType); | ||
| 7706 | $scroller->set_policy('automatic', 'automatic'); | ||
| 7707 | $scroller->set_border_width(5); | ||
| 7708 | |||
| 7709 | # Create a textview with default colours/fonts | ||
| 7710 | my $textView = Gtk3::TextView->new(); | ||
| 7711 | $scroller->add($textView); | ||
| 7712 | my $buffer = Gtk3::TextBuffer->new(); | ||
| 7713 | $textView->set_buffer($buffer); | ||
| 7714 | $textView->set_editable(FALSE); | ||
| 7715 | $textView->set_cursor_visible(FALSE); | ||
| 7716 | $axmud::CLIENT->desktopObj->setTextViewStyle($self->winType, $textView); | ||
| 7717 | |||
| 7718 | # Copy the contents of the file to the textview | ||
| 7719 | $buffer->set_text(join("\n", $self->lineList)); | ||
| 7720 | |||
| 7721 | # At the bottom, create a button strip in a horizontal packing box | ||
| 7722 | my $hBox = Gtk3::HBox->new(FALSE, 0); | ||
| 7723 | $packingBox->pack_end($hBox, FALSE, FALSE, $self->spacingPixels); | ||
| 7724 | |||
| 7725 | # Add a single button | ||
| 7726 | my $button = Gtk3::Button->new(' Close '); | ||
| 7727 | $hBox->pack_end($button, FALSE, FALSE, $self->borderPixels); | ||
| 7728 | $button->get_child->set_width_chars(10); | ||
| 7729 | $button->signal_connect('clicked' => sub { | ||
| 7730 | |||
| 7731 | $self->winDestroy(); | ||
| 7732 | }); | ||
| 7733 | |||
| 7734 | # Update IVs (not worth storing widgets other than the main packing box) | ||
| 7735 | $self->ivPoke('packingBox', $packingBox); | ||
| 7736 | |||
| 7737 | return 1; | ||
| 7738 | } | ||
| 7739 | |||
| 7740 | # sub redrawWidgets {} # Inherited from GA::Generic::Win | ||
| 7741 | |||
| 7742 | # ->signal_connects | ||
| 7743 | |||
| 7744 | # Other functions | ||
| 7745 | |||
| 7746 | sub readFile { | ||
| 7747 | |||
| 7748 | # Called by $self->winSetup before creating the Gtk3::Window | ||
| 7749 | # Performs a few checks, displaying a 'dialogue' window if the source code viewer window | ||
| 7750 | # can't be opened for one reason or another | ||
| 7751 | # | ||
| 7752 | # Expected arguments | ||
| 7753 | # (none besides $self) | ||
| 7754 | # | ||
| 7755 | # Return values | ||
| 7756 | # 'undef' on improper arguments or if the window should not be opened | ||
| 7757 | # 1 otherwise | ||
| 7758 | |||
| 7759 | my ($self, $check) = @_; | ||
| 7760 | |||
| 7761 | # Local variables | ||
| 7762 | my ( | ||
| 7763 | $worldModelObj, $obj, $virtualFlag, $sourcePath, $errorMsg, $file, $fileName, | ||
| 7764 | $fileHandle, | ||
| 7765 | @lineList, | ||
| 7766 | ); | ||
| 7767 | |||
| 7768 | # Check for improper arguments | ||
| 7769 | if (defined $check) { | ||
| 7770 | |||
| 7771 | return $axmud::CLIENT->writeImproper($self->_objClass . '->readFile', @_); | ||
| 7772 | } | ||
| 7773 | |||
| 7774 | # Import the world model (for convenience) | ||
| 7775 | $worldModelObj = $self->session->worldModelObj; | ||
| 7776 | # Import some values from $self->configHash (for convenience) | ||
| 7777 | $obj = $self->ivShow('configHash', 'model_obj'); | ||
| 7778 | $virtualFlag = $self->ivShow('configHash', 'virtual_flag'); | ||
| 7779 | $sourcePath = $self->ivShow('configHash', 'path'); | ||
| 7780 | |||
| 7781 | # Check that the model object knows the source code of the equivalent mudlib object | ||
| 7782 | if (! $obj->sourceCodePath && ! $sourcePath) { | ||
| 7783 | |||
| 7784 | $errorMsg = 'World model object #' . $obj->number . ' has no source code file set'; | ||
| 7785 | |||
| 7786 | } elsif ($virtualFlag) { | ||
| 7787 | |||
| 7788 | if ($obj->category ne 'room') { | ||
| 7789 | |||
| 7790 | $errorMsg = 'World model object #' . $obj->number . ' is not a room'; | ||
| 7791 | |||
| 7792 | } elsif (! $obj->virtualAreaPath) { | ||
| 7793 | |||
| 7794 | $errorMsg = 'World model object #' . $obj->number . ' has no virtual area file set'; | ||
| 7795 | } | ||
| 7796 | } | ||
| 7797 | |||
| 7798 | if ($errorMsg) { | ||
| 7799 | |||
| 7800 | $self->showMsgDialogue( | ||
| 7801 | 'View source code', | ||
| 7802 | 'error', | ||
| 7803 | $errorMsg, | ||
| 7804 | 'ok', | ||
| 7805 | ); | ||
| 7806 | |||
| 7807 | return undef; | ||
| 7808 | } | ||
| 7809 | |||
| 7810 | # Set the file to be displayed. If the current world model defines a mudlib directory, | ||
| 7811 | # the object's ->mudlibPath is relative to that; otherwise it's an absolute path | ||
| 7812 | if ($worldModelObj->mudlibPath) { | ||
| 7813 | $file = $worldModelObj->mudlibPath; | ||
| 7814 | } else { | ||
| 7815 | $file = ''; | ||
| 7816 | } | ||
| 7817 | |||
| 7818 | if ($sourcePath && ! $virtualFlag) { | ||
| 7819 | |||
| 7820 | # Use a different file than the one stored in the room object | ||
| 7821 | $fileName = $sourcePath; | ||
| 7822 | |||
| 7823 | } elsif ($virtualFlag && $obj->category eq 'room') { | ||
| 7824 | |||
| 7825 | # This is a room in a virtual area | ||
| 7826 | $fileName = $obj->virtualAreaPath; | ||
| 7827 | |||
| 7828 | } else { | ||
| 7829 | |||
| 7830 | # Any other kind of model object | ||
| 7831 | $fileName = $obj->sourceCodePath; | ||
| 7832 | } | ||
| 7833 | |||
| 7834 | $file .= $fileName; | ||
| 7835 | |||
| 7836 | # Add the file extension, if set | ||
| 7837 | if ($worldModelObj->mudlibExtension) { | ||
| 7838 | |||
| 7839 | $file .= $worldModelObj->mudlibExtension; | ||
| 7840 | } | ||
| 7841 | |||
| 7842 | # Check the file exists | ||
| 7843 | if (! (-e $file)) { | ||
| 7844 | |||
| 7845 | $self->showMsgDialogue( | ||
| 7846 | 'View source code', | ||
| 7847 | 'error', | ||
| 7848 | 'Can\'t find the file \'' . $file . '\'', | ||
| 7849 | 'ok', | ||
| 7850 | ); | ||
| 7851 | |||
| 7852 | return undef; | ||
| 7853 | } | ||
| 7854 | |||
| 7855 | # Open the file for reading | ||
| 7856 | if (! open ($fileHandle, "<$file")) { | ||
| 7857 | |||
| 7858 | $self->showMessageDialogue( | ||
| 7859 | 'View source code', | ||
| 7860 | 'error', | ||
| 7861 | 'Couldn\'t open the file ' . $file, | ||
| 7862 | 'ok', | ||
| 7863 | ); | ||
| 7864 | |||
| 7865 | return undef; | ||
| 7866 | } | ||
| 7867 | |||
| 7868 | # Read the file | ||
| 7869 | while (defined (my $line = <$fileHandle>)) { | ||
| 7870 | |||
| 7871 | chomp $line; | ||
| 7872 | push (@lineList, $line); | ||
| 7873 | } | ||
| 7874 | |||
| 7875 | # Close the file | ||
| 7876 | if (! close $fileHandle) { | ||
| 7877 | |||
| 7878 | $self->showMsgDialogue( | ||
| 7879 | 'View source code', | ||
| 7880 | 'error', | ||
| 7881 | 'Couldn\'t read the file ' . $file, | ||
| 7882 | 'ok', | ||
| 7883 | ); | ||
| 7884 | |||
| 7885 | return undef; | ||
| 7886 | } | ||
| 7887 | |||
| 7888 | # File read successfully. Update IVs | ||
| 7889 | $self->ivPoke('file', $file); | ||
| 7890 | $self->ivPoke('modelObj', $obj); | ||
| 7891 | $self->ivPoke('lineList', @lineList); | ||
| 7892 | |||
| 7893 | return 1; | ||
| 7894 | } | ||
| 7895 | |||
| 7896 | ################## | ||
| 7897 | # Accessors - set | ||
| 7898 | |||
| 7899 | ################## | ||
| 7900 | # Accessors - get | ||
| 7901 | |||
| 7902 | sub file | ||
| 7903 | { $_[0]->{file} } | ||
| 7904 | sub modelObj | ||
| 7905 | { $_[0]->{modelObj} } | ||
| 7906 | sub lineList | ||
| 7907 | { my $self = shift; return @{$self->{lineList}}; } | ||
| 7908 | } | ||
| 7909 | |||
| 7910 | { package Games::Axmud::OtherWin::Viewer; | ||
| 7911 | |||
| 7912 | use strict; | ||
| 7913 | use warnings; | ||
| 7914 | use diagnostics; | ||
| 7915 | |||
| 7916 | use Glib qw(TRUE FALSE); | ||
| 7917 | |||
| 7918 | our @ISA = qw( | ||
| 7919 | Games::Axmud::Generic::OtherWin Games::Axmud::Generic::FreeWin Games::Axmud::Generic::Win | ||
| 7920 | Games::Axmud | ||
| 7921 | ); | ||
| 7922 | |||
| 7923 | ################## | ||
| 7924 | # Constructors | ||
| 7925 | |||
| 7926 | sub new { | ||
| 7927 | |||
| 7928 | # Called by GA::Generic::Win->createFreeWin | ||
| 7929 | # Creates a new instance of the object viewer window, which provides easy access to Axmud's | ||
| 7930 | # stored data | ||
| 7931 | # | ||
| 7932 | # Expected arguments | ||
| 7933 | # $number - Unique number for this window object | ||
| 7934 | # $workspaceObj - The GA::Obj::Workspace handling the workspace in which this window | ||
| 7935 | # should be created | ||
| 7936 | # $owner - The owner; a 'grid' window object (but not an 'external' window) or a | ||
| 7937 | # 'free' window object. When this window opens/closes, the owner is | ||
| 7938 | # informed via calls to its ->add_childFreeWin / ->del_childFreeWin | ||
| 7939 | # functions | ||
| 7940 | # | ||
| 7941 | # Optional arguments | ||
| 7942 | # $session - The GA::Session from which this function was called. 'undef' if the | ||
| 7943 | # calling function didn't specify a session and $owner's ->session IV | ||
| 7944 | # is also 'undef' | ||
| 7945 | # $title - Ignored if set (all 'other' windows define their own title) | ||
| 7946 | # $editObj - Ignored if set | ||
| 7947 | # $tempFlag - Ignored if set | ||
| 7948 | # %configHash - Hash containing any number of key-value pairs needed for this | ||
| 7949 | # particular 'other' window; set to an empty hash if not required | ||
| 7950 | # - This type of window object recognises these initialisation settings: | ||
| 7951 | # | ||
| 7952 | # ... | ||
| 7953 | # | ||
| 7954 | # Return values | ||
| 7955 | # 'undef' on improper arguments or if no $session was specified | ||
| 7956 | # Blessed reference to the newly-created object on success | ||
| 7957 | |||
| 7958 | my ( | ||
| 7959 | $class, $number, $workspaceObj, $owner, $session, $title, $editObj, $tempFlag, | ||
| 7960 | %configHash, | ||
| 7961 | ) = @_; | ||
| 7962 | |||
| 7963 | # Check for improper arguments | ||
| 7964 | if (! defined $class || ! defined $number || ! defined $workspaceObj || ! defined $owner) { | ||
| 7965 | |||
| 7966 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 7967 | } | ||
| 7968 | |||
| 7969 | # Object viewer windows are unique to their session. If no $session is specified, refuse to | ||
| 7970 | # create a window object | ||
| 7971 | if (! $session) { | ||
| 7972 | |||
| 7973 | return undef; | ||
| 7974 | } | ||
| 7975 | |||
| 7976 | # Setup | ||
| 7977 | my $self = { | ||
| 7978 | _objName => 'other_win_' . $number, | ||
| 7979 | _objClass => $class, | ||
| 7980 | _parentFile => undef, # No parent file object | ||
| 7981 | _parentWorld => undef, # No parent file object | ||
| 7982 | _privFlag => TRUE, # All IVs are private | ||
| 7983 | |||
| 7984 | # Standard window object IVs | ||
| 7985 | # -------------------------- | ||
| 7986 | |||
| 7987 | # Unique number for this window object | ||
| 7988 | number => $number, | ||
| 7989 | # The window category - 'grid' or 'free' | ||
| 7990 | winCategory => 'free', | ||
| 7991 | # The window type, any of the keys in GA::Client->constFreeWinTypeHash | ||
| 7992 | winType => 'viewer', | ||
| 7993 | # A name for the window (for some 'free' windows, the same as the window type) | ||
| 7994 | winName => 'viewer', | ||
| 7995 | # The GA::Obj::Workspace object for the workspace in which this window is created | ||
| 7996 | workspaceObj => $workspaceObj, | ||
| 7997 | # The owner; a 'grid' window object (but not an 'external' window) or a 'free' window | ||
| 7998 | # object. When this window opens/closes, the owner is informed via calls to its | ||
| 7999 | # ->add_childFreeWin / ->del_childFreeWin functions | ||
| 8000 | owner => $owner, | ||
| 8001 | # The GA::Session from which this function was called. 'undef' if the calling function | ||
| 8002 | # didn't specify a session and $owner's ->session IV is also 'undef' | ||
| 8003 | session => $session, | ||
| 8004 | # When GA::Session->pseudoCmd is called to execute a client command, the mode in which | ||
| 8005 | # it should be called (usually 'win_error' or 'win_only', which causes errors to be | ||
| 8006 | # displayed in a 'dialogue' window) | ||
| 8007 | pseudoCmdMode => 'win_error', | ||
| 8008 | |||
| 8009 | # The window widget. For most window objects, the Gtk3::Window. For pseudo-windows, the | ||
| 8010 | # parent 'main' window's Gtk3::Window | ||
| 8011 | # The code should use this IV when it wants to do something to the window itself | ||
| 8012 | # (minimise it, make it active, etc) | ||
| 8013 | winWidget => undef, | ||
| 8014 | # The window container. For most window objects, the Gtk3::Window. For pseudo-windows, | ||
| 8015 | # the parent GA::Table::PseudoWin table object | ||
| 8016 | # The code should use this IV when it wants to add, modify or remove widgets inside the | ||
| 8017 | # window itself | ||
| 8018 | winBox => undef, | ||
| 8019 | # Flag set to TRUE if the window actually exists (after a call to $self->winEnable), | ||
| 8020 | # FALSE if not | ||
| 8021 | enabledFlag => FALSE, | ||
| 8022 | # Flag set to TRUE if the Gtk3 window itself is visible (after a call to | ||
| 8023 | # $self->setVisible), FALSE if it is not visible (after a call to $self->setInvisible) | ||
| 8024 | visibleFlag => TRUE, | ||
| 8025 | # Registry hash of 'free' windows (excluding 'dialogue' windows) for which this window | ||
| 8026 | # is the parent, a subset of GA::Obj::Desktop->freeWinHash. Hash in the form | ||
| 8027 | # $childFreeWinHash{unique_number} = blessed_reference_to_window_object | ||
| 8028 | childFreeWinHash => {}, | ||
| 8029 | # When a child 'free' window (excluding 'dialogue' windows) is destroyed, this parent | ||
| 8030 | # window is informed via a call to $self->del_childFreeWin | ||
| 8031 | # When the child is destroyed, this window might want to call some of its own functions | ||
| 8032 | # to update various widgets and/or IVs, in which case this window adds an entry to | ||
| 8033 | # this hash; a hash in the form | ||
| 8034 | # $childDestroyHash{unique_number} = list_reference | ||
| 8035 | # ...where 'unique_number' is the child window's ->number, and 'list_reference' is a | ||
| 8036 | # reference to a list in groups of 2, in the form | ||
| 8037 | # (sub_name, argument_list_ref, sub_name, argument_list_ref...) | ||
| 8038 | childDestroyHash => {}, | ||
| 8039 | |||
| 8040 | # The container widget into which all other widgets are packed (usually a Gtk3::VBox or | ||
| 8041 | # Gtk3::HBox, but any container widget can be used; takes up the whole window client | ||
| 8042 | # area) | ||
| 8043 | packingBox => undef, | ||
| 8044 | |||
| 8045 | # Standard IVs for 'free' windows | ||
| 8046 | |||
| 8047 | # The window's default size, in pixels | ||
| 8048 | widthPixels => $axmud::CLIENT->customFreeWinWidth, | ||
| 8049 | heightPixels => $axmud::CLIENT->customFreeWinHeight, | ||
| 8050 | # Default border/item spacing sizes used in the window, in pixels | ||
| 8051 | # (A border width of 1 pixel or more would leave the background photo exposed) | ||
| 8052 | borderPixels => 0, | ||
| 8053 | spacingPixels => $axmud::CLIENT->constFreeSpacingPixels, | ||
| 8054 | |||
| 8055 | # A string to use as the window title. If 'undef', a generic title is used | ||
| 8056 | title => $axmud::SCRIPT . ' object viewer', | ||
| 8057 | # Hash containing any number of key-value pairs needed for this particular 'free' | ||
| 8058 | # window; for example, for example, GA::PrefWin::TaskStart uses it to specify a task | ||
| 8059 | # name and type. Set to an empty hash if not required | ||
| 8060 | configHash => {%configHash}, | ||
| 8061 | |||
| 8062 | # IVs for this type of window | ||
| 8063 | |||
| 8064 | # Widgets | ||
| 8065 | |||
| 8066 | # A horizontal pane, dividing the treeview on the left from everything else on the right | ||
| 8067 | hPaned => undef, # Gtk3::HPaned | ||
| 8068 | # The treeview components | ||
| 8069 | treeViewModel => undef, # Gtk3::TreeStore | ||
| 8070 | treeView => undef, # Gtk3::TreeView | ||
| 8071 | treeViewScroller => undef, # Gtk3::ScrolledWindow | ||
| 8072 | # Another horizontal pane, dividing the strip of buttons on the right from everything | ||
| 8073 | # in the middle | ||
| 8074 | hPaned2 => undef, # Gtk3::HPaned | ||
| 8075 | # The notebook | ||
| 8076 | notebook => undef, # Gtk3::Notebook | ||
| 8077 | # A second vertical packing box containing the strip of buttons | ||
| 8078 | vBox => undef, # Gtk3::VBox | ||
| 8079 | # The buttons themselves (children of $self->vBox2) - also contains any separators used | ||
| 8080 | # in the button strip | ||
| 8081 | buttonList => [], | ||
| 8082 | |||
| 8083 | # The object viewer window is divided into three areas - a treeview on the left, | ||
| 8084 | # something in the middle, and a strip of buttons on the right (which are sometimes | ||
| 8085 | # invisible) | ||
| 8086 | # The widths of these areas (in pixels). When the strip of buttons is hidden, the middle | ||
| 8087 | # area swallows up the right area, and the right area is hidden | ||
| 8088 | leftWidth => int ($axmud::CLIENT->constFreeWinWidth * 0.3), | ||
| 8089 | centreWidth => int ($axmud::CLIENT->constFreeWinWidth * 0.5), | ||
| 8090 | rightWidth => int ($axmud::CLIENT->constFreeWinWidth * 0.2), | ||
| 8091 | |||
| 8092 | # Which layout the notebook is using: | ||
| 8093 | # 'empty' - contains nothing | ||
| 8094 | # 'list' - a GA::Obj::SimpleList on the left, and buttons on the right | ||
| 8095 | # 'text' - a Gtk3::TextView | ||
| 8096 | notebookMode => 'empty', | ||
| 8097 | # Which kind of notebook is currently being displayed - namely, which header in the | ||
| 8098 | # treeview was the last one clicked (matches a key in $self->headerHash) | ||
| 8099 | notebookCurrentHeader => undef, | ||
| 8100 | # When the user double-clicks an item in the notebook's list, the reference of the | ||
| 8101 | # function which should be called in response (usually to make double-clicking the | ||
| 8102 | # equivalent of clicking on one of the buttons) | ||
| 8103 | # Set to 'undef' if nothing should happen | ||
| 8104 | notebookSelectRef => undef, | ||
| 8105 | |||
| 8106 | # Hash of treeview headers, in the form | ||
| 8107 | # $headerHash{header_string} = ref_of_subroutine | ||
| 8108 | headerHash => {}, | ||
| 8109 | |||
| 8110 | # List of notebok 'tab_name's in the same order used in the window | ||
| 8111 | # (match the keys of ->notebookTabHash) | ||
| 8112 | notebookTabList => [], | ||
| 8113 | # Hash of notebook tabs, in the form | ||
| 8114 | # $notebookTagHash{tab_name} = reference_to_Gtk3::Label_of_tab | ||
| 8115 | notebookTabHash => {}, | ||
| 8116 | # Hash of data lists displayed in the notebook, in the form | ||
| 8117 | # $notebookDataHash{tab_name} = reference_to_GA::Obj::SimpleList | ||
| 8118 | notebookDataHash => {}, | ||
| 8119 | |||
| 8120 | # To access Axbasic's default data, $self->setupTreeView creates a dummy | ||
| 8121 | # Language::Axbasic::Script object, which is stored here so that functions like | ||
| 8122 | # $self->axbasicHeader can use it | ||
| 8123 | dummyScriptObj => undef, | ||
| 8124 | }; | ||
| 8125 | |||
| 8126 | # Bless the object into existence | ||
| 8127 | bless $self, $class; | ||
| 8128 | |||
| 8129 | return $self; | ||
| 8130 | } | ||
| 8131 | |||
| 8132 | ################## | ||
| 8133 | # Methods | ||
| 8134 | |||
| 8135 | # Standard window object functions | ||
| 8136 | |||
| 8137 | # sub winSetup {} # Inherited from GA::Generic::FreeWin | ||
| 8138 | |||
| 8139 | sub winEnable { | ||
| 8140 | |||
| 8141 | # Called by GA::Generic::Win->createFreeWin, after the call to $self->winSetup | ||
| 8142 | # After the Gtk3::Window has been setup and moved into position, makes it visible | ||
| 8143 | # | ||
| 8144 | # Expected arguments | ||
| 8145 | # (none besides $self) | ||
| 8146 | # | ||
| 8147 | # Return values | ||
| 8148 | # 'undef' on improper arguments | ||
| 8149 | # 1 on success | ||
| 8150 | |||
| 8151 | my ($self, $check) = @_; | ||
| 8152 | |||
| 8153 | # Check for improper arguments | ||
| 8154 | if (defined $check) { | ||
| 8155 | |||
| 8156 | return $axmud::CLIENT->writeImproper($self->_objClass . '->winEnable', @_); | ||
| 8157 | } | ||
| 8158 | |||
| 8159 | # Make the window appear on the desktop | ||
| 8160 | $self->winShowAll($self->_objClass . '->winEnable'); | ||
| 8161 | $self->ivPoke('enabledFlag', TRUE); | ||
| 8162 | |||
| 8163 | # This type of window is unique to its GA::Session (only one can be open at any time, per | ||
| 8164 | # session); inform the session it has opened | ||
| 8165 | $self->session->set_viewerWin($self); | ||
| 8166 | |||
| 8167 | return 1; | ||
| 8168 | } | ||
| 8169 | |||
| 8170 | # sub winDesengage {} # Inherited from GA::Generic::FreeWin | ||
| 8171 | |||
| 8172 | sub winDestroy { | ||
| 8173 | |||
| 8174 | # Can be called by anything | ||
| 8175 | # Updates IVs | ||
| 8176 | # | ||
| 8177 | # Expected arguments | ||
| 8178 | # (none besides $self) | ||
| 8179 | # | ||
| 8180 | # Return values | ||
| 8181 | # 'undef' on improper arguments, if the window can't be destroyed or if it has already | ||
| 8182 | # been destroyed | ||
| 8183 | # 1 on success | ||
| 8184 | |||
| 8185 | my ($self, $check) = @_; | ||
| 8186 | |||
| 8187 | # Check for improper arguments | ||
| 8188 | if (defined $check) { | ||
| 8189 | |||
| 8190 | return $axmud::CLIENT->writeImproper($self->_objClass . '->winDestroy', @_); | ||
| 8191 | } | ||
| 8192 | |||
| 8193 | if (! $self->winBox) { | ||
| 8194 | |||
| 8195 | # Window already destroyed in a previous call to this function | ||
| 8196 | return undef; | ||
| 8197 | } | ||
| 8198 | |||
| 8199 | # Close any 'free' windows for which this window is a parent | ||
| 8200 | foreach my $winObj ($self->ivValues('childFreeWinHash')) { | ||
| 8201 | |||
| 8202 | $winObj->winDestroy(); | ||
| 8203 | } | ||
| 8204 | |||
| 8205 | # Destroy the Gtk3::Window | ||
| 8206 | eval { $self->winBox->destroy(); }; | ||
| 8207 | if ($@) { | ||
| 8208 | |||
| 8209 | # Window can't be destroyed | ||
| 8210 | return undef; | ||
| 8211 | |||
| 8212 | } else { | ||
| 8213 | |||
| 8214 | $self->ivUndef('winWidget'); | ||
| 8215 | $self->ivUndef('winBox'); | ||
| 8216 | } | ||
| 8217 | |||
| 8218 | # Inform the owner and the desktop object of this 'free' window's demise | ||
| 8219 | $axmud::CLIENT->desktopObj->del_freeWin($self); | ||
| 8220 | if ($self->owner) { | ||
| 8221 | |||
| 8222 | $self->owner->del_childFreeWin($self); | ||
| 8223 | } | ||
| 8224 | |||
| 8225 | # This type of window is unique to its GA::Session (only one can be open at any time, per | ||
| 8226 | # session); inform the session it has closed | ||
| 8227 | $self->session->set_viewerWin(); | ||
| 8228 | |||
| 8229 | return 1; | ||
| 8230 | } | ||
| 8231 | |||
| 8232 | # sub winShowAll {} # Inherited from GA::Generic::Win | ||
| 8233 | |||
| 8234 | sub drawWidgets { | ||
| 8235 | |||
| 8236 | # Called by $self->winSetup | ||
| 8237 | # Sets up the object viewer window with its standard widgets | ||
| 8238 | # | ||
| 8239 | # Expected arguments | ||
| 8240 | # (none besides $self) | ||
| 8241 | # | ||
| 8242 | # Return values | ||
| 8243 | # 'undef' on improper arguments | ||
| 8244 | # 1 otherwise | ||
| 8245 | |||
| 8246 | my ($self, $check) = @_; | ||
| 8247 | |||
| 8248 | # Check for improper arguments | ||
| 8249 | if (defined $check) { | ||
| 8250 | |||
| 8251 | return $axmud::CLIENT->writeImproper($self->_objClass . '->drawWidgets', @_); | ||
| 8252 | } | ||
| 8253 | |||
| 8254 | # Create a packing box | ||
| 8255 | my $packingBox = Gtk3::VBox->new(FALSE, 0); | ||
| 8256 | $self->winBox->add($packingBox); | ||
| 8257 | $packingBox->set_border_width(0); | ||
| 8258 | |||
| 8259 | # Create a horizontal pane to divide the window into two, with the treeview on the left, and | ||
| 8260 | # everything else on the right | ||
| 8261 | my $hPaned = Gtk3::HPaned->new(); | ||
| 8262 | $packingBox->pack_start($hPaned, TRUE, TRUE, 0); | ||
| 8263 | |||
| 8264 | # Add a treeview on the left of the window | ||
| 8265 | my $treeViewModel = Gtk3::TreeStore->new( ['Glib::String'] ); | ||
| 8266 | my $treeView = Gtk3::TreeView->new($treeViewModel); | ||
| 8267 | $treeView->set_enable_search(FALSE); | ||
| 8268 | # Append a single column to the treeview | ||
| 8269 | $treeView->append_column( | ||
| 8270 | Gtk3::TreeViewColumn->new_with_attributes( | ||
| 8271 | 'Objects', | ||
| 8272 | Gtk3::CellRendererText->new, | ||
| 8273 | text => 0, | ||
| 8274 | ) | ||
| 8275 | ); | ||
| 8276 | |||
| 8277 | # Make the treeview scrollable | ||
| 8278 | my $treeViewScroller = Gtk3::ScrolledWindow->new(); | ||
| 8279 | $hPaned->pack1($treeViewScroller, FALSE, FALSE); | ||
| 8280 | $treeViewScroller->add($treeView); | ||
| 8281 | $treeViewScroller->set_policy(qw/automatic automatic/); | ||
| 8282 | |||
| 8283 | # Make the branches of the list tree clickable, so the rows can be expanded and collapsed | ||
| 8284 | $treeView->signal_connect('row_activated' => \&treeViewRowActivated, $self); | ||
| 8285 | # Respond to clicks on the treeview | ||
| 8286 | $treeView->get_selection->set_mode('browse'); | ||
| 8287 | $treeView->get_selection->signal_connect('changed' => \&treeViewChanged, $self); | ||
| 8288 | |||
| 8289 | # Fill the tree | ||
| 8290 | $self->setupTreeView($treeView); | ||
| 8291 | |||
| 8292 | # Add a notebook on the right. Later, this might be replaced by a second Gtk3::HPaned | ||
| 8293 | my $notebook = Gtk3::Notebook->new(); | ||
| 8294 | $hPaned->pack2($notebook, TRUE, FALSE); | ||
| 8295 | $notebook->set_scrollable(TRUE); | ||
| 8296 | $notebook->popup_enable(); | ||
| 8297 | |||
| 8298 | $hPaned->set_position($self->leftWidth); | ||
| 8299 | |||
| 8300 | # Set up the window's background photo using a CSS style | ||
| 8301 | my $provider = Gtk3::CssProvider->new(); | ||
| 8302 | my $display = Gtk3::Gdk::Display::get_default(); | ||
| 8303 | my $screen = Gtk3::Gdk::Display::get_default_screen($display); | ||
| 8304 | # (Don't call ->add_provider_for_screen so that the style is only applied to this window) | ||
| 8305 | # Gtk3::StyleContext::add_provider_for_screen($screen, $provider, 600); | ||
| 8306 | |||
| 8307 | my $imagePath = $axmud::SHARE_DIR . '/images/viewerbg.jpg'; | ||
| 8308 | |||
| 8309 | my $theming = "#css_oov_id, window.background {\n"; | ||
| 8310 | $theming .= " background-image: url(\"$imagePath\");\n"; | ||
| 8311 | $theming .= " background-repeat: repeat;\n"; | ||
| 8312 | $theming .= " background-position: top left;\n"; | ||
| 8313 | $theming .= "}"; | ||
| 8314 | |||
| 8315 | $provider->load_from_data ([map ord, split //, $theming]); | ||
| 8316 | |||
| 8317 | my $context = $self->winWidget->get_style_context(); | ||
| 8318 | $context->add_provider($provider, 600); | ||
| 8319 | |||
| 8320 | # Update IVs | ||
| 8321 | $self->ivPoke('packingBox', $packingBox); | ||
| 8322 | $self->ivPoke('hPaned', $hPaned); | ||
| 8323 | $self->ivPoke('treeViewModel', $treeViewModel); | ||
| 8324 | $self->ivPoke('treeView', $treeView); | ||
| 8325 | $self->ivPoke('treeViewScroller', $treeViewScroller); | ||
| 8326 | $self->ivPoke('notebook', $notebook); | ||
| 8327 | |||
| 8328 | return 1; | ||
| 8329 | } | ||
| 8330 | |||
| 8331 | # sub redrawWidgets {} # Inherited from GA::Generic::Win | ||
| 8332 | |||
| 8333 | # ->signal_connects | ||
| 8334 | |||
| 8335 | # Other functions | ||
| 8336 | |||
| 8337 | # Set up widgets | ||
| 8338 | |||
| 8339 | sub setupTreeView { | ||
| 8340 | |||
| 8341 | # Called by $self->enable | ||
| 8342 | # Fills the object tree on the left of the window | ||
| 8343 | # | ||
| 8344 | # Expected arguments | ||
| 8345 | # $treeView - The Gtk3::TreeView widget | ||
| 8346 | # | ||
| 8347 | # Return values | ||
| 8348 | # 'undef' on improper arguments | ||
| 8349 | # 1 otherwise | ||
| 8350 | |||
| 8351 | my ($self, $treeView, $check) = @_; | ||
| 8352 | |||
| 8353 | # Local variables | ||
| 8354 | my ( | ||
| 8355 | $model, $pointer, $child, $grandChild, $greatGrandChild, $greatGreatGrandChild, | ||
| 8356 | $scriptObj, | ||
| 8357 | @sortedList, @functionList, @taskList, | ||
| 8358 | %functionHash, | ||
| 8359 | ); | ||
| 8360 | |||
| 8361 | # Check for improper arguments | ||
| 8362 | if (! defined $treeView || defined $check) { | ||
| 8363 | |||
| 8364 | return $axmud::CLIENT->writeImproper($self->_objClass . '->setupTreeView', @_); | ||
| 8365 | } | ||
| 8366 | |||
| 8367 | # Fill a model of the tree, not the tree itself | ||
| 8368 | $model = $treeView->get_model(); | ||
| 8369 | $model->clear(); | ||
| 8370 | |||
| 8371 | # Profiles | ||
| 8372 | $pointer = $model->append(undef); | ||
| 8373 | $model->set($pointer, [0], ['Profiles']); | ||
| 8374 | |||
| 8375 | $child = $model->append($pointer); | ||
| 8376 | $model->set($child, [0], ['All profiles']); | ||
| 8377 | $self->ivAdd('headerHash', 'All profiles', 'allProfHeader'); | ||
| 8378 | $child = $model->append($pointer); | ||
| 8379 | $model->set($child, [0], ['Current profiles']); | ||
| 8380 | $self->ivAdd('headerHash', 'Current profile', 'currentProfHeader'); | ||
| 8381 | $child = $model->append($pointer); | ||
| 8382 | $model->set($child, [0], ['Profile templates']); | ||
| 8383 | $self->ivAdd('headerHash', 'Profile templates', 'templateHeader'); | ||
| 8384 | $child = $model->append($pointer); | ||
| 8385 | $model->set($child, [0], ['Profile priority list']); | ||
| 8386 | $self->ivAdd('headerHash', 'Profile priority list', 'profPriorityHeader'); | ||
| 8387 | |||
| 8388 | # Cages | ||
| 8389 | $pointer = $model->append(undef); | ||
| 8390 | $model->set($pointer, [0], ['Cages']); | ||
| 8391 | |||
| 8392 | $child = $model->append($pointer); | ||
| 8393 | $model->set($child, [0], ['All cages']); | ||
| 8394 | $self->ivAdd('headerHash', 'All cages', 'allCageHeader'); | ||
| 8395 | $child = $model->append($pointer); | ||
| 8396 | $model->set($child, [0], ['Current cages']); | ||
| 8397 | $self->ivAdd('headerHash', 'Current cages', 'currentCageHeader'); | ||
| 8398 | $child = $model->append($pointer); | ||
| 8399 | $model->set($child, [0], ['Active interfaces']); | ||
| 8400 | $self->ivAdd('headerHash', 'Active interfaces', 'activeInterfaceHeader'); | ||
| 8401 | $child = $model->append($pointer); | ||
| 8402 | $model->set($child, [0], ['Interface models']); | ||
| 8403 | $self->ivAdd('headerHash', 'Interface models', 'interfaceModelHeader'); | ||
| 8404 | |||
| 8405 | # Dictionaries | ||
| 8406 | $pointer = $model->append(undef); | ||
| 8407 | $model->set($pointer, [0], ['Dictionaries']); | ||
| 8408 | |||
| 8409 | $child = $model->append($pointer); | ||
| 8410 | $model->set($child, [0], ['All dictionaries']); | ||
| 8411 | $self->ivAdd('headerHash', 'All dictionaries', 'allDictHeader'); | ||
| 8412 | $child = $model->append($pointer); | ||
| 8413 | $model->set($child, [0], ['Current dictionary']); | ||
| 8414 | $self->ivAdd('headerHash', 'Current dictionary', 'currentDictHeader'); | ||
| 8415 | |||
| 8416 | # Tasks | ||
| 8417 | $pointer = $model->append(undef); | ||
| 8418 | $model->set($pointer, [0], ['Tasks']); | ||
| 8419 | |||
| 8420 | $child = $model->append($pointer); | ||
| 8421 | $model->set($child, [0], ['Available tasks']); | ||
| 8422 | $self->ivAdd('headerHash', 'Available tasks', 'availableTaskHeader'); | ||
| 8423 | $child = $model->append($pointer); | ||
| 8424 | $model->set($child, [0], ['Current tasklist']); | ||
| 8425 | $self->ivAdd('headerHash', 'Current tasklist', 'currentTaskHeader'); | ||
| 8426 | $child = $model->append($pointer); | ||
| 8427 | $model->set($child, [0], ['Global initial tasklist']); | ||
| 8428 | $self->ivAdd('headerHash', 'Global initial tasklist', 'initialTaskHeader'); | ||
| 8429 | $child = $model->append($pointer); | ||
| 8430 | $model->set($child, [0], ['Custom tasklist']); | ||
| 8431 | $self->ivAdd('headerHash', 'Custom tasklist', 'customTaskHeader'); | ||
| 8432 | $child = $model->append($pointer); | ||
| 8433 | $model->set($child, [0], ['Task package names']); | ||
| 8434 | $self->ivAdd('headerHash', 'Task package names', 'taskPackageHeader'); | ||
| 8435 | $child = $model->append($pointer); | ||
| 8436 | $model->set($child, [0], ['Task labels']); | ||
| 8437 | $self->ivAdd('headerHash', 'Task labels', 'taskLabelHeader'); | ||
| 8438 | |||
| 8439 | # World model | ||
| 8440 | $pointer = $model->append(undef); | ||
| 8441 | $model->set($pointer, [0], ['World model']); | ||
| 8442 | |||
| 8443 | $child = $model->append($pointer); | ||
| 8444 | $model->set($child, [0], ['All objects']); | ||
| 8445 | $self->ivAdd('headerHash', 'All objects', 'allModelHeader'); | ||
| 8446 | $child = $model->append($pointer); | ||
| 8447 | $model->set($child, [0], ['Regions']); | ||
| 8448 | $self->ivAdd('headerHash', 'Regions', 'regionModelHeader'); | ||
| 8449 | $child = $model->append($pointer); | ||
| 8450 | $model->set($child, [0], ['Rooms']); | ||
| 8451 | $self->ivAdd('headerHash', 'Rooms', 'roomModelHeader'); | ||
| 8452 | $child = $model->append($pointer); | ||
| 8453 | $model->set($child, [0], ['Weapons']); | ||
| 8454 | $self->ivAdd('headerHash', 'Weapons', 'weaponModelHeader'); | ||
| 8455 | $child = $model->append($pointer); | ||
| 8456 | $model->set($child, [0], ['Armours']); | ||
| 8457 | $self->ivAdd('headerHash', 'Armours', 'armourModelHeader'); | ||
| 8458 | $child = $model->append($pointer); | ||
| 8459 | $model->set($child, [0], ['Garments']); | ||
| 8460 | $self->ivAdd('headerHash', 'Garments', 'garmentModelHeader'); | ||
| 8461 | $child = $model->append($pointer); | ||
| 8462 | $model->set($child, [0], ['Characters']); | ||
| 8463 | $self->ivAdd('headerHash', 'Characters', 'charModelHeader'); | ||
| 8464 | $child = $model->append($pointer); | ||
| 8465 | $model->set($child, [0], ['Minions']); | ||
| 8466 | $self->ivAdd('headerHash', 'Minions', 'minionModelHeader'); | ||
| 8467 | $child = $model->append($pointer); | ||
| 8468 | $model->set($child, [0], ['Sentients']); | ||
| 8469 | $self->ivAdd('headerHash', 'Sentients', 'sentientModelHeader'); | ||
| 8470 | $child = $model->append($pointer); | ||
| 8471 | $model->set($child, [0], ['Creatures']); | ||
| 8472 | $self->ivAdd('headerHash', 'Creatures', 'creatureModelHeader'); | ||
| 8473 | $child = $model->append($pointer); | ||
| 8474 | $model->set($child, [0], ['Portables']); | ||
| 8475 | $self->ivAdd('headerHash', 'Portables', 'portableModelHeader'); | ||
| 8476 | $child = $model->append($pointer); | ||
| 8477 | $model->set($child, [0], ['Decorations']); | ||
| 8478 | $self->ivAdd('headerHash', 'Decorations', 'decorationModelHeader'); | ||
| 8479 | $child = $model->append($pointer); | ||
| 8480 | $model->set($child, [0], ['Custom objects']); | ||
| 8481 | $self->ivAdd('headerHash', 'Custom objects', 'customModelHeader'); | ||
| 8482 | $child = $model->append($pointer); | ||
| 8483 | $model->set($child, [0], ['Exits']); | ||
| 8484 | $self->ivAdd('headerHash', 'Exits', 'exitModelHeader'); | ||
| 8485 | |||
| 8486 | # Buffers | ||
| 8487 | $pointer = $model->append(undef); | ||
| 8488 | $model->set($pointer, [0], ['Buffers']); | ||
| 8489 | |||
| 8490 | $child = $model->append($pointer); | ||
| 8491 | $model->set($child, [0], ['Display buffer']); | ||
| 8492 | $self->ivAdd('headerHash', 'Display buffer', 'displayBufferHeader'); | ||
| 8493 | $child = $model->append($pointer); | ||
| 8494 | $model->set($child, [0], ['Instruction buffer']); | ||
| 8495 | $self->ivAdd('headerHash', 'Instruction buffer', 'instructBufferHeader'); | ||
| 8496 | $child = $model->append($pointer); | ||
| 8497 | $model->set($child, [0], ['Command buffer']); | ||
| 8498 | $self->ivAdd('headerHash', 'Command buffer', 'cmdBufferHeader'); | ||
| 8499 | |||
| 8500 | # Other objects | ||
| 8501 | $pointer = $model->append(undef); | ||
| 8502 | $model->set($pointer, [0], ['Other objects']); | ||
| 8503 | |||
| 8504 | $child = $model->append($pointer); | ||
| 8505 | $model->set($child, [0], ['Chat contacts']); | ||
| 8506 | $self->ivAdd('headerHash', 'Chat contacts', 'chatContactHeader'); | ||
| 8507 | |||
| 8508 | $child = $model->append($pointer); | ||
| 8509 | $model->set($child, [0], ['Colour schemes']); | ||
| 8510 | $self->ivAdd('headerHash', 'Colour schemes', 'colourSchemeHeader'); | ||
| 8511 | |||
| 8512 | $child = $model->append($pointer); | ||
| 8513 | $model->set($child, [0], ['Map label styles']); | ||
| 8514 | $self->ivAdd('headerHash', 'Map label styles', 'mapLabelStyleHeader'); | ||
| 8515 | |||
| 8516 | $child = $model->append($pointer); | ||
| 8517 | $model->set($child, [0], ['Region colour schemes']); | ||
| 8518 | $self->ivAdd('headerHash', 'Region colour schemes', 'regionSchemeHeader'); | ||
| 8519 | |||
| 8520 | $child = $model->append($pointer); | ||
| 8521 | $model->set($child, [0], ['TTS configurations']); | ||
| 8522 | $self->ivAdd('headerHash', 'TTS configurations', 'ttsHeader'); | ||
| 8523 | |||
| 8524 | $child = $model->append($pointer); | ||
| 8525 | $model->set($child, [0], ['Winmaps']); | ||
| 8526 | $self->ivAdd('headerHash', 'Winmaps', 'winmapHeader'); | ||
| 8527 | |||
| 8528 | $child = $model->append($pointer); | ||
| 8529 | $model->set($child, [0], ['Zonemaps']); | ||
| 8530 | $self->ivAdd('headerHash', 'Zonemaps', 'zonemapHeader'); | ||
| 8531 | |||
| 8532 | # Help | ||
| 8533 | $pointer = $model->append(undef); | ||
| 8534 | $model->set($pointer, [0], ['Help']); | ||
| 8535 | |||
| 8536 | # Quick help | ||
| 8537 | $child = $model->append($pointer); | ||
| 8538 | $model->set($child, [0], ['Quick help']); | ||
| 8539 | $self->ivAdd('headerHash', 'Quick help', 'quickHelpHeader'); | ||
| 8540 | |||
| 8541 | # Client command Help | ||
| 8542 | $child = $model->append($pointer); | ||
| 8543 | $model->set($child, [0], ['Client commands']); | ||
| 8544 | |||
| 8545 | $grandChild = $model->append($child); | ||
| 8546 | $model->set($grandChild, [0], ['Categorised commands']); | ||
| 8547 | |||
| 8548 | foreach my $item ($axmud::CLIENT->clientCmdPrettyList) { | ||
| 8549 | |||
| 8550 | if (index ($item, '@') == 0) { | ||
| 8551 | |||
| 8552 | # It's a group heading, so remove the @ character | ||
| 8553 | $item =~ s/\@//; | ||
| 8554 | $greatGrandChild = $model->append($grandChild); | ||
| 8555 | $model->set($greatGrandChild, [0], [$item]); | ||
| 8556 | |||
| 8557 | } else { | ||
| 8558 | |||
| 8559 | # It's a client command, which begins with ; to distinguish it from Axbasic items | ||
| 8560 | $item = $axmud::CLIENT->cmdSep . lc($item); | ||
| 8561 | $greatGreatGrandChild = $model->append($greatGrandChild); | ||
| 8562 | $model->set($greatGreatGrandChild, [0], [$item]); | ||
| 8563 | $self->ivAdd('headerHash', $item, 'cmdHeader'); | ||
| 8564 | } | ||
| 8565 | } | ||
| 8566 | |||
| 8567 | $grandChild = $model->append($child); | ||
| 8568 | $model->set($grandChild, [0], ['Sorted commands']); | ||
| 8569 | |||
| 8570 | @sortedList = sort {$a cmp $b} ($axmud::CLIENT->clientCmdList); | ||
| 8571 | foreach my $item (@sortedList) { | ||
| 8572 | |||
| 8573 | # It's a client command, which begins with ; to distinguish it from Axbasic items | ||
| 8574 | $item = $axmud::CLIENT->cmdSep . lc($item); | ||
| 8575 | $greatGrandChild = $model->append($grandChild); | ||
| 8576 | $model->set($greatGrandChild, [0], [$item]); | ||
| 8577 | $self->ivAdd('headerHash', $item, 'cmdHeader'); | ||
| 8578 | } | ||
| 8579 | |||
| 8580 | # Axbasic Help | ||
| 8581 | |||
| 8582 | # Create a dummy LA::Script object so we can access the default instance variables and help | ||
| 8583 | # functions | ||
| 8584 | $scriptObj = Language::Axbasic::Script->new($self->session); | ||
| 8585 | if ($scriptObj) { | ||
| 8586 | |||
| 8587 | $child = $model->append($pointer); | ||
| 8588 | $model->set($child, [0], [$axmud::BASIC_NAME . ' help']); | ||
| 8589 | |||
| 8590 | $grandChild = $model->append($child); | ||
| 8591 | $model->set($grandChild, [0], ['Keywords']); | ||
| 8592 | |||
| 8593 | foreach my $item ($scriptObj->keywordList) { | ||
| 8594 | |||
| 8595 | $greatGrandChild = $model->append($grandChild); | ||
| 8596 | $model->set($greatGrandChild, [0], [$item]); | ||
| 8597 | $self->ivAdd('headerHash', $item, 'axbasicKeywordHeader'); | ||
| 8598 | } | ||
| 8599 | |||
| 8600 | $grandChild = $model->append($child); | ||
| 8601 | $model->set($grandChild, [0], ['Modern keywords']); | ||
| 8602 | |||
| 8603 | foreach my $item ($scriptObj->modernKeywordList) { | ||
| 8604 | |||
| 8605 | $greatGrandChild = $model->append($grandChild); | ||
| 8606 | $model->set($greatGrandChild, [0], [$item]); | ||
| 8607 | $self->ivAdd('headerHash', $item, 'axbasicKeywordHeader'); | ||
| 8608 | } | ||
| 8609 | |||
| 8610 | $grandChild = $model->append($child); | ||
| 8611 | $model->set($grandChild, [0], ['Primitive keywords']); | ||
| 8612 | |||
| 8613 | foreach my $item ($scriptObj->primKeywordList) { | ||
| 8614 | |||
| 8615 | $greatGrandChild = $model->append($grandChild); | ||
| 8616 | $model->set($greatGrandChild, [0], [$item]); | ||
| 8617 | $self->ivAdd('headerHash', $item, 'axbasicKeywordHeader'); | ||
| 8618 | } | ||
| 8619 | |||
| 8620 | $grandChild = $model->append($child); | ||
| 8621 | $model->set($grandChild, [0], ['Weak keywords']); | ||
| 8622 | |||
| 8623 | @sortedList = sort {$a cmp $b} ($scriptObj->ivKeys('weakKeywordHash')); | ||
| 8624 | foreach my $item (@sortedList) { | ||
| 8625 | |||
| 8626 | $greatGrandChild = $model->append($grandChild); | ||
| 8627 | $model->set($greatGrandChild, [0], [$item]); | ||
| 8628 | $self->ivAdd('headerHash', $item, 'axbasicKeywordHeader'); | ||
| 8629 | } | ||
| 8630 | |||
| 8631 | $grandChild = $model->append($child); | ||
| 8632 | $model->set($grandChild, [0], ['Client keywords']); | ||
| 8633 | |||
| 8634 | foreach my $item ($scriptObj->clientKeywordList) { | ||
| 8635 | |||
| 8636 | $greatGrandChild = $model->append($grandChild); | ||
| 8637 | $model->set($greatGrandChild, [0], [$item]); | ||
| 8638 | $self->ivAdd('headerHash', $item, 'axbasicKeywordHeader'); | ||
| 8639 | } | ||
| 8640 | |||
| 8641 | $grandChild = $model->append($child); | ||
| 8642 | $model->set($grandChild, [0], ['Task keywords']); | ||
| 8643 | |||
| 8644 | foreach my $item ($scriptObj->taskKeywordList) { | ||
| 8645 | |||
| 8646 | $greatGrandChild = $model->append($grandChild); | ||
| 8647 | $model->set($greatGrandChild, [0], [$item]); | ||
| 8648 | $self->ivAdd('headerHash', $item, 'axbasicKeywordHeader'); | ||
| 8649 | } | ||
| 8650 | |||
| 8651 | $grandChild = $model->append($child); | ||
| 8652 | $model->set($grandChild, [0], ['Intrinsic functions']); | ||
| 8653 | |||
| 8654 | %functionHash = $scriptObj->funcArgHash; | ||
| 8655 | @functionList = sort {$a cmp $b} (keys %functionHash); | ||
| 8656 | foreach my $item (@functionList) { | ||
| 8657 | |||
| 8658 | $greatGrandChild = $model->append($grandChild); | ||
| 8659 | $model->set($greatGrandChild, [0], [$item]); | ||
| 8660 | $self->ivAdd('headerHash', $item, 'axbasicFuncHeader'); | ||
| 8661 | } | ||
| 8662 | |||
| 8663 | # (Store the dummy script object, so that functions like $self->axbasicKeywordHeader can | ||
| 8664 | # use it) | ||
| 8665 | $self->ivPoke('dummyScriptObj', $scriptObj); | ||
| 8666 | } | ||
| 8667 | |||
| 8668 | # Task Help | ||
| 8669 | $child = $model->append($pointer); | ||
| 8670 | $model->set($child, [0], ['Task help']); | ||
| 8671 | |||
| 8672 | @taskList = sort {lc($a) cmp lc($b)} ($axmud::CLIENT->ivKeys('taskPackageHash')); | ||
| 8673 | foreach my $task (@taskList) { | ||
| 8674 | |||
| 8675 | $grandChild = $model->append($child); | ||
| 8676 | $model->set($grandChild, [0], [$task]); | ||
| 8677 | $self->ivAdd('headerHash', $task, 'taskHeader'); | ||
| 8678 | } | ||
| 8679 | |||
| 8680 | # Peek/poke help | ||
| 8681 | $child = $model->append($pointer); | ||
| 8682 | $model->set($child, [0], ['Peek/poke strings']); | ||
| 8683 | $self->ivAdd('headerHash', 'Peek/poke strings', 'peekPokeHelpHeader'); | ||
| 8684 | |||
| 8685 | return 1; | ||
| 8686 | } | ||
| 8687 | |||
| 8688 | sub refreshNotebook { | ||
| 8689 | |||
| 8690 | # Called by $self->currentProfHeader, $self->allProfHeader, (etc etc) | ||
| 8691 | # Populates the notebook with tabs and a list, using the supplied arguments | ||
| 8692 | # (Header functions which need a textview, rather than a simple list, call | ||
| 8693 | # ->refreshTextView) | ||
| 8694 | # | ||
| 8695 | # Expected arguments | ||
| 8696 | # $tabListRef - a reference to a hash of tabs, in the format | ||
| 8697 | # [ | ||
| 8698 | # 'tab_name' => 'tab_mnemonic', | ||
| 8699 | # 'tab_name' => 'tab_mnemonic', | ||
| 8700 | # 'tab_name' => 'tab_mnemonic', | ||
| 8701 | # ... | ||
| 8702 | # ] | ||
| 8703 | # | ||
| 8704 | # $columnListRef - a list of columns used in the call to GA::Obj::SimpleList->new, in | ||
| 8705 | # the format | ||
| 8706 | # [ | ||
| 8707 | # 'column_name' => 'type', | ||
| 8708 | # 'column_name' => 'type', | ||
| 8709 | # 'column_name' => 'type', | ||
| 8710 | # ... | ||
| 8711 | # ] | ||
| 8712 | # | ||
| 8713 | # $dataHashRef - a reference to a hash. The keys are the same as the keys in | ||
| 8714 | # $tabListRef; the corresponding values contain a reference to a | ||
| 8715 | # two-dimensional list of data to be displayed in the | ||
| 8716 | # GA::Obj::SimpleList, in the form | ||
| 8717 | # [ | ||
| 8718 | # [row0_cell0, row0_cell1, row0cell2...], | ||
| 8719 | # [row1_cell0, row1_cell1, row1cell2...], | ||
| 8720 | # [row2_cell0, row2_cell1, row2cell2...], | ||
| 8721 | # ... | ||
| 8722 | # ] | ||
| 8723 | # | ||
| 8724 | # Optional arguments | ||
| 8725 | # $buttonListRef - a reference to a list of buttons, in the format | ||
| 8726 | # [ | ||
| 8727 | # 'button_name', 'tooltip', 'callback_sub_ref', | ||
| 8728 | # 'button_name', 'tooltip', 'callback_sub_ref', | ||
| 8729 | # 'button_name', 'tooltip', 'callback_sub_ref', | ||
| 8730 | # ... | ||
| 8731 | # ] | ||
| 8732 | # - if $buttonListRef is 'undef', no buttons are displayed | ||
| 8733 | # | ||
| 8734 | # $scrollFlag - if set to TRUE, the Gtk3::ScrolledWindow is scrolled to the bottom; | ||
| 8735 | # if FALSE (or 'undef'), it remains scrolled to the top | ||
| 8736 | # | ||
| 8737 | # Return values | ||
| 8738 | # 'undef' on improper arguments | ||
| 8739 | # 1 otherwise | ||
| 8740 | |||
| 8741 | my ( | ||
| 8742 | $self, $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, $scrollFlag, | ||
| 8743 | $check, | ||
| 8744 | ) = @_; | ||
| 8745 | |||
| 8746 | # Local variables | ||
| 8747 | my ( | ||
| 8748 | $number, $dataListRef, | ||
| 8749 | @tabList, @columnList, @buttonList, @scrollerList, | ||
| 8750 | %dataHash, | ||
| 8751 | ); | ||
| 8752 | |||
| 8753 | # Check for improper arguments | ||
| 8754 | if ( | ||
| 8755 | ! defined $tabListRef || ! defined $columnListRef || ! defined $dataHashRef | ||
| 8756 | || defined $check | ||
| 8757 | ) { | ||
| 8758 | return $axmud::CLIENT->writeImproper($self->_objClass . '->refreshNotebook', @_); | ||
| 8759 | } | ||
| 8760 | |||
| 8761 | # Dereference the supplied arguments | ||
| 8762 | @tabList = @$tabListRef; | ||
| 8763 | @columnList = @$columnListRef; | ||
| 8764 | %dataHash = %$dataHashRef; | ||
| 8765 | if ($buttonListRef) { | ||
| 8766 | |||
| 8767 | @buttonList = @$buttonListRef; | ||
| 8768 | }; | ||
| 8769 | |||
| 8770 | # Remove the existing tabs and buttons (if any) | ||
| 8771 | $self->resetNotebook(); | ||
| 8772 | |||
| 8773 | # If a button list was not visible, but should now be visible, do some repacking | ||
| 8774 | if (! $self->hPaned2 && $buttonListRef) { | ||
| 8775 | |||
| 8776 | # Unpack existing widgets | ||
| 8777 | $axmud::CLIENT->desktopObj->removeWidget($self->hPaned, $self->treeViewScroller); | ||
| 8778 | $axmud::CLIENT->desktopObj->removeWidget($self->hPaned, $self->notebook); | ||
| 8779 | |||
| 8780 | # Repack the treeview scroller | ||
| 8781 | $self->hPaned->pack1($self->treeViewScroller, FALSE, FALSE); | ||
| 8782 | |||
| 8783 | # Add a second horizontal pane on the right of the first one | ||
| 8784 | # In this pane, a notebook is on the left, and a strip of buttons is on the right | ||
| 8785 | my $hPaned2 = Gtk3::HPaned->new(); | ||
| 8786 | $self->hPaned->pack2($hPaned2, TRUE, FALSE); | ||
| 8787 | |||
| 8788 | # Repack the notebook on the left of $hPaned2 | ||
| 8789 | $hPaned2->pack1($self->notebook, TRUE, FALSE); | ||
| 8790 | |||
| 8791 | # Add a second vertical packing box for the strip of buttons | ||
| 8792 | my $vBox = Gtk3::VBox->new(FALSE, 0); | ||
| 8793 | $hPaned2->pack2($vBox, FALSE, FALSE); | ||
| 8794 | |||
| 8795 | $self->hPaned->set_position($self->leftWidth); | ||
| 8796 | $hPaned2->set_position($self->centreWidth); | ||
| 8797 | |||
| 8798 | # Update IVs | ||
| 8799 | $self->ivPoke('hPaned2', $hPaned2); | ||
| 8800 | $self->ivPoke('vBox', $vBox); | ||
| 8801 | |||
| 8802 | # Likewise, if the button list was visible and is no longer required, do some repacking | ||
| 8803 | } elsif ($self->hPaned2 && ! $buttonListRef) { | ||
| 8804 | |||
| 8805 | $axmud::CLIENT->desktopObj->removeWidget($self->hPaned, $self->treeViewScroller); | ||
| 8806 | $axmud::CLIENT->desktopObj->removeWidget($self->hPaned2, $self->notebook); | ||
| 8807 | $axmud::CLIENT->desktopObj->removeWidget($self->hPaned, $self->hPaned2); | ||
| 8808 | |||
| 8809 | # Repack the treeview scroller | ||
| 8810 | $self->hPaned->pack1($self->treeViewScroller, FALSE, FALSE); | ||
| 8811 | |||
| 8812 | # Repack the notebook | ||
| 8813 | $self->hPaned->pack2($self->notebook, TRUE, FALSE); | ||
| 8814 | |||
| 8815 | $self->hPaned->set_position($self->leftWidth); | ||
| 8816 | |||
| 8817 | # Update IVs | ||
| 8818 | $self->ivUndef('hPaned2'); | ||
| 8819 | $self->ivUndef('vBox'); | ||
| 8820 | } | ||
| 8821 | |||
| 8822 | # Create new tabs in the notebook | ||
| 8823 | do { | ||
| 8824 | |||
| 8825 | my ( | ||
| 8826 | $tab, $mnemonic, $slWidget, $scroller, $label, $slWidgetRef, $button, $count, | ||
| 8827 | $vAdjust, | ||
| 8828 | @ownColumnList, | ||
| 8829 | ); | ||
| 8830 | |||
| 8831 | $tab = shift @tabList; | ||
| 8832 | $mnemonic = shift @tabList; | ||
| 8833 | |||
| 8834 | # Add a simple list | ||
| 8835 | $slWidget = Games::Axmud::Obj::SimpleList->new(@columnList); | ||
| 8836 | # Make each row double-clickable | ||
| 8837 | $slWidget->signal_connect('row_activated' => sub { | ||
| 8838 | |||
| 8839 | # If doubling-clicking on a row is equivalent to something else, call the specified | ||
| 8840 | # function to make it happen | ||
| 8841 | if ($self->notebookSelectRef) { | ||
| 8842 | |||
| 8843 | &{$self->notebookSelectRef}; | ||
| 8844 | } | ||
| 8845 | }); | ||
| 8846 | |||
| 8847 | # Make the simple list scrollable | ||
| 8848 | $scroller = Gtk3::ScrolledWindow->new(); | ||
| 8849 | $scroller->set_policy('automatic', 'automatic'); | ||
| 8850 | $scroller->add($slWidget); | ||
| 8851 | push (@scrollerList, $scroller); | ||
| 8852 | |||
| 8853 | # Fill the columns with data | ||
| 8854 | $dataListRef = $dataHash{$tab}; | ||
| 8855 | @{$slWidget->{data}} = @$dataListRef; | ||
| 8856 | |||
| 8857 | # Make all columns of type 'bool' (which are composed of checkbuttons) non-activatable, | ||
| 8858 | # so that the user can't click them on and off | ||
| 8859 | if (@columnList) { | ||
| 8860 | |||
| 8861 | $count = -1; | ||
| 8862 | @ownColumnList = @columnList; | ||
| 8863 | |||
| 8864 | do { | ||
| 8865 | |||
| 8866 | my ($title, $type); | ||
| 8867 | |||
| 8868 | $title = shift @ownColumnList; | ||
| 8869 | $type = shift @ownColumnList; | ||
| 8870 | |||
| 8871 | $count++; | ||
| 8872 | |||
| 8873 | if ($type eq 'bool') { | ||
| 8874 | |||
| 8875 | my ($cellRenderer) = $slWidget->get_column($count)->get_cells(); | ||
| 8876 | $cellRenderer->set(activatable => FALSE); | ||
| 8877 | } | ||
| 8878 | |||
| 8879 | } until (! @ownColumnList); | ||
| 8880 | } | ||
| 8881 | |||
| 8882 | # Give the tab a label | ||
| 8883 | $label = Gtk3::Label->new_with_mnemonic($tab); | ||
| 8884 | $label->set_markup_with_mnemonic($mnemonic); | ||
| 8885 | # Add the tab to the notebook | ||
| 8886 | $self->notebook->append_page($scroller, $label); | ||
| 8887 | |||
| 8888 | # Update IVs | ||
| 8889 | $self->ivAdd('notebookTabHash', $tab, $label); | ||
| 8890 | $self->ivPush('notebookTabList', $tab); | ||
| 8891 | $self->ivAdd('notebookDataHash', $tab, $slWidget); | ||
| 8892 | |||
| 8893 | } until (! @tabList); | ||
| 8894 | |||
| 8895 | # Displaying a list of objects puts the notebook in 'list' mode | ||
| 8896 | $self->ivPoke('notebookMode', 'list'); | ||
| 8897 | |||
| 8898 | # Add an strip of buttons at the top of $self->vBox | ||
| 8899 | if (@buttonList) { | ||
| 8900 | |||
| 8901 | do { | ||
| 8902 | |||
| 8903 | my ($name, $tip, $method, $btn); | ||
| 8904 | |||
| 8905 | $name = shift @buttonList; | ||
| 8906 | $tip = shift @buttonList; | ||
| 8907 | $method = shift @buttonList; | ||
| 8908 | |||
| 8909 | $btn = Gtk3::Button->new($name); | ||
| 8910 | $btn->signal_connect('clicked' => sub { | ||
| 8911 | |||
| 8912 | $self->$method(); | ||
| 8913 | }); | ||
| 8914 | $btn->set_tooltip_text($tip); | ||
| 8915 | |||
| 8916 | $self->vBox->pack_start($btn, FALSE, FALSE, 0); | ||
| 8917 | $self->ivPush('buttonList', $btn); | ||
| 8918 | |||
| 8919 | } until (! @buttonList); | ||
| 8920 | } | ||
| 8921 | |||
| 8922 | # Add a separator just beneath these buttons | ||
| 8923 | my $separator = Gtk3::HSeparator->new(); | ||
| 8924 | $self->vBox->pack_start($separator, FALSE, FALSE, 10); | ||
| 8925 | $self->ivPush('buttonList', $separator); | ||
| 8926 | |||
| 8927 | # Add two standard buttons at the bottom of $self->vBox, regardless of the type of list | ||
| 8928 | # displayed | ||
| 8929 | my $btn = Gtk3::Button->new('Refresh list'); | ||
| 8930 | $btn->signal_connect('clicked' => sub { | ||
| 8931 | |||
| 8932 | $self->updateNotebook(); | ||
| 8933 | }); | ||
| 8934 | $btn->set_tooltip_text('Refresh this list'); | ||
| 8935 | $self->vBox->pack_start($btn, FALSE, FALSE, 0); | ||
| 8936 | $self->ivPush('buttonList', $btn); | ||
| 8937 | |||
| 8938 | my $btn2 = Gtk3::Button->new('Exit viewer'); | ||
| 8939 | $btn2->signal_connect('clicked' => sub { | ||
| 8940 | |||
| 8941 | $self->winDestroy(); | ||
| 8942 | }); | ||
| 8943 | $btn2->set_tooltip_text('Close the ' . $axmud::SCRIPT . ' object viewer'); | ||
| 8944 | $self->vBox->pack_start($btn2, FALSE, FALSE, 0); | ||
| 8945 | $self->ivPush('buttonList', $btn2); | ||
| 8946 | |||
| 8947 | # Set the width of the notebook, depending on whether there are any buttons to display | ||
| 8948 | if ($buttonListRef) { | ||
| 8949 | $self->hPaned2->set_position($self->centreWidth); | ||
| 8950 | } else { | ||
| 8951 | $self->hPaned2->set_position($self->centreWidth + $self->rightWidth); | ||
| 8952 | } | ||
| 8953 | |||
| 8954 | # Render the changes | ||
| 8955 | $self->winShowAll($self->_objClass . '->refreshNotebook'); | ||
| 8956 | $axmud::CLIENT->desktopObj->updateWidgets($self->_objClass . '->refreshNotebook'); | ||
| 8957 | |||
| 8958 | # If $scrollFlag is set, we can now scroll the Gtk3::ScrolledWindow to the bottom | ||
| 8959 | if ($scrollFlag) { | ||
| 8960 | |||
| 8961 | foreach my $scroller (@scrollerList) { | ||
| 8962 | |||
| 8963 | my $vAdjust = $scroller->get_vadjustment(); | ||
| 8964 | |||
| 8965 | $vAdjust->set_value( | ||
| 8966 | $vAdjust->get_lower() | ||
| 8967 | + (($vAdjust->get_upper() - $vAdjust->get_page_size()) - $vAdjust->get_lower()) | ||
| 8968 | ); | ||
| 8969 | } | ||
| 8970 | |||
| 8971 | $self->winShowAll($self->_objClass . '->refreshNotebook'); | ||
| 8972 | } | ||
| 8973 | |||
| 8974 | return 1; | ||
| 8975 | } | ||
| 8976 | |||
| 8977 | sub resetNotebook { | ||
| 8978 | |||
| 8979 | # Called by $self->refreshNotebook | ||
| 8980 | # Resets the notebook, removing tabs and buttons | ||
| 8981 | # | ||
| 8982 | # Expected arguments | ||
| 8983 | # (none besides $self) | ||
| 8984 | # | ||
| 8985 | # Return values | ||
| 8986 | # 'undef' on improper arguments or if there is no notebook to reset | ||
| 8987 | # 1 otherwise | ||
| 8988 | |||
| 8989 | my ($self, $check) = @_; | ||
| 8990 | |||
| 8991 | # Local variables | ||
| 8992 | my $number; | ||
| 8993 | |||
| 8994 | # Check for improper arguments | ||
| 8995 | if (defined $check) { | ||
| 8996 | |||
| 8997 | return $axmud::CLIENT->writeImproper($self->_objClass . '->resetNotebook', @_); | ||
| 8998 | } | ||
| 8999 | |||
| 9000 | # If the notebook doesn't exist, there's nothing to reset | ||
| 9001 | if (! $self->notebook) { | ||
| 9002 | |||
| 9003 | return undef; | ||
| 9004 | } | ||
| 9005 | |||
| 9006 | # Remove the existing tabs (if any) | ||
| 9007 | if ( | ||
| 9008 | $self->notebookMode eq 'list' | ||
| 9009 | || $self->notebookMode eq 'text' | ||
| 9010 | ) { | ||
| 9011 | $number = $self->notebook->get_n_pages(); | ||
| 9012 | if ($number) { | ||
| 9013 | |||
| 9014 | for (my $count = 0; $count < $number; $count++) { | ||
| 9015 | |||
| 9016 | $self->notebook->remove_page(0); | ||
| 9017 | } | ||
| 9018 | } | ||
| 9019 | |||
| 9020 | $self->ivEmpty('notebookTabHash'); | ||
| 9021 | $self->ivEmpty('notebookTabList'); | ||
| 9022 | $self->ivEmpty('notebookDataHash'); | ||
| 9023 | } | ||
| 9024 | |||
| 9025 | # Remove the existing buttons (if any) | ||
| 9026 | if ($self->buttonList) { | ||
| 9027 | |||
| 9028 | foreach my $button ($self->buttonList) { | ||
| 9029 | |||
| 9030 | $button->destroy; | ||
| 9031 | } | ||
| 9032 | |||
| 9033 | $self->ivEmpty('buttonList'); | ||
| 9034 | } | ||
| 9035 | |||
| 9036 | return 1; | ||
| 9037 | } | ||
| 9038 | |||
| 9039 | sub refreshTextView { | ||
| 9040 | |||
| 9041 | # Called by $self->cmdHeader (etc) | ||
| 9042 | # Creates a Gtk3::TextView in the notebook, and writes the supplied text to it | ||
| 9043 | # (Header functions which need a simple list, rather than a textview, call | ||
| 9044 | # ->refreshNotebook) | ||
| 9045 | # | ||
| 9046 | # Expected arguments | ||
| 9047 | # $tab - The title of the notebook tab | ||
| 9048 | # @list - A list of lines to display in the textview | ||
| 9049 | # | ||
| 9050 | # Return values | ||
| 9051 | # 'undef' on improper arguments | ||
| 9052 | # 1 otherwise | ||
| 9053 | |||
| 9054 | my ($self, $tab, @list) = @_; | ||
| 9055 | |||
| 9056 | # Local variables | ||
| 9057 | my $label; | ||
| 9058 | |||
| 9059 | # Check for improper arguments | ||
| 9060 | if (! defined $tab) { | ||
| 9061 | |||
| 9062 | return $axmud::CLIENT->writeImproper($self->_objClass . '->refreshTextView', @_); | ||
| 9063 | } | ||
| 9064 | |||
| 9065 | # If the button strip is visible, do some repacking | ||
| 9066 | if ($self->hPaned2) { | ||
| 9067 | |||
| 9068 | $axmud::CLIENT->desktopObj->removeWidget($self->hPaned2, $self->notebook); | ||
| 9069 | $axmud::CLIENT->desktopObj->removeWidget($self->hPaned, $self->hPaned2); | ||
| 9070 | |||
| 9071 | $self->hPaned->add2($self->notebook); | ||
| 9072 | |||
| 9073 | $self->hPaned->set_position($self->leftWidth); | ||
| 9074 | } | ||
| 9075 | |||
| 9076 | # Update IVs | ||
| 9077 | $self->ivUndef('hPaned2'); | ||
| 9078 | $self->ivUndef('vBox'); | ||
| 9079 | |||
| 9080 | # Remove the existing notebook content | ||
| 9081 | $self->resetNotebook(); | ||
| 9082 | |||
| 9083 | # Create a scrolled window | ||
| 9084 | my $scrolled = Gtk3::ScrolledWindow->new(undef, undef); | ||
| 9085 | $scrolled->set_shadow_type($axmud::CLIENT->constShadowType); | ||
| 9086 | $scrolled->set_policy('automatic', 'automatic'); | ||
| 9087 | $scrolled->set_border_width(5); | ||
| 9088 | |||
| 9089 | # Create a textview with default colours/fonts | ||
| 9090 | my $textView = Gtk3::TextView->new(); | ||
| 9091 | my $buffer = Gtk3::TextBuffer->new(); | ||
| 9092 | $textView->set_buffer($buffer); | ||
| 9093 | $textView->set_editable(FALSE); | ||
| 9094 | $axmud::CLIENT->desktopObj->setTextViewStyle($self->winType, $textView); | ||
| 9095 | |||
| 9096 | # Copy the text into the textview | ||
| 9097 | $buffer->set_text(join("\n", @list)); | ||
| 9098 | |||
| 9099 | # Complete setup | ||
| 9100 | $scrolled->add($textView); | ||
| 9101 | |||
| 9102 | # Add a label | ||
| 9103 | $label = Gtk3::Label->new_with_mnemonic($tab); | ||
| 9104 | $self->notebook->append_page($scrolled, $label); | ||
| 9105 | |||
| 9106 | # Render the changes | ||
| 9107 | $self->winShowAll($self->_objClass . '->refreshTextView'); | ||
| 9108 | |||
| 9109 | # Update IVs | ||
| 9110 | $self->ivAdd('notebookTabHash', $tab, $label); | ||
| 9111 | $self->ivPoke('notebookMode', 'text'); | ||
| 9112 | |||
| 9113 | return 1; | ||
| 9114 | } | ||
| 9115 | |||
| 9116 | sub updateNotebook { | ||
| 9117 | |||
| 9118 | # Called whenever the current notebook changes (when a new profile or cage is created or | ||
| 9119 | # deleted - eg by $self->refreshNotebook) | ||
| 9120 | # Updates the notebook by calling the same method called when a header in the treeview is | ||
| 9121 | # selected | ||
| 9122 | # | ||
| 9123 | # Expected arguments | ||
| 9124 | # (none besides $self) | ||
| 9125 | # | ||
| 9126 | # Optional arguments | ||
| 9127 | # @list - The rows in the notebook's GA::Obj::SimpleList which should be marked as | ||
| 9128 | # 'selected' (as if the user had clicked on them). If the list is empty, | ||
| 9129 | # no rows are marked as 'selected' | ||
| 9130 | # | ||
| 9131 | # Return values | ||
| 9132 | # 'undef' on improper arguments or if the notebook isn't displaying anything | ||
| 9133 | # 1 otherwise | ||
| 9134 | |||
| 9135 | my ($self, @list) = @_; | ||
| 9136 | |||
| 9137 | # Local variables | ||
| 9138 | my ($method, $currentTab); | ||
| 9139 | |||
| 9140 | # (No improper arguments to check) | ||
| 9141 | |||
| 9142 | if ( | ||
| 9143 | $self->notebookCurrentHeader | ||
| 9144 | && $self->ivExists('headerHash', $self->notebookCurrentHeader) | ||
| 9145 | ) { | ||
| 9146 | # Remember the currently selected tab | ||
| 9147 | $currentTab = $self->notebook->get_current_page(); | ||
| 9148 | |||
| 9149 | # Call the method specified by $self->headerHash | ||
| 9150 | $method = $self->ivShow('headerHash', $self->notebookCurrentHeader); | ||
| 9151 | $self->$method($self->notebookCurrentHeader); | ||
| 9152 | |||
| 9153 | # If @list isn't empty, mark some of the rows as selected | ||
| 9154 | if (@list) { | ||
| 9155 | |||
| 9156 | $self->notebookSetSelectedLines(@list); | ||
| 9157 | } | ||
| 9158 | |||
| 9159 | # Open the previously selected tab | ||
| 9160 | $self->notebook->set_current_page($currentTab); | ||
| 9161 | |||
| 9162 | return 1; | ||
| 9163 | |||
| 9164 | } else { | ||
| 9165 | |||
| 9166 | return undef; | ||
| 9167 | } | ||
| 9168 | } | ||
| 9169 | |||
| 9170 | # Notebook support functions | ||
| 9171 | |||
| 9172 | sub notebookGetTab { | ||
| 9173 | |||
| 9174 | # Can be called by anything | ||
| 9175 | # Finds the name of the current tab in the notebook | ||
| 9176 | # | ||
| 9177 | # Expected arguments | ||
| 9178 | # (none besides $self) | ||
| 9179 | # | ||
| 9180 | # Return values | ||
| 9181 | # 'undef' on improper arguments | ||
| 9182 | # Otherwise, returns the name (label) of the tab | ||
| 9183 | |||
| 9184 | my ($self, $check) = @_; | ||
| 9185 | |||
| 9186 | # Local variables | ||
| 9187 | my $number; | ||
| 9188 | |||
| 9189 | # Check for improper arguments | ||
| 9190 | if (defined $check) { | ||
| 9191 | |||
| 9192 | return $axmud::CLIENT->writeImproper($self->_objClass . '->notebookGetTab', @_); | ||
| 9193 | } | ||
| 9194 | |||
| 9195 | $number = $self->notebook->get_current_page(); | ||
| 9196 | return $self->ivIndex('notebookTabList', $number); | ||
| 9197 | } | ||
| 9198 | |||
| 9199 | sub notebookGetData { | ||
| 9200 | |||
| 9201 | # Can be called by anything | ||
| 9202 | # Finds the data displayed in the GA::Obj::SimpleList of the current notebook tab | ||
| 9203 | # (use ->notebookGetSelectedData to get only the selected data) | ||
| 9204 | # | ||
| 9205 | # Expected arguments | ||
| 9206 | # (none besides $self) | ||
| 9207 | # | ||
| 9208 | # Return values | ||
| 9209 | # 'undef' on improper arguments | ||
| 9210 | # Otherwise, returns the reference to the selected data, matching | ||
| 9211 | # GA::Obj::SimpleList->{data} | ||
| 9212 | |||
| 9213 | my ($self, $check) = @_; | ||
| 9214 | |||
| 9215 | # Local variables | ||
| 9216 | my $tabName; | ||
| 9217 | |||
| 9218 | # Check for improper arguments | ||
| 9219 | if (defined $check) { | ||
| 9220 | |||
| 9221 | return $axmud::CLIENT->writeImproper($self->_objClass . '->notebookGetData', @_); | ||
| 9222 | } | ||
| 9223 | |||
| 9224 | $tabName = $self->notebookGetTab(); | ||
| 9225 | return $self->ivShow('notebookDataHash', $tabName); | ||
| 9226 | } | ||
| 9227 | |||
| 9228 | sub notebookGetSelectedData { | ||
| 9229 | |||
| 9230 | # Can be called by anything | ||
| 9231 | # Gets the data displayed in the selected line of the GA::Obj::SimpleList of the current | ||
| 9232 | # notebook tab | ||
| 9233 | # | ||
| 9234 | # Expected arguments | ||
| 9235 | # (none besides $self) | ||
| 9236 | # | ||
| 9237 | # Return values | ||
| 9238 | # An empty list on improper arguments | ||
| 9239 | # Otherwise, returns a list, each element containing a list reference with all the data in | ||
| 9240 | # a selected row | ||
| 9241 | |||
| 9242 | my ($self, $check) = @_; | ||
| 9243 | |||
| 9244 | # Local variables | ||
| 9245 | my ( | ||
| 9246 | $dataRef, | ||
| 9247 | @emptyList, @selectList, @returnList, | ||
| 9248 | ); | ||
| 9249 | |||
| 9250 | # Check for improper arguments | ||
| 9251 | if (defined $check) { | ||
| 9252 | |||
| 9253 | $axmud::CLIENT->writeImproper($self->_objClass . '->notebookGetSelectedData', @_); | ||
| 9254 | return @emptyList, | ||
| 9255 | } | ||
| 9256 | |||
| 9257 | $dataRef = $self->notebookGetData(); | ||
| 9258 | @selectList = $dataRef->get_selected_indices(); | ||
| 9259 | |||
| 9260 | foreach my $index (@selectList) { | ||
| 9261 | |||
| 9262 | push (@returnList, ${$dataRef->{data}}[$index]); | ||
| 9263 | } | ||
| 9264 | |||
| 9265 | return @returnList; | ||
| 9266 | } | ||
| 9267 | |||
| 9268 | sub notebookGetSelectedLines { | ||
| 9269 | |||
| 9270 | # Can be called by anything | ||
| 9271 | # Gets a list containing the number of each selected line in the GA::Obj::SimpleList of | ||
| 9272 | # the current notebook tab | ||
| 9273 | # | ||
| 9274 | # Expected arguments | ||
| 9275 | # (none besides $self) | ||
| 9276 | # | ||
| 9277 | # Return values | ||
| 9278 | # An empty list on improper arguments | ||
| 9279 | # Otherwise, returns the list of selected line numbers | ||
| 9280 | |||
| 9281 | my ($self, $check) = @_; | ||
| 9282 | |||
| 9283 | # Local variables | ||
| 9284 | my ( | ||
| 9285 | $dataRef, | ||
| 9286 | @emptyList, @returnList, | ||
| 9287 | ); | ||
| 9288 | |||
| 9289 | # Check for improper arguments | ||
| 9290 | if (defined $check) { | ||
| 9291 | |||
| 9292 | $axmud::CLIENT->writeImproper($self->_objClass . '->notebookGetSelectedLines', @_); | ||
| 9293 | return @emptyList, | ||
| 9294 | } | ||
| 9295 | |||
| 9296 | $dataRef = $self->notebookGetData(); | ||
| 9297 | @returnList = $dataRef->get_selected_indices(); | ||
| 9298 | |||
| 9299 | return @returnList; | ||
| 9300 | } | ||
| 9301 | |||
| 9302 | sub notebookSetSelectedLines { | ||
| 9303 | |||
| 9304 | # Can be called by anything, but usually by $self->updateNotebook | ||
| 9305 | # Selects lines in the GA::Obj::SimpleList of the current notebook tab, as if the user had | ||
| 9306 | # clicked on them | ||
| 9307 | # | ||
| 9308 | # Expected arguments | ||
| 9309 | # @list - List of indices in the GA::Obj::SimpleList to select | ||
| 9310 | # | ||
| 9311 | # Return values | ||
| 9312 | # 1 | ||
| 9313 | |||
| 9314 | my ($self, @list) = @_; | ||
| 9315 | |||
| 9316 | # Local variables | ||
| 9317 | my $dataRef; | ||
| 9318 | |||
| 9319 | # (No improper arguments to check) | ||
| 9320 | |||
| 9321 | $dataRef = $self->notebookGetData(); | ||
| 9322 | foreach my $index (@list) { | ||
| 9323 | |||
| 9324 | $dataRef->select($index); | ||
| 9325 | } | ||
| 9326 | |||
| 9327 | return 1; | ||
| 9328 | } | ||
| 9329 | |||
| 9330 | sub getMnemonic { | ||
| 9331 | |||
| 9332 | # Called by $self->setTabList_prof and several other functions | ||
| 9333 | # Given the label of a tab - e.g. 'world' - create a label mnemonic, e.g. '_world' (which | ||
| 9334 | # the user can select with the ALT+W key combination) | ||
| 9335 | # The calling function supplies a hash of letters that have already been used for other | ||
| 9336 | # mnemonics, so that each label can be selected with a different key combination (for as | ||
| 9337 | # long as there are spare letters remaining) | ||
| 9338 | # | ||
| 9339 | # Expected arguments | ||
| 9340 | # $string - The string to process, e.g. 'world' | ||
| 9341 | # $hashRef - Reference to a hash of mnemonics already used, in the form | ||
| 9342 | # $hash{letter} = undef | ||
| 9343 | # | ||
| 9344 | # Return values | ||
| 9345 | # 'undef' on improper arguments | ||
| 9346 | # Otherwise, returns the modified string | ||
| 9347 | |||
| 9348 | my ($self, $string, $hashRef, $check) = @_; | ||
| 9349 | |||
| 9350 | # Check for improper arguments | ||
| 9351 | if (! defined $string || ! defined $hashRef || defined $check) { | ||
| 9352 | |||
| 9353 | return $axmud::CLIENT->writeImproper($self->_objClass . '->getMnemonic', @_); | ||
| 9354 | } | ||
| 9355 | |||
| 9356 | if (! $string) { | ||
| 9357 | |||
| 9358 | # Can't process an empty string | ||
| 9359 | return $string; | ||
| 9360 | } | ||
| 9361 | |||
| 9362 | # Dereference the supplied hash (for convenience) | ||
| 9363 | |||
| 9364 | # Examine each letter of $string in turn, looking for one which hasn't already been used as | ||
| 9365 | # a mnemonic | ||
| 9366 | for (my $count = 0; $count < length($string); $count++) { | ||
| 9367 | |||
| 9368 | my $letter = lc(substr($string, $count, 1)); | ||
| 9369 | |||
| 9370 | if (! exists $$hashRef{$letter}) { | ||
| 9371 | |||
| 9372 | # Insert an underline at this location | ||
| 9373 | substr($string, $count, 0, '_'); | ||
| 9374 | # This mnemonic is no longer available | ||
| 9375 | $$hashRef{$letter} = undef; | ||
| 9376 | |||
| 9377 | return $string; | ||
| 9378 | } | ||
| 9379 | } | ||
| 9380 | |||
| 9381 | # Cannot add an underline to $string; all of its letters are already in use. Return the | ||
| 9382 | # unmodified string | ||
| 9383 | return $string | ||
| 9384 | } | ||
| 9385 | |||
| 9386 | # Treeview header responses - profiles | ||
| 9387 | |||
| 9388 | sub allProfHeader { | ||
| 9389 | |||
| 9390 | # Called by ->treeViewChanged when the user clicks on the 'All profiles' header in the | ||
| 9391 | # treeview | ||
| 9392 | # | ||
| 9393 | # Expected arguments | ||
| 9394 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 9395 | # | ||
| 9396 | # Return values | ||
| 9397 | # 'undef' on improper arguments | ||
| 9398 | # 1 otherwise | ||
| 9399 | |||
| 9400 | my ($self, $item, $check) = @_; | ||
| 9401 | |||
| 9402 | # Local variables | ||
| 9403 | my ( | ||
| 9404 | $tabListRef, $shortTabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 9405 | @shortTabList, | ||
| 9406 | %dataHash, | ||
| 9407 | ); | ||
| 9408 | |||
| 9409 | # Check for improper arguments | ||
| 9410 | if (! defined $item || defined $check) { | ||
| 9411 | |||
| 9412 | return $axmud::CLIENT->writeImproper($self->_objClass . '->allProfHeader', @_); | ||
| 9413 | } | ||
| 9414 | |||
| 9415 | # Prepare the list of tabs | ||
| 9416 | ($tabListRef, $shortTabListRef) = $self->setTabList_prof(); | ||
| 9417 | # Prepare the list of column headings | ||
| 9418 | $columnListRef = $self->setColumnList_prof(); | ||
| 9419 | # Prepare the list of buttons | ||
| 9420 | $buttonListRef = $self->setButtonList_prof(); | ||
| 9421 | |||
| 9422 | # Prepare the data to be displayed. Each item in @$shortTabListRef is a profile category, | ||
| 9423 | # e.g. 'world' or 'char' | ||
| 9424 | @shortTabList = @$shortTabListRef; | ||
| 9425 | foreach my $tab (@shortTabList) { | ||
| 9426 | |||
| 9427 | my (@profList, @sortedList, @dataList); | ||
| 9428 | |||
| 9429 | if ($tab eq 'world') { | ||
| 9430 | |||
| 9431 | # Add world profiles from the GA::Client's hash | ||
| 9432 | @profList = sort {lc($a->name) cmp lc($b->name)} | ||
| 9433 | ($axmud::CLIENT->ivValues('worldProfHash')); | ||
| 9434 | |||
| 9435 | foreach my $profObj (@profList) { | ||
| 9436 | |||
| 9437 | my ($flag, $listRef); | ||
| 9438 | |||
| 9439 | if ($profObj eq $self->session->currentWorld) { | ||
| 9440 | $flag = TRUE; | ||
| 9441 | } else { | ||
| 9442 | $flag = FALSE; | ||
| 9443 | } | ||
| 9444 | |||
| 9445 | $listRef = [$flag, $profObj->name, $profObj->category]; | ||
| 9446 | push (@dataList, $listRef); | ||
| 9447 | } | ||
| 9448 | |||
| 9449 | } else { | ||
| 9450 | |||
| 9451 | # Add non-world profiles from the current GA::Session | ||
| 9452 | foreach my $profObj ($self->session->ivValues('profHash')) { | ||
| 9453 | |||
| 9454 | if ($profObj->category eq $tab) { | ||
| 9455 | |||
| 9456 | push (@profList, $profObj); | ||
| 9457 | } | ||
| 9458 | } | ||
| 9459 | |||
| 9460 | @sortedList = sort {lc($a->name) cmp lc($b->name)} (@profList); | ||
| 9461 | foreach my $profObj (@sortedList) { | ||
| 9462 | |||
| 9463 | my ($flag, $listRef); | ||
| 9464 | |||
| 9465 | if ( | ||
| 9466 | $self->session->ivExists('currentProfHash', $tab) | ||
| 9467 | && $self->session->ivShow('currentProfHash', $tab) eq $profObj | ||
| 9468 | ) { | ||
| 9469 | $flag = TRUE; | ||
| 9470 | } else { | ||
| 9471 | $flag = FALSE; | ||
| 9472 | } | ||
| 9473 | |||
| 9474 | $listRef = [$flag, $profObj->name, $profObj->category]; | ||
| 9475 | push (@dataList, $listRef); | ||
| 9476 | } | ||
| 9477 | } | ||
| 9478 | |||
| 9479 | $dataHash{$tab} = \@dataList; | ||
| 9480 | } | ||
| 9481 | |||
| 9482 | $dataHashRef = \%dataHash; | ||
| 9483 | |||
| 9484 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 9485 | # equivalent to the edit button | ||
| 9486 | $self->ivPoke('notebookSelectRef', sub { | ||
| 9487 | |||
| 9488 | $self->buttonEdit_prof(); | ||
| 9489 | }); | ||
| 9490 | |||
| 9491 | # Display all of this in the notebook | ||
| 9492 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 9493 | } | ||
| 9494 | |||
| 9495 | sub currentProfHeader { | ||
| 9496 | |||
| 9497 | # Called by ->treeViewChanged when the user clicks on the 'Current profiles' header in the | ||
| 9498 | # treeview | ||
| 9499 | # | ||
| 9500 | # Expected arguments | ||
| 9501 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 9502 | # | ||
| 9503 | # Return values | ||
| 9504 | # 'undef' on improper arguments | ||
| 9505 | # 1 otherwise | ||
| 9506 | |||
| 9507 | my ($self, $item, $check) = @_; | ||
| 9508 | |||
| 9509 | # Local variables | ||
| 9510 | my ( | ||
| 9511 | $tabListRef, $shortTabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 9512 | @shortTabList, | ||
| 9513 | %dataHash, | ||
| 9514 | ); | ||
| 9515 | |||
| 9516 | # Check for improper arguments | ||
| 9517 | if (! defined $item || defined $check) { | ||
| 9518 | |||
| 9519 | return $axmud::CLIENT->writeImproper($self->_objClass . '->currentProfHeader', @_); | ||
| 9520 | } | ||
| 9521 | |||
| 9522 | # Prepare the list of tabs | ||
| 9523 | ($tabListRef, $shortTabListRef) = $self->setTabList_prof(); | ||
| 9524 | # Prepare the list of column headings | ||
| 9525 | $columnListRef = $self->setColumnList_prof(); | ||
| 9526 | # Prepare the list of buttons | ||
| 9527 | $buttonListRef = $self->setButtonList_prof(); | ||
| 9528 | |||
| 9529 | # Prepare the data to be displayed. Each item in @$shortTabListRef is a profile category, | ||
| 9530 | # e.g. 'world' or 'char' | ||
| 9531 | @shortTabList = @$shortTabListRef; | ||
| 9532 | foreach my $tab (@shortTabList) { | ||
| 9533 | |||
| 9534 | my @dataList; | ||
| 9535 | |||
| 9536 | # Add all current profiles from the current GA::Session (there should only be one from | ||
| 9537 | # each category of profile, so no need to sort the list alphabetically) | ||
| 9538 | foreach my $profObj ($self->session->ivValues('currentProfHash')) { | ||
| 9539 | |||
| 9540 | my $listRef; | ||
| 9541 | |||
| 9542 | if ($profObj->category eq $tab) { | ||
| 9543 | |||
| 9544 | # The TRUE argument marks this as a current profile | ||
| 9545 | $listRef = [TRUE, $profObj->name, $profObj->category]; | ||
| 9546 | push (@dataList, $listRef); | ||
| 9547 | } | ||
| 9548 | } | ||
| 9549 | |||
| 9550 | $dataHash{$tab} = \@dataList; | ||
| 9551 | } | ||
| 9552 | |||
| 9553 | $dataHashRef = \%dataHash; | ||
| 9554 | |||
| 9555 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 9556 | # equivalent to the edit button | ||
| 9557 | $self->ivPoke('notebookSelectRef', sub { | ||
| 9558 | |||
| 9559 | $self->buttonEdit_prof(); | ||
| 9560 | }); | ||
| 9561 | |||
| 9562 | # Display all of this in the notebook | ||
| 9563 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 9564 | } | ||
| 9565 | |||
| 9566 | sub templateHeader { | ||
| 9567 | |||
| 9568 | # Called by ->treeViewChanged when the user clicks on the 'Profile templates' header in the | ||
| 9569 | # treeview | ||
| 9570 | # | ||
| 9571 | # Expected arguments | ||
| 9572 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 9573 | # | ||
| 9574 | # Return values | ||
| 9575 | # 'undef' on improper arguments | ||
| 9576 | # 1 otherwise | ||
| 9577 | |||
| 9578 | my ($self, $item, $check) = @_; | ||
| 9579 | |||
| 9580 | # Local variables | ||
| 9581 | my ( | ||
| 9582 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 9583 | @objList, @dataList, | ||
| 9584 | %dataHash, | ||
| 9585 | ); | ||
| 9586 | |||
| 9587 | # Check for improper arguments | ||
| 9588 | if (! defined $item || defined $check) { | ||
| 9589 | |||
| 9590 | return $axmud::CLIENT->writeImproper($self->_objClass . '->templateHeader', @_); | ||
| 9591 | } | ||
| 9592 | |||
| 9593 | # Prepare the list of tabs | ||
| 9594 | $tabListRef = [ | ||
| 9595 | 'Profile templates', 'Profile _templates', | ||
| 9596 | ]; | ||
| 9597 | |||
| 9598 | # Prepare the list of column headings | ||
| 9599 | $columnListRef = [ | ||
| 9600 | 'Fixed' => 'bool', | ||
| 9601 | 'Template category' => 'text', | ||
| 9602 | ]; | ||
| 9603 | |||
| 9604 | # Prepare the list of buttons | ||
| 9605 | $buttonListRef = [ | ||
| 9606 | 'Add', 'Add a new template profile', 'buttonAdd_template', | ||
| 9607 | 'Edit', 'Edit the selected template profile', 'buttonEdit_template', | ||
| 9608 | 'Clone', 'Clone the selected template profile', 'buttonClone_template', | ||
| 9609 | 'Delete', 'Delete the selected template profile', 'buttonDelete_template', | ||
| 9610 | 'Dump', 'Display the list of template in the \'main\' window', 'buttonDump_template', | ||
| 9611 | ]; | ||
| 9612 | |||
| 9613 | # Prepare the data to be displayed (there is only one tab) | ||
| 9614 | @objList = sort {lc($a->category) cmp lc($b->category)} | ||
| 9615 | ($self->session->ivValues('templateHash')); | ||
| 9616 | OUTER: foreach my $templObj (@objList) { | ||
| 9617 | |||
| 9618 | my $listRef = [$templObj->constFixedFlag, $templObj->category]; | ||
| 9619 | |||
| 9620 | push (@dataList, $listRef); | ||
| 9621 | } | ||
| 9622 | |||
| 9623 | $dataHash{'Profile templates'} = \@dataList; | ||
| 9624 | $dataHashRef = \%dataHash; | ||
| 9625 | |||
| 9626 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 9627 | # equivalent to the edit button | ||
| 9628 | $self->ivPoke('notebookSelectRef', sub { | ||
| 9629 | |||
| 9630 | $self->buttonEdit_template(); | ||
| 9631 | }); | ||
| 9632 | |||
| 9633 | # Display all of this in the notebook | ||
| 9634 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 9635 | } | ||
| 9636 | |||
| 9637 | sub profPriorityHeader { | ||
| 9638 | |||
| 9639 | # Called by ->treeViewChanged when the user clicks on the 'Profile priority' header in the | ||
| 9640 | # treeview | ||
| 9641 | # | ||
| 9642 | # Expected arguments | ||
| 9643 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 9644 | # | ||
| 9645 | # Return values | ||
| 9646 | # 'undef' on improper arguments | ||
| 9647 | # 1 otherwise | ||
| 9648 | |||
| 9649 | my ($self, $item, $check) = @_; | ||
| 9650 | |||
| 9651 | # Local variables | ||
| 9652 | my ( | ||
| 9653 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, $count, | ||
| 9654 | @dataList, @otherList, | ||
| 9655 | %dataHash, | ||
| 9656 | ); | ||
| 9657 | |||
| 9658 | # Check for improper arguments | ||
| 9659 | if (! defined $item || defined $check) { | ||
| 9660 | |||
| 9661 | return $axmud::CLIENT->writeImproper($self->_objClass . '->profPriorityHeader', @_); | ||
| 9662 | } | ||
| 9663 | |||
| 9664 | # Prepare the list of tabs | ||
| 9665 | $tabListRef = [ | ||
| 9666 | 'Profile priority list', 'Profile _priority list', | ||
| 9667 | ]; | ||
| 9668 | |||
| 9669 | # Prepare the list of column headings | ||
| 9670 | $columnListRef = [ | ||
| 9671 | 'Priority' => 'text', | ||
| 9672 | 'Category' => 'text', | ||
| 9673 | ]; | ||
| 9674 | |||
| 9675 | # Prepare the list of buttons | ||
| 9676 | $buttonListRef = [ | ||
| 9677 | 'Move to top', 'Profile category has the highest priority', | ||
| 9678 | 'buttonMoveTop_profPriority', | ||
| 9679 | 'Move up', 'Profile category has a higher priority', | ||
| 9680 | 'buttonMoveUp_profPriority', | ||
| 9681 | 'Move down', 'Profile category has a lower priority', | ||
| 9682 | 'buttonMoveDown_profPriority', | ||
| 9683 | 'Give priority', 'Add the selected category to the priority list', | ||
| 9684 | 'buttonGivePriority_profPriority', | ||
| 9685 | 'Lose priority', 'Remove the selected category from the priority list', | ||
| 9686 | 'buttonLosePriority_profPriority', | ||
| 9687 | 'Reset list', 'Use the default priority list', | ||
| 9688 | 'buttonResetList_profPriority', | ||
| 9689 | ]; | ||
| 9690 | |||
| 9691 | # Compile the data to display | ||
| 9692 | $dataHashRef = $self->compileList_profPriority(); | ||
| 9693 | |||
| 9694 | # (Nothing happens if the user double-clicks on a row) | ||
| 9695 | |||
| 9696 | # Display all of this in the notebook | ||
| 9697 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 9698 | } | ||
| 9699 | |||
| 9700 | # Treeview header responses - dictionaries | ||
| 9701 | |||
| 9702 | sub allDictHeader { | ||
| 9703 | |||
| 9704 | # Called by ->treeViewChanged when the user clicks on the 'All dictionaries' header in the | ||
| 9705 | # treeview | ||
| 9706 | # | ||
| 9707 | # Expected arguments | ||
| 9708 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 9709 | # | ||
| 9710 | # Return values | ||
| 9711 | # 'undef' on improper arguments | ||
| 9712 | # 1 otherwise | ||
| 9713 | |||
| 9714 | my ($self, $item, $check) = @_; | ||
| 9715 | |||
| 9716 | # Local variables | ||
| 9717 | my ( | ||
| 9718 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 9719 | @objList, @dataList, | ||
| 9720 | %dataHash, | ||
| 9721 | ); | ||
| 9722 | |||
| 9723 | # Check for improper arguments | ||
| 9724 | if (! defined $item || defined $check) { | ||
| 9725 | |||
| 9726 | return $axmud::CLIENT->writeImproper($self->_objClass . '->allDictHeader', @_); | ||
| 9727 | } | ||
| 9728 | |||
| 9729 | # Prepare the list of tabs | ||
| 9730 | $tabListRef = [ | ||
| 9731 | 'Dictionary' => '_Dictionary', | ||
| 9732 | ]; | ||
| 9733 | |||
| 9734 | # Prepare the list of column headings | ||
| 9735 | $columnListRef = [ | ||
| 9736 | 'Current' => 'bool', | ||
| 9737 | 'Name' => 'text', | ||
| 9738 | 'Language' => 'text', | ||
| 9739 | ]; | ||
| 9740 | |||
| 9741 | # Prepare the list of buttons | ||
| 9742 | $buttonListRef = [ | ||
| 9743 | 'Add', 'Add a new dictionary', 'buttonAdd_dict', | ||
| 9744 | 'Edit', 'Edit the selected dictionary', 'buttonEdit_dict', | ||
| 9745 | 'Set current', 'Set the current dictionary', 'buttonSet_dict', | ||
| 9746 | 'Clone', 'Clone the selected dictionary', 'buttonClone_dict', | ||
| 9747 | 'Delete', 'Delete the selected dictinoary', 'buttonDelete_dict', | ||
| 9748 | 'Dump', 'Display a list of dictionaries in the \'main\' window', 'buttonDump_dict', | ||
| 9749 | ]; | ||
| 9750 | |||
| 9751 | # Prepare the data to be displayed (there is only one tab) | ||
| 9752 | @objList = sort {lc($a->name) cmp lc($b->name)} ($axmud::CLIENT->ivValues('dictHash')); | ||
| 9753 | OUTER: foreach my $dictObj (@objList) { | ||
| 9754 | |||
| 9755 | my ($listRef, $flag); | ||
| 9756 | |||
| 9757 | if ($dictObj eq $self->session->currentDict) { | ||
| 9758 | $flag = TRUE; | ||
| 9759 | } else { | ||
| 9760 | $flag = FALSE; | ||
| 9761 | } | ||
| 9762 | |||
| 9763 | $listRef = [$flag, $dictObj->name, $dictObj->language]; | ||
| 9764 | push (@dataList, $listRef); | ||
| 9765 | } | ||
| 9766 | |||
| 9767 | $dataHash{'Dictionary'} = \@dataList; | ||
| 9768 | $dataHashRef = \%dataHash; | ||
| 9769 | |||
| 9770 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 9771 | # equivalent to the edit button | ||
| 9772 | $self->ivPoke('notebookSelectRef', sub { | ||
| 9773 | |||
| 9774 | $self->buttonEdit_dict(); | ||
| 9775 | }); | ||
| 9776 | |||
| 9777 | # Display all of this in the notebook | ||
| 9778 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 9779 | } | ||
| 9780 | |||
| 9781 | sub currentDictHeader { | ||
| 9782 | |||
| 9783 | # Called by ->treeViewChanged when the user clicks on the 'Current dictionaries' header in | ||
| 9784 | # the treeview | ||
| 9785 | # | ||
| 9786 | # Expected arguments | ||
| 9787 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 9788 | # | ||
| 9789 | # Return values | ||
| 9790 | # 'undef' on improper arguments | ||
| 9791 | # 1 otherwise | ||
| 9792 | |||
| 9793 | my ($self, $item, $check) = @_; | ||
| 9794 | |||
| 9795 | # Local variables | ||
| 9796 | my ( | ||
| 9797 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 9798 | @dataList, | ||
| 9799 | %dataHash, | ||
| 9800 | ); | ||
| 9801 | |||
| 9802 | # Check for improper arguments | ||
| 9803 | if (! defined $item || defined $check) { | ||
| 9804 | |||
| 9805 | return $axmud::CLIENT->writeImproper($self->_objClass . '->currentDictHeader', @_); | ||
| 9806 | } | ||
| 9807 | |||
| 9808 | # Prepare the list of tabs | ||
| 9809 | $tabListRef = [ | ||
| 9810 | 'Dictionary' => '_Dictionary', | ||
| 9811 | ]; | ||
| 9812 | |||
| 9813 | # Prepare the list of column headings | ||
| 9814 | $columnListRef = [ | ||
| 9815 | 'Current' => 'bool', | ||
| 9816 | 'Name' => 'text', | ||
| 9817 | 'Language' => 'text', | ||
| 9818 | ]; | ||
| 9819 | |||
| 9820 | # Prepare the list of buttons | ||
| 9821 | $buttonListRef = [ | ||
| 9822 | 'Add', 'Add a new dictionary', 'buttonAdd_dict', | ||
| 9823 | 'Edit', 'Edit the selected dictionary', 'buttonEdit_dict', | ||
| 9824 | 'Set current', 'Set the current dictionary', 'buttonSet_dict', | ||
| 9825 | 'Clone', 'Clone the selected dictionary', 'buttonClone_dict', | ||
| 9826 | 'Delete', 'Delete the selected dictinoary', 'buttonDelete_dict', | ||
| 9827 | 'Dump', 'Display a list of dictionaries in the \'main\' window', 'buttonDump_dict', | ||
| 9828 | |||
| 9829 | ]; | ||
| 9830 | |||
| 9831 | # Prepare the data to be displayed (there is only one tab, and there should be only one | ||
| 9832 | # dictionary to display) | ||
| 9833 | OUTER: foreach my $dictObj ($axmud::CLIENT->ivValues('dictHash')) { | ||
| 9834 | |||
| 9835 | my $listRef; | ||
| 9836 | |||
| 9837 | if ($dictObj eq $self->session->currentDict) { | ||
| 9838 | |||
| 9839 | $listRef = [TRUE, $dictObj->name, $dictObj->language]; | ||
| 9840 | push (@dataList, $listRef); | ||
| 9841 | } | ||
| 9842 | } | ||
| 9843 | |||
| 9844 | $dataHash{'Dictionary'} = \@dataList; | ||
| 9845 | $dataHashRef = \%dataHash; | ||
| 9846 | |||
| 9847 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 9848 | # equivalent to the edit button | ||
| 9849 | $self->ivPoke('notebookSelectRef', sub { | ||
| 9850 | |||
| 9851 | $self->buttonEdit_dict(); | ||
| 9852 | }); | ||
| 9853 | |||
| 9854 | # Display all of this in the notebook | ||
| 9855 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 9856 | } | ||
| 9857 | |||
| 9858 | # Treeview header responses - tasks | ||
| 9859 | |||
| 9860 | sub availableTaskHeader { | ||
| 9861 | |||
| 9862 | # Called by ->treeViewChanged when the user clicks on the 'Available tasks' header in the | ||
| 9863 | # treeview | ||
| 9864 | # | ||
| 9865 | # Expected arguments | ||
| 9866 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 9867 | # | ||
| 9868 | # Return values | ||
| 9869 | # 'undef' on improper arguments | ||
| 9870 | # 1 otherwise | ||
| 9871 | |||
| 9872 | my ($self, $item, $check) = @_; | ||
| 9873 | |||
| 9874 | # Local variables | ||
| 9875 | my ( | ||
| 9876 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 9877 | @objList, @dataList, | ||
| 9878 | %dataHash, | ||
| 9879 | ); | ||
| 9880 | |||
| 9881 | # Check for improper arguments | ||
| 9882 | if (! defined $item || defined $check) { | ||
| 9883 | |||
| 9884 | return $axmud::CLIENT->writeImproper($self->_objClass . '->availableTaskHeader', @_); | ||
| 9885 | } | ||
| 9886 | |||
| 9887 | # Prepare the list of tabs | ||
| 9888 | $tabListRef = [ | ||
| 9889 | 'Available tasks' => '_Available tasks', | ||
| 9890 | ]; | ||
| 9891 | |||
| 9892 | # Prepare the list of column headings | ||
| 9893 | $columnListRef = [ | ||
| 9894 | 'Built-in' => 'bool', | ||
| 9895 | 'Task name' => 'text', | ||
| 9896 | ]; | ||
| 9897 | |||
| 9898 | # Prepare the list of buttons | ||
| 9899 | $buttonListRef = [ | ||
| 9900 | 'Start', 'Start a new task with default settings', 'buttonStart_availableTask', | ||
| 9901 | 'Start options', 'Start a new task with non-standard settings', | ||
| 9902 | 'buttonStartOptions_availableTask', | ||
| 9903 | 'Add initial', 'Add a new task to the global initial tasklist', | ||
| 9904 | 'buttonAddInitial_availableTask', | ||
| 9905 | 'Add custom', 'Add a new task to the custom tasklist', | ||
| 9906 | 'buttonAddCustom_availableTask', | ||
| 9907 | 'Halt', 'Halt all currently-running copies of the selected task', | ||
| 9908 | 'buttonHalt_availableTask', | ||
| 9909 | 'Kill', 'Kill all currently-running copies of the selected task', | ||
| 9910 | 'buttonKill_availableTask', | ||
| 9911 | 'Pause', 'Pauses all currently-running copies of the selected task', | ||
| 9912 | 'buttonPause_availableTask', | ||
| 9913 | 'Safe resume', 'Resume all tasks paused with the pause button', | ||
| 9914 | 'buttonSafeResume_task', | ||
| 9915 | 'Reset', 'Reset all currently-running copies of the selected task', | ||
| 9916 | 'buttonReset_availableTask', | ||
| 9917 | 'Help', 'Shows help for the selected task', 'buttonHelp_availableTask', | ||
| 9918 | ]; | ||
| 9919 | |||
| 9920 | # Prepare the data to be displayed (there is only one tab) | ||
| 9921 | @objList = sort {lc($a) cmp lc($b)} ($axmud::CLIENT->ivKeys('taskPackageHash')); | ||
| 9922 | OUTER: foreach my $packageName (@objList) { | ||
| 9923 | |||
| 9924 | my ($listRef, $flag); | ||
| 9925 | |||
| 9926 | if ($axmud::CLIENT->ivExists('constTaskPackageHash', $packageName)) { | ||
| 9927 | $flag = TRUE; | ||
| 9928 | } else { | ||
| 9929 | $flag = FALSE; | ||
| 9930 | } | ||
| 9931 | |||
| 9932 | $listRef = [$flag, $packageName]; | ||
| 9933 | push (@dataList, $listRef); | ||
| 9934 | |||
| 9935 | } | ||
| 9936 | |||
| 9937 | $dataHash{'Available tasks'} = \@dataList; | ||
| 9938 | $dataHashRef = \%dataHash; | ||
| 9939 | |||
| 9940 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 9941 | # equivalent to the 'start' button | ||
| 9942 | $self->ivPoke('notebookSelectRef', sub { | ||
| 9943 | |||
| 9944 | $self->buttonStart_availableTask(); | ||
| 9945 | }); | ||
| 9946 | |||
| 9947 | # Display all of this in the notebook | ||
| 9948 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 9949 | } | ||
| 9950 | |||
| 9951 | sub currentTaskHeader { | ||
| 9952 | |||
| 9953 | # Called by ->treeViewChanged when the user clicks on the 'Current tasklist' header in the | ||
| 9954 | # treeview | ||
| 9955 | # | ||
| 9956 | # Expected arguments | ||
| 9957 | # (none besides $self) | ||
| 9958 | # | ||
| 9959 | # Optional arguments | ||
| 9960 | # $item - The treeview item that was clicked (i.e. the text it contains). Not specified | ||
| 9961 | # when called by GA::Session->taskLoop | ||
| 9962 | # | ||
| 9963 | # Return values | ||
| 9964 | # 'undef' on improper arguments | ||
| 9965 | # 1 otherwise | ||
| 9966 | |||
| 9967 | my ($self, $item, $check) = @_; | ||
| 9968 | |||
| 9969 | # Local variables | ||
| 9970 | my ( | ||
| 9971 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 9972 | @objList, @dataList, | ||
| 9973 | %dataHash, | ||
| 9974 | ); | ||
| 9975 | |||
| 9976 | # Check for improper arguments | ||
| 9977 | if (defined $check) { | ||
| 9978 | |||
| 9979 | return $axmud::CLIENT->writeImproper($self->_objClass . '->currentTaskHeader', @_); | ||
| 9980 | } | ||
| 9981 | |||
| 9982 | # Prepare the list of tabs | ||
| 9983 | $tabListRef = [ | ||
| 9984 | 'Current tasklist' => '_Current tasklist', | ||
| 9985 | ]; | ||
| 9986 | |||
| 9987 | # Prepare the list of column headings | ||
| 9988 | $columnListRef = [ | ||
| 9989 | 'Name' => 'text', # ->name | ||
| 9990 | 'Type' => 'text', # ->category | ||
| 9991 | 'Jealous' => 'bool', # ->jealousyFlag | ||
| 9992 | 'Stage' => 'text', # ->stage | ||
| 9993 | 'Status' => 'text', # ->status | ||
| 9994 | ]; | ||
| 9995 | |||
| 9996 | # Prepare the list of buttons | ||
| 9997 | $buttonListRef = [ | ||
| 9998 | 'Edit', 'Edit a task\'s settings and parameters', 'buttonEdit_task', | ||
| 9999 | 'Halt', 'Halt a task (gracefully)', 'buttonHalt_task', | ||
| 10000 | 'Halt all', 'Halt all tasks (gracefully)', 'buttonHaltAll_task', | ||
| 10001 | 'Kill', ' Kill (stop) a task immediately (not recommended)', 'buttonKill_task', | ||
| 10002 | 'Kill all', 'Kill (stop) all tasks immediately (not recommended)', 'buttonKillAll_task', | ||
| 10003 | 'Pause', 'Pause a task', 'buttonPause_task', | ||
| 10004 | 'Pause all', 'Pause all tasks', 'buttonPauseAll_task', | ||
| 10005 | 'Safe resume', 'Resume all tasks paused with the pause button', 'buttonSafeResume_task', | ||
| 10006 | 'Reset', 'Reset a task', 'buttonReset_task', | ||
| 10007 | 'Reset all', 'Reset all tasks', 'buttonResetAll_task', | ||
| 10008 | '(Un)freeze all', 'Freeze (or unfreeze) all running tasks', 'buttonFreezeAll_task', | ||
| 10009 | 'Dump', 'Dump the list of running tasks to the \'main\' window', 'buttonDump_task', | ||
| 10010 | ]; | ||
| 10011 | |||
| 10012 | # Prepare the data to be displayed (there is only one tab) | ||
| 10013 | @objList = sort {lc($a->uniqueName) cmp lc($b->uniqueName)} | ||
| 10014 | ($self->session->ivValues('currentTaskHash')); | ||
| 10015 | |||
| 10016 | OUTER: foreach my $taskObj (@objList) { | ||
| 10017 | |||
| 10018 | my $listRef = [ | ||
| 10019 | $taskObj->uniqueName, $taskObj->category, $taskObj->jealousyFlag, | ||
| 10020 | $taskObj->stage, $taskObj->status, | ||
| 10021 | ]; | ||
| 10022 | |||
| 10023 | push (@dataList, $listRef); | ||
| 10024 | |||
| 10025 | } | ||
| 10026 | |||
| 10027 | $dataHash{'Current tasklist'} = \@dataList; | ||
| 10028 | $dataHashRef = \%dataHash; | ||
| 10029 | |||
| 10030 | # (Nothing happens when user double-clicks on line) | ||
| 10031 | |||
| 10032 | # Display all of this in the notebook | ||
| 10033 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 10034 | } | ||
| 10035 | |||
| 10036 | sub initialTaskHeader { | ||
| 10037 | |||
| 10038 | # Called by ->treeViewChanged when the user clicks on the 'Global initial tasklist' header | ||
| 10039 | # in the treeview | ||
| 10040 | # | ||
| 10041 | # Expected arguments | ||
| 10042 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 10043 | # | ||
| 10044 | # Return values | ||
| 10045 | # 'undef' on improper arguments | ||
| 10046 | # 1 otherwise | ||
| 10047 | |||
| 10048 | my ($self, $item, $check) = @_; | ||
| 10049 | |||
| 10050 | # Local variables | ||
| 10051 | my ( | ||
| 10052 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 10053 | @dataList, | ||
| 10054 | %dataHash, | ||
| 10055 | ); | ||
| 10056 | |||
| 10057 | # Check for improper arguments | ||
| 10058 | if (! defined $item || defined $check) { | ||
| 10059 | |||
| 10060 | return $axmud::CLIENT->writeImproper($self->_objClass . '->initialTaskHeader', @_); | ||
| 10061 | } | ||
| 10062 | |||
| 10063 | # Prepare the list of tabs | ||
| 10064 | $tabListRef = [ | ||
| 10065 | 'Global initial tasklist' => '_Global initial tasklist', | ||
| 10066 | ]; | ||
| 10067 | |||
| 10068 | # Prepare the list of column headings | ||
| 10069 | $columnListRef = [ | ||
| 10070 | 'Name' => 'text', # ->uniqueName | ||
| 10071 | 'Type' => 'text', # ->category | ||
| 10072 | 'Jealous' => 'bool', # ->jealousyFlag | ||
| 10073 | 'Stage' => 'text', # ->stage | ||
| 10074 | 'Status' => 'text', # ->status | ||
| 10075 | ]; | ||
| 10076 | |||
| 10077 | # Prepare the list of buttons | ||
| 10078 | $buttonListRef = [ | ||
| 10079 | 'Edit', 'Edit the selected task', 'buttonEdit_initialTask', | ||
| 10080 | 'Move up', 'Move the selected task up', 'buttonMoveUp_initialTask', | ||
| 10081 | 'Move down', 'Move the selected task down', 'buttonMoveDown_initialTask', | ||
| 10082 | 'Delete', 'Delete a task from the global initial tasklist', 'buttonDelete_initialTask', | ||
| 10083 | 'Delete all', 'Delete all tasks from the global initial tasklist', | ||
| 10084 | 'buttonDeleteAll_initialTask', | ||
| 10085 | 'Dump', 'Dump the list of initial tasks to the \'main\' window', | ||
| 10086 | 'buttonDump_initialTask', | ||
| 10087 | ]; | ||
| 10088 | |||
| 10089 | # Prepare the data to be displayed (there is only one tab) | ||
| 10090 | OUTER: foreach my $taskName ($axmud::CLIENT->initTaskOrderList) { | ||
| 10091 | |||
| 10092 | my ($taskObj, $listRef); | ||
| 10093 | |||
| 10094 | $taskObj = $axmud::CLIENT->ivShow('initTaskHash', $taskName); | ||
| 10095 | $listRef = [ | ||
| 10096 | $taskObj->uniqueName, $taskObj->category, $taskObj->jealousyFlag, | ||
| 10097 | $taskObj->stage, $taskObj->status, | ||
| 10098 | ]; | ||
| 10099 | |||
| 10100 | push (@dataList, $listRef); | ||
| 10101 | |||
| 10102 | } | ||
| 10103 | |||
| 10104 | $dataHash{'Global initial tasklist'} = \@dataList; | ||
| 10105 | $dataHashRef = \%dataHash; | ||
| 10106 | |||
| 10107 | # (Nothing happens when user double-clicks on line) | ||
| 10108 | |||
| 10109 | # Display all of this in the notebook | ||
| 10110 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 10111 | } | ||
| 10112 | |||
| 10113 | sub customTaskHeader { | ||
| 10114 | |||
| 10115 | # Called by ->treeViewChanged when the user clicks on the 'Custom tasklist' header in the | ||
| 10116 | # treeview | ||
| 10117 | # | ||
| 10118 | # Expected arguments | ||
| 10119 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 10120 | # | ||
| 10121 | # Return values | ||
| 10122 | # 'undef' on improper arguments | ||
| 10123 | # 1 otherwise | ||
| 10124 | |||
| 10125 | my ($self, $item, $check) = @_; | ||
| 10126 | |||
| 10127 | # Local variables | ||
| 10128 | my ( | ||
| 10129 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 10130 | @labelList, @dataList, | ||
| 10131 | %dataHash, | ||
| 10132 | ); | ||
| 10133 | |||
| 10134 | # Check for improper arguments | ||
| 10135 | if (! defined $item || defined $check) { | ||
| 10136 | |||
| 10137 | return $axmud::CLIENT->writeImproper($self->_objClass . '->customTaskHeader', @_); | ||
| 10138 | } | ||
| 10139 | |||
| 10140 | # Prepare the list of tabs | ||
| 10141 | $tabListRef = [ | ||
| 10142 | 'Custom tasklist' => '_Custom tasklist', | ||
| 10143 | ]; | ||
| 10144 | |||
| 10145 | # Prepare the list of column headings | ||
| 10146 | $columnListRef = [ | ||
| 10147 | 'Name' => 'text', # key in GA::Client->customTaskHash | ||
| 10148 | 'Task' => 'text', # ->name | ||
| 10149 | 'Type' => 'text', # ->category | ||
| 10150 | 'Jealous' => 'bool', # ->jealousyFlag | ||
| 10151 | 'Stage' => 'text', # ->stage | ||
| 10152 | 'Status' => 'text', # ->status | ||
| 10153 | ]; | ||
| 10154 | |||
| 10155 | # Prepare the list of buttons | ||
| 10156 | $buttonListRef = [ | ||
| 10157 | 'Start', 'Start the selected custom task', 'buttonStart_customTask', | ||
| 10158 | 'Edit', 'Edit the selected task', 'buttonEdit_customTask', | ||
| 10159 | 'Delete', 'Delete a task from the global initial tasklist', 'buttonDelete_customTask', | ||
| 10160 | 'Delete all', 'Delete all tasks from the global initial tasklist', | ||
| 10161 | 'buttonDeleteAll_customTask', | ||
| 10162 | 'Dump', 'Dump the list of custom tasks to the \'main\' window', | ||
| 10163 | 'buttonDump_customTask', | ||
| 10164 | ]; | ||
| 10165 | |||
| 10166 | # Prepare the data to be displayed (there is only one tab) | ||
| 10167 | @labelList = sort {lc($a) cmp lc($b)} ($axmud::CLIENT->ivKeys('customTaskHash')); | ||
| 10168 | OUTER: foreach my $label (@labelList) { | ||
| 10169 | |||
| 10170 | my ($taskObj, $listRef); | ||
| 10171 | |||
| 10172 | $taskObj = $axmud::CLIENT->ivShow('customTaskHash', $label); | ||
| 10173 | $listRef = [ | ||
| 10174 | $label, $taskObj->name, $taskObj->category, | ||
| 10175 | $taskObj->jealousyFlag, $taskObj->stage, $taskObj->status, | ||
| 10176 | ]; | ||
| 10177 | |||
| 10178 | push (@dataList, $listRef); | ||
| 10179 | |||
| 10180 | } | ||
| 10181 | |||
| 10182 | $dataHash{'Custom tasklist'} = \@dataList; | ||
| 10183 | $dataHashRef = \%dataHash; | ||
| 10184 | |||
| 10185 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 10186 | # equivalent to the 'start' button | ||
| 10187 | $self->ivPoke('notebookSelectRef', sub { | ||
| 10188 | |||
| 10189 | $self->buttonStart_customTask(); | ||
| 10190 | }); | ||
| 10191 | |||
| 10192 | # Display all of this in the notebook | ||
| 10193 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 10194 | } | ||
| 10195 | |||
| 10196 | sub taskPackageHeader { | ||
| 10197 | |||
| 10198 | # Called by ->treeViewChanged when the user clicks on the 'Task package names' header in the | ||
| 10199 | # treeview | ||
| 10200 | # | ||
| 10201 | # Expected arguments | ||
| 10202 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 10203 | # | ||
| 10204 | # Return values | ||
| 10205 | # 'undef' on improper arguments | ||
| 10206 | # 1 otherwise | ||
| 10207 | |||
| 10208 | my ($self, $item, $check) = @_; | ||
| 10209 | |||
| 10210 | # Local variables | ||
| 10211 | my ( | ||
| 10212 | $tabListRef, $shortTabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 10213 | @list, @dataList, | ||
| 10214 | %dataHash, | ||
| 10215 | ); | ||
| 10216 | |||
| 10217 | # Check for improper arguments | ||
| 10218 | if (! defined $item || defined $check) { | ||
| 10219 | |||
| 10220 | return $axmud::CLIENT->writeImproper($self->_objClass . '->taskPackageHeader', @_); | ||
| 10221 | } | ||
| 10222 | |||
| 10223 | # Prepare the list of tabs | ||
| 10224 | $tabListRef = [ | ||
| 10225 | 'Task package names' => 'Task _package names', | ||
| 10226 | ]; | ||
| 10227 | |||
| 10228 | # Prepare the list of column headings | ||
| 10229 | $columnListRef = [ | ||
| 10230 | 'Built-in' => 'bool', | ||
| 10231 | 'Standard task name' => 'text', | ||
| 10232 | 'Package name' => 'text', | ||
| 10233 | ]; | ||
| 10234 | |||
| 10235 | # Prepare the list of buttons | ||
| 10236 | $buttonListRef = [ | ||
| 10237 | 'Add', 'Add a new task package name', 'buttonAdd_taskPackage', | ||
| 10238 | 'Edit', 'Edit a new task package name', 'buttonEdit_taskPackage', | ||
| 10239 | 'Delete', 'Delete an existing task package name', 'buttonDelete_taskPackage', | ||
| 10240 | 'Reset', 'Reset all task package names to defaults', 'buttonReset_taskPackage', | ||
| 10241 | 'Reset All', 'Reset all task package names to defaults', 'buttonResetAll_taskPackage', | ||
| 10242 | 'Dump', 'Dump the list of task package names to the \'main\' window', | ||
| 10243 | 'buttonDump_taskPackage', | ||
| 10244 | ]; | ||
| 10245 | |||
| 10246 | # Prepare the data to be displayed (there is only one tab) | ||
| 10247 | @list = sort {lc($a) cmp lc($b)} ($axmud::CLIENT->ivKeys('taskPackageHash')); | ||
| 10248 | foreach my $standardName (@list) { | ||
| 10249 | |||
| 10250 | my ($flag, $listRef); | ||
| 10251 | |||
| 10252 | if ($axmud::CLIENT->ivExists('constTaskPackageHash', $standardName)) { | ||
| 10253 | $flag = TRUE; | ||
| 10254 | } else { | ||
| 10255 | $flag = FALSE; | ||
| 10256 | } | ||
| 10257 | |||
| 10258 | $listRef = [ | ||
| 10259 | $flag, | ||
| 10260 | $standardName, | ||
| 10261 | $axmud::CLIENT->ivShow('taskPackageHash', $standardName), | ||
| 10262 | ]; | ||
| 10263 | push (@dataList, $listRef); | ||
| 10264 | } | ||
| 10265 | |||
| 10266 | $dataHash{'Task package names'} = \@dataList; | ||
| 10267 | $dataHashRef = \%dataHash; | ||
| 10268 | |||
| 10269 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 10270 | # equivalent to the edit button | ||
| 10271 | $self->ivPoke('notebookSelectRef', sub { | ||
| 10272 | |||
| 10273 | $self->buttonEdit_taskPackage(); | ||
| 10274 | }); | ||
| 10275 | |||
| 10276 | # Display all of this in the notebook | ||
| 10277 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 10278 | } | ||
| 10279 | |||
| 10280 | sub taskLabelHeader { | ||
| 10281 | |||
| 10282 | # Called by ->treeViewChanged when the user clicks on the 'Task labels' header in the | ||
| 10283 | # treeview | ||
| 10284 | # | ||
| 10285 | # Expected arguments | ||
| 10286 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 10287 | # | ||
| 10288 | # Return values | ||
| 10289 | # 'undef' on improper arguments | ||
| 10290 | # 1 otherwise | ||
| 10291 | |||
| 10292 | my ($self, $item, $check) = @_; | ||
| 10293 | |||
| 10294 | # Local variables | ||
| 10295 | my ( | ||
| 10296 | $tabListRef, $shortTabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 10297 | @list, @dataList, | ||
| 10298 | %dataHash, | ||
| 10299 | ); | ||
| 10300 | |||
| 10301 | # Check for improper arguments | ||
| 10302 | if (! defined $item || defined $check) { | ||
| 10303 | |||
| 10304 | return $axmud::CLIENT->writeImproper($self->_objClass . '->taskLabelHeader', @_); | ||
| 10305 | } | ||
| 10306 | |||
| 10307 | # Prepare the list of tabs | ||
| 10308 | $tabListRef = [ | ||
| 10309 | 'Task labels' => 'Task _labels', | ||
| 10310 | ]; | ||
| 10311 | |||
| 10312 | # Prepare the list of column headings | ||
| 10313 | $columnListRef = [ | ||
| 10314 | 'Built-in' => 'bool', | ||
| 10315 | 'Label' => 'text', | ||
| 10316 | 'Standard task name' => 'text', | ||
| 10317 | ]; | ||
| 10318 | |||
| 10319 | # Prepare the list of buttons | ||
| 10320 | $buttonListRef = [ | ||
| 10321 | 'Add', 'Add a new task label', 'buttonAdd_taskLabel', | ||
| 10322 | 'Delete', 'Delete an existing task label', 'buttonDelete_taskLabel', | ||
| 10323 | 'Empty labels', 'Empties all labels attached to a particular task', | ||
| 10324 | 'buttonEmpty_taskLabel', | ||
| 10325 | 'Reset', 'Reset all task labels to defaults', 'buttonReset_taskLabel', | ||
| 10326 | 'Reset All', 'Resets all task labels to defaults', 'buttonResetAll_taskLabel', | ||
| 10327 | 'Dump', 'Dumps the list of task labels to the \'main\' window', 'buttonDump_taskLabel', | ||
| 10328 | ]; | ||
| 10329 | |||
| 10330 | # Prepare the data to be displayed (there is only one tab) | ||
| 10331 | @list = sort {lc($a) cmp lc($b)} ($axmud::CLIENT->ivKeys('taskLabelHash')); | ||
| 10332 | foreach my $label (@list) { | ||
| 10333 | |||
| 10334 | my ($flag, $listRef); | ||
| 10335 | |||
| 10336 | if ($axmud::CLIENT->ivExists('constTaskLabelHash', $label)) { | ||
| 10337 | $flag = TRUE; | ||
| 10338 | } else { | ||
| 10339 | $flag = FALSE, | ||
| 10340 | } | ||
| 10341 | |||
| 10342 | $listRef = [ | ||
| 10343 | $flag, | ||
| 10344 | $label, | ||
| 10345 | $axmud::CLIENT->ivShow('taskLabelHash', $label), | ||
| 10346 | ]; | ||
| 10347 | |||
| 10348 | push (@dataList, $listRef); | ||
| 10349 | } | ||
| 10350 | |||
| 10351 | $dataHash{'Task labels'} = \@dataList; | ||
| 10352 | $dataHashRef = \%dataHash; | ||
| 10353 | |||
| 10354 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 10355 | # equivalent to the edit button | ||
| 10356 | $self->ivPoke('notebookSelectRef', sub { | ||
| 10357 | |||
| 10358 | $self->buttonEdit_taskLabel(); | ||
| 10359 | }); | ||
| 10360 | |||
| 10361 | # Display all of this in the notebook | ||
| 10362 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 10363 | } | ||
| 10364 | |||
| 10365 | # Treeview header responses - cages | ||
| 10366 | |||
| 10367 | sub allCageHeader { | ||
| 10368 | |||
| 10369 | # Called by ->treeViewChanged when the user clicks on the 'All cages' header in the treeview | ||
| 10370 | # | ||
| 10371 | # Expected arguments | ||
| 10372 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 10373 | # | ||
| 10374 | # Return values | ||
| 10375 | # 'undef' on improper arguments | ||
| 10376 | # 1 otherwise | ||
| 10377 | |||
| 10378 | my ($self, $item, $check) = @_; | ||
| 10379 | |||
| 10380 | # Local variables | ||
| 10381 | my ( | ||
| 10382 | $tabListRef, $shortTabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 10383 | @shortTabList, | ||
| 10384 | %dataHash, | ||
| 10385 | ); | ||
| 10386 | |||
| 10387 | # Check for improper arguments | ||
| 10388 | if (! defined $item || defined $check) { | ||
| 10389 | |||
| 10390 | return $axmud::CLIENT->writeImproper($self->_objClass . '->allCageHeader', @_); | ||
| 10391 | } | ||
| 10392 | |||
| 10393 | # Prepare the list of tabs | ||
| 10394 | ($tabListRef, $shortTabListRef) = $self->setTabList_cage(); | ||
| 10395 | # Prepare the list of column headings | ||
| 10396 | $columnListRef = $self->setColumnList_cage(); | ||
| 10397 | # Prepare the list of buttons | ||
| 10398 | $buttonListRef = $self->setButtonList_cage(); | ||
| 10399 | |||
| 10400 | # Prepare the data to be displayed | ||
| 10401 | @shortTabList = @$shortTabListRef; | ||
| 10402 | OUTER: foreach my $tab (@shortTabList) { | ||
| 10403 | |||
| 10404 | my (@cageList, @dataList); | ||
| 10405 | |||
| 10406 | @cageList = $self->getSortedCages($tab); | ||
| 10407 | |||
| 10408 | # @cageList contains a sorted list of cages. Convert that list into one that can be | ||
| 10409 | # displayed in a GA::Obj::SimpleList, in columns | ||
| 10410 | foreach my $cageObj (@cageList) { | ||
| 10411 | |||
| 10412 | my ($flag, $listRef); | ||
| 10413 | |||
| 10414 | if ( | ||
| 10415 | $self->session->ivExists('currentCageHash', $cageObj->name) | ||
| 10416 | && $self->session->ivShow('currentCageHash', $cageObj->name) eq $cageObj | ||
| 10417 | ) { | ||
| 10418 | $flag = TRUE; | ||
| 10419 | } else { | ||
| 10420 | $flag = FALSE; | ||
| 10421 | } | ||
| 10422 | |||
| 10423 | $listRef = [$flag, $cageObj->name]; | ||
| 10424 | push (@dataList, $listRef); | ||
| 10425 | } | ||
| 10426 | |||
| 10427 | $dataHash{$tab} = \@dataList; | ||
| 10428 | } | ||
| 10429 | |||
| 10430 | $dataHashRef = \%dataHash; | ||
| 10431 | |||
| 10432 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 10433 | # equivalent to the edit button | ||
| 10434 | $self->ivPoke('notebookSelectRef', sub { | ||
| 10435 | |||
| 10436 | $self->buttonEdit_cage(); | ||
| 10437 | }); | ||
| 10438 | |||
| 10439 | # Display all of this in the notebook | ||
| 10440 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 10441 | } | ||
| 10442 | |||
| 10443 | sub currentCageHeader { | ||
| 10444 | |||
| 10445 | # Called by ->treeViewChanged when the user clicks on the 'Current cages' header in the | ||
| 10446 | # treeview | ||
| 10447 | # | ||
| 10448 | # Expected arguments | ||
| 10449 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 10450 | # | ||
| 10451 | # Return values | ||
| 10452 | # 'undef' on improper arguments | ||
| 10453 | # 1 otherwise | ||
| 10454 | |||
| 10455 | my ($self, $item, $check) = @_; | ||
| 10456 | |||
| 10457 | # Local variables | ||
| 10458 | my ( | ||
| 10459 | $tabListRef, $shortTabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 10460 | @shortTabList, | ||
| 10461 | %dataHash, | ||
| 10462 | ); | ||
| 10463 | |||
| 10464 | # Check for improper arguments | ||
| 10465 | if (! defined $item || defined $check) { | ||
| 10466 | |||
| 10467 | return $axmud::CLIENT->writeImproper($self->_objClass . '->currentCageHeader', @_); | ||
| 10468 | } | ||
| 10469 | |||
| 10470 | # Prepare the list of tabs | ||
| 10471 | ($tabListRef, $shortTabListRef) = $self->setTabList_cage(); | ||
| 10472 | # Prepare the list of column headings | ||
| 10473 | $columnListRef = $self->setColumnList_cage(); | ||
| 10474 | # Prepare the list of buttons | ||
| 10475 | $buttonListRef = $self->setButtonList_cage(); | ||
| 10476 | |||
| 10477 | # Prepare the data to be displayed | ||
| 10478 | @shortTabList = @$shortTabListRef; | ||
| 10479 | OUTER: foreach my $tab (@shortTabList) { | ||
| 10480 | |||
| 10481 | my (@cageList, @dataList); | ||
| 10482 | |||
| 10483 | @cageList = $self->getSortedCages($tab); | ||
| 10484 | |||
| 10485 | foreach my $cageObj (@cageList) { | ||
| 10486 | |||
| 10487 | my $listRef; | ||
| 10488 | |||
| 10489 | if ( | ||
| 10490 | $self->session->ivExists('currentCageHash', $cageObj->name) | ||
| 10491 | && $self->session->ivShow('currentCageHash', $cageObj->name) eq $cageObj | ||
| 10492 | ) { | ||
| 10493 | # The TRUE argument marks this as a current cage | ||
| 10494 | $listRef = [TRUE, $cageObj->name]; | ||
| 10495 | push (@dataList, $listRef); | ||
| 10496 | } | ||
| 10497 | } | ||
| 10498 | |||
| 10499 | $dataHash{$tab} = \@dataList; | ||
| 10500 | } | ||
| 10501 | |||
| 10502 | $dataHashRef = \%dataHash; | ||
| 10503 | |||
| 10504 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 10505 | # equivalent to the edit button | ||
| 10506 | $self->ivPoke('notebookSelectRef', sub { | ||
| 10507 | |||
| 10508 | $self->buttonEdit_cage(); | ||
| 10509 | }); | ||
| 10510 | |||
| 10511 | # Display all of this in the notebook | ||
| 10512 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 10513 | } | ||
| 10514 | |||
| 10515 | sub activeInterfaceHeader { | ||
| 10516 | |||
| 10517 | # Called by ->treeViewChanged when the user clicks on the 'Active interfaces' header in the | ||
| 10518 | # treeview | ||
| 10519 | # | ||
| 10520 | # Expected arguments | ||
| 10521 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 10522 | # | ||
| 10523 | # Return values | ||
| 10524 | # 'undef' on improper arguments | ||
| 10525 | # 1 otherwise | ||
| 10526 | |||
| 10527 | my ($self, $item, $check) = @_; | ||
| 10528 | |||
| 10529 | # Local variables | ||
| 10530 | my ( | ||
| 10531 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 10532 | @shortTabList, | ||
| 10533 | %dataHash, | ||
| 10534 | ); | ||
| 10535 | |||
| 10536 | # Check for improper arguments | ||
| 10537 | if (! defined $item || defined $check) { | ||
| 10538 | |||
| 10539 | return $axmud::CLIENT->writeImproper($self->_objClass . '->activeInterfaceHeader', @_); | ||
| 10540 | } | ||
| 10541 | |||
| 10542 | # Prepare the list of tabs | ||
| 10543 | $tabListRef = [ | ||
| 10544 | 'All' => 'A_ll', | ||
| 10545 | 'Dependent' => '_Dependent', | ||
| 10546 | 'Independent' => 'I_ndependent', | ||
| 10547 | 'Trigger' => '_Trigger', | ||
| 10548 | 'Alias' => '_Alias', | ||
| 10549 | 'Macro' => '_Macro', | ||
| 10550 | 'Timer' => 'T_imer', | ||
| 10551 | 'Hook' => '_Hook', | ||
| 10552 | ]; | ||
| 10553 | |||
| 10554 | @shortTabList = ( | ||
| 10555 | 'All', 'Dependent', 'Independent', | ||
| 10556 | 'Trigger', 'Alias', 'Macro', 'Timer', 'Hook', | ||
| 10557 | ); | ||
| 10558 | |||
| 10559 | # Prepare the list of column headings | ||
| 10560 | $columnListRef = [ | ||
| 10561 | '#' => 'int', | ||
| 10562 | 'Enab.' => 'bool', | ||
| 10563 | 'Indep.' => 'bool', | ||
| 10564 | 'Cat.' => 'text', | ||
| 10565 | 'Name' => 'text', | ||
| 10566 | ]; | ||
| 10567 | |||
| 10568 | # Prepare the list of buttons | ||
| 10569 | $buttonListRef = [ | ||
| 10570 | 'Edit', 'Edit the selected interface', 'buttonEdit_activeInterface', | ||
| 10571 | 'Dump', 'Display this list of interfaces in the \'main\' window', | ||
| 10572 | 'buttonDump_activeInterface', | ||
| 10573 | ]; | ||
| 10574 | |||
| 10575 | # Prepare the data to be displayed | ||
| 10576 | foreach my $tab (@shortTabList) { | ||
| 10577 | |||
| 10578 | my (@interfaceList, @dataList); | ||
| 10579 | |||
| 10580 | @interfaceList = sort {$a->number <=> $b->number} | ||
| 10581 | ($self->session->ivValues('interfaceNumHash')); | ||
| 10582 | |||
| 10583 | foreach my $interfaceObj (@interfaceList) { | ||
| 10584 | |||
| 10585 | my $listRef; | ||
| 10586 | |||
| 10587 | if ( | ||
| 10588 | $tab eq 'All' | ||
| 10589 | || ($tab eq 'Dependent' && ! $interfaceObj->indepFlag) | ||
| 10590 | || ($tab eq 'Independent' && $interfaceObj->indepFlag) | ||
| 10591 | || lc($tab) eq $interfaceObj->category | ||
| 10592 | ) { | ||
| 10593 | $listRef = [ | ||
| 10594 | $interfaceObj->number, | ||
| 10595 | $interfaceObj->enabledFlag, | ||
| 10596 | $interfaceObj->indepFlag, | ||
| 10597 | $interfaceObj->category, | ||
| 10598 | $interfaceObj->name, | ||
| 10599 | ]; | ||
| 10600 | |||
| 10601 | push (@dataList, $listRef); | ||
| 10602 | } | ||
| 10603 | } | ||
| 10604 | |||
| 10605 | $dataHash{$tab} = \@dataList; | ||
| 10606 | } | ||
| 10607 | |||
| 10608 | $dataHashRef = \%dataHash; | ||
| 10609 | |||
| 10610 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 10611 | # equivalent to the edit button | ||
| 10612 | $self->ivPoke('notebookSelectRef', sub { | ||
| 10613 | |||
| 10614 | $self->buttonEdit_activeInterface(); | ||
| 10615 | }); | ||
| 10616 | |||
| 10617 | # Display all of this in the notebook | ||
| 10618 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 10619 | } | ||
| 10620 | |||
| 10621 | sub interfaceModelHeader { | ||
| 10622 | |||
| 10623 | # Called by ->treeViewChanged when the user clicks on the 'Interface models' header in the | ||
| 10624 | # treeview | ||
| 10625 | # | ||
| 10626 | # Expected arguments | ||
| 10627 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 10628 | # | ||
| 10629 | # Return values | ||
| 10630 | # 'undef' on improper arguments | ||
| 10631 | # 1 otherwise | ||
| 10632 | |||
| 10633 | my ($self, $item, $check) = @_; | ||
| 10634 | |||
| 10635 | # Local variables | ||
| 10636 | my ( | ||
| 10637 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 10638 | @categoryList, @dataList, | ||
| 10639 | %dataHash, | ||
| 10640 | ); | ||
| 10641 | |||
| 10642 | # Check for improper arguments | ||
| 10643 | if (! defined $item || defined $check) { | ||
| 10644 | |||
| 10645 | return $axmud::CLIENT->writeImproper($self->_objClass . '->interfaceModelHeader', @_); | ||
| 10646 | } | ||
| 10647 | |||
| 10648 | # Prepare the list of tabs | ||
| 10649 | $tabListRef = [ | ||
| 10650 | 'Interface models' => '_Interface models', | ||
| 10651 | ]; | ||
| 10652 | |||
| 10653 | # Prepare the list of column headings | ||
| 10654 | $columnListRef = [ | ||
| 10655 | 'Category' => 'text', | ||
| 10656 | 'Stimulus' => 'text', | ||
| 10657 | 'Response' => 'text', | ||
| 10658 | ]; | ||
| 10659 | |||
| 10660 | # Prepare the list of buttons | ||
| 10661 | $buttonListRef = [ | ||
| 10662 | 'View', 'View the selected interface model', 'buttonView_interfaceModel', | ||
| 10663 | 'Dump', 'Display this list of interface models in the \'main\' window', | ||
| 10664 | 'buttonDump_interfaceModel', | ||
| 10665 | ]; | ||
| 10666 | |||
| 10667 | # Prepare the data to be displayed (there is only one tab) | ||
| 10668 | @categoryList = ('trigger', 'alias', 'macro', 'timer', 'hook'); | ||
| 10669 | foreach my $category (@categoryList) { | ||
| 10670 | |||
| 10671 | my ($modelObj, $listRef); | ||
| 10672 | |||
| 10673 | $modelObj = $axmud::CLIENT->ivShow('interfaceModelHash', $category); | ||
| 10674 | $listRef = [$modelObj->category, $modelObj->stimulusName, $modelObj->responseName]; | ||
| 10675 | push (@dataList, $listRef); | ||
| 10676 | } | ||
| 10677 | |||
| 10678 | $dataHash{'Interface models'} = \@dataList; | ||
| 10679 | $dataHashRef = \%dataHash; | ||
| 10680 | |||
| 10681 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 10682 | # equivalent to the edit button | ||
| 10683 | $self->ivPoke('notebookSelectRef', sub { | ||
| 10684 | |||
| 10685 | $self->buttonView_interfaceModel(); | ||
| 10686 | }); | ||
| 10687 | |||
| 10688 | # Display all of this in the notebook | ||
| 10689 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 10690 | } | ||
| 10691 | |||
| 10692 | # Treeview header responses - world model | ||
| 10693 | |||
| 10694 | sub modelHeader { | ||
| 10695 | |||
| 10696 | # Called by $self->allModelHeader, $self->regionModelHeader etc, after a call by | ||
| 10697 | # ->treeViewChanged when the user clicks on one of the items under the 'world model' | ||
| 10698 | # header in the treeview | ||
| 10699 | # | ||
| 10700 | # Expected arguments | ||
| 10701 | # $tabName - What to display on the tab, e.g. 'Weapons' | ||
| 10702 | # $tabShortCut - e.g. '_Weapons' | ||
| 10703 | # $iv - The GA::Obj::WorldModel IV storing all the world model objects of a | ||
| 10704 | # certain type, e.g. 'regionModelHash', 'weaponModelHash' (or even | ||
| 10705 | # 'modelHash') | ||
| 10706 | # $buttonListRef - Reference to a list containing the buttons to use for this category of | ||
| 10707 | # world model object (usually defined by $self->setButtonList_model, | ||
| 10708 | # but some types of object specify their own buttons) | ||
| 10709 | # | ||
| 10710 | # Return values | ||
| 10711 | # 'undef' on improper arguments | ||
| 10712 | # 1 otherwise | ||
| 10713 | |||
| 10714 | my ($self, $tabName, $tabShortCut, $iv, $buttonListRef, $check) = @_; | ||
| 10715 | |||
| 10716 | # Local variables | ||
| 10717 | my ( | ||
| 10718 | $tabListRef, $columnListRef, $wmObj, $dataHashRef, | ||
| 10719 | @objList, @dataList, | ||
| 10720 | %dataHash, | ||
| 10721 | ); | ||
| 10722 | |||
| 10723 | # Check for improper arguments | ||
| 10724 | if ( | ||
| 10725 | ! defined $tabName || ! defined $tabShortCut || ! defined $iv | ||
| 10726 | || ! defined $buttonListRef || defined $check | ||
| 10727 | ) { | ||
| 10728 | return $axmud::CLIENT->writeImproper($self->_objClass . '->modelHeader', @_); | ||
| 10729 | } | ||
| 10730 | |||
| 10731 | # Prepare the list of tabs | ||
| 10732 | $tabListRef = [ | ||
| 10733 | $tabName => $tabShortCut, | ||
| 10734 | ]; | ||
| 10735 | |||
| 10736 | # Prepare the list of column headings | ||
| 10737 | $columnListRef = $self->setColumnList_model(); | ||
| 10738 | |||
| 10739 | # Import the world model object (for convenience) | ||
| 10740 | $wmObj = $self->session->worldModelObj; | ||
| 10741 | # Prepare the data to be displayed (there is only one tab). Rather than sort the model | ||
| 10742 | # objects by number (which might take a long time), check every number between 1 and | ||
| 10743 | # GA::Obj::WorldModel->modelObjCount, using only objects which are actually stored in $iv | ||
| 10744 | if ($wmObj->modelObjCount) { | ||
| 10745 | |||
| 10746 | for (my $count = 1; $count <= $wmObj->modelObjCount; $count++) { | ||
| 10747 | |||
| 10748 | if (exists $wmObj->{$iv}{$count}) { | ||
| 10749 | |||
| 10750 | push (@objList, $wmObj->{$iv}{$count}); | ||
| 10751 | } | ||
| 10752 | } | ||
| 10753 | } | ||
| 10754 | |||
| 10755 | OUTER: foreach my $obj (@objList) { | ||
| 10756 | |||
| 10757 | my $listRef = [$obj->number, $obj->category, $obj->name]; | ||
| 10758 | push (@dataList, $listRef); | ||
| 10759 | } | ||
| 10760 | |||
| 10761 | $dataHash{$tabName} = \@dataList; | ||
| 10762 | $dataHashRef = \%dataHash; | ||
| 10763 | |||
| 10764 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 10765 | # equivalent to the edit button | ||
| 10766 | $self->ivPoke('notebookSelectRef', sub { | ||
| 10767 | |||
| 10768 | $self->buttonEdit_model(); | ||
| 10769 | }); | ||
| 10770 | |||
| 10771 | # Display all of this in the notebook | ||
| 10772 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 10773 | } | ||
| 10774 | |||
| 10775 | sub allModelHeader { | ||
| 10776 | |||
| 10777 | # Called by ->treeViewChanged when the user clicks on the 'All objects' header in the | ||
| 10778 | # treeview | ||
| 10779 | # The code to display the tab is basically the same for all categories of world model | ||
| 10780 | # object, so all categories call a single function | ||
| 10781 | # | ||
| 10782 | # Expected arguments | ||
| 10783 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 10784 | # | ||
| 10785 | # Return values | ||
| 10786 | # 'undef' on improper arguments | ||
| 10787 | # The return value of $self->modelHeader, otherwise | ||
| 10788 | |||
| 10789 | my ($self, $item, $check) = @_; | ||
| 10790 | |||
| 10791 | # Local variables | ||
| 10792 | my @buttonList; | ||
| 10793 | |||
| 10794 | # Check for improper arguments | ||
| 10795 | if (! defined $item || defined $check) { | ||
| 10796 | |||
| 10797 | return $axmud::CLIENT->writeImproper($self->_objClass . '->allModelHeader', @_); | ||
| 10798 | } | ||
| 10799 | |||
| 10800 | # Prepare the list of buttons. This list is the same as the standard list of buttons, but | ||
| 10801 | # without the 'add' button | ||
| 10802 | @buttonList = ( | ||
| 10803 | 'Edit', 'Edit the selected world model object', 'buttonEdit_model', | ||
| 10804 | 'Delete', 'Delete the selected world model object', 'buttonDelete_model', | ||
| 10805 | 'Dump', 'Displays a list of all world model objects in the \'main\' window', | ||
| 10806 | 'buttonDump_model', | ||
| 10807 | 'Edit model', 'Edit the world model itself', 'buttonEdit_worldModel', | ||
| 10808 | ); | ||
| 10809 | |||
| 10810 | return $self->modelHeader( | ||
| 10811 | 'All objects', | ||
| 10812 | 'A_ll objects', | ||
| 10813 | 'modelHash', | ||
| 10814 | \@buttonList, | ||
| 10815 | ); | ||
| 10816 | } | ||
| 10817 | |||
| 10818 | sub regionModelHeader { | ||
| 10819 | |||
| 10820 | # Called by ->treeViewChanged when the user clicks on the 'Regions' header in the treeview | ||
| 10821 | # The code to display the tab is basically the same for all categories of world model | ||
| 10822 | # object, so all categories call a single function | ||
| 10823 | # | ||
| 10824 | # Expected arguments | ||
| 10825 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 10826 | # | ||
| 10827 | # Return values | ||
| 10828 | # 'undef' on improper arguments | ||
| 10829 | # The return value of $self->modelHeader, otherwise | ||
| 10830 | |||
| 10831 | my ($self, $item, $check) = @_; | ||
| 10832 | |||
| 10833 | # Local variables | ||
| 10834 | my @buttonList; | ||
| 10835 | |||
| 10836 | # Check for improper arguments | ||
| 10837 | if (! defined $item || defined $check) { | ||
| 10838 | |||
| 10839 | return $axmud::CLIENT->writeImproper($self->_objClass . '->regionModelHeader', @_); | ||
| 10840 | } | ||
| 10841 | |||
| 10842 | # Prepare the list of buttons | ||
| 10843 | @buttonList = ( | ||
| 10844 | 'Add', 'Add a region object to the world model', 'buttonAddRegion_model', | ||
| 10845 | 'Add temporary', | ||
| 10846 | 'Add a temporary region object to the world model', 'buttonAddTempRegion_model', | ||
| 10847 | 'Edit region', 'Edit the selected region model object', 'buttonEdit_model', | ||
| 10848 | 'Edit regionmap', 'Edit the selected region\' regionmap', 'buttonEdit_regionmap', | ||
| 10849 | 'Delete', 'Delete the selected region model object', 'buttonDeleteRegion_model', | ||
| 10850 | 'Dump', 'Displays a list of all world model objects in the \'main\' window', | ||
| 10851 | 'buttonDump_model', | ||
| 10852 | ); | ||
| 10853 | |||
| 10854 | return $self->modelHeader( | ||
| 10855 | 'Regions', | ||
| 10856 | 'Regio_ns', | ||
| 10857 | 'regionModelHash', | ||
| 10858 | \@buttonList, | ||
| 10859 | ); | ||
| 10860 | } | ||
| 10861 | |||
| 10862 | sub roomModelHeader { | ||
| 10863 | |||
| 10864 | # Called by ->treeViewChanged when the user clicks on the 'Rooms' header in the treeview | ||
| 10865 | # The code to display the tab is basically the same for all categories of world model | ||
| 10866 | # object, so all categories call a single function | ||
| 10867 | # | ||
| 10868 | # Expected arguments | ||
| 10869 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 10870 | # | ||
| 10871 | # Return values | ||
| 10872 | # 'undef' on improper arguments | ||
| 10873 | # The return value of $self->modelHeader, otherwise | ||
| 10874 | |||
| 10875 | my ($self, $item, $check) = @_; | ||
| 10876 | |||
| 10877 | # Local variables | ||
| 10878 | my @buttonList; | ||
| 10879 | |||
| 10880 | # Check for improper arguments | ||
| 10881 | if (! defined $item || defined $check) { | ||
| 10882 | |||
| 10883 | return $axmud::CLIENT->writeImproper($self->_objClass . '->roomModelHeader', @_); | ||
| 10884 | } | ||
| 10885 | |||
| 10886 | # Prepare the list of buttons | ||
| 10887 | @buttonList = ( | ||
| 10888 | 'Edit', 'Edit the selected world model object', 'buttonEdit_model', | ||
| 10889 | 'Delete', 'Delete the selected room model object', 'buttonDeleteRoom_model', | ||
| 10890 | 'Dump', 'Displays a list of all world model objects in the \'main\' window', | ||
| 10891 | 'buttonDump_model', | ||
| 10892 | ); | ||
| 10893 | |||
| 10894 | return $self->modelHeader( | ||
| 10895 | 'Rooms', | ||
| 10896 | '_Rooms', | ||
| 10897 | 'roomModelHash', | ||
| 10898 | \@buttonList, | ||
| 10899 | ); | ||
| 10900 | } | ||
| 10901 | |||
| 10902 | sub weaponModelHeader { | ||
| 10903 | |||
| 10904 | # Called by ->treeViewChanged when the user clicks on the 'Weapons' header in the treeview | ||
| 10905 | # The code to display the tab is basically the same for all categories of world model | ||
| 10906 | # object, so all categories call a single function | ||
| 10907 | # | ||
| 10908 | # Expected arguments | ||
| 10909 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 10910 | # | ||
| 10911 | # Return values | ||
| 10912 | # 'undef' on improper arguments | ||
| 10913 | # The return value of $self->modelHeader, otherwise | ||
| 10914 | |||
| 10915 | my ($self, $item, $check) = @_; | ||
| 10916 | |||
| 10917 | # Local variables | ||
| 10918 | my $buttonListRef; | ||
| 10919 | |||
| 10920 | # Check for improper arguments | ||
| 10921 | if (! defined $item || defined $check) { | ||
| 10922 | |||
| 10923 | return $axmud::CLIENT->writeImproper($self->_objClass . '->weaponModelHeader', @_); | ||
| 10924 | } | ||
| 10925 | |||
| 10926 | # Prepare the list of buttons | ||
| 10927 | $buttonListRef = $self->setButtonList_model(); | ||
| 10928 | |||
| 10929 | return $self->modelHeader( | ||
| 10930 | 'Weapons', | ||
| 10931 | '_Weapons', | ||
| 10932 | 'weaponModelHash', | ||
| 10933 | $buttonListRef, | ||
| 10934 | ); | ||
| 10935 | } | ||
| 10936 | |||
| 10937 | sub armourModelHeader { | ||
| 10938 | |||
| 10939 | # Called by ->treeViewChanged when the user clicks on the 'Armours' header in the treeview | ||
| 10940 | # The code to display the tab is basically the same for all categories of world model | ||
| 10941 | # object, so all categories call a single function | ||
| 10942 | # | ||
| 10943 | # Expected arguments | ||
| 10944 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 10945 | # | ||
| 10946 | # Return values | ||
| 10947 | # 'undef' on improper arguments | ||
| 10948 | # The return value of $self->modelHeader, otherwise | ||
| 10949 | |||
| 10950 | my ($self, $item, $check) = @_; | ||
| 10951 | |||
| 10952 | # Local variables | ||
| 10953 | my $buttonListRef; | ||
| 10954 | |||
| 10955 | # Check for improper arguments | ||
| 10956 | if (! defined $item || defined $check) { | ||
| 10957 | |||
| 10958 | return $axmud::CLIENT->writeImproper($self->_objClass . '->armourModelHeader', @_); | ||
| 10959 | } | ||
| 10960 | |||
| 10961 | # Prepare the list of buttons | ||
| 10962 | $buttonListRef = $self->setButtonList_model(); | ||
| 10963 | |||
| 10964 | return $self->modelHeader( | ||
| 10965 | 'Armours', | ||
| 10966 | '_Armours', | ||
| 10967 | 'armourModelHash', | ||
| 10968 | $buttonListRef, | ||
| 10969 | ); | ||
| 10970 | } | ||
| 10971 | |||
| 10972 | sub garmentModelHeader { | ||
| 10973 | |||
| 10974 | # Called by ->treeViewChanged when the user clicks on the 'Garments' header in the treeview | ||
| 10975 | # The code to display the tab is basically the same for all categories of world model | ||
| 10976 | # object, so all categories call a single function | ||
| 10977 | # | ||
| 10978 | # Expected arguments | ||
| 10979 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 10980 | # | ||
| 10981 | # Return values | ||
| 10982 | # 'undef' on improper arguments | ||
| 10983 | # The return value of $self->modelHeader, otherwise | ||
| 10984 | |||
| 10985 | my ($self, $item, $check) = @_; | ||
| 10986 | |||
| 10987 | # Local variables | ||
| 10988 | my $buttonListRef; | ||
| 10989 | |||
| 10990 | # Check for improper arguments | ||
| 10991 | if (! defined $item || defined $check) { | ||
| 10992 | |||
| 10993 | return $axmud::CLIENT->writeImproper($self->_objClass . '->garmentModelHeader', @_); | ||
| 10994 | } | ||
| 10995 | |||
| 10996 | # Prepare the list of buttons | ||
| 10997 | $buttonListRef = $self->setButtonList_model(); | ||
| 10998 | |||
| 10999 | return $self->modelHeader( | ||
| 11000 | 'Garments', | ||
| 11001 | '_Garments', | ||
| 11002 | 'garmentModelHash', | ||
| 11003 | $buttonListRef, | ||
| 11004 | ); | ||
| 11005 | } | ||
| 11006 | |||
| 11007 | sub charModelHeader { | ||
| 11008 | |||
| 11009 | # Called by ->treeViewChanged when the user clicks on the 'Characters' header in the | ||
| 11010 | # treeview | ||
| 11011 | # The code to display the tab is basically the same for all categories of world model | ||
| 11012 | # object, so all categories call a single function | ||
| 11013 | # | ||
| 11014 | # Expected arguments | ||
| 11015 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 11016 | # | ||
| 11017 | # Return values | ||
| 11018 | # 'undef' on improper arguments | ||
| 11019 | # The return value of $self->modelHeader, otherwise | ||
| 11020 | |||
| 11021 | my ($self, $item, $check) = @_; | ||
| 11022 | |||
| 11023 | # Local variables | ||
| 11024 | my @buttonList; | ||
| 11025 | |||
| 11026 | # Check for improper arguments | ||
| 11027 | if (! defined $item || defined $check) { | ||
| 11028 | |||
| 11029 | return $axmud::CLIENT->writeImproper($self->_objClass . '->charModelHeader', @_); | ||
| 11030 | } | ||
| 11031 | |||
| 11032 | # Prepare the list of buttons | ||
| 11033 | @buttonList = ( | ||
| 11034 | 'Add', 'Add a player character to the world model', 'buttonAddChar_model', | ||
| 11035 | 'Edit', 'Edit the selected character object', 'buttonEdit_model', | ||
| 11036 | 'Delete', 'Delete the selected character object', 'buttonDelete_model', | ||
| 11037 | 'Dump', 'Displays a list of all world model characters in the \'main\' window', | ||
| 11038 | 'buttonDumpChar_model', | ||
| 11039 | ); | ||
| 11040 | |||
| 11041 | return $self->modelHeader( | ||
| 11042 | 'Characters', | ||
| 11043 | '_Characters', | ||
| 11044 | 'charModelHash', | ||
| 11045 | \@buttonList, | ||
| 11046 | ); | ||
| 11047 | } | ||
| 11048 | |||
| 11049 | sub minionModelHeader { | ||
| 11050 | |||
| 11051 | # Called by ->treeViewChanged when the user clicks on the 'Minions' header in the treeview | ||
| 11052 | # The code to display the tab is basically the same for all categories of world model | ||
| 11053 | # object, so all categories call a single function | ||
| 11054 | # | ||
| 11055 | # Expected arguments | ||
| 11056 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 11057 | # | ||
| 11058 | # Return values | ||
| 11059 | # 'undef' on improper arguments | ||
| 11060 | # The return value of $self->modelHeader, otherwise | ||
| 11061 | |||
| 11062 | my ($self, $item, $check) = @_; | ||
| 11063 | |||
| 11064 | # Local variables | ||
| 11065 | my $buttonListRef; | ||
| 11066 | |||
| 11067 | # Check for improper arguments | ||
| 11068 | if (! defined $item || defined $check) { | ||
| 11069 | |||
| 11070 | return $axmud::CLIENT->writeImproper($self->_objClass . '->minionModelHeader', @_); | ||
| 11071 | } | ||
| 11072 | |||
| 11073 | # Prepare the list of buttons | ||
| 11074 | $buttonListRef = $self->setButtonList_model(); | ||
| 11075 | |||
| 11076 | return $self->modelHeader( | ||
| 11077 | 'Minions', | ||
| 11078 | '_Minions', | ||
| 11079 | 'minionModelHash', | ||
| 11080 | $buttonListRef, | ||
| 11081 | ); | ||
| 11082 | } | ||
| 11083 | |||
| 11084 | sub sentientModelHeader { | ||
| 11085 | |||
| 11086 | # Called by ->treeViewChanged when the user clicks on the 'Sentients' header in the treeview | ||
| 11087 | # The code to display the tab is basically the same for all categories of world model | ||
| 11088 | # object, so all categories call a single function | ||
| 11089 | # | ||
| 11090 | # Expected arguments | ||
| 11091 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 11092 | # | ||
| 11093 | # Return values | ||
| 11094 | # 'undef' on improper arguments | ||
| 11095 | # The return value of $self->modelHeader, otherwise | ||
| 11096 | |||
| 11097 | my ($self, $item, $check) = @_; | ||
| 11098 | |||
| 11099 | # Local variables | ||
| 11100 | my $buttonListRef; | ||
| 11101 | |||
| 11102 | # Check for improper arguments | ||
| 11103 | if (! defined $item || defined $check) { | ||
| 11104 | |||
| 11105 | return $axmud::CLIENT->writeImproper($self->_objClass . '->sentientModelHeader', @_); | ||
| 11106 | } | ||
| 11107 | |||
| 11108 | # Prepare the list of buttons | ||
| 11109 | $buttonListRef = $self->setButtonList_model(); | ||
| 11110 | |||
| 11111 | return $self->modelHeader( | ||
| 11112 | 'Sentients', | ||
| 11113 | '_Sentients', | ||
| 11114 | 'sentientModelHash', | ||
| 11115 | $buttonListRef, | ||
| 11116 | ); | ||
| 11117 | } | ||
| 11118 | |||
| 11119 | sub creatureModelHeader { | ||
| 11120 | |||
| 11121 | # Called by ->treeViewChanged when the user clicks on the 'Creatures' header in the treeview | ||
| 11122 | # The code to display the tab is basically the same for all categories of world model | ||
| 11123 | # object, so all categories call a single function | ||
| 11124 | # | ||
| 11125 | # Expected arguments | ||
| 11126 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 11127 | # | ||
| 11128 | # Return values | ||
| 11129 | # 'undef' on improper arguments | ||
| 11130 | # The return value of $self->modelHeader, otherwise | ||
| 11131 | |||
| 11132 | my ($self, $item, $check) = @_; | ||
| 11133 | |||
| 11134 | # Local variables | ||
| 11135 | my $buttonListRef; | ||
| 11136 | |||
| 11137 | # Check for improper arguments | ||
| 11138 | if (! defined $item || defined $check) { | ||
| 11139 | |||
| 11140 | return $axmud::CLIENT->writeImproper($self->_objClass . '->creatureModelHeader', @_); | ||
| 11141 | } | ||
| 11142 | |||
| 11143 | # Prepare the list of buttons | ||
| 11144 | $buttonListRef = $self->setButtonList_model(); | ||
| 11145 | |||
| 11146 | return $self->modelHeader( | ||
| 11147 | 'Creatures', | ||
| 11148 | 'Crea_tures', | ||
| 11149 | 'creatureModelHash', | ||
| 11150 | $buttonListRef, | ||
| 11151 | ); | ||
| 11152 | } | ||
| 11153 | |||
| 11154 | sub portableModelHeader { | ||
| 11155 | |||
| 11156 | # Called by ->treeViewChanged when the user clicks on the 'Portables' header in the treeview | ||
| 11157 | # The code to display the tab is basically the same for all categories of world model | ||
| 11158 | # object, so all categories call a single function | ||
| 11159 | # | ||
| 11160 | # Expected arguments | ||
| 11161 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 11162 | # | ||
| 11163 | # Return values | ||
| 11164 | # 'undef' on improper arguments | ||
| 11165 | # The return value of $self->modelHeader, otherwise | ||
| 11166 | |||
| 11167 | my ($self, $item, $check) = @_; | ||
| 11168 | |||
| 11169 | # Local variables | ||
| 11170 | my $buttonListRef; | ||
| 11171 | |||
| 11172 | # Check for improper arguments | ||
| 11173 | if (! defined $item || defined $check) { | ||
| 11174 | |||
| 11175 | return $axmud::CLIENT->writeImproper($self->_objClass . '->portableModelHeader', @_); | ||
| 11176 | } | ||
| 11177 | |||
| 11178 | # Prepare the list of buttons | ||
| 11179 | $buttonListRef = $self->setButtonList_model(); | ||
| 11180 | |||
| 11181 | return $self->modelHeader( | ||
| 11182 | 'Portables', | ||
| 11183 | '_Portables', | ||
| 11184 | 'portableModelHash', | ||
| 11185 | $buttonListRef, | ||
| 11186 | ); | ||
| 11187 | } | ||
| 11188 | |||
| 11189 | sub decorationModelHeader { | ||
| 11190 | |||
| 11191 | # Called by ->treeViewChanged when the user clicks on the 'Decorations' header in the | ||
| 11192 | # treeview | ||
| 11193 | # The code to display the tab is basically the same for all categories of world model | ||
| 11194 | # object, so all categories call a single function | ||
| 11195 | # | ||
| 11196 | # Expected arguments | ||
| 11197 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 11198 | # | ||
| 11199 | # Return values | ||
| 11200 | # 'undef' on improper arguments | ||
| 11201 | # The return value of $self->modelHeader, otherwise | ||
| 11202 | |||
| 11203 | my ($self, $item, $check) = @_; | ||
| 11204 | |||
| 11205 | # Local variables | ||
| 11206 | my $buttonListRef; | ||
| 11207 | |||
| 11208 | # Check for improper arguments | ||
| 11209 | if (! defined $item || defined $check) { | ||
| 11210 | |||
| 11211 | return $axmud::CLIENT->writeImproper($self->_objClass . '->decorationModelHeader', @_); | ||
| 11212 | } | ||
| 11213 | |||
| 11214 | # Prepare the list of buttons | ||
| 11215 | $buttonListRef = $self->setButtonList_model(); | ||
| 11216 | |||
| 11217 | return $self->modelHeader( | ||
| 11218 | 'Decorations', | ||
| 11219 | '_Decorations', | ||
| 11220 | 'decorationModelHash', | ||
| 11221 | $buttonListRef, | ||
| 11222 | ); | ||
| 11223 | } | ||
| 11224 | |||
| 11225 | sub customModelHeader { | ||
| 11226 | |||
| 11227 | # Called by ->treeViewChanged when the user clicks on the 'Custom objects' header in the | ||
| 11228 | # treeview | ||
| 11229 | # The code to display the tab is basically the same for all categories of world model | ||
| 11230 | # object, so all categories call a single function | ||
| 11231 | # | ||
| 11232 | # Expected arguments | ||
| 11233 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 11234 | # | ||
| 11235 | # Return values | ||
| 11236 | # 'undef' on improper arguments | ||
| 11237 | # The return value of $self->modelHeader, otherwise | ||
| 11238 | |||
| 11239 | my ($self, $item, $check) = @_; | ||
| 11240 | |||
| 11241 | # Local variables | ||
| 11242 | my $buttonListRef; | ||
| 11243 | |||
| 11244 | # Check for improper arguments | ||
| 11245 | if (! defined $item || defined $check) { | ||
| 11246 | |||
| 11247 | return $axmud::CLIENT->writeImproper($self->_objClass . '->customModelHeader', @_); | ||
| 11248 | } | ||
| 11249 | |||
| 11250 | # Prepare the list of buttons | ||
| 11251 | $buttonListRef = $self->setButtonList_model(); | ||
| 11252 | |||
| 11253 | return $self->modelHeader( | ||
| 11254 | 'Custom', | ||
| 11255 | 'C_ustom', | ||
| 11256 | 'customModelHash', | ||
| 11257 | $buttonListRef, | ||
| 11258 | ); | ||
| 11259 | } | ||
| 11260 | |||
| 11261 | sub exitModelHeader { | ||
| 11262 | |||
| 11263 | # Called by ->treeViewChanged when the user clicks on the 'Exits' header in the treeview | ||
| 11264 | # | ||
| 11265 | # Expected arguments | ||
| 11266 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 11267 | # | ||
| 11268 | # Return values | ||
| 11269 | # 'undef' on improper arguments | ||
| 11270 | # 1 otherwise | ||
| 11271 | |||
| 11272 | my ($self, $item, $check) = @_; | ||
| 11273 | |||
| 11274 | # Local variables | ||
| 11275 | my ( | ||
| 11276 | $tabListRef, $columnListRef, $buttonListRef, $wmObj, $dataHashRef, | ||
| 11277 | @objList, @dataList, | ||
| 11278 | %dataHash, | ||
| 11279 | ); | ||
| 11280 | |||
| 11281 | # Check for improper arguments | ||
| 11282 | if (! defined $item || defined $check) { | ||
| 11283 | |||
| 11284 | return $axmud::CLIENT->writeImproper($self->_objClass . '->exitModelHeader', @_); | ||
| 11285 | } | ||
| 11286 | |||
| 11287 | # Prepare the list of tabs | ||
| 11288 | $tabListRef = [ | ||
| 11289 | 'Exits' => '_Exits', | ||
| 11290 | ]; | ||
| 11291 | |||
| 11292 | # Prepare the list of column headings | ||
| 11293 | $columnListRef = [ | ||
| 11294 | 'Exit #' => 'int', | ||
| 11295 | 'Room #' => 'int', | ||
| 11296 | 'Nominal dir' => 'text', | ||
| 11297 | 'Map dir' => 'text', | ||
| 11298 | ]; | ||
| 11299 | |||
| 11300 | # Prepare the list of buttons | ||
| 11301 | $buttonListRef = [ | ||
| 11302 | 'Add', 'Add an exit to the exit model', 'buttonAdd_exitModel', | ||
| 11303 | 'Edit', 'Edit the selected exit', 'buttonEdit_exitModel', | ||
| 11304 | 'Delete', 'Delete the selected exit from the exit model', 'buttonDelete_exitModel', | ||
| 11305 | 'Dump', 'Dump the contents of the exit model in the \'main\' window', | ||
| 11306 | 'buttonDump_exitModel', | ||
| 11307 | ]; | ||
| 11308 | |||
| 11309 | # Import the world model object (for convenience) | ||
| 11310 | $wmObj = $self->session->worldModelObj; | ||
| 11311 | # Prepare the data to be displayed (there is only one tab). Rather than sort the exit model | ||
| 11312 | # objects by number (which might take a long time), check every number between 1 and | ||
| 11313 | # GA::Obj::WorldModel->exitObjCount, using only objects which are actually stored in $iv | ||
| 11314 | if ($wmObj->exitObjCount) { | ||
| 11315 | |||
| 11316 | for (my $count = 1; $count <= $wmObj->exitObjCount; $count++) { | ||
| 11317 | |||
| 11318 | if (exists $wmObj->{'exitModelHash'}{$count}) { | ||
| 11319 | |||
| 11320 | push (@objList, $wmObj->{'exitModelHash'}{$count}); | ||
| 11321 | } | ||
| 11322 | } | ||
| 11323 | } | ||
| 11324 | |||
| 11325 | foreach my $exitObj (@objList) { | ||
| 11326 | |||
| 11327 | my ($listRef, $mapDir); | ||
| 11328 | |||
| 11329 | if ($exitObj->mapDir) { | ||
| 11330 | $mapDir = $exitObj->mapDir; | ||
| 11331 | } else { | ||
| 11332 | $mapDir = 'unallocatable'; | ||
| 11333 | } | ||
| 11334 | |||
| 11335 | $listRef = [$exitObj->number, $exitObj->parent, $exitObj->dir, $mapDir]; | ||
| 11336 | push (@dataList, $listRef); | ||
| 11337 | } | ||
| 11338 | |||
| 11339 | $dataHash{'Exits'} = \@dataList; | ||
| 11340 | $dataHashRef = \%dataHash; | ||
| 11341 | |||
| 11342 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 11343 | # equivalent to the edit button | ||
| 11344 | $self->ivPoke('notebookSelectRef', sub { | ||
| 11345 | |||
| 11346 | $self->buttonEdit_exitModel(); | ||
| 11347 | }); | ||
| 11348 | |||
| 11349 | # Display all of this in the notebook | ||
| 11350 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 11351 | } | ||
| 11352 | |||
| 11353 | # Treeview header responses - buffers | ||
| 11354 | |||
| 11355 | sub displayBufferHeader { | ||
| 11356 | |||
| 11357 | # Called by ->treeViewChanged when the user clicks on the 'Display buffer' header in the | ||
| 11358 | # treeview | ||
| 11359 | # | ||
| 11360 | # Expected arguments | ||
| 11361 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 11362 | # | ||
| 11363 | # Return values | ||
| 11364 | # 'undef' on improper arguments | ||
| 11365 | # 1 otherwise | ||
| 11366 | |||
| 11367 | my ($self, $item, $check) = @_; | ||
| 11368 | |||
| 11369 | # Local variables | ||
| 11370 | my ( | ||
| 11371 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 11372 | @objList, @dataList, | ||
| 11373 | %dataHash, | ||
| 11374 | ); | ||
| 11375 | |||
| 11376 | # Check for improper arguments | ||
| 11377 | if (! defined $item || defined $check) { | ||
| 11378 | |||
| 11379 | return $axmud::CLIENT->writeImproper($self->_objClass . '->displayBufferHeader', @_); | ||
| 11380 | } | ||
| 11381 | |||
| 11382 | # Prepare the list of tabs | ||
| 11383 | $tabListRef = [ | ||
| 11384 | 'Display buffer' => '_Display buffer', | ||
| 11385 | ]; | ||
| 11386 | |||
| 11387 | # Prepare the list of column headings | ||
| 11388 | $columnListRef = [ | ||
| 11389 | 'Line' => 'int', | ||
| 11390 | 'Time' => 'int', | ||
| 11391 | 'Text' => 'text', | ||
| 11392 | ]; | ||
| 11393 | |||
| 11394 | # Prepare the list of buttons | ||
| 11395 | $buttonListRef = [ | ||
| 11396 | 'Dump 20', 'Display the most recent 20 lines in the \'main\' window', | ||
| 11397 | 'buttonDump20_displayBuffer', | ||
| 11398 | 'Dump all', 'Display all lines in the \'main\' window', 'buttonDumpAll_displayBuffer', | ||
| 11399 | 'Status', 'Display the display buffer\'s status in the \'main\' window', | ||
| 11400 | 'buttonStatus_displayBuffer', | ||
| 11401 | 'View line', 'View the selected line in an \'edit\' window', 'buttonView_displayBuffer', | ||
| 11402 | 'Test pattern', 'Test a pattern (regex) against this line', 'buttonTest_displayBuffer', | ||
| 11403 | 'Save buffer', 'Save lines from the display buffer to file', 'buttonSave_displayBuffer', | ||
| 11404 | 'Save both', 'Save lines from the display and command buffers to file', | ||
| 11405 | 'buttonSaveBoth_displayBuffer', | ||
| 11406 | ]; | ||
| 11407 | |||
| 11408 | # Prepare the data to be displayed (there is only one tab). Rather than sort the buffer | ||
| 11409 | # objects by number (which might take a while), check every number between | ||
| 11410 | # GA::Session->displayBufferFirst and ->displayBufferLast | ||
| 11411 | if (defined $self->session->displayBufferLast) { | ||
| 11412 | |||
| 11413 | for ( | ||
| 11414 | my $count = $self->session->displayBufferFirst; | ||
| 11415 | $count <= $self->session->displayBufferLast; | ||
| 11416 | $count++ | ||
| 11417 | ) { | ||
| 11418 | # There shouldn't be any missing buffer objects, but just in case... | ||
| 11419 | if (exists $self->session->{'displayBufferHash'}{$count}) { | ||
| 11420 | |||
| 11421 | push (@objList, $self->session->{'displayBufferHash'}{$count}); | ||
| 11422 | } | ||
| 11423 | } | ||
| 11424 | } | ||
| 11425 | |||
| 11426 | foreach my $bufferObj (@objList) { | ||
| 11427 | |||
| 11428 | my $listRef = [ | ||
| 11429 | $bufferObj->number, | ||
| 11430 | int ($bufferObj->time), | ||
| 11431 | $bufferObj->modLine, | ||
| 11432 | ]; | ||
| 11433 | push (@dataList, $listRef); | ||
| 11434 | } | ||
| 11435 | |||
| 11436 | $dataHash{'Display buffer'} = \@dataList; | ||
| 11437 | $dataHashRef = \%dataHash; | ||
| 11438 | |||
| 11439 | # (Do nothing when a line is double-clicked) | ||
| 11440 | |||
| 11441 | # Display all of this in the notebook | ||
| 11442 | return $self->refreshNotebook( | ||
| 11443 | $tabListRef, | ||
| 11444 | $columnListRef, | ||
| 11445 | $dataHashRef, | ||
| 11446 | $buttonListRef, | ||
| 11447 | TRUE, # Scroll to bottom | ||
| 11448 | ); | ||
| 11449 | } | ||
| 11450 | |||
| 11451 | sub instructBufferHeader { | ||
| 11452 | |||
| 11453 | # Called by ->treeViewChanged when the user clicks on the 'Instruction buffer' header in the | ||
| 11454 | # treeview | ||
| 11455 | # | ||
| 11456 | # Expected arguments | ||
| 11457 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 11458 | # | ||
| 11459 | # Return values | ||
| 11460 | # 'undef' on improper arguments | ||
| 11461 | # 1 otherwise | ||
| 11462 | |||
| 11463 | my ($self, $item, $check) = @_; | ||
| 11464 | |||
| 11465 | # Local variables | ||
| 11466 | my ( | ||
| 11467 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 11468 | @objList, @dataList, | ||
| 11469 | %dataHash, | ||
| 11470 | ); | ||
| 11471 | |||
| 11472 | # Check for improper arguments | ||
| 11473 | if (! defined $item || defined $check) { | ||
| 11474 | |||
| 11475 | return $axmud::CLIENT->writeImproper($self->_objClass . '->instructBufferHeader', @_); | ||
| 11476 | } | ||
| 11477 | |||
| 11478 | # Prepare the list of tabs | ||
| 11479 | $tabListRef = [ | ||
| 11480 | 'Instruction buffer' => '_Instruction buffer', | ||
| 11481 | ]; | ||
| 11482 | |||
| 11483 | # Prepare the list of column headings | ||
| 11484 | $columnListRef = [ | ||
| 11485 | 'Line' => 'int', | ||
| 11486 | 'Type' => 'text', | ||
| 11487 | 'Time' => 'int', | ||
| 11488 | 'Instruction' => 'text', | ||
| 11489 | ]; | ||
| 11490 | |||
| 11491 | # Prepare the list of buttons | ||
| 11492 | $buttonListRef = [ | ||
| 11493 | 'Dump 20', 'Display the most recent 20 instructions in the \'main\' window', | ||
| 11494 | 'buttonDump20_instructBuffer', | ||
| 11495 | 'Dump all', 'Display all instructions in the \'main\' window', | ||
| 11496 | 'buttonDumpAll_instructBuffer', | ||
| 11497 | 'Status', 'Display the instruction buffer\'s status in the \'main\' window', | ||
| 11498 | 'buttonStatus_instructBuffer', | ||
| 11499 | 'View line', 'View the selected line in an \'edit\' window', | ||
| 11500 | 'buttonView_instructBuffer', | ||
| 11501 | ]; | ||
| 11502 | |||
| 11503 | # Prepare the data to be displayed (there is only one tab). Rather than sort the buffer | ||
| 11504 | # objects by number (which might take a while), check every number between | ||
| 11505 | # GA::Session->instructBufferFirst and ->instructBufferLast | ||
| 11506 | if ($self->session->instructBufferCount) { | ||
| 11507 | |||
| 11508 | for ( | ||
| 11509 | my $count = $self->session->instructBufferFirst; | ||
| 11510 | $count <= $self->session->instructBufferLast; | ||
| 11511 | $count++ | ||
| 11512 | ) { | ||
| 11513 | # There shouldn't be any missing buffer objects, but just in case... | ||
| 11514 | if (exists $self->session->{'instructBufferHash'}{$count}) { | ||
| 11515 | |||
| 11516 | push (@objList, $self->session->{'instructBufferHash'}{$count}); | ||
| 11517 | } | ||
| 11518 | } | ||
| 11519 | } | ||
| 11520 | |||
| 11521 | foreach my $bufferObj (@objList) { | ||
| 11522 | |||
| 11523 | my ($listRef, $time); | ||
| 11524 | |||
| 11525 | # During the session's setup, client commands (notably ';setguild', ';setrace', | ||
| 11526 | # ';setchar') might be executed before GA::Session->sessionTime has been initialised | ||
| 11527 | $time = $bufferObj->time; | ||
| 11528 | if (! defined $time) { | ||
| 11529 | |||
| 11530 | $time = 0; | ||
| 11531 | } | ||
| 11532 | |||
| 11533 | $listRef = [ | ||
| 11534 | $bufferObj->number, | ||
| 11535 | $bufferObj->type, | ||
| 11536 | int ($time), | ||
| 11537 | $bufferObj->instruct, | ||
| 11538 | ]; | ||
| 11539 | |||
| 11540 | push (@dataList, $listRef); | ||
| 11541 | } | ||
| 11542 | |||
| 11543 | $dataHash{'Instruction buffer'} = \@dataList; | ||
| 11544 | $dataHashRef = \%dataHash; | ||
| 11545 | |||
| 11546 | # (Do nothing when a line is double-clicked) | ||
| 11547 | |||
| 11548 | # Display all of this in the notebook | ||
| 11549 | return $self->refreshNotebook( | ||
| 11550 | $tabListRef, | ||
| 11551 | $columnListRef, | ||
| 11552 | $dataHashRef, | ||
| 11553 | $buttonListRef, | ||
| 11554 | TRUE, # Scroll to bottom | ||
| 11555 | ); | ||
| 11556 | } | ||
| 11557 | |||
| 11558 | sub cmdBufferHeader { | ||
| 11559 | |||
| 11560 | # Called by ->treeViewChanged when the user clicks on the 'Command buffer' header in the | ||
| 11561 | # treeview | ||
| 11562 | # | ||
| 11563 | # Expected arguments | ||
| 11564 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 11565 | # | ||
| 11566 | # Return values | ||
| 11567 | # 'undef' on improper arguments | ||
| 11568 | # 1 otherwise | ||
| 11569 | |||
| 11570 | my ($self, $item, $check) = @_; | ||
| 11571 | |||
| 11572 | # Local variables | ||
| 11573 | my ( | ||
| 11574 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 11575 | @objList, @dataList, | ||
| 11576 | %dataHash, | ||
| 11577 | ); | ||
| 11578 | |||
| 11579 | # Check for improper arguments | ||
| 11580 | if (! defined $item || defined $check) { | ||
| 11581 | |||
| 11582 | return $axmud::CLIENT->writeImproper($self->_objClass . '->cmdBufferHeader', @_); | ||
| 11583 | } | ||
| 11584 | |||
| 11585 | # Prepare the list of tabs | ||
| 11586 | $tabListRef = [ | ||
| 11587 | 'Command buffer' => '_Command buffer', | ||
| 11588 | ]; | ||
| 11589 | |||
| 11590 | # Prepare the list of column headings | ||
| 11591 | $columnListRef = [ | ||
| 11592 | 'Line' => 'int', | ||
| 11593 | 'Time' => 'int', | ||
| 11594 | 'Command' => 'text', | ||
| 11595 | ]; | ||
| 11596 | |||
| 11597 | # Prepare the list of buttons | ||
| 11598 | $buttonListRef = [ | ||
| 11599 | 'Dump 20', 'Display the most recent 20 commands in the \'main\' window', | ||
| 11600 | 'buttonDump20_cmdBuffer', | ||
| 11601 | 'Dump all', 'Display all commands in the \'main\' window', 'buttonDumpAll_cmdBuffer', | ||
| 11602 | 'Status', 'Display the command buffer\'s status in the \'main\' window', | ||
| 11603 | 'buttonStatus_cmdBuffer', | ||
| 11604 | 'View line', 'View the selected line in an \'edit\' window', 'buttonView_cmdBuffer', | ||
| 11605 | 'Save buffer', 'Save lines from the command buffer to file', 'buttonSave_cmdBuffer', | ||
| 11606 | 'Save both', 'Save lines from the text and command buffers to file', | ||
| 11607 | 'buttonSaveBoth_displayBuffer', | ||
| 11608 | ]; | ||
| 11609 | |||
| 11610 | # Prepare the data to be displayed (there is only one tab). Rather than sort the buffer | ||
| 11611 | # objects by number (which might take a while), check every number between | ||
| 11612 | # GA::Session->cmdBufferFirst and ->cmdBufferLast | ||
| 11613 | if ($self->session->cmdBufferCount) { | ||
| 11614 | |||
| 11615 | for ( | ||
| 11616 | my $count = $self->session->cmdBufferFirst; | ||
| 11617 | $count <= $self->session->cmdBufferLast; | ||
| 11618 | $count++ | ||
| 11619 | ) { | ||
| 11620 | # There shouldn't be any missing buffer objects, but just in case... | ||
| 11621 | if (exists $self->session->{'cmdBufferHash'}{$count}) { | ||
| 11622 | |||
| 11623 | push (@objList, $self->session->{'cmdBufferHash'}{$count}); | ||
| 11624 | } | ||
| 11625 | } | ||
| 11626 | } | ||
| 11627 | |||
| 11628 | foreach my $bufferObj (@objList) { | ||
| 11629 | |||
| 11630 | my $listRef = [ | ||
| 11631 | $bufferObj->number, | ||
| 11632 | int ($bufferObj->time), | ||
| 11633 | $bufferObj->cmd, | ||
| 11634 | ]; | ||
| 11635 | push (@dataList, $listRef); | ||
| 11636 | } | ||
| 11637 | |||
| 11638 | $dataHash{'Command buffer'} = \@dataList; | ||
| 11639 | $dataHashRef = \%dataHash; | ||
| 11640 | |||
| 11641 | # (Do nothing when a line is double-clicked) | ||
| 11642 | |||
| 11643 | # Display all of this in the notebook | ||
| 11644 | return $self->refreshNotebook( | ||
| 11645 | $tabListRef, | ||
| 11646 | $columnListRef, | ||
| 11647 | $dataHashRef, | ||
| 11648 | $buttonListRef, | ||
| 11649 | TRUE, # Scroll to bottom | ||
| 11650 | ); | ||
| 11651 | } | ||
| 11652 | |||
| 11653 | # Treeview header responses - other objects | ||
| 11654 | |||
| 11655 | sub chatContactHeader { | ||
| 11656 | |||
| 11657 | # Called by ->treeViewChanged when the user clicks on the 'Chat contacts' header in the | ||
| 11658 | # treeview | ||
| 11659 | # | ||
| 11660 | # Expected arguments | ||
| 11661 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 11662 | # | ||
| 11663 | # Return values | ||
| 11664 | # 'undef' on improper arguments | ||
| 11665 | # 1 otherwise | ||
| 11666 | |||
| 11667 | my ($self, $item, $check) = @_; | ||
| 11668 | |||
| 11669 | # Local variables | ||
| 11670 | my ( | ||
| 11671 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 11672 | @list, @dataList, | ||
| 11673 | %dataHash, | ||
| 11674 | ); | ||
| 11675 | |||
| 11676 | # Check for improper arguments | ||
| 11677 | if (! defined $item || defined $check) { | ||
| 11678 | |||
| 11679 | return $axmud::CLIENT->writeImproper($self->_objClass . '->chatContactHeader', @_); | ||
| 11680 | } | ||
| 11681 | |||
| 11682 | # Prepare the list of tabs | ||
| 11683 | $tabListRef = [ | ||
| 11684 | 'Chat contact' => '_Chat contact', | ||
| 11685 | ]; | ||
| 11686 | |||
| 11687 | # Prepare the list of column headings | ||
| 11688 | $columnListRef = [ | ||
| 11689 | 'Name' => 'text', | ||
| 11690 | ]; | ||
| 11691 | |||
| 11692 | # Prepare the list of buttons | ||
| 11693 | $buttonListRef = [ | ||
| 11694 | 'Add', 'Add a new chat contact', 'buttonAdd_chatContact', | ||
| 11695 | 'Edit', 'Edit the selected chat contact', 'buttonEdit_chatContact', | ||
| 11696 | 'Delete', 'Delete the selected chat contact', 'buttonDelete_chatContact', | ||
| 11697 | 'Dump', 'Display a list of chat contacts in the \'main\' window', | ||
| 11698 | 'buttonDump_chatContact', | ||
| 11699 | ]; | ||
| 11700 | |||
| 11701 | # Prepare the data to be displayed (there is only one tab) | ||
| 11702 | @list = sort {lc($a->name) cmp lc($b->name)} ($axmud::CLIENT->ivValues('chatContactHash')); | ||
| 11703 | OUTER: foreach my $obj (@list) { | ||
| 11704 | |||
| 11705 | push (@dataList, [$obj->name]); | ||
| 11706 | } | ||
| 11707 | |||
| 11708 | $dataHash{'Chat contact'} = \@dataList; | ||
| 11709 | $dataHashRef = \%dataHash; | ||
| 11710 | |||
| 11711 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 11712 | # equivalent to the edit button | ||
| 11713 | $self->ivPoke('notebookSelectRef', sub { | ||
| 11714 | |||
| 11715 | $self->buttonEdit_chatContact(); | ||
| 11716 | }); | ||
| 11717 | |||
| 11718 | # Display all of this in the notebook | ||
| 11719 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 11720 | } | ||
| 11721 | |||
| 11722 | sub colourSchemeHeader { | ||
| 11723 | |||
| 11724 | # Called by ->treeViewChanged when the user clicks on the 'Colour schemes' header in the | ||
| 11725 | # treeview | ||
| 11726 | # | ||
| 11727 | # Expected arguments | ||
| 11728 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 11729 | # | ||
| 11730 | # Return values | ||
| 11731 | # 'undef' on improper arguments | ||
| 11732 | # 1 otherwise | ||
| 11733 | |||
| 11734 | my ($self, $item, $check) = @_; | ||
| 11735 | |||
| 11736 | # Local variables | ||
| 11737 | my ( | ||
| 11738 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 11739 | @list, @dataList, | ||
| 11740 | %dataHash, | ||
| 11741 | ); | ||
| 11742 | |||
| 11743 | # Check for improper arguments | ||
| 11744 | if (! defined $item || defined $check) { | ||
| 11745 | |||
| 11746 | return $axmud::CLIENT->writeImproper($self->_objClass . '->colourSchemeHeader', @_); | ||
| 11747 | } | ||
| 11748 | |||
| 11749 | # Prepare the list of tabs | ||
| 11750 | $tabListRef = [ | ||
| 11751 | 'Colour scheme' => '_Colour scheme', | ||
| 11752 | ]; | ||
| 11753 | |||
| 11754 | # Prepare the list of column headings | ||
| 11755 | $columnListRef = [ | ||
| 11756 | 'Standard' => 'bool', | ||
| 11757 | 'Name' => 'text', | ||
| 11758 | ]; | ||
| 11759 | |||
| 11760 | # Prepare the list of buttons | ||
| 11761 | $buttonListRef = [ | ||
| 11762 | 'Add', 'Add a new colour scheme object', 'buttonAdd_colourScheme', | ||
| 11763 | 'Edit', 'Edit the selected colour scheme object', 'buttonEdit_colourScheme', | ||
| 11764 | 'Delete', 'Delete the selected colour scheme object', 'buttonDelete_colourScheme', | ||
| 11765 | 'Dump', 'Display a list of colour scheme objects in the \'main\' window', | ||
| 11766 | 'buttonDump_colourScheme', | ||
| 11767 | ]; | ||
| 11768 | |||
| 11769 | # Prepare the data to be displayed (there is only one tab) | ||
| 11770 | @list = sort {lc($a->name) cmp lc($b->name)} ($axmud::CLIENT->ivValues('colourSchemeHash')); | ||
| 11771 | OUTER: foreach my $obj (@list) { | ||
| 11772 | |||
| 11773 | my ($flag, $listRef); | ||
| 11774 | |||
| 11775 | if ( | ||
| 11776 | $axmud::CLIENT->ivExists('constGridWinTypeHash', $obj->name) | ||
| 11777 | || $axmud::CLIENT->ivExists('constFreeWinTypeHash', $obj->name) | ||
| 11778 | ) { | ||
| 11779 | $flag = TRUE; | ||
| 11780 | } else { | ||
| 11781 | $flag = FALSE; | ||
| 11782 | } | ||
| 11783 | |||
| 11784 | $listRef = [$flag, $obj->name]; | ||
| 11785 | push (@dataList, $listRef); | ||
| 11786 | } | ||
| 11787 | |||
| 11788 | $dataHash{'Colour scheme'} = \@dataList; | ||
| 11789 | $dataHashRef = \%dataHash; | ||
| 11790 | |||
| 11791 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 11792 | # equivalent to the edit button | ||
| 11793 | $self->ivPoke('notebookSelectRef', sub { | ||
| 11794 | |||
| 11795 | $self->buttonEdit_colourScheme(); | ||
| 11796 | }); | ||
| 11797 | |||
| 11798 | # Display all of this in the notebook | ||
| 11799 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 11800 | } | ||
| 11801 | |||
| 11802 | sub mapLabelStyleHeader { | ||
| 11803 | |||
| 11804 | # Called by ->treeViewChanged when the user clicks on the 'Map label styles' header in the | ||
| 11805 | # treeview | ||
| 11806 | # | ||
| 11807 | # Expected arguments | ||
| 11808 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 11809 | # | ||
| 11810 | # Return values | ||
| 11811 | # 'undef' on improper arguments | ||
| 11812 | # 1 otherwise | ||
| 11813 | |||
| 11814 | my ($self, $item, $check) = @_; | ||
| 11815 | |||
| 11816 | # Local variables | ||
| 11817 | my ( | ||
| 11818 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 11819 | @list, @dataList, | ||
| 11820 | %dataHash, | ||
| 11821 | ); | ||
| 11822 | |||
| 11823 | # Check for improper arguments | ||
| 11824 | if (! defined $item || defined $check) { | ||
| 11825 | |||
| 11826 | return $axmud::CLIENT->writeImproper($self->_objClass . '->mapLabelStyleHeader', @_); | ||
| 11827 | } | ||
| 11828 | |||
| 11829 | # Prepare the list of tabs | ||
| 11830 | $tabListRef = [ | ||
| 11831 | 'Map label style' => '_Map label style', | ||
| 11832 | ]; | ||
| 11833 | |||
| 11834 | # Prepare the list of column headings | ||
| 11835 | $columnListRef = [ | ||
| 11836 | 'Default' => 'bool', | ||
| 11837 | 'Name' => 'text', | ||
| 11838 | ]; | ||
| 11839 | |||
| 11840 | # Prepare the list of buttons | ||
| 11841 | $buttonListRef = [ | ||
| 11842 | 'Add', 'Add a new map label style object', 'buttonAdd_mapLabelStyle', | ||
| 11843 | 'Edit', 'Edit the selected map label style object', 'buttonEdit_mapLabelStyle', | ||
| 11844 | 'Rename', 'Rename the selected map label style object', 'buttonRename_mapLabelStyle', | ||
| 11845 | 'Delete', 'Delete the selected map label style object', 'buttonDelete_mapLabelStyle', | ||
| 11846 | 'Dump', 'Display a list of map label style objects in the \'main\' window', | ||
| 11847 | 'buttonDump_mapLabelStyle', | ||
| 11848 | ]; | ||
| 11849 | |||
| 11850 | # Prepare the data to be displayed (there is only one tab) | ||
| 11851 | @list = sort {lc($a->name) cmp lc($b->name)} | ||
| 11852 | ($self->session->worldModelObj->ivValues('mapLabelStyleHash')); | ||
| 11853 | |||
| 11854 | OUTER: foreach my $obj (@list) { | ||
| 11855 | |||
| 11856 | my ($flag, $listRef); | ||
| 11857 | |||
| 11858 | if ($self->session->worldModelObj->mapLabelStyle eq $obj->name) { | ||
| 11859 | $flag = TRUE; | ||
| 11860 | } else { | ||
| 11861 | $flag = FALSE; | ||
| 11862 | } | ||
| 11863 | |||
| 11864 | $listRef = [$flag, $obj->name]; | ||
| 11865 | push (@dataList, $listRef); | ||
| 11866 | } | ||
| 11867 | |||
| 11868 | $dataHash{'Map label style'} = \@dataList; | ||
| 11869 | $dataHashRef = \%dataHash; | ||
| 11870 | |||
| 11871 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 11872 | # equivalent to the edit button | ||
| 11873 | $self->ivPoke('notebookSelectRef', sub { | ||
| 11874 | |||
| 11875 | $self->buttonEdit_mapLabelStyle(); | ||
| 11876 | }); | ||
| 11877 | |||
| 11878 | # Display all of this in the notebook | ||
| 11879 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 11880 | } | ||
| 11881 | |||
| 11882 | sub regionSchemeHeader { | ||
| 11883 | |||
| 11884 | # Called by ->treeViewChanged when the user clicks on the 'Region colour schemes' header in | ||
| 11885 | # the treeview | ||
| 11886 | # | ||
| 11887 | # Expected arguments | ||
| 11888 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 11889 | # | ||
| 11890 | # Return values | ||
| 11891 | # 'undef' on improper arguments | ||
| 11892 | # 1 otherwise | ||
| 11893 | |||
| 11894 | my ($self, $item, $check) = @_; | ||
| 11895 | |||
| 11896 | # Local variables | ||
| 11897 | my ( | ||
| 11898 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 11899 | @list, @dataList, | ||
| 11900 | %dataHash, | ||
| 11901 | ); | ||
| 11902 | |||
| 11903 | # Check for improper arguments | ||
| 11904 | if (! defined $item || defined $check) { | ||
| 11905 | |||
| 11906 | return $axmud::CLIENT->writeImproper($self->_objClass . '->regionSchemeHeader', @_); | ||
| 11907 | } | ||
| 11908 | |||
| 11909 | # Prepare the list of tabs | ||
| 11910 | $tabListRef = [ | ||
| 11911 | 'Region colour scheme' => '_Region colour scheme', | ||
| 11912 | ]; | ||
| 11913 | |||
| 11914 | # Prepare the list of column headings | ||
| 11915 | $columnListRef = [ | ||
| 11916 | 'Default' => 'bool', | ||
| 11917 | 'Name' => 'text', | ||
| 11918 | ]; | ||
| 11919 | |||
| 11920 | # Prepare the list of buttons | ||
| 11921 | $buttonListRef = [ | ||
| 11922 | 'Add', 'Add a new region colour scheme object', 'buttonAdd_regionScheme', | ||
| 11923 | 'Edit', 'Edit the selected region colour scheme object', 'buttonEdit_regionScheme', | ||
| 11924 | 'Rename', 'Rename the selected region colour scheme object', | ||
| 11925 | 'buttonRename_regionScheme', | ||
| 11926 | 'Delete', 'Delete the selected region colour scheme object', | ||
| 11927 | 'buttonDelete_regionScheme', | ||
| 11928 | 'Dump', 'Display a list of region colour scheme objects in the \'main\' window', | ||
| 11929 | 'buttonDump_regionScheme', | ||
| 11930 | ]; | ||
| 11931 | |||
| 11932 | # Prepare the data to be displayed (there is only one tab) | ||
| 11933 | @list = sort {lc($a->name) cmp lc($b->name)} | ||
| 11934 | ($self->session->worldModelObj->ivValues('regionSchemeHash')); | ||
| 11935 | |||
| 11936 | OUTER: foreach my $obj (@list) { | ||
| 11937 | |||
| 11938 | my ($flag, $listRef); | ||
| 11939 | |||
| 11940 | if ($obj->name eq 'default') { | ||
| 11941 | $flag = TRUE; | ||
| 11942 | } else { | ||
| 11943 | $flag = FALSE; | ||
| 11944 | } | ||
| 11945 | |||
| 11946 | $listRef = [$flag, $obj->name]; | ||
| 11947 | push (@dataList, $listRef); | ||
| 11948 | } | ||
| 11949 | |||
| 11950 | $dataHash{'Region colour scheme'} = \@dataList; | ||
| 11951 | $dataHashRef = \%dataHash; | ||
| 11952 | |||
| 11953 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 11954 | # equivalent to the edit button | ||
| 11955 | $self->ivPoke('notebookSelectRef', sub { | ||
| 11956 | |||
| 11957 | $self->buttonEdit_regionScheme(); | ||
| 11958 | }); | ||
| 11959 | |||
| 11960 | # Display all of this in the notebook | ||
| 11961 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 11962 | } | ||
| 11963 | |||
| 11964 | sub ttsHeader { | ||
| 11965 | |||
| 11966 | # Called by ->treeViewChanged when the user clicks on the 'TTS configurations' header in the | ||
| 11967 | # treeview | ||
| 11968 | # | ||
| 11969 | # Expected arguments | ||
| 11970 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 11971 | # | ||
| 11972 | # Return values | ||
| 11973 | # 'undef' on improper arguments | ||
| 11974 | # 1 otherwise | ||
| 11975 | |||
| 11976 | my ($self, $item, $check) = @_; | ||
| 11977 | |||
| 11978 | # Local variables | ||
| 11979 | my ( | ||
| 11980 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 11981 | @list, @dataList, | ||
| 11982 | %dataHash, | ||
| 11983 | ); | ||
| 11984 | |||
| 11985 | # Check for improper arguments | ||
| 11986 | if (! defined $item || defined $check) { | ||
| 11987 | |||
| 11988 | return $axmud::CLIENT->writeImproper($self->_objClass . '->ttsHeader', @_); | ||
| 11989 | } | ||
| 11990 | |||
| 11991 | # Prepare the list of tabs | ||
| 11992 | $tabListRef = [ | ||
| 11993 | 'TTS configuration' => '_TTS configuration', | ||
| 11994 | ]; | ||
| 11995 | |||
| 11996 | # Prepare the list of column headings | ||
| 11997 | $columnListRef = [ | ||
| 11998 | 'Name' => 'text', | ||
| 11999 | 'Engine' => 'text', | ||
| 12000 | 'Voice' => 'text', | ||
| 12001 | ]; | ||
| 12002 | |||
| 12003 | # Prepare the list of buttons | ||
| 12004 | $buttonListRef = [ | ||
| 12005 | 'Add', 'Add a new TTS configuration', 'buttonAdd_tts', | ||
| 12006 | 'Clone', 'Clone the selected TTS configuration', 'buttonClone_tts', | ||
| 12007 | 'Edit', 'Edit the selected TTS configuration', 'buttonEdit_tts', | ||
| 12008 | 'Delete', 'Delete the selected TTS configuration', 'buttonDelete_tts', | ||
| 12009 | 'Dump', 'Display a list of TTS configurations in the \'main\' window', 'buttonDump_tts', | ||
| 12010 | ]; | ||
| 12011 | |||
| 12012 | # Prepare the data to be displayed (there is only one tab) | ||
| 12013 | @list = sort {lc($a->name) cmp lc($b->name)} ($axmud::CLIENT->ivValues('ttsObjHash')); | ||
| 12014 | OUTER: foreach my $obj (@list) { | ||
| 12015 | |||
| 12016 | my $listRef = [$obj->name, $obj->engine, $obj->voice]; | ||
| 12017 | push (@dataList, $listRef); | ||
| 12018 | } | ||
| 12019 | |||
| 12020 | $dataHash{'TTS configuration'} = \@dataList; | ||
| 12021 | $dataHashRef = \%dataHash; | ||
| 12022 | |||
| 12023 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 12024 | # equivalent to the edit button | ||
| 12025 | $self->ivPoke('notebookSelectRef', sub { | ||
| 12026 | |||
| 12027 | $self->buttonEdit_tts(); | ||
| 12028 | }); | ||
| 12029 | |||
| 12030 | # Display all of this in the notebook | ||
| 12031 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 12032 | } | ||
| 12033 | |||
| 12034 | sub winmapHeader { | ||
| 12035 | |||
| 12036 | # Called by ->treeViewChanged when the user clicks on the 'Winmaps' header in the treeview | ||
| 12037 | # | ||
| 12038 | # Expected arguments | ||
| 12039 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 12040 | # | ||
| 12041 | # Return values | ||
| 12042 | # 'undef' on improper arguments | ||
| 12043 | # 1 otherwise | ||
| 12044 | |||
| 12045 | my ($self, $item, $check) = @_; | ||
| 12046 | |||
| 12047 | # Local variables | ||
| 12048 | my ( | ||
| 12049 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 12050 | @list, @dataList, | ||
| 12051 | %dataHash, | ||
| 12052 | ); | ||
| 12053 | |||
| 12054 | # Check for improper arguments | ||
| 12055 | if (! defined $item || defined $check) { | ||
| 12056 | |||
| 12057 | return $axmud::CLIENT->writeImproper($self->_objClass . '->winmapHeader', @_); | ||
| 12058 | } | ||
| 12059 | |||
| 12060 | # Prepare the list of tabs | ||
| 12061 | $tabListRef = [ | ||
| 12062 | 'Winmap' => '_Winmap', | ||
| 12063 | ]; | ||
| 12064 | |||
| 12065 | # Prepare the list of column headings | ||
| 12066 | $columnListRef = [ | ||
| 12067 | 'Standard' => 'bool', | ||
| 12068 | 'Full' => 'bool', | ||
| 12069 | 'Name' => 'text', | ||
| 12070 | ]; | ||
| 12071 | |||
| 12072 | # Prepare the list of buttons | ||
| 12073 | $buttonListRef = [ | ||
| 12074 | 'Add', 'Add a new winmap', 'buttonAdd_winmap', | ||
| 12075 | 'Clone', 'Clone the selected winmap', 'buttonClone_winmap', | ||
| 12076 | 'Edit', 'Edit the selected winmap', 'buttonEdit_winmap', | ||
| 12077 | 'Delete', 'Delete the selected winmap', 'buttonDelete_winmap', | ||
| 12078 | 'Dump', 'Display a list of winmaps in the \'main\' window', 'buttonDump_winmap', | ||
| 12079 | ]; | ||
| 12080 | |||
| 12081 | # Prepare the data to be displayed (there is only one tab) | ||
| 12082 | @list = sort {lc($a->name) cmp lc($b->name)} ($axmud::CLIENT->ivValues('winmapHash')); | ||
| 12083 | OUTER: foreach my $obj (@list) { | ||
| 12084 | |||
| 12085 | my ($flag, $listRef); | ||
| 12086 | |||
| 12087 | if ($axmud::CLIENT->ivExists('standardWinmapHash', $obj->name)) { | ||
| 12088 | $flag = TRUE; | ||
| 12089 | } else { | ||
| 12090 | $flag = FALSE; | ||
| 12091 | } | ||
| 12092 | |||
| 12093 | $listRef = [$flag, $obj->fullFlag, $obj->name]; | ||
| 12094 | push (@dataList, $listRef); | ||
| 12095 | } | ||
| 12096 | |||
| 12097 | $dataHash{'Winmap'} = \@dataList; | ||
| 12098 | $dataHashRef = \%dataHash; | ||
| 12099 | |||
| 12100 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 12101 | # equivalent to the edit button | ||
| 12102 | $self->ivPoke('notebookSelectRef', sub { | ||
| 12103 | |||
| 12104 | $self->buttonEdit_winmap(); | ||
| 12105 | }); | ||
| 12106 | |||
| 12107 | # Display all of this in the notebook | ||
| 12108 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 12109 | } | ||
| 12110 | |||
| 12111 | sub zonemapHeader { | ||
| 12112 | |||
| 12113 | # Called by ->treeViewChanged when the user clicks on the 'Zonemaps' header in the treeview | ||
| 12114 | # | ||
| 12115 | # Expected arguments | ||
| 12116 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 12117 | # | ||
| 12118 | # Return values | ||
| 12119 | # 'undef' on improper arguments | ||
| 12120 | # 1 otherwise | ||
| 12121 | |||
| 12122 | my ($self, $item, $check) = @_; | ||
| 12123 | |||
| 12124 | # Local variables | ||
| 12125 | my ( | ||
| 12126 | $tabListRef, $columnListRef, $dataHashRef, $buttonListRef, | ||
| 12127 | @list, @dataList, | ||
| 12128 | %dataHash, | ||
| 12129 | ); | ||
| 12130 | |||
| 12131 | # Check for improper arguments | ||
| 12132 | if (! defined $item || defined $check) { | ||
| 12133 | |||
| 12134 | return $axmud::CLIENT->writeImproper($self->_objClass . '->zonemapHeader', @_); | ||
| 12135 | } | ||
| 12136 | |||
| 12137 | # Prepare the list of tabs | ||
| 12138 | $tabListRef = [ | ||
| 12139 | 'Zonemap' => '_Zonemap', | ||
| 12140 | ]; | ||
| 12141 | |||
| 12142 | # Prepare the list of column headings | ||
| 12143 | $columnListRef = [ | ||
| 12144 | 'Standard' => 'bool', | ||
| 12145 | 'Full' => 'bool', | ||
| 12146 | 'Temporary' => 'bool', | ||
| 12147 | 'Name' => 'text', | ||
| 12148 | ]; | ||
| 12149 | |||
| 12150 | # Prepare the list of buttons | ||
| 12151 | $buttonListRef = [ | ||
| 12152 | 'Add', 'Add a new zonemap', 'buttonAdd_zonemap', | ||
| 12153 | 'Clone', 'Clone the selected zonemap', 'buttonClone_zonemap', | ||
| 12154 | 'Edit', 'Edit the selected zonemap', 'buttonEdit_zonemap', | ||
| 12155 | 'Delete', 'Delete the selected zonemap', 'buttonDelete_zonemap', | ||
| 12156 | 'Dump', 'Display a list of zonemaps in the \'main\' window', 'buttonDump_zonemap', | ||
| 12157 | ]; | ||
| 12158 | |||
| 12159 | # Prepare the data to be displayed (there is only one tab) | ||
| 12160 | @list = sort {lc($a->name) cmp lc($b->name)} ($axmud::CLIENT->ivValues('zonemapHash')); | ||
| 12161 | OUTER: foreach my $obj (@list) { | ||
| 12162 | |||
| 12163 | my ($flag, $listRef); | ||
| 12164 | |||
| 12165 | if ($axmud::CLIENT->ivExists('standardZonemapHash', $obj->name)) { | ||
| 12166 | $flag = TRUE; | ||
| 12167 | } else { | ||
| 12168 | $flag = FALSE; | ||
| 12169 | } | ||
| 12170 | |||
| 12171 | $listRef = [$flag, $obj->fullFlag, $obj->tempFlag, $obj->name]; | ||
| 12172 | push (@dataList, $listRef); | ||
| 12173 | } | ||
| 12174 | |||
| 12175 | $dataHash{'Zonemap'} = \@dataList; | ||
| 12176 | $dataHashRef = \%dataHash; | ||
| 12177 | |||
| 12178 | # Which function to call if the user double-clicks on a row in the list - in this case, it's | ||
| 12179 | # equivalent to the edit button | ||
| 12180 | $self->ivPoke('notebookSelectRef', sub { | ||
| 12181 | |||
| 12182 | $self->buttonEdit_zonemap(); | ||
| 12183 | }); | ||
| 12184 | |||
| 12185 | # Display all of this in the notebook | ||
| 12186 | return $self->refreshNotebook($tabListRef, $columnListRef, $dataHashRef, $buttonListRef); | ||
| 12187 | } | ||
| 12188 | |||
| 12189 | # Treeview header responses - help | ||
| 12190 | |||
| 12191 | sub quickHelpHeader { | ||
| 12192 | |||
| 12193 | # Called by ->treeViewChanged when the user clicks on one of the quick help item in the | ||
| 12194 | # treeview | ||
| 12195 | # | ||
| 12196 | # Expected arguments | ||
| 12197 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 12198 | # | ||
| 12199 | # Return values | ||
| 12200 | # 'undef' on improper arguments | ||
| 12201 | # 1 otherwise | ||
| 12202 | |||
| 12203 | my ($self, $item, $check) = @_; | ||
| 12204 | |||
| 12205 | # Local variables | ||
| 12206 | my ( | ||
| 12207 | $file, $fileHandle, | ||
| 12208 | @list, | ||
| 12209 | ); | ||
| 12210 | |||
| 12211 | # Check for improper arguments | ||
| 12212 | if (! defined $item || defined $check) { | ||
| 12213 | |||
| 12214 | return $axmud::CLIENT->writeImproper($self->_objClass . '->quickHelpHeader', @_); | ||
| 12215 | } | ||
| 12216 | |||
| 12217 | # Load the quick help file | ||
| 12218 | $file = $axmud::SHARE_DIR . '/help/misc/quickhelp'; | ||
| 12219 | if (-e $file && open($fileHandle, $file)) { | ||
| 12220 | |||
| 12221 | @list = <$fileHandle>; | ||
| 12222 | close($fileHandle); | ||
| 12223 | |||
| 12224 | foreach my $item (@list) { | ||
| 12225 | |||
| 12226 | chomp $item; | ||
| 12227 | } | ||
| 12228 | } | ||
| 12229 | |||
| 12230 | # Display the help in the notebook | ||
| 12231 | return $self->refreshTextView($item, @list); | ||
| 12232 | } | ||
| 12233 | |||
| 12234 | sub peekPokeHelpHeader { | ||
| 12235 | |||
| 12236 | # Called by ->treeViewChanged when the user clicks on one of the peek/poke help item in the | ||
| 12237 | # treeview | ||
| 12238 | # | ||
| 12239 | # Expected arguments | ||
| 12240 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 12241 | # | ||
| 12242 | # Return values | ||
| 12243 | # 'undef' on improper arguments | ||
| 12244 | # 1 otherwise | ||
| 12245 | |||
| 12246 | my ($self, $item, $check) = @_; | ||
| 12247 | |||
| 12248 | # Local variables | ||
| 12249 | my ( | ||
| 12250 | $file, $fileHandle, | ||
| 12251 | @list, | ||
| 12252 | ); | ||
| 12253 | |||
| 12254 | # Check for improper arguments | ||
| 12255 | if (! defined $item || defined $check) { | ||
| 12256 | |||
| 12257 | return $axmud::CLIENT->writeImproper($self->_objClass . '->peekPokeHelpHeader', @_); | ||
| 12258 | } | ||
| 12259 | |||
| 12260 | # Load the quick help file | ||
| 12261 | $file = $axmud::SHARE_DIR . '/help/misc/peekpoke'; | ||
| 12262 | if (-e $file && open($fileHandle, $file)) { | ||
| 12263 | |||
| 12264 | @list = <$fileHandle>; | ||
| 12265 | close($fileHandle); | ||
| 12266 | |||
| 12267 | foreach my $item (@list) { | ||
| 12268 | |||
| 12269 | chomp $item; | ||
| 12270 | } | ||
| 12271 | } | ||
| 12272 | |||
| 12273 | # Display the help in the notebook | ||
| 12274 | return $self->refreshTextView($item, @list); | ||
| 12275 | } | ||
| 12276 | |||
| 12277 | sub cmdHeader { | ||
| 12278 | |||
| 12279 | # Called by ->treeViewChanged when the user clicks on one of the client commands in the | ||
| 12280 | # treeview | ||
| 12281 | # | ||
| 12282 | # Expected arguments | ||
| 12283 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 12284 | # | ||
| 12285 | # Return values | ||
| 12286 | # 'undef' on improper arguments | ||
| 12287 | # 1 otherwise | ||
| 12288 | |||
| 12289 | my ($self, $item, $check) = @_; | ||
| 12290 | |||
| 12291 | # Local variables | ||
| 12292 | my ( | ||
| 12293 | $cmd, $obj, | ||
| 12294 | @list, | ||
| 12295 | ); | ||
| 12296 | |||
| 12297 | # Check for improper arguments | ||
| 12298 | if (! defined $item || defined $check) { | ||
| 12299 | |||
| 12300 | return $axmud::CLIENT->writeImproper($self->_objClass . '->cmdHeader', @_); | ||
| 12301 | } | ||
| 12302 | |||
| 12303 | # Remove the command sigil from the beginning of $item | ||
| 12304 | $cmd = substr($item, length($axmud::CLIENT->cmdSep)); | ||
| 12305 | # Get the blessed reference of the command object for this command | ||
| 12306 | $obj = $axmud::CLIENT->ivShow('clientCmdHash', $cmd); | ||
| 12307 | |||
| 12308 | # Get the first three lines of the help text | ||
| 12309 | push (@list, $obj->getHelpStart()); | ||
| 12310 | # Call the help function for the command to fetch the command-specific text | ||
| 12311 | push (@list, $obj->help($self->session)); | ||
| 12312 | # Fetch the final three lines of the help text; add an extra blank line | ||
| 12313 | push (@list, $obj->getHelpEnd(), ' '); | ||
| 12314 | |||
| 12315 | # (Do nothing when a line is double-clicked) | ||
| 12316 | |||
| 12317 | # Display the help in the notebook | ||
| 12318 | return $self->refreshTextView($item, @list); | ||
| 12319 | } | ||
| 12320 | |||
| 12321 | sub axbasicKeywordHeader { | ||
| 12322 | |||
| 12323 | # Called by ->treeViewChanged when the user clicks on one of the Axbasic keyword help topics | ||
| 12324 | # in the treeview | ||
| 12325 | # | ||
| 12326 | # Expected arguments | ||
| 12327 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 12328 | # | ||
| 12329 | # Return values | ||
| 12330 | # 'undef' on improper arguments | ||
| 12331 | # 1 otherwise | ||
| 12332 | |||
| 12333 | my ($self, $item, $check) = @_; | ||
| 12334 | |||
| 12335 | # Local variables | ||
| 12336 | my ( | ||
| 12337 | $obj, | ||
| 12338 | @list, | ||
| 12339 | ); | ||
| 12340 | |||
| 12341 | # Check for improper arguments | ||
| 12342 | if (! defined $item || defined $check) { | ||
| 12343 | |||
| 12344 | return $axmud::CLIENT->writeImproper($self->_objClass . '->axbasicKeywordHeader', @_); | ||
| 12345 | } | ||
| 12346 | |||
| 12347 | # Get the ';axbasichelp' command object (rather than going through GA::Generic::Cmd) | ||
| 12348 | $obj = $axmud::CLIENT->ivShow('clientCmdHash', 'axbasichelp'); | ||
| 12349 | # If $item is a weak keyword, then we use the help file for the equivalent strong keyword | ||
| 12350 | # (e.g. use help for OPEN rather than ACCESS) | ||
| 12351 | if ($self->dummyScriptObj->ivExists('weakKeywordHash', $item)) { | ||
| 12352 | |||
| 12353 | $item = $self->dummyScriptObj->ivShow('weakKeywordHash', $item); | ||
| 12354 | } | ||
| 12355 | |||
| 12356 | # Get the help for the keyword $item | ||
| 12357 | @list = $obj->abHelp($self->session, $item, 'keyword'); | ||
| 12358 | |||
| 12359 | # (Do nothing when a line is double-clicked) | ||
| 12360 | |||
| 12361 | # Display the help in the notebook | ||
| 12362 | return $self->refreshTextView($item, @list); | ||
| 12363 | } | ||
| 12364 | |||
| 12365 | sub axbasicFuncHeader { | ||
| 12366 | |||
| 12367 | # Called by ->treeViewChanged when the user clicks on one of the Axbasic intrinsic function | ||
| 12368 | # help topics in the treeview | ||
| 12369 | # | ||
| 12370 | # Expected arguments | ||
| 12371 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 12372 | # | ||
| 12373 | # Return values | ||
| 12374 | # 'undef' on improper arguments | ||
| 12375 | # 1 otherwise | ||
| 12376 | |||
| 12377 | my ($self, $item, $check) = @_; | ||
| 12378 | |||
| 12379 | # Local variables | ||
| 12380 | my ( | ||
| 12381 | $obj, | ||
| 12382 | @list, | ||
| 12383 | ); | ||
| 12384 | |||
| 12385 | # Check for improper arguments | ||
| 12386 | if (! defined $item || defined $check) { | ||
| 12387 | |||
| 12388 | return $axmud::CLIENT->writeImproper($self->_objClass . '->axbasicFuncHeader', @_); | ||
| 12389 | } | ||
| 12390 | |||
| 12391 | # Get the ';axbasichelp' command object (rather than going through GA::Generic::Cmd) | ||
| 12392 | $obj = $axmud::CLIENT->ivShow('clientCmdHash', 'axbasichelp'); | ||
| 12393 | # Get the help for the keyword $item | ||
| 12394 | @list = $obj->abHelp($self->session, $item, 'func'); | ||
| 12395 | |||
| 12396 | # (Do nothing when a line is double-clicked) | ||
| 12397 | |||
| 12398 | # Display the help in the notebook | ||
| 12399 | return $self->refreshTextView($item, @list); | ||
| 12400 | } | ||
| 12401 | |||
| 12402 | sub taskHeader { | ||
| 12403 | |||
| 12404 | # Called by ->treeViewChanged when the user clicks on one of the tasks in the treeview | ||
| 12405 | # | ||
| 12406 | # Expected arguments | ||
| 12407 | # $item - The treeview item that was clicked (i.e. the text it contains) | ||
| 12408 | # | ||
| 12409 | # Return values | ||
| 12410 | # 'undef' on improper arguments | ||
| 12411 | # 1 otherwise | ||
| 12412 | |||
| 12413 | my ($self, $item, $check) = @_; | ||
| 12414 | |||
| 12415 | # Local variables | ||
| 12416 | my ( | ||
| 12417 | $cmdObj, $packageName, | ||
| 12418 | @list, | ||
| 12419 | ); | ||
| 12420 | |||
| 12421 | # Check for improper arguments | ||
| 12422 | if (! defined $item || defined $check) { | ||
| 12423 | |||
| 12424 | return $axmud::CLIENT->writeImproper($self->_objClass . '->taskHeader', @_); | ||
| 12425 | } | ||
| 12426 | |||
| 12427 | # Get the ';taskhelp' command object (rather than going through GA::Generic::Cmd) | ||
| 12428 | $cmdObj = $axmud::CLIENT->ivShow('clientCmdHash', 'taskhelp'); | ||
| 12429 | |||
| 12430 | # Get the package name for the task | ||
| 12431 | $packageName = $cmdObj->findTaskPackageName($self->session, $item); | ||
| 12432 | # Remove the 'Games::Axmud::Task::' bit... | ||
| 12433 | $packageName =~ s/^Games\:\:Axmud\:\:Task\:\://; | ||
| 12434 | # Get the help for the task | ||
| 12435 | @list = $cmdObj->taskHelp($self->session, $packageName); | ||
| 12436 | |||
| 12437 | # (Do nothing when a line is double-clicked) | ||
| 12438 | |||
| 12439 | # Display the help in the notebook | ||
| 12440 | return $self->refreshTextView($packageName, @list); | ||
| 12441 | } | ||
| 12442 | |||
| 12443 | # Header support functions | ||
| 12444 | |||
| 12445 | sub setTabList_prof { | ||
| 12446 | |||
| 12447 | # Called by $self->allProfHeader and ->currentProfHeader | ||
| 12448 | # Sets up the list of tabs appropriate for displaying profiles in the notebook list, in the | ||
| 12449 | # form | ||
| 12450 | # [ | ||
| 12451 | # 'tab_name' => 'tab_mnemonic', | ||
| 12452 | # 'tab_name' => 'tab_mnemonic', | ||
| 12453 | # 'tab_name' => 'tab_mnemonic', | ||
| 12454 | # ... | ||
| 12455 | # ] | ||
| 12456 | # | ||
| 12457 | # Expected arguments | ||
| 12458 | # (none besides $self) | ||
| 12459 | # | ||
| 12460 | # Return values | ||
| 12461 | # An empty list on improper arguments | ||
| 12462 | # Otherwise returns a list containing two list references: | ||
| 12463 | # - the first is the list described above | ||
| 12464 | # - the second is a list of 'tab_name's | ||
| 12465 | |||
| 12466 | my ($self, $check) = @_; | ||
| 12467 | |||
| 12468 | # Local variables | ||
| 12469 | my ( | ||
| 12470 | @emptyList, @categoryList, @tabList, | ||
| 12471 | %mnemonicHash, | ||
| 12472 | ); | ||
| 12473 | |||
| 12474 | # Check for improper arguments | ||
| 12475 | if (defined $check) { | ||
| 12476 | |||
| 12477 | $axmud::CLIENT->writeImproper($self->_objClass . '->setTabList_prof', @_); | ||
| 12478 | return @emptyList; | ||
| 12479 | } | ||
| 12480 | |||
| 12481 | # Display the tabs in reverse priority order (i.e. so that 'world' is always first) | ||
| 12482 | @categoryList = reverse $self->session->profPriorityList; | ||
| 12483 | foreach my $category (@categoryList) { | ||
| 12484 | |||
| 12485 | # Add to the list the pair 'world' and 'W_orld', the pair 'char' and 'C_har', etc | ||
| 12486 | push ( | ||
| 12487 | @tabList, | ||
| 12488 | $category, | ||
| 12489 | $self->getMnemonic(ucfirst($category), \%mnemonicHash), | ||
| 12490 | ); | ||
| 12491 | } | ||
| 12492 | |||
| 12493 | return (\@tabList, \@categoryList); | ||
| 12494 | } | ||
| 12495 | |||
| 12496 | sub setColumnList_prof { | ||
| 12497 | |||
| 12498 | # Called by $self->allProfHeader and ->currentProfHeader | ||
| 12499 | # Sets up the list of column titles appropriate for displaying profiles in the notebook | ||
| 12500 | # list, in the form | ||
| 12501 | # [ | ||
| 12502 | # 'column_name' => 'type', | ||
| 12503 | # 'column_name' => 'type', | ||
| 12504 | # 'column_name' => 'type', | ||
| 12505 | # ... | ||
| 12506 | # ] | ||
| 12507 | # | ||
| 12508 | # Expected arguments | ||
| 12509 | # (none besides $self) | ||
| 12510 | # | ||
| 12511 | # Return values | ||
| 12512 | # 'undef' on improper arguments | ||
| 12513 | # Otherwise returns a reference to the list described above | ||
| 12514 | |||
| 12515 | my ($self, $check) = @_; | ||
| 12516 | |||
| 12517 | # Local variables | ||
| 12518 | my @list; | ||
| 12519 | |||
| 12520 | # Check for improper arguments | ||
| 12521 | if (defined $check) { | ||
| 12522 | |||
| 12523 | return $axmud::CLIENT->writeImproper($self->_objClass . '->setColumnList_prof', @_); | ||
| 12524 | } | ||
| 12525 | |||
| 12526 | @list = ( | ||
| 12527 | 'Current' => 'bool', | ||
| 12528 | 'Profile Name' => 'text', | ||
| 12529 | 'Category' => 'text', | ||
| 12530 | ); | ||
| 12531 | |||
| 12532 | return \@list; | ||
| 12533 | } | ||
| 12534 | |||
| 12535 | sub setButtonList_prof { | ||
| 12536 | |||
| 12537 | # Called by $self->allProfHeader and ->currentProfHeader | ||
| 12538 | # Sets up the list of buttons appropriate for manipulating profiles in the notebook list, | ||
| 12539 | # in the form | ||
| 12540 | # [ | ||
| 12541 | # 'button_name', 'tooltip', 'callback_sub_ref', | ||
| 12542 | # 'button_name', 'tooltip', 'callback_sub_ref', | ||
| 12543 | # 'button_name', 'tooltip', 'callback_sub_ref', | ||
| 12544 | # ... | ||
| 12545 | # ] | ||
| 12546 | # | ||
| 12547 | # Expected arguments | ||
| 12548 | # (none besides $self) | ||
| 12549 | # | ||
| 12550 | # Return values | ||
| 12551 | # 'undef' on improper arguments | ||
| 12552 | # Otherwise returns a reference to the list described above | ||
| 12553 | |||
| 12554 | my ($self, $check) = @_; | ||
| 12555 | |||
| 12556 | # Local variables | ||
| 12557 | my @list; | ||
| 12558 | |||
| 12559 | # Check for improper arguments | ||
| 12560 | if (defined $check) { | ||
| 12561 | |||
| 12562 | return $axmud::CLIENT->writeImproper($self->_objClass . '->setButtonList_prof', @_); | ||
| 12563 | } | ||
| 12564 | |||
| 12565 | @list = ( | ||
| 12566 | 'Add', 'Add a new profile', 'buttonAdd_prof', | ||
| 12567 | 'Edit', 'Edit the selected profile', 'buttonEdit_prof', | ||
| 12568 | 'Set current', 'Set a current profile', 'buttonSet_prof', | ||
| 12569 | 'Unset current', 'Unset the current profile', 'buttonUnset_prof', | ||
| 12570 | 'Clone', 'Clone the selected profile', 'buttonClone_prof', | ||
| 12571 | 'Delete', 'Delete the selected profile', 'buttonDelete_prof', | ||
| 12572 | 'Dump', 'Display this list of profiles in the \'main\' window', 'buttonDump_prof', | ||
| 12573 | 'Dump all', 'Display a list of all profiles in the \'main\' window', | ||
| 12574 | 'buttonDumpAll_prof', | ||
| 12575 | ); | ||
| 12576 | |||
| 12577 | return \@list; | ||
| 12578 | } | ||
| 12579 | |||
| 12580 | sub compileList_profPriority { | ||
| 12581 | |||
| 12582 | # Called by $self->profPriorityHeader | ||
| 12583 | # Compiles the data to be displayed in a Gtk3::SimpleList, and converts it into a reference | ||
| 12584 | # to a hash | ||
| 12585 | # | ||
| 12586 | # Expected arguments | ||
| 12587 | # (none besides $self) | ||
| 12588 | # | ||
| 12589 | # Return values | ||
| 12590 | # 'undef' on improper arguments | ||
| 12591 | # Otherwise returns a reference to the has described above | ||
| 12592 | |||
| 12593 | my ($self, $check) = @_; | ||
| 12594 | |||
| 12595 | # Local variables | ||
| 12596 | my ( | ||
| 12597 | $count, $dataHashRef, | ||
| 12598 | @dataList, @otherList, | ||
| 12599 | %dataHash, | ||
| 12600 | ); | ||
| 12601 | |||
| 12602 | # Check for improper arguments | ||
| 12603 | if (defined $check) { | ||
| 12604 | |||
| 12605 | return $axmud::CLIENT->writeImproper( | ||
| 12606 | $self->_objClass . '->compileList_profPriority', | ||
| 12607 | @_, | ||
| 12608 | ); | ||
| 12609 | } | ||
| 12610 | |||
| 12611 | # A numbered list of categories comes first, containing everything in | ||
| 12612 | # $self->session->profPriorityList | ||
| 12613 | # Then follows an unnumbered list of any remaining categories which aren't in the priority | ||
| 12614 | # list | ||
| 12615 | |||
| 12616 | # Numbered categories (in priority list) | ||
| 12617 | $count = 0; | ||
| 12618 | OUTER: foreach my $category ($self->session->profPriorityList) { | ||
| 12619 | |||
| 12620 | my $listRef; | ||
| 12621 | |||
| 12622 | $count++; | ||
| 12623 | $listRef = [$count, $category]; | ||
| 12624 | push (@dataList, $listRef); | ||
| 12625 | } | ||
| 12626 | |||
| 12627 | # Unnumbered categories (not in priority list). Compile a list of unnumbered categories. | ||
| 12628 | # First check the default priority list | ||
| 12629 | OUTER: foreach my $defaultCategory ($axmud::CLIENT->constProfPriorityList) { | ||
| 12630 | |||
| 12631 | INNER: foreach my $numberedCategory ($self->session->profPriorityList) { | ||
| 12632 | |||
| 12633 | if ($defaultCategory eq $numberedCategory) { | ||
| 12634 | |||
| 12635 | next OUTER; | ||
| 12636 | } | ||
| 12637 | } | ||
| 12638 | |||
| 12639 | # One of the default categories (world, guild, race, char) is missing from the priority | ||
| 12640 | # list | ||
| 12641 | push (@otherList, $defaultCategory); | ||
| 12642 | } | ||
| 12643 | |||
| 12644 | # Next check profile template categories | ||
| 12645 | OUTER: foreach my $category ($self->session->ivKeys('templateHash')) { | ||
| 12646 | |||
| 12647 | INNER: foreach my $numberedCategory ($self->session->profPriorityList) { | ||
| 12648 | |||
| 12649 | if ($category eq $numberedCategory) { | ||
| 12650 | |||
| 12651 | next OUTER; | ||
| 12652 | } | ||
| 12653 | } | ||
| 12654 | |||
| 12655 | # This template category is missing from the priority list | ||
| 12656 | push (@otherList, $category); | ||
| 12657 | } | ||
| 12658 | |||
| 12659 | # Add the unnumbered categories to the displayed list | ||
| 12660 | @otherList = sort {lc($a) cmp lc($b)} (@otherList); | ||
| 12661 | foreach my $category (@otherList) { | ||
| 12662 | |||
| 12663 | my $listRef = ['-', $category]; | ||
| 12664 | push (@dataList, $listRef); | ||
| 12665 | } | ||
| 12666 | |||
| 12667 | # Display the list | ||
| 12668 | $dataHash{'Profile priority list'} = \@dataList; | ||
| 12669 | $dataHashRef = \%dataHash; | ||
| 12670 | |||
| 12671 | return $dataHashRef; | ||
| 12672 | } | ||
| 12673 | |||
| 12674 | sub setTabList_cage { | ||
| 12675 | |||
| 12676 | # Called by $self->allCageHeader and ->currentCageHeader | ||
| 12677 | # Sets up the list of tabs appropriate for displaying cages in the notebook list, in the | ||
| 12678 | # form | ||
| 12679 | # [ | ||
| 12680 | # 'tab_name' => 'tab_mnemonic', | ||
| 12681 | # 'tab_name' => 'tab_mnemonic', | ||
| 12682 | # 'tab_name' => 'tab_mnemonic', | ||
| 12683 | # ... | ||
| 12684 | # ] | ||
| 12685 | # | ||
| 12686 | # Expected arguments | ||
| 12687 | # (none besides $self) | ||
| 12688 | # | ||
| 12689 | # Return values | ||
| 12690 | # An empty list on improper arguments | ||
| 12691 | # Otherwise returns a list containing two list references: | ||
| 12692 | # - the first is the list described above | ||
| 12693 | # - the second is a list of 'tab_name's | ||
| 12694 | |||
| 12695 | my ($self, $check) = @_; | ||
| 12696 | |||
| 12697 | # Local variables | ||
| 12698 | my ( | ||
| 12699 | @emptyList, @tabList, @typeList, | ||
| 12700 | %mnemonicHash, | ||
| 12701 | ); | ||
| 12702 | |||
| 12703 | # Check for improper arguments | ||
| 12704 | if (defined $check) { | ||
| 12705 | |||
| 12706 | $axmud::CLIENT->writeImproper($self->_objClass . '->setTabList_cage', @_); | ||
| 12707 | return @emptyList; | ||
| 12708 | } | ||
| 12709 | |||
| 12710 | foreach my $type ($axmud::CLIENT->cageTypeList) { | ||
| 12711 | |||
| 12712 | # Add to the list the pair 'trigger' and 't_rigger', the pair 'alias' and 'a_lias', etc | ||
| 12713 | push ( | ||
| 12714 | @tabList, | ||
| 12715 | lc($type), | ||
| 12716 | $self->getMnemonic($type, \%mnemonicHash), | ||
| 12717 | ); | ||
| 12718 | |||
| 12719 | # Everything in @list is upper-case, so reduce it to lower-case | ||
| 12720 | push (@typeList, lc($type)); | ||
| 12721 | } | ||
| 12722 | |||
| 12723 | return (\@tabList, \@typeList); | ||
| 12724 | } | ||
| 12725 | |||
| 12726 | sub setColumnList_cage { | ||
| 12727 | |||
| 12728 | # Called by $self->allCageHeader and ->currentCageHeader | ||
| 12729 | # Sets up the list of column titles appropriate for displaying cages in the notebook list, | ||
| 12730 | # in the form | ||
| 12731 | # [ | ||
| 12732 | # 'column_name' => 'type', | ||
| 12733 | # 'column_name' => 'type', | ||
| 12734 | # 'column_name' => 'type', | ||
| 12735 | # ... | ||
| 12736 | # ] | ||
| 12737 | # | ||
| 12738 | # Expected arguments | ||
| 12739 | # (none besides $self) | ||
| 12740 | # | ||
| 12741 | # Return values | ||
| 12742 | # 'undef' on improper arguments | ||
| 12743 | # Otherwise returns a reference to the list described above | ||
| 12744 | |||
| 12745 | my ($self, $check) = @_; | ||
| 12746 | |||
| 12747 | # Local variables | ||
| 12748 | my @list; | ||
| 12749 | |||
| 12750 | # Check for improper arguments | ||
| 12751 | if (defined $check) { | ||
| 12752 | |||
| 12753 | return $axmud::CLIENT->writeImproper($self->_objClass . '->setColumnList_cage', @_); | ||
| 12754 | } | ||
| 12755 | |||
| 12756 | @list = ( | ||
| 12757 | 'Current' => 'bool', | ||
| 12758 | 'Cage Name' => 'text', | ||
| 12759 | ); | ||
| 12760 | |||
| 12761 | return \@list; | ||
| 12762 | } | ||
| 12763 | |||
| 12764 | sub setButtonList_cage { | ||
| 12765 | |||
| 12766 | # Called by $self->allCageHeader and ->currentCageHeader | ||
| 12767 | # Sets up the list of buttons appropriate for manipulating cages in the notebook list, in | ||
| 12768 | # the form | ||
| 12769 | # [ | ||
| 12770 | # 'button_name', 'tooltip', 'callback_sub_ref', | ||
| 12771 | # 'button_name', 'tooltip', 'callback_sub_ref', | ||
| 12772 | # 'button_name', 'tooltip', 'callback_sub_ref', | ||
| 12773 | # ... | ||
| 12774 | # ] | ||
| 12775 | # | ||
| 12776 | # Expected arguments | ||
| 12777 | # (none besides $self) | ||
| 12778 | # | ||
| 12779 | # Return values | ||
| 12780 | # 'undef' on improper arguments | ||
| 12781 | # Otherwise returns a reference to the list described above | ||
| 12782 | |||
| 12783 | my ($self, $check) = @_; | ||
| 12784 | |||
| 12785 | # Local variables | ||
| 12786 | my @list; | ||
| 12787 | |||
| 12788 | # Check for improper arguments | ||
| 12789 | |||
| 12790 | if (defined $check) { | ||
| 12791 | |||
| 12792 | return $axmud::CLIENT->writeImproper($self->_objClass . '->setButtonList_cage', @_); | ||
| 12793 | } | ||
| 12794 | |||
| 12795 | @list = ( | ||
| 12796 | 'Edit', 'Edit the selected cage', 'buttonEdit_cage', | ||
| 12797 | 'Dump', 'Display this list of cages in the \'main\' window', 'buttonDump_cage', | ||
| 12798 | 'Dump all', 'Display a list of all cages in the \'main\' window', 'buttonDumpAll_cage', | ||
| 12799 | ); | ||
| 12800 | |||
| 12801 | return \@list; | ||
| 12802 | } | ||
| 12803 | |||
| 12804 | sub getSortedCages { | ||
| 12805 | |||
| 12806 | # Called by $self->allCageHeader and $self->currentCageHeader | ||
| 12807 | # Returns a list of cages to be displayed in a single tab, sorted in the priority order of | ||
| 12808 | # each cage's associated profile | ||
| 12809 | # | ||
| 12810 | # Expected arguments | ||
| 12811 | # $tab - The name of the tab, which corresponds to a profile category ('world', 'char', | ||
| 12812 | # etc) | ||
| 12813 | # | ||
| 12814 | # Return values | ||
| 12815 | # An empty list on improper arguments | ||
| 12816 | # The sorted list of cages otherwise | ||
| 12817 | |||
| 12818 | my ($self, $tab, $check) = @_; | ||
| 12819 | |||
| 12820 | # Local variables | ||
| 12821 | my ( | ||
| 12822 | @emptyList, @cageList, @spareList, @lonelyList, @sortedList, | ||
| 12823 | %cageHash, | ||
| 12824 | ); | ||
| 12825 | |||
| 12826 | # Check for improper arguments | ||
| 12827 | if (! defined $tab || defined $check) { | ||
| 12828 | |||
| 12829 | $axmud::CLIENT->writeImproper($self->_objClass . '->getSortedCages', @_); | ||
| 12830 | return @emptyList; | ||
| 12831 | } | ||
| 12832 | |||
| 12833 | # Get a hash of cages belonging to this tab | ||
| 12834 | foreach my $cageObj ($self->session->ivValues('cageHash')) { | ||
| 12835 | |||
| 12836 | if ($cageObj->cageType eq $tab) { | ||
| 12837 | |||
| 12838 | if ( | ||
| 12839 | defined $cageObj->profCategory | ||
| 12840 | && $self->session->ivExists('currentCageHash', $cageObj->name) | ||
| 12841 | ) { | ||
| 12842 | $cageHash{$cageObj->profCategory} = $cageObj; | ||
| 12843 | |||
| 12844 | } else { | ||
| 12845 | |||
| 12846 | # Not a current cage - leave it until the end | ||
| 12847 | push (@spareList, $cageObj); | ||
| 12848 | } | ||
| 12849 | } | ||
| 12850 | } | ||
| 12851 | |||
| 12852 | # Sort the list in priority order | ||
| 12853 | foreach my $category ($self->session->profPriorityList) { | ||
| 12854 | |||
| 12855 | if (exists $cageHash{$category}) { | ||
| 12856 | |||
| 12857 | push (@cageList, $cageHash{$category}); | ||
| 12858 | delete $cageHash{$category}; | ||
| 12859 | } | ||
| 12860 | } | ||
| 12861 | |||
| 12862 | if (%cageHash) { | ||
| 12863 | |||
| 12864 | # These cages are associated with profiles which aren't in the profile priority list | ||
| 12865 | @lonelyList = sort {lc($a->name) cmp lc($b->name)} (values %cageHash); | ||
| 12866 | push (@cageList, @lonelyList); | ||
| 12867 | } | ||
| 12868 | |||
| 12869 | # Add all the cages for non-current profiles | ||
| 12870 | @sortedList = sort {lc($a->name) cmp lc($b->name)} (@spareList); | ||
| 12871 | push (@cageList, @sortedList); | ||
| 12872 | |||
| 12873 | return @cageList; | ||
| 12874 | } | ||
| 12875 | |||
| 12876 | sub setColumnList_model { | ||
| 12877 | |||
| 12878 | # Called by $self->allModelHeader, $self->regionModelHeader, etc | ||
| 12879 | # Sets up the list of column titles appropriate for displaying model objects in the notebook | ||
| 12880 | # list, in the form | ||
| 12881 | # [ | ||
| 12882 | # 'column_name' => 'type', | ||
| 12883 | # 'column_name' => 'type', | ||
| 12884 | # 'column_name' => 'type', | ||
| 12885 | # ... | ||
| 12886 | # ] | ||
| 12887 | # | ||
| 12888 | # Expected arguments | ||
| 12889 | # (none besides $self) | ||
| 12890 | # | ||
| 12891 | # Return values | ||
| 12892 | # 'undef' on improper arguments | ||
| 12893 | # Otherwise returns a reference to the list described above | ||
| 12894 | |||
| 12895 | my ($self, $check) = @_; | ||
| 12896 | |||
| 12897 | # Local variables | ||
| 12898 | my @list; | ||
| 12899 | |||
| 12900 | # Check for improper arguments | ||
| 12901 | if (defined $check) { | ||
| 12902 | |||
| 12903 | return $axmud::CLIENT->writeImproper($self->_objClass . '->setColumnList_model', @_); | ||
| 12904 | } | ||
| 12905 | |||
| 12906 | @list = ( | ||
| 12907 | 'Model #' => 'int', | ||
| 12908 | 'Category' => 'text', | ||
| 12909 | 'Name' => 'text', | ||
| 12910 | ); | ||
| 12911 | |||
| 12912 | return \@list; | ||
| 12913 | } | ||
| 12914 | |||
| 12915 | sub setButtonList_model { | ||
| 12916 | |||
| 12917 | # Called by $self->allModelHeader, $self->regionModelHeader, etc (most world model object | ||
| 12918 | # tabs use this function, but a few - such as the tab for characters - specify their own | ||
| 12919 | # buttons) | ||
| 12920 | # Sets up the list of buttons appropriate for manipulating model objects in the notebook | ||
| 12921 | # list, in the form | ||
| 12922 | # [ | ||
| 12923 | # 'button_name', 'tooltip', 'callback_sub_ref', | ||
| 12924 | # 'button_name', 'tooltip', 'callback_sub_ref', | ||
| 12925 | # 'button_name', 'tooltip', 'callback_sub_ref', | ||
| 12926 | # ... | ||
| 12927 | # ] | ||
| 12928 | # | ||
| 12929 | # Expected arguments | ||
| 12930 | # (none besides $self) | ||
| 12931 | # | ||
| 12932 | # Return values | ||
| 12933 | # 'undef' on improper arguments | ||
| 12934 | # Otherwise returns a reference to the list described above | ||
| 12935 | |||
| 12936 | my ($self, $check) = @_; | ||
| 12937 | |||
| 12938 | # Local variables | ||
| 12939 | my @list; | ||
| 12940 | |||
| 12941 | # Check for improper arguments | ||
| 12942 | if (defined $check) { | ||
| 12943 | |||
| 12944 | return $axmud::CLIENT->writeImproper($self->_objClass . '->setButtonList_model', @_); | ||
| 12945 | } | ||
| 12946 | |||
| 12947 | @list = ( | ||
| 12948 | 'Add', 'Add an object to the world model', 'buttonAdd_model', | ||
| 12949 | 'Edit', 'Edit the selected world model object', 'buttonEdit_model', | ||
| 12950 | 'Delete', 'Delete the selected world model object', 'buttonDelete_model', | ||
| 12951 | 'Dump', 'Displays a list of all world model objects in the \'main\' window', | ||
| 12952 | 'buttonDump_model', | ||
| 12953 | ); | ||
| 12954 | |||
| 12955 | return \@list; | ||
| 12956 | } | ||
| 12957 | |||
| 12958 | # Treeview callbacks | ||
| 12959 | |||
| 12960 | sub treeViewRowActivated { | ||
| 12961 | |||
| 12962 | # Treeview's 'row_activated' callback - expands and collapses parts of the tree | ||
| 12963 | # Defined in $self->enable | ||
| 12964 | # | ||
| 12965 | # Expected arguments | ||
| 12966 | # $tree - The Gtk3::TreeView widget | ||
| 12967 | # $path, $column - The clicked cell | ||
| 12968 | # $self - This Perl object | ||
| 12969 | # | ||
| 12970 | # Return values | ||
| 12971 | # 'undef' on improper arguments | ||
| 12972 | # 1 otherwise | ||
| 12973 | |||
| 12974 | my ($tree, $path, $column, $self, $check) = @_; | ||
| 12975 | |||
| 12976 | # Check for improper arguments | ||
| 12977 | if ( | ||
| 12978 | ! defined $tree || ! defined $path || ! defined $column || ! defined $self | ||
| 12979 | || defined $check | ||
| 12980 | ) { | ||
| 12981 | return $axmud::CLIENT->writeImproper($self->_objClass . '->treeViewRowActivated', @_); | ||
| 12982 | } | ||
| 12983 | |||
| 12984 | if ($tree->row_expanded($path)) { | ||
| 12985 | |||
| 12986 | $tree->collapse_row($path); | ||
| 12987 | |||
| 12988 | } else { | ||
| 12989 | |||
| 12990 | $tree->expand_row($path, FALSE); | ||
| 12991 | } | ||
| 12992 | |||
| 12993 | return 1; | ||
| 12994 | } | ||
| 12995 | |||
| 12996 | sub treeViewChanged { | ||
| 12997 | |||
| 12998 | # Treeview's 'changed' callback - responds to clicks on the tree | ||
| 12999 | # Defined in $self->winEnable | ||
| 13000 | # | ||
| 13001 | # Expected arguments | ||
| 13002 | # $selection - Gtk3::Selection | ||
| 13003 | # $self - This Perl object | ||
| 13004 | # | ||
| 13005 | # Return values | ||
| 13006 | # 'undef' on improper arguments | ||
| 13007 | # 1 otherwise | ||
| 13008 | |||
| 13009 | my ($selection, $self, $check) = @_; | ||
| 13010 | |||
| 13011 | # Local variables | ||
| 13012 | my ($model, $iter, $type, $method); | ||
| 13013 | |||
| 13014 | # Check for improper arguments | ||
| 13015 | if (! defined $selection || ! defined $self || defined $check) { | ||
| 13016 | |||
| 13017 | return $axmud::CLIENT->writeImproper($self->_objClass . '->treeViewChanged', @_); | ||
| 13018 | } | ||
| 13019 | |||
| 13020 | ($model, $iter) = $selection->get_selected(); | ||
| 13021 | if (! $iter) { | ||
| 13022 | |||
| 13023 | return undef; | ||
| 13024 | |||
| 13025 | } else { | ||
| 13026 | |||
| 13027 | $type = $model->get($iter, 0); | ||
| 13028 | } | ||
| 13029 | |||
| 13030 | # Is the clicked item a header? If so, call its function | ||
| 13031 | if ($self->ivExists('headerHash', $type)) { | ||
| 13032 | |||
| 13033 | # ->notebookSelectRef's default value is 'undef'; the function we're about to call will | ||
| 13034 | # set it, if need be | ||
| 13035 | $self->ivPoke('notebookSelectRef', undef); | ||
| 13036 | # Remember which type of notebook we're about to display | ||
| 13037 | $self->ivPoke('notebookCurrentHeader', $type); | ||
| 13038 | |||
| 13039 | # Call the function to create this type of notebook | ||
| 13040 | $method = $self->ivShow('headerHash', $type); | ||
| 13041 | $self->$method($type); | ||
| 13042 | } | ||
| 13043 | |||
| 13044 | return 1; | ||
| 13045 | } | ||
| 13046 | |||
| 13047 | # Profile button callbacks | ||
| 13048 | |||
| 13049 | sub buttonAdd_prof { | ||
| 13050 | |||
| 13051 | # Callback: Adds a profile (equivalent to ';addworld', ';addchar', etc) | ||
| 13052 | # | ||
| 13053 | # Expected arguments | ||
| 13054 | # (none besides $self) | ||
| 13055 | # | ||
| 13056 | # Return values | ||
| 13057 | # 'undef' on improper arguments or if a temporary profile object can't be created | ||
| 13058 | # 1 otherwise | ||
| 13059 | |||
| 13060 | my ($self, $check) = @_; | ||
| 13061 | |||
| 13062 | # Local variables | ||
| 13063 | my ($tab, $slWidget, $world, $profObj, $templObj); | ||
| 13064 | |||
| 13065 | # Check for improper arguments | ||
| 13066 | if (defined $check) { | ||
| 13067 | |||
| 13068 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonAdd_prof', @_); | ||
| 13069 | } | ||
| 13070 | |||
| 13071 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 13072 | $tab = $self->notebookGetTab(); | ||
| 13073 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 13074 | |||
| 13075 | # Unselect everything in the list, because we're creating a new profile | ||
| 13076 | $slWidget->get_selection->unselect_all(); | ||
| 13077 | |||
| 13078 | # Create a temporary profile, to store the changes the user will make | ||
| 13079 | $world = $self->session->currentWorld->name; | ||
| 13080 | |||
| 13081 | if ($tab eq 'world') { | ||
| 13082 | $profObj = Games::Axmud::Profile::World->new($self->session, '<temp>', TRUE); | ||
| 13083 | } elsif ($tab eq 'guild') { | ||
| 13084 | $profObj = Games::Axmud::Profile::Guild->new($self->session, '<temp>', $world, TRUE); | ||
| 13085 | } elsif ($tab eq 'race') { | ||
| 13086 | $profObj = Games::Axmud::Profile::Race->new($self->session, '<temp>', $world, TRUE); | ||
| 13087 | } elsif ($tab eq 'char') { | ||
| 13088 | $profObj = Games::Axmud::Profile::Char->new($self->session, '<temp>', $world, TRUE); | ||
| 13089 | } else { | ||
| 13090 | |||
| 13091 | # Find the matching template profile | ||
| 13092 | if ($self->session->ivExists('templateHash', $tab)) { | ||
| 13093 | |||
| 13094 | $templObj = $self->session->ivShow('templateHash', $tab); | ||
| 13095 | |||
| 13096 | # Spawn a new custom profile | ||
| 13097 | $profObj = $templObj->spawn( | ||
| 13098 | $self->session, | ||
| 13099 | '<temp>', | ||
| 13100 | $self->session->currentWorld->name, | ||
| 13101 | TRUE, | ||
| 13102 | ); | ||
| 13103 | } | ||
| 13104 | } | ||
| 13105 | |||
| 13106 | if (! $profObj) { | ||
| 13107 | |||
| 13108 | # Can't edit anything | ||
| 13109 | return undef; | ||
| 13110 | |||
| 13111 | } else { | ||
| 13112 | |||
| 13113 | # Open up an 'edit' window to create the new object, replacing the temporary one we've | ||
| 13114 | # just created | ||
| 13115 | if ($tab eq 'world') { | ||
| 13116 | |||
| 13117 | $self->createFreeWin( | ||
| 13118 | 'Games::Axmud::EditWin::Profile::World', | ||
| 13119 | $self, | ||
| 13120 | $self->session, | ||
| 13121 | 'Edit world profile \'' . $profObj->name . '\'', | ||
| 13122 | $profObj, | ||
| 13123 | TRUE, # Temporary object | ||
| 13124 | ); | ||
| 13125 | |||
| 13126 | } elsif ($tab eq 'guild') { | ||
| 13127 | |||
| 13128 | $self->createFreeWin( | ||
| 13129 | 'Games::Axmud::EditWin::Profile::Guild', | ||
| 13130 | $self, | ||
| 13131 | $self->session, | ||
| 13132 | 'Edit guild profile \'' . $profObj->name . '\'', | ||
| 13133 | $profObj, | ||
| 13134 | TRUE, # Temporary object | ||
| 13135 | ); | ||
| 13136 | |||
| 13137 | } elsif ($tab eq 'race') { | ||
| 13138 | |||
| 13139 | $self->createFreeWin( | ||
| 13140 | 'Games::Axmud::EditWin::Profile::Race', | ||
| 13141 | $self, | ||
| 13142 | $self->session, | ||
| 13143 | 'Edit race profile \'' . $profObj->name . '\'', | ||
| 13144 | $profObj, | ||
| 13145 | TRUE, # Temporary object | ||
| 13146 | ); | ||
| 13147 | |||
| 13148 | } elsif ($tab eq 'char') { | ||
| 13149 | |||
| 13150 | $self->createFreeWin( | ||
| 13151 | 'Games::Axmud::EditWin::Profile::Char', | ||
| 13152 | $self, | ||
| 13153 | $self->session, | ||
| 13154 | 'Edit character profile \'' . $profObj->name . '\'', | ||
| 13155 | $profObj, | ||
| 13156 | TRUE, # Temporary object | ||
| 13157 | ); | ||
| 13158 | |||
| 13159 | } else { | ||
| 13160 | |||
| 13161 | $self->createFreeWin( | ||
| 13162 | 'Games::Axmud::EditWin::Profile::Custom', | ||
| 13163 | $self, | ||
| 13164 | $self->session, | ||
| 13165 | 'Edit ' . $profObj->category . ' profile \'' . $profObj->name . '\'', | ||
| 13166 | $profObj, | ||
| 13167 | TRUE, # Temporary object | ||
| 13168 | ); | ||
| 13169 | } | ||
| 13170 | } | ||
| 13171 | |||
| 13172 | return 1; | ||
| 13173 | } | ||
| 13174 | |||
| 13175 | sub buttonEdit_prof { | ||
| 13176 | |||
| 13177 | # Callback: Edits a profile (equivalent to ';editworld', ';editchar', etc) | ||
| 13178 | # | ||
| 13179 | # Expected arguments | ||
| 13180 | # (none besides $self) | ||
| 13181 | # | ||
| 13182 | # Return values | ||
| 13183 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 13184 | # object no longer exists | ||
| 13185 | # 1 otherwise | ||
| 13186 | |||
| 13187 | my ($self, $check) = @_; | ||
| 13188 | |||
| 13189 | # Local variables | ||
| 13190 | my ( | ||
| 13191 | $tab, $dataRef, $profName, $profObj, | ||
| 13192 | @list, @dataList, | ||
| 13193 | ); | ||
| 13194 | |||
| 13195 | # Check for improper arguments | ||
| 13196 | if (defined $check) { | ||
| 13197 | |||
| 13198 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonEdit_prof', @_); | ||
| 13199 | } | ||
| 13200 | |||
| 13201 | # Get the selected tab | ||
| 13202 | $tab = $self->notebookGetTab(); | ||
| 13203 | # Import the currently selected portions of the notebook list | ||
| 13204 | @list = $self->notebookGetSelectedData(); | ||
| 13205 | if (! @list) { | ||
| 13206 | |||
| 13207 | # Nothing selected | ||
| 13208 | return undef; | ||
| 13209 | } | ||
| 13210 | |||
| 13211 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 13212 | # a single row of the list | ||
| 13213 | $dataRef = $list[0]; | ||
| 13214 | @dataList = @$dataRef; | ||
| 13215 | # The profile name is the second item of data | ||
| 13216 | $profName = $dataList[1]; | ||
| 13217 | if (! $profName) { | ||
| 13218 | |||
| 13219 | # Can't continue | ||
| 13220 | return undef; | ||
| 13221 | } | ||
| 13222 | |||
| 13223 | # Get the profile itself | ||
| 13224 | if ($tab eq 'world') { | ||
| 13225 | $profObj = $axmud::CLIENT->ivShow('worldProfHash', $profName); | ||
| 13226 | } else { | ||
| 13227 | $profObj = $self->session->ivShow('profHash', $profName); | ||
| 13228 | } | ||
| 13229 | |||
| 13230 | if (! $profObj) { | ||
| 13231 | |||
| 13232 | # Can't continue | ||
| 13233 | return undef; | ||
| 13234 | |||
| 13235 | } else { | ||
| 13236 | |||
| 13237 | # Open up an 'edit' window to edit the object | ||
| 13238 | if ($tab eq 'world') { | ||
| 13239 | |||
| 13240 | $self->createFreeWin( | ||
| 13241 | 'Games::Axmud::EditWin::Profile::World', | ||
| 13242 | $self, | ||
| 13243 | $self->session, | ||
| 13244 | 'Edit world profile \'' . $profName . '\'', | ||
| 13245 | $profObj, | ||
| 13246 | FALSE, # Not temporary | ||
| 13247 | ); | ||
| 13248 | |||
| 13249 | } elsif ($tab eq 'guild') { | ||
| 13250 | |||
| 13251 | $self->createFreeWin( | ||
| 13252 | 'Games::Axmud::EditWin::Profile::Guild', | ||
| 13253 | $self, | ||
| 13254 | $self->session, | ||
| 13255 | 'Edit guild profile \'' . $profName . '\'', | ||
| 13256 | $profObj, | ||
| 13257 | FALSE, # Not temporary | ||
| 13258 | ); | ||
| 13259 | |||
| 13260 | } elsif ($tab eq 'race') { | ||
| 13261 | |||
| 13262 | $self->createFreeWin( | ||
| 13263 | 'Games::Axmud::EditWin::Profile::Race', | ||
| 13264 | $self, | ||
| 13265 | $self->session, | ||
| 13266 | 'Edit race profile \'' . $profName . '\'', | ||
| 13267 | $profObj, | ||
| 13268 | FALSE, # Not temporary | ||
| 13269 | ); | ||
| 13270 | |||
| 13271 | } elsif ($tab eq 'char') { | ||
| 13272 | |||
| 13273 | $self->createFreeWin( | ||
| 13274 | 'Games::Axmud::EditWin::Profile::Char', | ||
| 13275 | $self, | ||
| 13276 | $self->session, | ||
| 13277 | 'Edit char profile \'' . $profName . '\'', | ||
| 13278 | $profObj, | ||
| 13279 | FALSE, # Not temporary | ||
| 13280 | ); | ||
| 13281 | |||
| 13282 | } else { | ||
| 13283 | |||
| 13284 | $self->createFreeWin( | ||
| 13285 | 'Games::Axmud::EditWin::Profile::Custom', | ||
| 13286 | $self, | ||
| 13287 | $self->session, | ||
| 13288 | 'Edit ' . $profObj->category . ' profile \'' . $profName . '\'', | ||
| 13289 | $profObj, | ||
| 13290 | FALSE, # Not temporary | ||
| 13291 | ); | ||
| 13292 | } | ||
| 13293 | |||
| 13294 | return 1; | ||
| 13295 | } | ||
| 13296 | } | ||
| 13297 | |||
| 13298 | sub buttonSet_prof { | ||
| 13299 | |||
| 13300 | # Callback: Sets a current profile (equivalent to ';setworld', ';setchar', etc) | ||
| 13301 | # | ||
| 13302 | # Expected arguments | ||
| 13303 | # (none besides $self) | ||
| 13304 | # | ||
| 13305 | # Return values | ||
| 13306 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 13307 | # object no longer exists | ||
| 13308 | # 1 otherwise | ||
| 13309 | |||
| 13310 | my ($self, $check) = @_; | ||
| 13311 | |||
| 13312 | # Local variables | ||
| 13313 | my ( | ||
| 13314 | $tab, $dataRef, $profName, $profObj, | ||
| 13315 | @list, @dataList, | ||
| 13316 | ); | ||
| 13317 | |||
| 13318 | # Check for improper arguments | ||
| 13319 | if (defined $check) { | ||
| 13320 | |||
| 13321 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonSet_prof', @_); | ||
| 13322 | } | ||
| 13323 | |||
| 13324 | # Get the selected tab | ||
| 13325 | $tab = $self->notebookGetTab(); | ||
| 13326 | # Import the currently selected portions of the notebook list | ||
| 13327 | @list = $self->notebookGetSelectedData(); | ||
| 13328 | if (! @list) { | ||
| 13329 | |||
| 13330 | # Nothing selected | ||
| 13331 | return undef; | ||
| 13332 | } | ||
| 13333 | |||
| 13334 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 13335 | # a single row of the list | ||
| 13336 | $dataRef = $list[0]; | ||
| 13337 | @dataList = @$dataRef; | ||
| 13338 | # The profile name is the second item of data | ||
| 13339 | $profName = $dataList[1]; | ||
| 13340 | if (! $profName) { | ||
| 13341 | |||
| 13342 | # Can't continue | ||
| 13343 | return undef; | ||
| 13344 | } | ||
| 13345 | |||
| 13346 | # Get the profile itself (to check it still exists) | ||
| 13347 | if ($tab eq 'world') { | ||
| 13348 | $profObj = $axmud::CLIENT->ivShow('worldProfHash', $profName); | ||
| 13349 | } else { | ||
| 13350 | $profObj = $self->session->ivShow('profHash', $profName); | ||
| 13351 | } | ||
| 13352 | |||
| 13353 | if (! $profObj) { | ||
| 13354 | |||
| 13355 | # Can't continue | ||
| 13356 | return undef; | ||
| 13357 | } | ||
| 13358 | |||
| 13359 | # Set the profile | ||
| 13360 | if ($profObj->category eq 'world') { | ||
| 13361 | $self->session->pseudoCmd('setworld ' . $profName, $self->pseudoCmdMode); | ||
| 13362 | } elsif ($profObj->category eq 'guild') { | ||
| 13363 | $self->session->pseudoCmd('setguild ' . $profName, $self->pseudoCmdMode); | ||
| 13364 | } elsif ($profObj->category eq 'race') { | ||
| 13365 | $self->session->pseudoCmd('setrace ' . $profName, $self->pseudoCmdMode); | ||
| 13366 | } elsif ($profObj->category eq 'char') { | ||
| 13367 | $self->session->pseudoCmd('setchar ' . $profName, $self->pseudoCmdMode); | ||
| 13368 | } else { | ||
| 13369 | $self->session->pseudoCmd('setcustomprofile ' . $profName, $self->pseudoCmdMode); | ||
| 13370 | } | ||
| 13371 | |||
| 13372 | # Update the notebook | ||
| 13373 | $self->updateNotebook(); | ||
| 13374 | |||
| 13375 | return 1; | ||
| 13376 | } | ||
| 13377 | |||
| 13378 | sub buttonUnset_prof { | ||
| 13379 | |||
| 13380 | # Callback: Unsets a current profile (equivalent to ';unsetguild', ';unsetchar', etc) | ||
| 13381 | # | ||
| 13382 | # Expected arguments | ||
| 13383 | # (none besides $self) | ||
| 13384 | # | ||
| 13385 | # Return values | ||
| 13386 | # 'undef' on improper arguments or if the user tries to unset a current world profile | ||
| 13387 | # 1 otherwise | ||
| 13388 | |||
| 13389 | my ($self, $check) = @_; | ||
| 13390 | |||
| 13391 | # Local variables | ||
| 13392 | my ($tab, $profObj); | ||
| 13393 | |||
| 13394 | # Check for improper arguments | ||
| 13395 | if (defined $check) { | ||
| 13396 | |||
| 13397 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonUnset_prof', @_); | ||
| 13398 | } | ||
| 13399 | |||
| 13400 | # Get the selected tab | ||
| 13401 | $tab = $self->notebookGetTab(); | ||
| 13402 | |||
| 13403 | # There is no ';unsetworld' command | ||
| 13404 | if ($tab eq 'world') { | ||
| 13405 | |||
| 13406 | $self->showMsgDialogue( | ||
| 13407 | 'Unset profile', | ||
| 13408 | 'warning', | ||
| 13409 | 'Current world profiles can\'t be unset', | ||
| 13410 | 'ok', | ||
| 13411 | ); | ||
| 13412 | |||
| 13413 | return undef; | ||
| 13414 | } | ||
| 13415 | |||
| 13416 | # Unset the current profile for the category displayed in this tab | ||
| 13417 | if ($tab eq 'guild') { | ||
| 13418 | $self->session->pseudoCmd('unsetguild', $self->pseudoCmdMode); | ||
| 13419 | } elsif ($tab eq 'race') { | ||
| 13420 | $self->session->pseudoCmd('unsetrace', $self->pseudoCmdMode); | ||
| 13421 | } elsif ($tab eq 'char') { | ||
| 13422 | $self->session->pseudoCmd('unsetchar', $self->pseudoCmdMode); | ||
| 13423 | } else { | ||
| 13424 | |||
| 13425 | $profObj = $self->session->ivShow('currentProfHash', $tab); | ||
| 13426 | if ($profObj) { | ||
| 13427 | |||
| 13428 | $self->session->pseudoCmd( | ||
| 13429 | 'unsetcustomprofile ' . $profObj->name, | ||
| 13430 | $self->pseudoCmdMode, | ||
| 13431 | ); | ||
| 13432 | } | ||
| 13433 | } | ||
| 13434 | |||
| 13435 | # Update the notebook | ||
| 13436 | $self->updateNotebook(); | ||
| 13437 | |||
| 13438 | return 1; | ||
| 13439 | } | ||
| 13440 | |||
| 13441 | sub buttonClone_prof { | ||
| 13442 | |||
| 13443 | # Callback: Clones the selected profile (equivalent to ';cloneworld', ';clonechar', etc) | ||
| 13444 | # | ||
| 13445 | # Expected arguments | ||
| 13446 | # (none besides $self) | ||
| 13447 | # | ||
| 13448 | # Return values | ||
| 13449 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 13450 | # object no longer exists | ||
| 13451 | # 1 otherwise | ||
| 13452 | |||
| 13453 | my ($self, $check) = @_; | ||
| 13454 | |||
| 13455 | # Local variables | ||
| 13456 | my ( | ||
| 13457 | $tab, $dataRef, $profName, $profObj, $cloneName, | ||
| 13458 | @list, @dataList, | ||
| 13459 | ); | ||
| 13460 | |||
| 13461 | # Check for improper arguments | ||
| 13462 | if (defined $check) { | ||
| 13463 | |||
| 13464 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonClone_prof', @_); | ||
| 13465 | } | ||
| 13466 | |||
| 13467 | # Get the selected tab | ||
| 13468 | $tab = $self->notebookGetTab(); | ||
| 13469 | # Import the currently selected portions of the notebook list | ||
| 13470 | @list = $self->notebookGetSelectedData(); | ||
| 13471 | if (! @list) { | ||
| 13472 | |||
| 13473 | # Nothing selected | ||
| 13474 | return undef; | ||
| 13475 | } | ||
| 13476 | |||
| 13477 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 13478 | # a single row of the list | ||
| 13479 | $dataRef = $list[0]; | ||
| 13480 | @dataList = @$dataRef; | ||
| 13481 | # The profile name is the second item of data | ||
| 13482 | $profName = $dataList[1]; | ||
| 13483 | if (! $profName) { | ||
| 13484 | |||
| 13485 | # Can't continue | ||
| 13486 | return undef; | ||
| 13487 | } | ||
| 13488 | |||
| 13489 | # Get the profile itself | ||
| 13490 | if ($tab eq 'world') { | ||
| 13491 | $profObj = $axmud::CLIENT->ivShow('worldProfHash', $profName); | ||
| 13492 | } else { | ||
| 13493 | $profObj = $self->session->ivShow('profHash', $profName); | ||
| 13494 | } | ||
| 13495 | |||
| 13496 | if (! $profObj) { | ||
| 13497 | |||
| 13498 | # Can't continue | ||
| 13499 | return undef; | ||
| 13500 | } | ||
| 13501 | |||
| 13502 | # Prompt the user for the name of the clone (max 16 chars) | ||
| 13503 | $cloneName = $self->showEntryDialogue( | ||
| 13504 | 'Clone profile', | ||
| 13505 | 'Enter a name for the clone (max 16 chars: A-Z a-z _ 0-9)', | ||
| 13506 | 16, # Max chars | ||
| 13507 | ); | ||
| 13508 | |||
| 13509 | if ($cloneName) { | ||
| 13510 | |||
| 13511 | # Clone the profile | ||
| 13512 | if ($profObj->category eq 'world') { | ||
| 13513 | |||
| 13514 | $self->session->pseudoCmd( | ||
| 13515 | 'cloneworld ' . $profName . ' ' . $cloneName, | ||
| 13516 | $self->pseudoCmdMode, | ||
| 13517 | ); | ||
| 13518 | |||
| 13519 | } elsif ($profObj->category eq 'guild') { | ||
| 13520 | |||
| 13521 | $self->session->pseudoCmd( | ||
| 13522 | 'cloneguild ' . $profName . ' ' . $cloneName, | ||
| 13523 | $self->pseudoCmdMode, | ||
| 13524 | ); | ||
| 13525 | |||
| 13526 | } elsif ($profObj->category eq 'race') { | ||
| 13527 | |||
| 13528 | $self->session->pseudoCmd( | ||
| 13529 | 'clonerace ' . $profName . ' ' . $cloneName, | ||
| 13530 | $self->pseudoCmdMode, | ||
| 13531 | ); | ||
| 13532 | |||
| 13533 | } elsif ($profObj->category eq 'char') { | ||
| 13534 | |||
| 13535 | $self->session->pseudoCmd( | ||
| 13536 | 'clonechar ' . $profName . ' ' . $cloneName, | ||
| 13537 | $self->pseudoCmdMode, | ||
| 13538 | ); | ||
| 13539 | |||
| 13540 | } else { | ||
| 13541 | |||
| 13542 | $self->session->pseudoCmd( | ||
| 13543 | 'clonecustomprofile ' . $profName . ' ' . $cloneName, | ||
| 13544 | $self->pseudoCmdMode, | ||
| 13545 | ); | ||
| 13546 | } | ||
| 13547 | |||
| 13548 | # Update the notebook | ||
| 13549 | $self->updateNotebook(); | ||
| 13550 | } | ||
| 13551 | |||
| 13552 | return 1; | ||
| 13553 | } | ||
| 13554 | |||
| 13555 | sub buttonDelete_prof { | ||
| 13556 | |||
| 13557 | # Callback: Deletes a profile (equivalent to ';deleteworld', ';deletechar', etc) | ||
| 13558 | # | ||
| 13559 | # Expected arguments | ||
| 13560 | # (none besides $self) | ||
| 13561 | # | ||
| 13562 | # Return values | ||
| 13563 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 13564 | # object no longer exists | ||
| 13565 | # 1 otherwise | ||
| 13566 | |||
| 13567 | my ($self, $check) = @_; | ||
| 13568 | |||
| 13569 | # Local variables | ||
| 13570 | my ( | ||
| 13571 | $tab, $dataRef, $profName, $profObj, | ||
| 13572 | @list, @dataList, | ||
| 13573 | ); | ||
| 13574 | |||
| 13575 | # Check for improper arguments | ||
| 13576 | if (defined $check) { | ||
| 13577 | |||
| 13578 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDelete_prof', @_); | ||
| 13579 | } | ||
| 13580 | |||
| 13581 | # Get the selected tab | ||
| 13582 | $tab = $self->notebookGetTab(); | ||
| 13583 | # Import the currently selected portions of the notebook list | ||
| 13584 | @list = $self->notebookGetSelectedData(); | ||
| 13585 | if (! @list) { | ||
| 13586 | |||
| 13587 | # Nothing selected | ||
| 13588 | return undef; | ||
| 13589 | } | ||
| 13590 | |||
| 13591 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 13592 | # a single row of the list | ||
| 13593 | $dataRef = $list[0]; | ||
| 13594 | @dataList = @$dataRef; | ||
| 13595 | # The profile name is the second item of data | ||
| 13596 | $profName = $dataList[1]; | ||
| 13597 | if (! $profName) { | ||
| 13598 | |||
| 13599 | # Can't continue | ||
| 13600 | return undef; | ||
| 13601 | } | ||
| 13602 | |||
| 13603 | # Get the profile itself (to check it still exists) | ||
| 13604 | if ($tab eq 'world') { | ||
| 13605 | $profObj = $axmud::CLIENT->ivShow('worldProfHash', $profName); | ||
| 13606 | } else { | ||
| 13607 | $profObj = $self->session->ivShow('profHash', $profName); | ||
| 13608 | } | ||
| 13609 | |||
| 13610 | if (! $profObj) { | ||
| 13611 | |||
| 13612 | # Can't continue | ||
| 13613 | return undef; | ||
| 13614 | } | ||
| 13615 | |||
| 13616 | # Delete the profile | ||
| 13617 | if ($profObj->category eq 'world') { | ||
| 13618 | $self->session->pseudoCmd('deleteworld ' . $profName, $self->pseudoCmdMode); | ||
| 13619 | } elsif ($profObj->category eq 'guild') { | ||
| 13620 | $self->session->pseudoCmd('deleteguild ' . $profName, $self->pseudoCmdMode); | ||
| 13621 | } elsif ($profObj->category eq 'race') { | ||
| 13622 | $self->session->pseudoCmd('deleterace ' . $profName, $self->pseudoCmdMode); | ||
| 13623 | } elsif ($profObj->category eq 'char') { | ||
| 13624 | $self->session->pseudoCmd('deletechar ' . $profName, $self->pseudoCmdMode); | ||
| 13625 | } else { | ||
| 13626 | $self->session->pseudoCmd('deletecustomprofile ' . $profName, $self->pseudoCmdMode); | ||
| 13627 | } | ||
| 13628 | |||
| 13629 | # Update the notebook | ||
| 13630 | $self->updateNotebook(); | ||
| 13631 | |||
| 13632 | return 1; | ||
| 13633 | } | ||
| 13634 | |||
| 13635 | sub buttonDump_prof { | ||
| 13636 | |||
| 13637 | # Callback: Displays profiles in the 'main' window (equivalent to ';listword', | ||
| 13638 | # ';listchar' etc) | ||
| 13639 | # | ||
| 13640 | # Expected arguments | ||
| 13641 | # (none besides $self) | ||
| 13642 | # | ||
| 13643 | # Return values | ||
| 13644 | # 'undef' on improper arguments | ||
| 13645 | # 1 otherwise | ||
| 13646 | |||
| 13647 | my ($self, $check) = @_; | ||
| 13648 | |||
| 13649 | # Local variables | ||
| 13650 | my $tab; | ||
| 13651 | |||
| 13652 | # Check for improper arguments | ||
| 13653 | if (defined $check) { | ||
| 13654 | |||
| 13655 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDump_prof', @_); | ||
| 13656 | } | ||
| 13657 | |||
| 13658 | # Get the selected tab | ||
| 13659 | $tab = $self->notebookGetTab(); | ||
| 13660 | |||
| 13661 | # Display the list | ||
| 13662 | if ($tab eq 'world') { | ||
| 13663 | $self->session->pseudoCmd('listworld', $self->pseudoCmdMode); | ||
| 13664 | } elsif ($tab eq 'guild') { | ||
| 13665 | $self->session->pseudoCmd('listguild', $self->pseudoCmdMode); | ||
| 13666 | } elsif ($tab eq 'race') { | ||
| 13667 | $self->session->pseudoCmd('listrace', $self->pseudoCmdMode); | ||
| 13668 | } elsif ($tab eq 'char') { | ||
| 13669 | $self->session->pseudoCmd('listchar', $self->pseudoCmdMode); | ||
| 13670 | } else { | ||
| 13671 | |||
| 13672 | # (Actually lists all custom profiles based on the same template) | ||
| 13673 | $self->session->pseudoCmd('listcustomprofile ' . $tab, $self->pseudoCmdMode); | ||
| 13674 | } | ||
| 13675 | |||
| 13676 | return 1; | ||
| 13677 | } | ||
| 13678 | |||
| 13679 | sub buttonDumpAll_prof { | ||
| 13680 | |||
| 13681 | # Callback: Displays all profiles in the 'main' window (equivalent to ';listprofile') | ||
| 13682 | # | ||
| 13683 | # Expected arguments | ||
| 13684 | # (none besides $self) | ||
| 13685 | # | ||
| 13686 | # Return values | ||
| 13687 | # 'undef' on improper arguments | ||
| 13688 | # 1 otherwise | ||
| 13689 | |||
| 13690 | my ($self, $check) = @_; | ||
| 13691 | |||
| 13692 | # Check for improper arguments | ||
| 13693 | if (defined $check) { | ||
| 13694 | |||
| 13695 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDumpAll_prof', @_); | ||
| 13696 | } | ||
| 13697 | |||
| 13698 | # Display the list of profiles | ||
| 13699 | $self->session->pseudoCmd('listprofile', $self->pseudoCmdMode); | ||
| 13700 | |||
| 13701 | return 1; | ||
| 13702 | } | ||
| 13703 | |||
| 13704 | # Template button callbacks | ||
| 13705 | |||
| 13706 | sub buttonAdd_template { | ||
| 13707 | |||
| 13708 | # Callback: Adds a profile template (equivalent to ';addtemplate') | ||
| 13709 | # | ||
| 13710 | # Expected arguments | ||
| 13711 | # (none besides $self) | ||
| 13712 | # | ||
| 13713 | # Return values | ||
| 13714 | # 'undef' on improper arguments or if a temporary profile template object can't be created | ||
| 13715 | # 1 otherwise | ||
| 13716 | |||
| 13717 | my ($self, $check) = @_; | ||
| 13718 | |||
| 13719 | # Local variables | ||
| 13720 | my ($tab, $slWidget, $templObj); | ||
| 13721 | |||
| 13722 | # Check for improper arguments | ||
| 13723 | if (defined $check) { | ||
| 13724 | |||
| 13725 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonAdd_template', @_); | ||
| 13726 | } | ||
| 13727 | |||
| 13728 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 13729 | $tab = $self->notebookGetTab(); | ||
| 13730 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 13731 | |||
| 13732 | # Unselect everything in the list, because we're creating a new profile template | ||
| 13733 | $slWidget->get_selection->unselect_all(); | ||
| 13734 | |||
| 13735 | # Create a temporary template | ||
| 13736 | $templObj = Games::Axmud::Profile::Template->new($self->session, '<temp>', TRUE); | ||
| 13737 | if (! $templObj) { | ||
| 13738 | |||
| 13739 | # Can't edit anything | ||
| 13740 | return undef; | ||
| 13741 | |||
| 13742 | } else { | ||
| 13743 | |||
| 13744 | # Open up an 'edit' window to create the new object, replacing the temporary one we've | ||
| 13745 | # just created | ||
| 13746 | $self->createFreeWin( | ||
| 13747 | 'Games::Axmud::EditWin::Profile::Template', | ||
| 13748 | $self, | ||
| 13749 | $self->session, | ||
| 13750 | 'Edit \'' . $templObj->category . '\' profile template', | ||
| 13751 | $templObj, | ||
| 13752 | TRUE, # Temporary object | ||
| 13753 | ); | ||
| 13754 | } | ||
| 13755 | |||
| 13756 | return 1; | ||
| 13757 | } | ||
| 13758 | |||
| 13759 | sub buttonEdit_template { | ||
| 13760 | |||
| 13761 | # Callback: Edits a profile template (equivalent to ';edittemplate') | ||
| 13762 | # | ||
| 13763 | # Expected arguments | ||
| 13764 | # (none besides $self) | ||
| 13765 | # | ||
| 13766 | # Return values | ||
| 13767 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 13768 | # object no longer exists | ||
| 13769 | # 1 otherwise | ||
| 13770 | |||
| 13771 | my ($self, $check) = @_; | ||
| 13772 | |||
| 13773 | # Local variables | ||
| 13774 | my ( | ||
| 13775 | $dataRef, $category, $templObj, | ||
| 13776 | @list, @dataList, | ||
| 13777 | ); | ||
| 13778 | |||
| 13779 | # Check for improper arguments | ||
| 13780 | if (defined $check) { | ||
| 13781 | |||
| 13782 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonEdit_template', @_); | ||
| 13783 | } | ||
| 13784 | |||
| 13785 | # Import the currently selected portions of the notebook list | ||
| 13786 | @list = $self->notebookGetSelectedData(); | ||
| 13787 | if (! @list) { | ||
| 13788 | |||
| 13789 | # Nothing selected | ||
| 13790 | return undef; | ||
| 13791 | } | ||
| 13792 | |||
| 13793 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 13794 | # a single row of the list | ||
| 13795 | $dataRef = $list[0]; | ||
| 13796 | @dataList = @$dataRef; | ||
| 13797 | # The template category is the second item of data | ||
| 13798 | $category = $dataList[1]; | ||
| 13799 | if (! $category) { | ||
| 13800 | |||
| 13801 | # Can't continue | ||
| 13802 | return undef; | ||
| 13803 | } | ||
| 13804 | |||
| 13805 | # Get the template itself | ||
| 13806 | $templObj = $self->session->ivShow('templateHash', $category); | ||
| 13807 | if (! $templObj) { | ||
| 13808 | |||
| 13809 | # Can't continue | ||
| 13810 | return undef; | ||
| 13811 | |||
| 13812 | } else { | ||
| 13813 | |||
| 13814 | # Open up an 'edit' window to edit the object | ||
| 13815 | $self->createFreeWin( | ||
| 13816 | 'Games::Axmud::EditWin::Profile::Template', | ||
| 13817 | $self, | ||
| 13818 | $self->session, | ||
| 13819 | 'Edit \'' . $category . '\' profile template', | ||
| 13820 | $templObj, | ||
| 13821 | FALSE, # Not temporary | ||
| 13822 | ); | ||
| 13823 | |||
| 13824 | return 1; | ||
| 13825 | } | ||
| 13826 | } | ||
| 13827 | |||
| 13828 | sub buttonClone_template { | ||
| 13829 | |||
| 13830 | # Callback: Clones the selected profile template (equivalent to ';clonetemplate') | ||
| 13831 | # | ||
| 13832 | # Expected arguments | ||
| 13833 | # (none besides $self) | ||
| 13834 | # | ||
| 13835 | # Return values | ||
| 13836 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 13837 | # object no longer exists | ||
| 13838 | # 1 otherwise | ||
| 13839 | |||
| 13840 | my ($self, $check) = @_; | ||
| 13841 | |||
| 13842 | # Local variables | ||
| 13843 | my ( | ||
| 13844 | $dataRef, $category, $templObj, $cloneCategory, | ||
| 13845 | @list, @dataList, | ||
| 13846 | ); | ||
| 13847 | |||
| 13848 | # Check for improper arguments | ||
| 13849 | if (defined $check) { | ||
| 13850 | |||
| 13851 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonClone_template', @_); | ||
| 13852 | } | ||
| 13853 | |||
| 13854 | # Import the currently selected portions of the notebook list | ||
| 13855 | @list = $self->notebookGetSelectedData(); | ||
| 13856 | if (! @list) { | ||
| 13857 | |||
| 13858 | # Nothing selected | ||
| 13859 | return undef; | ||
| 13860 | } | ||
| 13861 | |||
| 13862 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 13863 | # a single row of the list | ||
| 13864 | $dataRef = $list[0]; | ||
| 13865 | @dataList = @$dataRef; | ||
| 13866 | # The template category is the second item of data | ||
| 13867 | $category = $dataList[1]; | ||
| 13868 | if (! $category) { | ||
| 13869 | |||
| 13870 | # Can't continue | ||
| 13871 | return undef; | ||
| 13872 | } | ||
| 13873 | |||
| 13874 | # Get the template itself | ||
| 13875 | $templObj = $self->session->ivShow('templateHash', $category); | ||
| 13876 | if (! $templObj) { | ||
| 13877 | |||
| 13878 | # Can't continue | ||
| 13879 | return undef; | ||
| 13880 | } | ||
| 13881 | |||
| 13882 | # Prompt the user for the category of the clone (max 16 chars) | ||
| 13883 | $cloneCategory = $self->showEntryDialogue( | ||
| 13884 | 'Clone template', | ||
| 13885 | 'Enter a category for the clone (max 16 chars: A-Z a-z _ 0-9)', | ||
| 13886 | 16, # Max chars | ||
| 13887 | ); | ||
| 13888 | |||
| 13889 | if ($cloneCategory) { | ||
| 13890 | |||
| 13891 | # Clone the template | ||
| 13892 | $self->session->pseudoCmd( | ||
| 13893 | 'clonetemplate ' . $category . ' ' . $cloneCategory, | ||
| 13894 | $self->pseudoCmdMode, | ||
| 13895 | ); | ||
| 13896 | |||
| 13897 | # Update the notebook | ||
| 13898 | $self->updateNotebook(); | ||
| 13899 | } | ||
| 13900 | |||
| 13901 | return 1; | ||
| 13902 | } | ||
| 13903 | |||
| 13904 | sub buttonDelete_template { | ||
| 13905 | |||
| 13906 | # Callback: Deletes a profile template (equivalent to ';deletetemplate') | ||
| 13907 | # | ||
| 13908 | # Expected arguments | ||
| 13909 | # (none besides $self) | ||
| 13910 | # | ||
| 13911 | # Return values | ||
| 13912 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 13913 | # object no longer exists | ||
| 13914 | # 1 otherwise | ||
| 13915 | |||
| 13916 | my ($self, $check) = @_; | ||
| 13917 | |||
| 13918 | # Local variables | ||
| 13919 | my ( | ||
| 13920 | $dataRef, $category, $templObj, | ||
| 13921 | @list, @dataList, | ||
| 13922 | ); | ||
| 13923 | |||
| 13924 | # Check for improper arguments | ||
| 13925 | if (defined $check) { | ||
| 13926 | |||
| 13927 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDelete_template', @_); | ||
| 13928 | } | ||
| 13929 | |||
| 13930 | # Import the currently selected portions of the notebook list | ||
| 13931 | @list = $self->notebookGetSelectedData(); | ||
| 13932 | if (! @list) { | ||
| 13933 | |||
| 13934 | # Nothing selected | ||
| 13935 | return undef; | ||
| 13936 | } | ||
| 13937 | |||
| 13938 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 13939 | # a single row of the list | ||
| 13940 | $dataRef = $list[0]; | ||
| 13941 | @dataList = @$dataRef; | ||
| 13942 | # The template category is the second item of data | ||
| 13943 | $category = $dataList[1]; | ||
| 13944 | if (! $category) { | ||
| 13945 | |||
| 13946 | # Can't continue | ||
| 13947 | return undef; | ||
| 13948 | } | ||
| 13949 | |||
| 13950 | # Get the template itself (to check it still exists) | ||
| 13951 | $templObj = $self->session->ivShow('templateHash', $category); | ||
| 13952 | if (! $templObj) { | ||
| 13953 | |||
| 13954 | # Can't continue | ||
| 13955 | return undef; | ||
| 13956 | } | ||
| 13957 | |||
| 13958 | # Delete the template | ||
| 13959 | $self->session->pseudoCmd('deletetemplate ' . $category, $self->pseudoCmdMode); | ||
| 13960 | |||
| 13961 | # Update the notebook | ||
| 13962 | $self->updateNotebook(); | ||
| 13963 | |||
| 13964 | return 1; | ||
| 13965 | } | ||
| 13966 | |||
| 13967 | sub buttonDump_template { | ||
| 13968 | |||
| 13969 | # Callback: Displays profile templates in the 'main' window (equivalent to ';listtemplate') | ||
| 13970 | # | ||
| 13971 | # Expected arguments | ||
| 13972 | # (none besides $self) | ||
| 13973 | # | ||
| 13974 | # Return values | ||
| 13975 | # 'undef' on improper arguments | ||
| 13976 | # 1 otherwise | ||
| 13977 | |||
| 13978 | my ($self, $check) = @_; | ||
| 13979 | |||
| 13980 | # Check for improper arguments | ||
| 13981 | if (defined $check) { | ||
| 13982 | |||
| 13983 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDump_template', @_); | ||
| 13984 | } | ||
| 13985 | |||
| 13986 | # Display the list of profile templates | ||
| 13987 | $self->session->pseudoCmd('listtemplate', $self->pseudoCmdMode); | ||
| 13988 | |||
| 13989 | return 1; | ||
| 13990 | } | ||
| 13991 | |||
| 13992 | # Profile priority button callbacks | ||
| 13993 | |||
| 13994 | sub buttonMoveTop_profPriority { | ||
| 13995 | |||
| 13996 | # Callback: Moves a category of profile to the top of the priority list (comparable to | ||
| 13997 | # ';setprofilepriority') | ||
| 13998 | # | ||
| 13999 | # Expected arguments | ||
| 14000 | # (none besides $self) | ||
| 14001 | # | ||
| 14002 | # Return values | ||
| 14003 | # 'undef' on improper arguments, if no line is selected or if the selected item can't be | ||
| 14004 | # moved to the top | ||
| 14005 | # 1 otherwise | ||
| 14006 | |||
| 14007 | my ($self, $check) = @_; | ||
| 14008 | |||
| 14009 | # Local variables | ||
| 14010 | my ( | ||
| 14011 | $index, $priority, $category, | ||
| 14012 | @priorityList, | ||
| 14013 | ); | ||
| 14014 | |||
| 14015 | # Check for improper arguments | ||
| 14016 | if (defined $check) { | ||
| 14017 | |||
| 14018 | return $axmud::CLIENT->writeImproper( | ||
| 14019 | $self->_objClass . '->buttonMoveTop_profPriority', | ||
| 14020 | @_, | ||
| 14021 | ); | ||
| 14022 | } | ||
| 14023 | |||
| 14024 | # Import the priority list | ||
| 14025 | @priorityList = $self->session->profPriorityList; | ||
| 14026 | |||
| 14027 | # Import the GA::Obj::SimpleList and find the currently selected line and the data it | ||
| 14028 | # contains | ||
| 14029 | ($index, $priority, $category) = $self->profPriorityData(); | ||
| 14030 | if (! defined $index) { | ||
| 14031 | |||
| 14032 | return undef; | ||
| 14033 | } | ||
| 14034 | |||
| 14035 | # $index must be at least 2nd in the list (element 1), else it can't be moved up | ||
| 14036 | if ($index) { | ||
| 14037 | |||
| 14038 | # Move the item to the top of the priority list | ||
| 14039 | splice(@priorityList, $index, 1); | ||
| 14040 | unshift(@priorityList, $category); | ||
| 14041 | } | ||
| 14042 | |||
| 14043 | # Now, try using the client command ';setprofilepriority' with @priorityList as the | ||
| 14044 | # argument. The command checks whether the new arrangement is allowed | ||
| 14045 | if ( | ||
| 14046 | ! $self->session->pseudoCmd( | ||
| 14047 | 'setprofilepriority ' . join(' ', @priorityList), | ||
| 14048 | $self->pseudoCmdMode, | ||
| 14049 | ) | ||
| 14050 | ) { | ||
| 14051 | return undef; | ||
| 14052 | |||
| 14053 | } else { | ||
| 14054 | |||
| 14055 | # Update the notebook (if the priority list has actually changed) | ||
| 14056 | # The single argument makes sure the same item is selected | ||
| 14057 | $self->updateNotebook(0); | ||
| 14058 | return 1; | ||
| 14059 | } | ||
| 14060 | } | ||
| 14061 | |||
| 14062 | sub buttonMoveUp_profPriority { | ||
| 14063 | |||
| 14064 | # Callback: Moves a category of profile up the priority list (comparable to | ||
| 14065 | # ';setprofilepriority') | ||
| 14066 | # | ||
| 14067 | # Expected arguments | ||
| 14068 | # (none besides $self) | ||
| 14069 | # | ||
| 14070 | # Return values | ||
| 14071 | # 'undef' on improper arguments, if no line is selected or if the selected item can't be | ||
| 14072 | # moved up | ||
| 14073 | # 1 otherwise | ||
| 14074 | |||
| 14075 | my ($self, $check) = @_; | ||
| 14076 | |||
| 14077 | # Local variables | ||
| 14078 | my ( | ||
| 14079 | $index, $priority, $category, | ||
| 14080 | @priorityList, | ||
| 14081 | ); | ||
| 14082 | |||
| 14083 | # Check for improper arguments | ||
| 14084 | if (defined $check) { | ||
| 14085 | |||
| 14086 | return $axmud::CLIENT->writeImproper( | ||
| 14087 | $self->_objClass . '->buttonMoveUp_profPriority', | ||
| 14088 | @_, | ||
| 14089 | ); | ||
| 14090 | } | ||
| 14091 | |||
| 14092 | # Import the priority list | ||
| 14093 | @priorityList = $self->session->profPriorityList; | ||
| 14094 | |||
| 14095 | # Import the GA::Obj::SimpleList and find the currently selected line and the data it | ||
| 14096 | # contains | ||
| 14097 | ($index, $priority, $category) = $self->profPriorityData(); | ||
| 14098 | if (! defined $index) { | ||
| 14099 | |||
| 14100 | return undef; | ||
| 14101 | } | ||
| 14102 | |||
| 14103 | # $index must be at least 2nd in the list (element 1), else it can't be moved up | ||
| 14104 | if ($index) { | ||
| 14105 | |||
| 14106 | # Move the item up in the priority list | ||
| 14107 | splice(@priorityList, $index, 1); | ||
| 14108 | splice(@priorityList, ($index - 1), 0, $category); | ||
| 14109 | } | ||
| 14110 | |||
| 14111 | # Now, try using the client command ';setprofilepriority' with @priorityList as the | ||
| 14112 | # argument. The command checks whether the new arrangement is allowed | ||
| 14113 | if ( | ||
| 14114 | ! $self->session->pseudoCmd( | ||
| 14115 | 'setprofilepriority ' . join(' ', @priorityList), | ||
| 14116 | $self->pseudoCmdMode, | ||
| 14117 | ) | ||
| 14118 | ) { | ||
| 14119 | return undef; | ||
| 14120 | |||
| 14121 | } else { | ||
| 14122 | |||
| 14123 | # Update the notebook (if the priority list has actually changed) | ||
| 14124 | # The single argument makes sure the same item is selected | ||
| 14125 | $self->updateNotebook($index - 1); | ||
| 14126 | return 1; | ||
| 14127 | } | ||
| 14128 | } | ||
| 14129 | |||
| 14130 | sub buttonMoveDown_profPriority { | ||
| 14131 | |||
| 14132 | # Callback: Moves a category of profile down the priority list (comparable to | ||
| 14133 | # ';setprofilepriority') | ||
| 14134 | # | ||
| 14135 | # Expected arguments | ||
| 14136 | # (none besides $self) | ||
| 14137 | # | ||
| 14138 | # Return values | ||
| 14139 | # 'undef' on improper arguments, if no line is selected or if the selected item can't be | ||
| 14140 | # moved down | ||
| 14141 | # 1 otherwise | ||
| 14142 | |||
| 14143 | my ($self, $check) = @_; | ||
| 14144 | |||
| 14145 | # Local variables | ||
| 14146 | my ( | ||
| 14147 | $index, $priority, $category, | ||
| 14148 | @priorityList, | ||
| 14149 | ); | ||
| 14150 | |||
| 14151 | # Check for improper arguments | ||
| 14152 | if (defined $check) { | ||
| 14153 | |||
| 14154 | return $axmud::CLIENT->writeImproper( | ||
| 14155 | $self->_objClass . '->buttonMoveDown_profPriority', | ||
| 14156 | @_, | ||
| 14157 | ); | ||
| 14158 | } | ||
| 14159 | |||
| 14160 | # Import the priority list | ||
| 14161 | @priorityList = $self->session->profPriorityList; | ||
| 14162 | |||
| 14163 | # Import the GA::Obj::SimpleList and find the currently selected line and the data it | ||
| 14164 | # contains | ||
| 14165 | ($index, $priority, $category) = $self->profPriorityData(); | ||
| 14166 | if (! defined $index) { | ||
| 14167 | |||
| 14168 | return undef; | ||
| 14169 | } | ||
| 14170 | |||
| 14171 | # Move the item down in the priority list | ||
| 14172 | splice(@priorityList, $index, 1); | ||
| 14173 | splice(@priorityList, ($index + 1), 0, $category); | ||
| 14174 | |||
| 14175 | # Now, try using the client command ';setprofilepriority' with @priorityList as the | ||
| 14176 | # argument. The command checks whether the new arrangement is allowed | ||
| 14177 | if ( | ||
| 14178 | ! $self->session->pseudoCmd( | ||
| 14179 | 'setprofilepriority ' . join(' ', @priorityList), | ||
| 14180 | $self->pseudoCmdMode, | ||
| 14181 | ) | ||
| 14182 | ) { | ||
| 14183 | return undef; | ||
| 14184 | |||
| 14185 | } else { | ||
| 14186 | |||
| 14187 | # Update the notebook (if the priority list has actually changed) | ||
| 14188 | # The single argument makes sure the same item is selected | ||
| 14189 | $self->updateNotebook($index + 1); | ||
| 14190 | return 1; | ||
| 14191 | } | ||
| 14192 | } | ||
| 14193 | |||
| 14194 | sub buttonGivePriority_profPriority { | ||
| 14195 | |||
| 14196 | # Callback: Takes a category of profile which isn't in the priority list and moves it into | ||
| 14197 | # the priority list (comparable to ';setprofilepriority') | ||
| 14198 | # | ||
| 14199 | # Expected arguments | ||
| 14200 | # (none besides $self) | ||
| 14201 | # | ||
| 14202 | # Return values | ||
| 14203 | # 'undef' on improper arguments, if no line is selected, if the selected item is already | ||
| 14204 | # in the priority list or if the 'give priority' operation fails | ||
| 14205 | # 1 otherwise | ||
| 14206 | |||
| 14207 | my ($self, $check) = @_; | ||
| 14208 | |||
| 14209 | # Local variables | ||
| 14210 | my ( | ||
| 14211 | $index, $priority, $category, | ||
| 14212 | @priorityList, | ||
| 14213 | ); | ||
| 14214 | |||
| 14215 | # Check for improper arguments | ||
| 14216 | if (defined $check) { | ||
| 14217 | |||
| 14218 | return $axmud::CLIENT->writeImproper( | ||
| 14219 | $self->_objClass . '->buttonGivePriority_profPriority', | ||
| 14220 | @_, | ||
| 14221 | ); | ||
| 14222 | } | ||
| 14223 | |||
| 14224 | # Import the priority list | ||
| 14225 | @priorityList = $self->session->profPriorityList; | ||
| 14226 | |||
| 14227 | # Import the GA::Obj::SimpleList and find the currently selected line and the data it | ||
| 14228 | # contains | ||
| 14229 | ($index, $priority, $category) = $self->profPriorityData(); | ||
| 14230 | # If the category is already marked as being in the priority list, do nothing | ||
| 14231 | if (! defined $priority || $priority ne '-') { | ||
| 14232 | |||
| 14233 | return undef; | ||
| 14234 | } | ||
| 14235 | |||
| 14236 | # Add the category to the top of the priority list | ||
| 14237 | unshift (@priorityList, $category); | ||
| 14238 | |||
| 14239 | # Now, try using the client command ';setprofilepriority' with @priorityList as the | ||
| 14240 | # argument. The command checks whether the new arrangement is allowed | ||
| 14241 | if ( | ||
| 14242 | ! $self->session->pseudoCmd( | ||
| 14243 | 'setprofilepriority ' . join(' ', @priorityList), | ||
| 14244 | $self->pseudoCmdMode, | ||
| 14245 | ) | ||
| 14246 | ) { | ||
| 14247 | return undef; | ||
| 14248 | |||
| 14249 | } else { | ||
| 14250 | |||
| 14251 | # Update the notebook (if the priority list has actually changed) | ||
| 14252 | # The single argument makes sure the same item is selected | ||
| 14253 | $self->updateNotebook(0); | ||
| 14254 | return 1; | ||
| 14255 | } | ||
| 14256 | } | ||
| 14257 | |||
| 14258 | sub buttonLosePriority_profPriority { | ||
| 14259 | |||
| 14260 | # Callback: Moves a category of profile out of the priority list entirely (comparable to | ||
| 14261 | # ';setprofilepriority') | ||
| 14262 | # | ||
| 14263 | # Expected arguments | ||
| 14264 | # (none besides $self) | ||
| 14265 | # | ||
| 14266 | # Return values | ||
| 14267 | # 'undef' on improper arguments, if no line is selected or if the selected item isn't | ||
| 14268 | # already in the priority list | ||
| 14269 | # 1 otherwise | ||
| 14270 | |||
| 14271 | my ($self, $check) = @_; | ||
| 14272 | |||
| 14273 | # Local variables | ||
| 14274 | my ( | ||
| 14275 | $index, $priority, $category, | ||
| 14276 | @priorityList, | ||
| 14277 | ); | ||
| 14278 | |||
| 14279 | # Check for improper arguments | ||
| 14280 | if (defined $check) { | ||
| 14281 | |||
| 14282 | return $axmud::CLIENT->writeImproper( | ||
| 14283 | $self->_objClass . '->buttonLosePriority_profPriority', | ||
| 14284 | @_, | ||
| 14285 | ); | ||
| 14286 | } | ||
| 14287 | |||
| 14288 | # Import the priority list | ||
| 14289 | @priorityList = $self->session->profPriorityList; | ||
| 14290 | |||
| 14291 | # Import the GA::Obj::SimpleList and find the currently selected line and the data it | ||
| 14292 | # contains | ||
| 14293 | ($index, $priority, $category) = $self->profPriorityData(); | ||
| 14294 | # If the category is already marked as not being in the priority list, do nothing | ||
| 14295 | if (! defined $priority || $priority eq '-') { | ||
| 14296 | |||
| 14297 | return undef; | ||
| 14298 | } | ||
| 14299 | |||
| 14300 | # Remove the category from the priority list | ||
| 14301 | splice (@priorityList, $index, 1); | ||
| 14302 | |||
| 14303 | # Now, try using the client command ';setprofilepriority' with @priorityList as the | ||
| 14304 | # argument. The command checks whether the new arrangement is allowed | ||
| 14305 | if ( | ||
| 14306 | ! $self->session->pseudoCmd( | ||
| 14307 | 'setprofilepriority ' . join(' ', @priorityList), | ||
| 14308 | $self->pseudoCmdMode, | ||
| 14309 | ) | ||
| 14310 | ) { | ||
| 14311 | return undef; | ||
| 14312 | |||
| 14313 | } else { | ||
| 14314 | |||
| 14315 | # Update the notebook (if the priority list has actually changed) | ||
| 14316 | # Use no arguments, so that no item is selected (can't easily predict where in the list | ||
| 14317 | # the profile will now occur) | ||
| 14318 | $self->updateNotebook(); | ||
| 14319 | return 1; | ||
| 14320 | } | ||
| 14321 | } | ||
| 14322 | |||
| 14323 | sub buttonResetList_profPriority { | ||
| 14324 | |||
| 14325 | # Callback: Resets the profile priority list to the default list (comparable to | ||
| 14326 | # ';setprofilepriority', with no arguments) | ||
| 14327 | # | ||
| 14328 | # Expected arguments | ||
| 14329 | # (none besides $self) | ||
| 14330 | # | ||
| 14331 | # Return values | ||
| 14332 | # 'undef' on improper arguments | ||
| 14333 | # 1 otherwise | ||
| 14334 | |||
| 14335 | my ($self, $check) = @_; | ||
| 14336 | |||
| 14337 | # Check for improper arguments | ||
| 14338 | if (defined $check) { | ||
| 14339 | |||
| 14340 | return $axmud::CLIENT->writeImproper( | ||
| 14341 | $self->_objClass . '->buttonResetList_profPriority', | ||
| 14342 | @_, | ||
| 14343 | ); | ||
| 14344 | } | ||
| 14345 | |||
| 14346 | $self->session->pseudoCmd('setprofilepriority', $self->pseudoCmdMode); | ||
| 14347 | $self->updateNotebook(); | ||
| 14348 | |||
| 14349 | return 1; | ||
| 14350 | } | ||
| 14351 | |||
| 14352 | # Cage button callbacks | ||
| 14353 | |||
| 14354 | sub buttonEdit_cage { | ||
| 14355 | |||
| 14356 | # Callback: Edits a cage (equivalent to ';editcage') | ||
| 14357 | # | ||
| 14358 | # Expected arguments | ||
| 14359 | # (none besides $self) | ||
| 14360 | # | ||
| 14361 | # Return values | ||
| 14362 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 14363 | # object no longer exists | ||
| 14364 | # 1 otherwise | ||
| 14365 | |||
| 14366 | my ($self, $check) = @_; | ||
| 14367 | |||
| 14368 | # Local variables | ||
| 14369 | my ( | ||
| 14370 | $dataRef, $cageNamee, $cageObj, $package, | ||
| 14371 | @list, @dataList, | ||
| 14372 | ); | ||
| 14373 | |||
| 14374 | # Check for improper arguments | ||
| 14375 | if (defined $check) { | ||
| 14376 | |||
| 14377 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonEdit_cage', @_); | ||
| 14378 | } | ||
| 14379 | |||
| 14380 | # Import the currently selected portions of the notebook list | ||
| 14381 | @list = $self->notebookGetSelectedData(); | ||
| 14382 | if (! @list) { | ||
| 14383 | |||
| 14384 | # Nothing selected | ||
| 14385 | return undef; | ||
| 14386 | } | ||
| 14387 | |||
| 14388 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 14389 | # a single row of the list | ||
| 14390 | $dataRef = $list[0]; | ||
| 14391 | @dataList = @$dataRef; | ||
| 14392 | # The cage's name is the second item of data | ||
| 14393 | $cageNamee = $dataList[1]; | ||
| 14394 | if (! $cageNamee) { | ||
| 14395 | |||
| 14396 | # Can't continue | ||
| 14397 | return undef; | ||
| 14398 | } | ||
| 14399 | |||
| 14400 | # Get the cage object itself | ||
| 14401 | $cageObj = $self->session->ivShow('cageHash', $cageNamee); | ||
| 14402 | if (! $cageObj) { | ||
| 14403 | |||
| 14404 | # Can't continue | ||
| 14405 | return undef; | ||
| 14406 | |||
| 14407 | } else { | ||
| 14408 | |||
| 14409 | # Work out the package name of the correct cage 'edit' window | ||
| 14410 | if ($axmud::CLIENT->ivExists('pluginCageEditWinHash', $cageObj->cageType)) { | ||
| 14411 | |||
| 14412 | # Cage 'edit' window added by a plugin | ||
| 14413 | $package = $axmud::CLIENT->ivShow('pluginCageEditWinHash', $cageObj->cageType); | ||
| 14414 | |||
| 14415 | } else { | ||
| 14416 | |||
| 14417 | # Built-in cage 'edit' window | ||
| 14418 | $package = 'Games::Axmud::EditWin::Cage::' . ucfirst($cageObj->cageType); | ||
| 14419 | } | ||
| 14420 | |||
| 14421 | # Open up an 'edit' window to edit the object | ||
| 14422 | $self->createFreeWin( | ||
| 14423 | $package, | ||
| 14424 | $self, | ||
| 14425 | $self->session, | ||
| 14426 | 'Edit ' . $cageObj->cageType . ' cage \'' . $cageObj->name . '\'', | ||
| 14427 | $cageObj, | ||
| 14428 | FALSE, # Not temporary | ||
| 14429 | ); | ||
| 14430 | |||
| 14431 | return 1; | ||
| 14432 | } | ||
| 14433 | } | ||
| 14434 | |||
| 14435 | sub buttonDump_cage { | ||
| 14436 | |||
| 14437 | # Callback: Displays the list of cages to the 'main' window (equivalent to | ||
| 14438 | # ';listcage <switch>') | ||
| 14439 | # | ||
| 14440 | # Expected arguments | ||
| 14441 | # (none besides $self) | ||
| 14442 | # | ||
| 14443 | # Return values | ||
| 14444 | # 'undef' on improper arguments | ||
| 14445 | # 1 otherwise | ||
| 14446 | |||
| 14447 | my ($self, $check) = @_; | ||
| 14448 | |||
| 14449 | # Local variables | ||
| 14450 | my ($tab, $slWidget); | ||
| 14451 | |||
| 14452 | # Check for improper arguments | ||
| 14453 | if (defined $check) { | ||
| 14454 | |||
| 14455 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDump_cage', @_); | ||
| 14456 | } | ||
| 14457 | |||
| 14458 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 14459 | $tab = $self->notebookGetTab(); | ||
| 14460 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 14461 | |||
| 14462 | # Unselect everything in the list | ||
| 14463 | $slWidget->get_selection->unselect_all(); | ||
| 14464 | |||
| 14465 | # Dump the data | ||
| 14466 | if ($tab eq 'cmd') { | ||
| 14467 | $self->session->pseudoCmd('listcage -c', $self->pseudoCmdMode); | ||
| 14468 | } elsif ($tab eq 'trigger') { | ||
| 14469 | $self->session->pseudoCmd('listcage -t', $self->pseudoCmdMode); | ||
| 14470 | } elsif ($tab eq 'alias') { | ||
| 14471 | $self->session->pseudoCmd('listcage -a', $self->pseudoCmdMode); | ||
| 14472 | } elsif ($tab eq 'macro') { | ||
| 14473 | $self->session->pseudoCmd('listcage -m', $self->pseudoCmdMode); | ||
| 14474 | } elsif ($tab eq 'timer') { | ||
| 14475 | $self->session->pseudoCmd('listcage -i', $self->pseudoCmdMode); | ||
| 14476 | } elsif ($tab eq 'hook') { | ||
| 14477 | $self->session->pseudoCmd('listcage -h', $self->pseudoCmdMode); | ||
| 14478 | } elsif ($tab eq 'route') { | ||
| 14479 | $self->session->pseudoCmd('listcage -r', $self->pseudoCmdMode); | ||
| 14480 | } else { | ||
| 14481 | |||
| 14482 | # Non-standard cages - list them all together | ||
| 14483 | $self->session->pseudoCmd('listcage -x', $self->pseudoCmdMode); | ||
| 14484 | } | ||
| 14485 | |||
| 14486 | # Update the notebook | ||
| 14487 | $self->updateNotebook(); | ||
| 14488 | |||
| 14489 | return 1; | ||
| 14490 | } | ||
| 14491 | |||
| 14492 | sub buttonDumpAll_cage { | ||
| 14493 | |||
| 14494 | # Callback: Displays a list of all cages to the 'main' window (equivalent to | ||
| 14495 | # ';listcage') | ||
| 14496 | # | ||
| 14497 | # Expected arguments | ||
| 14498 | # (none besides $self) | ||
| 14499 | # | ||
| 14500 | # Return values | ||
| 14501 | # 'undef' on improper arguments | ||
| 14502 | # 1 otherwise | ||
| 14503 | |||
| 14504 | my ($self, $check) = @_; | ||
| 14505 | |||
| 14506 | # Local variables | ||
| 14507 | my ($tab, $slWidget, $standard, $package); | ||
| 14508 | |||
| 14509 | # Check for improper arguments | ||
| 14510 | if (defined $check) { | ||
| 14511 | |||
| 14512 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDumpAll_cage', @_); | ||
| 14513 | } | ||
| 14514 | |||
| 14515 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 14516 | $tab = $self->notebookGetTab(); | ||
| 14517 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 14518 | |||
| 14519 | # Unselect everything in the list | ||
| 14520 | $slWidget->get_selection->unselect_all(); | ||
| 14521 | |||
| 14522 | # Dump the data | ||
| 14523 | $self->session->pseudoCmd('listcage', $self->pseudoCmdMode); | ||
| 14524 | |||
| 14525 | # Update the notebook | ||
| 14526 | $self->updateNotebook(); | ||
| 14527 | |||
| 14528 | return 1; | ||
| 14529 | } | ||
| 14530 | |||
| 14531 | # Dictionary button callbacks | ||
| 14532 | |||
| 14533 | sub buttonAdd_dict { | ||
| 14534 | |||
| 14535 | # Callback: Adds a dictionary (equivalent to ';adddictionary') | ||
| 14536 | # | ||
| 14537 | # Expected arguments | ||
| 14538 | # (none besides $self) | ||
| 14539 | # | ||
| 14540 | # Return values | ||
| 14541 | # 'undef' on improper arguments or if a temporary dictionary object can't be created | ||
| 14542 | # 1 otherwise | ||
| 14543 | |||
| 14544 | my ($self, $check) = @_; | ||
| 14545 | |||
| 14546 | # Local variables | ||
| 14547 | my ($tab, $slWidget, $dictObj); | ||
| 14548 | |||
| 14549 | # Check for improper arguments | ||
| 14550 | if (defined $check) { | ||
| 14551 | |||
| 14552 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonAdd_dict', @_); | ||
| 14553 | } | ||
| 14554 | |||
| 14555 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 14556 | $tab = $self->notebookGetTab(); | ||
| 14557 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 14558 | |||
| 14559 | # Unselect everything in the list, because we're creating a new dictionary | ||
| 14560 | $slWidget->get_selection->unselect_all(); | ||
| 14561 | |||
| 14562 | # Create a temporary dictionary | ||
| 14563 | $dictObj = Games::Axmud::Obj::Dict->new($self->session, '<temp>', 'English', TRUE); | ||
| 14564 | if (! $dictObj) { | ||
| 14565 | |||
| 14566 | # Can't edit anything | ||
| 14567 | return undef; | ||
| 14568 | |||
| 14569 | } else { | ||
| 14570 | |||
| 14571 | # Open up an 'edit' window to create the new object, replacing the temporary one we've | ||
| 14572 | # just created | ||
| 14573 | $self->createFreeWin( | ||
| 14574 | 'Games::Axmud::EditWin::Dict', | ||
| 14575 | $self, | ||
| 14576 | $self->session, | ||
| 14577 | 'Edit dictionary \'' . $dictObj->name . '\'', | ||
| 14578 | $dictObj, | ||
| 14579 | TRUE, # Temporary object | ||
| 14580 | ); | ||
| 14581 | } | ||
| 14582 | |||
| 14583 | return 1; | ||
| 14584 | } | ||
| 14585 | |||
| 14586 | sub buttonEdit_dict { | ||
| 14587 | |||
| 14588 | # Callback: Edits a dictionary (equivalent to ';editdictionary') | ||
| 14589 | # | ||
| 14590 | # Expected arguments | ||
| 14591 | # (none besides $self) | ||
| 14592 | # | ||
| 14593 | # Return values | ||
| 14594 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 14595 | # object no longer exists | ||
| 14596 | # 1 otherwise | ||
| 14597 | |||
| 14598 | my ($self, $check) = @_; | ||
| 14599 | |||
| 14600 | # Local variables | ||
| 14601 | my ( | ||
| 14602 | $dataRef, $dictName, $dictObj, | ||
| 14603 | @list, @dataList, | ||
| 14604 | ); | ||
| 14605 | |||
| 14606 | # Check for improper arguments | ||
| 14607 | if (defined $check) { | ||
| 14608 | |||
| 14609 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonEdit_dict', @_); | ||
| 14610 | } | ||
| 14611 | |||
| 14612 | # Import the currently selected portions of the notebook list | ||
| 14613 | @list = $self->notebookGetSelectedData(); | ||
| 14614 | if (! @list) { | ||
| 14615 | |||
| 14616 | # Nothing selected | ||
| 14617 | return undef; | ||
| 14618 | } | ||
| 14619 | |||
| 14620 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 14621 | # a single row of the list | ||
| 14622 | $dataRef = $list[0]; | ||
| 14623 | @dataList = @$dataRef; | ||
| 14624 | # The dictionary name is the second item of data | ||
| 14625 | $dictName = $dataList[1]; | ||
| 14626 | if (! $dictName) { | ||
| 14627 | |||
| 14628 | # Can't continue | ||
| 14629 | return undef; | ||
| 14630 | } | ||
| 14631 | |||
| 14632 | # Get the dictionary itself | ||
| 14633 | $dictObj = $axmud::CLIENT->ivShow('dictHash', $dictName); | ||
| 14634 | if (! $dictObj) { | ||
| 14635 | |||
| 14636 | # Can't continue | ||
| 14637 | return undef; | ||
| 14638 | |||
| 14639 | } else { | ||
| 14640 | |||
| 14641 | # Open up an 'edit' window to edit the object | ||
| 14642 | $self->createFreeWin( | ||
| 14643 | 'Games::Axmud::EditWin::Dict', | ||
| 14644 | $self, | ||
| 14645 | $self->session, | ||
| 14646 | 'Edit dictionary \'' . $dictName . '\'', | ||
| 14647 | $dictObj, | ||
| 14648 | FALSE, # Not temporary | ||
| 14649 | ); | ||
| 14650 | |||
| 14651 | return 1; | ||
| 14652 | } | ||
| 14653 | } | ||
| 14654 | |||
| 14655 | sub buttonSet_dict { | ||
| 14656 | |||
| 14657 | # Callback: Sets the current dictionary (equivalent to ';setdictionary') | ||
| 14658 | # | ||
| 14659 | # Expected arguments | ||
| 14660 | # (none besides $self) | ||
| 14661 | # | ||
| 14662 | # Return values | ||
| 14663 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 14664 | # object no longer exists | ||
| 14665 | # 1 otherwise | ||
| 14666 | |||
| 14667 | my ($self, $check) = @_; | ||
| 14668 | |||
| 14669 | # Local variables | ||
| 14670 | my ( | ||
| 14671 | $dataRef, $dictName, $dictObj, | ||
| 14672 | @list, @dataList, | ||
| 14673 | ); | ||
| 14674 | |||
| 14675 | # Check for improper arguments | ||
| 14676 | if (defined $check) { | ||
| 14677 | |||
| 14678 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonSet_dict', @_); | ||
| 14679 | } | ||
| 14680 | |||
| 14681 | # Import the currently selected portions of the notebook list | ||
| 14682 | @list = $self->notebookGetSelectedData(); | ||
| 14683 | if (! @list) { | ||
| 14684 | |||
| 14685 | # Nothing selected | ||
| 14686 | return undef; | ||
| 14687 | } | ||
| 14688 | |||
| 14689 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 14690 | # a single row of the list | ||
| 14691 | $dataRef = $list[0]; | ||
| 14692 | @dataList = @$dataRef; | ||
| 14693 | # The dictionary name is the second item of data | ||
| 14694 | $dictName = $dataList[1]; | ||
| 14695 | if (! $dictName) { | ||
| 14696 | |||
| 14697 | # Can't continue | ||
| 14698 | return undef; | ||
| 14699 | } | ||
| 14700 | |||
| 14701 | # Get the dictionary itself | ||
| 14702 | $dictObj = $axmud::CLIENT->ivShow('dictHash', $dictName); | ||
| 14703 | if (! $dictObj) { | ||
| 14704 | |||
| 14705 | # Can't continue | ||
| 14706 | return undef; | ||
| 14707 | } | ||
| 14708 | |||
| 14709 | # Set the dictionary | ||
| 14710 | $self->session->pseudoCmd('setdictionary ' . $dictName, $self->pseudoCmdMode); | ||
| 14711 | |||
| 14712 | # Update the notebook | ||
| 14713 | $self->updateNotebook(); | ||
| 14714 | |||
| 14715 | return 1; | ||
| 14716 | } | ||
| 14717 | |||
| 14718 | sub buttonClone_dict { | ||
| 14719 | |||
| 14720 | # Callback: Clones the selected dictionary (equivalent to ';clonedictionary') | ||
| 14721 | # | ||
| 14722 | # Expected arguments | ||
| 14723 | # (none besides $self) | ||
| 14724 | # | ||
| 14725 | # Return values | ||
| 14726 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 14727 | # object no longer exists | ||
| 14728 | # 1 otherwise | ||
| 14729 | |||
| 14730 | my ($self, $check) = @_; | ||
| 14731 | |||
| 14732 | # Local variables | ||
| 14733 | my ( | ||
| 14734 | $dataRef, $dictName, $dictObj, $cloneName, | ||
| 14735 | @list, @dataList, | ||
| 14736 | ); | ||
| 14737 | |||
| 14738 | # Check for improper arguments | ||
| 14739 | if (defined $check) { | ||
| 14740 | |||
| 14741 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonClone_dict', @_); | ||
| 14742 | } | ||
| 14743 | |||
| 14744 | # Import the currently selected portions of the notebook list | ||
| 14745 | @list = $self->notebookGetSelectedData(); | ||
| 14746 | if (! @list) { | ||
| 14747 | |||
| 14748 | # Nothing selected | ||
| 14749 | return undef; | ||
| 14750 | } | ||
| 14751 | |||
| 14752 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 14753 | # a single row of the list | ||
| 14754 | $dataRef = $list[0]; | ||
| 14755 | @dataList = @$dataRef; | ||
| 14756 | # The dictionary name is the second item of data | ||
| 14757 | $dictName = $dataList[1]; | ||
| 14758 | if (! $dictName) { | ||
| 14759 | |||
| 14760 | # Can't continue | ||
| 14761 | return undef; | ||
| 14762 | } | ||
| 14763 | |||
| 14764 | # Get the dictionary itself | ||
| 14765 | $dictObj = $axmud::CLIENT->ivShow('dictHash', $dictName); | ||
| 14766 | if (! $dictObj) { | ||
| 14767 | |||
| 14768 | # Can't continue | ||
| 14769 | return undef; | ||
| 14770 | } | ||
| 14771 | |||
| 14772 | # Prompt the user for the name of the clone (max 16 chars) | ||
| 14773 | $cloneName = $self->showEntryDialogue( | ||
| 14774 | 'Clone dictionary', | ||
| 14775 | 'Enter a name for the clone (max 16 chars: A-Z a-z _ 0-9)', | ||
| 14776 | 16, # Max chars | ||
| 14777 | ); | ||
| 14778 | |||
| 14779 | if ($cloneName) { | ||
| 14780 | |||
| 14781 | # Clone the dictionary | ||
| 14782 | $self->session->pseudoCmd( | ||
| 14783 | 'clonedictionary ' . $dictName . ' ' . $cloneName, | ||
| 14784 | $self->pseudoCmdMode, | ||
| 14785 | ); | ||
| 14786 | |||
| 14787 | # Update the notebook | ||
| 14788 | $self->updateNotebook(); | ||
| 14789 | } | ||
| 14790 | |||
| 14791 | return 1; | ||
| 14792 | } | ||
| 14793 | |||
| 14794 | sub buttonDelete_dict { | ||
| 14795 | |||
| 14796 | # Callback: Deletes a dictionary (equivalent to ';deletedictionary') | ||
| 14797 | # | ||
| 14798 | # Expected arguments | ||
| 14799 | # (none besides $self) | ||
| 14800 | # | ||
| 14801 | # Return values | ||
| 14802 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 14803 | # object no longer exists | ||
| 14804 | # 1 otherwise | ||
| 14805 | |||
| 14806 | my ($self, $check) = @_; | ||
| 14807 | |||
| 14808 | # Local variables | ||
| 14809 | my ( | ||
| 14810 | $dataRef, $dictName, $dictObj, | ||
| 14811 | @list, @dataList, | ||
| 14812 | ); | ||
| 14813 | |||
| 14814 | # Check for improper arguments | ||
| 14815 | if (defined $check) { | ||
| 14816 | |||
| 14817 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDelete_dict', @_); | ||
| 14818 | } | ||
| 14819 | |||
| 14820 | # Import the currently selected portions of the notebook list | ||
| 14821 | @list = $self->notebookGetSelectedData(); | ||
| 14822 | if (! @list) { | ||
| 14823 | |||
| 14824 | # Nothing selected | ||
| 14825 | return undef; | ||
| 14826 | } | ||
| 14827 | |||
| 14828 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 14829 | # a single row of the list | ||
| 14830 | $dataRef = $list[0]; | ||
| 14831 | @dataList = @$dataRef; | ||
| 14832 | # The dictionary name is the second item of data | ||
| 14833 | $dictName = $dataList[1]; | ||
| 14834 | if (! $dictName) { | ||
| 14835 | |||
| 14836 | # Can't continue | ||
| 14837 | return undef; | ||
| 14838 | } | ||
| 14839 | |||
| 14840 | # Get the dictionary itself | ||
| 14841 | $dictObj = $axmud::CLIENT->ivShow('dictHash', $dictName); | ||
| 14842 | if (! $dictObj) { | ||
| 14843 | |||
| 14844 | # Can't continue | ||
| 14845 | return undef; | ||
| 14846 | } | ||
| 14847 | |||
| 14848 | # Delete the dictionary | ||
| 14849 | $self->session->pseudoCmd('deletedictionary ' . $dictName, $self->pseudoCmdMode); | ||
| 14850 | |||
| 14851 | # Update the notebook | ||
| 14852 | $self->updateNotebook(); | ||
| 14853 | |||
| 14854 | return 1; | ||
| 14855 | } | ||
| 14856 | |||
| 14857 | sub buttonDump_dict { | ||
| 14858 | |||
| 14859 | # Callback: Displays a list of dictionaries in the 'main' window (equivalent to | ||
| 14860 | # ';listdictionary') | ||
| 14861 | # | ||
| 14862 | # Expected arguments | ||
| 14863 | # (none besides $self) | ||
| 14864 | # | ||
| 14865 | # Return values | ||
| 14866 | # 'undef' on improper arguments | ||
| 14867 | # 1 otherwise | ||
| 14868 | |||
| 14869 | my ($self, $check) = @_; | ||
| 14870 | |||
| 14871 | # Local variables | ||
| 14872 | my ($tab, $slWidget, $ref); | ||
| 14873 | |||
| 14874 | # Check for improper arguments | ||
| 14875 | if (defined $check) { | ||
| 14876 | |||
| 14877 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDump_dict', @_); | ||
| 14878 | } | ||
| 14879 | |||
| 14880 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 14881 | $tab = $self->notebookGetTab(); | ||
| 14882 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 14883 | |||
| 14884 | # Unselect everything in the list | ||
| 14885 | $slWidget->get_selection->unselect_all(); | ||
| 14886 | |||
| 14887 | # Display the list of dictionaries | ||
| 14888 | $self->session->pseudoCmd('listdictionary', $self->pseudoCmdMode); | ||
| 14889 | |||
| 14890 | return 1; | ||
| 14891 | } | ||
| 14892 | |||
| 14893 | # Tasklist button callbacks - Available tasks | ||
| 14894 | |||
| 14895 | sub buttonStart_availableTask { | ||
| 14896 | |||
| 14897 | # Callback: Starts the selected task (equivalent to ';starttask') | ||
| 14898 | # | ||
| 14899 | # Expected arguments | ||
| 14900 | # (none besides $self) | ||
| 14901 | # | ||
| 14902 | # Return values | ||
| 14903 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 14904 | # 1 otherwise | ||
| 14905 | |||
| 14906 | my ($self, $check) = @_; | ||
| 14907 | |||
| 14908 | # Local variables | ||
| 14909 | my ( | ||
| 14910 | $dataRef, $taskName, | ||
| 14911 | @list, @dataList, | ||
| 14912 | ); | ||
| 14913 | |||
| 14914 | # Check for improper arguments | ||
| 14915 | if (defined $check) { | ||
| 14916 | |||
| 14917 | return $axmud::CLIENT->writeImproper( | ||
| 14918 | $self->_objClass . '->buttonStart_availableTask', | ||
| 14919 | @_, | ||
| 14920 | ); | ||
| 14921 | } | ||
| 14922 | |||
| 14923 | # Import the currently selected portions of the notebook list | ||
| 14924 | @list = $self->notebookGetSelectedData(); | ||
| 14925 | if (! @list) { | ||
| 14926 | |||
| 14927 | # Nothing selected | ||
| 14928 | return undef; | ||
| 14929 | } | ||
| 14930 | |||
| 14931 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 14932 | # a single row of the list | ||
| 14933 | $dataRef = $list[0]; | ||
| 14934 | @dataList = @$dataRef; | ||
| 14935 | # The standard task name is the second item of data | ||
| 14936 | $taskName = $dataList[1]; | ||
| 14937 | if (! $taskName) { | ||
| 14938 | |||
| 14939 | # Can't continue | ||
| 14940 | return undef; | ||
| 14941 | |||
| 14942 | } else { | ||
| 14943 | |||
| 14944 | $self->session->pseudoCmd('starttask ' . $taskName, $self->pseudoCmdMode); | ||
| 14945 | } | ||
| 14946 | |||
| 14947 | return 1; | ||
| 14948 | } | ||
| 14949 | |||
| 14950 | sub buttonStartOptions_availableTask { | ||
| 14951 | |||
| 14952 | # Callback: Starts the selected task after prompting the user to specify task settings | ||
| 14953 | # using a GA::PrefWin::TaskStart window (equivalent to ';starttask <task> <switches>') | ||
| 14954 | # | ||
| 14955 | # Expected arguments | ||
| 14956 | # (none besides $self) | ||
| 14957 | # | ||
| 14958 | # Return values | ||
| 14959 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 14960 | # 1 otherwise | ||
| 14961 | |||
| 14962 | my ($self, $check) = @_; | ||
| 14963 | |||
| 14964 | # Local variables | ||
| 14965 | my ( | ||
| 14966 | $dataRef, $taskName, | ||
| 14967 | @list, @dataList, | ||
| 14968 | ); | ||
| 14969 | |||
| 14970 | # Check for improper arguments | ||
| 14971 | if (defined $check) { | ||
| 14972 | |||
| 14973 | return $axmud::CLIENT->writeImproper( | ||
| 14974 | $self->_objClass . '->buttonStartOptions_availableTask', | ||
| 14975 | @_, | ||
| 14976 | ); | ||
| 14977 | } | ||
| 14978 | |||
| 14979 | # Import the currently selected portions of the notebook list | ||
| 14980 | @list = $self->notebookGetSelectedData(); | ||
| 14981 | if (! @list) { | ||
| 14982 | |||
| 14983 | # Nothing selected | ||
| 14984 | return undef; | ||
| 14985 | } | ||
| 14986 | |||
| 14987 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 14988 | # a single row of the list | ||
| 14989 | $dataRef = $list[0]; | ||
| 14990 | @dataList = @$dataRef; | ||
| 14991 | # The standard task name is the second item of data | ||
| 14992 | $taskName = $dataList[1]; | ||
| 14993 | if (! $taskName) { | ||
| 14994 | |||
| 14995 | # Can't continue | ||
| 14996 | return undef; | ||
| 14997 | |||
| 14998 | } else { | ||
| 14999 | |||
| 15000 | # Open up a task start 'pref' window to specify task settings | ||
| 15001 | $self->createFreeWin( | ||
| 15002 | 'Games::Axmud::PrefWin::TaskStart', | ||
| 15003 | $self, | ||
| 15004 | $self->session, | ||
| 15005 | '\'' . $taskName . '\' task preferences', | ||
| 15006 | undef, # No ->editObj | ||
| 15007 | FALSE, # Not temporary | ||
| 15008 | # Config | ||
| 15009 | 'type' => 'current', # Current tasklist | ||
| 15010 | 'task_name' => $taskName, | ||
| 15011 | ); | ||
| 15012 | } | ||
| 15013 | |||
| 15014 | return 1; | ||
| 15015 | } | ||
| 15016 | |||
| 15017 | sub buttonAddInitial_availableTask { | ||
| 15018 | |||
| 15019 | # Callback: Adds a new task to the global initial tasklist after prompting the user to | ||
| 15020 | # specify task settings using a GA::PrefWin::TaskStar window (equivalent to | ||
| 15021 | # ';addinitialtask <task> <switches>') | ||
| 15022 | # | ||
| 15023 | # Expected arguments | ||
| 15024 | # (none besides $self) | ||
| 15025 | # | ||
| 15026 | # Return values | ||
| 15027 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 15028 | # 1 otherwise | ||
| 15029 | |||
| 15030 | my ($self, $check) = @_; | ||
| 15031 | |||
| 15032 | # Local variables | ||
| 15033 | my ( | ||
| 15034 | $dataRef, $taskName, | ||
| 15035 | @list, @dataList, | ||
| 15036 | ); | ||
| 15037 | |||
| 15038 | # Check for improper arguments | ||
| 15039 | if (defined $check) { | ||
| 15040 | |||
| 15041 | return $axmud::CLIENT->writeImproper( | ||
| 15042 | $self->_objClass . '->buttonAddInitial_availableTask', | ||
| 15043 | @_, | ||
| 15044 | ); | ||
| 15045 | } | ||
| 15046 | |||
| 15047 | # Import the currently selected portions of the notebook list | ||
| 15048 | @list = $self->notebookGetSelectedData(); | ||
| 15049 | if (! @list) { | ||
| 15050 | |||
| 15051 | # Nothing selected | ||
| 15052 | return undef; | ||
| 15053 | } | ||
| 15054 | |||
| 15055 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 15056 | # a single row of the list | ||
| 15057 | $dataRef = $list[0]; | ||
| 15058 | @dataList = @$dataRef; | ||
| 15059 | # The standard task name is the second item of data | ||
| 15060 | $taskName = $dataList[1]; | ||
| 15061 | if (! $taskName) { | ||
| 15062 | |||
| 15063 | # Can't continue | ||
| 15064 | return undef; | ||
| 15065 | |||
| 15066 | } else { | ||
| 15067 | |||
| 15068 | # Open up a task start 'pref' window to specify task settings | ||
| 15069 | $self->createFreeWin( | ||
| 15070 | 'Games::Axmud::PrefWin::TaskStart', | ||
| 15071 | $self, | ||
| 15072 | $self->session, | ||
| 15073 | '\'' . $taskName . '\' task preferences', | ||
| 15074 | undef, # No ->editObj | ||
| 15075 | FALSE, # Not temporary | ||
| 15076 | # Config | ||
| 15077 | 'type' => 'global_initial', # Global initial tasklist | ||
| 15078 | 'task_name' => $taskName, | ||
| 15079 | ); | ||
| 15080 | } | ||
| 15081 | |||
| 15082 | return 1; | ||
| 15083 | } | ||
| 15084 | |||
| 15085 | sub buttonAddCustom_availableTask { | ||
| 15086 | |||
| 15087 | # Callback: Adds a new task to the custom tasklist after prompting the user to specify task | ||
| 15088 | # settings using a GA::PrefWin::TaskStar window (equivalent to | ||
| 15089 | # ';addcustomtask <task> <name> <switches>') | ||
| 15090 | # | ||
| 15091 | # Expected arguments | ||
| 15092 | # (none besides $self) | ||
| 15093 | # | ||
| 15094 | # Return values | ||
| 15095 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 15096 | # 1 otherwise | ||
| 15097 | |||
| 15098 | my ($self, $check) = @_; | ||
| 15099 | |||
| 15100 | # Local variables | ||
| 15101 | my ( | ||
| 15102 | $dataRef, $taskName, | ||
| 15103 | @list, @dataList, | ||
| 15104 | ); | ||
| 15105 | |||
| 15106 | # Check for improper arguments | ||
| 15107 | if (defined $check) { | ||
| 15108 | |||
| 15109 | return $axmud::CLIENT->writeImproper( | ||
| 15110 | $self->_objClass . '->buttonAddCustom_availableTask', | ||
| 15111 | @_, | ||
| 15112 | ); | ||
| 15113 | } | ||
| 15114 | |||
| 15115 | # Import the currently selected portions of the notebook list | ||
| 15116 | @list = $self->notebookGetSelectedData(); | ||
| 15117 | if (! @list) { | ||
| 15118 | |||
| 15119 | # Nothing selected | ||
| 15120 | return undef; | ||
| 15121 | } | ||
| 15122 | |||
| 15123 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 15124 | # a single row of the list | ||
| 15125 | $dataRef = $list[0]; | ||
| 15126 | @dataList = @$dataRef; | ||
| 15127 | # The standard task name is the second item of data | ||
| 15128 | $taskName = $dataList[1]; | ||
| 15129 | if (! $taskName) { | ||
| 15130 | |||
| 15131 | # Can't continue | ||
| 15132 | return undef; | ||
| 15133 | |||
| 15134 | } else { | ||
| 15135 | |||
| 15136 | # Open up a task start 'pref' window to specify task settings | ||
| 15137 | $self->createFreeWin( | ||
| 15138 | 'Games::Axmud::PrefWin::TaskStart', | ||
| 15139 | $self, | ||
| 15140 | $self->session, | ||
| 15141 | '\'' . $taskName . '\' task preferences', | ||
| 15142 | undef, # No ->editObj | ||
| 15143 | FALSE, # Not temporary | ||
| 15144 | # Config | ||
| 15145 | 'type' => 'custom', # Custom tasklist | ||
| 15146 | 'task_name' => $taskName, | ||
| 15147 | ); | ||
| 15148 | } | ||
| 15149 | |||
| 15150 | return 1; | ||
| 15151 | } | ||
| 15152 | |||
| 15153 | sub buttonHalt_availableTask { | ||
| 15154 | |||
| 15155 | # Callback: Halts gracefully all copies of the selected task (equivalent to | ||
| 15156 | # ';halttask <task>') | ||
| 15157 | # | ||
| 15158 | # Expected arguments | ||
| 15159 | # (none besides $self) | ||
| 15160 | # | ||
| 15161 | # Return values | ||
| 15162 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 15163 | # 1 otherwise | ||
| 15164 | |||
| 15165 | my ($self, $check) = @_; | ||
| 15166 | |||
| 15167 | # Local variables | ||
| 15168 | my ( | ||
| 15169 | $dataRef, $taskName, | ||
| 15170 | @list, @dataList, | ||
| 15171 | ); | ||
| 15172 | |||
| 15173 | # Check for improper arguments | ||
| 15174 | if (defined $check) { | ||
| 15175 | |||
| 15176 | return $axmud::CLIENT->writeImproper( | ||
| 15177 | $self->_objClass . '->buttonHalt_availableTask', | ||
| 15178 | @_, | ||
| 15179 | ); | ||
| 15180 | } | ||
| 15181 | |||
| 15182 | # Import the currently selected portions of the notebook list | ||
| 15183 | @list = $self->notebookGetSelectedData(); | ||
| 15184 | if (! @list) { | ||
| 15185 | |||
| 15186 | # Nothing selected | ||
| 15187 | return undef; | ||
| 15188 | } | ||
| 15189 | |||
| 15190 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 15191 | # a single row of the list | ||
| 15192 | $dataRef = $list[0]; | ||
| 15193 | @dataList = @$dataRef; | ||
| 15194 | # The standard task name is the second item of data | ||
| 15195 | $taskName = $dataList[1]; | ||
| 15196 | if (! $taskName) { | ||
| 15197 | |||
| 15198 | # Can't continue | ||
| 15199 | return undef; | ||
| 15200 | |||
| 15201 | } else { | ||
| 15202 | |||
| 15203 | # Halt gracefully all copies of this task | ||
| 15204 | $self->session->pseudoCmd('halttask ' . $taskName, $self->pseudoCmdMode); | ||
| 15205 | |||
| 15206 | # Update the notebook | ||
| 15207 | $self->updateNotebook(); | ||
| 15208 | } | ||
| 15209 | |||
| 15210 | return 1; | ||
| 15211 | } | ||
| 15212 | |||
| 15213 | sub buttonKill_availableTask { | ||
| 15214 | |||
| 15215 | # Callback: Kills all copies of the selected task (equivalent to ';killtask <task>') | ||
| 15216 | # | ||
| 15217 | # Expected arguments | ||
| 15218 | # (none besides $self) | ||
| 15219 | # | ||
| 15220 | # Return values | ||
| 15221 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 15222 | # 1 otherwise | ||
| 15223 | |||
| 15224 | my ($self, $check) = @_; | ||
| 15225 | |||
| 15226 | # Local variables | ||
| 15227 | my ( | ||
| 15228 | $dataRef, $taskName, | ||
| 15229 | @list, @dataList, | ||
| 15230 | ); | ||
| 15231 | |||
| 15232 | # Check for improper arguments | ||
| 15233 | if (defined $check) { | ||
| 15234 | |||
| 15235 | return $axmud::CLIENT->writeImproper( | ||
| 15236 | $self->_objClass . '->buttonKill_availableTask', | ||
| 15237 | @_, | ||
| 15238 | ); | ||
| 15239 | } | ||
| 15240 | |||
| 15241 | # Import the currently selected portions of the notebook list | ||
| 15242 | @list = $self->notebookGetSelectedData(); | ||
| 15243 | if (! @list) { | ||
| 15244 | |||
| 15245 | # Nothing selected | ||
| 15246 | return undef; | ||
| 15247 | } | ||
| 15248 | |||
| 15249 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 15250 | # a single row of the list | ||
| 15251 | $dataRef = $list[0]; | ||
| 15252 | @dataList = @$dataRef; | ||
| 15253 | # The standard task name is the second item of data | ||
| 15254 | $taskName = $dataList[1]; | ||
| 15255 | if (! $taskName) { | ||
| 15256 | |||
| 15257 | # Can't continue | ||
| 15258 | return undef; | ||
| 15259 | |||
| 15260 | } else { | ||
| 15261 | |||
| 15262 | # Kill all copies of this task | ||
| 15263 | $self->session->pseudoCmd('killtask ' . $taskName, $self->pseudoCmdMode); | ||
| 15264 | |||
| 15265 | # Update the notebook | ||
| 15266 | $self->updateNotebook(); | ||
| 15267 | } | ||
| 15268 | |||
| 15269 | return 1; | ||
| 15270 | } | ||
| 15271 | |||
| 15272 | sub buttonPause_availableTask { | ||
| 15273 | |||
| 15274 | # Callback: Pauses all copies of the selected task (equivalent to ';pausetask <task>') | ||
| 15275 | # | ||
| 15276 | # Expected arguments | ||
| 15277 | # (none besides $self) | ||
| 15278 | # | ||
| 15279 | # Return values | ||
| 15280 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 15281 | # 1 otherwise | ||
| 15282 | |||
| 15283 | my ($self, $check) = @_; | ||
| 15284 | |||
| 15285 | # Local variables | ||
| 15286 | my ( | ||
| 15287 | $dataRef, $taskName, | ||
| 15288 | @list, @dataList, | ||
| 15289 | ); | ||
| 15290 | |||
| 15291 | # Check for improper arguments | ||
| 15292 | if (defined $check) { | ||
| 15293 | |||
| 15294 | return $axmud::CLIENT->writeImproper( | ||
| 15295 | $self->_objClass . '->buttonPause_availableTask', | ||
| 15296 | @_, | ||
| 15297 | ); | ||
| 15298 | } | ||
| 15299 | |||
| 15300 | # Import the currently selected portions of the notebook list | ||
| 15301 | @list = $self->notebookGetSelectedData(); | ||
| 15302 | if (! @list) { | ||
| 15303 | |||
| 15304 | # Nothing selected | ||
| 15305 | return undef; | ||
| 15306 | } | ||
| 15307 | |||
| 15308 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 15309 | # a single row of the list | ||
| 15310 | $dataRef = $list[0]; | ||
| 15311 | @dataList = @$dataRef; | ||
| 15312 | # The standard task name is the second item of data | ||
| 15313 | $taskName = $dataList[1]; | ||
| 15314 | if (! $taskName) { | ||
| 15315 | |||
| 15316 | # Can't continue | ||
| 15317 | return undef; | ||
| 15318 | |||
| 15319 | } else { | ||
| 15320 | |||
| 15321 | # Pause all copies of this task | ||
| 15322 | $self->session->pseudoCmd('pausetask ' . $taskName, $self->pseudoCmdMode); | ||
| 15323 | |||
| 15324 | # Update the notebook | ||
| 15325 | $self->updateNotebook(); | ||
| 15326 | } | ||
| 15327 | |||
| 15328 | return 1; | ||
| 15329 | } | ||
| 15330 | |||
| 15331 | sub buttonSafeResume_task { | ||
| 15332 | |||
| 15333 | # Callback: Resumes all tasks safely (equivalent to ';resumetask') | ||
| 15334 | # | ||
| 15335 | # Expected arguments | ||
| 15336 | # (none besides $self) | ||
| 15337 | # | ||
| 15338 | # Return values | ||
| 15339 | # 'undef' on improper arguments | ||
| 15340 | # 1 otherwise | ||
| 15341 | |||
| 15342 | my ($self, $check) = @_; | ||
| 15343 | |||
| 15344 | # Local variables | ||
| 15345 | my ($tab, $slWidget); | ||
| 15346 | |||
| 15347 | # Check for improper arguments | ||
| 15348 | if (defined $check) { | ||
| 15349 | |||
| 15350 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonSafeResume_task', @_); | ||
| 15351 | } | ||
| 15352 | |||
| 15353 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 15354 | $tab = $self->notebookGetTab(); | ||
| 15355 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 15356 | |||
| 15357 | # Unselect everything in the list | ||
| 15358 | $slWidget->get_selection->unselect_all(); | ||
| 15359 | |||
| 15360 | # Reumse paused tasks | ||
| 15361 | $self->session->pseudoCmd('resumetask', $self->pseudoCmdMode); | ||
| 15362 | |||
| 15363 | # Update the notebook | ||
| 15364 | $self->updateNotebook(); | ||
| 15365 | |||
| 15366 | return 1; | ||
| 15367 | } | ||
| 15368 | |||
| 15369 | sub buttonReset_availableTask { | ||
| 15370 | |||
| 15371 | # Callback: Resets all copies of the selected task (equivalent to ';resettask <task>') | ||
| 15372 | # | ||
| 15373 | # Expected arguments | ||
| 15374 | # (none besides $self) | ||
| 15375 | # | ||
| 15376 | # Return values | ||
| 15377 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 15378 | # 1 otherwise | ||
| 15379 | |||
| 15380 | my ($self, $check) = @_; | ||
| 15381 | |||
| 15382 | # Local variables | ||
| 15383 | my ( | ||
| 15384 | $dataRef, $taskName, | ||
| 15385 | @list, @dataList, | ||
| 15386 | ); | ||
| 15387 | |||
| 15388 | # Check for improper arguments | ||
| 15389 | if (defined $check) { | ||
| 15390 | |||
| 15391 | return $axmud::CLIENT->writeImproper( | ||
| 15392 | $self->_objClass . '->buttonReset_availableTask', | ||
| 15393 | @_, | ||
| 15394 | ); | ||
| 15395 | } | ||
| 15396 | |||
| 15397 | # Import the currently selected portions of the notebook list | ||
| 15398 | @list = $self->notebookGetSelectedData(); | ||
| 15399 | if (! @list) { | ||
| 15400 | |||
| 15401 | # Nothing selected | ||
| 15402 | return undef; | ||
| 15403 | } | ||
| 15404 | |||
| 15405 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 15406 | # a single row of the list | ||
| 15407 | $dataRef = $list[0]; | ||
| 15408 | @dataList = @$dataRef; | ||
| 15409 | # The standard task name is the second item of data | ||
| 15410 | $taskName = $dataList[1]; | ||
| 15411 | if (! $taskName) { | ||
| 15412 | |||
| 15413 | # Can't continue | ||
| 15414 | return undef; | ||
| 15415 | |||
| 15416 | } else { | ||
| 15417 | |||
| 15418 | # Pause all copies of this task | ||
| 15419 | $self->session->pseudoCmd('resettask ' . $taskName, $self->pseudoCmdMode); | ||
| 15420 | |||
| 15421 | # Update the notebook | ||
| 15422 | $self->updateNotebook(); | ||
| 15423 | } | ||
| 15424 | |||
| 15425 | return 1; | ||
| 15426 | } | ||
| 15427 | |||
| 15428 | sub buttonHelp_availableTask { | ||
| 15429 | |||
| 15430 | # Callback: Shows help for the selected task (equivalent to ';taskhelp <task>') | ||
| 15431 | # | ||
| 15432 | # Expected arguments | ||
| 15433 | # (none besides $self) | ||
| 15434 | # | ||
| 15435 | # Return values | ||
| 15436 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 15437 | # 1 otherwise | ||
| 15438 | |||
| 15439 | my ($self, $check) = @_; | ||
| 15440 | |||
| 15441 | # Local variables | ||
| 15442 | my ( | ||
| 15443 | $dataRef, $taskName, | ||
| 15444 | @list, @dataList, | ||
| 15445 | ); | ||
| 15446 | |||
| 15447 | # Check for improper arguments | ||
| 15448 | if (defined $check) { | ||
| 15449 | |||
| 15450 | return $axmud::CLIENT->writeImproper( | ||
| 15451 | $self->_objClass . '->buttonHelp_availableTask', | ||
| 15452 | @_, | ||
| 15453 | ); | ||
| 15454 | } | ||
| 15455 | |||
| 15456 | # Import the currently selected portions of the notebook list | ||
| 15457 | @list = $self->notebookGetSelectedData(); | ||
| 15458 | if (! @list) { | ||
| 15459 | |||
| 15460 | # Nothing selected | ||
| 15461 | return undef; | ||
| 15462 | } | ||
| 15463 | |||
| 15464 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 15465 | # a single row of the list | ||
| 15466 | $dataRef = $list[0]; | ||
| 15467 | @dataList = @$dataRef; | ||
| 15468 | # The standard task name is the second item of data | ||
| 15469 | $taskName = $dataList[1]; | ||
| 15470 | if (! $taskName) { | ||
| 15471 | |||
| 15472 | # Can't continue | ||
| 15473 | return undef; | ||
| 15474 | |||
| 15475 | } else { | ||
| 15476 | |||
| 15477 | # Pause all copies of this task | ||
| 15478 | $self->session->pseudoCmd('taskhelp ' . $taskName, $self->pseudoCmdMode); | ||
| 15479 | |||
| 15480 | # Update the notebook | ||
| 15481 | $self->updateNotebook(); | ||
| 15482 | } | ||
| 15483 | |||
| 15484 | return 1; | ||
| 15485 | } | ||
| 15486 | |||
| 15487 | # Tasklist button callbacks - Current tasklist | ||
| 15488 | |||
| 15489 | sub buttonEdit_task { | ||
| 15490 | |||
| 15491 | # Callback: Edits the selected task (equivalent to ';edittask') | ||
| 15492 | # | ||
| 15493 | # Expected arguments | ||
| 15494 | # (none besides $self) | ||
| 15495 | # | ||
| 15496 | # Return values | ||
| 15497 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 15498 | # object no longer exists | ||
| 15499 | # 1 otherwise | ||
| 15500 | |||
| 15501 | my ($self, $check) = @_; | ||
| 15502 | |||
| 15503 | # Local variables | ||
| 15504 | my ( | ||
| 15505 | $dataRef, $taskName, $taskObj, | ||
| 15506 | @list, @dataList, | ||
| 15507 | ); | ||
| 15508 | |||
| 15509 | # Check for improper arguments | ||
| 15510 | if (defined $check) { | ||
| 15511 | |||
| 15512 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonEdit_task', @_); | ||
| 15513 | } | ||
| 15514 | |||
| 15515 | # Import the currently selected portions of the notebook list | ||
| 15516 | @list = $self->notebookGetSelectedData(); | ||
| 15517 | if (! @list) { | ||
| 15518 | |||
| 15519 | # Nothing selected | ||
| 15520 | return undef; | ||
| 15521 | } | ||
| 15522 | |||
| 15523 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 15524 | # a single row of the list | ||
| 15525 | $dataRef = $list[0]; | ||
| 15526 | @dataList = @$dataRef; | ||
| 15527 | # The unique task name is the first item of data | ||
| 15528 | $taskName = $dataList[0]; | ||
| 15529 | if (! $taskName) { | ||
| 15530 | |||
| 15531 | # Can't continue | ||
| 15532 | return undef; | ||
| 15533 | } | ||
| 15534 | |||
| 15535 | # Get the task reference itself | ||
| 15536 | $taskObj = $self->session->ivShow('currentTaskHash', $taskName); | ||
| 15537 | if (! $taskObj) { | ||
| 15538 | |||
| 15539 | # Can't continue | ||
| 15540 | return undef; | ||
| 15541 | |||
| 15542 | } else { | ||
| 15543 | |||
| 15544 | # Open up an 'edit' window to edit the object | ||
| 15545 | $self->createFreeWin( | ||
| 15546 | 'Games::Axmud::EditWin::Task', | ||
| 15547 | $self, | ||
| 15548 | $self->session, | ||
| 15549 | 'Edit ' . $taskObj->prettyName . ' task', | ||
| 15550 | $taskObj, | ||
| 15551 | FALSE, # Not temporary | ||
| 15552 | # Config | ||
| 15553 | 'edit_flag' => FALSE, # Some IVs for current tasks not editable | ||
| 15554 | ); | ||
| 15555 | |||
| 15556 | return 1; | ||
| 15557 | } | ||
| 15558 | } | ||
| 15559 | |||
| 15560 | sub buttonHalt_task { | ||
| 15561 | |||
| 15562 | # Callback: Halts the selected task gracefully (equivalent to ';halttask') | ||
| 15563 | # | ||
| 15564 | # Expected arguments | ||
| 15565 | # (none besides $self) | ||
| 15566 | # | ||
| 15567 | # Return values | ||
| 15568 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 15569 | # object no longer exists | ||
| 15570 | # 1 otherwise | ||
| 15571 | |||
| 15572 | my ($self, $check) = @_; | ||
| 15573 | |||
| 15574 | # Local variables | ||
| 15575 | my ( | ||
| 15576 | $dataRef, $taskName, | ||
| 15577 | @list, @dataList, | ||
| 15578 | ); | ||
| 15579 | |||
| 15580 | # Check for improper arguments | ||
| 15581 | if (defined $check) { | ||
| 15582 | |||
| 15583 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonHalt_task', @_); | ||
| 15584 | } | ||
| 15585 | |||
| 15586 | # Import the currently selected portions of the notebook list | ||
| 15587 | @list = $self->notebookGetSelectedData(); | ||
| 15588 | if (! @list) { | ||
| 15589 | |||
| 15590 | # Nothing selected | ||
| 15591 | return undef; | ||
| 15592 | } | ||
| 15593 | |||
| 15594 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 15595 | # a single row of the list | ||
| 15596 | $dataRef = $list[0]; | ||
| 15597 | @dataList = @$dataRef; | ||
| 15598 | # The unique task name is the first item of data | ||
| 15599 | $taskName = $dataList[0]; | ||
| 15600 | if (! $taskName) { | ||
| 15601 | |||
| 15602 | # Can't continue | ||
| 15603 | return undef; | ||
| 15604 | |||
| 15605 | } else { | ||
| 15606 | |||
| 15607 | # Halt the task | ||
| 15608 | $self->session->pseudoCmd('halttask ' . $taskName, $self->pseudoCmdMode); | ||
| 15609 | |||
| 15610 | # Update the notebook | ||
| 15611 | $self->updateNotebook(); | ||
| 15612 | } | ||
| 15613 | |||
| 15614 | return 1; | ||
| 15615 | } | ||
| 15616 | |||
| 15617 | sub buttonHaltAll_task { | ||
| 15618 | |||
| 15619 | # Callback: Halts all tasks gracefully (equivalent to ';halttask -a') | ||
| 15620 | # | ||
| 15621 | # Expected arguments | ||
| 15622 | # (none besides $self) | ||
| 15623 | # | ||
| 15624 | # Return values | ||
| 15625 | # 'undef' on improper arguments | ||
| 15626 | # 1 otherwise | ||
| 15627 | |||
| 15628 | my ($self, $check) = @_; | ||
| 15629 | |||
| 15630 | # Local variables | ||
| 15631 | my ($tab, $slWidget); | ||
| 15632 | |||
| 15633 | # Check for improper arguments | ||
| 15634 | if (defined $check) { | ||
| 15635 | |||
| 15636 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonHaltAll_task', @_); | ||
| 15637 | } | ||
| 15638 | |||
| 15639 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 15640 | $tab = $self->notebookGetTab(); | ||
| 15641 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 15642 | |||
| 15643 | # Unselect everything in the list | ||
| 15644 | $slWidget->get_selection->unselect_all(); | ||
| 15645 | |||
| 15646 | # Halt all tasks | ||
| 15647 | $self->session->pseudoCmd('halttask -a', $self->pseudoCmdMode); | ||
| 15648 | |||
| 15649 | # Update the notebook | ||
| 15650 | $self->updateNotebook(); | ||
| 15651 | |||
| 15652 | return 1; | ||
| 15653 | } | ||
| 15654 | |||
| 15655 | sub buttonKill_task { | ||
| 15656 | |||
| 15657 | # Callback: Kills the selected task immediately (equivalent to ';killtask') | ||
| 15658 | # | ||
| 15659 | # Expected arguments | ||
| 15660 | # (none besides $self) | ||
| 15661 | # | ||
| 15662 | # Return values | ||
| 15663 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 15664 | # object no longer exists | ||
| 15665 | # 1 otherwise | ||
| 15666 | |||
| 15667 | my ($self, $check) = @_; | ||
| 15668 | |||
| 15669 | # Local variables | ||
| 15670 | my ( | ||
| 15671 | $dataRef, $taskName, | ||
| 15672 | @list, @dataList, | ||
| 15673 | ); | ||
| 15674 | |||
| 15675 | # Check for improper arguments | ||
| 15676 | if (defined $check) { | ||
| 15677 | |||
| 15678 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonKill_task', @_); | ||
| 15679 | } | ||
| 15680 | |||
| 15681 | # Import the currently selected portions of the notebook list | ||
| 15682 | @list = $self->notebookGetSelectedData(); | ||
| 15683 | if (! @list) { | ||
| 15684 | |||
| 15685 | # Nothing selected | ||
| 15686 | return undef; | ||
| 15687 | } | ||
| 15688 | |||
| 15689 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 15690 | # a single row of the list | ||
| 15691 | $dataRef = $list[0]; | ||
| 15692 | @dataList = @$dataRef; | ||
| 15693 | # The unique task name is the first item of data | ||
| 15694 | $taskName = $dataList[0]; | ||
| 15695 | if (! $taskName) { | ||
| 15696 | |||
| 15697 | # Can't continue | ||
| 15698 | return undef; | ||
| 15699 | |||
| 15700 | } else { | ||
| 15701 | |||
| 15702 | # Kill the task | ||
| 15703 | $self->session->pseudoCmd('killtask ' . $taskName, $self->pseudoCmdMode); | ||
| 15704 | |||
| 15705 | # Update the notebook | ||
| 15706 | $self->updateNotebook(); | ||
| 15707 | } | ||
| 15708 | |||
| 15709 | return 1; | ||
| 15710 | } | ||
| 15711 | |||
| 15712 | sub buttonKillAll_task { | ||
| 15713 | |||
| 15714 | # Callback: Kills all tasks immediately (equivalent to ';killtask -a') | ||
| 15715 | # | ||
| 15716 | # Expected arguments | ||
| 15717 | # (none besides $self) | ||
| 15718 | # | ||
| 15719 | # Return values | ||
| 15720 | # 'undef' on improper arguments | ||
| 15721 | # 1 otherwise | ||
| 15722 | |||
| 15723 | my ($self, $check) = @_; | ||
| 15724 | |||
| 15725 | # Local variables | ||
| 15726 | my ($tab, $slWidget); | ||
| 15727 | |||
| 15728 | # Check for improper arguments | ||
| 15729 | if (defined $check) { | ||
| 15730 | |||
| 15731 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonKillAll_task', @_); | ||
| 15732 | } | ||
| 15733 | |||
| 15734 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 15735 | $tab = $self->notebookGetTab(); | ||
| 15736 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 15737 | |||
| 15738 | # Unselect everything in the list | ||
| 15739 | $slWidget->get_selection->unselect_all(); | ||
| 15740 | |||
| 15741 | # Halt all tasks | ||
| 15742 | $self->session->pseudoCmd('killtask -a', $self->pseudoCmdMode); | ||
| 15743 | |||
| 15744 | # Update the notebook | ||
| 15745 | $self->updateNotebook(); | ||
| 15746 | |||
| 15747 | return 1; | ||
| 15748 | } | ||
| 15749 | |||
| 15750 | sub buttonPause_task { | ||
| 15751 | |||
| 15752 | # Callback: Pauses the selected task (equivalent to ';pausetask') | ||
| 15753 | # | ||
| 15754 | # Expected arguments | ||
| 15755 | # (none besides $self) | ||
| 15756 | # | ||
| 15757 | # Return values | ||
| 15758 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 15759 | # object no longer exists | ||
| 15760 | # 1 otherwise | ||
| 15761 | |||
| 15762 | my ($self, $check) = @_; | ||
| 15763 | |||
| 15764 | # Local variables | ||
| 15765 | my ( | ||
| 15766 | $dataRef, $taskName, | ||
| 15767 | @list, @dataList, | ||
| 15768 | ); | ||
| 15769 | |||
| 15770 | # Check for improper arguments | ||
| 15771 | if (defined $check) { | ||
| 15772 | |||
| 15773 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonPause_task', @_); | ||
| 15774 | } | ||
| 15775 | |||
| 15776 | # Import the currently selected portions of the notebook list | ||
| 15777 | @list = $self->notebookGetSelectedData(); | ||
| 15778 | if (! @list) { | ||
| 15779 | |||
| 15780 | # Nothing selected | ||
| 15781 | return undef; | ||
| 15782 | } | ||
| 15783 | |||
| 15784 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 15785 | # a single row of the list | ||
| 15786 | $dataRef = $list[0]; | ||
| 15787 | @dataList = @$dataRef; | ||
| 15788 | # The unique task name is the first item of data | ||
| 15789 | $taskName = $dataList[0]; | ||
| 15790 | if (! $taskName) { | ||
| 15791 | |||
| 15792 | # Can't continue | ||
| 15793 | return undef; | ||
| 15794 | |||
| 15795 | } else { | ||
| 15796 | |||
| 15797 | # Pause the task | ||
| 15798 | $self->session->pseudoCmd('pausetask ' . $taskName, $self->pseudoCmdMode); | ||
| 15799 | |||
| 15800 | # Update the notebook | ||
| 15801 | $self->updateNotebook(); | ||
| 15802 | } | ||
| 15803 | |||
| 15804 | return 1; | ||
| 15805 | } | ||
| 15806 | |||
| 15807 | sub buttonPauseAll_task { | ||
| 15808 | |||
| 15809 | # Callback: Pauses all tasks (equivalent to ';pausetask -a') | ||
| 15810 | # | ||
| 15811 | # Expected arguments | ||
| 15812 | # (none besides $self) | ||
| 15813 | # | ||
| 15814 | # Return values | ||
| 15815 | # 'undef' on improper arguments | ||
| 15816 | # 1 otherwise | ||
| 15817 | |||
| 15818 | my ($self, $check) = @_; | ||
| 15819 | |||
| 15820 | # Local variables | ||
| 15821 | my ($tab, $slWidget, $ref); | ||
| 15822 | |||
| 15823 | # Check for improper arguments | ||
| 15824 | if (defined $check) { | ||
| 15825 | |||
| 15826 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonPauseAll_task', @_); | ||
| 15827 | } | ||
| 15828 | |||
| 15829 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 15830 | $tab = $self->notebookGetTab(); | ||
| 15831 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 15832 | |||
| 15833 | # Unselect everything in the list | ||
| 15834 | $slWidget->get_selection->unselect_all(); | ||
| 15835 | |||
| 15836 | # Pause all tasks | ||
| 15837 | $self->session->pseudoCmd('pausetask -a', $self->pseudoCmdMode); | ||
| 15838 | |||
| 15839 | # Update the notebook | ||
| 15840 | $self->updateNotebook(); | ||
| 15841 | |||
| 15842 | return 1; | ||
| 15843 | } | ||
| 15844 | |||
| 15845 | sub buttonReset_task { | ||
| 15846 | |||
| 15847 | # Callback: Resets the selected task (equivalent to ';resettask') | ||
| 15848 | # | ||
| 15849 | # Expected arguments | ||
| 15850 | # (none besides $self) | ||
| 15851 | # | ||
| 15852 | # Return values | ||
| 15853 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 15854 | # 1 otherwise | ||
| 15855 | |||
| 15856 | my ($self, $check) = @_; | ||
| 15857 | |||
| 15858 | # Local variables | ||
| 15859 | my ( | ||
| 15860 | $dataRef, $taskName, | ||
| 15861 | @list, @dataList, | ||
| 15862 | ); | ||
| 15863 | |||
| 15864 | # Check for improper arguments | ||
| 15865 | if (defined $check) { | ||
| 15866 | |||
| 15867 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonReset_task', @_); | ||
| 15868 | } | ||
| 15869 | |||
| 15870 | # Import the currently selected portions of the notebook list | ||
| 15871 | @list = $self->notebookGetSelectedData(); | ||
| 15872 | if (! @list) { | ||
| 15873 | |||
| 15874 | # Nothing selected | ||
| 15875 | return undef; | ||
| 15876 | } | ||
| 15877 | |||
| 15878 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 15879 | # a single row of the list | ||
| 15880 | $dataRef = $list[0]; | ||
| 15881 | @dataList = @$dataRef; | ||
| 15882 | # The unique task name is the first item of data | ||
| 15883 | $taskName = $dataList[0]; | ||
| 15884 | if (! $taskName) { | ||
| 15885 | |||
| 15886 | # Can't continue | ||
| 15887 | return undef; | ||
| 15888 | |||
| 15889 | } else { | ||
| 15890 | |||
| 15891 | # Reset the task | ||
| 15892 | $self->session->pseudoCmd('resettask ' . $taskName, $self->pseudoCmdMode); | ||
| 15893 | |||
| 15894 | # Update the notebook | ||
| 15895 | $self->updateNotebook(); | ||
| 15896 | } | ||
| 15897 | |||
| 15898 | return 1; | ||
| 15899 | } | ||
| 15900 | |||
| 15901 | sub buttonResetAll_task { | ||
| 15902 | |||
| 15903 | # Callback: Resets all tasks (equivalent to ';resettask -a') | ||
| 15904 | # | ||
| 15905 | # Expected arguments | ||
| 15906 | # (none besides $self) | ||
| 15907 | # | ||
| 15908 | # Return values | ||
| 15909 | # 'undef' on improper arguments | ||
| 15910 | # 1 otherwise | ||
| 15911 | |||
| 15912 | my ($self, $check) = @_; | ||
| 15913 | |||
| 15914 | # Local variables | ||
| 15915 | my ($tab, $slWidget); | ||
| 15916 | |||
| 15917 | # Check for improper arguments | ||
| 15918 | if (defined $check) { | ||
| 15919 | |||
| 15920 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonResetAll_task', @_); | ||
| 15921 | } | ||
| 15922 | |||
| 15923 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 15924 | $tab = $self->notebookGetTab(); | ||
| 15925 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 15926 | |||
| 15927 | # Unselect everything in the list | ||
| 15928 | $slWidget->get_selection->unselect_all(); | ||
| 15929 | |||
| 15930 | # Halt all tasks | ||
| 15931 | $self->session->pseudoCmd('resettask -a', $self->pseudoCmdMode); | ||
| 15932 | |||
| 15933 | # Update the notebook | ||
| 15934 | $self->updateNotebook(); | ||
| 15935 | |||
| 15936 | return 1; | ||
| 15937 | } | ||
| 15938 | |||
| 15939 | sub buttonFreezeAll_task { | ||
| 15940 | |||
| 15941 | # Callback: Freezes (or unfreezes) all tasks immediately (equivalent to ';freezetask') | ||
| 15942 | # | ||
| 15943 | # Expected arguments | ||
| 15944 | # (none besides $self) | ||
| 15945 | # | ||
| 15946 | # Return values | ||
| 15947 | # 'undef' on improper arguments | ||
| 15948 | # 1 otherwise | ||
| 15949 | |||
| 15950 | my ($self, $check) = @_; | ||
| 15951 | |||
| 15952 | # Local variables | ||
| 15953 | my ($tab, $slWidget); | ||
| 15954 | |||
| 15955 | # Check for improper arguments | ||
| 15956 | if (defined $check) { | ||
| 15957 | |||
| 15958 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonFreezeAll_task', @_); | ||
| 15959 | } | ||
| 15960 | |||
| 15961 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 15962 | $tab = $self->notebookGetTab(); | ||
| 15963 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 15964 | |||
| 15965 | # Unselect everything in the list | ||
| 15966 | $slWidget->get_selection->unselect_all(); | ||
| 15967 | |||
| 15968 | # Freeze/unfreeze all tasks | ||
| 15969 | $self->session->pseudoCmd('freezetask', $self->pseudoCmdMode); | ||
| 15970 | |||
| 15971 | # Update the notebook | ||
| 15972 | $self->updateNotebook(); | ||
| 15973 | |||
| 15974 | return 1; | ||
| 15975 | } | ||
| 15976 | |||
| 15977 | sub buttonDump_task { | ||
| 15978 | |||
| 15979 | # Callback: Displays the list of running tasks in the 'main' window (equivalent to | ||
| 15980 | # ';listtask') | ||
| 15981 | # | ||
| 15982 | # Expected arguments | ||
| 15983 | # (none besides $self) | ||
| 15984 | # | ||
| 15985 | # Return values | ||
| 15986 | # 'undef' on improper arguments | ||
| 15987 | # 1 otherwise | ||
| 15988 | |||
| 15989 | my ($self, $check) = @_; | ||
| 15990 | |||
| 15991 | # Local variables | ||
| 15992 | my ($tab, $slWidget); | ||
| 15993 | |||
| 15994 | # Check for improper arguments | ||
| 15995 | if (defined $check) { | ||
| 15996 | |||
| 15997 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDump_task', @_); | ||
| 15998 | } | ||
| 15999 | |||
| 16000 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 16001 | $tab = $self->notebookGetTab(); | ||
| 16002 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 16003 | |||
| 16004 | # Unselect everything in the list | ||
| 16005 | $slWidget->get_selection->unselect_all(); | ||
| 16006 | |||
| 16007 | # Display list of tasks | ||
| 16008 | $self->session->pseudoCmd('listtask', $self->pseudoCmdMode); | ||
| 16009 | |||
| 16010 | # Update the notebook | ||
| 16011 | $self->updateNotebook(); | ||
| 16012 | |||
| 16013 | return 1; | ||
| 16014 | } | ||
| 16015 | |||
| 16016 | # Tasklist button callbacks - Global initial tasklist | ||
| 16017 | |||
| 16018 | sub buttonEdit_initialTask { | ||
| 16019 | |||
| 16020 | # Callback: Edit a task from the global initial tasklist (equivalent to ';editinitialtask') | ||
| 16021 | # | ||
| 16022 | # Expected arguments | ||
| 16023 | # (none besides $self) | ||
| 16024 | # | ||
| 16025 | # Return values | ||
| 16026 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 16027 | # object no longer exists | ||
| 16028 | # 1 otherwise | ||
| 16029 | |||
| 16030 | my ($self, $check) = @_; | ||
| 16031 | |||
| 16032 | # Local variables | ||
| 16033 | my ( | ||
| 16034 | $dataRef, $taskName, $taskObj, | ||
| 16035 | @list, @dataList, | ||
| 16036 | ); | ||
| 16037 | |||
| 16038 | # Check for improper arguments | ||
| 16039 | if (defined $check) { | ||
| 16040 | |||
| 16041 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonEdit_initialTask', @_); | ||
| 16042 | } | ||
| 16043 | |||
| 16044 | # Import the currently selected portions of the notebook list | ||
| 16045 | @list = $self->notebookGetSelectedData(); | ||
| 16046 | if (! @list) { | ||
| 16047 | |||
| 16048 | # Nothing selected | ||
| 16049 | return undef; | ||
| 16050 | } | ||
| 16051 | |||
| 16052 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 16053 | # a single row of the list | ||
| 16054 | $dataRef = $list[0]; | ||
| 16055 | @dataList = @$dataRef; | ||
| 16056 | # The initial task name is the first item of data | ||
| 16057 | $taskName = $dataList[0]; | ||
| 16058 | if (! $taskName) { | ||
| 16059 | |||
| 16060 | # Can't continue | ||
| 16061 | return undef; | ||
| 16062 | } | ||
| 16063 | |||
| 16064 | # Get the task reference itself | ||
| 16065 | $taskObj = $axmud::CLIENT->ivShow('initTaskHash', $taskName); | ||
| 16066 | if (! $taskObj) { | ||
| 16067 | |||
| 16068 | # Can't continue | ||
| 16069 | return undef; | ||
| 16070 | |||
| 16071 | } else { | ||
| 16072 | |||
| 16073 | # Open up an 'edit' window to edit the object | ||
| 16074 | $self->createFreeWin( | ||
| 16075 | 'Games::Axmud::EditWin::Task', | ||
| 16076 | $self, | ||
| 16077 | $self->session, | ||
| 16078 | 'Edit ' . $taskObj->prettyName . ' task', | ||
| 16079 | $taskObj, | ||
| 16080 | FALSE, # Not temporary | ||
| 16081 | # Config | ||
| 16082 | 'edit_flag' => TRUE, # Some IVs for initial tasks are editable | ||
| 16083 | ); | ||
| 16084 | |||
| 16085 | return 1; | ||
| 16086 | } | ||
| 16087 | } | ||
| 16088 | |||
| 16089 | sub buttonMoveUp_initialTask { | ||
| 16090 | |||
| 16091 | # Callback: Moves a global initial task up in the ordered list (no equivalent client | ||
| 16092 | # command) | ||
| 16093 | # | ||
| 16094 | # Expected arguments | ||
| 16095 | # (none besides $self) | ||
| 16096 | # | ||
| 16097 | # Return values | ||
| 16098 | # 'undef' on improper arguments or if no line is selected | ||
| 16099 | # 1 otherwise | ||
| 16100 | |||
| 16101 | my ($self, $check) = @_; | ||
| 16102 | |||
| 16103 | # Local variables | ||
| 16104 | my ( | ||
| 16105 | $index, $taskName, | ||
| 16106 | @taskList, | ||
| 16107 | ); | ||
| 16108 | |||
| 16109 | # Check for improper arguments | ||
| 16110 | if (defined $check) { | ||
| 16111 | |||
| 16112 | return $axmud::CLIENT->writeImproper( | ||
| 16113 | $self->_objClass . '->buttonMoveUp_initialTask', | ||
| 16114 | @_, | ||
| 16115 | ); | ||
| 16116 | } | ||
| 16117 | |||
| 16118 | # Import the ordered list of global initial tasks | ||
| 16119 | @taskList = $axmud::CLIENT->initTaskOrderList; | ||
| 16120 | |||
| 16121 | # Import the GA::Obj::SimpleList and find the currently selected line and the data it | ||
| 16122 | # contains | ||
| 16123 | ($index, $taskName) = $self->initialTaskData(); | ||
| 16124 | if (! defined $index) { | ||
| 16125 | |||
| 16126 | return undef; | ||
| 16127 | } | ||
| 16128 | |||
| 16129 | # $index must be at least 2nd in the list (element 1), else it can't be moved up | ||
| 16130 | if ($index) { | ||
| 16131 | |||
| 16132 | # Move the item up the ordered list | ||
| 16133 | splice(@taskList, $index, 1); | ||
| 16134 | splice(@taskList, ($index - 1), 0, $taskName); | ||
| 16135 | |||
| 16136 | # Update the client IV | ||
| 16137 | $axmud::CLIENT->set_initTaskOrderList(@taskList); | ||
| 16138 | # Update the notebook (the single argument makes sure the same item is selected) | ||
| 16139 | $self->updateNotebook($index - 1); | ||
| 16140 | } | ||
| 16141 | |||
| 16142 | return 1; | ||
| 16143 | } | ||
| 16144 | |||
| 16145 | sub buttonMoveDown_initialTask { | ||
| 16146 | |||
| 16147 | # Callback: Moves a global initial task down in the ordered list (no equivalent client | ||
| 16148 | # command) | ||
| 16149 | # | ||
| 16150 | # Expected arguments | ||
| 16151 | # (none besides $self) | ||
| 16152 | # | ||
| 16153 | # Return values | ||
| 16154 | # 'undef' on improper arguments, if no line is selected or if the selected item can't be | ||
| 16155 | # moved down | ||
| 16156 | # 1 otherwise | ||
| 16157 | |||
| 16158 | my ($self, $check) = @_; | ||
| 16159 | |||
| 16160 | # Local variables | ||
| 16161 | my ( | ||
| 16162 | $index, $taskName, | ||
| 16163 | @taskList, | ||
| 16164 | ); | ||
| 16165 | |||
| 16166 | # Check for improper arguments | ||
| 16167 | if (defined $check) { | ||
| 16168 | |||
| 16169 | return $axmud::CLIENT->writeImproper( | ||
| 16170 | $self->_objClass . '->buttonMoveDown_initialTask', | ||
| 16171 | @_, | ||
| 16172 | ); | ||
| 16173 | } | ||
| 16174 | |||
| 16175 | # Import the ordered list of global initial tasks | ||
| 16176 | @taskList = $axmud::CLIENT->initTaskOrderList; | ||
| 16177 | |||
| 16178 | # Import the GA::Obj::SimpleList and find the currently selected line and the data it | ||
| 16179 | # contains | ||
| 16180 | ($index, $taskName) = $self->initialTaskData(); | ||
| 16181 | if (! defined $index) { | ||
| 16182 | |||
| 16183 | return undef; | ||
| 16184 | } | ||
| 16185 | |||
| 16186 | # $index must not be last in the list, else it can't be moved down | ||
| 16187 | if ($taskList[-1] ne $taskName) { | ||
| 16188 | |||
| 16189 | # Move the item down the ordered list | ||
| 16190 | splice(@taskList, $index, 1); | ||
| 16191 | splice(@taskList, ($index + 1), 0, $taskName); | ||
| 16192 | |||
| 16193 | # Update the client IV | ||
| 16194 | $axmud::CLIENT->set_initTaskOrderList(@taskList); | ||
| 16195 | # Update the notebook (the single argument makes sure the same item is selected) | ||
| 16196 | $self->updateNotebook($index + 1); | ||
| 16197 | } | ||
| 16198 | |||
| 16199 | return 1; | ||
| 16200 | } | ||
| 16201 | |||
| 16202 | sub buttonDelete_initialTask { | ||
| 16203 | |||
| 16204 | # Callback: Delete a task from the global initial tasklist (equivalent to | ||
| 16205 | # ';deleteinitialtask') | ||
| 16206 | # | ||
| 16207 | # Expected arguments | ||
| 16208 | # (none besides $self) | ||
| 16209 | # | ||
| 16210 | # Return values | ||
| 16211 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 16212 | # 1 otherwise | ||
| 16213 | |||
| 16214 | my ($self, $check) = @_; | ||
| 16215 | |||
| 16216 | # Local variables | ||
| 16217 | my ( | ||
| 16218 | $dataRef, $taskName, | ||
| 16219 | @list, @dataList, | ||
| 16220 | ); | ||
| 16221 | |||
| 16222 | # Check for improper arguments | ||
| 16223 | if (defined $check) { | ||
| 16224 | |||
| 16225 | return $axmud::CLIENT->writeImproper( | ||
| 16226 | $self->_objClass . '->buttonDelete_initialTask', | ||
| 16227 | @_, | ||
| 16228 | ); | ||
| 16229 | } | ||
| 16230 | |||
| 16231 | # Import the currently selected portions of the notebook list | ||
| 16232 | @list = $self->notebookGetSelectedData(); | ||
| 16233 | if (! @list) { | ||
| 16234 | |||
| 16235 | # Nothing selected | ||
| 16236 | return undef; | ||
| 16237 | } | ||
| 16238 | |||
| 16239 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 16240 | # a single row of the list | ||
| 16241 | $dataRef = $list[0]; | ||
| 16242 | @dataList = @$dataRef; | ||
| 16243 | # The initial task name is the first item of data | ||
| 16244 | $taskName = $dataList[0]; | ||
| 16245 | if (! $taskName) { | ||
| 16246 | |||
| 16247 | # Can't continue | ||
| 16248 | return undef; | ||
| 16249 | |||
| 16250 | } else { | ||
| 16251 | |||
| 16252 | # Delete the initial task | ||
| 16253 | $self->session->pseudoCmd('deleteinitialtask ' . $taskName, $self->pseudoCmdMode); | ||
| 16254 | |||
| 16255 | # Update the notebook | ||
| 16256 | $self->updateNotebook(); | ||
| 16257 | |||
| 16258 | return 1; | ||
| 16259 | } | ||
| 16260 | } | ||
| 16261 | |||
| 16262 | sub buttonDeleteAll_initialTask { | ||
| 16263 | |||
| 16264 | # Callback: Delete all tasks from the global initial tasklist (equivalent to | ||
| 16265 | # ';deleteinitialtask -a') | ||
| 16266 | # | ||
| 16267 | # Expected arguments | ||
| 16268 | # (none besides $self) | ||
| 16269 | # | ||
| 16270 | # Return values | ||
| 16271 | # 'undef' on improper arguments | ||
| 16272 | # 1 otherwise | ||
| 16273 | |||
| 16274 | my ($self, $check) = @_; | ||
| 16275 | |||
| 16276 | # Local variables | ||
| 16277 | my ($tab, $slWidget); | ||
| 16278 | |||
| 16279 | # Check for improper arguments | ||
| 16280 | if (defined $check) { | ||
| 16281 | |||
| 16282 | return $axmud::CLIENT->writeImproper( | ||
| 16283 | $self->_objClass . '->buttonDeleteAll_initialTask', | ||
| 16284 | @_, | ||
| 16285 | ); | ||
| 16286 | } | ||
| 16287 | |||
| 16288 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 16289 | $tab = $self->notebookGetTab(); | ||
| 16290 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 16291 | |||
| 16292 | # Unselect everything in the list | ||
| 16293 | $slWidget->get_selection->unselect_all(); | ||
| 16294 | |||
| 16295 | # Delete all initial tasks | ||
| 16296 | $self->session->pseudoCmd('deleteinitialtask -a', $self->pseudoCmdMode); | ||
| 16297 | |||
| 16298 | # Update the notebook | ||
| 16299 | $self->updateNotebook(); | ||
| 16300 | |||
| 16301 | return 1; | ||
| 16302 | } | ||
| 16303 | |||
| 16304 | sub buttonDump_initialTask { | ||
| 16305 | |||
| 16306 | # Callback: Display list of initial tasks to the 'main' window (equivalent to | ||
| 16307 | # ';listinitialtask') | ||
| 16308 | # | ||
| 16309 | # Expected arguments | ||
| 16310 | # (none besides $self) | ||
| 16311 | # | ||
| 16312 | # Return values | ||
| 16313 | # 'undef' on improper arguments | ||
| 16314 | # 1 otherwise | ||
| 16315 | |||
| 16316 | my ($self, $check) = @_; | ||
| 16317 | |||
| 16318 | # Local variables | ||
| 16319 | my ($tab, $slWidget); | ||
| 16320 | |||
| 16321 | # Check for improper arguments | ||
| 16322 | if (defined $check) { | ||
| 16323 | |||
| 16324 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDump_initialTask', @_); | ||
| 16325 | } | ||
| 16326 | |||
| 16327 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 16328 | $tab = $self->notebookGetTab(); | ||
| 16329 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 16330 | |||
| 16331 | # Unselect everything in the list | ||
| 16332 | $slWidget->get_selection->unselect_all(); | ||
| 16333 | |||
| 16334 | # Display initial tasks | ||
| 16335 | $self->session->pseudoCmd('listinitialtask', $self->pseudoCmdMode); | ||
| 16336 | |||
| 16337 | # Update the notebook | ||
| 16338 | $self->updateNotebook(); | ||
| 16339 | |||
| 16340 | return 1; | ||
| 16341 | } | ||
| 16342 | |||
| 16343 | # Tasklist button callbacks - Custom tasklist | ||
| 16344 | |||
| 16345 | sub buttonStart_customTask { | ||
| 16346 | |||
| 16347 | # Callback: Starts a task from the custom tasklist (equivalent to ';startcustomtask') | ||
| 16348 | # | ||
| 16349 | # Expected arguments | ||
| 16350 | # (none besides $self) | ||
| 16351 | # | ||
| 16352 | # Return values | ||
| 16353 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 16354 | # 1 otherwise | ||
| 16355 | |||
| 16356 | my ($self, $check) = @_; | ||
| 16357 | |||
| 16358 | # Local variables | ||
| 16359 | my ( | ||
| 16360 | $dataRef, $taskName, | ||
| 16361 | @list, @dataList, | ||
| 16362 | ); | ||
| 16363 | |||
| 16364 | # Check for improper arguments | ||
| 16365 | if (defined $check) { | ||
| 16366 | |||
| 16367 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonStart_customTask', @_); | ||
| 16368 | } | ||
| 16369 | |||
| 16370 | # Import the currently selected portions of the notebook list | ||
| 16371 | @list = $self->notebookGetSelectedData(); | ||
| 16372 | if (! @list) { | ||
| 16373 | |||
| 16374 | # Nothing selected | ||
| 16375 | return undef; | ||
| 16376 | } | ||
| 16377 | |||
| 16378 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 16379 | # a single row of the list | ||
| 16380 | $dataRef = $list[0]; | ||
| 16381 | @dataList = @$dataRef; | ||
| 16382 | # The custom task's name is the first item of data | ||
| 16383 | $taskName = $dataList[0]; | ||
| 16384 | if (! $taskName) { | ||
| 16385 | |||
| 16386 | # Can't continue | ||
| 16387 | return undef; | ||
| 16388 | |||
| 16389 | } else { | ||
| 16390 | |||
| 16391 | # Start the task | ||
| 16392 | $self->session->pseudoCmd('startcustomtask ' . $taskName, $self->pseudoCmdMode); | ||
| 16393 | |||
| 16394 | # Update the notebook | ||
| 16395 | $self->updateNotebook(); | ||
| 16396 | |||
| 16397 | return 1; | ||
| 16398 | } | ||
| 16399 | } | ||
| 16400 | |||
| 16401 | sub buttonEdit_customTask { | ||
| 16402 | |||
| 16403 | # Callback: Edit a task from the custom tasklist (equivalent to ';editcustomtask') | ||
| 16404 | # | ||
| 16405 | # Expected arguments | ||
| 16406 | # (none besides $self) | ||
| 16407 | # | ||
| 16408 | # Return values | ||
| 16409 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 16410 | # object no longer exists | ||
| 16411 | # 1 otherwise | ||
| 16412 | |||
| 16413 | my ($self, $check) = @_; | ||
| 16414 | |||
| 16415 | # Local variables | ||
| 16416 | my ( | ||
| 16417 | $dataRef, $taskName, $taskObj, | ||
| 16418 | @list, @dataList, | ||
| 16419 | ); | ||
| 16420 | |||
| 16421 | # Check for improper arguments | ||
| 16422 | if (defined $check) { | ||
| 16423 | |||
| 16424 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonEdit_customTask', @_); | ||
| 16425 | } | ||
| 16426 | |||
| 16427 | # Import the currently selected portions of the notebook list | ||
| 16428 | @list = $self->notebookGetSelectedData(); | ||
| 16429 | if (! @list) { | ||
| 16430 | |||
| 16431 | # Nothing selected | ||
| 16432 | return undef; | ||
| 16433 | } | ||
| 16434 | |||
| 16435 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 16436 | # a single row of the list | ||
| 16437 | $dataRef = $list[0]; | ||
| 16438 | @dataList = @$dataRef; | ||
| 16439 | # The custom task's name is the first item of data | ||
| 16440 | $taskName = $dataList[0]; | ||
| 16441 | if (! $taskName) { | ||
| 16442 | |||
| 16443 | # Can't continue | ||
| 16444 | return undef; | ||
| 16445 | } | ||
| 16446 | |||
| 16447 | # Get the task object itself | ||
| 16448 | $taskObj = $axmud::CLIENT->ivShow('customTaskHash', $taskName); | ||
| 16449 | if (! $taskObj) { | ||
| 16450 | |||
| 16451 | # Can't continue | ||
| 16452 | return undef; | ||
| 16453 | |||
| 16454 | } else { | ||
| 16455 | |||
| 16456 | # Open up an 'edit' window to edit the object | ||
| 16457 | $self->createFreeWin( | ||
| 16458 | 'Games::Axmud::EditWin::Task', | ||
| 16459 | $self, | ||
| 16460 | $self->session, | ||
| 16461 | 'Edit ' . $taskObj->prettyName . ' task', | ||
| 16462 | $taskObj, | ||
| 16463 | FALSE, # Not temporary | ||
| 16464 | # Config | ||
| 16465 | 'edit_flag' => TRUE, # Some IVs for custom tasks are editable | ||
| 16466 | ); | ||
| 16467 | |||
| 16468 | return 1; | ||
| 16469 | } | ||
| 16470 | } | ||
| 16471 | |||
| 16472 | sub buttonDelete_customTask { | ||
| 16473 | |||
| 16474 | # Callback: Delete a task from the custom tasklist (equivalent to ';deletecustomtask') | ||
| 16475 | # | ||
| 16476 | # Expected arguments | ||
| 16477 | # (none besides $self) | ||
| 16478 | # | ||
| 16479 | # Return values | ||
| 16480 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 16481 | # 1 otherwise | ||
| 16482 | |||
| 16483 | my ($self, $check) = @_; | ||
| 16484 | |||
| 16485 | # Local variables | ||
| 16486 | my ( | ||
| 16487 | $dataRef, $taskName, | ||
| 16488 | @list, @dataList, | ||
| 16489 | ); | ||
| 16490 | |||
| 16491 | # Check for improper arguments | ||
| 16492 | if (defined $check) { | ||
| 16493 | |||
| 16494 | return $axmud::CLIENT->writeImproper( | ||
| 16495 | $self->_objClass . '->buttonDelete_customTask', | ||
| 16496 | @_, | ||
| 16497 | ); | ||
| 16498 | } | ||
| 16499 | |||
| 16500 | # Import the currently selected portions of the notebook list | ||
| 16501 | @list = $self->notebookGetSelectedData(); | ||
| 16502 | if (! @list) { | ||
| 16503 | |||
| 16504 | # Nothing selected | ||
| 16505 | return undef; | ||
| 16506 | } | ||
| 16507 | |||
| 16508 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 16509 | # a single row of the list | ||
| 16510 | $dataRef = $list[0]; | ||
| 16511 | @dataList = @$dataRef; | ||
| 16512 | # The custom task's name is the first item of data | ||
| 16513 | $taskName = $dataList[0]; | ||
| 16514 | if (! $taskName) { | ||
| 16515 | |||
| 16516 | # Can't continue | ||
| 16517 | return undef; | ||
| 16518 | |||
| 16519 | } else { | ||
| 16520 | |||
| 16521 | # Delete the task | ||
| 16522 | $self->session->pseudoCmd('deletecustomtask ' . $taskName, $self->pseudoCmdMode); | ||
| 16523 | |||
| 16524 | # Update the notebook | ||
| 16525 | $self->updateNotebook(); | ||
| 16526 | |||
| 16527 | return 1; | ||
| 16528 | } | ||
| 16529 | } | ||
| 16530 | |||
| 16531 | sub buttonDeleteAll_customTask { | ||
| 16532 | |||
| 16533 | # Callback: Delete all tasks from the custom tasklist (equivalent to ';deletecustomtask -a') | ||
| 16534 | # | ||
| 16535 | # Expected arguments | ||
| 16536 | # (none besides $self) | ||
| 16537 | # | ||
| 16538 | # Return values | ||
| 16539 | # 'undef' on improper arguments | ||
| 16540 | # 1 otherwise | ||
| 16541 | |||
| 16542 | my ($self, $check) = @_; | ||
| 16543 | |||
| 16544 | # Local variables | ||
| 16545 | my ($tab, $slWidget); | ||
| 16546 | |||
| 16547 | # Check for improper arguments | ||
| 16548 | if (defined $check) { | ||
| 16549 | |||
| 16550 | return $axmud::CLIENT->writeImproper( | ||
| 16551 | $self->_objClass . '->buttonDeleteAll_customTask', | ||
| 16552 | @_, | ||
| 16553 | ); | ||
| 16554 | } | ||
| 16555 | |||
| 16556 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 16557 | $tab = $self->notebookGetTab(); | ||
| 16558 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 16559 | |||
| 16560 | # Unselect everything in the list | ||
| 16561 | $slWidget->get_selection->unselect_all(); | ||
| 16562 | |||
| 16563 | # Delete all custom tasks | ||
| 16564 | $self->session->pseudoCmd('deletecustomtask -a', $self->pseudoCmdMode); | ||
| 16565 | |||
| 16566 | # Update the notebook | ||
| 16567 | $self->updateNotebook(); | ||
| 16568 | |||
| 16569 | return 1; | ||
| 16570 | } | ||
| 16571 | |||
| 16572 | sub buttonDump_customTask { | ||
| 16573 | |||
| 16574 | # Callback: Display list of custom tasks in the 'main' window (equivalent to | ||
| 16575 | # ';listcustomtask') | ||
| 16576 | # | ||
| 16577 | # Expected arguments | ||
| 16578 | # (none besides $self) | ||
| 16579 | # | ||
| 16580 | # Return values | ||
| 16581 | # 'undef' on improper arguments | ||
| 16582 | # 1 otherwise | ||
| 16583 | |||
| 16584 | my ($self, $check) = @_; | ||
| 16585 | |||
| 16586 | # Local variables | ||
| 16587 | my ($tab, $slWidget, $ref); | ||
| 16588 | |||
| 16589 | # Check for improper arguments | ||
| 16590 | if (defined $check) { | ||
| 16591 | |||
| 16592 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDump_customTask', @_); | ||
| 16593 | } | ||
| 16594 | |||
| 16595 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 16596 | $tab = $self->notebookGetTab(); | ||
| 16597 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 16598 | |||
| 16599 | # Unselect everything in the list | ||
| 16600 | $slWidget->get_selection->unselect_all(); | ||
| 16601 | |||
| 16602 | # Dump custom tasks | ||
| 16603 | $self->session->pseudoCmd('listcustomtask', $self->pseudoCmdMode); | ||
| 16604 | |||
| 16605 | # Update the notebook | ||
| 16606 | $self->updateNotebook(); | ||
| 16607 | |||
| 16608 | return 1; | ||
| 16609 | } | ||
| 16610 | |||
| 16611 | # Tasklist button callbacks - Task packages | ||
| 16612 | |||
| 16613 | sub buttonAdd_taskPackage { | ||
| 16614 | |||
| 16615 | # Callback: Add a task package name (equivalent to ';addtaskpackage') | ||
| 16616 | # | ||
| 16617 | # Expected arguments | ||
| 16618 | # (none besides $self) | ||
| 16619 | # | ||
| 16620 | # Return values | ||
| 16621 | # 'undef' on improper arguments | ||
| 16622 | # 1 otherwise | ||
| 16623 | |||
| 16624 | my ($self, $check) = @_; | ||
| 16625 | |||
| 16626 | # Local variables | ||
| 16627 | my ($tab, $slWidget, $standard, $package); | ||
| 16628 | |||
| 16629 | # Check for improper arguments | ||
| 16630 | if (defined $check) { | ||
| 16631 | |||
| 16632 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonAdd_taskPackage', @_); | ||
| 16633 | } | ||
| 16634 | |||
| 16635 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 16636 | $tab = $self->notebookGetTab(); | ||
| 16637 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 16638 | |||
| 16639 | # Unselect everything in the list, because we're starting a new task package name | ||
| 16640 | $slWidget->get_selection->unselect_all(); | ||
| 16641 | |||
| 16642 | ($standard, $package) = $self->showDoubleEntryDialogue( | ||
| 16643 | 'Add task package name', | ||
| 16644 | 'Standard task name', | ||
| 16645 | 'Task package name', | ||
| 16646 | ); | ||
| 16647 | |||
| 16648 | if (defined $standard && defined $package) { | ||
| 16649 | |||
| 16650 | $self->session->pseudoCmd( | ||
| 16651 | 'addtaskpackage ' . $standard . ' ' . $package, | ||
| 16652 | $self->pseudoCmdMode, | ||
| 16653 | ); | ||
| 16654 | |||
| 16655 | # Update the notebook | ||
| 16656 | $self->updateNotebook(); | ||
| 16657 | }; | ||
| 16658 | |||
| 16659 | return 1; | ||
| 16660 | } | ||
| 16661 | |||
| 16662 | sub buttonEdit_taskPackage { | ||
| 16663 | |||
| 16664 | # Callback: Edits a task package name (no client command equivalent) | ||
| 16665 | # | ||
| 16666 | # Expected arguments | ||
| 16667 | # (none besides $self) | ||
| 16668 | # | ||
| 16669 | # Return values | ||
| 16670 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 16671 | # item no longer exists | ||
| 16672 | # 1 otherwise | ||
| 16673 | |||
| 16674 | my ($self, $check) = @_; | ||
| 16675 | |||
| 16676 | # Local variables | ||
| 16677 | my ( | ||
| 16678 | $dataRef, $standard, $package, | ||
| 16679 | @list, @dataList, | ||
| 16680 | ); | ||
| 16681 | |||
| 16682 | # Check for improper arguments | ||
| 16683 | if (defined $check) { | ||
| 16684 | |||
| 16685 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonEdit_taskPackage', @_); | ||
| 16686 | } | ||
| 16687 | |||
| 16688 | # Import the currently selected portions of the notebook list | ||
| 16689 | @list = $self->notebookGetSelectedData(); | ||
| 16690 | if (! @list) { | ||
| 16691 | |||
| 16692 | # Nothing selected | ||
| 16693 | return undef; | ||
| 16694 | } | ||
| 16695 | |||
| 16696 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 16697 | # a single row of the list | ||
| 16698 | $dataRef = $list[0]; | ||
| 16699 | @dataList = @$dataRef; | ||
| 16700 | # The standard task name is the second item of data | ||
| 16701 | $standard = $dataList[1]; | ||
| 16702 | if (! $standard) { | ||
| 16703 | |||
| 16704 | # Can't continue | ||
| 16705 | return undef; | ||
| 16706 | } | ||
| 16707 | |||
| 16708 | # Prompt for a new package name | ||
| 16709 | $package = $self->showEntryDialogue( | ||
| 16710 | 'Edit task package name', | ||
| 16711 | 'Enter a task package name for \'' . $standard . '\'', | ||
| 16712 | ); | ||
| 16713 | |||
| 16714 | if (defined $package) { | ||
| 16715 | |||
| 16716 | $self->session->pseudoCmd( | ||
| 16717 | 'addtaskpackage ' . $standard . ' ' . $package, | ||
| 16718 | $self->pseudoCmdMode, | ||
| 16719 | ); | ||
| 16720 | |||
| 16721 | # Update the notebook | ||
| 16722 | $self->updateNotebook(); | ||
| 16723 | }; | ||
| 16724 | |||
| 16725 | return 1; | ||
| 16726 | } | ||
| 16727 | |||
| 16728 | sub buttonDelete_taskPackage { | ||
| 16729 | |||
| 16730 | # Callback: Deletes a task package name (equivalent to ';deletetaskpackage') | ||
| 16731 | # | ||
| 16732 | # Expected arguments | ||
| 16733 | # (none besides $self) | ||
| 16734 | # | ||
| 16735 | # Return values | ||
| 16736 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 16737 | # item no longer exists | ||
| 16738 | # 1 otherwise | ||
| 16739 | |||
| 16740 | my ($self, $check) = @_; | ||
| 16741 | |||
| 16742 | # Local variables | ||
| 16743 | my ( | ||
| 16744 | $dataRef, $standard, | ||
| 16745 | @list, @dataList, | ||
| 16746 | ); | ||
| 16747 | |||
| 16748 | # Check for improper arguments | ||
| 16749 | if (defined $check) { | ||
| 16750 | |||
| 16751 | return $axmud::CLIENT->writeImproper( | ||
| 16752 | $self->_objClass . '->buttonDelete_taskPackage', | ||
| 16753 | @_, | ||
| 16754 | ); | ||
| 16755 | } | ||
| 16756 | |||
| 16757 | # Import the currently selected portions of the notebook list | ||
| 16758 | @list = $self->notebookGetSelectedData(); | ||
| 16759 | if (! @list) { | ||
| 16760 | |||
| 16761 | # Nothing selected | ||
| 16762 | return undef; | ||
| 16763 | } | ||
| 16764 | |||
| 16765 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 16766 | # a single row of the list | ||
| 16767 | $dataRef = $list[0]; | ||
| 16768 | @dataList = @$dataRef; | ||
| 16769 | # The standard task name is the second item of data | ||
| 16770 | $standard = $dataList[1]; | ||
| 16771 | if (! $standard) { | ||
| 16772 | |||
| 16773 | # Can't continue | ||
| 16774 | return undef; | ||
| 16775 | |||
| 16776 | } else { | ||
| 16777 | |||
| 16778 | # Delete the task package | ||
| 16779 | $self->session->pseudoCmd('deletetaskpackage ' . $standard, $self->pseudoCmdMode); | ||
| 16780 | |||
| 16781 | # Update the notebook | ||
| 16782 | $self->updateNotebook(); | ||
| 16783 | }; | ||
| 16784 | |||
| 16785 | return 1; | ||
| 16786 | } | ||
| 16787 | |||
| 16788 | sub buttonReset_taskPackage { | ||
| 16789 | |||
| 16790 | # Callback: Reset a task package name to its default (equivalent to | ||
| 16791 | # ';resettaskpackage <name>') | ||
| 16792 | # | ||
| 16793 | # Expected arguments | ||
| 16794 | # (none besides $self) | ||
| 16795 | # | ||
| 16796 | # Return values | ||
| 16797 | # 'undef' on improper arguments, if no line is selected in the notebook or if the user | ||
| 16798 | # declines to continue the operation | ||
| 16799 | # 1 otherwise | ||
| 16800 | |||
| 16801 | my ($self, $check) = @_; | ||
| 16802 | |||
| 16803 | # Local variables | ||
| 16804 | my ( | ||
| 16805 | $dataRef, $standard, $result, | ||
| 16806 | @list, @dataList, | ||
| 16807 | ); | ||
| 16808 | |||
| 16809 | # Check for improper arguments | ||
| 16810 | if (defined $check) { | ||
| 16811 | |||
| 16812 | return $axmud::CLIENT->writeImproper( | ||
| 16813 | $self->_objClass . '->buttonReset_taskPackage', | ||
| 16814 | @_, | ||
| 16815 | ); | ||
| 16816 | } | ||
| 16817 | |||
| 16818 | # Import the currently selected portions of the notebook list | ||
| 16819 | @list = $self->notebookGetSelectedData(); | ||
| 16820 | if (! @list) { | ||
| 16821 | |||
| 16822 | # Nothing selected | ||
| 16823 | return undef; | ||
| 16824 | } | ||
| 16825 | |||
| 16826 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 16827 | # a single row of the list | ||
| 16828 | $dataRef = $list[0]; | ||
| 16829 | @dataList = @$dataRef; | ||
| 16830 | # The standard task name is the second item of data | ||
| 16831 | $standard = $dataList[1]; | ||
| 16832 | if (! $standard) { | ||
| 16833 | |||
| 16834 | # Can't continue | ||
| 16835 | return undef; | ||
| 16836 | } | ||
| 16837 | |||
| 16838 | # If it's not one of the built-in tasks, we need to show a warning message | ||
| 16839 | if (! $axmud::CLIENT->ivExists('constTaskPackageHash', $standard)) { | ||
| 16840 | |||
| 16841 | $result = $self->showMsgDialogue( | ||
| 16842 | 'Reset task package name', | ||
| 16843 | 'warning', | ||
| 16844 | 'The task \'' . $standard . '\' isn\'t a built-in task, so resetting its package' | ||
| 16845 | . ' name will cause it to disappear from this list. You won\'t be able to run the' | ||
| 16846 | . ' task until you enter a new package name for it. Continue?', | ||
| 16847 | 'yes-no', | ||
| 16848 | ); | ||
| 16849 | |||
| 16850 | if ($result ne 'yes') { | ||
| 16851 | |||
| 16852 | return undef; | ||
| 16853 | } | ||
| 16854 | } | ||
| 16855 | |||
| 16856 | # Reset the task package | ||
| 16857 | $self->session->pseudoCmd('resettaskpackage ' . $standard, $self->pseudoCmdMode); | ||
| 16858 | |||
| 16859 | # Update the notebook | ||
| 16860 | $self->updateNotebook(); | ||
| 16861 | |||
| 16862 | return 1; | ||
| 16863 | } | ||
| 16864 | |||
| 16865 | sub buttonResetAll_taskPackage { | ||
| 16866 | |||
| 16867 | # Callback: Resets all task package names to default (equivalent to | ||
| 16868 | # ';resettaskpackage') | ||
| 16869 | # | ||
| 16870 | # Expected arguments | ||
| 16871 | # (none besides $self) | ||
| 16872 | # | ||
| 16873 | # Return values | ||
| 16874 | # 'undef' on improper arguments or if the user declines to continue the operation | ||
| 16875 | # 1 otherwise | ||
| 16876 | |||
| 16877 | my ($self, $check) = @_; | ||
| 16878 | |||
| 16879 | # Local variables | ||
| 16880 | my ($tab, $slWidget, $result, $count, $text); | ||
| 16881 | |||
| 16882 | # Check for improper arguments | ||
| 16883 | if (defined $check) { | ||
| 16884 | |||
| 16885 | return $axmud::CLIENT->writeImproper( | ||
| 16886 | $self->_objClass . '->buttonResetAll_taskPackage', | ||
| 16887 | @_, | ||
| 16888 | ); | ||
| 16889 | } | ||
| 16890 | |||
| 16891 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 16892 | $tab = $self->notebookGetTab(); | ||
| 16893 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 16894 | |||
| 16895 | # Unselect everything in the list | ||
| 16896 | $slWidget->get_selection->unselect_all(); | ||
| 16897 | |||
| 16898 | # Count the number of tasks which aren't built-in tasks, but which have package names | ||
| 16899 | $count = 0; | ||
| 16900 | foreach my $taskName ($axmud::CLIENT->ivKeys('taskPackageHash')) { | ||
| 16901 | |||
| 16902 | if (! $axmud::CLIENT->ivExists('constTaskPackageHash', $taskName)) { | ||
| 16903 | |||
| 16904 | $count++; | ||
| 16905 | } | ||
| 16906 | } | ||
| 16907 | |||
| 16908 | if ($count) { | ||
| 16909 | |||
| 16910 | if ($count == 1) { | ||
| 16911 | |||
| 16912 | $text = 'This list contains 1 task which isn\'t a built-in task. Resetting all' | ||
| 16913 | . ' task package names will cause this task to disappear from the list.' | ||
| 16914 | . ' You won\'t be able to run it until you enter a new package name' | ||
| 16915 | . ' for it. Continue?'; | ||
| 16916 | |||
| 16917 | } else { | ||
| 16918 | |||
| 16919 | $text = 'This list contains ' . $count . ' tasks which aren\'t built-in tasks.' | ||
| 16920 | . ' Resetting all package names will cause these tasks to disappear from the' | ||
| 16921 | . ' list. You won\'t be able to run them until you enter new package names for' | ||
| 16922 | . ' them. Continue?'; | ||
| 16923 | } | ||
| 16924 | |||
| 16925 | $result = $self->showMsgDialogue( | ||
| 16926 | 'Reset task package name', | ||
| 16927 | 'warning', | ||
| 16928 | $text, | ||
| 16929 | 'yes-no', | ||
| 16930 | ); | ||
| 16931 | |||
| 16932 | if ($result ne 'yes') { | ||
| 16933 | |||
| 16934 | return undef; | ||
| 16935 | } | ||
| 16936 | } | ||
| 16937 | |||
| 16938 | # Reset all task packages | ||
| 16939 | $self->session->pseudoCmd('resettaskpackage', $self->pseudoCmdMode); | ||
| 16940 | |||
| 16941 | # Update the notebook | ||
| 16942 | $self->updateNotebook(); | ||
| 16943 | |||
| 16944 | return 1; | ||
| 16945 | } | ||
| 16946 | |||
| 16947 | sub buttonDump_taskPackage { | ||
| 16948 | |||
| 16949 | # Callback: Displays the list of task package names in the 'main' window (equivalent to | ||
| 16950 | # ';listtaskpackage') | ||
| 16951 | # | ||
| 16952 | # Expected arguments | ||
| 16953 | # (none besides $self) | ||
| 16954 | # | ||
| 16955 | # Return values | ||
| 16956 | # 'undef' on improper arguments | ||
| 16957 | # 1 otherwise | ||
| 16958 | |||
| 16959 | my ($self, $check) = @_; | ||
| 16960 | |||
| 16961 | # Local variables | ||
| 16962 | my ($tab, $slWidget, $standard, $package); | ||
| 16963 | |||
| 16964 | # Check for improper arguments | ||
| 16965 | if (defined $check) { | ||
| 16966 | |||
| 16967 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonHaltAll_task', @_); | ||
| 16968 | } | ||
| 16969 | |||
| 16970 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 16971 | $tab = $self->notebookGetTab(); | ||
| 16972 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 16973 | |||
| 16974 | # Unselect everything in the list | ||
| 16975 | $slWidget->get_selection->unselect_all(); | ||
| 16976 | |||
| 16977 | # Dump the data | ||
| 16978 | $self->session->pseudoCmd('listtaskpackage -d', $self->pseudoCmdMode); | ||
| 16979 | $self->session->pseudoCmd('listtaskpackage', $self->pseudoCmdMode); | ||
| 16980 | |||
| 16981 | # Update the notebook | ||
| 16982 | $self->updateNotebook(); | ||
| 16983 | |||
| 16984 | return 1; | ||
| 16985 | } | ||
| 16986 | |||
| 16987 | # Tasklist button callbacks - Task labels | ||
| 16988 | |||
| 16989 | sub buttonAdd_taskLabel { | ||
| 16990 | |||
| 16991 | # Callback: Adds a task label (equivalent to ';addtasklabel') | ||
| 16992 | # | ||
| 16993 | # Expected arguments | ||
| 16994 | # (none besides $self) | ||
| 16995 | # | ||
| 16996 | # Return values | ||
| 16997 | # 'undef' on improper arguments | ||
| 16998 | # 1 otherwise | ||
| 16999 | |||
| 17000 | my ($self, $check) = @_; | ||
| 17001 | |||
| 17002 | # Local variables | ||
| 17003 | my ( | ||
| 17004 | $tab, $slWidget, $label, $standard, | ||
| 17005 | @comboList, | ||
| 17006 | ); | ||
| 17007 | |||
| 17008 | # Check for improper arguments | ||
| 17009 | if (defined $check) { | ||
| 17010 | |||
| 17011 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonAdd_taskLabel', @_); | ||
| 17012 | } | ||
| 17013 | |||
| 17014 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 17015 | $tab = $self->notebookGetTab(); | ||
| 17016 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 17017 | |||
| 17018 | # Unselect everything in the list | ||
| 17019 | $slWidget->get_selection->unselect_all(); | ||
| 17020 | |||
| 17021 | # Get a sorted list of standard task names | ||
| 17022 | @comboList = sort {lc($a) cmp lc($b)} ($axmud::CLIENT->ivKeys('taskPackageHash')); | ||
| 17023 | |||
| 17024 | # Prompt the user for a label | ||
| 17025 | ($label, $standard) = $self->showEntryComboDialogue( | ||
| 17026 | 'Add task label', | ||
| 17027 | 'Task label', | ||
| 17028 | 'Standard task name', | ||
| 17029 | \@comboList, | ||
| 17030 | ); | ||
| 17031 | |||
| 17032 | if (defined $label && defined $standard) { | ||
| 17033 | |||
| 17034 | $self->session->pseudoCmd( | ||
| 17035 | 'addtasklabel ' . $standard . ' ' . $label, | ||
| 17036 | $self->pseudoCmdMode, | ||
| 17037 | ); | ||
| 17038 | |||
| 17039 | # Update the notebook | ||
| 17040 | $self->updateNotebook(); | ||
| 17041 | }; | ||
| 17042 | |||
| 17043 | return 1; | ||
| 17044 | } | ||
| 17045 | |||
| 17046 | sub buttonDelete_taskLabel { | ||
| 17047 | |||
| 17048 | # Callback: Delete a task label (equivalent to ';deletetasklabel') | ||
| 17049 | # | ||
| 17050 | # Expected arguments | ||
| 17051 | # (none besides $self) | ||
| 17052 | # | ||
| 17053 | # Return values | ||
| 17054 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 17055 | # 1 otherwise | ||
| 17056 | |||
| 17057 | my ($self, $check) = @_; | ||
| 17058 | |||
| 17059 | # Local variables | ||
| 17060 | my ( | ||
| 17061 | $dataRef, $label, | ||
| 17062 | @list, @dataList, | ||
| 17063 | ); | ||
| 17064 | |||
| 17065 | # Check for improper arguments | ||
| 17066 | if (defined $check) { | ||
| 17067 | |||
| 17068 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDelete_taskLabel', @_); | ||
| 17069 | } | ||
| 17070 | |||
| 17071 | # Import the currently selected portions of the notebook list | ||
| 17072 | @list = $self->notebookGetSelectedData(); | ||
| 17073 | if (! @list) { | ||
| 17074 | |||
| 17075 | # Nothing selected | ||
| 17076 | return undef; | ||
| 17077 | } | ||
| 17078 | |||
| 17079 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 17080 | # a single row of the list | ||
| 17081 | $dataRef = $list[0]; | ||
| 17082 | @dataList = @$dataRef; | ||
| 17083 | # The label is the second item of data | ||
| 17084 | $label = $dataList[1]; | ||
| 17085 | if (! $label) { | ||
| 17086 | |||
| 17087 | # Can't continue | ||
| 17088 | return undef; | ||
| 17089 | |||
| 17090 | } else { | ||
| 17091 | |||
| 17092 | # Delete the label | ||
| 17093 | $self->session->pseudoCmd('deletetasklabel ' . $label, $self->pseudoCmdMode); | ||
| 17094 | |||
| 17095 | # Update the notebook | ||
| 17096 | $self->updateNotebook(); | ||
| 17097 | }; | ||
| 17098 | |||
| 17099 | return 1; | ||
| 17100 | } | ||
| 17101 | |||
| 17102 | sub buttonEmpty_taskLabel { | ||
| 17103 | |||
| 17104 | # Callback: Empty task labels attached to a particular task (equivalent to | ||
| 17105 | # ';addtasklabel <name>') | ||
| 17106 | # | ||
| 17107 | # Expected arguments | ||
| 17108 | # (none besides $self) | ||
| 17109 | # | ||
| 17110 | # Return values | ||
| 17111 | # 'undef' on improper arguments or if the user declines to continue the operation | ||
| 17112 | # 1 otherwise | ||
| 17113 | |||
| 17114 | my ($self, $check) = @_; | ||
| 17115 | |||
| 17116 | # Local variables | ||
| 17117 | my ( | ||
| 17118 | $tab, $slWidget, $standard, | ||
| 17119 | @comboList, | ||
| 17120 | ); | ||
| 17121 | |||
| 17122 | # Check for improper arguments | ||
| 17123 | if (defined $check) { | ||
| 17124 | |||
| 17125 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonEmpty_taskLabel', @_); | ||
| 17126 | } | ||
| 17127 | |||
| 17128 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 17129 | $tab = $self->notebookGetTab(); | ||
| 17130 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 17131 | |||
| 17132 | # Unselect everything in the list | ||
| 17133 | $slWidget->get_selection->unselect_all(); | ||
| 17134 | |||
| 17135 | # Get a sorted list of standard task names | ||
| 17136 | @comboList = sort {lc($a) cmp lc($b)} ($axmud::CLIENT->ivKeys('taskPackageHash')); | ||
| 17137 | |||
| 17138 | # Prompt the user to choose a task | ||
| 17139 | $standard = $self->showComboDialogue( | ||
| 17140 | 'Empty labels', | ||
| 17141 | 'Select the task which should have all its labels emptied', | ||
| 17142 | \@comboList, | ||
| 17143 | ); | ||
| 17144 | |||
| 17145 | if ($standard) { | ||
| 17146 | |||
| 17147 | $self->session->pseudoCmd('addtasklabel ' . $standard, $self->pseudoCmdMode); | ||
| 17148 | |||
| 17149 | # Update the notebook | ||
| 17150 | $self->updateNotebook(); | ||
| 17151 | }; | ||
| 17152 | |||
| 17153 | return 1; | ||
| 17154 | } | ||
| 17155 | |||
| 17156 | sub buttonReset_taskLabel { | ||
| 17157 | |||
| 17158 | # Callback: Reset task labels attached to a particular task (equivalent to | ||
| 17159 | # ';resettasklabel <name>') | ||
| 17160 | # | ||
| 17161 | # Expected arguments | ||
| 17162 | # (none besides $self) | ||
| 17163 | # | ||
| 17164 | # Return values | ||
| 17165 | # 'undef' on improper arguments | ||
| 17166 | # 1 otherwise | ||
| 17167 | |||
| 17168 | my ($self, $check) = @_; | ||
| 17169 | |||
| 17170 | # Local variables | ||
| 17171 | my ( | ||
| 17172 | $tab, $slWidget, $standard, | ||
| 17173 | @comboList, | ||
| 17174 | ); | ||
| 17175 | |||
| 17176 | # Check for improper arguments | ||
| 17177 | if (defined $check) { | ||
| 17178 | |||
| 17179 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonReset_taskLabel', @_); | ||
| 17180 | } | ||
| 17181 | |||
| 17182 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 17183 | $tab = $self->notebookGetTab(); | ||
| 17184 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 17185 | |||
| 17186 | # Unselect everything in the list | ||
| 17187 | $slWidget->get_selection->unselect_all(); | ||
| 17188 | |||
| 17189 | # Get a sorted list of standard task names | ||
| 17190 | @comboList = sort {lc($a) cmp lc($b)} ($axmud::CLIENT->ivKeys('taskPackageHash')); | ||
| 17191 | |||
| 17192 | # Prompt the user to choose a task | ||
| 17193 | $standard = $self->showComboDialogue( | ||
| 17194 | 'Reset labels', | ||
| 17195 | 'Select the task which should have all its labels reset', | ||
| 17196 | \@comboList, | ||
| 17197 | ); | ||
| 17198 | |||
| 17199 | if ($standard) { | ||
| 17200 | |||
| 17201 | $self->session->pseudoCmd('resettasklabel ' . $standard, $self->pseudoCmdMode); | ||
| 17202 | |||
| 17203 | # Update the notebook | ||
| 17204 | $self->updateNotebook(); | ||
| 17205 | }; | ||
| 17206 | |||
| 17207 | return 1; | ||
| 17208 | } | ||
| 17209 | |||
| 17210 | sub buttonResetAll_taskLabel { | ||
| 17211 | |||
| 17212 | # Callback: Resets all task labels to defaults (equivalent to ';resettasklabel') | ||
| 17213 | # | ||
| 17214 | # Expected arguments | ||
| 17215 | # (none besides $self) | ||
| 17216 | # | ||
| 17217 | # Return values | ||
| 17218 | # 'undef' on improper arguments | ||
| 17219 | # 1 otherwise | ||
| 17220 | |||
| 17221 | my ($self, $check) = @_; | ||
| 17222 | |||
| 17223 | # Local variables | ||
| 17224 | my ($tab, $slWidget); | ||
| 17225 | |||
| 17226 | # Check for improper arguments | ||
| 17227 | if (defined $check) { | ||
| 17228 | |||
| 17229 | return $axmud::CLIENT->writeImproper( | ||
| 17230 | $self->_objClass . '->buttonResetAll_taskLabel', | ||
| 17231 | @_, | ||
| 17232 | ); | ||
| 17233 | } | ||
| 17234 | |||
| 17235 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 17236 | $tab = $self->notebookGetTab(); | ||
| 17237 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 17238 | |||
| 17239 | # Unselect everything in the list | ||
| 17240 | $slWidget->get_selection->unselect_all(); | ||
| 17241 | |||
| 17242 | # Reset all task labels | ||
| 17243 | $self->session->pseudoCmd('resettasklabel', $self->pseudoCmdMode); | ||
| 17244 | |||
| 17245 | # Update the notebook | ||
| 17246 | $self->updateNotebook(); | ||
| 17247 | |||
| 17248 | return 1; | ||
| 17249 | } | ||
| 17250 | |||
| 17251 | sub buttonDump_taskLabel { | ||
| 17252 | |||
| 17253 | # Callback: Displays the list of task labels in the 'main' window (equivalent to | ||
| 17254 | # ';listtasklabel') | ||
| 17255 | # | ||
| 17256 | # Expected arguments | ||
| 17257 | # (none besides $self) | ||
| 17258 | # | ||
| 17259 | # Return values | ||
| 17260 | # 'undef' on improper arguments | ||
| 17261 | # 1 otherwise | ||
| 17262 | |||
| 17263 | my ($self, $check) = @_; | ||
| 17264 | |||
| 17265 | # Local variables | ||
| 17266 | my ($tab, $slWidget); | ||
| 17267 | |||
| 17268 | # Check for improper arguments | ||
| 17269 | if (defined $check) { | ||
| 17270 | |||
| 17271 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDump_taskLabel', @_); | ||
| 17272 | } | ||
| 17273 | |||
| 17274 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 17275 | $tab = $self->notebookGetTab(); | ||
| 17276 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 17277 | |||
| 17278 | # Unselect everything in the list | ||
| 17279 | $slWidget->get_selection->unselect_all(); | ||
| 17280 | |||
| 17281 | # Dump the data | ||
| 17282 | $self->session->pseudoCmd('listtasklabel -b', $self->pseudoCmdMode); | ||
| 17283 | $self->session->pseudoCmd('listtasklabel', $self->pseudoCmdMode); | ||
| 17284 | |||
| 17285 | # Update the notebook | ||
| 17286 | $self->updateNotebook(); | ||
| 17287 | |||
| 17288 | return 1; | ||
| 17289 | } | ||
| 17290 | |||
| 17291 | # Interfaces and interface model callbacks | ||
| 17292 | |||
| 17293 | sub buttonEdit_activeInterface { | ||
| 17294 | |||
| 17295 | # Callback: Edits an active interface (equivalent to ';editactiveinterface') | ||
| 17296 | # | ||
| 17297 | # Expected arguments | ||
| 17298 | # (none besides $self) | ||
| 17299 | # | ||
| 17300 | # Return values | ||
| 17301 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 17302 | # object no longer exists | ||
| 17303 | # 1 otherwise | ||
| 17304 | |||
| 17305 | my ($self, $check) = @_; | ||
| 17306 | |||
| 17307 | # Local variables | ||
| 17308 | my ( | ||
| 17309 | $dataRef, $interfaceNum, $interfaceObj, | ||
| 17310 | @list, @dataList, | ||
| 17311 | ); | ||
| 17312 | |||
| 17313 | # Check for improper arguments | ||
| 17314 | if (defined $check) { | ||
| 17315 | |||
| 17316 | return $axmud::CLIENT->writeImproper( | ||
| 17317 | $self->_objClass . '->buttonEdit_activeInterface', | ||
| 17318 | @_, | ||
| 17319 | ); | ||
| 17320 | } | ||
| 17321 | |||
| 17322 | # Import the currently selected portions of the notebook list | ||
| 17323 | @list = $self->notebookGetSelectedData(); | ||
| 17324 | if (! @list) { | ||
| 17325 | |||
| 17326 | # Nothing selected | ||
| 17327 | return undef; | ||
| 17328 | } | ||
| 17329 | |||
| 17330 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 17331 | # a single row of the list | ||
| 17332 | $dataRef = $list[0]; | ||
| 17333 | @dataList = @$dataRef; | ||
| 17334 | # The interface's number is the first item of data | ||
| 17335 | $interfaceNum = $dataList[0]; | ||
| 17336 | if (! $interfaceNum) { | ||
| 17337 | |||
| 17338 | # Can't continue | ||
| 17339 | return undef; | ||
| 17340 | } | ||
| 17341 | |||
| 17342 | # Get the interface object itself | ||
| 17343 | $interfaceObj = $self->session->ivShow('interfaceNumHash', $interfaceNum); | ||
| 17344 | if (! $interfaceObj) { | ||
| 17345 | |||
| 17346 | # Can't continue | ||
| 17347 | return undef; | ||
| 17348 | |||
| 17349 | } else { | ||
| 17350 | |||
| 17351 | # Open up an 'edit' window to edit the object | ||
| 17352 | $self->createFreeWin( | ||
| 17353 | 'Games::Axmud::EditWin::Interface::Active', | ||
| 17354 | $self, | ||
| 17355 | $self->session, | ||
| 17356 | 'Edit active ' . $interfaceObj->category . ' interface \'' . $interfaceObj->name | ||
| 17357 | . '\'', | ||
| 17358 | $interfaceObj, | ||
| 17359 | FALSE, # Not temporary | ||
| 17360 | ); | ||
| 17361 | |||
| 17362 | return 1; | ||
| 17363 | } | ||
| 17364 | } | ||
| 17365 | |||
| 17366 | sub buttonDump_activeInterface { | ||
| 17367 | |||
| 17368 | # Callback: Displays the list of active interfaces to the 'main' window (equivalent to | ||
| 17369 | # ';listactiveinterface' <switch>) | ||
| 17370 | # | ||
| 17371 | # Expected arguments | ||
| 17372 | # (none besides $self) | ||
| 17373 | # | ||
| 17374 | # Return values | ||
| 17375 | # 'undef' on improper arguments | ||
| 17376 | # 1 otherwise | ||
| 17377 | |||
| 17378 | my ($self, $check) = @_; | ||
| 17379 | |||
| 17380 | # Local variables | ||
| 17381 | my ($tab, $slWidget); | ||
| 17382 | |||
| 17383 | # Check for improper arguments | ||
| 17384 | if (defined $check) { | ||
| 17385 | |||
| 17386 | return $axmud::CLIENT->writeImproper( | ||
| 17387 | $self->_objClass . '->buttonDump_activeInterface', | ||
| 17388 | @_, | ||
| 17389 | ); | ||
| 17390 | } | ||
| 17391 | |||
| 17392 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 17393 | $tab = $self->notebookGetTab(); | ||
| 17394 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 17395 | |||
| 17396 | # Unselect everything in the list | ||
| 17397 | $slWidget->get_selection->unselect_all(); | ||
| 17398 | |||
| 17399 | # Dump the data | ||
| 17400 | if ($tab eq 'All') { | ||
| 17401 | |||
| 17402 | $self->session->pseudoCmd('listactiveinterface -n', $self->pseudoCmdMode); | ||
| 17403 | |||
| 17404 | } elsif ($tab eq 'Dependent') { | ||
| 17405 | |||
| 17406 | $self->session->pseudoCmd('listactiveinterface -d', $self->pseudoCmdMode); | ||
| 17407 | |||
| 17408 | } elsif ($tab eq 'Independent') { | ||
| 17409 | |||
| 17410 | $self->session->pseudoCmd('listactiveinterface -i', $self->pseudoCmdMode); | ||
| 17411 | |||
| 17412 | } else { | ||
| 17413 | |||
| 17414 | # Trigger, Alias (etc) tabs | ||
| 17415 | $self->session->pseudoCmd('listactiveinterface -c ' . lc($tab), $self->pseudoCmdMode); | ||
| 17416 | } | ||
| 17417 | |||
| 17418 | # Update the notebook | ||
| 17419 | $self->updateNotebook(); | ||
| 17420 | |||
| 17421 | return 1; | ||
| 17422 | } | ||
| 17423 | |||
| 17424 | sub buttonView_interfaceModel { | ||
| 17425 | |||
| 17426 | # Callback: Views an interface model object (equivalent to ';editinterfacemodel') | ||
| 17427 | # | ||
| 17428 | # Expected arguments | ||
| 17429 | # (none besides $self) | ||
| 17430 | # | ||
| 17431 | # Return values | ||
| 17432 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 17433 | # object no longer exists | ||
| 17434 | # 1 otherwise | ||
| 17435 | |||
| 17436 | my ($self, $check) = @_; | ||
| 17437 | |||
| 17438 | # Local variables | ||
| 17439 | my ( | ||
| 17440 | $dataRef, $interfaceModelName, $interfaceModelObj, | ||
| 17441 | @list, @dataList, | ||
| 17442 | ); | ||
| 17443 | |||
| 17444 | # Check for improper arguments | ||
| 17445 | if (defined $check) { | ||
| 17446 | |||
| 17447 | return $axmud::CLIENT->writeImproper( | ||
| 17448 | $self->_objClass . '->buttonView_interfaceModel', | ||
| 17449 | @_, | ||
| 17450 | ); | ||
| 17451 | } | ||
| 17452 | |||
| 17453 | # Import the currently selected portions of the notebook list | ||
| 17454 | @list = $self->notebookGetSelectedData(); | ||
| 17455 | if (! @list) { | ||
| 17456 | |||
| 17457 | # Nothing selected | ||
| 17458 | return undef; | ||
| 17459 | } | ||
| 17460 | |||
| 17461 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 17462 | # a single row of the list | ||
| 17463 | $dataRef = $list[0]; | ||
| 17464 | @dataList = @$dataRef; | ||
| 17465 | # The interface model's name is the first item of data | ||
| 17466 | $interfaceModelName = $dataList[0]; | ||
| 17467 | if (! $interfaceModelName) { | ||
| 17468 | |||
| 17469 | # Can't continue | ||
| 17470 | return undef; | ||
| 17471 | } | ||
| 17472 | |||
| 17473 | # Get the interface model object itself | ||
| 17474 | $interfaceModelObj = $axmud::CLIENT->ivShow('interfaceModelHash', $interfaceModelName); | ||
| 17475 | if (! $interfaceModelObj) { | ||
| 17476 | |||
| 17477 | # Can't continue | ||
| 17478 | return undef; | ||
| 17479 | |||
| 17480 | } else { | ||
| 17481 | |||
| 17482 | # Open up an 'edit' window to edit the object | ||
| 17483 | $self->createFreeWin( | ||
| 17484 | 'Games::Axmud::EditWin::InterfaceModel', | ||
| 17485 | $self, | ||
| 17486 | $self->session, | ||
| 17487 | 'Edit ' . $interfaceModelObj->category . ' interface model', | ||
| 17488 | $interfaceModelObj, | ||
| 17489 | FALSE, # Not temporary | ||
| 17490 | ); | ||
| 17491 | |||
| 17492 | return 1; | ||
| 17493 | } | ||
| 17494 | } | ||
| 17495 | |||
| 17496 | sub buttonDump_interfaceModel { | ||
| 17497 | |||
| 17498 | # Callback: Displays the list of interface models to the 'main' window (equivalent to | ||
| 17499 | # ';listinterfacemodel' <switch>) | ||
| 17500 | # | ||
| 17501 | # Expected arguments | ||
| 17502 | # (none besides $self) | ||
| 17503 | # | ||
| 17504 | # Return values | ||
| 17505 | # 'undef' on improper arguments | ||
| 17506 | # 1 otherwise | ||
| 17507 | |||
| 17508 | my ($self, $check) = @_; | ||
| 17509 | |||
| 17510 | # Local variables | ||
| 17511 | my ($tab, $slWidget); | ||
| 17512 | |||
| 17513 | # Check for improper arguments | ||
| 17514 | if (defined $check) { | ||
| 17515 | |||
| 17516 | return $axmud::CLIENT->writeImproper( | ||
| 17517 | $self->_objClass . '->buttonDump_interfaceModel', | ||
| 17518 | @_, | ||
| 17519 | ); | ||
| 17520 | } | ||
| 17521 | |||
| 17522 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 17523 | $tab = $self->notebookGetTab(); | ||
| 17524 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 17525 | |||
| 17526 | # Unselect everything in the list | ||
| 17527 | $slWidget->get_selection->unselect_all(); | ||
| 17528 | |||
| 17529 | # Dump the data | ||
| 17530 | $self->session->pseudoCmd('listinterfacemodel', $self->pseudoCmdMode); | ||
| 17531 | |||
| 17532 | # Update the notebook | ||
| 17533 | $self->updateNotebook(); | ||
| 17534 | |||
| 17535 | return 1; | ||
| 17536 | } | ||
| 17537 | |||
| 17538 | # World model callbacks | ||
| 17539 | |||
| 17540 | sub buttonAdd_model { | ||
| 17541 | |||
| 17542 | # Callback: Adds a world model object (equivalent to ';addmodelobject') | ||
| 17543 | # | ||
| 17544 | # Expected arguments | ||
| 17545 | # (none besides $self) | ||
| 17546 | # | ||
| 17547 | # Return values | ||
| 17548 | # 'undef' on improper arguments | ||
| 17549 | # 1 otherwise | ||
| 17550 | |||
| 17551 | my ($self, $check) = @_; | ||
| 17552 | |||
| 17553 | # Local variables | ||
| 17554 | my ( | ||
| 17555 | $tab, $slWidget, $objName, $objParent, $string, | ||
| 17556 | %switchHash, %typeHash, | ||
| 17557 | ); | ||
| 17558 | |||
| 17559 | # Check for improper arguments | ||
| 17560 | if (defined $check) { | ||
| 17561 | |||
| 17562 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonAdd_model', @_); | ||
| 17563 | } | ||
| 17564 | |||
| 17565 | # Compile a quick hash of switches accepted by ;addmodelobject | ||
| 17566 | %switchHash = ( | ||
| 17567 | 'Weapons' => '-w', | ||
| 17568 | 'Armours' => '-a', | ||
| 17569 | 'Garments' => '-g', | ||
| 17570 | 'Characters' => '-c', | ||
| 17571 | 'Minions' => '-m', | ||
| 17572 | 'Sentients' => '-s', | ||
| 17573 | 'Creatures' => '-k', | ||
| 17574 | 'Portables' => '-p', | ||
| 17575 | 'Decorations' => '-d', | ||
| 17576 | 'Custom' => '-u', | ||
| 17577 | ); | ||
| 17578 | |||
| 17579 | # Also a hash to convert the tab name to the type of model object | ||
| 17580 | %typeHash = ( | ||
| 17581 | 'Weapons' => 'weapon', | ||
| 17582 | 'Armours' => 'armour', | ||
| 17583 | 'Garments' => 'garment', | ||
| 17584 | 'Characters' => 'char', | ||
| 17585 | 'Minions' => 'minion', | ||
| 17586 | 'Sentients' => 'sentient', | ||
| 17587 | 'Creatures' => 'creature', | ||
| 17588 | 'Portables' => 'portable', | ||
| 17589 | 'Decorations' => 'decoration', | ||
| 17590 | 'Custom' => 'custom', | ||
| 17591 | ); | ||
| 17592 | |||
| 17593 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 17594 | $tab = $self->notebookGetTab(); | ||
| 17595 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 17596 | |||
| 17597 | # Unselect everything in the list, because we're creating a new model object | ||
| 17598 | $slWidget->get_selection->unselect_all(); | ||
| 17599 | |||
| 17600 | # Prompt to get a name for the object | ||
| 17601 | ($objName, $objParent) = $self->showDoubleEntryDialogue( | ||
| 17602 | 'Add \'' . $typeHash{$tab} . '\' model object', | ||
| 17603 | 'Object name', | ||
| 17604 | 'Parent # (optional)', | ||
| 17605 | ); | ||
| 17606 | |||
| 17607 | if ($objName) { | ||
| 17608 | |||
| 17609 | if ($objParent) { | ||
| 17610 | $string = '<' . $objName . '> ' . $objParent; | ||
| 17611 | } else { | ||
| 17612 | $string = '<' . $objName . '>'; | ||
| 17613 | } | ||
| 17614 | |||
| 17615 | # Add the new world model object | ||
| 17616 | $self->session->pseudoCmd( | ||
| 17617 | 'addmodelobject ' . $switchHash{$tab} . ' ' . $string, | ||
| 17618 | $self->pseudoCmdMode, | ||
| 17619 | ); | ||
| 17620 | |||
| 17621 | # Update the notebook | ||
| 17622 | $self->updateNotebook(); | ||
| 17623 | } | ||
| 17624 | |||
| 17625 | return 1; | ||
| 17626 | } | ||
| 17627 | |||
| 17628 | sub buttonAddRegion_model { | ||
| 17629 | |||
| 17630 | # Callback: Adds a region model object (equivalent to ';addregion') | ||
| 17631 | # | ||
| 17632 | # Expected arguments | ||
| 17633 | # (none besides $self) | ||
| 17634 | # | ||
| 17635 | # Return values | ||
| 17636 | # 'undef' on improper arguments | ||
| 17637 | # 1 otherwise | ||
| 17638 | |||
| 17639 | my ($self, $check) = @_; | ||
| 17640 | |||
| 17641 | # Local variables | ||
| 17642 | my ( | ||
| 17643 | $tab, $slWidget, $objName, $objParent, $string, | ||
| 17644 | %switchHash, | ||
| 17645 | ); | ||
| 17646 | |||
| 17647 | # Check for improper arguments | ||
| 17648 | if (defined $check) { | ||
| 17649 | |||
| 17650 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonAddRegion_model', @_); | ||
| 17651 | } | ||
| 17652 | |||
| 17653 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 17654 | $tab = $self->notebookGetTab(); | ||
| 17655 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 17656 | |||
| 17657 | # Unselect everything in the list, because we're creating a new model object | ||
| 17658 | $slWidget->get_selection->unselect_all(); | ||
| 17659 | |||
| 17660 | # Prompt to get a name for the object | ||
| 17661 | ($objName, $objParent) = $self->showDoubleEntryDialogue( | ||
| 17662 | 'Add region model object', | ||
| 17663 | 'Region name', | ||
| 17664 | 'Parent region name (optional)', | ||
| 17665 | ); | ||
| 17666 | |||
| 17667 | if ($objName) { | ||
| 17668 | |||
| 17669 | if ($objParent) { | ||
| 17670 | $string = '<' . $objName . '> ' . $objParent; | ||
| 17671 | } else { | ||
| 17672 | $string = '<' . $objName . '>'; | ||
| 17673 | } | ||
| 17674 | |||
| 17675 | # Add the new region model object | ||
| 17676 | $self->session->pseudoCmd( | ||
| 17677 | 'addregion ' . $string, | ||
| 17678 | $self->pseudoCmdMode, | ||
| 17679 | ); | ||
| 17680 | |||
| 17681 | # Update the notebook | ||
| 17682 | $self->updateNotebook(); | ||
| 17683 | } | ||
| 17684 | |||
| 17685 | return 1; | ||
| 17686 | } | ||
| 17687 | |||
| 17688 | sub buttonAddChar_model { | ||
| 17689 | |||
| 17690 | # Callback: Adds a character model object (equivalent to ';addplayercharacter') | ||
| 17691 | # | ||
| 17692 | # Expected arguments | ||
| 17693 | # (none besides $self) | ||
| 17694 | # | ||
| 17695 | # Return values | ||
| 17696 | # 'undef' on improper arguments | ||
| 17697 | # 1 otherwise | ||
| 17698 | |||
| 17699 | my ($self, $check) = @_; | ||
| 17700 | |||
| 17701 | # Local variables | ||
| 17702 | my ( | ||
| 17703 | $tab, $slWidget, $objName, $objParent, $string, | ||
| 17704 | %switchHash, | ||
| 17705 | ); | ||
| 17706 | |||
| 17707 | # Check for improper arguments | ||
| 17708 | if (defined $check) { | ||
| 17709 | |||
| 17710 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonAddChar_model', @_); | ||
| 17711 | } | ||
| 17712 | |||
| 17713 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 17714 | $tab = $self->notebookGetTab(); | ||
| 17715 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 17716 | |||
| 17717 | # Unselect everything in the list, because we're creating a new model object | ||
| 17718 | $slWidget->get_selection->unselect_all(); | ||
| 17719 | |||
| 17720 | # Prompt to get a name for the object | ||
| 17721 | ($objName, $objParent) = $self->showDoubleEntryDialogue( | ||
| 17722 | 'Add character model object', | ||
| 17723 | 'Character name', | ||
| 17724 | 'Parent object # (optional)', | ||
| 17725 | 16, # Max length 16 characters, to match profile name maximum | ||
| 17726 | ); | ||
| 17727 | |||
| 17728 | if ($objName) { | ||
| 17729 | |||
| 17730 | if ($objParent) { | ||
| 17731 | $string = '<' . $objName . '> ' . $objParent; | ||
| 17732 | } else { | ||
| 17733 | $string = '<' . $objName . '>'; | ||
| 17734 | } | ||
| 17735 | |||
| 17736 | # Add the new region model object | ||
| 17737 | $self->session->pseudoCmd( | ||
| 17738 | 'addplayercharacter ' . $string, | ||
| 17739 | $self->pseudoCmdMode, | ||
| 17740 | ); | ||
| 17741 | |||
| 17742 | # Update the notebook | ||
| 17743 | $self->updateNotebook(); | ||
| 17744 | } | ||
| 17745 | |||
| 17746 | return 1; | ||
| 17747 | } | ||
| 17748 | |||
| 17749 | sub buttonAddTempRegion_model { | ||
| 17750 | |||
| 17751 | # Callback: Adds a temporary region model object (equivalent to ';addregion -t') | ||
| 17752 | # | ||
| 17753 | # Expected arguments | ||
| 17754 | # (none besides $self) | ||
| 17755 | # | ||
| 17756 | # Return values | ||
| 17757 | # 'undef' on improper arguments | ||
| 17758 | # 1 otherwise | ||
| 17759 | |||
| 17760 | my ($self, $check) = @_; | ||
| 17761 | |||
| 17762 | # Local variables | ||
| 17763 | my ( | ||
| 17764 | $tab, $slWidget, $objName, $objParent, $string, | ||
| 17765 | %switchHash, | ||
| 17766 | ); | ||
| 17767 | |||
| 17768 | # Check for improper arguments | ||
| 17769 | if (defined $check) { | ||
| 17770 | |||
| 17771 | return $axmud::CLIENT->writeImproper( | ||
| 17772 | $self->_objClass . '->buttonAddTempRegion_model', | ||
| 17773 | @_, | ||
| 17774 | ); | ||
| 17775 | } | ||
| 17776 | |||
| 17777 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 17778 | $tab = $self->notebookGetTab(); | ||
| 17779 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 17780 | |||
| 17781 | # Unselect everything in the list, because we're creating a new model object | ||
| 17782 | $slWidget->get_selection->unselect_all(); | ||
| 17783 | |||
| 17784 | # Prompt to get a name for the object | ||
| 17785 | ($objName, $objParent) = $self->showDoubleEntryDialogue( | ||
| 17786 | 'Add temporary region model object', | ||
| 17787 | 'Region name', | ||
| 17788 | 'Parent region name (optional)', | ||
| 17789 | ); | ||
| 17790 | |||
| 17791 | if ($objName) { | ||
| 17792 | |||
| 17793 | if ($objParent) { | ||
| 17794 | $string = '<' . $objName . '> <' . $objParent . '>'; | ||
| 17795 | } else { | ||
| 17796 | $string = '<' . $objName . '>'; | ||
| 17797 | } | ||
| 17798 | |||
| 17799 | # Add the new region model object | ||
| 17800 | $self->session->pseudoCmd( | ||
| 17801 | 'addregion ' . $string . ' -t', | ||
| 17802 | $self->pseudoCmdMode, | ||
| 17803 | ); | ||
| 17804 | |||
| 17805 | # Update the notebook | ||
| 17806 | $self->updateNotebook(); | ||
| 17807 | } | ||
| 17808 | |||
| 17809 | return 1; | ||
| 17810 | } | ||
| 17811 | |||
| 17812 | sub buttonEdit_model { | ||
| 17813 | |||
| 17814 | # Callback: Edits a world model object (equivalent to ';editmodelobject') | ||
| 17815 | # | ||
| 17816 | # Expected arguments | ||
| 17817 | # (none besides $self) | ||
| 17818 | # | ||
| 17819 | # Return values | ||
| 17820 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 17821 | # object no longer exists | ||
| 17822 | # 1 otherwise | ||
| 17823 | |||
| 17824 | my ($self, $check) = @_; | ||
| 17825 | |||
| 17826 | # Local variables | ||
| 17827 | my ( | ||
| 17828 | $dataRef, $number, $obj, $package, | ||
| 17829 | @list, @dataList, | ||
| 17830 | ); | ||
| 17831 | |||
| 17832 | # Check for improper arguments | ||
| 17833 | if (defined $check) { | ||
| 17834 | |||
| 17835 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonEdit_model', @_); | ||
| 17836 | } | ||
| 17837 | |||
| 17838 | # Import the currently selected portions of the notebook list | ||
| 17839 | @list = $self->notebookGetSelectedData(); | ||
| 17840 | if (! @list) { | ||
| 17841 | |||
| 17842 | # Nothing selected | ||
| 17843 | return undef; | ||
| 17844 | } | ||
| 17845 | |||
| 17846 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 17847 | # a single row of the list | ||
| 17848 | $dataRef = $list[0]; | ||
| 17849 | @dataList = @$dataRef; | ||
| 17850 | # The world model object's unique number is the first item of data | ||
| 17851 | $number = $dataList[0]; | ||
| 17852 | if (! $number) { | ||
| 17853 | |||
| 17854 | # Can't continue | ||
| 17855 | return undef; | ||
| 17856 | } | ||
| 17857 | |||
| 17858 | # Get the world model object itself | ||
| 17859 | $obj = $self->session->worldModelObj->ivShow('modelHash', $number); | ||
| 17860 | if (! $obj) { | ||
| 17861 | |||
| 17862 | # Can't continue | ||
| 17863 | return undef; | ||
| 17864 | |||
| 17865 | } else { | ||
| 17866 | |||
| 17867 | $package = 'Games::Axmud::EditWin::ModelObj::' . ucfirst($obj->category); | ||
| 17868 | |||
| 17869 | # Open up an 'edit' window to edit the object | ||
| 17870 | $self->createFreeWin( | ||
| 17871 | 'Games::Axmud::EditWin::ModelObj::' . ucfirst($obj->category), | ||
| 17872 | $self, | ||
| 17873 | $self->session, | ||
| 17874 | 'Edit ' . $obj->category . ' model object #' . $obj->number, | ||
| 17875 | $obj, | ||
| 17876 | FALSE, | ||
| 17877 | ); | ||
| 17878 | } | ||
| 17879 | |||
| 17880 | return 1; | ||
| 17881 | } | ||
| 17882 | |||
| 17883 | sub buttonEdit_worldModel { | ||
| 17884 | |||
| 17885 | # Callback: Edits a world model object (equivalent to ';editmodel') | ||
| 17886 | # | ||
| 17887 | # Expected arguments | ||
| 17888 | # (none besides $self) | ||
| 17889 | # | ||
| 17890 | # Return values | ||
| 17891 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 17892 | # object no longer exists | ||
| 17893 | # 1 otherwise | ||
| 17894 | |||
| 17895 | my ($self, $check) = @_; | ||
| 17896 | |||
| 17897 | # Local variables | ||
| 17898 | my ($tab, $slWidget); | ||
| 17899 | |||
| 17900 | # Check for improper arguments | ||
| 17901 | if (defined $check) { | ||
| 17902 | |||
| 17903 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonEdit_worldModel', @_); | ||
| 17904 | } | ||
| 17905 | |||
| 17906 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 17907 | $tab = $self->notebookGetTab(); | ||
| 17908 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 17909 | |||
| 17910 | # Unselect everything in the list, because we're creating a new model object | ||
| 17911 | $slWidget->get_selection->unselect_all(); | ||
| 17912 | |||
| 17913 | # Open up an 'edit' window to edit the world model | ||
| 17914 | $self->createFreeWin( | ||
| 17915 | 'Games::Axmud::EditWin::WorldModel', | ||
| 17916 | $self, | ||
| 17917 | $self->session, | ||
| 17918 | 'Edit world model', | ||
| 17919 | $self->session->worldModelObj, | ||
| 17920 | FALSE, | ||
| 17921 | ); | ||
| 17922 | |||
| 17923 | return 1; | ||
| 17924 | } | ||
| 17925 | |||
| 17926 | sub buttonEdit_regionmap { | ||
| 17927 | |||
| 17928 | # Callback: Edits a regionmap corresponding to the selected world model object (equivalent | ||
| 17929 | # to ';editregionmap') | ||
| 17930 | # | ||
| 17931 | # Expected arguments | ||
| 17932 | # (none besides $self) | ||
| 17933 | # | ||
| 17934 | # Return values | ||
| 17935 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 17936 | # object no longer exists | ||
| 17937 | # 1 otherwise | ||
| 17938 | |||
| 17939 | my ($self, $check) = @_; | ||
| 17940 | |||
| 17941 | # Local variables | ||
| 17942 | my ( | ||
| 17943 | $dataRef, $name, $obj, | ||
| 17944 | @list, @dataList, | ||
| 17945 | ); | ||
| 17946 | |||
| 17947 | # Check for improper arguments | ||
| 17948 | if (defined $check) { | ||
| 17949 | |||
| 17950 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonEdit_regionmap', @_); | ||
| 17951 | } | ||
| 17952 | |||
| 17953 | # Import the currently selected portions of the notebook list | ||
| 17954 | @list = $self->notebookGetSelectedData(); | ||
| 17955 | if (! @list) { | ||
| 17956 | |||
| 17957 | # Nothing selected | ||
| 17958 | return undef; | ||
| 17959 | } | ||
| 17960 | |||
| 17961 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 17962 | # a single row of the list | ||
| 17963 | $dataRef = $list[0]; | ||
| 17964 | @dataList = @$dataRef; | ||
| 17965 | # The regionmap's name is the third item of data | ||
| 17966 | $name = $dataList[2]; | ||
| 17967 | if (! $name) { | ||
| 17968 | |||
| 17969 | # Can't continue | ||
| 17970 | return undef; | ||
| 17971 | } | ||
| 17972 | |||
| 17973 | # Get the regionmap object itself | ||
| 17974 | $obj = $self->session->worldModelObj->ivShow('regionmapHash', $name); | ||
| 17975 | if (! $obj) { | ||
| 17976 | |||
| 17977 | # Can't continue | ||
| 17978 | return undef; | ||
| 17979 | |||
| 17980 | } else { | ||
| 17981 | |||
| 17982 | # Open up an 'edit' window to edit the object | ||
| 17983 | $self->createFreeWin( | ||
| 17984 | 'Games::Axmud::EditWin::Regionmap', | ||
| 17985 | $self, | ||
| 17986 | $self->session, | ||
| 17987 | 'Edit regionmap \'' . $obj->name . '\'', | ||
| 17988 | $obj, | ||
| 17989 | FALSE, | ||
| 17990 | ); | ||
| 17991 | } | ||
| 17992 | |||
| 17993 | return 1; | ||
| 17994 | } | ||
| 17995 | |||
| 17996 | sub buttonDelete_model { | ||
| 17997 | |||
| 17998 | # Callback: Deletes a world model object (equivalent to ';deletemodelobject') | ||
| 17999 | # | ||
| 18000 | # Expected arguments | ||
| 18001 | # (none besides $self) | ||
| 18002 | # | ||
| 18003 | # Return values | ||
| 18004 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 18005 | # 1 otherwise | ||
| 18006 | |||
| 18007 | my ($self, $check) = @_; | ||
| 18008 | |||
| 18009 | # Local variables | ||
| 18010 | my ( | ||
| 18011 | $dataRef, $number, | ||
| 18012 | @list, @dataList, | ||
| 18013 | ); | ||
| 18014 | |||
| 18015 | # Check for improper arguments | ||
| 18016 | if (defined $check) { | ||
| 18017 | |||
| 18018 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDelete_model', @_); | ||
| 18019 | } | ||
| 18020 | |||
| 18021 | # Import the currently selected portions of the notebook list | ||
| 18022 | @list = $self->notebookGetSelectedData(); | ||
| 18023 | if (! @list) { | ||
| 18024 | |||
| 18025 | # Nothing selected | ||
| 18026 | return undef; | ||
| 18027 | } | ||
| 18028 | |||
| 18029 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 18030 | # a single row of the list | ||
| 18031 | $dataRef = $list[0]; | ||
| 18032 | @dataList = @$dataRef; | ||
| 18033 | # The model object number is the first item of data | ||
| 18034 | $number = $dataList[0]; | ||
| 18035 | if (! $number) { | ||
| 18036 | |||
| 18037 | # Can't continue | ||
| 18038 | return undef; | ||
| 18039 | } | ||
| 18040 | |||
| 18041 | # Delete the world model object | ||
| 18042 | $self->session->pseudoCmd('deletemodelobject ' . $number, $self->pseudoCmdMode); | ||
| 18043 | |||
| 18044 | # Update the notebook | ||
| 18045 | $self->updateNotebook(); | ||
| 18046 | |||
| 18047 | return 1; | ||
| 18048 | } | ||
| 18049 | |||
| 18050 | sub buttonDeleteRegion_model { | ||
| 18051 | |||
| 18052 | # Callback: Deletes a region model object (equivalent to ';deleteregion') | ||
| 18053 | # | ||
| 18054 | # Expected arguments | ||
| 18055 | # (none besides $self) | ||
| 18056 | # | ||
| 18057 | # Return values | ||
| 18058 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 18059 | # 1 otherwise | ||
| 18060 | |||
| 18061 | my ($self, $check) = @_; | ||
| 18062 | |||
| 18063 | # Local variables | ||
| 18064 | my ( | ||
| 18065 | $dataRef, $number, | ||
| 18066 | @list, @dataList, | ||
| 18067 | ); | ||
| 18068 | |||
| 18069 | # Check for improper arguments | ||
| 18070 | if (defined $check) { | ||
| 18071 | |||
| 18072 | return $axmud::CLIENT->writeImproper( | ||
| 18073 | $self->_objClass . '->buttonDeleteRegion_model', | ||
| 18074 | @_, | ||
| 18075 | ); | ||
| 18076 | } | ||
| 18077 | |||
| 18078 | # Import the currently selected portions of the notebook list | ||
| 18079 | @list = $self->notebookGetSelectedData(); | ||
| 18080 | if (! @list) { | ||
| 18081 | |||
| 18082 | # Nothing selected | ||
| 18083 | return undef; | ||
| 18084 | } | ||
| 18085 | |||
| 18086 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 18087 | # a single row of the list | ||
| 18088 | $dataRef = $list[0]; | ||
| 18089 | @dataList = @$dataRef; | ||
| 18090 | # The model object number is the first item of data | ||
| 18091 | $number = $dataList[0]; | ||
| 18092 | if (! $number) { | ||
| 18093 | |||
| 18094 | # Can't continue | ||
| 18095 | return undef; | ||
| 18096 | } | ||
| 18097 | |||
| 18098 | # Delete the region model object | ||
| 18099 | $self->session->pseudoCmd('deleteregion ' . $number, $self->pseudoCmdMode); | ||
| 18100 | |||
| 18101 | # Update the notebook | ||
| 18102 | $self->updateNotebook(); | ||
| 18103 | |||
| 18104 | return 1; | ||
| 18105 | } | ||
| 18106 | |||
| 18107 | sub buttonDeleteRoom_model { | ||
| 18108 | |||
| 18109 | # Callback: Deletes a room model object (equivalent to ';deleteroom') | ||
| 18110 | # | ||
| 18111 | # Expected arguments | ||
| 18112 | # (none besides $self) | ||
| 18113 | # | ||
| 18114 | # Return values | ||
| 18115 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 18116 | # 1 otherwise | ||
| 18117 | |||
| 18118 | my ($self, $check) = @_; | ||
| 18119 | |||
| 18120 | # Local variables | ||
| 18121 | my ( | ||
| 18122 | $dataRef, $number, | ||
| 18123 | @list, @dataList, | ||
| 18124 | ); | ||
| 18125 | |||
| 18126 | # Check for improper arguments | ||
| 18127 | if (defined $check) { | ||
| 18128 | |||
| 18129 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDeleteRoom_model', @_); | ||
| 18130 | } | ||
| 18131 | |||
| 18132 | # Import the currently selected portions of the notebook list | ||
| 18133 | @list = $self->notebookGetSelectedData(); | ||
| 18134 | if (! @list) { | ||
| 18135 | |||
| 18136 | # Nothing selected | ||
| 18137 | return undef; | ||
| 18138 | } | ||
| 18139 | |||
| 18140 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 18141 | # a single row of the list | ||
| 18142 | $dataRef = $list[0]; | ||
| 18143 | @dataList = @$dataRef; | ||
| 18144 | # The model object number is the first item of data | ||
| 18145 | $number = $dataList[0]; | ||
| 18146 | if (! $number) { | ||
| 18147 | |||
| 18148 | # Can't continue | ||
| 18149 | return undef; | ||
| 18150 | } | ||
| 18151 | |||
| 18152 | # Delete the room model object | ||
| 18153 | $self->session->pseudoCmd('deleteroom ' . $number, $self->pseudoCmdMode); | ||
| 18154 | |||
| 18155 | # Update the notebook | ||
| 18156 | $self->updateNotebook(); | ||
| 18157 | |||
| 18158 | return 1; | ||
| 18159 | } | ||
| 18160 | |||
| 18161 | sub buttonDump_Model { | ||
| 18162 | |||
| 18163 | # Callback: Displays a list of world model objects in the 'main' window (equivalent to | ||
| 18164 | # ';dumpmodel') | ||
| 18165 | # | ||
| 18166 | # Expected arguments | ||
| 18167 | # (none besides $self) | ||
| 18168 | # | ||
| 18169 | # Return values | ||
| 18170 | # 'undef' on improper arguments | ||
| 18171 | # 1 otherwise | ||
| 18172 | |||
| 18173 | my ($self, $check) = @_; | ||
| 18174 | |||
| 18175 | # Local variables | ||
| 18176 | my ($tab, $slWidget); | ||
| 18177 | |||
| 18178 | # Check for improper arguments | ||
| 18179 | if (defined $check) { | ||
| 18180 | |||
| 18181 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDump_Model', @_); | ||
| 18182 | } | ||
| 18183 | |||
| 18184 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 18185 | $tab = $self->notebookGetTab(); | ||
| 18186 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 18187 | |||
| 18188 | # Unselect everything in the list | ||
| 18189 | $slWidget->get_selection->unselect_all(); | ||
| 18190 | |||
| 18191 | # Display the list | ||
| 18192 | $self->session->pseudoCmd('dumpmodel', $self->pseudoCmdMode); | ||
| 18193 | |||
| 18194 | return 1; | ||
| 18195 | } | ||
| 18196 | |||
| 18197 | sub buttonDumpChar_model { | ||
| 18198 | |||
| 18199 | # Callback: Displays a list of character model objects in the 'main' window (equivalent to | ||
| 18200 | # ';listplayercharacter -a') | ||
| 18201 | # | ||
| 18202 | # Expected arguments | ||
| 18203 | # (none besides $self) | ||
| 18204 | # | ||
| 18205 | # Return values | ||
| 18206 | # 'undef' on improper arguments | ||
| 18207 | # 1 otherwise | ||
| 18208 | |||
| 18209 | my ($self, $check) = @_; | ||
| 18210 | |||
| 18211 | # Local variables | ||
| 18212 | my ($tab, $slWidget); | ||
| 18213 | |||
| 18214 | # Check for improper arguments | ||
| 18215 | if (defined $check) { | ||
| 18216 | |||
| 18217 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDumpChar_model', @_); | ||
| 18218 | } | ||
| 18219 | |||
| 18220 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 18221 | $tab = $self->notebookGetTab(); | ||
| 18222 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 18223 | |||
| 18224 | # Unselect everything in the list | ||
| 18225 | $slWidget->get_selection->unselect_all(); | ||
| 18226 | |||
| 18227 | # Display the list | ||
| 18228 | $self->session->pseudoCmd('listplayercharacter -a', $self->pseudoCmdMode); | ||
| 18229 | |||
| 18230 | return 1; | ||
| 18231 | } | ||
| 18232 | |||
| 18233 | sub buttonAdd_exitModel { | ||
| 18234 | |||
| 18235 | # Callback: Adds an exit model object (equivalent to ';addexit') | ||
| 18236 | # | ||
| 18237 | # Expected arguments | ||
| 18238 | # (none besides $self) | ||
| 18239 | # | ||
| 18240 | # Return values | ||
| 18241 | # 'undef' on improper arguments | ||
| 18242 | # 1 otherwise | ||
| 18243 | |||
| 18244 | my ($self, $check) = @_; | ||
| 18245 | |||
| 18246 | # Local variables | ||
| 18247 | my ($tab, $slWidget, $obj, $objName, $objParent, $string); | ||
| 18248 | |||
| 18249 | # Check for improper arguments | ||
| 18250 | if (defined $check) { | ||
| 18251 | |||
| 18252 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonAdd_exitModel', @_); | ||
| 18253 | } | ||
| 18254 | |||
| 18255 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 18256 | $tab = $self->notebookGetTab(); | ||
| 18257 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 18258 | |||
| 18259 | # Unselect everything in the list, because we're creating a new model object | ||
| 18260 | $slWidget->get_selection->unselect_all(); | ||
| 18261 | |||
| 18262 | # Prompt to get a name for the object | ||
| 18263 | ($objName, $objParent) = $self->showDoubleEntryDialogue( | ||
| 18264 | 'Add exit object', | ||
| 18265 | 'Nominal direction', | ||
| 18266 | 'Parent room #', | ||
| 18267 | 32, # Max chars for directions | ||
| 18268 | ); | ||
| 18269 | |||
| 18270 | if ($objName && $objParent) { | ||
| 18271 | |||
| 18272 | if ($objParent) { | ||
| 18273 | $string = $objName . ' ' . $objParent; | ||
| 18274 | } else { | ||
| 18275 | $string = $objName; | ||
| 18276 | } | ||
| 18277 | |||
| 18278 | # Add the new exit model object | ||
| 18279 | $self->session->pseudoCmd('addexit ' . $string, $self->pseudoCmdMode); | ||
| 18280 | |||
| 18281 | # Update the notebook | ||
| 18282 | $self->updateNotebook(); | ||
| 18283 | } | ||
| 18284 | |||
| 18285 | return 1; | ||
| 18286 | } | ||
| 18287 | |||
| 18288 | sub buttonEdit_exitModel { | ||
| 18289 | |||
| 18290 | # Callback: Edits an exit model object (equivalent to ';editexit') | ||
| 18291 | # | ||
| 18292 | # Expected arguments | ||
| 18293 | # (none besides $self) | ||
| 18294 | # | ||
| 18295 | # Return values | ||
| 18296 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 18297 | # object no longer exists | ||
| 18298 | # 1 otherwise | ||
| 18299 | |||
| 18300 | my ($self, $check) = @_; | ||
| 18301 | |||
| 18302 | # Local variables | ||
| 18303 | my ( | ||
| 18304 | $dataRef, $number, $obj, | ||
| 18305 | @list, @dataList, | ||
| 18306 | ); | ||
| 18307 | |||
| 18308 | # Check for improper arguments | ||
| 18309 | if (defined $check) { | ||
| 18310 | |||
| 18311 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonEdit_exitModel', @_); | ||
| 18312 | } | ||
| 18313 | |||
| 18314 | # Import the currently selected portions of the notebook list | ||
| 18315 | @list = $self->notebookGetSelectedData(); | ||
| 18316 | if (! @list) { | ||
| 18317 | |||
| 18318 | # Nothing selected | ||
| 18319 | return undef; | ||
| 18320 | } | ||
| 18321 | |||
| 18322 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 18323 | # a single row of the list | ||
| 18324 | $dataRef = $list[0]; | ||
| 18325 | @dataList = @$dataRef; | ||
| 18326 | # The exit model object's unique number is the first item of data | ||
| 18327 | $number = $dataList[0]; | ||
| 18328 | if (! $number) { | ||
| 18329 | |||
| 18330 | # Can't continue | ||
| 18331 | return undef; | ||
| 18332 | } | ||
| 18333 | |||
| 18334 | # Get the world model object itself | ||
| 18335 | $obj = $self->session->worldModelObj->ivShow('exitModelHash', $number); | ||
| 18336 | if (! $obj) { | ||
| 18337 | |||
| 18338 | # Can't continue | ||
| 18339 | return undef; | ||
| 18340 | |||
| 18341 | } else { | ||
| 18342 | |||
| 18343 | # Open up an 'edit' window to edit the object | ||
| 18344 | $self->createFreeWin( | ||
| 18345 | 'Games::Axmud::EditWin::Exit', | ||
| 18346 | $self, | ||
| 18347 | $self->session, | ||
| 18348 | 'Edit exit model object #' . $obj->number, | ||
| 18349 | $obj, | ||
| 18350 | FALSE, # Not temporary | ||
| 18351 | ); | ||
| 18352 | } | ||
| 18353 | |||
| 18354 | return 1; | ||
| 18355 | } | ||
| 18356 | |||
| 18357 | sub buttonDelete_exitModel { | ||
| 18358 | |||
| 18359 | # Callback: Deletes an exit model object (equivalent to ';deleteexit') | ||
| 18360 | # | ||
| 18361 | # Expected arguments | ||
| 18362 | # (none besides $self) | ||
| 18363 | # | ||
| 18364 | # Return values | ||
| 18365 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 18366 | # 1 otherwise | ||
| 18367 | |||
| 18368 | my ($self, $check) = @_; | ||
| 18369 | |||
| 18370 | # Local variables | ||
| 18371 | my ( | ||
| 18372 | $dataRef, $number, | ||
| 18373 | @list, @dataList, | ||
| 18374 | ); | ||
| 18375 | |||
| 18376 | # Check for improper arguments | ||
| 18377 | if (defined $check) { | ||
| 18378 | |||
| 18379 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDelete_exitModel', @_); | ||
| 18380 | } | ||
| 18381 | |||
| 18382 | # Import the currently selected portions of the notebook list | ||
| 18383 | @list = $self->notebookGetSelectedData(); | ||
| 18384 | if (! @list) { | ||
| 18385 | |||
| 18386 | # Nothing selected | ||
| 18387 | return undef; | ||
| 18388 | } | ||
| 18389 | |||
| 18390 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 18391 | # a single row of the list | ||
| 18392 | $dataRef = $list[0]; | ||
| 18393 | @dataList = @$dataRef; | ||
| 18394 | # The model object number is the first item of data | ||
| 18395 | $number = $dataList[0]; | ||
| 18396 | if (! $number) { | ||
| 18397 | |||
| 18398 | # Can't continue | ||
| 18399 | return undef; | ||
| 18400 | } | ||
| 18401 | |||
| 18402 | # Delete the exit model object | ||
| 18403 | $self->session->pseudoCmd('deleteexit ' . $number, $self->pseudoCmdMode); | ||
| 18404 | |||
| 18405 | # Update the notebook | ||
| 18406 | $self->updateNotebook(); | ||
| 18407 | |||
| 18408 | return 1; | ||
| 18409 | } | ||
| 18410 | |||
| 18411 | sub buttonDump_exitModel { | ||
| 18412 | |||
| 18413 | # Callback: Displays a list of exit model objects in the 'main' window (equivalent to | ||
| 18414 | # ';dumpexitmodel') | ||
| 18415 | # | ||
| 18416 | # Expected arguments | ||
| 18417 | # (none besides $self) | ||
| 18418 | # | ||
| 18419 | # Return values | ||
| 18420 | # 'undef' on improper arguments | ||
| 18421 | # 1 otherwise | ||
| 18422 | |||
| 18423 | my ($self, $check) = @_; | ||
| 18424 | |||
| 18425 | # Local variables | ||
| 18426 | my ($tab, $slWidget); | ||
| 18427 | |||
| 18428 | # Check for improper arguments | ||
| 18429 | if (defined $check) { | ||
| 18430 | |||
| 18431 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDump_exitModel', @_); | ||
| 18432 | } | ||
| 18433 | |||
| 18434 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 18435 | $tab = $self->notebookGetTab(); | ||
| 18436 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 18437 | |||
| 18438 | # Unselect everything in the list | ||
| 18439 | $slWidget->get_selection->unselect_all(); | ||
| 18440 | |||
| 18441 | # Display the list | ||
| 18442 | $self->session->pseudoCmd('dumpexitmodel', $self->pseudoCmdMode); | ||
| 18443 | |||
| 18444 | return 1; | ||
| 18445 | } | ||
| 18446 | |||
| 18447 | # Buffer callbacks | ||
| 18448 | |||
| 18449 | sub buttonDump20_displayBuffer { | ||
| 18450 | |||
| 18451 | # Callback: Display a list of the 20 most recent lines from the display buffer in the | ||
| 18452 | # 'main' window (equivalent to ';dumpdisplaybuffer <start> <stop>') | ||
| 18453 | # | ||
| 18454 | # Expected arguments | ||
| 18455 | # (none besides $self) | ||
| 18456 | # | ||
| 18457 | # Return values | ||
| 18458 | # 'undef' on improper arguments | ||
| 18459 | # 1 otherwise | ||
| 18460 | |||
| 18461 | my ($self, $check) = @_; | ||
| 18462 | |||
| 18463 | # Local variables | ||
| 18464 | my ($tab, $slWidget, $start, $stop); | ||
| 18465 | |||
| 18466 | # Check for improper arguments | ||
| 18467 | if (defined $check) { | ||
| 18468 | |||
| 18469 | return $axmud::CLIENT->writeImproper( | ||
| 18470 | $self->_objClass . '->buttonDump20_displayBuffer', | ||
| 18471 | @_, | ||
| 18472 | ); | ||
| 18473 | } | ||
| 18474 | |||
| 18475 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 18476 | $tab = $self->notebookGetTab(); | ||
| 18477 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 18478 | |||
| 18479 | # Unselect everything in the list | ||
| 18480 | $slWidget->get_selection->unselect_all(); | ||
| 18481 | |||
| 18482 | # Don't do anything if no lines have been received | ||
| 18483 | if ($self->session->displayBufferFirst) { | ||
| 18484 | |||
| 18485 | # Work out the line numbers | ||
| 18486 | $stop = $self->session->displayBufferLast; | ||
| 18487 | $start = $self->session->displayBufferLast - 19; | ||
| 18488 | if ($start < 1) { | ||
| 18489 | |||
| 18490 | $start = 1; | ||
| 18491 | } | ||
| 18492 | |||
| 18493 | # Display the lines | ||
| 18494 | $self->session->pseudoCmd( | ||
| 18495 | 'dumpdisplaybuffer ' . $start . ' ' . $stop, | ||
| 18496 | $self->pseudoCmdMode, | ||
| 18497 | ); | ||
| 18498 | } | ||
| 18499 | |||
| 18500 | return 1; | ||
| 18501 | } | ||
| 18502 | |||
| 18503 | sub buttonDumpAll_displayBuffer { | ||
| 18504 | |||
| 18505 | # Callback: Display a list of all lines from the display buffer in the 'main' window | ||
| 18506 | # (equivalent to ';dumpdisplaybuffer <first line> <last line>') | ||
| 18507 | # | ||
| 18508 | # Expected arguments | ||
| 18509 | # (none besides $self) | ||
| 18510 | # | ||
| 18511 | # Return values | ||
| 18512 | # 'undef' on improper arguments | ||
| 18513 | # 1 otherwise | ||
| 18514 | |||
| 18515 | my ($self, $check) = @_; | ||
| 18516 | |||
| 18517 | # Local variables | ||
| 18518 | my ($tab, $slWidget, $start, $stop); | ||
| 18519 | |||
| 18520 | # Check for improper arguments | ||
| 18521 | if (defined $check) { | ||
| 18522 | |||
| 18523 | return $axmud::CLIENT->writeImproper( | ||
| 18524 | $self->_objClass . '->buttonDumpAll_displayBuffer', | ||
| 18525 | @_, | ||
| 18526 | ); | ||
| 18527 | } | ||
| 18528 | |||
| 18529 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 18530 | $tab = $self->notebookGetTab(); | ||
| 18531 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 18532 | |||
| 18533 | # Unselect everything in the list | ||
| 18534 | $slWidget->get_selection->unselect_all(); | ||
| 18535 | |||
| 18536 | # Don't do anything if no lines have been received | ||
| 18537 | if ($self->session->displayBufferFirst) { | ||
| 18538 | |||
| 18539 | # Work out the line numbers | ||
| 18540 | $stop = $self->session->displayBufferLast; | ||
| 18541 | $start = $self->session->displayBufferFirst; | ||
| 18542 | |||
| 18543 | # Display the lines | ||
| 18544 | $self->session->pseudoCmd( | ||
| 18545 | 'dumpdisplaybuffer ' . $start . ' ' . $stop, | ||
| 18546 | $self->pseudoCmdMode, | ||
| 18547 | ); | ||
| 18548 | } | ||
| 18549 | |||
| 18550 | return 1; | ||
| 18551 | } | ||
| 18552 | |||
| 18553 | sub buttonStatus_displayBuffer { | ||
| 18554 | |||
| 18555 | # Callback: Display the display buffer's status in the 'main' window (equivalent to | ||
| 18556 | # ';displaybuffer') | ||
| 18557 | # | ||
| 18558 | # Expected arguments | ||
| 18559 | # (none besides $self) | ||
| 18560 | # | ||
| 18561 | # Return values | ||
| 18562 | # 'undef' on improper arguments | ||
| 18563 | # 1 otherwise | ||
| 18564 | |||
| 18565 | my ($self, $check) = @_; | ||
| 18566 | |||
| 18567 | # Local variables | ||
| 18568 | my ($tab, $slWidget, $start, $stop); | ||
| 18569 | |||
| 18570 | # Check for improper arguments | ||
| 18571 | if (defined $check) { | ||
| 18572 | |||
| 18573 | return $axmud::CLIENT->writeImproper( | ||
| 18574 | $self->_objClass . '->buttonStatus_displayBuffer', | ||
| 18575 | @_, | ||
| 18576 | ); | ||
| 18577 | } | ||
| 18578 | |||
| 18579 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 18580 | $tab = $self->notebookGetTab(); | ||
| 18581 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 18582 | |||
| 18583 | # Unselect everything in the list | ||
| 18584 | $slWidget->get_selection->unselect_all(); | ||
| 18585 | |||
| 18586 | # Display the display buffer status | ||
| 18587 | $self->session->pseudoCmd('displaybuffer', $self->pseudoCmdMode); | ||
| 18588 | |||
| 18589 | return 1; | ||
| 18590 | } | ||
| 18591 | |||
| 18592 | sub buttonView_displayBuffer { | ||
| 18593 | |||
| 18594 | # Callback: Views the selected display buffer line in an 'edit' window (equivalent to | ||
| 18595 | # ';editdisplaybuffer') | ||
| 18596 | # | ||
| 18597 | # Expected arguments | ||
| 18598 | # (none besides $self) | ||
| 18599 | # | ||
| 18600 | # Return values | ||
| 18601 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 18602 | # object no longer exists | ||
| 18603 | # 1 otherwise | ||
| 18604 | |||
| 18605 | my ($self, $check) = @_; | ||
| 18606 | |||
| 18607 | # Local variables | ||
| 18608 | my ( | ||
| 18609 | $dataRef, $number, $obj, | ||
| 18610 | @list, @dataList, | ||
| 18611 | ); | ||
| 18612 | |||
| 18613 | # Check for improper arguments | ||
| 18614 | if (defined $check) { | ||
| 18615 | |||
| 18616 | return $axmud::CLIENT->writeImproper( | ||
| 18617 | $self->_objClass . '->buttonView_displayBuffer', | ||
| 18618 | @_, | ||
| 18619 | ); | ||
| 18620 | } | ||
| 18621 | |||
| 18622 | # Import the currently selected portions of the notebook list | ||
| 18623 | @list = $self->notebookGetSelectedData(); | ||
| 18624 | if (! @list) { | ||
| 18625 | |||
| 18626 | # Nothing selected | ||
| 18627 | return undef; | ||
| 18628 | } | ||
| 18629 | |||
| 18630 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 18631 | # a single row of the list | ||
| 18632 | $dataRef = $list[0]; | ||
| 18633 | @dataList = @$dataRef; | ||
| 18634 | # The line number is the first item of data | ||
| 18635 | $number = $dataList[0]; | ||
| 18636 | if (! defined $number) { | ||
| 18637 | |||
| 18638 | # Can't continue | ||
| 18639 | return undef; | ||
| 18640 | } | ||
| 18641 | |||
| 18642 | # Get the corresponding display buffer object | ||
| 18643 | $obj = $self->session->ivShow('displayBufferHash', $number); | ||
| 18644 | if (! $obj) { | ||
| 18645 | |||
| 18646 | # Can't continue | ||
| 18647 | return undef; | ||
| 18648 | |||
| 18649 | } else { | ||
| 18650 | |||
| 18651 | # Open up an 'edit' window to edit the object | ||
| 18652 | $self->createFreeWin( | ||
| 18653 | 'Games::Axmud::EditWin::Buffer::Display', | ||
| 18654 | $self, | ||
| 18655 | $self->session, | ||
| 18656 | 'Edit display buffer line #' . $number, | ||
| 18657 | $obj, | ||
| 18658 | FALSE, # Not temporary | ||
| 18659 | ); | ||
| 18660 | } | ||
| 18661 | |||
| 18662 | return 1; | ||
| 18663 | } | ||
| 18664 | |||
| 18665 | sub buttonTest_displayBuffer { | ||
| 18666 | |||
| 18667 | # Callback: Tets the selected display buffer line against a pattern supplied by the user in | ||
| 18668 | # a 'dialogue' window (no corresponding client command) | ||
| 18669 | # | ||
| 18670 | # Expected arguments | ||
| 18671 | # (none besides $self) | ||
| 18672 | # | ||
| 18673 | # Return values | ||
| 18674 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 18675 | # object no longer exists | ||
| 18676 | # 1 otherwise | ||
| 18677 | |||
| 18678 | my ($self, $check) = @_; | ||
| 18679 | |||
| 18680 | # Local variables | ||
| 18681 | my ( | ||
| 18682 | $dataRef, $number, $obj, $pattern, $msg, $type, | ||
| 18683 | @list, @dataList, | ||
| 18684 | ); | ||
| 18685 | |||
| 18686 | # Check for improper arguments | ||
| 18687 | if (defined $check) { | ||
| 18688 | |||
| 18689 | return $axmud::CLIENT->writeImproper( | ||
| 18690 | $self->_objClass . '->buttonTest_displayBuffer', | ||
| 18691 | @_, | ||
| 18692 | ); | ||
| 18693 | } | ||
| 18694 | |||
| 18695 | # Import the currently selected portions of the notebook list | ||
| 18696 | @list = $self->notebookGetSelectedData(); | ||
| 18697 | if (! @list) { | ||
| 18698 | |||
| 18699 | # Nothing selected | ||
| 18700 | return undef; | ||
| 18701 | } | ||
| 18702 | |||
| 18703 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 18704 | # a single row of the list | ||
| 18705 | $dataRef = $list[0]; | ||
| 18706 | @dataList = @$dataRef; | ||
| 18707 | # The line number is the first item of data | ||
| 18708 | $number = $dataList[0]; | ||
| 18709 | if (! defined $number) { | ||
| 18710 | |||
| 18711 | # Can't continue | ||
| 18712 | return undef; | ||
| 18713 | } | ||
| 18714 | |||
| 18715 | # Get the corresponding display buffer object | ||
| 18716 | $obj = $self->session->ivShow('displayBufferHash', $number); | ||
| 18717 | if (! $obj) { | ||
| 18718 | |||
| 18719 | # Can't continue | ||
| 18720 | return undef; | ||
| 18721 | } | ||
| 18722 | |||
| 18723 | # Prompt the user for a regex | ||
| 18724 | $pattern = $self->showEntryDialogue( | ||
| 18725 | 'Test original line', | ||
| 18726 | 'Enter a pattern (regex) to test against line #' . $number, | ||
| 18727 | ); | ||
| 18728 | |||
| 18729 | if ($pattern) { | ||
| 18730 | |||
| 18731 | if ($axmud::CLIENT->regexCheck($pattern)) { | ||
| 18732 | |||
| 18733 | $msg = 'Invalid pattern (regular expression)'; | ||
| 18734 | $type = 'error'; | ||
| 18735 | |||
| 18736 | } elsif ($obj->stripLine =~ m/$pattern/) { | ||
| 18737 | |||
| 18738 | $msg = 'Pattern MATCHES line #' . $number; | ||
| 18739 | $type = 'info'; | ||
| 18740 | |||
| 18741 | } else { | ||
| 18742 | |||
| 18743 | $msg = 'Pattern does NOT match line #' . $number; | ||
| 18744 | $type = 'error'; | ||
| 18745 | } | ||
| 18746 | |||
| 18747 | # Display the result | ||
| 18748 | $self->showMsgDialogue( | ||
| 18749 | 'Test result', | ||
| 18750 | $type, | ||
| 18751 | $msg, | ||
| 18752 | 'ok', | ||
| 18753 | ); | ||
| 18754 | } | ||
| 18755 | |||
| 18756 | return 1; | ||
| 18757 | } | ||
| 18758 | |||
| 18759 | sub buttonSave_displayBuffer { | ||
| 18760 | |||
| 18761 | # Callback: Saves the display buffer to file (equivalent to ';savebuffer -t') | ||
| 18762 | # | ||
| 18763 | # Expected arguments | ||
| 18764 | # (none besides $self) | ||
| 18765 | # | ||
| 18766 | # Return values | ||
| 18767 | # 'undef' on improper arguments | ||
| 18768 | # 1 otherwise | ||
| 18769 | |||
| 18770 | my ($self, $check) = @_; | ||
| 18771 | |||
| 18772 | # Local variables | ||
| 18773 | my ($tab, $slWidget, $start, $stop); | ||
| 18774 | |||
| 18775 | # Check for improper arguments | ||
| 18776 | if (defined $check) { | ||
| 18777 | |||
| 18778 | return $axmud::CLIENT->writeImproper( | ||
| 18779 | $self->_objClass . '->buttonSave_displayBuffer', | ||
| 18780 | @_, | ||
| 18781 | ); | ||
| 18782 | } | ||
| 18783 | |||
| 18784 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 18785 | $tab = $self->notebookGetTab(); | ||
| 18786 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 18787 | |||
| 18788 | # Unselect everything in the list | ||
| 18789 | $slWidget->get_selection->unselect_all(); | ||
| 18790 | |||
| 18791 | # Save the display buffer to file | ||
| 18792 | $self->session->pseudoCmd('savebuffer -d', $self->pseudoCmdMode); | ||
| 18793 | |||
| 18794 | return 1; | ||
| 18795 | } | ||
| 18796 | |||
| 18797 | sub buttonSaveBoth_displayBuffer { | ||
| 18798 | |||
| 18799 | # Callback: Saves the text and command buffers to file (equivalent to ';savebuffer') | ||
| 18800 | # | ||
| 18801 | # Expected arguments | ||
| 18802 | # (none besides $self) | ||
| 18803 | # | ||
| 18804 | # Return values | ||
| 18805 | # 'undef' on improper arguments | ||
| 18806 | # 1 otherwise | ||
| 18807 | |||
| 18808 | my ($self, $check) = @_; | ||
| 18809 | |||
| 18810 | # Local variables | ||
| 18811 | my ($tab, $slWidget, $start, $stop); | ||
| 18812 | |||
| 18813 | # Check for improper arguments | ||
| 18814 | if (defined $check) { | ||
| 18815 | |||
| 18816 | return $axmud::CLIENT->writeImproper( | ||
| 18817 | $self->_objClass . '->buttonSaveBoth_displayBuffer', | ||
| 18818 | @_, | ||
| 18819 | ); | ||
| 18820 | } | ||
| 18821 | |||
| 18822 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 18823 | $tab = $self->notebookGetTab(); | ||
| 18824 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 18825 | |||
| 18826 | # Unselect everything in the list | ||
| 18827 | $slWidget->get_selection->unselect_all(); | ||
| 18828 | |||
| 18829 | # Save the text and command buffers to file | ||
| 18830 | $self->session->pseudoCmd('savebuffer', $self->pseudoCmdMode); | ||
| 18831 | |||
| 18832 | return 1; | ||
| 18833 | } | ||
| 18834 | |||
| 18835 | sub buttonDump20_instructBuffer { | ||
| 18836 | |||
| 18837 | # Callback: Display a list of the 20 most recent lines from the instruction buffer in the | ||
| 18838 | # 'main' window (equivalent to ';dumpinstructionbuffer <start> <stop>') | ||
| 18839 | # | ||
| 18840 | # Expected arguments | ||
| 18841 | # (none besides $self) | ||
| 18842 | # | ||
| 18843 | # Return values | ||
| 18844 | # 'undef' on improper arguments | ||
| 18845 | # 1 otherwise | ||
| 18846 | |||
| 18847 | my ($self, $check) = @_; | ||
| 18848 | |||
| 18849 | # Local variables | ||
| 18850 | my ($tab, $slWidget, $start, $stop); | ||
| 18851 | |||
| 18852 | # Check for improper arguments | ||
| 18853 | if (defined $check) { | ||
| 18854 | |||
| 18855 | return $axmud::CLIENT->writeImproper( | ||
| 18856 | $self->_objClass . '->buttonDump20_instructBuffer', | ||
| 18857 | @_, | ||
| 18858 | ); | ||
| 18859 | } | ||
| 18860 | |||
| 18861 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 18862 | $tab = $self->notebookGetTab(); | ||
| 18863 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 18864 | |||
| 18865 | # Unselect everything in the list | ||
| 18866 | $slWidget->get_selection->unselect_all(); | ||
| 18867 | |||
| 18868 | # Don't do anything if no lines have been received | ||
| 18869 | if ($self->session->instructBufferFirst) { | ||
| 18870 | |||
| 18871 | # Work out the line numbers | ||
| 18872 | $stop = $self->session->instructBufferLast; | ||
| 18873 | $start = $self->session->instructBufferLast - 19; | ||
| 18874 | if ($start < 1) { | ||
| 18875 | |||
| 18876 | $start = 1; | ||
| 18877 | } | ||
| 18878 | |||
| 18879 | # Display the lines | ||
| 18880 | $self->session->pseudoCmd( | ||
| 18881 | 'dumpinstructionbuffer ' . $start . ' ' . $stop, | ||
| 18882 | $self->pseudoCmdMode, | ||
| 18883 | ); | ||
| 18884 | } | ||
| 18885 | |||
| 18886 | return 1; | ||
| 18887 | } | ||
| 18888 | |||
| 18889 | sub buttonDumpAll_instructBuffer { | ||
| 18890 | |||
| 18891 | # Callback: Display a list of all lines from the instruction buffer in the 'main' window | ||
| 18892 | # (equivalent to ';dumpcommandbuffer <first line> <last line>') | ||
| 18893 | # | ||
| 18894 | # Expected arguments | ||
| 18895 | # (none besides $self) | ||
| 18896 | # | ||
| 18897 | # Return values | ||
| 18898 | # 'undef' on improper arguments | ||
| 18899 | # 1 otherwise | ||
| 18900 | |||
| 18901 | my ($self, $check) = @_; | ||
| 18902 | |||
| 18903 | # Local variables | ||
| 18904 | my ($tab, $slWidget, $start, $stop); | ||
| 18905 | |||
| 18906 | # Check for improper arguments | ||
| 18907 | if (defined $check) { | ||
| 18908 | |||
| 18909 | return $axmud::CLIENT->writeImproper( | ||
| 18910 | $self->_objClass . '->buttonDumpAll_instructBuffer', | ||
| 18911 | @_, | ||
| 18912 | ); | ||
| 18913 | } | ||
| 18914 | |||
| 18915 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 18916 | $tab = $self->notebookGetTab(); | ||
| 18917 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 18918 | |||
| 18919 | # Unselect everything in the list | ||
| 18920 | $slWidget->get_selection->unselect_all(); | ||
| 18921 | |||
| 18922 | # Don't do anything if no lines have been received | ||
| 18923 | if ($self->session->instructBufferFirst) { | ||
| 18924 | |||
| 18925 | # Work out the line numbers | ||
| 18926 | $stop = $self->session->instructBufferLast; | ||
| 18927 | $start = $self->session->instructBufferFirst; | ||
| 18928 | |||
| 18929 | # Display the lines | ||
| 18930 | $self->session->pseudoCmd( | ||
| 18931 | 'dumpinstructionbuffer ' . $start . ' ' . $stop, | ||
| 18932 | $self->pseudoCmdMode, | ||
| 18933 | ); | ||
| 18934 | } | ||
| 18935 | |||
| 18936 | return 1; | ||
| 18937 | } | ||
| 18938 | |||
| 18939 | sub buttonStatus_instructBuffer { | ||
| 18940 | |||
| 18941 | # Callback: Display the instruction buffer's status in the 'main' window (equivalent to | ||
| 18942 | # ';cmdbuffer') | ||
| 18943 | # | ||
| 18944 | # Expected arguments | ||
| 18945 | # (none besides $self) | ||
| 18946 | # | ||
| 18947 | # Return values | ||
| 18948 | # 'undef' on improper arguments | ||
| 18949 | # 1 otherwise | ||
| 18950 | |||
| 18951 | my ($self, $check) = @_; | ||
| 18952 | |||
| 18953 | # Local variables | ||
| 18954 | my ($tab, $slWidget, $start, $stop); | ||
| 18955 | |||
| 18956 | # Check for improper arguments | ||
| 18957 | if (defined $check) { | ||
| 18958 | |||
| 18959 | return $axmud::CLIENT->writeImproper( | ||
| 18960 | $self->_objClass . '->buttonStatus_instructBuffer', | ||
| 18961 | @_, | ||
| 18962 | ); | ||
| 18963 | } | ||
| 18964 | |||
| 18965 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 18966 | $tab = $self->notebookGetTab(); | ||
| 18967 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 18968 | |||
| 18969 | # Unselect everything in the list | ||
| 18970 | $slWidget->get_selection->unselect_all(); | ||
| 18971 | |||
| 18972 | # Display the instruction buffer status | ||
| 18973 | $self->session->pseudoCmd('instructionbuffer', $self->pseudoCmdMode); | ||
| 18974 | |||
| 18975 | return 1; | ||
| 18976 | } | ||
| 18977 | |||
| 18978 | sub buttonView_instructBuffer { | ||
| 18979 | |||
| 18980 | # Callback: Views the selected intruction buffer line in an 'edit' window (equivalent to | ||
| 18981 | # ';editinstructionbuffer') | ||
| 18982 | # | ||
| 18983 | # Expected arguments | ||
| 18984 | # (none besides $self) | ||
| 18985 | # | ||
| 18986 | # Return values | ||
| 18987 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 18988 | # object no longer exists | ||
| 18989 | # 1 otherwise | ||
| 18990 | |||
| 18991 | my ($self, $check) = @_; | ||
| 18992 | |||
| 18993 | # Local variables | ||
| 18994 | my ( | ||
| 18995 | $dataRef, $number, $obj, | ||
| 18996 | @list, @dataList, | ||
| 18997 | ); | ||
| 18998 | |||
| 18999 | # Check for improper arguments | ||
| 19000 | if (defined $check) { | ||
| 19001 | |||
| 19002 | return $axmud::CLIENT->writeImproper( | ||
| 19003 | $self->_objClass . '->buttonView_instructBuffer', | ||
| 19004 | @_, | ||
| 19005 | ); | ||
| 19006 | } | ||
| 19007 | |||
| 19008 | # Import the currently selected portions of the notebook list | ||
| 19009 | @list = $self->notebookGetSelectedData(); | ||
| 19010 | if (! @list) { | ||
| 19011 | |||
| 19012 | # Nothing selected | ||
| 19013 | return undef; | ||
| 19014 | } | ||
| 19015 | |||
| 19016 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 19017 | # a single row of the list | ||
| 19018 | $dataRef = $list[0]; | ||
| 19019 | @dataList = @$dataRef; | ||
| 19020 | # The line number is the first item of data | ||
| 19021 | $number = $dataList[0]; | ||
| 19022 | if (! defined $number) { | ||
| 19023 | |||
| 19024 | # Can't continue | ||
| 19025 | return undef; | ||
| 19026 | } | ||
| 19027 | |||
| 19028 | # Get the corresponding instruction buffer object | ||
| 19029 | $obj = $self->session->ivShow('instructBufferHash', $number); | ||
| 19030 | if (! $obj) { | ||
| 19031 | |||
| 19032 | # Can't continue | ||
| 19033 | return undef; | ||
| 19034 | |||
| 19035 | } else { | ||
| 19036 | |||
| 19037 | # Open up an 'edit' window to view the object | ||
| 19038 | $self->createFreeWin( | ||
| 19039 | 'Games::Axmud::EditWin::Buffer::Instruct', | ||
| 19040 | $self, | ||
| 19041 | $self->session, | ||
| 19042 | 'Edit instruction buffer item #' . $number, | ||
| 19043 | $obj, | ||
| 19044 | FALSE, # Not temporary | ||
| 19045 | ); | ||
| 19046 | } | ||
| 19047 | |||
| 19048 | return 1; | ||
| 19049 | } | ||
| 19050 | |||
| 19051 | sub buttonDump20_cmdBuffer { | ||
| 19052 | |||
| 19053 | # Callback: Display a list of the 20 most recent lines from the command buffer in the | ||
| 19054 | # 'main' window (equivalent to ';dumpcommandbuffer <start> <stop>') | ||
| 19055 | # | ||
| 19056 | # Expected arguments | ||
| 19057 | # (none besides $self) | ||
| 19058 | # | ||
| 19059 | # Return values | ||
| 19060 | # 'undef' on improper arguments | ||
| 19061 | # 1 otherwise | ||
| 19062 | |||
| 19063 | my ($self, $check) = @_; | ||
| 19064 | |||
| 19065 | # Local variables | ||
| 19066 | my ($tab, $slWidget, $start, $stop); | ||
| 19067 | |||
| 19068 | # Check for improper arguments | ||
| 19069 | if (defined $check) { | ||
| 19070 | |||
| 19071 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDump20_cmdBuffer', @_); | ||
| 19072 | } | ||
| 19073 | |||
| 19074 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 19075 | $tab = $self->notebookGetTab(); | ||
| 19076 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 19077 | |||
| 19078 | # Unselect everything in the list | ||
| 19079 | $slWidget->get_selection->unselect_all(); | ||
| 19080 | |||
| 19081 | # Don't do anything if no lines have been received | ||
| 19082 | if ($self->session->cmdBufferFirst) { | ||
| 19083 | |||
| 19084 | # Work out the line numbers | ||
| 19085 | $stop = $self->session->cmdBufferLast; | ||
| 19086 | $start = $self->session->cmdBufferLast - 19; | ||
| 19087 | if ($start < 1) { | ||
| 19088 | |||
| 19089 | $start = 1; | ||
| 19090 | } | ||
| 19091 | |||
| 19092 | # Display the lines | ||
| 19093 | $self->session->pseudoCmd( | ||
| 19094 | 'dumpcommandbuffer ' . $start . ' ' . $stop, | ||
| 19095 | $self->pseudoCmdMode, | ||
| 19096 | ); | ||
| 19097 | } | ||
| 19098 | |||
| 19099 | return 1; | ||
| 19100 | } | ||
| 19101 | |||
| 19102 | sub buttonDumpAll_cmdBuffer { | ||
| 19103 | |||
| 19104 | # Callback: Display a list of all lines from the command buffer in the 'main' window | ||
| 19105 | # (equivalent to ';dumpcommandbuffer <first line> <last line>') | ||
| 19106 | # | ||
| 19107 | # Expected arguments | ||
| 19108 | # (none besides $self) | ||
| 19109 | # | ||
| 19110 | # Return values | ||
| 19111 | # 'undef' on improper arguments | ||
| 19112 | # 1 otherwise | ||
| 19113 | |||
| 19114 | my ($self, $check) = @_; | ||
| 19115 | |||
| 19116 | # Local variables | ||
| 19117 | my ($tab, $slWidget, $start, $stop); | ||
| 19118 | |||
| 19119 | # Check for improper arguments | ||
| 19120 | if (defined $check) { | ||
| 19121 | |||
| 19122 | return $axmud::CLIENT->writeImproper( | ||
| 19123 | $self->_objClass . '->buttonDumpAll_cmdBuffer', | ||
| 19124 | @_, | ||
| 19125 | ); | ||
| 19126 | } | ||
| 19127 | |||
| 19128 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 19129 | $tab = $self->notebookGetTab(); | ||
| 19130 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 19131 | |||
| 19132 | # Unselect everything in the list | ||
| 19133 | $slWidget->get_selection->unselect_all(); | ||
| 19134 | |||
| 19135 | # Don't do anything if no lines have been received | ||
| 19136 | if ($self->session->cmdBufferFirst) { | ||
| 19137 | |||
| 19138 | # Work out the line numbers | ||
| 19139 | $stop = $self->session->cmdBufferLast; | ||
| 19140 | $start = $self->session->cmdBufferFirst; | ||
| 19141 | |||
| 19142 | # Display the lines | ||
| 19143 | $self->session->pseudoCmd( | ||
| 19144 | 'dumpcommandbuffer ' . $start . ' ' . $stop, | ||
| 19145 | $self->pseudoCmdMode, | ||
| 19146 | ); | ||
| 19147 | } | ||
| 19148 | |||
| 19149 | return 1; | ||
| 19150 | } | ||
| 19151 | |||
| 19152 | sub buttonStatus_cmdBuffer { | ||
| 19153 | |||
| 19154 | # Callback: Display the command buffer's status in the 'main' window (equivalent to | ||
| 19155 | # ';cmdbuffer') | ||
| 19156 | # | ||
| 19157 | # Expected arguments | ||
| 19158 | # (none besides $self) | ||
| 19159 | # | ||
| 19160 | # Return values | ||
| 19161 | # 'undef' on improper arguments | ||
| 19162 | # 1 otherwise | ||
| 19163 | |||
| 19164 | my ($self, $check) = @_; | ||
| 19165 | |||
| 19166 | # Local variables | ||
| 19167 | my ($tab, $slWidget, $start, $stop); | ||
| 19168 | |||
| 19169 | # Check for improper arguments | ||
| 19170 | if (defined $check) { | ||
| 19171 | |||
| 19172 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonStatus_cmdBuffer', @_); | ||
| 19173 | } | ||
| 19174 | |||
| 19175 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 19176 | $tab = $self->notebookGetTab(); | ||
| 19177 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 19178 | |||
| 19179 | # Unselect everything in the list | ||
| 19180 | $slWidget->get_selection->unselect_all(); | ||
| 19181 | |||
| 19182 | # Display the command buffer status | ||
| 19183 | $self->session->pseudoCmd('commandbuffer', $self->pseudoCmdMode); | ||
| 19184 | |||
| 19185 | return 1; | ||
| 19186 | } | ||
| 19187 | |||
| 19188 | sub buttonView_cmdBuffer { | ||
| 19189 | |||
| 19190 | # Callback: Views the selected command buffer line in an 'edit' window (equivalent to | ||
| 19191 | # ';editcommandbuffer') | ||
| 19192 | # | ||
| 19193 | # Expected arguments | ||
| 19194 | # (none besides $self) | ||
| 19195 | # | ||
| 19196 | # Return values | ||
| 19197 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 19198 | # object no longer exists | ||
| 19199 | # 1 otherwise | ||
| 19200 | |||
| 19201 | my ($self, $check) = @_; | ||
| 19202 | |||
| 19203 | # Local variables | ||
| 19204 | my ( | ||
| 19205 | $dataRef, $number, $obj, | ||
| 19206 | @list, @dataList, | ||
| 19207 | ); | ||
| 19208 | |||
| 19209 | # Check for improper arguments | ||
| 19210 | if (defined $check) { | ||
| 19211 | |||
| 19212 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonView_cmdBuffer', @_); | ||
| 19213 | } | ||
| 19214 | |||
| 19215 | # Import the currently selected portions of the notebook list | ||
| 19216 | @list = $self->notebookGetSelectedData(); | ||
| 19217 | if (! @list) { | ||
| 19218 | |||
| 19219 | # Nothing selected | ||
| 19220 | return undef; | ||
| 19221 | } | ||
| 19222 | |||
| 19223 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 19224 | # a single row of the list | ||
| 19225 | $dataRef = $list[0]; | ||
| 19226 | @dataList = @$dataRef; | ||
| 19227 | # The line number is the first item of data | ||
| 19228 | $number = $dataList[0]; | ||
| 19229 | if (! defined $number) { | ||
| 19230 | |||
| 19231 | # Can't continue | ||
| 19232 | return undef; | ||
| 19233 | } | ||
| 19234 | |||
| 19235 | # Get the corresponding command buffer object | ||
| 19236 | $obj = $self->session->ivShow('cmdBufferHash', $number); | ||
| 19237 | if (! $obj) { | ||
| 19238 | |||
| 19239 | # Can't continue | ||
| 19240 | return undef; | ||
| 19241 | |||
| 19242 | } else { | ||
| 19243 | |||
| 19244 | # Open up an 'edit' window to view the object | ||
| 19245 | $self->createFreeWin( | ||
| 19246 | 'Games::Axmud::EditWin::Buffer::Cmd', | ||
| 19247 | $self, | ||
| 19248 | $self->session, | ||
| 19249 | 'Edit world command buffer item #' . $number, | ||
| 19250 | $obj, | ||
| 19251 | FALSE, # Not temporary | ||
| 19252 | ); | ||
| 19253 | } | ||
| 19254 | |||
| 19255 | return 1; | ||
| 19256 | } | ||
| 19257 | |||
| 19258 | sub buttonSave_cmdBuffer { | ||
| 19259 | |||
| 19260 | # Callback: Saves the command buffer to file (equivalent to ';savebuffer -c') | ||
| 19261 | # | ||
| 19262 | # Expected arguments | ||
| 19263 | # (none besides $self) | ||
| 19264 | # | ||
| 19265 | # Return values | ||
| 19266 | # 'undef' on improper arguments | ||
| 19267 | # 1 otherwise | ||
| 19268 | |||
| 19269 | my ($self, $check) = @_; | ||
| 19270 | |||
| 19271 | # Local variables | ||
| 19272 | my ($tab, $slWidget, $start, $stop); | ||
| 19273 | |||
| 19274 | # Check for improper arguments | ||
| 19275 | if (defined $check) { | ||
| 19276 | |||
| 19277 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonSave_cmdBuffer', @_); | ||
| 19278 | } | ||
| 19279 | |||
| 19280 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 19281 | $tab = $self->notebookGetTab(); | ||
| 19282 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 19283 | |||
| 19284 | # Unselect everything in the list | ||
| 19285 | $slWidget->get_selection->unselect_all(); | ||
| 19286 | |||
| 19287 | # Save the command buffer to file | ||
| 19288 | $self->session->pseudoCmd('savebuffer -c', $self->pseudoCmdMode); | ||
| 19289 | |||
| 19290 | return 1; | ||
| 19291 | } | ||
| 19292 | |||
| 19293 | # Chat contact button callbacks | ||
| 19294 | |||
| 19295 | sub buttonAdd_chatContact { | ||
| 19296 | |||
| 19297 | # Callback: Add a chat contact object (equivalent to ';addcontact') | ||
| 19298 | # | ||
| 19299 | # Expected arguments | ||
| 19300 | # (none besides $self) | ||
| 19301 | # | ||
| 19302 | # Return values | ||
| 19303 | # 'undef' on improper arguments | ||
| 19304 | # 1 otherwise | ||
| 19305 | |||
| 19306 | my ($self, $check) = @_; | ||
| 19307 | |||
| 19308 | # Local variables | ||
| 19309 | my ($tab, $slWidget, $name, $ip); | ||
| 19310 | |||
| 19311 | # Check for improper arguments | ||
| 19312 | if (defined $check) { | ||
| 19313 | |||
| 19314 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonAdd_chatContact', @_); | ||
| 19315 | } | ||
| 19316 | |||
| 19317 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 19318 | $tab = $self->notebookGetTab(); | ||
| 19319 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 19320 | |||
| 19321 | # Unselect everything in the list, because we're creating a new chat contact | ||
| 19322 | $slWidget->get_selection->unselect_all(); | ||
| 19323 | |||
| 19324 | # Prompt the user for the name of the chat contact object | ||
| 19325 | ($name, $ip) = $self->showDoubleEntryDialogue( | ||
| 19326 | 'Add chat contact', | ||
| 19327 | "Enter a name for the object\n<i>Max 16 chars: A-Z a-z _ 0-9</i>", | ||
| 19328 | "Enter the contact's IP address\n<i>e.g. 100.101.102.103</i>", | ||
| 19329 | 16, # Max chars | ||
| 19330 | ); | ||
| 19331 | |||
| 19332 | if ($name && $ip) { | ||
| 19333 | |||
| 19334 | # Add the new chat contact | ||
| 19335 | $self->session->pseudoCmd('addcontact ' . $name . ' ' . $ip, $self->pseudoCmdMode); | ||
| 19336 | |||
| 19337 | # Update the notebook | ||
| 19338 | $self->updateNotebook(); | ||
| 19339 | } | ||
| 19340 | |||
| 19341 | return 1; | ||
| 19342 | } | ||
| 19343 | |||
| 19344 | sub buttonEdit_chatContact { | ||
| 19345 | |||
| 19346 | # Callback: Edits a chat contact object (equivalent to ';editcontact') | ||
| 19347 | # | ||
| 19348 | # Expected arguments | ||
| 19349 | # (none besides $self) | ||
| 19350 | # | ||
| 19351 | # Return values | ||
| 19352 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 19353 | # object no longer exists | ||
| 19354 | # 1 otherwise | ||
| 19355 | |||
| 19356 | my ($self, $check) = @_; | ||
| 19357 | |||
| 19358 | # Local variables | ||
| 19359 | my ( | ||
| 19360 | $dataRef, $name, $obj, | ||
| 19361 | @list, @dataList, | ||
| 19362 | ); | ||
| 19363 | |||
| 19364 | # Check for improper arguments | ||
| 19365 | if (defined $check) { | ||
| 19366 | |||
| 19367 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonEdit_chatContact', @_); | ||
| 19368 | } | ||
| 19369 | |||
| 19370 | # Import the currently selected portions of the notebook list | ||
| 19371 | @list = $self->notebookGetSelectedData(); | ||
| 19372 | if (! @list) { | ||
| 19373 | |||
| 19374 | # Nothing selected | ||
| 19375 | return undef; | ||
| 19376 | } | ||
| 19377 | |||
| 19378 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 19379 | # a single row of the list | ||
| 19380 | $dataRef = $list[0]; | ||
| 19381 | @dataList = @$dataRef; | ||
| 19382 | # The colour scheme's name is the first item of data | ||
| 19383 | $name = $dataList[0]; | ||
| 19384 | if (! $name) { | ||
| 19385 | |||
| 19386 | # Can't continue | ||
| 19387 | return undef; | ||
| 19388 | } | ||
| 19389 | |||
| 19390 | # Get the chat contact itself | ||
| 19391 | $obj = $axmud::CLIENT->ivShow('chatContactHash', $name); | ||
| 19392 | if (! $obj) { | ||
| 19393 | |||
| 19394 | # Can't continue | ||
| 19395 | return undef; | ||
| 19396 | |||
| 19397 | } else { | ||
| 19398 | |||
| 19399 | # Open up an 'edit' window to edit the object | ||
| 19400 | $self->createFreeWin( | ||
| 19401 | 'Games::Axmud::EditWin::ChatContact', | ||
| 19402 | $self, | ||
| 19403 | $self->session, | ||
| 19404 | 'Edit contact \'' . $obj->name . '\'', | ||
| 19405 | $obj, | ||
| 19406 | FALSE, # Not temporary | ||
| 19407 | ); | ||
| 19408 | |||
| 19409 | return 1; | ||
| 19410 | } | ||
| 19411 | } | ||
| 19412 | |||
| 19413 | sub buttonDelete_chatContact { | ||
| 19414 | |||
| 19415 | # Callback: Deletes a chat contact object (equivalent to ';deletecontact') | ||
| 19416 | # | ||
| 19417 | # Expected arguments | ||
| 19418 | # (none besides $self) | ||
| 19419 | # | ||
| 19420 | # Return values | ||
| 19421 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 19422 | # 1 otherwise | ||
| 19423 | |||
| 19424 | my ($self, $check) = @_; | ||
| 19425 | |||
| 19426 | # Local variables | ||
| 19427 | my ( | ||
| 19428 | $dataRef, $name, | ||
| 19429 | @list, @dataList, | ||
| 19430 | ); | ||
| 19431 | |||
| 19432 | # Check for improper arguments | ||
| 19433 | if (defined $check) { | ||
| 19434 | |||
| 19435 | return $axmud::CLIENT->writeImproper( | ||
| 19436 | $self->_objClass . '->buttonDelete_chatContact', | ||
| 19437 | @_, | ||
| 19438 | ); | ||
| 19439 | } | ||
| 19440 | |||
| 19441 | # Import the currently selected portions of the notebook list | ||
| 19442 | @list = $self->notebookGetSelectedData(); | ||
| 19443 | if (! @list) { | ||
| 19444 | |||
| 19445 | # Nothing selected | ||
| 19446 | return undef; | ||
| 19447 | } | ||
| 19448 | |||
| 19449 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 19450 | # a single row of the list | ||
| 19451 | $dataRef = $list[0]; | ||
| 19452 | @dataList = @$dataRef; | ||
| 19453 | # The chat contact object name is the first item of data | ||
| 19454 | $name = $dataList[0]; | ||
| 19455 | if (! $name) { | ||
| 19456 | |||
| 19457 | # Can't continue | ||
| 19458 | return undef; | ||
| 19459 | } | ||
| 19460 | |||
| 19461 | # Delete the chat contact | ||
| 19462 | $self->session->pseudoCmd('deletecontact ' . $name, $self->pseudoCmdMode); | ||
| 19463 | |||
| 19464 | # Update the notebook | ||
| 19465 | $self->updateNotebook(); | ||
| 19466 | |||
| 19467 | return 1; | ||
| 19468 | } | ||
| 19469 | |||
| 19470 | sub buttonDump_chatContact { | ||
| 19471 | |||
| 19472 | # Callback: Displays a list of chat contact objects in the 'main' window (equivalent to | ||
| 19473 | # ';listcontact') | ||
| 19474 | # | ||
| 19475 | # Expected arguments | ||
| 19476 | # (none besides $self) | ||
| 19477 | # | ||
| 19478 | # Return values | ||
| 19479 | # 'undef' on improper arguments | ||
| 19480 | # 1 otherwise | ||
| 19481 | |||
| 19482 | my ($self, $check) = @_; | ||
| 19483 | |||
| 19484 | # Local variables | ||
| 19485 | my ($tab, $slWidget); | ||
| 19486 | |||
| 19487 | # Check for improper arguments | ||
| 19488 | if (defined $check) { | ||
| 19489 | |||
| 19490 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDump_chatContact', @_); | ||
| 19491 | } | ||
| 19492 | |||
| 19493 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 19494 | $tab = $self->notebookGetTab(); | ||
| 19495 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 19496 | |||
| 19497 | # Unselect everything in the list | ||
| 19498 | $slWidget->get_selection->unselect_all(); | ||
| 19499 | |||
| 19500 | # Display the list | ||
| 19501 | $self->session->pseudoCmd('listcontact', $self->pseudoCmdMode); | ||
| 19502 | |||
| 19503 | return 1; | ||
| 19504 | } | ||
| 19505 | |||
| 19506 | # Colour scheme button callbacks | ||
| 19507 | |||
| 19508 | sub buttonAdd_colourScheme { | ||
| 19509 | |||
| 19510 | # Callback: Add a colour scheme object (equivalent to ';addcolourscheme') | ||
| 19511 | # | ||
| 19512 | # Expected arguments | ||
| 19513 | # (none besides $self) | ||
| 19514 | # | ||
| 19515 | # Return values | ||
| 19516 | # 'undef' on improper arguments | ||
| 19517 | # 1 otherwise | ||
| 19518 | |||
| 19519 | my ($self, $check) = @_; | ||
| 19520 | |||
| 19521 | # Local variables | ||
| 19522 | my ($tab, $slWidget, $name); | ||
| 19523 | |||
| 19524 | # Check for improper arguments | ||
| 19525 | if (defined $check) { | ||
| 19526 | |||
| 19527 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonAdd_colourScheme', @_); | ||
| 19528 | } | ||
| 19529 | |||
| 19530 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 19531 | $tab = $self->notebookGetTab(); | ||
| 19532 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 19533 | |||
| 19534 | # Unselect everything in the list, because we're creating a new colour scheme | ||
| 19535 | $slWidget->get_selection->unselect_all(); | ||
| 19536 | |||
| 19537 | # Prompt the user for the name of the colour scheme object | ||
| 19538 | $name = $self->showEntryDialogue( | ||
| 19539 | 'Add colour scheme', | ||
| 19540 | 'Enter a name for the object (max 16 chars: A-Z a-z _ 0-9)', | ||
| 19541 | 16, # Max chars | ||
| 19542 | ); | ||
| 19543 | |||
| 19544 | if ($name) { | ||
| 19545 | |||
| 19546 | # Add the new colour scheme | ||
| 19547 | $self->session->pseudoCmd('addcolourscheme ' . $name, $self->pseudoCmdMode); | ||
| 19548 | |||
| 19549 | # Update the notebook | ||
| 19550 | $self->updateNotebook(); | ||
| 19551 | } | ||
| 19552 | |||
| 19553 | return 1; | ||
| 19554 | } | ||
| 19555 | |||
| 19556 | sub buttonEdit_colourScheme { | ||
| 19557 | |||
| 19558 | # Callback: Edits a colour scheme object (equivalent to ';editcolourscheme') | ||
| 19559 | # | ||
| 19560 | # Expected arguments | ||
| 19561 | # (none besides $self) | ||
| 19562 | # | ||
| 19563 | # Return values | ||
| 19564 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 19565 | # object no longer exists | ||
| 19566 | # 1 otherwise | ||
| 19567 | |||
| 19568 | my ($self, $check) = @_; | ||
| 19569 | |||
| 19570 | # Local variables | ||
| 19571 | my ( | ||
| 19572 | $dataRef, $name, $obj, | ||
| 19573 | @list, @dataList, | ||
| 19574 | ); | ||
| 19575 | |||
| 19576 | # Check for improper arguments | ||
| 19577 | if (defined $check) { | ||
| 19578 | |||
| 19579 | return $axmud::CLIENT->writeImproper( | ||
| 19580 | $self->_objClass . '->buttonEdit_colourScheme', | ||
| 19581 | @_, | ||
| 19582 | ); | ||
| 19583 | } | ||
| 19584 | |||
| 19585 | # Import the currently selected portions of the notebook list | ||
| 19586 | @list = $self->notebookGetSelectedData(); | ||
| 19587 | if (! @list) { | ||
| 19588 | |||
| 19589 | # Nothing selected | ||
| 19590 | return undef; | ||
| 19591 | } | ||
| 19592 | |||
| 19593 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 19594 | # a single row of the list | ||
| 19595 | $dataRef = $list[0]; | ||
| 19596 | @dataList = @$dataRef; | ||
| 19597 | # The colour scheme's name is the second item of data | ||
| 19598 | $name = $dataList[1]; | ||
| 19599 | if (! $name) { | ||
| 19600 | |||
| 19601 | # Can't continue | ||
| 19602 | return undef; | ||
| 19603 | } | ||
| 19604 | |||
| 19605 | # Get the colour scheme itself | ||
| 19606 | $obj = $axmud::CLIENT->ivShow('colourSchemeHash', $name); | ||
| 19607 | if (! $obj) { | ||
| 19608 | |||
| 19609 | # Can't continue | ||
| 19610 | return undef; | ||
| 19611 | |||
| 19612 | } else { | ||
| 19613 | |||
| 19614 | # Open up an 'edit' window to edit the object | ||
| 19615 | $self->createFreeWin( | ||
| 19616 | 'Games::Axmud::EditWin::ColourScheme', | ||
| 19617 | $self, | ||
| 19618 | $self->session, | ||
| 19619 | 'Edit colour scheme \'' . $name . '\'', | ||
| 19620 | $obj, | ||
| 19621 | FALSE, # Not temporary | ||
| 19622 | ); | ||
| 19623 | |||
| 19624 | return 1; | ||
| 19625 | } | ||
| 19626 | } | ||
| 19627 | |||
| 19628 | sub buttonDelete_colourScheme { | ||
| 19629 | |||
| 19630 | # Callback: Deletes a colour scheme object (equivalent to ';deletecolourscheme') | ||
| 19631 | # | ||
| 19632 | # Expected arguments | ||
| 19633 | # (none besides $self) | ||
| 19634 | # | ||
| 19635 | # Return values | ||
| 19636 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 19637 | # 1 otherwise | ||
| 19638 | |||
| 19639 | my ($self, $check) = @_; | ||
| 19640 | |||
| 19641 | # Local variables | ||
| 19642 | my ( | ||
| 19643 | $dataRef, $name, | ||
| 19644 | @list, @dataList, | ||
| 19645 | ); | ||
| 19646 | |||
| 19647 | # Check for improper arguments | ||
| 19648 | if (defined $check) { | ||
| 19649 | |||
| 19650 | return $axmud::CLIENT->writeImproper( | ||
| 19651 | $self->_objClass . '->buttonDelete_colourScheme', | ||
| 19652 | @_, | ||
| 19653 | ); | ||
| 19654 | } | ||
| 19655 | |||
| 19656 | # Import the currently selected portions of the notebook list | ||
| 19657 | @list = $self->notebookGetSelectedData(); | ||
| 19658 | if (! @list) { | ||
| 19659 | |||
| 19660 | # Nothing selected | ||
| 19661 | return undef; | ||
| 19662 | } | ||
| 19663 | |||
| 19664 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 19665 | # a single row of the list | ||
| 19666 | $dataRef = $list[0]; | ||
| 19667 | @dataList = @$dataRef; | ||
| 19668 | # The colour scheme object name is the second item of data | ||
| 19669 | $name = $dataList[1]; | ||
| 19670 | if (! $name) { | ||
| 19671 | |||
| 19672 | # Can't continue | ||
| 19673 | return undef; | ||
| 19674 | } | ||
| 19675 | |||
| 19676 | # Delete the colour scheme | ||
| 19677 | $self->session->pseudoCmd('deletecolourscheme <' . $name . '>', $self->pseudoCmdMode); | ||
| 19678 | |||
| 19679 | # Update the notebook | ||
| 19680 | $self->updateNotebook(); | ||
| 19681 | |||
| 19682 | return 1; | ||
| 19683 | } | ||
| 19684 | |||
| 19685 | sub buttonDump_colourScheme { | ||
| 19686 | |||
| 19687 | # Callback: Displays a list of colour scheme objects in the 'main' window (equivalent to | ||
| 19688 | # ';listcolourscheme') | ||
| 19689 | # | ||
| 19690 | # Expected arguments | ||
| 19691 | # (none besides $self) | ||
| 19692 | # | ||
| 19693 | # Return values | ||
| 19694 | # 'undef' on improper arguments | ||
| 19695 | # 1 otherwise | ||
| 19696 | |||
| 19697 | my ($self, $check) = @_; | ||
| 19698 | |||
| 19699 | # Local variables | ||
| 19700 | my ($tab, $slWidget); | ||
| 19701 | |||
| 19702 | # Check for improper arguments | ||
| 19703 | if (defined $check) { | ||
| 19704 | |||
| 19705 | return $axmud::CLIENT->writeImproper( | ||
| 19706 | $self->_objClass . '->buttonDump_colourScheme', | ||
| 19707 | @_, | ||
| 19708 | ); | ||
| 19709 | } | ||
| 19710 | |||
| 19711 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 19712 | $tab = $self->notebookGetTab(); | ||
| 19713 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 19714 | |||
| 19715 | # Unselect everything in the list | ||
| 19716 | $slWidget->get_selection->unselect_all(); | ||
| 19717 | |||
| 19718 | # Display the list | ||
| 19719 | $self->session->pseudoCmd('listcolourscheme', $self->pseudoCmdMode); | ||
| 19720 | |||
| 19721 | return 1; | ||
| 19722 | } | ||
| 19723 | |||
| 19724 | # Map label style callbacks | ||
| 19725 | |||
| 19726 | sub buttonAdd_mapLabelStyle { | ||
| 19727 | |||
| 19728 | # Callback: Add a map label style object (equivalent to ';addlabelstyle') | ||
| 19729 | # | ||
| 19730 | # Expected arguments | ||
| 19731 | # (none besides $self) | ||
| 19732 | # | ||
| 19733 | # Return values | ||
| 19734 | # 'undef' on improper arguments | ||
| 19735 | # 1 otherwise | ||
| 19736 | |||
| 19737 | my ($self, $check) = @_; | ||
| 19738 | |||
| 19739 | # Local variables | ||
| 19740 | my ($tab, $slWidget, $name); | ||
| 19741 | |||
| 19742 | # Check for improper arguments | ||
| 19743 | if (defined $check) { | ||
| 19744 | |||
| 19745 | return $axmud::CLIENT->writeImproper( | ||
| 19746 | $self->_objClass . '->buttonAdd_mapLabelStyle', | ||
| 19747 | @_, | ||
| 19748 | ); | ||
| 19749 | } | ||
| 19750 | |||
| 19751 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 19752 | $tab = $self->notebookGetTab(); | ||
| 19753 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 19754 | |||
| 19755 | # Unselect everything in the list, because we're creating a new map label style | ||
| 19756 | $slWidget->get_selection->unselect_all(); | ||
| 19757 | |||
| 19758 | # Prompt the user for the name of the map label style object | ||
| 19759 | $name = $self->showEntryDialogue( | ||
| 19760 | 'Add map label style', | ||
| 19761 | 'Enter a name for the object (max 16 chars)', | ||
| 19762 | 16, # Max chars | ||
| 19763 | ); | ||
| 19764 | |||
| 19765 | if ($name) { | ||
| 19766 | |||
| 19767 | # Add the new map label style | ||
| 19768 | $self->session->pseudoCmd('addlabelstyle <' . $name . '>', $self->pseudoCmdMode); | ||
| 19769 | |||
| 19770 | # Update the notebook | ||
| 19771 | $self->updateNotebook(); | ||
| 19772 | } | ||
| 19773 | |||
| 19774 | return 1; | ||
| 19775 | } | ||
| 19776 | |||
| 19777 | sub buttonEdit_mapLabelStyle { | ||
| 19778 | |||
| 19779 | # Callback: Edits a map label style object (equivalent to ';editlabelstyle') | ||
| 19780 | # | ||
| 19781 | # Expected arguments | ||
| 19782 | # (none besides $self) | ||
| 19783 | # | ||
| 19784 | # Return values | ||
| 19785 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 19786 | # object no longer exists | ||
| 19787 | # 1 otherwise | ||
| 19788 | |||
| 19789 | my ($self, $check) = @_; | ||
| 19790 | |||
| 19791 | # Local variables | ||
| 19792 | my ( | ||
| 19793 | $dataRef, $name, $obj, | ||
| 19794 | @list, @dataList, | ||
| 19795 | ); | ||
| 19796 | |||
| 19797 | # Check for improper arguments | ||
| 19798 | if (defined $check) { | ||
| 19799 | |||
| 19800 | return $axmud::CLIENT->writeImproper( | ||
| 19801 | $self->_objClass . '->buttonEdit_mapLabelStyle', | ||
| 19802 | @_, | ||
| 19803 | ); | ||
| 19804 | } | ||
| 19805 | |||
| 19806 | # Import the currently selected portions of the notebook list | ||
| 19807 | @list = $self->notebookGetSelectedData(); | ||
| 19808 | if (! @list) { | ||
| 19809 | |||
| 19810 | # Nothing selected | ||
| 19811 | return undef; | ||
| 19812 | } | ||
| 19813 | |||
| 19814 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 19815 | # a single row of the list | ||
| 19816 | $dataRef = $list[0]; | ||
| 19817 | @dataList = @$dataRef; | ||
| 19818 | # The map label style's name is the second item of data | ||
| 19819 | $name = $dataList[1]; | ||
| 19820 | if (! $name) { | ||
| 19821 | |||
| 19822 | # Can't continue | ||
| 19823 | return undef; | ||
| 19824 | } | ||
| 19825 | |||
| 19826 | # Get the map label style itself | ||
| 19827 | $obj = $self->session->worldModelObj->ivShow('mapLabelStyleHash', $name); | ||
| 19828 | if (! $obj) { | ||
| 19829 | |||
| 19830 | # Can't continue | ||
| 19831 | return undef; | ||
| 19832 | |||
| 19833 | } else { | ||
| 19834 | |||
| 19835 | # Open up an 'edit' window to edit the object | ||
| 19836 | $self->createFreeWin( | ||
| 19837 | 'Games::Axmud::EditWin::MapLabelStyle', | ||
| 19838 | $self, | ||
| 19839 | $self->session, | ||
| 19840 | 'Edit map label style \'' . $name . '\'', | ||
| 19841 | $obj, | ||
| 19842 | FALSE, # Not temporary | ||
| 19843 | ); | ||
| 19844 | |||
| 19845 | return 1; | ||
| 19846 | } | ||
| 19847 | } | ||
| 19848 | |||
| 19849 | sub buttonRename_mapLabelStyle { | ||
| 19850 | |||
| 19851 | # Callback: Renames a map label style object (equivalent to ';renamelabelstyle') | ||
| 19852 | # | ||
| 19853 | # Expected arguments | ||
| 19854 | # (none besides $self) | ||
| 19855 | # | ||
| 19856 | # Return values | ||
| 19857 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 19858 | # object no longer exists | ||
| 19859 | # 1 otherwise | ||
| 19860 | |||
| 19861 | my ($self, $check) = @_; | ||
| 19862 | |||
| 19863 | # Local variables | ||
| 19864 | my ( | ||
| 19865 | $dataRef, $oldName, $obj, $newName, | ||
| 19866 | @list, @dataList, | ||
| 19867 | ); | ||
| 19868 | |||
| 19869 | # Check for improper arguments | ||
| 19870 | if (defined $check) { | ||
| 19871 | |||
| 19872 | return $axmud::CLIENT->writeImproper( | ||
| 19873 | $self->_objClass . '->buttonRename_mapLabelStyle', | ||
| 19874 | @_, | ||
| 19875 | ); | ||
| 19876 | } | ||
| 19877 | |||
| 19878 | # Import the currently selected portions of the notebook list | ||
| 19879 | @list = $self->notebookGetSelectedData(); | ||
| 19880 | if (! @list) { | ||
| 19881 | |||
| 19882 | # Nothing selected | ||
| 19883 | return undef; | ||
| 19884 | } | ||
| 19885 | |||
| 19886 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 19887 | # a single row of the list | ||
| 19888 | $dataRef = $list[0]; | ||
| 19889 | @dataList = @$dataRef; | ||
| 19890 | # The map label style's name is the second item of data | ||
| 19891 | $oldName = $dataList[1]; | ||
| 19892 | if (! $oldName) { | ||
| 19893 | |||
| 19894 | # Can't continue | ||
| 19895 | return undef; | ||
| 19896 | } | ||
| 19897 | |||
| 19898 | # Get the map label style itself | ||
| 19899 | $obj = $self->session->worldModelObj->ivShow('mapLabelStyleHash', $oldName); | ||
| 19900 | if (! $obj) { | ||
| 19901 | |||
| 19902 | # Can't continue | ||
| 19903 | return undef; | ||
| 19904 | } | ||
| 19905 | |||
| 19906 | # Prompt the user for a new name | ||
| 19907 | $newName = $self->showEntryDialogue( | ||
| 19908 | 'Rename map label style', | ||
| 19909 | 'Enter a new name for the object (max 16 chars)', | ||
| 19910 | 16, # Max chars | ||
| 19911 | ); | ||
| 19912 | |||
| 19913 | if ($newName) { | ||
| 19914 | |||
| 19915 | # Rename the map label style | ||
| 19916 | $self->session->pseudoCmd( | ||
| 19917 | 'renamelabelstyle <' . $oldName . '> <' . $newName . '>', | ||
| 19918 | $self->pseudoCmdMode, | ||
| 19919 | ); | ||
| 19920 | |||
| 19921 | # Update the notebook | ||
| 19922 | $self->updateNotebook(); | ||
| 19923 | } | ||
| 19924 | |||
| 19925 | return 1; | ||
| 19926 | } | ||
| 19927 | |||
| 19928 | sub buttonDelete_mapLabelStyle { | ||
| 19929 | |||
| 19930 | # Callback: Deletes a map label style object (equivalent to ';deletelabelstyle') | ||
| 19931 | # | ||
| 19932 | # Expected arguments | ||
| 19933 | # (none besides $self) | ||
| 19934 | # | ||
| 19935 | # Return values | ||
| 19936 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 19937 | # 1 otherwise | ||
| 19938 | |||
| 19939 | my ($self, $check) = @_; | ||
| 19940 | |||
| 19941 | # Local variables | ||
| 19942 | my ( | ||
| 19943 | $dataRef, $name, | ||
| 19944 | @list, @dataList, | ||
| 19945 | ); | ||
| 19946 | |||
| 19947 | # Check for improper arguments | ||
| 19948 | if (defined $check) { | ||
| 19949 | |||
| 19950 | return $axmud::CLIENT->writeImproper( | ||
| 19951 | $self->_objClass . '->buttonDelete_mapLabelStyle', | ||
| 19952 | @_, | ||
| 19953 | ); | ||
| 19954 | } | ||
| 19955 | |||
| 19956 | # Import the currently selected portions of the notebook list | ||
| 19957 | @list = $self->notebookGetSelectedData(); | ||
| 19958 | if (! @list) { | ||
| 19959 | |||
| 19960 | # Nothing selected | ||
| 19961 | return undef; | ||
| 19962 | } | ||
| 19963 | |||
| 19964 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 19965 | # a single row of the list | ||
| 19966 | $dataRef = $list[0]; | ||
| 19967 | @dataList = @$dataRef; | ||
| 19968 | # The map label style object name is the second item of data | ||
| 19969 | $name = $dataList[1]; | ||
| 19970 | if (! $name) { | ||
| 19971 | |||
| 19972 | # Can't continue | ||
| 19973 | return undef; | ||
| 19974 | } | ||
| 19975 | |||
| 19976 | # Delete the map label style | ||
| 19977 | $self->session->pseudoCmd('deletelabelstyle <' . $name . '>', $self->pseudoCmdMode); | ||
| 19978 | |||
| 19979 | # Update the notebook | ||
| 19980 | $self->updateNotebook(); | ||
| 19981 | |||
| 19982 | return 1; | ||
| 19983 | } | ||
| 19984 | |||
| 19985 | sub buttonDump_mapLabelStyle { | ||
| 19986 | |||
| 19987 | # Callback: Displays a list of map label style objects in the 'main' window (equivalent to | ||
| 19988 | # ';listlabelstyle') | ||
| 19989 | # | ||
| 19990 | # Expected arguments | ||
| 19991 | # (none besides $self) | ||
| 19992 | # | ||
| 19993 | # Return values | ||
| 19994 | # 'undef' on improper arguments | ||
| 19995 | # 1 otherwise | ||
| 19996 | |||
| 19997 | my ($self, $check) = @_; | ||
| 19998 | |||
| 19999 | # Local variables | ||
| 20000 | my ($tab, $slWidget); | ||
| 20001 | |||
| 20002 | # Check for improper arguments | ||
| 20003 | if (defined $check) { | ||
| 20004 | |||
| 20005 | return $axmud::CLIENT->writeImproper( | ||
| 20006 | $self->_objClass . '->buttonDump_mapLabelStyle', | ||
| 20007 | @_, | ||
| 20008 | ); | ||
| 20009 | } | ||
| 20010 | |||
| 20011 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 20012 | $tab = $self->notebookGetTab(); | ||
| 20013 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 20014 | |||
| 20015 | # Unselect everything in the list | ||
| 20016 | $slWidget->get_selection->unselect_all(); | ||
| 20017 | |||
| 20018 | # Display the list | ||
| 20019 | $self->session->pseudoCmd('listlabelstyle', $self->pseudoCmdMode); | ||
| 20020 | |||
| 20021 | return 1; | ||
| 20022 | } | ||
| 20023 | |||
| 20024 | # Region colour scheme button callbacks | ||
| 20025 | |||
| 20026 | sub buttonAdd_regionScheme { | ||
| 20027 | |||
| 20028 | # Callback: Add a region scheme object (equivalent to ';addregionscheme') | ||
| 20029 | # | ||
| 20030 | # Expected arguments | ||
| 20031 | # (none besides $self) | ||
| 20032 | # | ||
| 20033 | # Return values | ||
| 20034 | # 'undef' on improper arguments | ||
| 20035 | # 1 otherwise | ||
| 20036 | |||
| 20037 | my ($self, $check) = @_; | ||
| 20038 | |||
| 20039 | # Local variables | ||
| 20040 | my ($tab, $slWidget, $name); | ||
| 20041 | |||
| 20042 | # Check for improper arguments | ||
| 20043 | if (defined $check) { | ||
| 20044 | |||
| 20045 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonAdd_regionScheme', @_); | ||
| 20046 | } | ||
| 20047 | |||
| 20048 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 20049 | $tab = $self->notebookGetTab(); | ||
| 20050 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 20051 | |||
| 20052 | # Unselect everything in the list, because we're creating a new region scheme | ||
| 20053 | $slWidget->get_selection->unselect_all(); | ||
| 20054 | |||
| 20055 | # Prompt the user for the name of the region scheme object | ||
| 20056 | $name = $self->showEntryDialogue( | ||
| 20057 | 'Add region colour scheme', | ||
| 20058 | 'Enter a name for the object (max 16 chars)', | ||
| 20059 | 16, # Max chars | ||
| 20060 | ); | ||
| 20061 | |||
| 20062 | if ($name) { | ||
| 20063 | |||
| 20064 | # Add the new colour scheme | ||
| 20065 | $self->session->pseudoCmd('addregionscheme <' . $name . '>', $self->pseudoCmdMode); | ||
| 20066 | |||
| 20067 | # Update the notebook | ||
| 20068 | $self->updateNotebook(); | ||
| 20069 | } | ||
| 20070 | |||
| 20071 | return 1; | ||
| 20072 | } | ||
| 20073 | |||
| 20074 | sub buttonEdit_regionScheme { | ||
| 20075 | |||
| 20076 | # Callback: Edits a region colour scheme object (equivalent to ';editregionscheme') | ||
| 20077 | # | ||
| 20078 | # Expected arguments | ||
| 20079 | # (none besides $self) | ||
| 20080 | # | ||
| 20081 | # Return values | ||
| 20082 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 20083 | # object no longer exists | ||
| 20084 | # 1 otherwise | ||
| 20085 | |||
| 20086 | my ($self, $check) = @_; | ||
| 20087 | |||
| 20088 | # Local variables | ||
| 20089 | my ( | ||
| 20090 | $dataRef, $name, $obj, | ||
| 20091 | @list, @dataList, | ||
| 20092 | ); | ||
| 20093 | |||
| 20094 | # Check for improper arguments | ||
| 20095 | if (defined $check) { | ||
| 20096 | |||
| 20097 | return $axmud::CLIENT->writeImproper( | ||
| 20098 | $self->_objClass . '->buttonEdit_regionScheme', | ||
| 20099 | @_, | ||
| 20100 | ); | ||
| 20101 | } | ||
| 20102 | |||
| 20103 | # Import the currently selected portions of the notebook list | ||
| 20104 | @list = $self->notebookGetSelectedData(); | ||
| 20105 | if (! @list) { | ||
| 20106 | |||
| 20107 | # Nothing selected | ||
| 20108 | return undef; | ||
| 20109 | } | ||
| 20110 | |||
| 20111 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 20112 | # a single row of the list | ||
| 20113 | $dataRef = $list[0]; | ||
| 20114 | @dataList = @$dataRef; | ||
| 20115 | # The region scheme's name is the second item of data | ||
| 20116 | $name = $dataList[1]; | ||
| 20117 | if (! $name) { | ||
| 20118 | |||
| 20119 | # Can't continue | ||
| 20120 | return undef; | ||
| 20121 | } | ||
| 20122 | |||
| 20123 | # Get the region scheme itself | ||
| 20124 | $obj = $self->session->worldModelObj->ivShow('regionSchemeHash', $name); | ||
| 20125 | if (! $obj) { | ||
| 20126 | |||
| 20127 | # Can't continue | ||
| 20128 | return undef; | ||
| 20129 | |||
| 20130 | } else { | ||
| 20131 | |||
| 20132 | # Open up an 'edit' window to edit the object | ||
| 20133 | $self->createFreeWin( | ||
| 20134 | 'Games::Axmud::EditWin::RegionScheme', | ||
| 20135 | $self, | ||
| 20136 | $self->session, | ||
| 20137 | 'Edit region colour scheme \'' . $name . '\'', | ||
| 20138 | $obj, | ||
| 20139 | FALSE, # Not temporary | ||
| 20140 | ); | ||
| 20141 | |||
| 20142 | return 1; | ||
| 20143 | } | ||
| 20144 | } | ||
| 20145 | |||
| 20146 | sub buttonRename_regionScheme { | ||
| 20147 | |||
| 20148 | # Callback: Renames a region colour scheme object (equivalent to ';renameregionscheme') | ||
| 20149 | # | ||
| 20150 | # Expected arguments | ||
| 20151 | # (none besides $self) | ||
| 20152 | # | ||
| 20153 | # Return values | ||
| 20154 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 20155 | # object no longer exists | ||
| 20156 | # 1 otherwise | ||
| 20157 | |||
| 20158 | my ($self, $check) = @_; | ||
| 20159 | |||
| 20160 | # Local variables | ||
| 20161 | my ( | ||
| 20162 | $dataRef, $oldName, $obj, $newName, | ||
| 20163 | @list, @dataList, | ||
| 20164 | ); | ||
| 20165 | |||
| 20166 | # Check for improper arguments | ||
| 20167 | if (defined $check) { | ||
| 20168 | |||
| 20169 | return $axmud::CLIENT->writeImproper( | ||
| 20170 | $self->_objClass . '->buttonEdit_regionScheme', | ||
| 20171 | @_, | ||
| 20172 | ); | ||
| 20173 | } | ||
| 20174 | |||
| 20175 | # Import the currently selected portions of the notebook list | ||
| 20176 | @list = $self->notebookGetSelectedData(); | ||
| 20177 | if (! @list) { | ||
| 20178 | |||
| 20179 | # Nothing selected | ||
| 20180 | return undef; | ||
| 20181 | } | ||
| 20182 | |||
| 20183 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 20184 | # a single row of the list | ||
| 20185 | $dataRef = $list[0]; | ||
| 20186 | @dataList = @$dataRef; | ||
| 20187 | # The region scheme's name is the second item of data | ||
| 20188 | $oldName = $dataList[1]; | ||
| 20189 | if (! $oldName) { | ||
| 20190 | |||
| 20191 | # Can't continue | ||
| 20192 | return undef; | ||
| 20193 | } | ||
| 20194 | |||
| 20195 | # Get the region scheme itself | ||
| 20196 | $obj = $self->session->worldModelObj->ivShow('regionSchemeHash', $oldName); | ||
| 20197 | if (! $obj) { | ||
| 20198 | |||
| 20199 | # Can't continue | ||
| 20200 | return undef; | ||
| 20201 | } | ||
| 20202 | |||
| 20203 | # Prompt the user for a new name | ||
| 20204 | $newName = $self->showEntryDialogue( | ||
| 20205 | 'Rename region colour scheme', | ||
| 20206 | 'Enter a new name for the object (max 16 chars)', | ||
| 20207 | 16, # Max chars | ||
| 20208 | ); | ||
| 20209 | |||
| 20210 | if ($newName) { | ||
| 20211 | |||
| 20212 | # Rename the colour scheme | ||
| 20213 | $self->session->pseudoCmd( | ||
| 20214 | 'renameregionscheme <' . $oldName . '> <' . $newName . '>', | ||
| 20215 | $self->pseudoCmdMode, | ||
| 20216 | ); | ||
| 20217 | |||
| 20218 | # Update the notebook | ||
| 20219 | $self->updateNotebook(); | ||
| 20220 | } | ||
| 20221 | |||
| 20222 | return 1; | ||
| 20223 | } | ||
| 20224 | |||
| 20225 | sub buttonDelete_regionScheme { | ||
| 20226 | |||
| 20227 | # Callback: Deletes a region scheme object (equivalent to ';deleteregionscheme') | ||
| 20228 | # | ||
| 20229 | # Expected arguments | ||
| 20230 | # (none besides $self) | ||
| 20231 | # | ||
| 20232 | # Return values | ||
| 20233 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 20234 | # 1 otherwise | ||
| 20235 | |||
| 20236 | my ($self, $check) = @_; | ||
| 20237 | |||
| 20238 | # Local variables | ||
| 20239 | my ( | ||
| 20240 | $dataRef, $name, | ||
| 20241 | @list, @dataList, | ||
| 20242 | ); | ||
| 20243 | |||
| 20244 | # Check for improper arguments | ||
| 20245 | if (defined $check) { | ||
| 20246 | |||
| 20247 | return $axmud::CLIENT->writeImproper( | ||
| 20248 | $self->_objClass . '->buttonDelete_regionScheme', | ||
| 20249 | @_, | ||
| 20250 | ); | ||
| 20251 | } | ||
| 20252 | |||
| 20253 | # Import the currently selected portions of the notebook list | ||
| 20254 | @list = $self->notebookGetSelectedData(); | ||
| 20255 | if (! @list) { | ||
| 20256 | |||
| 20257 | # Nothing selected | ||
| 20258 | return undef; | ||
| 20259 | } | ||
| 20260 | |||
| 20261 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 20262 | # a single row of the list | ||
| 20263 | $dataRef = $list[0]; | ||
| 20264 | @dataList = @$dataRef; | ||
| 20265 | # The region scheme object name is the second item of data | ||
| 20266 | $name = $dataList[1]; | ||
| 20267 | if (! $name) { | ||
| 20268 | |||
| 20269 | # Can't continue | ||
| 20270 | return undef; | ||
| 20271 | } | ||
| 20272 | |||
| 20273 | # Delete the region scheme | ||
| 20274 | $self->session->pseudoCmd('deleteregionscheme <' . $name . '>', $self->pseudoCmdMode); | ||
| 20275 | |||
| 20276 | # Update the notebook | ||
| 20277 | $self->updateNotebook(); | ||
| 20278 | |||
| 20279 | return 1; | ||
| 20280 | } | ||
| 20281 | |||
| 20282 | sub buttonDump_regionScheme { | ||
| 20283 | |||
| 20284 | # Callback: Displays a list of region scheme objects in the 'main' window (equivalent to | ||
| 20285 | # ';listregionscheme') | ||
| 20286 | # | ||
| 20287 | # Expected arguments | ||
| 20288 | # (none besides $self) | ||
| 20289 | # | ||
| 20290 | # Return values | ||
| 20291 | # 'undef' on improper arguments | ||
| 20292 | # 1 otherwise | ||
| 20293 | |||
| 20294 | my ($self, $check) = @_; | ||
| 20295 | |||
| 20296 | # Local variables | ||
| 20297 | my ($tab, $slWidget); | ||
| 20298 | |||
| 20299 | # Check for improper arguments | ||
| 20300 | if (defined $check) { | ||
| 20301 | |||
| 20302 | return $axmud::CLIENT->writeImproper( | ||
| 20303 | $self->_objClass . '->buttonDump_regionScheme', | ||
| 20304 | @_, | ||
| 20305 | ); | ||
| 20306 | } | ||
| 20307 | |||
| 20308 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 20309 | $tab = $self->notebookGetTab(); | ||
| 20310 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 20311 | |||
| 20312 | # Unselect everything in the list | ||
| 20313 | $slWidget->get_selection->unselect_all(); | ||
| 20314 | |||
| 20315 | # Display the list | ||
| 20316 | $self->session->pseudoCmd('listregionscheme', $self->pseudoCmdMode); | ||
| 20317 | |||
| 20318 | return 1; | ||
| 20319 | } | ||
| 20320 | |||
| 20321 | # TTS configuration button callbacks | ||
| 20322 | |||
| 20323 | sub buttonAdd_tts { | ||
| 20324 | |||
| 20325 | # Callback: Add a TTS configuration (equivalent to ';addconfig') | ||
| 20326 | # | ||
| 20327 | # Expected arguments | ||
| 20328 | # (none besides $self) | ||
| 20329 | # | ||
| 20330 | # Return values | ||
| 20331 | # 'undef' on improper arguments | ||
| 20332 | # 1 otherwise | ||
| 20333 | |||
| 20334 | my ($self, $check) = @_; | ||
| 20335 | |||
| 20336 | # Local variables | ||
| 20337 | my ($tab, $slWidget, $name, $engine); | ||
| 20338 | |||
| 20339 | # Check for improper arguments | ||
| 20340 | if (defined $check) { | ||
| 20341 | |||
| 20342 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonAdd_tts', @_); | ||
| 20343 | } | ||
| 20344 | |||
| 20345 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 20346 | $tab = $self->notebookGetTab(); | ||
| 20347 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 20348 | |||
| 20349 | # Unselect everything in the list, because we're creating a new TTS configuration | ||
| 20350 | $slWidget->get_selection->unselect_all(); | ||
| 20351 | |||
| 20352 | # Prompt the user for the name of the TTS configuration and the engine to use | ||
| 20353 | ($name, $engine) = $self->showEntryComboDialogue( | ||
| 20354 | 'Add TTS configuration', | ||
| 20355 | 'Enter a name for the object (max 16 chars: A-Z a-z _ 0-9)', | ||
| 20356 | 'Select the speech engine', | ||
| 20357 | [$axmud::CLIENT->constTTSList], | ||
| 20358 | 16, # Max chars | ||
| 20359 | ); | ||
| 20360 | |||
| 20361 | if ($name) { | ||
| 20362 | |||
| 20363 | # Add the new TTS configuration | ||
| 20364 | $self->session->pseudoCmd('addconfig ' . $name . ' ' . $engine, $self->pseudoCmdMode); | ||
| 20365 | |||
| 20366 | # Update the notebook | ||
| 20367 | $self->updateNotebook(); | ||
| 20368 | } | ||
| 20369 | |||
| 20370 | return 1; | ||
| 20371 | } | ||
| 20372 | |||
| 20373 | sub buttonClone_tts { | ||
| 20374 | |||
| 20375 | # Callback: Clones the selected TTS configuration (equivalent to ';cloneconfig') | ||
| 20376 | # | ||
| 20377 | # Expected arguments | ||
| 20378 | # (none besides $self) | ||
| 20379 | # | ||
| 20380 | # Return values | ||
| 20381 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 20382 | # 1 otherwise | ||
| 20383 | |||
| 20384 | my ($self, $check) = @_; | ||
| 20385 | |||
| 20386 | # Local variables | ||
| 20387 | my ( | ||
| 20388 | $dataRef, $name, $cloneName, | ||
| 20389 | @list, @dataList, | ||
| 20390 | ); | ||
| 20391 | |||
| 20392 | # Check for improper arguments | ||
| 20393 | if (defined $check) { | ||
| 20394 | |||
| 20395 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonClone_tts', @_); | ||
| 20396 | } | ||
| 20397 | |||
| 20398 | # Import the currently selected portions of the notebook list | ||
| 20399 | @list = $self->notebookGetSelectedData(); | ||
| 20400 | if (! @list) { | ||
| 20401 | |||
| 20402 | # Nothing selected | ||
| 20403 | return undef; | ||
| 20404 | } | ||
| 20405 | |||
| 20406 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 20407 | # a single row of the list | ||
| 20408 | $dataRef = $list[0]; | ||
| 20409 | @dataList = @$dataRef; | ||
| 20410 | # The TTS configuration object name is the first item of data | ||
| 20411 | $name = $dataList[0]; | ||
| 20412 | if (! $name) { | ||
| 20413 | |||
| 20414 | # Can't continue | ||
| 20415 | return undef; | ||
| 20416 | } | ||
| 20417 | |||
| 20418 | # Prompt the user for the name of the clone | ||
| 20419 | $cloneName = $self->showEntryDialogue( | ||
| 20420 | 'Clone TTS configuration', | ||
| 20421 | 'Enter a name for the clone (max 16 chars: A-Z a-z _ 0-9)', | ||
| 20422 | 16, # Max chars | ||
| 20423 | ); | ||
| 20424 | |||
| 20425 | if ($cloneName) { | ||
| 20426 | |||
| 20427 | # Clone the TTS configuration | ||
| 20428 | $self->session->pseudoCmd( | ||
| 20429 | 'cloneconfig ' . $name . ' ' . $cloneName, | ||
| 20430 | $self->pseudoCmdMode, | ||
| 20431 | ); | ||
| 20432 | |||
| 20433 | # Update the notebook | ||
| 20434 | $self->updateNotebook(); | ||
| 20435 | } | ||
| 20436 | |||
| 20437 | return 1; | ||
| 20438 | } | ||
| 20439 | |||
| 20440 | sub buttonEdit_tts { | ||
| 20441 | |||
| 20442 | # Callback: Edits a TTS configuration (equivalent to ';editconfig') | ||
| 20443 | # | ||
| 20444 | # Expected arguments | ||
| 20445 | # (none besides $self) | ||
| 20446 | # | ||
| 20447 | # Return values | ||
| 20448 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 20449 | # object no longer exists | ||
| 20450 | # 1 otherwise | ||
| 20451 | |||
| 20452 | my ($self, $check) = @_; | ||
| 20453 | |||
| 20454 | # Local variables | ||
| 20455 | my ( | ||
| 20456 | $dataRef, $name, $obj, | ||
| 20457 | @list, @dataList, | ||
| 20458 | ); | ||
| 20459 | |||
| 20460 | # Check for improper arguments | ||
| 20461 | if (defined $check) { | ||
| 20462 | |||
| 20463 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonEdit_tts', @_); | ||
| 20464 | } | ||
| 20465 | |||
| 20466 | # Import the currently selected portions of the notebook list | ||
| 20467 | @list = $self->notebookGetSelectedData(); | ||
| 20468 | if (! @list) { | ||
| 20469 | |||
| 20470 | # Nothing selected | ||
| 20471 | return undef; | ||
| 20472 | } | ||
| 20473 | |||
| 20474 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 20475 | # a single row of the list | ||
| 20476 | $dataRef = $list[0]; | ||
| 20477 | @dataList = @$dataRef; | ||
| 20478 | # The TTS configuration's name is the first item of data | ||
| 20479 | $name = $dataList[0]; | ||
| 20480 | if (! $name) { | ||
| 20481 | |||
| 20482 | # Can't continue | ||
| 20483 | return undef; | ||
| 20484 | } | ||
| 20485 | |||
| 20486 | # Get the TTS configuration itself | ||
| 20487 | $obj = $axmud::CLIENT->ivShow('ttsObjHash', $name); | ||
| 20488 | if (! $obj) { | ||
| 20489 | |||
| 20490 | # Can't continue | ||
| 20491 | return undef; | ||
| 20492 | |||
| 20493 | } else { | ||
| 20494 | |||
| 20495 | # Open up an 'edit' window to edit the object | ||
| 20496 | $self->createFreeWin( | ||
| 20497 | 'Games::Axmud::EditWin::TTS', | ||
| 20498 | $self, | ||
| 20499 | $self->session, | ||
| 20500 | 'Edit text-to-speech configuration \'' . $name . '\'', | ||
| 20501 | $obj, | ||
| 20502 | FALSE, # Not temporary | ||
| 20503 | ); | ||
| 20504 | |||
| 20505 | return 1; | ||
| 20506 | } | ||
| 20507 | } | ||
| 20508 | |||
| 20509 | sub buttonDelete_tts { | ||
| 20510 | |||
| 20511 | # Callback: Deletes a TTS configuration (equivalent to ';deleteconfig') | ||
| 20512 | # | ||
| 20513 | # Expected arguments | ||
| 20514 | # (none besides $self) | ||
| 20515 | # | ||
| 20516 | # Return values | ||
| 20517 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 20518 | # 1 otherwise | ||
| 20519 | |||
| 20520 | my ($self, $check) = @_; | ||
| 20521 | |||
| 20522 | # Local variables | ||
| 20523 | my ( | ||
| 20524 | $dataRef, $name, | ||
| 20525 | @list, @dataList, | ||
| 20526 | ); | ||
| 20527 | |||
| 20528 | # Check for improper arguments | ||
| 20529 | if (defined $check) { | ||
| 20530 | |||
| 20531 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDelete_tts', @_); | ||
| 20532 | } | ||
| 20533 | |||
| 20534 | # Import the currently selected portions of the notebook list | ||
| 20535 | @list = $self->notebookGetSelectedData(); | ||
| 20536 | if (! @list) { | ||
| 20537 | |||
| 20538 | # Nothing selected | ||
| 20539 | return undef; | ||
| 20540 | } | ||
| 20541 | |||
| 20542 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 20543 | # a single row of the list | ||
| 20544 | $dataRef = $list[0]; | ||
| 20545 | @dataList = @$dataRef; | ||
| 20546 | # The TTS configuration name is the first item of data | ||
| 20547 | $name = $dataList[0]; | ||
| 20548 | if (! $name) { | ||
| 20549 | |||
| 20550 | # Can't continue | ||
| 20551 | return undef; | ||
| 20552 | } | ||
| 20553 | |||
| 20554 | # Delete the TTS configuration | ||
| 20555 | $self->session->pseudoCmd('deleteconfig ' . $name, $self->pseudoCmdMode); | ||
| 20556 | |||
| 20557 | # Update the notebook | ||
| 20558 | $self->updateNotebook(); | ||
| 20559 | |||
| 20560 | return 1; | ||
| 20561 | } | ||
| 20562 | |||
| 20563 | sub buttonDump_tts { | ||
| 20564 | |||
| 20565 | # Callback: Displays a list of TTS configurations in the 'main' window (equivalent to | ||
| 20566 | # ';listconfig') | ||
| 20567 | # | ||
| 20568 | # Expected arguments | ||
| 20569 | # (none besides $self) | ||
| 20570 | # | ||
| 20571 | # Return values | ||
| 20572 | # 'undef' on improper arguments | ||
| 20573 | # 1 otherwise | ||
| 20574 | |||
| 20575 | my ($self, $check) = @_; | ||
| 20576 | |||
| 20577 | # Local variables | ||
| 20578 | my ($tab, $slWidget); | ||
| 20579 | |||
| 20580 | # Check for improper arguments | ||
| 20581 | if (defined $check) { | ||
| 20582 | |||
| 20583 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDump_tts', @_); | ||
| 20584 | } | ||
| 20585 | |||
| 20586 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 20587 | $tab = $self->notebookGetTab(); | ||
| 20588 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 20589 | |||
| 20590 | # Unselect everything in the list | ||
| 20591 | $slWidget->get_selection->unselect_all(); | ||
| 20592 | |||
| 20593 | # Display the list | ||
| 20594 | $self->session->pseudoCmd('listconfig', $self->pseudoCmdMode); | ||
| 20595 | |||
| 20596 | return 1; | ||
| 20597 | } | ||
| 20598 | |||
| 20599 | # Winmap button callbacks | ||
| 20600 | |||
| 20601 | sub buttonAdd_winmap { | ||
| 20602 | |||
| 20603 | # Callback: Add a winmap (equivalent to ';addwinmap') | ||
| 20604 | # | ||
| 20605 | # Expected arguments | ||
| 20606 | # (none besides $self) | ||
| 20607 | # | ||
| 20608 | # Return values | ||
| 20609 | # 'undef' on improper arguments | ||
| 20610 | # 1 otherwise | ||
| 20611 | |||
| 20612 | my ($self, $check) = @_; | ||
| 20613 | |||
| 20614 | # Local variables | ||
| 20615 | my ($tab, $slWidget, $name); | ||
| 20616 | |||
| 20617 | # Check for improper arguments | ||
| 20618 | if (defined $check) { | ||
| 20619 | |||
| 20620 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonAdd_winmap', @_); | ||
| 20621 | } | ||
| 20622 | |||
| 20623 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 20624 | $tab = $self->notebookGetTab(); | ||
| 20625 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 20626 | |||
| 20627 | # Unselect everything in the list, because we're creating a new winmap | ||
| 20628 | $slWidget->get_selection->unselect_all(); | ||
| 20629 | |||
| 20630 | # Prompt the user for the name of the winmap | ||
| 20631 | $name = $self->showEntryDialogue( | ||
| 20632 | 'Add winmap', | ||
| 20633 | 'Enter a name for the object (max 16 chars: A-Z a-z _ 0-9)', | ||
| 20634 | 16, # Max chars | ||
| 20635 | ); | ||
| 20636 | |||
| 20637 | if ($name) { | ||
| 20638 | |||
| 20639 | # Add the new winmap | ||
| 20640 | $self->session->pseudoCmd('addwinmap ' . $name, $self->pseudoCmdMode); | ||
| 20641 | |||
| 20642 | # Update the notebook | ||
| 20643 | $self->updateNotebook(); | ||
| 20644 | } | ||
| 20645 | |||
| 20646 | return 1; | ||
| 20647 | } | ||
| 20648 | |||
| 20649 | sub buttonClone_winmap { | ||
| 20650 | |||
| 20651 | # Callback: Clones the selected winmap (equivalent to ';clonewinmap') | ||
| 20652 | # | ||
| 20653 | # Expected arguments | ||
| 20654 | # (none besides $self) | ||
| 20655 | # | ||
| 20656 | # Return values | ||
| 20657 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 20658 | # 1 otherwise | ||
| 20659 | |||
| 20660 | my ($self, $check) = @_; | ||
| 20661 | |||
| 20662 | # Local variables | ||
| 20663 | my ( | ||
| 20664 | $dataRef, $name, $cloneName, | ||
| 20665 | @list, @dataList, | ||
| 20666 | ); | ||
| 20667 | |||
| 20668 | # Check for improper arguments | ||
| 20669 | if (defined $check) { | ||
| 20670 | |||
| 20671 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonClone_winmap', @_); | ||
| 20672 | } | ||
| 20673 | |||
| 20674 | # Import the currently selected portions of the notebook list | ||
| 20675 | @list = $self->notebookGetSelectedData(); | ||
| 20676 | if (! @list) { | ||
| 20677 | |||
| 20678 | # Nothing selected | ||
| 20679 | return undef; | ||
| 20680 | } | ||
| 20681 | |||
| 20682 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 20683 | # a single row of the list | ||
| 20684 | $dataRef = $list[0]; | ||
| 20685 | @dataList = @$dataRef; | ||
| 20686 | # The winmap object name is the third item of data | ||
| 20687 | $name = $dataList[2]; | ||
| 20688 | if (! $name) { | ||
| 20689 | |||
| 20690 | # Can't continue | ||
| 20691 | return undef; | ||
| 20692 | } | ||
| 20693 | |||
| 20694 | # Prompt the user for the name of the clone | ||
| 20695 | $cloneName = $self->showEntryDialogue( | ||
| 20696 | 'Clone winmap', | ||
| 20697 | 'Enter a name for the clone (max 16 chars: A-Z a-z _ 0-9)', | ||
| 20698 | 16, # Max chars | ||
| 20699 | ); | ||
| 20700 | |||
| 20701 | if ($cloneName) { | ||
| 20702 | |||
| 20703 | # Clone the winmap | ||
| 20704 | $self->session->pseudoCmd( | ||
| 20705 | 'clonewinmap ' . $name . ' ' . $cloneName, | ||
| 20706 | $self->pseudoCmdMode, | ||
| 20707 | ); | ||
| 20708 | |||
| 20709 | # Update the notebook | ||
| 20710 | $self->updateNotebook(); | ||
| 20711 | } | ||
| 20712 | |||
| 20713 | return 1; | ||
| 20714 | } | ||
| 20715 | |||
| 20716 | sub buttonEdit_winmap { | ||
| 20717 | |||
| 20718 | # Callback: Edits a winmap (equivalent to ';editwinmap') | ||
| 20719 | # | ||
| 20720 | # Expected arguments | ||
| 20721 | # (none besides $self) | ||
| 20722 | # | ||
| 20723 | # Return values | ||
| 20724 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 20725 | # object no longer exists | ||
| 20726 | # 1 otherwise | ||
| 20727 | |||
| 20728 | my ($self, $check) = @_; | ||
| 20729 | |||
| 20730 | # Local variables | ||
| 20731 | my ( | ||
| 20732 | $dataRef, $name, $obj, | ||
| 20733 | @list, @dataList, | ||
| 20734 | ); | ||
| 20735 | |||
| 20736 | # Check for improper arguments | ||
| 20737 | if (defined $check) { | ||
| 20738 | |||
| 20739 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonEdit_winmap', @_); | ||
| 20740 | } | ||
| 20741 | |||
| 20742 | # Import the currently selected portions of the notebook list | ||
| 20743 | @list = $self->notebookGetSelectedData(); | ||
| 20744 | if (! @list) { | ||
| 20745 | |||
| 20746 | # Nothing selected | ||
| 20747 | return undef; | ||
| 20748 | } | ||
| 20749 | |||
| 20750 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 20751 | # a single row of the list | ||
| 20752 | $dataRef = $list[0]; | ||
| 20753 | @dataList = @$dataRef; | ||
| 20754 | # The winmap's name is the third item of data | ||
| 20755 | $name = $dataList[2]; | ||
| 20756 | if (! $name) { | ||
| 20757 | |||
| 20758 | # Can't continue | ||
| 20759 | return undef; | ||
| 20760 | } | ||
| 20761 | |||
| 20762 | # Get the winmap itself | ||
| 20763 | $obj = $axmud::CLIENT->ivShow('winmapHash', $name); | ||
| 20764 | if (! $obj) { | ||
| 20765 | |||
| 20766 | # Can't continue | ||
| 20767 | return undef; | ||
| 20768 | |||
| 20769 | } else { | ||
| 20770 | |||
| 20771 | # Open up an 'edit' window to edit the object | ||
| 20772 | $self->createFreeWin( | ||
| 20773 | 'Games::Axmud::EditWin::Winmap', | ||
| 20774 | $self, | ||
| 20775 | $self->session, | ||
| 20776 | 'Edit winmap \'' . $obj->name . '\'', | ||
| 20777 | $obj, | ||
| 20778 | FALSE, # Not temporary | ||
| 20779 | ); | ||
| 20780 | |||
| 20781 | return 1; | ||
| 20782 | } | ||
| 20783 | } | ||
| 20784 | |||
| 20785 | sub buttonDelete_winmap { | ||
| 20786 | |||
| 20787 | # Callback: Deletes a winmap (equivalent to ';deletewinmap') | ||
| 20788 | # | ||
| 20789 | # Expected arguments | ||
| 20790 | # (none besides $self) | ||
| 20791 | # | ||
| 20792 | # Return values | ||
| 20793 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 20794 | # 1 otherwise | ||
| 20795 | |||
| 20796 | my ($self, $check) = @_; | ||
| 20797 | |||
| 20798 | # Local variables | ||
| 20799 | my ( | ||
| 20800 | $dataRef, $name, | ||
| 20801 | @list, @dataList, | ||
| 20802 | ); | ||
| 20803 | |||
| 20804 | # Check for improper arguments | ||
| 20805 | if (defined $check) { | ||
| 20806 | |||
| 20807 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDelete_winmap', @_); | ||
| 20808 | } | ||
| 20809 | |||
| 20810 | # Import the currently selected portions of the notebook list | ||
| 20811 | @list = $self->notebookGetSelectedData(); | ||
| 20812 | if (! @list) { | ||
| 20813 | |||
| 20814 | # Nothing selected | ||
| 20815 | return undef; | ||
| 20816 | } | ||
| 20817 | |||
| 20818 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 20819 | # a single row of the list | ||
| 20820 | $dataRef = $list[0]; | ||
| 20821 | @dataList = @$dataRef; | ||
| 20822 | # The winmap name is the third item of data | ||
| 20823 | $name = $dataList[2]; | ||
| 20824 | if (! $name) { | ||
| 20825 | |||
| 20826 | # Can't continue | ||
| 20827 | return undef; | ||
| 20828 | } | ||
| 20829 | |||
| 20830 | # Delete the winmap | ||
| 20831 | $self->session->pseudoCmd('deletewinmap ' . $name, $self->pseudoCmdMode); | ||
| 20832 | |||
| 20833 | # Update the notebook | ||
| 20834 | $self->updateNotebook(); | ||
| 20835 | |||
| 20836 | return 1; | ||
| 20837 | } | ||
| 20838 | |||
| 20839 | sub buttonDump_winmap { | ||
| 20840 | |||
| 20841 | # Callback: Displays a list of winmaps in the 'main' window (equivalent to ';listwinmap') | ||
| 20842 | # | ||
| 20843 | # Expected arguments | ||
| 20844 | # (none besides $self) | ||
| 20845 | # | ||
| 20846 | # Return values | ||
| 20847 | # 'undef' on improper arguments | ||
| 20848 | # 1 otherwise | ||
| 20849 | |||
| 20850 | my ($self, $check) = @_; | ||
| 20851 | |||
| 20852 | # Local variables | ||
| 20853 | my ($tab, $slWidget); | ||
| 20854 | |||
| 20855 | # Check for improper arguments | ||
| 20856 | if (defined $check) { | ||
| 20857 | |||
| 20858 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDump_winmap', @_); | ||
| 20859 | } | ||
| 20860 | |||
| 20861 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 20862 | $tab = $self->notebookGetTab(); | ||
| 20863 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 20864 | |||
| 20865 | # Unselect everything in the list | ||
| 20866 | $slWidget->get_selection->unselect_all(); | ||
| 20867 | |||
| 20868 | # Display the list | ||
| 20869 | $self->session->pseudoCmd('listwinmap', $self->pseudoCmdMode); | ||
| 20870 | |||
| 20871 | return 1; | ||
| 20872 | } | ||
| 20873 | |||
| 20874 | # Zonemap button callbacks | ||
| 20875 | |||
| 20876 | sub buttonAdd_zonemap { | ||
| 20877 | |||
| 20878 | # Callback: Add a zonemap (equivalent to ';addzonemap') | ||
| 20879 | # | ||
| 20880 | # Expected arguments | ||
| 20881 | # (none besides $self) | ||
| 20882 | # | ||
| 20883 | # Return values | ||
| 20884 | # 'undef' on improper arguments | ||
| 20885 | # 1 otherwise | ||
| 20886 | |||
| 20887 | my ($self, $check) = @_; | ||
| 20888 | |||
| 20889 | # Local variables | ||
| 20890 | my ($tab, $slWidget, $name); | ||
| 20891 | |||
| 20892 | # Check for improper arguments | ||
| 20893 | if (defined $check) { | ||
| 20894 | |||
| 20895 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonAdd_zonemap', @_); | ||
| 20896 | } | ||
| 20897 | |||
| 20898 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 20899 | $tab = $self->notebookGetTab(); | ||
| 20900 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 20901 | |||
| 20902 | # Unselect everything in the list, because we're creating a new zonemap | ||
| 20903 | $slWidget->get_selection->unselect_all(); | ||
| 20904 | |||
| 20905 | # Prompt the user for the name of the zonemap | ||
| 20906 | $name = $self->showEntryDialogue( | ||
| 20907 | 'Add zonemap', | ||
| 20908 | 'Enter a name for the object (max 16 chars: A-Z a-z _ 0-9)', | ||
| 20909 | 16, # Max chars | ||
| 20910 | ); | ||
| 20911 | |||
| 20912 | if ($name) { | ||
| 20913 | |||
| 20914 | # Add the new zonemap | ||
| 20915 | $self->session->pseudoCmd('addzonemap ' . $name, $self->pseudoCmdMode); | ||
| 20916 | |||
| 20917 | # Update the notebook | ||
| 20918 | $self->updateNotebook(); | ||
| 20919 | } | ||
| 20920 | |||
| 20921 | return 1; | ||
| 20922 | } | ||
| 20923 | |||
| 20924 | sub buttonClone_zonemap { | ||
| 20925 | |||
| 20926 | # Callback: Clones the selected zonemap (equivalent to ';clonezonemap') | ||
| 20927 | # | ||
| 20928 | # Expected arguments | ||
| 20929 | # (none besides $self) | ||
| 20930 | # | ||
| 20931 | # Return values | ||
| 20932 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 20933 | # 1 otherwise | ||
| 20934 | |||
| 20935 | my ($self, $check) = @_; | ||
| 20936 | |||
| 20937 | # Local variables | ||
| 20938 | my ( | ||
| 20939 | $dataRef, $name, $cloneName, | ||
| 20940 | @list, @dataList, | ||
| 20941 | ); | ||
| 20942 | |||
| 20943 | # Check for improper arguments | ||
| 20944 | if (defined $check) { | ||
| 20945 | |||
| 20946 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonClone_zonemap', @_); | ||
| 20947 | } | ||
| 20948 | |||
| 20949 | # Import the currently selected portions of the notebook list | ||
| 20950 | @list = $self->notebookGetSelectedData(); | ||
| 20951 | if (! @list) { | ||
| 20952 | |||
| 20953 | # Nothing selected | ||
| 20954 | return undef; | ||
| 20955 | } | ||
| 20956 | |||
| 20957 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 20958 | # a single row of the list | ||
| 20959 | $dataRef = $list[0]; | ||
| 20960 | @dataList = @$dataRef; | ||
| 20961 | # The zonemap object name is the fourth item of data | ||
| 20962 | $name = $dataList[3]; | ||
| 20963 | if (! $name) { | ||
| 20964 | |||
| 20965 | # Can't continue | ||
| 20966 | return undef; | ||
| 20967 | } | ||
| 20968 | |||
| 20969 | # Prompt the user for the name of the clone | ||
| 20970 | $cloneName = $self->showEntryDialogue( | ||
| 20971 | 'Clone zonemap', | ||
| 20972 | 'Enter a name for the clone (max 16 chars: A-Z a-z _ 0-9)', | ||
| 20973 | 16, # Max chars | ||
| 20974 | ); | ||
| 20975 | |||
| 20976 | if ($cloneName) { | ||
| 20977 | |||
| 20978 | # Clone the zonemap | ||
| 20979 | $self->session->pseudoCmd( | ||
| 20980 | 'clonezonemap ' . $name . ' ' . $cloneName, | ||
| 20981 | $self->pseudoCmdMode, | ||
| 20982 | ); | ||
| 20983 | |||
| 20984 | # Update the notebook | ||
| 20985 | $self->updateNotebook(); | ||
| 20986 | } | ||
| 20987 | |||
| 20988 | return 1; | ||
| 20989 | } | ||
| 20990 | |||
| 20991 | sub buttonEdit_zonemap { | ||
| 20992 | |||
| 20993 | # Callback: Edits a zonemap (equivalent to ';editzonemap') | ||
| 20994 | # | ||
| 20995 | # Expected arguments | ||
| 20996 | # (none besides $self) | ||
| 20997 | # | ||
| 20998 | # Return values | ||
| 20999 | # 'undef' on improper arguments, if no line is selected in the notebook or if the selected | ||
| 21000 | # object no longer exists | ||
| 21001 | # 1 otherwise | ||
| 21002 | |||
| 21003 | my ($self, $check) = @_; | ||
| 21004 | |||
| 21005 | # Local variables | ||
| 21006 | my ( | ||
| 21007 | $dataRef, $name, $obj, | ||
| 21008 | @list, @dataList, | ||
| 21009 | ); | ||
| 21010 | |||
| 21011 | # Check for improper arguments | ||
| 21012 | if (defined $check) { | ||
| 21013 | |||
| 21014 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonEdit_zonemap', @_); | ||
| 21015 | } | ||
| 21016 | |||
| 21017 | # Import the currently selected portions of the notebook list | ||
| 21018 | @list = $self->notebookGetSelectedData(); | ||
| 21019 | if (! @list) { | ||
| 21020 | |||
| 21021 | # Nothing selected | ||
| 21022 | return undef; | ||
| 21023 | } | ||
| 21024 | |||
| 21025 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 21026 | # a single row of the list | ||
| 21027 | $dataRef = $list[0]; | ||
| 21028 | @dataList = @$dataRef; | ||
| 21029 | # The zonemap's name is the fourth item of data | ||
| 21030 | $name = $dataList[3]; | ||
| 21031 | if (! $name) { | ||
| 21032 | |||
| 21033 | # Can't continue | ||
| 21034 | return undef; | ||
| 21035 | } | ||
| 21036 | |||
| 21037 | # Get the zonemap itself | ||
| 21038 | $obj = $axmud::CLIENT->ivShow('zonemapHash', $name); | ||
| 21039 | if (! $obj) { | ||
| 21040 | |||
| 21041 | # Can't continue | ||
| 21042 | return undef; | ||
| 21043 | |||
| 21044 | } else { | ||
| 21045 | |||
| 21046 | # Open up an 'edit' window to edit the object | ||
| 21047 | $self->createFreeWin( | ||
| 21048 | 'Games::Axmud::EditWin::Zonemap', | ||
| 21049 | $self, | ||
| 21050 | $self->session, | ||
| 21051 | 'Edit zonemap \'' . $obj->name . '\'', | ||
| 21052 | $obj, | ||
| 21053 | FALSE, # Not temporary | ||
| 21054 | ); | ||
| 21055 | |||
| 21056 | return 1; | ||
| 21057 | } | ||
| 21058 | } | ||
| 21059 | |||
| 21060 | sub buttonDelete_zonemap { | ||
| 21061 | |||
| 21062 | # Callback: Deletes a zonemap (equivalent to ';deletezonemap') | ||
| 21063 | # | ||
| 21064 | # Expected arguments | ||
| 21065 | # (none besides $self) | ||
| 21066 | # | ||
| 21067 | # Return values | ||
| 21068 | # 'undef' on improper arguments or if no line is selected in the notebook | ||
| 21069 | # 1 otherwise | ||
| 21070 | |||
| 21071 | my ($self, $check) = @_; | ||
| 21072 | |||
| 21073 | # Local variables | ||
| 21074 | my ( | ||
| 21075 | $dataRef, $name, | ||
| 21076 | @list, @dataList, | ||
| 21077 | ); | ||
| 21078 | |||
| 21079 | # Check for improper arguments | ||
| 21080 | if (defined $check) { | ||
| 21081 | |||
| 21082 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDelete_zonemap', @_); | ||
| 21083 | } | ||
| 21084 | |||
| 21085 | # Import the currently selected portions of the notebook list | ||
| 21086 | @list = $self->notebookGetSelectedData(); | ||
| 21087 | if (! @list) { | ||
| 21088 | |||
| 21089 | # Nothing selected | ||
| 21090 | return undef; | ||
| 21091 | } | ||
| 21092 | |||
| 21093 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 21094 | # a single row of the list | ||
| 21095 | $dataRef = $list[0]; | ||
| 21096 | @dataList = @$dataRef; | ||
| 21097 | # The zonemap name is the fourth item of data | ||
| 21098 | $name = $dataList[3]; | ||
| 21099 | if (! $name) { | ||
| 21100 | |||
| 21101 | # Can't continue | ||
| 21102 | return undef; | ||
| 21103 | } | ||
| 21104 | |||
| 21105 | # Delete the zonemap | ||
| 21106 | $self->session->pseudoCmd('deletezonemap ' . $name, $self->pseudoCmdMode); | ||
| 21107 | |||
| 21108 | # Update the notebook | ||
| 21109 | $self->updateNotebook(); | ||
| 21110 | |||
| 21111 | return 1; | ||
| 21112 | } | ||
| 21113 | |||
| 21114 | sub buttonDump_zonemap { | ||
| 21115 | |||
| 21116 | # Callback: Displays a list of zonemaps in the 'main' window (equivalent to ';listzonemap') | ||
| 21117 | # | ||
| 21118 | # Expected arguments | ||
| 21119 | # (none besides $self) | ||
| 21120 | # | ||
| 21121 | # Return values | ||
| 21122 | # 'undef' on improper arguments | ||
| 21123 | # 1 otherwise | ||
| 21124 | |||
| 21125 | my ($self, $check) = @_; | ||
| 21126 | |||
| 21127 | # Local variables | ||
| 21128 | my ($tab, $slWidget); | ||
| 21129 | |||
| 21130 | # Check for improper arguments | ||
| 21131 | if (defined $check) { | ||
| 21132 | |||
| 21133 | return $axmud::CLIENT->writeImproper($self->_objClass . '->buttonDump_zonemap', @_); | ||
| 21134 | } | ||
| 21135 | |||
| 21136 | # Get the selected tab, and from there the tab's GA::Obj::SimpleList | ||
| 21137 | $tab = $self->notebookGetTab(); | ||
| 21138 | $slWidget = $self->ivShow('notebookDataHash', $tab); | ||
| 21139 | |||
| 21140 | # Unselect everything in the list | ||
| 21141 | $slWidget->get_selection->unselect_all(); | ||
| 21142 | |||
| 21143 | # Display the list | ||
| 21144 | $self->session->pseudoCmd('listzonemap', $self->pseudoCmdMode); | ||
| 21145 | |||
| 21146 | return 1; | ||
| 21147 | } | ||
| 21148 | |||
| 21149 | # Callback support functions | ||
| 21150 | |||
| 21151 | sub profPriorityData { | ||
| 21152 | |||
| 21153 | # Called by $self->buttonMoveTop_profPriority, $self->buttonMoveUp_profPriority, etc | ||
| 21154 | # Works out which part of the currrent notebook's GA::Obj::SimpleList is selected and | ||
| 21155 | # accesses the data on the selected row | ||
| 21156 | # | ||
| 21157 | # Expected arguments | ||
| 21158 | # (none besides $self) | ||
| 21159 | # | ||
| 21160 | # Return values | ||
| 21161 | # An empty list on improper arguments or if no row is selected | ||
| 21162 | # Otherwise returns a list containing three arguments: | ||
| 21163 | # $count - The position of the category within the current priority list, | ||
| 21164 | # $self->session->profPriorityList (or 'undef' if the category is not | ||
| 21165 | # in the priority list) | ||
| 21166 | # $priority - The priority of the category on the selected line (1+, or '-' for not | ||
| 21167 | # in the priority list) | ||
| 21168 | # $category - The category on the selected line | ||
| 21169 | |||
| 21170 | my ($self, $check) = @_; | ||
| 21171 | |||
| 21172 | # Local variables | ||
| 21173 | my ( | ||
| 21174 | $dataRef, $priority, $category, $count, | ||
| 21175 | @emptyList, @list, @dataList, | ||
| 21176 | ); | ||
| 21177 | |||
| 21178 | # Check for improper arguments | ||
| 21179 | if (defined $check) { | ||
| 21180 | |||
| 21181 | $axmud::CLIENT->writeImproper($self->_objClass . '->profPriorityData', @_); | ||
| 21182 | return @emptyList; | ||
| 21183 | } | ||
| 21184 | |||
| 21185 | # Import the currently selected portions of the notebook list | ||
| 21186 | @list = $self->notebookGetSelectedData(); | ||
| 21187 | if (! @list) { | ||
| 21188 | |||
| 21189 | # Nothing selected | ||
| 21190 | return @emptyList; | ||
| 21191 | } | ||
| 21192 | |||
| 21193 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 21194 | # a single row of the list | ||
| 21195 | $dataRef = $list[0]; | ||
| 21196 | @dataList = @$dataRef; | ||
| 21197 | # The current priority (if any) is the first item of data | ||
| 21198 | $priority = $dataList[0]; | ||
| 21199 | # The selected category is the second item of data | ||
| 21200 | $category = $dataList[1]; | ||
| 21201 | |||
| 21202 | # Can't continue if either is unavailable, or if the selected category isn't on the priority | ||
| 21203 | # list yet (use the 'give priority' button instead) | ||
| 21204 | if (! $priority || ! $category) { | ||
| 21205 | |||
| 21206 | # Can't continue | ||
| 21207 | return @emptyList; | ||
| 21208 | |||
| 21209 | } elsif ($priority eq '-') { | ||
| 21210 | |||
| 21211 | # Category isn't in the current priority list | ||
| 21212 | return (undef, $priority, $category); | ||
| 21213 | } | ||
| 21214 | |||
| 21215 | # Import the priority list; check that $category is somewhere to be found within it | ||
| 21216 | $count = -1; | ||
| 21217 | foreach my $item ($self->session->profPriorityList) { | ||
| 21218 | |||
| 21219 | $count++; | ||
| 21220 | |||
| 21221 | if ($category eq $item) { | ||
| 21222 | |||
| 21223 | return ($count, $priority, $category); | ||
| 21224 | } | ||
| 21225 | } | ||
| 21226 | |||
| 21227 | # Category not found (this shouldn't happen unless the IV has been modified, since the | ||
| 21228 | # window last updated its simple list) | ||
| 21229 | return @emptyList; | ||
| 21230 | } | ||
| 21231 | |||
| 21232 | sub initialTaskData { | ||
| 21233 | |||
| 21234 | # Called by $self->buttonMoveUp_initialTask and $self->buttonMoveUp_profPriority | ||
| 21235 | # Works out which part of the currrent notebook's GA::Obj::SimpleList is selected and | ||
| 21236 | # accesses the data on the selected row | ||
| 21237 | # | ||
| 21238 | # Expected arguments | ||
| 21239 | # (none besides $self) | ||
| 21240 | # | ||
| 21241 | # Return values | ||
| 21242 | # An empty list on improper arguments or if no row is selected | ||
| 21243 | # Otherwise returns a list containing two arguments: | ||
| 21244 | # $count - The position of the category within the current priority list, | ||
| 21245 | # $self->session->profPriorityList (or 'undef' if the category is not | ||
| 21246 | # in the priority list) | ||
| 21247 | # $priority - The priority of the category on the selected line (1+, or '-' for not | ||
| 21248 | # in the priority list) | ||
| 21249 | # $category - The category on the selected line | ||
| 21250 | |||
| 21251 | my ($self, $check) = @_; | ||
| 21252 | |||
| 21253 | # Local variables | ||
| 21254 | my ( | ||
| 21255 | $dataRef, $taskName, $count, | ||
| 21256 | @emptyList, @list, @dataList, | ||
| 21257 | ); | ||
| 21258 | |||
| 21259 | # Check for improper arguments | ||
| 21260 | if (defined $check) { | ||
| 21261 | |||
| 21262 | $axmud::CLIENT->writeImproper($self->_objClass . '->profPriorityData', @_); | ||
| 21263 | return @emptyList; | ||
| 21264 | } | ||
| 21265 | |||
| 21266 | # Import the currently selected portions of the notebook list | ||
| 21267 | @list = $self->notebookGetSelectedData(); | ||
| 21268 | if (! @list) { | ||
| 21269 | |||
| 21270 | # Nothing selected | ||
| 21271 | return @emptyList; | ||
| 21272 | } | ||
| 21273 | |||
| 21274 | # @list is a list of references to anonymous lists; each of these anonymous lists contains | ||
| 21275 | # a single row of the list | ||
| 21276 | $dataRef = $list[0]; | ||
| 21277 | @dataList = @$dataRef; | ||
| 21278 | # The selected initial task is the first item of data | ||
| 21279 | $taskName = $dataList[0]; | ||
| 21280 | if (! defined $taskName) { | ||
| 21281 | |||
| 21282 | return @emptyList; | ||
| 21283 | } | ||
| 21284 | |||
| 21285 | # Import the ordered list of global initial tasks; check that $taskName is somewhere to be | ||
| 21286 | # found within it | ||
| 21287 | $count = -1; | ||
| 21288 | foreach my $item ($axmud::CLIENT->initTaskOrderList) { | ||
| 21289 | |||
| 21290 | $count++; | ||
| 21291 | |||
| 21292 | if ($taskName eq $item) { | ||
| 21293 | |||
| 21294 | return ($count, $taskName); | ||
| 21295 | } | ||
| 21296 | } | ||
| 21297 | |||
| 21298 | # Task not found (this shouldn't happen unless the IV has been modified, since the | ||
| 21299 | # window last updated its simple list) | ||
| 21300 | return @emptyList; | ||
| 21301 | } | ||
| 21302 | |||
| 21303 | ################## | ||
| 21304 | # Accessors - set | ||
| 21305 | |||
| 21306 | ################## | ||
| 21307 | # Accessors - get | ||
| 21308 | |||
| 21309 | sub hPaned | ||
| 21310 | { $_[0]->{hPaned} } | ||
| 21311 | sub treeViewModel | ||
| 21312 | { $_[0]->{treeViewModel} } | ||
| 21313 | sub treeView | ||
| 21314 | { $_[0]->{treeView} } | ||
| 21315 | sub treeViewScroller | ||
| 21316 | { $_[0]->{treeViewScroller} } | ||
| 21317 | sub hPaned2 | ||
| 21318 | { $_[0]->{hPaned2} } | ||
| 21319 | sub notebook | ||
| 21320 | { $_[0]->{notebook} } | ||
| 21321 | sub vBox | ||
| 21322 | { $_[0]->{vBox} } | ||
| 21323 | sub buttonList | ||
| 21324 | { my $self = shift; return @{$self->{buttonList}}; } | ||
| 21325 | |||
| 21326 | sub leftWidth | ||
| 21327 | { $_[0]->{leftWidth} } | ||
| 21328 | sub centreWidth | ||
| 21329 | { $_[0]->{centreWidth} } | ||
| 21330 | sub rightWidth | ||
| 21331 | { $_[0]->{rightWidth} } | ||
| 21332 | |||
| 21333 | sub notebookMode | ||
| 21334 | { $_[0]->{notebookMode} } | ||
| 21335 | sub notebookCurrentHeader | ||
| 21336 | { $_[0]->{notebookCurrentHeader} } | ||
| 21337 | sub notebookSelectRef | ||
| 21338 | { $_[0]->{notebookSelectRef} } | ||
| 21339 | |||
| 21340 | sub headerHash | ||
| 21341 | { my $self = shift; return %{$self->{headerHash}}; } | ||
| 21342 | |||
| 21343 | sub notebookTabList | ||
| 21344 | { my $self = shift; return @{$self->{notebookTabList}}; } | ||
| 21345 | sub notebookTabHash | ||
| 21346 | { my $self = shift; return %{$self->{notebookTabHash}}; } | ||
| 21347 | sub notebookDataHash | ||
| 21348 | { my $self = shift; return %{$self->{notebookDataHash}}; } | ||
| 21349 | |||
| 21350 | sub dummyScriptObj | ||
| 21351 | { $_[0]->{dummyScriptObj} } | ||
| 21352 | } | ||
| 21353 | |||
| 21354 | # Package must return a true value | ||
| 21355 | 1 |