| 1 | # Copyright (C) 2011-2024 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::InterfaceModel::XXX | ||
| 16 | # Code that handles default settings for interfaces (triggers, alias, macros, timers and hooks) | ||
| 17 | |||
| 18 | { package Games::Axmud::InterfaceModel::Trigger; | ||
| 19 | |||
| 20 | use strict; | ||
| 21 | use warnings; | ||
| 22 | # use diagnostics; | ||
| 23 | |||
| 24 | use Glib qw(TRUE FALSE); | ||
| 25 | |||
| 26 | our @ISA = qw(Games::Axmud::Generic::InterfaceModel Games::Axmud); | ||
| 27 | |||
| 28 | ################## | ||
| 29 | # Constructors | ||
| 30 | |||
| 31 | sub new { | ||
| 32 | |||
| 33 | # Creates a new instance of the interface model object for triggers | ||
| 34 | # | ||
| 35 | # Axmud interfaces are triggers, aliases, macros, timers and hooks. Interface models contain | ||
| 36 | # default value for each type of interface. The GA::Client object stores one model | ||
| 37 | # interface object for every type of interface | ||
| 38 | # | ||
| 39 | # Expected arguments | ||
| 40 | # (none besides $self) | ||
| 41 | # | ||
| 42 | # Return values | ||
| 43 | # 'undef' on improper arguments | ||
| 44 | # Blessed reference to the newly-created object on success | ||
| 45 | |||
| 46 | my ($class, $check) = @_; | ||
| 47 | |||
| 48 | # Check for improper arguments | ||
| 49 | if (! defined $class || defined $check) { | ||
| 50 | |||
| 51 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 52 | } | ||
| 53 | |||
| 54 | # Setup | ||
| 55 | my $self = { | ||
| 56 | _objName => 'trigger', | ||
| 57 | _objClass => $class, | ||
| 58 | _parentFile => undef, # No parent file object | ||
| 59 | _parentWorld => undef, # No parent file object | ||
| 60 | _privFlag => TRUE, # All IVs are private | ||
| 61 | |||
| 62 | # Interface category | ||
| 63 | # ------------------ | ||
| 64 | |||
| 65 | category => 'trigger', # Shortcut to $self->_objClass | ||
| 66 | |||
| 67 | # Trigger attributes | ||
| 68 | # ------------------ | ||
| 69 | |||
| 70 | stimulusName => 'pattern', | ||
| 71 | responseName => 'instruction', # Or a pattern/substitution | ||
| 72 | |||
| 73 | # Default values for each trigger attribute | ||
| 74 | optionalAttribHash => { | ||
| 75 | 'ignore_response' => FALSE, | ||
| 76 | 'splitter' => FALSE, | ||
| 77 | 'split_after' => FALSE, | ||
| 78 | 'keep_splitting' => FALSE, | ||
| 79 | 'rewriter' => FALSE, | ||
| 80 | 'rewrite_global' => FALSE, | ||
| 81 | 'ignore_case' => TRUE, | ||
| 82 | 'gag' => FALSE, | ||
| 83 | 'gag_log' => FALSE, | ||
| 84 | 'need_prompt' => FALSE, | ||
| 85 | 'need_login' => FALSE, | ||
| 86 | 'keep_checking' => TRUE, | ||
| 87 | 'default_pane' => TRUE, | ||
| 88 | 'pane_name' => '', | ||
| 89 | 'temporary' => FALSE, | ||
| 90 | 'style_mode' => 0, # 0 - don't apply style | ||
| 91 | # -1 - apply style to whole line | ||
| 92 | # -2 - apply to matched text | ||
| 93 | # 1+ - apply to matched substring | ||
| 94 | 'style_text' => '', # Empty string or standard/xterm/RGB text colour | ||
| 95 | # tag | ||
| 96 | 'style_underlay' => '', # Empty string or standard/xterm/RGB underlay | ||
| 97 | # colour tag | ||
| 98 | 'style_italics' => 0, # 0 (do not change), 1 (yes), 2 (no) | ||
| 99 | 'style_underline' => 0, # 0 (do not change), 1 (yes), 2 (no) | ||
| 100 | 'style_blink_slow' => 0, # 0 (do not change), 1 (yes), 2 (no) | ||
| 101 | 'style_blink_fast' => 0, # 0 (do not change), 1 (yes), 2 (no) | ||
| 102 | 'style_strike' => 0, # 0 (do not change), 1 (yes), 2 (no) | ||
| 103 | 'style_link' => 0, # 0 (do not change), 1 (yes), 2 (no) | ||
| 104 | }, | ||
| 105 | |||
| 106 | # Acceptable values for all attributes (standard interface and trigger) | ||
| 107 | attribTypeHash => { | ||
| 108 | # Standard | ||
| 109 | 'name' => 'string', | ||
| 110 | 'stimulus' => 'pattern', | ||
| 111 | 'response' => 'instruction', # Or a substitution | ||
| 112 | 'enabled' => 'boolean', | ||
| 113 | # Trigger | ||
| 114 | 'ignore_response' => 'boolean', | ||
| 115 | 'splitter' => 'boolean', | ||
| 116 | 'split_after' => 'boolean', | ||
| 117 | 'keep_splitting' => 'boolean', | ||
| 118 | 'rewriter' => 'boolean', | ||
| 119 | 'rewrite_global' => 'boolean', | ||
| 120 | 'ignore_case' => 'boolean', | ||
| 121 | 'gag' => 'boolean', | ||
| 122 | 'gag_log' => 'boolean', | ||
| 123 | 'need_prompt' => 'boolean', | ||
| 124 | 'need_login' => 'boolean', | ||
| 125 | 'keep_checking' => 'boolean', | ||
| 126 | 'default_pane' => 'boolean', | ||
| 127 | 'pane_name' => 'string', | ||
| 128 | 'temporary' => 'boolean', | ||
| 129 | 'cooldown' => 'number', | ||
| 130 | 'style_mode' => 'mode', | ||
| 131 | 'style_text' => 'colour', | ||
| 132 | 'style_underlay' => 'underlay', | ||
| 133 | 'style_italics' => 'style', | ||
| 134 | 'style_underline' => 'style', | ||
| 135 | 'style_blink_slow' => 'style', | ||
| 136 | 'style_blink_fast' => 'style', | ||
| 137 | 'style_strike' => 'style', | ||
| 138 | 'style_link' => 'style', | ||
| 139 | }, | ||
| 140 | |||
| 141 | # Switches used in client commands | ||
| 142 | compulsorySwitchHash => { | ||
| 143 | 'stimulus' => 's', | ||
| 144 | 'response' => 'p', | ||
| 145 | }, | ||
| 146 | |||
| 147 | optionalSwitchHash => { | ||
| 148 | 'name' => 'n', | ||
| 149 | 'enabled' => 'e', | ||
| 150 | 'ignore_response' => 'ir', | ||
| 151 | 'splitter' => 'sp', # Don't like two letters, but run out of letters | ||
| 152 | 'split_after' => 'sa', | ||
| 153 | 'keep_splitting' => 'ks', | ||
| 154 | 'rewriter' => 'rw', | ||
| 155 | 'rewrite_global' => 'rg', | ||
| 156 | 'ignore_case' => 'o', | ||
| 157 | 'gag' => 'a', | ||
| 158 | 'gag_log' => 'l', | ||
| 159 | 'need_prompt' => 'pr', | ||
| 160 | 'need_login' => 'lg', | ||
| 161 | 'keep_checking' => 'k', | ||
| 162 | 'default_pane' => 'dp', | ||
| 163 | 'pane_name' => 'pn', | ||
| 164 | 'temporary' => 't', | ||
| 165 | 'cooldown' => 'cd', | ||
| 166 | 'style_mode' => 'm', | ||
| 167 | 'style_text' => 'h', | ||
| 168 | 'style_underlay' => 'j', | ||
| 169 | 'style_italics' => 'it', | ||
| 170 | 'style_underline' => 'u', | ||
| 171 | 'style_blink_slow' => 'bs', | ||
| 172 | 'style_blink_fast' => 'bf', | ||
| 173 | 'style_strike' => 'q', | ||
| 174 | 'style_link' => 'lk', | ||
| 175 | }, | ||
| 176 | }; | ||
| 177 | |||
| 178 | # Bless the object into existence | ||
| 179 | bless $self, $class; | ||
| 180 | return $self; | ||
| 181 | } | ||
| 182 | |||
| 183 | ################## | ||
| 184 | # Methods | ||
| 185 | |||
| 186 | ################## | ||
| 187 | # Accessors - set | ||
| 188 | |||
| 189 | ################## | ||
| 190 | # Accessors - get | ||
| 191 | } | ||
| 192 | |||
| 193 | { package Games::Axmud::InterfaceModel::Alias; | ||
| 194 | |||
| 195 | use strict; | ||
| 196 | use warnings; | ||
| 197 | # use diagnostics; | ||
| 198 | |||
| 199 | use Glib qw(TRUE FALSE); | ||
| 200 | |||
| 201 | our @ISA = qw(Games::Axmud::Generic::InterfaceModel Games::Axmud); | ||
| 202 | |||
| 203 | ################## | ||
| 204 | # Constructors | ||
| 205 | |||
| 206 | sub new { | ||
| 207 | |||
| 208 | # Creates a new instance of the interface model object for aliases | ||
| 209 | # | ||
| 210 | # Axmud interfaces are triggers, aliases, macros, timers and hooks. Interface models contain | ||
| 211 | # default value for each type of interface. The GA::Client object stores one model | ||
| 212 | # interface object for every type of interface | ||
| 213 | # | ||
| 214 | # Expected arguments | ||
| 215 | # (none besides $self) | ||
| 216 | # | ||
| 217 | # Return values | ||
| 218 | # 'undef' on improper arguments | ||
| 219 | # Blessed reference to the newly-created object on success | ||
| 220 | |||
| 221 | my ($class, $check) = @_; | ||
| 222 | |||
| 223 | # Check for improper arguments | ||
| 224 | if (! defined $class || defined $check) { | ||
| 225 | |||
| 226 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 227 | } | ||
| 228 | |||
| 229 | # Setup | ||
| 230 | my $self = { | ||
| 231 | _objName => 'alias', | ||
| 232 | _objClass => $class, | ||
| 233 | _parentFile => undef, # No parent file object | ||
| 234 | _parentWorld => undef, # No parent file object | ||
| 235 | _privFlag => TRUE, # All IVs are private | ||
| 236 | |||
| 237 | # Interface category | ||
| 238 | # ------------------ | ||
| 239 | |||
| 240 | category => 'alias', # Shortcut to $self->_objClass | ||
| 241 | |||
| 242 | # Alias attributes | ||
| 243 | # ---------------- | ||
| 244 | |||
| 245 | stimulusName => 'pattern', | ||
| 246 | responseName => 'substitution', | ||
| 247 | |||
| 248 | # Default values for each alias attribute | ||
| 249 | optionalAttribHash => { | ||
| 250 | 'ignore_case' => TRUE, | ||
| 251 | 'keep_checking' => FALSE, | ||
| 252 | 'temporary' => FALSE, | ||
| 253 | }, | ||
| 254 | |||
| 255 | # Acceptable values for all attributes (standard interface and alias) | ||
| 256 | attribTypeHash => { | ||
| 257 | # Standard | ||
| 258 | 'name' => 'string', | ||
| 259 | 'stimulus' => 'pattern', | ||
| 260 | 'response' => 'substitution', | ||
| 261 | 'enabled' => 'boolean', | ||
| 262 | # Alias | ||
| 263 | 'ignore_case' => 'boolean', | ||
| 264 | 'keep_checking' => 'boolean', | ||
| 265 | 'temporary' => 'boolean', | ||
| 266 | 'cooldown' => 'number', | ||
| 267 | }, | ||
| 268 | |||
| 269 | # Switches used in client commands | ||
| 270 | compulsorySwitchHash => { | ||
| 271 | 'stimulus' => 's', | ||
| 272 | 'response' => 'p', | ||
| 273 | }, | ||
| 274 | |||
| 275 | optionalSwitchHash => { | ||
| 276 | 'name' => 'n', | ||
| 277 | 'enabled' => 'e', | ||
| 278 | 'ignore_case' => 'o', | ||
| 279 | 'keep_checking' => 'k', | ||
| 280 | 'temporary' => 't', | ||
| 281 | 'cooldown' => 'cd', | ||
| 282 | }, | ||
| 283 | }; | ||
| 284 | |||
| 285 | # Bless the object into existence | ||
| 286 | bless $self, $class; | ||
| 287 | return $self; | ||
| 288 | } | ||
| 289 | |||
| 290 | ################## | ||
| 291 | # Methods | ||
| 292 | |||
| 293 | ################## | ||
| 294 | # Accessors - set | ||
| 295 | |||
| 296 | ################## | ||
| 297 | # Accessors - get | ||
| 298 | } | ||
| 299 | |||
| 300 | { package Games::Axmud::InterfaceModel::Macro; | ||
| 301 | |||
| 302 | use strict; | ||
| 303 | use warnings; | ||
| 304 | # use diagnostics; | ||
| 305 | |||
| 306 | use Glib qw(TRUE FALSE); | ||
| 307 | |||
| 308 | our @ISA = qw(Games::Axmud::Generic::InterfaceModel Games::Axmud); | ||
| 309 | |||
| 310 | ################## | ||
| 311 | # Constructors | ||
| 312 | |||
| 313 | sub new { | ||
| 314 | |||
| 315 | # Creates a new instance of the interface model object for macros | ||
| 316 | # | ||
| 317 | # Axmud interfaces are triggers, aliases, macros, timers and hooks. Interface models contain | ||
| 318 | # default value for each type of interface. The GA::Client object stores one model | ||
| 319 | # interface object for every type of interface | ||
| 320 | # | ||
| 321 | # Expected arguments | ||
| 322 | # (none besides $self) | ||
| 323 | # | ||
| 324 | # Return values | ||
| 325 | # 'undef' on improper arguments | ||
| 326 | # Blessed reference to the newly-created object on success | ||
| 327 | |||
| 328 | my ($class, $check) = @_; | ||
| 329 | |||
| 330 | # Check for improper arguments | ||
| 331 | if (! defined $class || defined $check) { | ||
| 332 | |||
| 333 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 334 | } | ||
| 335 | |||
| 336 | # Setup | ||
| 337 | my $self = { | ||
| 338 | _objName => 'macro', | ||
| 339 | _objClass => $class, | ||
| 340 | _parentFile => undef, # No parent file object | ||
| 341 | _parentWorld => undef, # No parent file object | ||
| 342 | _privFlag => TRUE, # All IVs are private | ||
| 343 | |||
| 344 | # Interface category | ||
| 345 | # ------------------ | ||
| 346 | |||
| 347 | category => 'macro', # Shortcut to $self->_objClass | ||
| 348 | |||
| 349 | # Macro attributes | ||
| 350 | # ---------------- | ||
| 351 | |||
| 352 | stimulusName => 'keycode', | ||
| 353 | responseName => 'instruction', | ||
| 354 | |||
| 355 | # Default values for each macro attribute | ||
| 356 | optionalAttribHash => { | ||
| 357 | 'temporary' => FALSE, | ||
| 358 | }, | ||
| 359 | |||
| 360 | # Acceptable values for all attributes (standard interface and macro) | ||
| 361 | attribTypeHash => { | ||
| 362 | # Standard | ||
| 363 | 'name' => 'string', | ||
| 364 | 'stimulus' => 'keycode', | ||
| 365 | 'response' => 'instruction', | ||
| 366 | 'enabled' => 'boolean', | ||
| 367 | # Macro | ||
| 368 | 'temporary' => 'boolean', | ||
| 369 | 'cooldown' => 'number', | ||
| 370 | }, | ||
| 371 | |||
| 372 | # Switches used in client commands | ||
| 373 | compulsorySwitchHash => { | ||
| 374 | 'stimulus' => 's', | ||
| 375 | 'response' => 'p', | ||
| 376 | }, | ||
| 377 | |||
| 378 | optionalSwitchHash => { | ||
| 379 | 'name' => 'n', | ||
| 380 | 'enabled' => 'e', | ||
| 381 | 'temporary' => 't', | ||
| 382 | 'cooldown' => 'cd', | ||
| 383 | }, | ||
| 384 | }; | ||
| 385 | |||
| 386 | # Bless the object into existence | ||
| 387 | bless $self, $class; | ||
| 388 | return $self; | ||
| 389 | } | ||
| 390 | |||
| 391 | ################## | ||
| 392 | # Methods | ||
| 393 | |||
| 394 | ################## | ||
| 395 | # Accessors - set | ||
| 396 | |||
| 397 | ################## | ||
| 398 | # Accessors - get | ||
| 399 | } | ||
| 400 | |||
| 401 | { package Games::Axmud::InterfaceModel::Timer; | ||
| 402 | |||
| 403 | use strict; | ||
| 404 | use warnings; | ||
| 405 | # use diagnostics; | ||
| 406 | |||
| 407 | use Glib qw(TRUE FALSE); | ||
| 408 | |||
| 409 | our @ISA = qw(Games::Axmud::Generic::InterfaceModel Games::Axmud); | ||
| 410 | |||
| 411 | ################## | ||
| 412 | # Constructors | ||
| 413 | |||
| 414 | sub new { | ||
| 415 | |||
| 416 | # Creates a new instance of the interface model object for timers | ||
| 417 | # | ||
| 418 | # Axmud interfaces are triggers, aliases, macros, timers and hooks. Interface models contain | ||
| 419 | # default value for each type of interface. The GA::Client object stores one model | ||
| 420 | # interface object for every type of interface | ||
| 421 | # | ||
| 422 | # Expected arguments | ||
| 423 | # (none besides $self) | ||
| 424 | # | ||
| 425 | # Return values | ||
| 426 | # 'undef' on improper arguments | ||
| 427 | # Blessed reference to the newly-created object on success | ||
| 428 | |||
| 429 | my ($class, $check) = @_; | ||
| 430 | |||
| 431 | # Check for improper arguments | ||
| 432 | if (! defined $class || defined $check) { | ||
| 433 | |||
| 434 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 435 | } | ||
| 436 | |||
| 437 | # Setup | ||
| 438 | my $self = { | ||
| 439 | _objName => 'timer', | ||
| 440 | _objClass => $class, | ||
| 441 | _parentFile => undef, # No parent file object | ||
| 442 | _parentWorld => undef, # No parent file object | ||
| 443 | _privFlag => TRUE, # All IVs are private | ||
| 444 | |||
| 445 | # Interface category | ||
| 446 | # ------------------ | ||
| 447 | |||
| 448 | category => 'timer', # Shortcut to $self->_objClass | ||
| 449 | |||
| 450 | # Timer attributes | ||
| 451 | # ------------------ | ||
| 452 | |||
| 453 | stimulusName => 'interval', | ||
| 454 | responseName => 'instruction', | ||
| 455 | |||
| 456 | # Default values for each timer attribute | ||
| 457 | optionalAttribHash => { | ||
| 458 | 'count' => -1, | ||
| 459 | 'initial_delay' => 0, | ||
| 460 | 'random_delay' => FALSE, | ||
| 461 | 'random_min' => 0, | ||
| 462 | 'wait_login' => TRUE, | ||
| 463 | 'temporary' => FALSE, | ||
| 464 | }, | ||
| 465 | |||
| 466 | # Acceptable values for all attributes (standard interface and timer) | ||
| 467 | attribTypeHash => { | ||
| 468 | # Standard | ||
| 469 | 'name' => 'string', | ||
| 470 | 'stimulus' => 'interval', # Interval or 24-hour clock time | ||
| 471 | 'response' => 'instruction', # Instruction | ||
| 472 | 'enabled' => 'boolean', | ||
| 473 | # Timer | ||
| 474 | 'count' => 'repeat_count', # -1 or a positive integer | ||
| 475 | 'initial_delay' => 'number', # 0 or a positive number | ||
| 476 | 'random_delay' => 'boolean', | ||
| 477 | 'random_min' => 'number', # 0 or a positive number | ||
| 478 | 'wait_login' => 'boolean', | ||
| 479 | 'temporary' => 'boolean', | ||
| 480 | }, | ||
| 481 | |||
| 482 | # Switches used in client commands | ||
| 483 | compulsorySwitchHash => { | ||
| 484 | 'stimulus' => 's', | ||
| 485 | 'response' => 'p', | ||
| 486 | }, | ||
| 487 | |||
| 488 | optionalSwitchHash => { | ||
| 489 | 'name' => 'n', | ||
| 490 | 'enabled' => 'e', | ||
| 491 | 'count' => 'o', | ||
| 492 | 'initial_delay' => 'i', | ||
| 493 | 'random_delay' => 'r', | ||
| 494 | 'random_min' => 'm', | ||
| 495 | 'wait_login' => 'w', | ||
| 496 | 'temporary' => 't', | ||
| 497 | }, | ||
| 498 | }; | ||
| 499 | |||
| 500 | # Bless the object into existence | ||
| 501 | bless $self, $class; | ||
| 502 | return $self; | ||
| 503 | } | ||
| 504 | |||
| 505 | ################## | ||
| 506 | # Methods | ||
| 507 | |||
| 508 | ################## | ||
| 509 | # Accessors - set | ||
| 510 | |||
| 511 | ################## | ||
| 512 | # Accessors - get | ||
| 513 | } | ||
| 514 | |||
| 515 | { package Games::Axmud::InterfaceModel::Hook; | ||
| 516 | |||
| 517 | use strict; | ||
| 518 | use warnings; | ||
| 519 | # use diagnostics; | ||
| 520 | |||
| 521 | use Glib qw(TRUE FALSE); | ||
| 522 | |||
| 523 | our @ISA = qw(Games::Axmud::Generic::InterfaceModel Games::Axmud); | ||
| 524 | |||
| 525 | ################## | ||
| 526 | # Constructors | ||
| 527 | |||
| 528 | sub new { | ||
| 529 | |||
| 530 | # Creates a new instance of the interface model object for hooks | ||
| 531 | # | ||
| 532 | # Axmud interfaces are triggers, aliases, macros, timers and hooks. Interface models contain | ||
| 533 | # default value for each type of interface. The GA::Client object stores one model | ||
| 534 | # interface object for every type of interface | ||
| 535 | # | ||
| 536 | # Expected arguments | ||
| 537 | # (none besides $self) | ||
| 538 | # | ||
| 539 | # Return values | ||
| 540 | # 'undef' on improper arguments | ||
| 541 | # Blessed reference to the newly-created object on success | ||
| 542 | |||
| 543 | my ($class, $check) = @_; | ||
| 544 | |||
| 545 | # Check for improper arguments | ||
| 546 | if (! defined $class || defined $check) { | ||
| 547 | |||
| 548 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 549 | } | ||
| 550 | |||
| 551 | # Setup | ||
| 552 | my $self = { | ||
| 553 | _objName => 'hook', | ||
| 554 | _objClass => $class, | ||
| 555 | _parentFile => undef, # No parent file object | ||
| 556 | _parentWorld => undef, # No parent file object | ||
| 557 | _privFlag => TRUE, # All IVs are private | ||
| 558 | |||
| 559 | # Interface category | ||
| 560 | # ------------------ | ||
| 561 | |||
| 562 | category => 'hook', # Shortcut to $self->_objClass | ||
| 563 | |||
| 564 | # Hook attributes | ||
| 565 | # --------------- | ||
| 566 | |||
| 567 | stimulusName => 'hook_event', | ||
| 568 | responseName => 'instruction', | ||
| 569 | |||
| 570 | # Default values for each hook attribute | ||
| 571 | optionalAttribHash => { | ||
| 572 | 'temporary' => FALSE, | ||
| 573 | }, | ||
| 574 | |||
| 575 | # Acceptable values for all attributes (standard interface and hook) | ||
| 576 | attribTypeHash => { | ||
| 577 | # Standard | ||
| 578 | 'name' => 'string', | ||
| 579 | 'stimulus' => 'hook_event', | ||
| 580 | 'response' => 'instruction', | ||
| 581 | 'enabled' => 'boolean', | ||
| 582 | # Hook | ||
| 583 | 'temporary' => 'boolean', | ||
| 584 | 'cooldown' => 'number', | ||
| 585 | }, | ||
| 586 | |||
| 587 | # Switches used in client commands | ||
| 588 | compulsorySwitchHash => { | ||
| 589 | 'stimulus' => 's', | ||
| 590 | 'response' => 'p', | ||
| 591 | }, | ||
| 592 | |||
| 593 | optionalSwitchHash => { | ||
| 594 | 'name' => 'n', | ||
| 595 | 'enabled' => 'e', | ||
| 596 | 'temporary' => 't', | ||
| 597 | 'cooldown' => 'cd', | ||
| 598 | }, | ||
| 599 | |||
| 600 | # Standard hook events. The key is the hook event name, the corresponding value is the | ||
| 601 | # number of hook data items to expect | ||
| 602 | # Any hook event not represented in this hash is a custom hook event. To prevent clashes | ||
| 603 | # with future releases, custom hooks must have names beginning with an underline | ||
| 604 | # followed by an alphanumeric character, e.g. '_myevent' | ||
| 605 | hookEventHash => { | ||
| 606 | # Fired by GA::Session->connectionComplete when the first text is received from the | ||
| 607 | # world (meaning we're connected) | ||
| 608 | # (Hook data: none) | ||
| 609 | 'connect' => 0, | ||
| 610 | # Fired by GA::Session->reactDisconnect when we are disconnected from the world | ||
| 611 | # (Hook data: none) | ||
| 612 | 'disconnect' => 0, | ||
| 613 | # Fired by GA::Session->doLogin when the character is marked as 'logged in' | ||
| 614 | # (Hook data: none) | ||
| 615 | 'login' => 0, | ||
| 616 | # Fired by GA::Session->processPrompt when something that looks like a prompt is | ||
| 617 | # received from the world - after waiting a short time, to confirm that the world | ||
| 618 | # isn't about to send the rest of an incomplete line. If the user types a command | ||
| 619 | # in the mean time, the 'prompt' event doesn't fire | ||
| 620 | # (Hook data: the line, stripped of escape sequences) | ||
| 621 | 'prompt' => 1, | ||
| 622 | # Fired by GA::Session->processLineSegment when any text is received | ||
| 623 | # (Hook data: the line, stripped of escape sequences) | ||
| 624 | 'receive_text' => 1, | ||
| 625 | # Fired by GA::Session->worldCmd or ->teleportCmd when an instruction contains a | ||
| 626 | # world command (an instruction like 'open door;n;kill orc' counts as three world | ||
| 627 | # commands, and causes the hook to fire three times. The hook fires BEFORE the | ||
| 628 | # world command is modified by any aliases, etc) | ||
| 629 | # (Hook data: the command being processed) | ||
| 630 | 'sending_cmd' => 1, | ||
| 631 | # Fired by GA::Session->dispatchCmd when a world command is actually sent to the | ||
| 632 | # world, AFTER any aliases (etc) have acted on it | ||
| 633 | # (Hook data: the command to be sent) | ||
| 634 | 'send_cmd' => 1, | ||
| 635 | # Fired by GA::Obj::Textview->showSystemText when a (normal) system message is due | ||
| 636 | # to be displayed | ||
| 637 | # (Hook data: the system message) | ||
| 638 | 'system_text' => 1, | ||
| 639 | # Fired by GA::Obj::Textview->showError when a system error message is due to be | ||
| 640 | # displayed | ||
| 641 | # (Hook data: the system message) | ||
| 642 | 'system_error' => 1, | ||
| 643 | # Fired by GA::Obj::Textview->showWarning when a system warning message is due to be | ||
| 644 | # displayed | ||
| 645 | # (Hook data: the system message) | ||
| 646 | 'system_warning' => 1, | ||
| 647 | # Fired by GA::Obj::Textview->showDebug when a system debug message is due to be | ||
| 648 | # displayed | ||
| 649 | # (Hook data: the system message) | ||
| 650 | 'system_debug' => 1, | ||
| 651 | # Fired by GA::Obj::Textview->showImproper when a system improper arguments | ||
| 652 | # (internal error) message is due to be displayed | ||
| 653 | # (Hook data: the system message) | ||
| 654 | 'system_improper' => 1, | ||
| 655 | # Fired by several functions in GA::Obj::Textview when a system message is due to be | ||
| 656 | # displayed | ||
| 657 | # (Hook data: the system message) | ||
| 658 | 'system_all' => 1, | ||
| 659 | # Fired by several functions in GA::Obj::Textview when a system error, warning, | ||
| 660 | # debug or improper arguments message is due to be displayed | ||
| 661 | # (Hook data: the system message) | ||
| 662 | 'system_all_error' => 1, | ||
| 663 | # Fired by GA::Session->processMsdpData when MSDP data is received (the hook is | ||
| 664 | # fired once for each variable/value pair received) | ||
| 665 | # (Hook data: The variable/value pair received) | ||
| 666 | 'msdp' => 2, | ||
| 667 | # Fired by GA::Session->processMsspData when MSSP data is received (the hook is | ||
| 668 | # fired once for each variable/value pair received) | ||
| 669 | # (Hook data: The variable/value pair received) | ||
| 670 | 'mssp' => 2, | ||
| 671 | # Fired by GA::Session->processZmpData when ZMP data is received (the hook is fired | ||
| 672 | # once for each ZMP packet received) | ||
| 673 | # (Hook data: The name of the ZMP package/command, as a string) | ||
| 674 | 'zmp' => 1, | ||
| 675 | # Fired by GA::Session->processAard102Data when AARD102 status data is received (but | ||
| 676 | # not when AARD102 tags are received; the hook is fired once for every AARD102 | ||
| 677 | # status notification) | ||
| 678 | # (Hook data: The AARD102 status, matching one of the possible values of | ||
| 679 | # GA::Session->aard102Status, or the string 'tick') | ||
| 680 | 'aard102' => 1, | ||
| 681 | # Fired by GA::Session->processAtcpData when ATCP data is received (the hook is | ||
| 682 | # fired once for each ATCP packet received) | ||
| 683 | # (Hook data: The name of the ATCP package received) | ||
| 684 | 'atcp' => 1, | ||
| 685 | # Fired by GA::Session->processGmcpData when GMCP data is received (the hook is | ||
| 686 | # fired once for each GMCP packet received) | ||
| 687 | # (Hook data: The name of the GMCP package received) | ||
| 688 | 'gmcp' => 1, | ||
| 689 | # Fired by GA::Session->processMcpMsg when an MCP message is received (the hook is | ||
| 690 | # fired once for each MCP single-line message, and once for every group of | ||
| 691 | # multiline messages) | ||
| 692 | # (Hook data: The name of the MCP message, as a string) | ||
| 693 | 'mcp' => 1, | ||
| 694 | # Fired by GA::Client->setCurrentSession when the session becomes the one visible | ||
| 695 | # in the 'main' window that has focus) | ||
| 696 | # (Hook data: none) | ||
| 697 | 'current_session' => 0, | ||
| 698 | # Fired by GA::Client->setCurrentSession when a different session becomes the one | ||
| 699 | # visible in the 'main' window that has focus | ||
| 700 | # (Hook data: the new current session's ->number) | ||
| 701 | 'not_current' => 1, | ||
| 702 | # Fired in every session by GA::Client->setCurrentSession when the visible session | ||
| 703 | # in the 'main' window that has focus changes | ||
| 704 | # (Hook data: the new current session's ->number) | ||
| 705 | 'change_session' => 1, | ||
| 706 | # Fired by GA::Win::Internal->setVisibleSession when the session becomes the one | ||
| 707 | # visible in its 'main' window) | ||
| 708 | # (Hook data: none) | ||
| 709 | 'visible_session' => 0, | ||
| 710 | # Fired by GA::Win::Internal->setVisibleSession when a different session becomes the | ||
| 711 | # one visible in the former's 'main' window | ||
| 712 | # (Hook data: the new current session's ->number) | ||
| 713 | 'not_visible' => 1, | ||
| 714 | # Fired in every session by GA::Win::Internal->setVisibleSession when a 'main' | ||
| 715 | # window's visible session changes | ||
| 716 | # (Hook data: the new current session's ->number) | ||
| 717 | 'change_visible' => 1, | ||
| 718 | # Fired by GA::Session->textViewSizeUpdate when a textview object is resized | ||
| 719 | # (including when its scrollbars are made visible or invisible) | ||
| 720 | # (Hook data: the textview object's number, GA::Obj::TextView->number) | ||
| 721 | 'textview_resize' => 1, | ||
| 722 | # Fired by GA::Session->spinTimerLoop when the user has been idle for 60 seconds | ||
| 723 | # (and no world commands have been sent) | ||
| 724 | # (Hook data: GA::Session->lastCmdTime, the time at which the last command was sent) | ||
| 725 | 'user_idle' => 1, | ||
| 726 | # Fired by GA::Session->spinTimerLoop when no text has been received from the world | ||
| 727 | # world for 60 seconds | ||
| 728 | # (Hook data: GA::Session->lastDisplayTime, the time at which the last text was | ||
| 729 | # received) | ||
| 730 | 'world_idle' => 1, | ||
| 731 | # Fired by ->signal_connect in GA::Win::Internal->setFocusInEvent when the | ||
| 732 | # 'internal' window gets focus | ||
| 733 | # (Hook data: none) | ||
| 734 | 'get_focus' => 0, | ||
| 735 | # Fired by ->signal_connect in GA::Win::Internal->setFocusOutEvent when the | ||
| 736 | # 'internal' window gets focus | ||
| 737 | # (Hook data: none) | ||
| 738 | 'lose_focus' => 0, | ||
| 739 | # Fired by GA::Client->stop when the client stops executing | ||
| 740 | # (Hook data: none) | ||
| 741 | 'close_disconnect' => 0, | ||
| 742 | # Fired by GA::Obj::Map->setCurrentRoom when the automapper's current room is set | ||
| 743 | # (Hook data: the current room's number) | ||
| 744 | 'map_room' => 1, | ||
| 745 | # Fired by GA::Obj::Map->setCurrentRoom when the automapper's current room is reset | ||
| 746 | # (does fire when the Locator task resets) | ||
| 747 | # (Hook data: the previous current room's number, or 0 if not known) | ||
| 748 | 'map_no_room' => 1, | ||
| 749 | # Fired by GA::Obj::Map->setCurrentRoom when the automapper's current room is reset | ||
| 750 | # (doesn't fire when the Locator task resets) | ||
| 751 | # (Hook data: the previous current room's number, or 0 if not known) | ||
| 752 | 'map_lost' => 1, | ||
| 753 | # Fired by GA::Obj::Map->setCurrentRoom when auto-rescue mode is activated | ||
| 754 | # (Hook data: the name of the temporary region created) | ||
| 755 | 'map_rescue_on' => 1, | ||
| 756 | # Fired by GA::Obj::Map->reset_rescueCheckFlag during auto-rescue mode when a merge | ||
| 757 | # operation takes place (i.e. the rescue was successful) | ||
| 758 | # (Hook data: none) | ||
| 759 | 'map_rescue_merge' => 0, | ||
| 760 | # Fired by GA::Obj::Map->reset_rescueRegion when auto-rescue mode is disactivated | ||
| 761 | # (regardless of whether the rescue was successful or not) | ||
| 762 | # (Hook data: none) | ||
| 763 | 'map_rescue_off' => 0, | ||
| 764 | }, | ||
| 765 | }; | ||
| 766 | |||
| 767 | # Bless the object into existence | ||
| 768 | bless $self, $class; | ||
| 769 | return $self; | ||
| 770 | } | ||
| 771 | |||
| 772 | ################## | ||
| 773 | # Methods | ||
| 774 | |||
| 775 | ################## | ||
| 776 | # Accessors - set | ||
| 777 | |||
| 778 | ################## | ||
| 779 | # Accessors - get | ||
| 780 | |||
| 781 | sub hookEventHash | ||
| 782 | { my $self = shift; return %{$self->{hookEventHash}}; } | ||
| 783 | } | ||
| 784 | |||
| 785 | # Package must return a true value | ||
| 786 | 1 |