minigl 2.2.5 → 2.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/minigl/forms.rb +22 -3
- data/lib/minigl/game_object.rb +4 -1
- data/test/game.rb +6 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c160807a14f043a9e5bffd7de36b8c0085a50c9b383144b6db7c86a066d7ace
|
4
|
+
data.tar.gz: a107f24295cbacc47a25069672301f085ee81fd7e3998e97a2ea47d9c7cc345b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbfbdaa66ae480738b129a9944cad90b2225d974479a18ec1e30a9f742856c5750036bff8a4bc9d499c6ad3eec4ba993b236a7e5184d6ac3e35f623de1db2f53
|
7
|
+
data.tar.gz: 58ade56420bfe2ee57481efadca47d0af79f55bdf34abf11da86f49f2680fa3459a5c48f3f5d1df4b37883942dd1ab4ea6827542fba9e5a3c1c0e1cac910f776
|
data/README.md
CHANGED
@@ -29,6 +29,7 @@ After installing the Gosu dependencies, you can just `gem install minigl`.
|
|
29
29
|
* The [wiki](https://github.com/victords/minigl/wiki) is a work in progress with tutorials and examples.
|
30
30
|
* Test package and examples aren't complete!
|
31
31
|
|
32
|
-
## Version 2.2.
|
32
|
+
## Version 2.2.6
|
33
33
|
|
34
|
-
*
|
34
|
+
* Made the `text` readable in all form components.
|
35
|
+
* Added the `text=` method to `Label`.
|
data/lib/minigl/forms.rb
CHANGED
@@ -37,6 +37,9 @@ module MiniGL
|
|
37
37
|
# The height of the component
|
38
38
|
attr_reader :h
|
39
39
|
|
40
|
+
# The text of the component
|
41
|
+
attr_reader :text
|
42
|
+
|
40
43
|
attr_reader :anchor, :anchor_offset_x, :anchor_offset_y # :nodoc:
|
41
44
|
|
42
45
|
# Determines whether the control is enabled, i.e., will process user input.
|
@@ -52,6 +55,8 @@ module MiniGL
|
|
52
55
|
# for each specific component class.
|
53
56
|
attr_accessor :params
|
54
57
|
|
58
|
+
attr_accessor :panel # :nodoc:
|
59
|
+
|
55
60
|
def initialize(x, y, font, text, text_color, disabled_text_color) # :nodoc:
|
56
61
|
@x = x
|
57
62
|
@y = y
|
@@ -127,6 +132,7 @@ module MiniGL
|
|
127
132
|
controls.each do |c|
|
128
133
|
_, x, y = FormUtils.check_anchor(c.anchor, c.anchor_offset_x, c.anchor_offset_y, c.w, c.h, @w, @h)
|
129
134
|
c.set_position(@x + x, @y + y)
|
135
|
+
c.panel = self
|
130
136
|
end
|
131
137
|
|
132
138
|
if img
|
@@ -537,9 +543,6 @@ module MiniGL
|
|
537
543
|
|
538
544
|
# This class represents a text field (input).
|
539
545
|
class TextField < Component
|
540
|
-
# The current text inside the text field.
|
541
|
-
attr_reader :text
|
542
|
-
|
543
546
|
# The current 'locale' used for detecting the keys. THIS FEATURE IS
|
544
547
|
# INCOMPLETE!
|
545
548
|
attr_reader :locale
|
@@ -1460,6 +1463,22 @@ module MiniGL
|
|
1460
1463
|
super(x, y, font, text, text_color, disabled_text_color)
|
1461
1464
|
end
|
1462
1465
|
|
1466
|
+
# Changes the label's text.
|
1467
|
+
#
|
1468
|
+
# Parameters:
|
1469
|
+
# [new_text] The new text to show in the label.
|
1470
|
+
def text=(new_text)
|
1471
|
+
@text = new_text
|
1472
|
+
@w = @font.text_width(@text) * @scale_x
|
1473
|
+
x = @anchor_offset_x; y = @anchor_offset_y
|
1474
|
+
_, x, y = FormUtils.check_anchor(@anchor, x, y, @w, @h, panel ? panel.w : G.window.width, panel ? panel.h : G.window.height)
|
1475
|
+
if panel
|
1476
|
+
set_position(panel.x + x, panel.y + y)
|
1477
|
+
else
|
1478
|
+
set_position(x, y)
|
1479
|
+
end
|
1480
|
+
end
|
1481
|
+
|
1463
1482
|
# Draws the label.
|
1464
1483
|
#
|
1465
1484
|
# Parameters:
|
data/lib/minigl/game_object.rb
CHANGED
@@ -82,7 +82,10 @@ module MiniGL
|
|
82
82
|
# [interval] The amount of frames between each change in the image index.
|
83
83
|
# See +animate+ for details.
|
84
84
|
def animate_once(indices, interval)
|
85
|
-
|
85
|
+
if @animate_once_control == 2
|
86
|
+
return if indices == @animate_once_indices && interval == @animate_once_interval
|
87
|
+
@animate_once_control = 0
|
88
|
+
end
|
86
89
|
|
87
90
|
unless @animate_once_control == 1
|
88
91
|
@anim_counter = 0
|
data/test/game.rb
CHANGED
@@ -35,7 +35,7 @@ class MyGame < GameWindow
|
|
35
35
|
|
36
36
|
@panel = Panel.new(10, 10, 720, 520, [
|
37
37
|
Button.new(x: 5, y: 5, font: @font1, text: 'Teste', img: :btn),
|
38
|
-
Label.new(0, 70, @font1, 'Teste de label',
|
38
|
+
@lbl = Label.new(0, 70, @font1, 'Teste de label', 0, 0x666666, 1, 1, :north),
|
39
39
|
TextField.new(x: 5, y: 40, font: @font1, text: 'Opa', img: :text, margin_x: 5, margin_y: 5, anchor: :top_left),
|
40
40
|
Button.new(x: 0, y: 5, font: @font1, text: 'Teste', img: :btn, anchor: :top),
|
41
41
|
DropDownList.new(x: 0, y: 40, width: 150, height: 25, font: @font1, options: ['olá amigos', 'opção 2', 'terceira'], anchor: :north),
|
@@ -49,6 +49,8 @@ class MyGame < GameWindow
|
|
49
49
|
ProgressBar.new(0, 40, 200, 20, :barbg, :barfg, 3456, 70, 2, 2, @font1, 0xff000080, nil, nil, 1, 1, :bottom)
|
50
50
|
], :text, :tiled, true, 2, 2, :bottom_right)
|
51
51
|
|
52
|
+
@lbl2 = Label.new(x: 5, y: 5, font: @font1, text: 'top-right corner label test', anchor: :top_right)
|
53
|
+
|
52
54
|
@eff = Effect.new(100, 100, :check, 2, 4, 10, nil, nil, '1')
|
53
55
|
|
54
56
|
@angle = 0
|
@@ -79,6 +81,8 @@ class MyGame < GameWindow
|
|
79
81
|
@panel.visible = !@panel.visible if KB.key_pressed? Gosu::KbM
|
80
82
|
|
81
83
|
@panel.add_component(Button.new(x: 5, y: 5, font: @font1, text: 'Teste', img: :btn, anchor: :southeast)) if KB.key_pressed?(Gosu::KbB)
|
84
|
+
@lbl.text = 'Test of changed text' if KB.key_pressed?(Gosu::KB_C)
|
85
|
+
@lbl2.text = 'Shorter text' if KB.key_pressed?(Gosu::KB_X)
|
82
86
|
|
83
87
|
@pb.increase 1 if KB.key_down? Gosu::KbD
|
84
88
|
@pb.decrease 1 if KB.key_down? Gosu::KbA
|
@@ -145,6 +149,7 @@ class MyGame < GameWindow
|
|
145
149
|
@chk.draw
|
146
150
|
@txt.draw
|
147
151
|
@pb.draw 0x66
|
152
|
+
@lbl2.draw
|
148
153
|
|
149
154
|
@panel.draw(204, 10)
|
150
155
|
|
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: 2.2.
|
4
|
+
version: 2.2.6
|
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: 2019-
|
11
|
+
date: 2019-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.7.
|
97
|
+
rubygems_version: 2.7.8
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: MiniGL
|