openrgss 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,78 +1,78 @@
1
- class Rect
2
-
3
- # The x-coordinate of the rectangle's upper left corner.
4
- attr_accessor :x
5
-
6
- # The y-coordinate of the rectangle's upper left corner.
7
- attr_accessor :y
8
-
9
- # The rectangle's width.
10
- attr_accessor :width
11
-
12
- # The rectangle's height.
13
- attr_accessor :height
14
-
15
- # :call-seq:
16
- # Rect.new(x, y, width, height)
17
- # Rect.new
18
- #
19
- # Creates a new Rect object.
20
- #
21
- # The default values when no arguments are specified are (0, 0, 0, 0).
22
-
23
- def initialize(x=0, y=0, width=0, height=0)
24
- set(x, y, width, height)
25
- end
26
-
27
- # :call-seq:
28
- # set(x, y, width, height)
29
- # set(rect)
30
- #
31
- # Sets all parameters at once.
32
- #
33
- # The second format copies all the components from a separate Rect object.
34
-
35
- def set(x, y=0, width=0, height=0)
36
- if x.is_a? Rect
37
- rect = x
38
- @x = rect.x
39
- @y = rect.y
40
- @width = rect.width
41
- @height = rect.height
42
- else
43
- @x = x
44
- @y = y
45
- @width = width
46
- @height = height
47
- end
48
- end
49
-
50
- def to_s
51
- "(#{x}, #{y}, #{width}, #{height})"
52
- end
53
-
54
- # Sets all components to 0.
55
- def empty
56
- set(0, 0, 0, 0)
57
- end
58
-
59
- # Vergleichsmethode
60
- def == other
61
- if other.kind_of?(Rect) then
62
- x == other.x && y == other.y && width == other.width && height == other.height
63
- else
64
- raise TypeError.new("Can't convert #{other.class} to Rect")
65
- end
66
- end
67
-
68
- # Serialisiert das Objekt
69
- def _dump limit
70
- [x, y, width, height].pack("iiii")
71
- end
72
-
73
- # Deserialisiert das Objekt
74
- def self._load str
75
- new(*str.unpack("iiii"))
76
- end
77
-
1
+ class Rect
2
+
3
+ # The x-coordinate of the rectangle's upper left corner.
4
+ attr_accessor :x
5
+
6
+ # The y-coordinate of the rectangle's upper left corner.
7
+ attr_accessor :y
8
+
9
+ # The rectangle's width.
10
+ attr_accessor :width
11
+
12
+ # The rectangle's height.
13
+ attr_accessor :height
14
+
15
+ # :call-seq:
16
+ # Rect.new(x, y, width, height)
17
+ # Rect.new
18
+ #
19
+ # Creates a new Rect object.
20
+ #
21
+ # The default values when no arguments are specified are (0, 0, 0, 0).
22
+
23
+ def initialize(x=0, y=0, width=0, height=0)
24
+ set(x, y, width, height)
25
+ end
26
+
27
+ # :call-seq:
28
+ # set(x, y, width, height)
29
+ # set(rect)
30
+ #
31
+ # Sets all parameters at once.
32
+ #
33
+ # The second format copies all the components from a separate Rect object.
34
+
35
+ def set(x, y=0, width=0, height=0)
36
+ if x.is_a? Rect
37
+ rect = x
38
+ @x = rect.x
39
+ @y = rect.y
40
+ @width = rect.width
41
+ @height = rect.height
42
+ else
43
+ @x = x
44
+ @y = y
45
+ @width = width
46
+ @height = height
47
+ end
48
+ end
49
+
50
+ def to_s
51
+ "(#{x}, #{y}, #{width}, #{height})"
52
+ end
53
+
54
+ # Sets all components to 0.
55
+ def empty
56
+ set(0, 0, 0, 0)
57
+ end
58
+
59
+ # Vergleichsmethode
60
+ def == other
61
+ if other.kind_of?(Rect) then
62
+ x == other.x && y == other.y && width == other.width && height == other.height
63
+ else
64
+ raise TypeError.new("Can't convert #{other.class} to Rect")
65
+ end
66
+ end
67
+
68
+ # Serialisiert das Objekt
69
+ def _dump limit
70
+ [x, y, width, height].pack("iiii")
71
+ end
72
+
73
+ # Deserialisiert das Objekt
74
+ def self._load str
75
+ new(*str.unpack("iiii"))
76
+ end
77
+
78
78
  end
@@ -1,7 +1,7 @@
1
- # An exception class providing notifications of RGSS internal errors.
2
- #
3
- # Generated when, for instance, trying to access Bitmap or Sprite class objects that have already been freed.
4
-
5
- class RGSSError < StandardError
6
-
1
+ # An exception class providing notifications of RGSS internal errors.
2
+ #
3
+ # Generated when, for instance, trying to access Bitmap or Sprite class objects that have already been freed.
4
+
5
+ class RGSSError < StandardError
6
+
7
7
  end
@@ -1,7 +1,7 @@
1
- # Exception class providing notifications for when the F12 key is pressed during game execution.
2
- #
3
- # Name changed from the hidden class Reset before RGSS2.
4
-
5
- class RGSSReset < Exception
6
-
1
+ # Exception class providing notifications for when the F12 key is pressed during game execution.
2
+ #
3
+ # Name changed from the hidden class Reset before RGSS2.
4
+
5
+ class RGSSReset < Exception
6
+
7
7
  end
@@ -1,51 +1,51 @@
1
- # The multidimensional array class. Each element is an integer of 2 signed bytes ranging from -32,768 to 32,767.
2
- #
3
- # Ruby's Array class does not run efficiently when handling large amounts of data, hence the inclusion of this class.
4
-
5
- class Table
6
- attr_reader :xsize, :ysize, :zsize
7
-
8
- # Creates a Table object. Specifies the size of each dimension in the multidimensional array. 1-, 2-, and 3-dimensional arrays are possible. Arrays with no parameters are also permitted.
9
-
10
- def initialize(xsize, ysize=1, zsize=1)
11
- @xsize = xsize
12
- @ysize = ysize
13
- @zsize = zsize
14
- @data = Array.new(@xsize*@ysize*@zsize, 0)
15
- end
16
-
17
- # Changes the size of the array. All data from before the size change is retained.
18
-
19
- def resize(xsize, ysize=1, zsize=1)
20
-
21
- end
22
-
23
- # :call-seq:
24
- # self[x]
25
- # self[x, y]
26
- # self[x, y, z]
27
- #
28
- # Accesses the array's elements. Pulls the same number of arguments as there are dimensions in the created array. Returns nil if the specified element does not exist.
29
-
30
- def [](x, y=0, z=0)
31
- return nil if x >= @xsize or y >= @ysize
32
- @data[x + y * @xsize + z * @xsize * @ysize]
33
- end
34
-
35
- def []=(x, y=0, z=0, v) #:nodoc:
36
- @data[x + y * @xsize + z * @xsize * @ysize]=v
37
- end
38
-
39
-
40
-
41
- def self._load(s) #:nodoc:
42
- Table.new(1).instance_eval {
43
- @size, @xsize, @ysize, @zsize, xx, *@data = s.unpack('LLLLLS*')
44
- self
45
- }
46
- end
47
-
48
- def _dump(d = 0) #:nodoc:
49
- [@size, @xsize, @ysize, @zsize, @xsize*@ysize*@zsize, *@data].pack('LLLLLS*')
50
- end
51
- end
1
+ # The multidimensional array class. Each element is an integer of 2 signed bytes ranging from -32,768 to 32,767.
2
+ #
3
+ # Ruby's Array class does not run efficiently when handling large amounts of data, hence the inclusion of this class.
4
+
5
+ class Table
6
+ attr_reader :xsize, :ysize, :zsize
7
+
8
+ # Creates a Table object. Specifies the size of each dimension in the multidimensional array. 1-, 2-, and 3-dimensional arrays are possible. Arrays with no parameters are also permitted.
9
+
10
+ def initialize(xsize, ysize=1, zsize=1)
11
+ @xsize = xsize
12
+ @ysize = ysize
13
+ @zsize = zsize
14
+ @data = Array.new(@xsize*@ysize*@zsize, 0)
15
+ end
16
+
17
+ # Changes the size of the array. All data from before the size change is retained.
18
+
19
+ def resize(xsize, ysize=1, zsize=1)
20
+
21
+ end
22
+
23
+ # :call-seq:
24
+ # self[x]
25
+ # self[x, y]
26
+ # self[x, y, z]
27
+ #
28
+ # Accesses the array's elements. Pulls the same number of arguments as there are dimensions in the created array. Returns nil if the specified element does not exist.
29
+
30
+ def [](x, y=0, z=0)
31
+ return nil if x >= @xsize or y >= @ysize
32
+ @data[x + y * @xsize + z * @xsize * @ysize]
33
+ end
34
+
35
+ def []=(x, y=0, z=0, v) #:nodoc:
36
+ @data[x + y * @xsize + z * @xsize * @ysize]=v
37
+ end
38
+
39
+
40
+
41
+ def self._load(s) #:nodoc:
42
+ Table.new(1).instance_eval {
43
+ @size, @xsize, @ysize, @zsize, xx, *@data = s.unpack('LLLLLS*')
44
+ self
45
+ }
46
+ end
47
+
48
+ def _dump(d = 0) #:nodoc:
49
+ [@size, @xsize, @ysize, @zsize, @xsize*@ysize*@zsize, *@data].pack('LLLLLS*')
50
+ end
51
+ end
@@ -1,95 +1,95 @@
1
- #The color tone class. Each component is handled with a floating-point value (Float).
2
-
3
- class Tone
4
-
5
- # The red balance adjustment value (-255 to 255). Out-of-range values are automatically corrected.
6
- attr_accessor :red
7
-
8
- # The green balance adjustment value (-255 to 255). Out-of-range values are automatically corrected.
9
- attr_accessor :green
10
-
11
- # The blue balance adjustment value (-255 to 255). Out-of-range values are automatically corrected.
12
- attr_accessor :blue
13
-
14
- # The grayscale filter strength (0 to 255). Out-of-range values are automatically corrected.
15
- #
16
- # When this value is not 0, processing time is significantly longer than when using tone balance adjustment values alone.
17
- attr_accessor :gray
18
-
19
- # :call-seq:
20
- # Tone.new(red, green, blue[, gray])
21
- # Tone.new
22
- #
23
- # Creates a Tone object. If gray is omitted, it is assumed to be 0.
24
- #
25
- # The default values when no arguments are specified are (0, 0, 0, 0).
26
-
27
- def initialize(red = 0, green = 0, blue = 0, gray = 0)
28
- self.red, self.green, self.blue, self.gray = red, green, blue, gray
29
- end
30
-
31
- # :call-seq:
32
- # set(red, green, blue[, gray])
33
- # set(tone) (RGSS3)
34
- #
35
- # Sets all components at once.
36
- #
37
- # The second format copies all the components from a separate Tone object.
38
-
39
- def set(red, green=0, blue=0, gray=0)
40
- if red.is_a? Tone
41
- tone = red
42
- @red = tone.red
43
- @green = tone.green
44
- @blue = tone.blue
45
- @gray = tone.gray
46
- else
47
- @red = red
48
- @green = green
49
- @blue = blue
50
- @gray = gray
51
- end
52
- end
53
-
54
- def red=(value) # :nodoc:
55
- @red = [[-255, value].max, 255].min
56
- end
57
-
58
- def green=(value) # :nodoc:
59
- @green = [[-255, value].max, 255].min
60
- end
61
-
62
- def blue=(value) # :nodoc:
63
- @blue = [[-255, value].max, 255].min
64
- end
65
-
66
- def gray=(value) # :nodoc:
67
- @gray = [[0, value].max, 255].min
68
- end
69
-
70
-
71
-
72
- def to_s # :nodoc:
73
- "(#{red}, #{green}, #{blue}, #{gray})"
74
- end
75
-
76
- def blend(tone) # :nodoc:
77
- self.clone.blend!(tone)
78
- end
79
-
80
- def blend!(tone) # :nodoc:
81
- self.red += tone.red
82
- self.green += tone.green
83
- self.blue += tone.blue
84
- self.gray += tone.gray
85
- self
86
- end
87
-
88
- def _dump(marshal_depth = -1) # :nodoc:
89
- [@red, @green, @blue, @gray].pack('E4')
90
- end
91
-
92
- def self._load(data) # :nodoc:
93
- new(*data.unpack('E4'))
94
- end
1
+ #The color tone class. Each component is handled with a floating-point value (Float).
2
+
3
+ class Tone
4
+
5
+ # The red balance adjustment value (-255 to 255). Out-of-range values are automatically corrected.
6
+ attr_accessor :red
7
+
8
+ # The green balance adjustment value (-255 to 255). Out-of-range values are automatically corrected.
9
+ attr_accessor :green
10
+
11
+ # The blue balance adjustment value (-255 to 255). Out-of-range values are automatically corrected.
12
+ attr_accessor :blue
13
+
14
+ # The grayscale filter strength (0 to 255). Out-of-range values are automatically corrected.
15
+ #
16
+ # When this value is not 0, processing time is significantly longer than when using tone balance adjustment values alone.
17
+ attr_accessor :gray
18
+
19
+ # :call-seq:
20
+ # Tone.new(red, green, blue[, gray])
21
+ # Tone.new
22
+ #
23
+ # Creates a Tone object. If gray is omitted, it is assumed to be 0.
24
+ #
25
+ # The default values when no arguments are specified are (0, 0, 0, 0).
26
+
27
+ def initialize(red = 0, green = 0, blue = 0, gray = 0)
28
+ self.red, self.green, self.blue, self.gray = red, green, blue, gray
29
+ end
30
+
31
+ # :call-seq:
32
+ # set(red, green, blue[, gray])
33
+ # set(tone) (RGSS3)
34
+ #
35
+ # Sets all components at once.
36
+ #
37
+ # The second format copies all the components from a separate Tone object.
38
+
39
+ def set(red, green=0, blue=0, gray=0)
40
+ if red.is_a? Tone
41
+ tone = red
42
+ @red = tone.red
43
+ @green = tone.green
44
+ @blue = tone.blue
45
+ @gray = tone.gray
46
+ else
47
+ @red = red
48
+ @green = green
49
+ @blue = blue
50
+ @gray = gray
51
+ end
52
+ end
53
+
54
+ def red=(value) # :nodoc:
55
+ @red = [[-255, value].max, 255].min
56
+ end
57
+
58
+ def green=(value) # :nodoc:
59
+ @green = [[-255, value].max, 255].min
60
+ end
61
+
62
+ def blue=(value) # :nodoc:
63
+ @blue = [[-255, value].max, 255].min
64
+ end
65
+
66
+ def gray=(value) # :nodoc:
67
+ @gray = [[0, value].max, 255].min
68
+ end
69
+
70
+
71
+
72
+ def to_s # :nodoc:
73
+ "(#{red}, #{green}, #{blue}, #{gray})"
74
+ end
75
+
76
+ def blend(tone) # :nodoc:
77
+ self.clone.blend!(tone)
78
+ end
79
+
80
+ def blend!(tone) # :nodoc:
81
+ self.red += tone.red
82
+ self.green += tone.green
83
+ self.blue += tone.blue
84
+ self.gray += tone.gray
85
+ self
86
+ end
87
+
88
+ def _dump(marshal_depth = -1) # :nodoc:
89
+ [@red, @green, @blue, @gray].pack('E4')
90
+ end
91
+
92
+ def self._load(data) # :nodoc:
93
+ new(*data.unpack('E4'))
94
+ end
95
95
  end