@@ -3,113 +3,113 @@ |
||
| 3 | 3 | /// @brief Superclass for all SpriteFile types |
| 4 | 4 | abstract class SpriteFile { |
| 5 | 5 | |
| 6 | - /// @cond INTERNAL_DOCS |
|
| 6 | + /// @cond INTERNAL_DOCS |
|
| 7 | 7 | |
| 8 | - private $frames = array(); |
|
| 9 | - private $spritefiletype; |
|
| 10 | - /// @endcond |
|
| 8 | + private $frames = array(); |
|
| 9 | + private $spritefiletype; |
|
| 10 | + /// @endcond |
|
| 11 | 11 | |
| 12 | - /// @cond INTERNAL_DOCS |
|
| 12 | + /// @cond INTERNAL_DOCS |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * @param string $filetype |
|
| 16 | - */ |
|
| 17 | - public function SpriteFile($filetype) { |
|
| 14 | + /** |
|
| 15 | + * @param string $filetype |
|
| 16 | + */ |
|
| 17 | + public function SpriteFile($filetype) { |
|
| 18 | 18 | $this->spritefiletype = $filetype; |
| 19 | - } |
|
| 20 | - /// @endcond |
|
| 19 | + } |
|
| 20 | + /// @endcond |
|
| 21 | 21 | |
| 22 | - /// @brief Gets a SpriteFrame from the SpriteFile. |
|
| 23 | - /** |
|
| 24 | - * @param $frame The 0-based index of the frame to get. |
|
| 25 | - * @return A SpriteFrame |
|
| 26 | - */ |
|
| 27 | - public function GetFrame($frame) { |
|
| 28 | - return $this->frames[$frame]; |
|
| 29 | - } |
|
| 30 | - /// @brief Gets the entire frame array. |
|
| 31 | - /** |
|
| 32 | - * @return An array of SpriteFrames |
|
| 33 | - */ |
|
| 34 | - public function GetFrames() { |
|
| 35 | - return $this->frames; |
|
| 36 | - } |
|
| 22 | + /// @brief Gets a SpriteFrame from the SpriteFile. |
|
| 23 | + /** |
|
| 24 | + * @param $frame The 0-based index of the frame to get. |
|
| 25 | + * @return A SpriteFrame |
|
| 26 | + */ |
|
| 27 | + public function GetFrame($frame) { |
|
| 28 | + return $this->frames[$frame]; |
|
| 29 | + } |
|
| 30 | + /// @brief Gets the entire frame array. |
|
| 31 | + /** |
|
| 32 | + * @return An array of SpriteFrames |
|
| 33 | + */ |
|
| 34 | + public function GetFrames() { |
|
| 35 | + return $this->frames; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /// @brief Compiles the SpriteFile into a binary string |
|
| 39 | - /** |
|
| 40 | - * @return A binary string containing the SpriteFile's data and frames. |
|
| 41 | - */ |
|
| 42 | - public abstract function Compile(); |
|
| 38 | + /// @brief Compiles the SpriteFile into a binary string |
|
| 39 | + /** |
|
| 40 | + * @return A binary string containing the SpriteFile's data and frames. |
|
| 41 | + */ |
|
| 42 | + public abstract function Compile(); |
|
| 43 | 43 | |
| 44 | - /// @brief Adds a SpriteFrame to the SpriteFile |
|
| 45 | - /** |
|
| 46 | - * If necessary, this function converts the SpriteFrame to the |
|
| 47 | - * correct format. |
|
| 48 | - * At the moment, this can only add a SpriteFrame to the end of the |
|
| 49 | - * SpriteFile. TODO: I aim to fix this by the CCSF 2011. |
|
| 50 | - * @internal |
|
| 51 | - * This process uses some magic which require all types of |
|
| 52 | - * SpriteFile and SpriteFrame to use 3-character identifiers. |
|
| 53 | - * This means that if you want to make your own sprite formats |
|
| 54 | - * you'll need to override this function and provide all our magic |
|
| 55 | - * plus your own. |
|
| 56 | - * @endinternal |
|
| 57 | - * @param $frame A SpriteFrame |
|
| 58 | - * @param $position Where to put the frame. Currently un-used. |
|
| 59 | - */ |
|
| 60 | - public function AddFrame(SpriteFrame $frame, $position = false) { |
|
| 61 | - /* |
|
| 44 | + /// @brief Adds a SpriteFrame to the SpriteFile |
|
| 45 | + /** |
|
| 46 | + * If necessary, this function converts the SpriteFrame to the |
|
| 47 | + * correct format. |
|
| 48 | + * At the moment, this can only add a SpriteFrame to the end of the |
|
| 49 | + * SpriteFile. TODO: I aim to fix this by the CCSF 2011. |
|
| 50 | + * @internal |
|
| 51 | + * This process uses some magic which require all types of |
|
| 52 | + * SpriteFile and SpriteFrame to use 3-character identifiers. |
|
| 53 | + * This means that if you want to make your own sprite formats |
|
| 54 | + * you'll need to override this function and provide all our magic |
|
| 55 | + * plus your own. |
|
| 56 | + * @endinternal |
|
| 57 | + * @param $frame A SpriteFrame |
|
| 58 | + * @param $position Where to put the frame. Currently un-used. |
|
| 59 | + */ |
|
| 60 | + public function AddFrame(SpriteFrame $frame, $position = false) { |
|
| 61 | + /* |
|
| 62 | 62 | if($position === false) { |
| 63 | 63 | $position = sizeof($this->frames); |
| 64 | 64 | } else if($position < 0) { |
| 65 | 65 | $position = sizeof($this->frames) - $position; |
| 66 | 66 | } |
| 67 | 67 | */ |
| 68 | - if ($this->spritefiletype == substr(get_class($frame), 0, 3)) { |
|
| 69 | - //$this->frames[$position] = $frame; |
|
| 70 | - $this->frames[] = $frame; |
|
| 71 | - } else { |
|
| 72 | - //$this->frames[$position] = $frame->ToSpriteFrame($this->spritefiletype); |
|
| 73 | - $this->frames[] = $frame->ToSpriteFrame($this->spritefiletype); |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - /// @brief Replaces a frame in the SpriteFile |
|
| 77 | - /** |
|
| 78 | - * Replaces the frame in the given position |
|
| 79 | - * Uses the same magic as AddFrame |
|
| 80 | - * @param $frame A SpriteFrame of any type. |
|
| 81 | - * @param $position Which frame to replace. If negative, counts |
|
| 82 | - * backwards from the end of the frames array. |
|
| 83 | - */ |
|
| 84 | - public function ReplaceFrame(SpriteFrame $frame, $position) { |
|
| 85 | - if ($position < 0) { |
|
| 86 | - $position = sizeof($this->frames)-$position; |
|
| 87 | - } |
|
| 88 | - $this->frames[$position] = $frame->ToSpriteFrame($this->spritefiletype); |
|
| 89 | - } |
|
| 90 | - /// @brief Gets the number of frames currently stored in this SpriteFile. |
|
| 91 | - /** |
|
| 92 | - * @return The number of frames |
|
| 93 | - */ |
|
| 94 | - public function GetFrameCount() { |
|
| 95 | - return sizeof($this->frames); |
|
| 96 | - } |
|
| 97 | - /// @brief Deletes the frame in the given position. |
|
| 98 | - /** |
|
| 99 | - * @param $frame The 0-based index of the frame to delete. |
|
| 100 | - */ |
|
| 101 | - public function DeleteFrame($frame) { |
|
| 102 | - unset($this->frames[$frame]); |
|
| 103 | - } |
|
| 104 | - /// @brief Converts the given frame to PNG. <strong>Deprecated.</strong> |
|
| 105 | - /** |
|
| 106 | - * May be removed in a future release. |
|
| 107 | - * Use GetFrame($frame)->ToPNG() instead. |
|
| 108 | - * @param integer $frame The 0-based index of the frame to delete. |
|
| 109 | - * @return A binary string containing a PNG. |
|
| 110 | - */ |
|
| 111 | - public function ToPNG($frame) { |
|
| 112 | - return $this->frames[$frame]->ToPNG(); |
|
| 113 | - } |
|
| 68 | + if ($this->spritefiletype == substr(get_class($frame), 0, 3)) { |
|
| 69 | + //$this->frames[$position] = $frame; |
|
| 70 | + $this->frames[] = $frame; |
|
| 71 | + } else { |
|
| 72 | + //$this->frames[$position] = $frame->ToSpriteFrame($this->spritefiletype); |
|
| 73 | + $this->frames[] = $frame->ToSpriteFrame($this->spritefiletype); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + /// @brief Replaces a frame in the SpriteFile |
|
| 77 | + /** |
|
| 78 | + * Replaces the frame in the given position |
|
| 79 | + * Uses the same magic as AddFrame |
|
| 80 | + * @param $frame A SpriteFrame of any type. |
|
| 81 | + * @param $position Which frame to replace. If negative, counts |
|
| 82 | + * backwards from the end of the frames array. |
|
| 83 | + */ |
|
| 84 | + public function ReplaceFrame(SpriteFrame $frame, $position) { |
|
| 85 | + if ($position < 0) { |
|
| 86 | + $position = sizeof($this->frames)-$position; |
|
| 87 | + } |
|
| 88 | + $this->frames[$position] = $frame->ToSpriteFrame($this->spritefiletype); |
|
| 89 | + } |
|
| 90 | + /// @brief Gets the number of frames currently stored in this SpriteFile. |
|
| 91 | + /** |
|
| 92 | + * @return The number of frames |
|
| 93 | + */ |
|
| 94 | + public function GetFrameCount() { |
|
| 95 | + return sizeof($this->frames); |
|
| 96 | + } |
|
| 97 | + /// @brief Deletes the frame in the given position. |
|
| 98 | + /** |
|
| 99 | + * @param $frame The 0-based index of the frame to delete. |
|
| 100 | + */ |
|
| 101 | + public function DeleteFrame($frame) { |
|
| 102 | + unset($this->frames[$frame]); |
|
| 103 | + } |
|
| 104 | + /// @brief Converts the given frame to PNG. <strong>Deprecated.</strong> |
|
| 105 | + /** |
|
| 106 | + * May be removed in a future release. |
|
| 107 | + * Use GetFrame($frame)->ToPNG() instead. |
|
| 108 | + * @param integer $frame The 0-based index of the frame to delete. |
|
| 109 | + * @return A binary string containing a PNG. |
|
| 110 | + */ |
|
| 111 | + public function ToPNG($frame) { |
|
| 112 | + return $this->frames[$frame]->ToPNG(); |
|
| 113 | + } |
|
| 114 | 114 | } |
| 115 | 115 | ?> |
@@ -13,14 +13,14 @@ |
||
| 13 | 13 | /** |
| 14 | 14 | * If $prayfile is not null, all the data for this block |
| 15 | 15 | * will be read from the PRAYFile. |
| 16 | - * @param PRAYFile $prayfile The PRAYFile that this DFAM block belongs to. |
|
| 17 | - * @param $name The block's name. |
|
| 18 | - * @param $content The binary data of this block. May be null. |
|
| 19 | - * @param $flags The block's flags |
|
| 20 | - */ |
|
| 21 | - public function DFAMBlock($prayfile, $name, $content, $flags) { |
|
| 22 | - parent::TagBlock($prayfile, $name, $content, $flags, PRAY_BLOCK_DFAM); |
|
| 16 | + * @param PRAYFile $prayfile The PRAYFile that this DFAM block belongs to. |
|
| 17 | + * @param $name The block's name. |
|
| 18 | + * @param $content The binary data of this block. May be null. |
|
| 19 | + * @param $flags The block's flags |
|
| 20 | + */ |
|
| 21 | + public function DFAMBlock($prayfile, $name, $content, $flags) { |
|
| 22 | + parent::TagBlock($prayfile, $name, $content, $flags, PRAY_BLOCK_DFAM); |
|
| 23 | 23 | |
| 24 | - } |
|
| 24 | + } |
|
| 25 | 25 | } |
| 26 | 26 | ?> |
@@ -22,17 +22,17 @@ |
||
| 22 | 22 | * @param $name The block's name. |
| 23 | 23 | * @param $content The content of the block as a binary string. |
| 24 | 24 | */ |
| 25 | - public function BinaryBlock($type, $name, $content) { |
|
| 26 | - parent::PrayBlock(null, $name, '', 0, $type); |
|
| 27 | - $this->binarydata = $content; |
|
| 25 | + public function BinaryBlock($type, $name, $content) { |
|
| 26 | + parent::PrayBlock(null, $name, '', 0, $type); |
|
| 27 | + $this->binarydata = $content; |
|
| 28 | 28 | } |
| 29 | 29 | /// @brief Compile the BinaryBlock |
| 30 | 30 | /** |
| 31 | 31 | * @return string compiled BinaryBlock as a binary string. |
| 32 | 32 | */ |
| 33 | - public function Compile() { |
|
| 34 | - return $this->EncodeBlockHeader(strlen($this->binarydata)).$this->binarydata; |
|
| 35 | - } |
|
| 33 | + public function Compile() { |
|
| 34 | + return $this->EncodeBlockHeader(strlen($this->binarydata)).$this->binarydata; |
|
| 35 | + } |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | ?> |
@@ -10,18 +10,18 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class SFAMBlock extends EXPCBlock { |
| 12 | 12 | |
| 13 | - /// @brief Instantiates a new SFAMBlock |
|
| 13 | + /// @brief Instantiates a new SFAMBlock |
|
| 14 | 14 | /** |
| 15 | 15 | * If $prayfile is not null, all the data for this block |
| 16 | 16 | * will be read from the PRAYFile. |
| 17 | - * @param PRAYFile $prayfile The PRAYFile that this DFAM block belongs to. |
|
| 18 | - * @param $name The block's name. |
|
| 19 | - * @param $content The binary data of this block. May be null. |
|
| 20 | - * @param $flags The block's flags |
|
| 21 | - */ |
|
| 22 | - public function SFAMBlock($prayfile, $name, $content, $flags) { |
|
| 23 | - parent::TagBlock($prayfile, $name, $content, $flags, PRAY_BLOCK_SFAM); |
|
| 17 | + * @param PRAYFile $prayfile The PRAYFile that this DFAM block belongs to. |
|
| 18 | + * @param $name The block's name. |
|
| 19 | + * @param $content The binary data of this block. May be null. |
|
| 20 | + * @param $flags The block's flags |
|
| 21 | + */ |
|
| 22 | + public function SFAMBlock($prayfile, $name, $content, $flags) { |
|
| 23 | + parent::TagBlock($prayfile, $name, $content, $flags, PRAY_BLOCK_SFAM); |
|
| 24 | 24 | |
| 25 | - } |
|
| 25 | + } |
|
| 26 | 26 | } |
| 27 | 27 | ?> |
@@ -6,38 +6,38 @@ |
||
| 6 | 6 | |
| 7 | 7 | /// @cond INTERNAL_DOCS |
| 8 | 8 | // |
| 9 | - private $fileType; |
|
| 10 | - private $fileName; |
|
| 9 | + private $fileType; |
|
| 10 | + private $fileName; |
|
| 11 | 11 | |
| 12 | - private $reserved; |
|
| 12 | + private $reserved; |
|
| 13 | 13 | private $contents; |
| 14 | 14 | |
| 15 | 15 | /// @endcond |
| 16 | 16 | |
| 17 | - /// @brief Constructs a new COBFileBlock |
|
| 17 | + /// @brief Constructs a new COBFileBlock |
|
| 18 | 18 | /** |
| 19 | 19 | * @param string $type The file type |
| 20 | - * @param $name The file name (including extension) |
|
| 21 | - * @param $contents The contents of the file |
|
| 22 | - */ |
|
| 23 | - public function COBFileBlock($type, $name, $contents) { |
|
| 24 | - parent::COBBlock(COB_BLOCK_FILE); |
|
| 25 | - $this->fileType = $type; |
|
| 26 | - $this->fileName = $name; |
|
| 27 | - $this->contents = $contents; |
|
| 20 | + * @param $name The file name (including extension) |
|
| 21 | + * @param $contents The contents of the file |
|
| 22 | + */ |
|
| 23 | + public function COBFileBlock($type, $name, $contents) { |
|
| 24 | + parent::COBBlock(COB_BLOCK_FILE); |
|
| 25 | + $this->fileType = $type; |
|
| 26 | + $this->fileName = $name; |
|
| 27 | + $this->contents = $contents; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - /// @brief Add the reserved data associated with this file block |
|
| 30 | + /// @brief Add the reserved data associated with this file block |
|
| 31 | 31 | /** |
| 32 | 32 | * @param $reserved The reserved data |
| 33 | - */ |
|
| 34 | - public function AddReserved($reserved) { |
|
| 35 | - $this->reserved = $reserved; |
|
| 33 | + */ |
|
| 34 | + public function AddReserved($reserved) { |
|
| 35 | + $this->reserved = $reserved; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /// @brief Get the name of the file |
| 39 | - public function GetName() { |
|
| 40 | - return $this->fileName; |
|
| 39 | + public function GetName() { |
|
| 40 | + return $this->fileName; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /// @brief Get the file's type |