@@ -89,8 +89,7 @@ |
||
89 | 89 | $red = ($pixel & 0xF800) >> 8; |
90 | 90 | $green = ($pixel & 0x07E0) >> 3; |
91 | 91 | $blue = ($pixel & 0x001F) << 3; |
92 | - } |
|
93 | - else if ($this->encoding == "555") |
|
92 | + } else if ($this->encoding == "555") |
|
94 | 93 | { |
95 | 94 | $red = ($pixel & 0x7C00) >> 7; |
96 | 95 | $green = ($pixel & 0x03E0) >> 2; |
@@ -75,10 +75,11 @@ discard block |
||
75 | 75 | for ($x = 0; $x < $this->GetWidth();) |
76 | 76 | { |
77 | 77 | $run = $this->reader->ReadInt(2); |
78 | - if (($run & 0x0001) > 0) |
|
79 | - $run_type = "colour"; |
|
80 | - else |
|
81 | - $run_type = "black"; |
|
78 | + if (($run & 0x0001) > 0) { |
|
79 | + $run_type = "colour"; |
|
80 | + } else { |
|
81 | + $run_type = "black"; |
|
82 | + } |
|
82 | 83 | $run_length = ($run & 0x7FFF) >> 1; |
83 | 84 | if ($run_type == "black") |
84 | 85 | { |
@@ -98,8 +99,7 @@ discard block |
||
98 | 99 | $red = ($pixel & 0xF800) >> 8; |
99 | 100 | $green = ($pixel & 0x07E0) >> 3; |
100 | 101 | $blue = ($pixel & 0x001F) << 3; |
101 | - } |
|
102 | - else if ($this->encoding == "555") |
|
102 | + } else if ($this->encoding == "555") |
|
103 | 103 | { |
104 | 104 | $red = ($pixel & 0x7C00) >> 7; |
105 | 105 | $green = ($pixel & 0x03E0) >> 2; |
@@ -109,8 +109,9 @@ discard block |
||
109 | 109 | imagesetpixel($image, $x, $y, $colour); |
110 | 110 | } |
111 | 111 | } |
112 | - if ($x == $this->GetWidth()) |
|
113 | - $this->reader->Skip(2); |
|
112 | + if ($x == $this->GetWidth()) { |
|
113 | + $this->reader->Skip(2); |
|
114 | + } |
|
114 | 115 | } |
115 | 116 | } |
116 | 117 | $this->gdImage = $image; |
@@ -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 | ?> |
@@ -19,24 +19,24 @@ |
||
19 | 19 | parent::SpriteFile('SPR'); |
20 | 20 | $frameCount = $reader->ReadInt(2); |
21 | 21 | |
22 | - for($i=0;$i<$frameCount;$i++) { |
|
22 | + for ($i = 0; $i < $frameCount; $i++) { |
|
23 | 23 | $offset = $reader->ReadInt(4); |
24 | 24 | $width = $reader->ReadInt(2); |
25 | 25 | $height = $reader->ReadInt(2); |
26 | - $this->AddFrame(new SPRFrame($reader,$width,$height,$offset)); |
|
26 | + $this->AddFrame(new SPRFrame($reader, $width, $height, $offset)); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | |
30 | 30 | /// @brief Compiles the SPR file into a binary string |
31 | 31 | public function Compile() { |
32 | - $data = pack('v',$this->GetFrameCount()); |
|
32 | + $data = pack('v', $this->GetFrameCount()); |
|
33 | 33 | $offset = 2+(8*$this->GetFrameCount()); |
34 | - foreach($this->GetFrames() as $frame) { |
|
35 | - $data .= pack('V',$offset); |
|
36 | - $data .= pack('vv',$frame->GetWidth(),$frame->GetHeight()); |
|
34 | + foreach ($this->GetFrames() as $frame) { |
|
35 | + $data .= pack('V', $offset); |
|
36 | + $data .= pack('vv', $frame->GetWidth(), $frame->GetHeight()); |
|
37 | 37 | $offset += $frame->GetWidth()*$frame->GetHeight(); |
38 | 38 | } |
39 | - foreach($this->GetFrames() as $frame) { |
|
39 | + foreach ($this->GetFrames() as $frame) { |
|
40 | 40 | $data .= $frame->Encode(); |
41 | 41 | } |
42 | 42 | return $data; |
@@ -34,8 +34,9 @@ |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | $buffer = $reader->ReadInt(2); |
37 | - if ($buffer < 1) |
|
38 | - throw new Exception('Sprite file appears to contain less than 1 frame.'); |
|
37 | + if ($buffer < 1) { |
|
38 | + throw new Exception('Sprite file appears to contain less than 1 frame.'); |
|
39 | + } |
|
39 | 40 | $frameCount = $buffer; |
40 | 41 | for ($x = 0; $x < $frameCount; $x++) |
41 | 42 | { |
@@ -7,56 +7,56 @@ |
||
7 | 7 | * @dataProvider createAgentFiles |
8 | 8 | */ |
9 | 9 | public function testCreatePRAYFile(PRAYFile $prayfile) { |
10 | - $this->assertInstanceOf('PRAYFile',$prayfile); |
|
10 | + $this->assertInstanceOf('PRAYFile', $prayfile); |
|
11 | 11 | $this->assertNotNull($prayfile); |
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
15 | 15 | * @dataProvider createAgentFiles |
16 | 16 | */ |
17 | - public function testNumberOfBlocks(PRAYFile $prayfile,$fixtureInfo) { |
|
17 | + public function testNumberOfBlocks(PRAYFile $prayfile, $fixtureInfo) { |
|
18 | 18 | $this->assertNotNull($prayfile); |
19 | - $this->assertEquals($fixtureInfo['block count'],sizeof($prayfile->GetBlocks())); |
|
19 | + $this->assertEquals($fixtureInfo['block count'], sizeof($prayfile->GetBlocks())); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
23 | 23 | * @dataProvider createAgentFiles |
24 | 24 | */ |
25 | - public function testFirstAgentDescription(PRAYFile $prayfile,$info) { |
|
25 | + public function testFirstAgentDescription(PRAYFile $prayfile, $info) { |
|
26 | 26 | $this->assertNotNull($prayfile); |
27 | 27 | $blocks = $prayfile->GetBlocks(PRAY_BLOCK_AGNT); |
28 | - $this->assertEquals($info['first agent desc'],$blocks[0]->GetAgentDescription()); |
|
28 | + $this->assertEquals($info['first agent desc'], $blocks[0]->GetAgentDescription()); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
32 | 32 | * @dataProvider createAgentFiles |
33 | 33 | */ |
34 | - public function testChangeAGNTAndRecompile(PRAYFile $prayfile,$info) { |
|
34 | + public function testChangeAGNTAndRecompile(PRAYFile $prayfile, $info) { |
|
35 | 35 | $this->assertNotNull($prayfile); |
36 | 36 | $blocks = $prayfile->GetBlocks(PRAY_BLOCK_AGNT); |
37 | - $blocks[0]->SetTag('Agent Description','Testing'); |
|
38 | - $this->assertEquals('Testing',$blocks[0]->GetAgentDescription()); |
|
37 | + $blocks[0]->SetTag('Agent Description', 'Testing'); |
|
38 | + $this->assertEquals('Testing', $blocks[0]->GetAgentDescription()); |
|
39 | 39 | $data = $prayfile->Compile(); |
40 | 40 | $newfile = new PRAYFile(new StringReader($data)); |
41 | - $this->assertEquals($info['block count'],sizeof($newfile->GetBlocks())); |
|
41 | + $this->assertEquals($info['block count'], sizeof($newfile->GetBlocks())); |
|
42 | 42 | $newfile->GetBlocks('AGNT'); |
43 | - $this->assertEquals('Testing',$blocks[0]->GetAgentDescription()); |
|
43 | + $this->assertEquals('Testing', $blocks[0]->GetAgentDescription()); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | 47 | * @dataProvider createCreatureFiles |
48 | 48 | */ |
49 | - public function testChangeGLSTAndRecompile(PRAYFILE $prayfile,$info) { |
|
49 | + public function testChangeGLSTAndRecompile(PRAYFILE $prayfile, $info) { |
|
50 | 50 | $this->assertNotNull($prayfile); |
51 | 51 | $blocks = $prayfile->GetBlocks(PRAY_BLOCK_GLST); |
52 | - $this->assertEquals($info['events count'],$blocks[0]->GetHistory()->CountEvents()); |
|
52 | + $this->assertEquals($info['events count'], $blocks[0]->GetHistory()->CountEvents()); |
|
53 | 53 | $blocks[0]->GetHistory()->RemoveEvent(0); |
54 | - $this->assertEquals($info['events count']-1,$blocks[0]->GetHistory()->CountEvents()); |
|
54 | + $this->assertEquals($info['events count']-1, $blocks[0]->GetHistory()->CountEvents()); |
|
55 | 55 | |
56 | 56 | $data = $prayfile->Compile(); |
57 | 57 | $newfile = new PRAYFile(new StringReader($data)); |
58 | 58 | $blocks = $newfile->GetBlocks(PRAY_BLOCK_GLST); |
59 | - $this->assertEquals($info['events count']-1,$blocks[0]->GetHistory()->CountEvents()); |
|
59 | + $this->assertEquals($info['events count']-1, $blocks[0]->GetHistory()->CountEvents()); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | } |
@@ -6,8 +6,7 @@ |
||
6 | 6 | class C3CAOSFlowControls { |
7 | 7 | /// @brief Returns an array of tokens. |
8 | 8 | public static function GetTokens() { |
9 | - return array |
|
10 | - ( |
|
9 | + return array( |
|
11 | 10 | |
12 | 11 | 'doif', |
13 | 12 | 'econ', |
@@ -9,8 +9,7 @@ |
||
9 | 9 | class C3CAOSVariables { |
10 | 10 | /// @brief Returns an array of tokens. |
11 | 11 | public static function GetTokens() { |
12 | - return array |
|
13 | - ( |
|
12 | + return array( |
|
14 | 13 | //agents |
15 | 14 | 'abba', |
16 | 15 | 'carr', |
@@ -6,8 +6,7 @@ |
||
6 | 6 | class C3CAOSCommands { |
7 | 7 | /// @brief Returns an array of tokens. |
8 | 8 | public static function GetTokens() { |
9 | - return array |
|
10 | - ( |
|
9 | + return array( |
|
11 | 10 | 'alph', |
12 | 11 | 'anim', |
13 | 12 | 'amms', |