minigl 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -5
  3. data/lib/minigl/forms.rb +28 -7
  4. data/test/game.rb +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 77d77deca3bb6d5d439cb293a9f4782abcba1b9f
4
- data.tar.gz: 68bdd7b0fb6c06fb0041717e0895b4f054b67464
3
+ metadata.gz: 6519693f68d4a4961b9b21e9379f46d76aaf042f
4
+ data.tar.gz: 9e5058266fb5de59417e4dcf13b6691700da5829
5
5
  SHA512:
6
- metadata.gz: 7c3b435fe29547b9f1ceb4507bb4fcbfc665cd058c0a22ba5a8843903f60df8908fe0348ca3af1e2aa2d85c7ad990a905ae9edfc5bf0d2fd1073823f822f6910
7
- data.tar.gz: 12522cfd3056d20e4afed6f8d89d57dc7f930e47febec71175bae399bf1905da591008ab68b7b14e78479307f291526ecae30c36b4f6a832b6ccae6be4841b0e
6
+ metadata.gz: 33c31a6af23f16ee8222642845d45f170508fe714a4e79d61aa3e1fc0f53eddc63438935ab5deaea6629ceac7a9c416626afb4e01c99a3682fc3108e9129d20a
7
+ data.tar.gz: cfeea61e4d33ef190302c82314c346c3ea7d37309dc5db38c42984cc2b29ffdec3bedc27330d07cd361125bdb76ddada346659bb12e25c0c77512568e166b2c4
data/README.md CHANGED
@@ -22,11 +22,12 @@ this [working game example](https://github.com/victords/aventura-do-saber).
22
22
  * An auxiliary, tutorial-like documentation is under construction
23
23
  [here](https://github.com/victords/minigl/wiki).
24
24
 
25
- **Version 1.3.1**
25
+ **Version 1.3.2**
26
26
 
27
- * Introduced the `enabled` and `visible` attributes for the form components.
28
- * Fixed issue with right shift for selection in the `TextField`.
29
- * Added missing keys to `KB`.
27
+ * Created documentation for the abstract class `Component`.
28
+ * Granted read and write access to the `params` attribute for all components.
29
+ * Fixed issue with `ToggleButton` instantiation with no width and height set.
30
+ * Added `checked` parameter to the constructor of `ToggleButton`.
30
31
 
31
32
  **WARNING**: this version can generate incompatibility, because of the parameter
32
- order in the constructors for `Button`, `ToggleButton` and `TextField`.
33
+ order in the constructor for `ToggleButton`.
@@ -1,9 +1,24 @@
1
1
  require_relative 'global'
2
2
 
3
3
  module AGL
4
- class Component # :nodoc:
5
- attr_accessor :enabled, :visible
4
+ # This class is an abstract ancestor for all form components (Button,
5
+ # ToggleButton and TextField).
6
+ class Component
7
+ # Determines whether the control is enabled, i.e., will process user input.
8
+ attr_accessor :enabled
6
9
 
10
+ # Determines whether the control is visible, i.e., will be drawn in the
11
+ # screen and process user input, if enabled.
12
+ attr_accessor :visible
13
+
14
+ # A container for any parameters to be passed to the code blocks called
15
+ # in response to events of the control (click of a button, change of the
16
+ # text in a text field, etc.). More detail can be found in the constructor
17
+ # for each specific component class.
18
+ attr_accessor :params
19
+
20
+ # This constructor is for internal use of the subclasses only. Do not
21
+ # instantiate objects of this class.
7
22
  def initialize x, y, font, text, text_color, disabled_text_color
8
23
  @x = x
9
24
  @y = y
@@ -66,8 +81,8 @@ module AGL
66
81
  if img; @img[0].height
67
82
  else; height; end
68
83
  if center
69
- @text_x = x + @w / 2
70
- @text_y = y + @h / 2
84
+ @text_x = x + @w / 2 if @w
85
+ @text_y = y + @h / 2 if @h
71
86
  else
72
87
  @text_x = x + margin_x
73
88
  @text_y = y + margin_y
@@ -188,9 +203,10 @@ module AGL
188
203
  attr_reader :checked
189
204
 
190
205
  # Creates a ToggleButton. All parameters work the same as in Button,
191
- # except the image, +img+, which now has to be composed of two columns
206
+ # except for the image, +img+, which now has to be composed of two columns
192
207
  # and four rows, the first column with images for the unchecked state,
193
- # and the second with images for the checked state.
208
+ # and the second with images for the checked state, and for +checked+,
209
+ # which defines the initial state of the ToggleButton.
194
210
  #
195
211
  # The +action+ block now will always receive a first boolean parameter
196
212
  # corresponding to the value of +checked+. So, if you want to pass
@@ -199,7 +215,7 @@ module AGL
199
215
  # puts "button was checked" if checked
200
216
  # # do something with params
201
217
  # }
202
- def initialize x, y, font, text, img, text_color = 0, disabled_text_color = 0, center = true, margin_x = 0, margin_y = 0,
218
+ def initialize x, y, font, text, img, checked = false, text_color = 0, disabled_text_color = 0, center = true, margin_x = 0, margin_y = 0,
203
219
  width = nil, height = nil, params = nil, &action
204
220
  super x, y, font, text, nil, text_color, disabled_text_color, center, margin_x, margin_y, width, height, params, &action
205
221
  @img =
@@ -211,6 +227,11 @@ module AGL
211
227
  @h =
212
228
  if img; @img[0].height
213
229
  else; height; end
230
+ if center
231
+ @text_x = x + @w / 2
232
+ @text_y = y + @h / 2
233
+ end
234
+ @checked = checked
214
235
  end
215
236
 
216
237
  # Updates the button, checking the mouse movement and buttons to define
@@ -13,7 +13,7 @@ class MyGame < Gosu::Window
13
13
  @writer = TextHelper.new @font, 5
14
14
  @btn = Button.new(10, 560, @font, "Test", :btn, 0x008000, 0x808080, 0, 0, 0, 0, 0, "friends") { |x| puts "hello #{x}" }
15
15
  @btn.enabled = false
16
- @chk = ToggleButton.new(210, 560, @font, "Click me", :check, 0xffffff, 0x808080, false, 36, 5, 0, 0, "friends") { |c, x|
16
+ @chk = ToggleButton.new(210, 560, @font, "Click me", :check, false, 0xffffff, 0x808080, false, 36, 5, 0, 0, "friends") { |c, x|
17
17
  puts "hello #{x}, checked: #{c}"
18
18
  }
19
19
  @txt = TextField.new(10, 520, @font, :text, nil, nil, 15, 5, 16, false, "", nil, 0, 0, 0x0000ff, "test") { |t, x| puts "field #{x}, text: #{t}" }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minigl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor David Santos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-16 00:00:00.000000000 Z
11
+ date: 2014-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gosu