minigl 1.2.4 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/lib/minigl/forms.rb +32 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01d773ef32ca54ed13e397c386708830e7731e8e
|
4
|
+
data.tar.gz: 810ff8899be10ec787147090c539ac0d7608f603
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25128512170f5275e48a8baec43555ab0307f246703cde5eeb55a5d2d4a52ffa9dbc055d5bb7933786eac9c7f00e289c03d8acb982d1aed514482127ebe8f952
|
7
|
+
data.tar.gz: 7e0a5f25b732eaba12c1156e471ea7e1cff6a68774e09be3f3d6e29fbb43903f67420b7aabab0f08640467e34ef24a7a1226d7d05a8f26f17f0c9eaf701db7d1
|
data/README.md
CHANGED
@@ -21,8 +21,9 @@ this [working game example](https://github.com/victords/aventura-do-saber).
|
|
21
21
|
* The [documentation](https://github.com/victords/minigl/wiki) is under
|
22
22
|
construction.
|
23
23
|
|
24
|
-
**Version 1.2.
|
24
|
+
**Version 1.2.5**
|
25
25
|
|
26
|
-
*
|
27
|
-
|
28
|
-
*
|
26
|
+
* Added support for "invisible" buttons (for associating actions with clicks
|
27
|
+
in screen areas).
|
28
|
+
* Exposed `Button`'s `click` method and `TextField`'s `focus` and `unfocus`
|
29
|
+
methods.
|
data/lib/minigl/forms.rb
CHANGED
@@ -2,15 +2,20 @@ require_relative 'global'
|
|
2
2
|
|
3
3
|
module AGL
|
4
4
|
class Button
|
5
|
-
def initialize x, y, font, text, img, text_color = 0, center = true, margin_x = 0, margin_y = 0, &action
|
5
|
+
def initialize x, y, font, text, img, text_color = 0, center = true, margin_x = 0, margin_y = 0, width = nil, height = nil, &action
|
6
6
|
@x = x
|
7
7
|
@y = y
|
8
8
|
@font = font
|
9
9
|
@text = text
|
10
|
-
@img =
|
11
|
-
|
12
|
-
|
13
|
-
@
|
10
|
+
@img =
|
11
|
+
if img; Res.imgs img, 1, 3, true
|
12
|
+
else; nil; end
|
13
|
+
@w =
|
14
|
+
if img; @img[0].width
|
15
|
+
else; width; end
|
16
|
+
@h =
|
17
|
+
if img; @img[0].height
|
18
|
+
else; height; end
|
14
19
|
if center
|
15
20
|
@text_x = x + @w / 2
|
16
21
|
@text_y = y + @h / 2
|
@@ -18,6 +23,7 @@ module AGL
|
|
18
23
|
@text_x = x + margin_x
|
19
24
|
@text_y = y + margin_y
|
20
25
|
end
|
26
|
+
@text_color = text_color
|
21
27
|
@center = center
|
22
28
|
@action = Proc.new &action
|
23
29
|
|
@@ -50,7 +56,7 @@ module AGL
|
|
50
56
|
elsif mouse_rel
|
51
57
|
@img_index = 0
|
52
58
|
@state = :up
|
53
|
-
|
59
|
+
click
|
54
60
|
end
|
55
61
|
elsif @state == :down_out
|
56
62
|
if mouse_over
|
@@ -63,14 +69,20 @@ module AGL
|
|
63
69
|
end
|
64
70
|
end
|
65
71
|
|
72
|
+
def click
|
73
|
+
@action.call
|
74
|
+
end
|
75
|
+
|
66
76
|
def draw alpha = 0xff
|
67
77
|
color = (alpha << 24) | 0xffffff
|
68
78
|
text_color = (alpha << 24) | @text_color
|
69
|
-
@img[@img_index].draw @x, @y, 0, 1, 1, color
|
70
|
-
if @
|
71
|
-
|
72
|
-
|
73
|
-
|
79
|
+
@img[@img_index].draw @x, @y, 0, 1, 1, color if @img
|
80
|
+
if @text
|
81
|
+
if @center
|
82
|
+
@font.draw_rel @text, @text_x, @text_y, 0, 0.5, 0.5, 1, 1, text_color
|
83
|
+
else
|
84
|
+
@font.draw @text, @text_x, @text_y, 0, 1, 1, text_color
|
85
|
+
end
|
74
86
|
end
|
75
87
|
end
|
76
88
|
end
|
@@ -144,17 +156,21 @@ module AGL
|
|
144
156
|
@active = true
|
145
157
|
end
|
146
158
|
|
159
|
+
def unfocus
|
160
|
+
@anchor1 = @anchor2 = nil
|
161
|
+
@cursor_visible = false
|
162
|
+
@cursor_timer = 0
|
163
|
+
@active = false
|
164
|
+
end
|
165
|
+
|
147
166
|
def update
|
148
167
|
################################ Mouse ################################
|
149
168
|
if Mouse.over? @x, @y, @w, @h
|
150
169
|
if not @active and Mouse.button_pressed? :left
|
151
|
-
|
170
|
+
focus
|
152
171
|
end
|
153
172
|
elsif Mouse.button_pressed? :left
|
154
|
-
|
155
|
-
@cursor_visible = false
|
156
|
-
@cursor_timer = 0
|
157
|
-
@active = false
|
173
|
+
unfocus
|
158
174
|
end
|
159
175
|
|
160
176
|
return unless @active
|
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.2.
|
4
|
+
version: 1.2.5
|
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-07-
|
11
|
+
date: 2014-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|