openrgss 0.1.4-x86-mingw32 → 0.1.5-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,106 +1,106 @@
1
- # The font class. Font is a property of the Bitmap class.
2
- #
3
- # If there is a "Fonts" folder directly under the game folder, the font files in it can be used even if they are not installed on the system.
4
- #
5
- # You can change the default values set for each component when a new Font object is created.
6
- #
7
- # Font.default_name = ["Myriad", "Verdana"]
8
- # Font.default_size = 22
9
- # Font.default_bold = true
10
-
11
- class Font
12
- @@cache = {}
13
- # Creates a Font object.
14
-
15
- def initialize(arg_name=@@default_name, arg_size=@@default_size)
16
- @name = arg_name
17
- @size = arg_size
18
- @bold = @@default_bold
19
- @italic= @@default_italic
20
- @color = @@default_color
21
- end
22
-
23
- # Returns true if the specified font exists on the system.
24
-
25
- def Font.exist?(arg_font_name)
26
- font_key = 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts'
27
- reg_open_keyex = Win32API.new('Advapi32', 'RegOpenKeyEx', 'lpllp', 'l')
28
- reg_enum_value = Win32API.new('Advapi32', 'RegEnumValue', 'llppiiii', 'l')
29
- reg_close_key = Win32API.new('Advapi32', 'RegCloseKey', 'l', 'l')
30
- open_key = [0].pack('V')
31
- # get key
32
- reg_open_keyex.call(0x80000002, font_key, 0, 0x20019, open_key)
33
- open_key = (open_key + [0].pack('V')).unpack('V').first
34
- # enumerate
35
- buffer = "\0"*256
36
- buff_size = [255].pack('l')
37
- key_i = 0
38
- font_names= []
39
- while (reg_enum_value.call(open_key, key_i, buffer, buff_size, 0, 0, 0, 0).zero?)
40
- # get name
41
- font_names << buffer[0, buff_size.unpack('l').first].sub(/\s\(.*\)/, '')
42
- # reset
43
- buff_size = [255].pack('l')
44
- # increment
45
- key_i += 1
46
- end
47
- reg_close_key.call(open_key)
48
- # test
49
- return font_names.include?(arg_font_name)
50
- end
51
-
52
- # SDL::TTF对象
53
-
54
- def entity
55
- result = @@cache[[@name, @size]] ||= SDL::TTF.open('wqy-microhei.ttc', @size)
56
- result.style = (@bold ? SDL::TTF::STYLE_BOLD : 0) | (@italic ? SDL::TTF::STYLE_ITALIC : 0)
57
- result
58
- end
59
-
60
- # The font name. Include an array of strings to specify multiple fonts to be used in a desired order.
61
- #
62
- # font.name = ["Myriad", "Verdana"]
63
- # In this example, if the higher priority font Myriad does not exist on the system, the second choice Verdana will be used instead.
64
- #
65
- # The default is ["Verdana", "Arial", "Courier New"].
66
- attr_accessor :name
67
-
68
- # The font size. The default is 24.
69
- attr_accessor :size
70
-
71
- # The bold flag. The default is FALSE.
72
- attr_accessor :bold
73
-
74
- # The italic flag. The default is FALSE.
75
- attr_accessor :italic
76
-
77
- # The flag for outline text. The default is TRUE.
78
- attr_accessor :outline
79
-
80
- # The flag for shadow text. The default is false (RGSS3). When enabled, a black shadow will be drawn to the bottom right of the character.
81
- attr_accessor :shadow
82
-
83
- # The font color (Color). Alpha values may also be used. The default is (255,255,255,255).
84
- #
85
- # Alpha values are also used when drawing outline (RGSS3) and shadow text.
86
- attr_accessor :color
87
-
88
- # The outline color (Color). The default is (0,0,0,128).
89
- attr_accessor :out_color
90
-
91
- class <<self
92
- [:name, :size, :bold, :italic, :color, :outline, :shadow, :out_color].each { |attribute|
93
- name = 'default_' + attribute.to_s
94
- define_method(name) { class_variable_get('@@'+name) }
95
- define_method(name+'=') { |value| class_variable_set('@@'+name, value) }
96
- }
97
- end
98
- #------------------------------------------------------------------------
99
- # * Standard Einstellungen aus der RGSS102E.dll.
100
- #------------------------------------------------------------------------
101
- @@default_name = "Arial"
102
- @@default_size = 22
103
- @@default_bold = false
104
- @@default_italic= false
105
- @@default_color = Color.new(255, 255, 255, 255)
1
+ # The font class. Font is a property of the Bitmap class.
2
+ #
3
+ # If there is a "Fonts" folder directly under the game folder, the font files in it can be used even if they are not installed on the system.
4
+ #
5
+ # You can change the default values set for each component when a new Font object is created.
6
+ #
7
+ # Font.default_name = ["Myriad", "Verdana"]
8
+ # Font.default_size = 22
9
+ # Font.default_bold = true
10
+
11
+ class Font
12
+ @@cache = {}
13
+ # Creates a Font object.
14
+
15
+ def initialize(arg_name=@@default_name, arg_size=@@default_size)
16
+ @name = arg_name
17
+ @size = arg_size
18
+ @bold = @@default_bold
19
+ @italic= @@default_italic
20
+ @color = @@default_color
21
+ end
22
+
23
+ # Returns true if the specified font exists on the system.
24
+
25
+ def Font.exist?(arg_font_name)
26
+ font_key = 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts'
27
+ reg_open_keyex = Win32API.new('Advapi32', 'RegOpenKeyEx', 'lpllp', 'l')
28
+ reg_enum_value = Win32API.new('Advapi32', 'RegEnumValue', 'llppiiii', 'l')
29
+ reg_close_key = Win32API.new('Advapi32', 'RegCloseKey', 'l', 'l')
30
+ open_key = [0].pack('V')
31
+ # get key
32
+ reg_open_keyex.call(0x80000002, font_key, 0, 0x20019, open_key)
33
+ open_key = (open_key + [0].pack('V')).unpack('V').first
34
+ # enumerate
35
+ buffer = "\0"*256
36
+ buff_size = [255].pack('l')
37
+ key_i = 0
38
+ font_names= []
39
+ while (reg_enum_value.call(open_key, key_i, buffer, buff_size, 0, 0, 0, 0).zero?)
40
+ # get name
41
+ font_names << buffer[0, buff_size.unpack('l').first].sub(/\s\(.*\)/, '')
42
+ # reset
43
+ buff_size = [255].pack('l')
44
+ # increment
45
+ key_i += 1
46
+ end
47
+ reg_close_key.call(open_key)
48
+ # test
49
+ return font_names.include?(arg_font_name)
50
+ end
51
+
52
+ # SDL::TTF对象
53
+
54
+ def entity
55
+ result = @@cache[[@name, @size]] ||= SDL::TTF.open('wqy-microhei.ttc', @size)
56
+ result.style = (@bold ? SDL::TTF::STYLE_BOLD : 0) | (@italic ? SDL::TTF::STYLE_ITALIC : 0)
57
+ result
58
+ end
59
+
60
+ # The font name. Include an array of strings to specify multiple fonts to be used in a desired order.
61
+ #
62
+ # font.name = ["Myriad", "Verdana"]
63
+ # In this example, if the higher priority font Myriad does not exist on the system, the second choice Verdana will be used instead.
64
+ #
65
+ # The default is ["Verdana", "Arial", "Courier New"].
66
+ attr_accessor :name
67
+
68
+ # The font size. The default is 24.
69
+ attr_accessor :size
70
+
71
+ # The bold flag. The default is FALSE.
72
+ attr_accessor :bold
73
+
74
+ # The italic flag. The default is FALSE.
75
+ attr_accessor :italic
76
+
77
+ # The flag for outline text. The default is TRUE.
78
+ attr_accessor :outline
79
+
80
+ # The flag for shadow text. The default is false (RGSS3). When enabled, a black shadow will be drawn to the bottom right of the character.
81
+ attr_accessor :shadow
82
+
83
+ # The font color (Color). Alpha values may also be used. The default is (255,255,255,255).
84
+ #
85
+ # Alpha values are also used when drawing outline (RGSS3) and shadow text.
86
+ attr_accessor :color
87
+
88
+ # The outline color (Color). The default is (0,0,0,128).
89
+ attr_accessor :out_color
90
+
91
+ class <<self
92
+ [:name, :size, :bold, :italic, :color, :outline, :shadow, :out_color].each { |attribute|
93
+ name = 'default_' + attribute.to_s
94
+ define_method(name) { class_variable_get('@@'+name) }
95
+ define_method(name+'=') { |value| class_variable_set('@@'+name, value) }
96
+ }
97
+ end
98
+ #------------------------------------------------------------------------
99
+ # * Standard Einstellungen aus der RGSS102E.dll.
100
+ #------------------------------------------------------------------------
101
+ @@default_name = "Arial"
102
+ @@default_size = 22
103
+ @@default_bold = false
104
+ @@default_italic= false
105
+ @@default_color = Color.new(255, 255, 255, 255)
106
106
  end
@@ -9,7 +9,7 @@ module Graphics
9
9
  @brightness = 255
10
10
  @width = 640
11
11
  @height = 480
12
- @graphics_render_target = Bitmap.new(544, 416) # need rebuild when resize.
12
+ @graphics_render_target = Bitmap.new(@width, @height) # need rebuild when resize.
13
13
  @freeze = false # or true?
14
14
  class <<self
15
15
  attr_reader :width, :height
@@ -1,141 +1,141 @@
1
- # A module that handles input data from a gamepad or keyboard.
2
- #
3
- # Managed by symbols rather than button numbers in RGSS3. (RGSS3)
4
- module Input
5
- Keys = {
6
- DOWN: [SDL::Key::DOWN, SDL::Key::S],
7
- LEFT: [SDL::Key::LEFT, SDL::Key::A],
8
- RIGHT: [SDL::Key::RIGHT, SDL::Key::D],
9
- UP: [SDL::Key::UP, SDL::Key::W],
10
- A: [SDL::Key::LSHIFT],
11
- B: [SDL::Key::X, SDL::Key::ESCAPE],
12
- C: [SDL::Key::Z, SDL::Key::RETURN],
13
- L: [SDL::Key::PAGEUP],
14
- R: [SDL::Key::PAGEDOWN],
15
- SHIFT: [SDL::Key::LSHIFT, SDL::Key::RSHIFT],
16
- CTRL: [SDL::Key::LSHIFT, SDL::Key::RSHIFT],
17
- ALT: [SDL::Key::LSHIFT, SDL::Key::RSHIFT],
18
- F5: [SDL::Key::F5],
19
- F6: [SDL::Key::F6],
20
- F7: [SDL::Key::F7],
21
- F8: [SDL::Key::F8],
22
- F9: [SDL::Key::F9],
23
- SHOW_FPS: [SDL::Key::F2],
24
- RESET: [SDL::Key::F12]
25
- }
26
-
27
- Entities = {}
28
-
29
- Keys.each { |key, value|
30
- const_set(key, key)
31
- value.each { |entity| Entities[entity] = key }
32
-
33
- }
34
- @status = {}
35
- @events = []
36
- class <<self
37
- attr_accessor :events
38
-
39
- # Updates input data. As a general rule, this method is called once per frame.
40
-
41
- def update
42
- RGSS.update
43
- @status.each { |key, value| @status[key] = value.next }
44
- while event = events.shift
45
- key = Entities[event.sym]
46
- Log.debug('key') { event }
47
- if event.press
48
- case key
49
- when :SHOW_FPS
50
- RGSS.show_fps = !RGSS.show_fps
51
- when :RESET
52
- raise RGSSReset
53
- else
54
- @status[key] = 0
55
- end
56
- else
57
- @status.delete key
58
- end
59
- end
60
- end
61
-
62
- # Determines whether the button corresponding to the symbol sym is currently being pressed.
63
- #
64
- # If the button is being pressed, returns TRUE. If not, returns FALSE.
65
- #
66
- # if Input.press?(:C)
67
- # do_something
68
- # end
69
-
70
- def press?(sym)
71
- @status[sym]
72
- end
73
-
74
- # Determines whether the button corresponding to the symbol sym is currently being pressed again.
75
- #
76
- # "Pressed again" is seen as time having passed between the button being not pressed and being pressed.
77
- #
78
- # If the button is being pressed, returns TRUE. If not, returns FALSE.
79
-
80
- def trigger?(sym)
81
- @status[sym] and @status[sym].zero?
82
- end
83
-
84
- # Determines whether the button corresponding to the symbol sym is currently being pressed again.
85
- #
86
- # Unlike trigger?, takes into account the repeated input of a button being held down continuously.
87
- #
88
- # If the button is being pressed, returns TRUE. If not, returns FALSE.
89
-
90
- def repeat?(sym)
91
- @status[sym] and (@status[sym].zero? or (@status[sym] > 10 and (@status[sym] % 4).zero?))
92
- end
93
-
94
- # Checks the status of the directional buttons, translates the data into a specialized 4-direction input format, and returns the number pad equivalent (2, 4, 6, 8).
95
- #
96
- # If no directional buttons are being pressed (or the equivalent), returns 0.
97
-
98
- def dir4
99
- case
100
- when @status[:DOWN]
101
- 2
102
- when @status[:LEFT]
103
- 4
104
- when @status[:RIGHT]
105
- 6
106
- when @status[:UP]
107
- 8
108
- else
109
- 0
110
- end
111
- end
112
-
113
- # Checks the status of the directional buttons, translates the data into a specialized 8-direction input format, and returns the number pad equivalent (1, 2, 3, 4, 6, 7, 8, 9).
114
- #
115
- # If no directional buttons are being pressed (or the equivalent), returns 0.
116
-
117
- def dir8
118
- case
119
- when @status[:DOWN] && @status[:LEFT]
120
- 1
121
- when @status[:DOWN] && @status[:RIGHT]
122
- 3
123
- when @status[:DOWN]
124
- 2
125
- when @status[:UP] && @status[:LEFT]
126
- 7
127
- when @status[:UP] && @status[:RIGHT]
128
- 9
129
- when @status[:UP]
130
- 8
131
- when @status[:LEFT]
132
- 4
133
- when @status[:RIGHT]
134
- 6
135
- else
136
- 0
137
- end
138
- end
139
- end
140
-
1
+ # A module that handles input data from a gamepad or keyboard.
2
+ #
3
+ # Managed by symbols rather than button numbers in RGSS3. (RGSS3)
4
+ module Input
5
+ Keys = {
6
+ DOWN: [SDL::Key::DOWN, SDL::Key::S],
7
+ LEFT: [SDL::Key::LEFT, SDL::Key::A],
8
+ RIGHT: [SDL::Key::RIGHT, SDL::Key::D],
9
+ UP: [SDL::Key::UP, SDL::Key::W],
10
+ A: [SDL::Key::LSHIFT],
11
+ B: [SDL::Key::X, SDL::Key::ESCAPE],
12
+ C: [SDL::Key::Z, SDL::Key::RETURN],
13
+ L: [SDL::Key::PAGEUP],
14
+ R: [SDL::Key::PAGEDOWN],
15
+ SHIFT: [SDL::Key::LSHIFT, SDL::Key::RSHIFT],
16
+ CTRL: [SDL::Key::LSHIFT, SDL::Key::RSHIFT],
17
+ ALT: [SDL::Key::LSHIFT, SDL::Key::RSHIFT],
18
+ F5: [SDL::Key::F5],
19
+ F6: [SDL::Key::F6],
20
+ F7: [SDL::Key::F7],
21
+ F8: [SDL::Key::F8],
22
+ F9: [SDL::Key::F9],
23
+ SHOW_FPS: [SDL::Key::F2],
24
+ RESET: [SDL::Key::F12]
25
+ }
26
+
27
+ Entities = {}
28
+
29
+ Keys.each { |key, value|
30
+ const_set(key, key)
31
+ value.each { |entity| Entities[entity] = key }
32
+
33
+ }
34
+ @status = {}
35
+ @events = []
36
+ class <<self
37
+ attr_accessor :events
38
+
39
+ # Updates input data. As a general rule, this method is called once per frame.
40
+
41
+ def update
42
+ RGSS.update
43
+ @status.each { |key, value| @status[key] = value.next }
44
+ while event = events.shift
45
+ key = Entities[event.sym]
46
+ Log.debug('key') { event }
47
+ if event.press
48
+ case key
49
+ when :SHOW_FPS
50
+ RGSS.show_fps = !RGSS.show_fps
51
+ when :RESET
52
+ raise RGSSReset
53
+ else
54
+ @status[key] = 0
55
+ end
56
+ else
57
+ @status.delete key
58
+ end
59
+ end
60
+ end
61
+
62
+ # Determines whether the button corresponding to the symbol sym is currently being pressed.
63
+ #
64
+ # If the button is being pressed, returns TRUE. If not, returns FALSE.
65
+ #
66
+ # if Input.press?(:C)
67
+ # do_something
68
+ # end
69
+
70
+ def press?(sym)
71
+ @status[sym]
72
+ end
73
+
74
+ # Determines whether the button corresponding to the symbol sym is currently being pressed again.
75
+ #
76
+ # "Pressed again" is seen as time having passed between the button being not pressed and being pressed.
77
+ #
78
+ # If the button is being pressed, returns TRUE. If not, returns FALSE.
79
+
80
+ def trigger?(sym)
81
+ @status[sym] and @status[sym].zero?
82
+ end
83
+
84
+ # Determines whether the button corresponding to the symbol sym is currently being pressed again.
85
+ #
86
+ # Unlike trigger?, takes into account the repeated input of a button being held down continuously.
87
+ #
88
+ # If the button is being pressed, returns TRUE. If not, returns FALSE.
89
+
90
+ def repeat?(sym)
91
+ @status[sym] and (@status[sym].zero? or (@status[sym] > 10 and (@status[sym] % 4).zero?))
92
+ end
93
+
94
+ # Checks the status of the directional buttons, translates the data into a specialized 4-direction input format, and returns the number pad equivalent (2, 4, 6, 8).
95
+ #
96
+ # If no directional buttons are being pressed (or the equivalent), returns 0.
97
+
98
+ def dir4
99
+ case
100
+ when @status[:DOWN]
101
+ 2
102
+ when @status[:LEFT]
103
+ 4
104
+ when @status[:RIGHT]
105
+ 6
106
+ when @status[:UP]
107
+ 8
108
+ else
109
+ 0
110
+ end
111
+ end
112
+
113
+ # Checks the status of the directional buttons, translates the data into a specialized 8-direction input format, and returns the number pad equivalent (1, 2, 3, 4, 6, 7, 8, 9).
114
+ #
115
+ # If no directional buttons are being pressed (or the equivalent), returns 0.
116
+
117
+ def dir8
118
+ case
119
+ when @status[:DOWN] && @status[:LEFT]
120
+ 1
121
+ when @status[:DOWN] && @status[:RIGHT]
122
+ 3
123
+ when @status[:DOWN]
124
+ 2
125
+ when @status[:UP] && @status[:LEFT]
126
+ 7
127
+ when @status[:UP] && @status[:RIGHT]
128
+ 9
129
+ when @status[:UP]
130
+ 8
131
+ when @status[:LEFT]
132
+ 4
133
+ when @status[:RIGHT]
134
+ 6
135
+ else
136
+ 0
137
+ end
138
+ end
139
+ end
140
+
141
141
  end