| 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::Obj::GridColour | ||
| 16 | # Object for storing details about a rectangular area of the automapper window's background map, | ||
| 17 | # and the colour it uses (useful for representing map features that aren't actually accessible to | ||
| 18 | # the player, such as rivers and mountain ranges) | ||
| 19 | |||
| 20 | { package Games::Axmud::Obj::GridColour; | ||
| 21 | |||
| 22 | use strict; | ||
| 23 | use warnings; | ||
| 24 | # use diagnostics; | ||
| 25 | |||
| 26 | use Glib qw(TRUE FALSE); | ||
| 27 | |||
| 28 | our @ISA = qw(Games::Axmud); | ||
| 29 | |||
| 30 | ################## | ||
| 31 | # Constructors | ||
| 32 | |||
| 33 | sub new { | ||
| 34 | |||
| 35 | # Called by GA::Obj::Regionmap->storeRect | ||
| 36 | # Creates a new instance of the grid colour object destination object (which stores details | ||
| 37 | # about a rectangular area of the automapper window's background map and the colour it | ||
| 38 | # uses; useful for representing map features that aren't actually accessible to the | ||
| 39 | # player, such as rivers and mountain ranges) | ||
| 40 | # | ||
| 41 | # Expected arguments | ||
| 42 | # $session - The GA::Session which called this function (not stored as an IV) | ||
| 43 | # $number - Unique number for this workspace object | ||
| 44 | # $colour - The colour to use; an RGB colour tag like '#ABCDEF' (case-insensitive) | ||
| 45 | # $x1, $y1 - Coordinates on the parent regionmap's grid, representing the top-left | ||
| 46 | # corner of the rectangle | ||
| 47 | # $x2, $y2 - Coordinates on the parent regionmap's grid, representing the bottom-right | ||
| 48 | # corner of the rectangle | ||
| 49 | # | ||
| 50 | # Optional arguments | ||
| 51 | # $level - The level (i.e., the z-coordinate), corresponding to the parent | ||
| 52 | # regionmap's ->currentLevel. If 'undef', the rectangle is drawn on every | ||
| 53 | # level | ||
| 54 | # | ||
| 55 | # Return values | ||
| 56 | # 'undef' on improper arguments | ||
| 57 | # Blessed reference to the newly-created object on success | ||
| 58 | |||
| 59 | my ($class, $session, $number, $colour, $x1, $y1, $x2, $y2, $level, $check) = @_; | ||
| 60 | |||
| 61 | # Check for improper arguments | ||
| 62 | if ( | ||
| 63 | ! defined $class || ! defined $session || ! defined $number || ! defined $colour | ||
| 64 | || ! defined $x1 || ! defined $y1 || ! defined $x2 || ! defined $y2 || defined $check | ||
| 65 | ) { | ||
| 66 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 67 | } | ||
| 68 | |||
| 69 | # Setup | ||
| 70 | my $self = { | ||
| 71 | _objName => $number, | ||
| 72 | _objClass => $class, | ||
| 73 | _parentFile => 'worldmodel', | ||
| 74 | _parentWorld => $session->currentWorld->name, | ||
| 75 | _privFlag => FALSE, # All IVs are public | ||
| 76 | |||
| 77 | # IVs | ||
| 78 | # --- | ||
| 79 | |||
| 80 | # Unique number for this workspace object | ||
| 81 | number => $number, | ||
| 82 | # The colour to use; an RGB colour tag like '#ABCDEF' (case-insensitive) | ||
| 83 | colour => $colour, | ||
| 84 | # Coordinates on the parent regionmap's grid, representing the top-left corner of the | ||
| 85 | # rectangle | ||
| 86 | x1 => $x1, | ||
| 87 | y1 => $y1, | ||
| 88 | # Coordinates on the parent regionmap's grid, representing the bottom-right corner of | ||
| 89 | # the rectangle | ||
| 90 | x2 => $x2, | ||
| 91 | y2 => $y2, | ||
| 92 | # The level (i.e., the z-coordinate), corresponding to the parent regionmap's | ||
| 93 | # ->currentLevel. If 'undef', the rectangle is drawn on every level | ||
| 94 | level => $level, | ||
| 95 | }; | ||
| 96 | |||
| 97 | # Bless the object into existence | ||
| 98 | bless $self, $class; | ||
| 99 | return $self; | ||
| 100 | } | ||
| 101 | |||
| 102 | ################## | ||
| 103 | # Methods | ||
| 104 | |||
| 105 | ################## | ||
| 106 | # Accessors - set | ||
| 107 | |||
| 108 | ################## | ||
| 109 | # Accessors - get | ||
| 110 | |||
| 111 | sub number | ||
| 112 | { $_[0]->{number} } | ||
| 113 | sub colour | ||
| 114 | { $_[0]->{colour} } | ||
| 115 | sub x1 | ||
| 116 | { $_[0]->{x1} } | ||
| 117 | sub y1 | ||
| 118 | { $_[0]->{y1} } | ||
| 119 | sub x2 | ||
| 120 | { $_[0]->{x2} } | ||
| 121 | sub y2 | ||
| 122 | { $_[0]->{y2} } | ||
| 123 | sub level | ||
| 124 | { $_[0]->{level} } | ||
| 125 | } | ||
| 126 | |||
| 127 | # Package must return a true value | ||
| 128 | 1 |