| 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::Pueblo::xxx | ||
| 16 | # Objects for use during Pueblo-enabled sessions | ||
| 17 | |||
| 18 | { package Games::Axmud::Pueblo::List; | ||
| 19 | |||
| 20 | use strict; | ||
| 21 | use warnings; | ||
| 22 | # use diagnostics; | ||
| 23 | |||
| 24 | use Glib qw(TRUE FALSE); | ||
| 25 | |||
| 26 | our @ISA = qw(Games::Axmud); | ||
| 27 | |||
| 28 | ################## | ||
| 29 | # Constructors | ||
| 30 | |||
| 31 | sub new { | ||
| 32 | |||
| 33 | # Called by GA::Session->processPuebloListElement | ||
| 34 | # Creates a new instance of the Pueblo list object (which stores details for the current | ||
| 35 | # ordered or unordered list) | ||
| 36 | # | ||
| 37 | # Expected arguments | ||
| 38 | # $session - The GA::Session which called this function (not stored as an IV) | ||
| 39 | # $listType - The type of list: 'ul' for an ordered list, 'ol' for an unordered list | ||
| 40 | # | ||
| 41 | # Return values | ||
| 42 | # 'undef' on improper arguments | ||
| 43 | # Blessed reference to the newly-created object on success | ||
| 44 | |||
| 45 | my ($class, $session, $listType, $check) = @_; | ||
| 46 | |||
| 47 | # Check for improper arguments | ||
| 48 | if (! defined $class || ! defined $session || ! defined $listType || defined $check) { | ||
| 49 | |||
| 50 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 51 | } | ||
| 52 | |||
| 53 | # Setup | ||
| 54 | my $self = { | ||
| 55 | _objName => $listType, | ||
| 56 | _objClass => $class, | ||
| 57 | _parentFile => $session->currentWorld->name, | ||
| 58 | _parentWorld => undef, | ||
| 59 | _privFlag => FALSE, # All IVs are public | ||
| 60 | |||
| 61 | # IVs | ||
| 62 | # --- | ||
| 63 | |||
| 64 | # The type of list: 'ul' for an ordered list, 'ol' for an unordered list | ||
| 65 | listType => $listType, | ||
| 66 | |||
| 67 | # For unordered lists, the bullet type: 'disc', 'circle' or 'square' ('disc' and | ||
| 68 | # 'circle' are the same'). 'undef' for ordered lists | ||
| 69 | bulletType => 'disc', | ||
| 70 | # For ordered lists, the item type, specifying how list items should be marked: 'A' for | ||
| 71 | # capital letters (A, B, C...), 'a' for small letters (a, b, c...), 'I' for large | ||
| 72 | # Roman numerals (I, II, III), 'i' for small Roman numerals (i, ii, iii), '1' for | ||
| 73 | # default numbers | ||
| 74 | itemType => 1, | ||
| 75 | # The number in the list of the next list item to add to it. The first list item added | ||
| 76 | # is 1, unless a different starting number is specified by the <OL> tag | ||
| 77 | # (Only used in ordered lists) | ||
| 78 | itemCount => 1, | ||
| 79 | }; | ||
| 80 | |||
| 81 | # Bless the object into existence | ||
| 82 | bless $self, $class; | ||
| 83 | return $self; | ||
| 84 | } | ||
| 85 | |||
| 86 | ################## | ||
| 87 | # Methods | ||
| 88 | |||
| 89 | ################## | ||
| 90 | # Accessors - set | ||
| 91 | |||
| 92 | ################## | ||
| 93 | # Accessors - get | ||
| 94 | |||
| 95 | sub listType | ||
| 96 | { $_[0]->{listType} } | ||
| 97 | |||
| 98 | sub bulletType | ||
| 99 | { $_[0]->{bulletType} } | ||
| 100 | sub itemType | ||
| 101 | { $_[0]->{itemType} } | ||
| 102 | sub itemCount | ||
| 103 | { $_[0]->{itemCount} } | ||
| 104 | } | ||
| 105 | |||
| 106 | # Package must return a true value | ||
| 107 | 1 |