minigl 2.3.8 → 2.3.9
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.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/minigl/forms.rb +9 -11
- data/lib/minigl/global.rb +49 -12
- data/test/game.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff7475dd66f98076ad86cc143943c75f186e6b696aba46083b71727ad69e95b0
|
4
|
+
data.tar.gz: 87bec4f94e32553a70ea4ca4318357bbadb71ffc6600859a8c63ec772e708137
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09094e3898b3a19939f39acf33ba4514db24bb1771b7795769a632e7f7230874058f921609d0760ea5958b42ca70e0a5b2224c974c5d3a80b4f1d2d1e59ad4cc'
|
7
|
+
data.tar.gz: ad1fc0475cee6c71ec019e5f8516b077da8ba4f37fbd95136137acb4716f83fe3fff42f68a5c458841c80732e8117776ac14c696c70b776d06c8b73860b379f5
|
data/README.md
CHANGED
@@ -37,10 +37,10 @@ After installing the Gosu dependencies, you can just `gem install minigl`.
|
|
37
37
|
* The [wiki](https://github.com/victords/minigl/wiki) is a work in progress with tutorials and examples.
|
38
38
|
* Test package and examples aren't complete!
|
39
39
|
|
40
|
-
## Version 2.3.
|
40
|
+
## Version 2.3.9
|
41
41
|
|
42
|
-
*
|
43
|
-
*
|
42
|
+
* Fixed click detection for very short clicks.
|
43
|
+
* Allow combining `center` and `margin` for `Button` text.
|
44
44
|
|
45
45
|
## Contributing
|
46
46
|
|
data/lib/minigl/forms.rb
CHANGED
@@ -317,12 +317,12 @@ module MiniGL
|
|
317
317
|
super x, y, font, text, text_color, disabled_text_color
|
318
318
|
@over_text_color = over_text_color
|
319
319
|
@down_text_color = down_text_color
|
320
|
-
if center_x; @text_x = x + @w / 2 if @w
|
321
|
-
else; @text_x = x + margin_x * @scale_x; end
|
322
|
-
if center_y; @text_y = y + @h / 2 if @h
|
323
|
-
else; @text_y = y + margin_y * @scale_y; end
|
324
320
|
@center_x = center_x
|
325
321
|
@center_y = center_y
|
322
|
+
@margin_x = margin_x
|
323
|
+
@margin_y = margin_y
|
324
|
+
set_position(x, y)
|
325
|
+
|
326
326
|
@action = action
|
327
327
|
@params = params
|
328
328
|
|
@@ -393,10 +393,10 @@ module MiniGL
|
|
393
393
|
# [x] The new x-coordinate for the button.
|
394
394
|
# [y] The new y-coordinate for the button.
|
395
395
|
def set_position(x, y)
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
396
|
+
@text_x = @center_x ? x + @w / 2 : x
|
397
|
+
@text_y = @center_y ? y + @h / 2 : y
|
398
|
+
@text_x += @margin_x
|
399
|
+
@text_y += @margin_y
|
400
400
|
@x = x; @y = y
|
401
401
|
end
|
402
402
|
|
@@ -445,7 +445,7 @@ module MiniGL
|
|
445
445
|
private
|
446
446
|
|
447
447
|
def perform_action
|
448
|
-
@action.call
|
448
|
+
@action.call(@params) if @action
|
449
449
|
end
|
450
450
|
end
|
451
451
|
|
@@ -514,8 +514,6 @@ module MiniGL
|
|
514
514
|
else; height * @scale_y; end
|
515
515
|
_, x, y = FormUtils.check_anchor(anchor, @anchor_offset_x, @anchor_offset_y, @w, @h)
|
516
516
|
set_position(x, y)
|
517
|
-
@text_x = x + @w / 2 if center_x
|
518
|
-
@text_y = y + @h / 2 if center_y
|
519
517
|
@checked = checked
|
520
518
|
end
|
521
519
|
|
data/lib/minigl/global.rb
CHANGED
@@ -245,6 +245,16 @@ module MiniGL
|
|
245
245
|
def toggle_fullscreen
|
246
246
|
self.fullscreen = !fullscreen?
|
247
247
|
end
|
248
|
+
|
249
|
+
def button_down(id)
|
250
|
+
super
|
251
|
+
Mouse.register_button_down(id)
|
252
|
+
end
|
253
|
+
|
254
|
+
def button_up(id)
|
255
|
+
super
|
256
|
+
Mouse.register_button_up(id)
|
257
|
+
end
|
248
258
|
end
|
249
259
|
|
250
260
|
# Exposes methods for controlling keyboard and gamepad events.
|
@@ -387,6 +397,7 @@ module MiniGL
|
|
387
397
|
def initialize
|
388
398
|
@down = {}
|
389
399
|
@prev_down = {}
|
400
|
+
@next_down = {}
|
390
401
|
@dbl_click = {}
|
391
402
|
@dbl_click_timer = {}
|
392
403
|
end
|
@@ -394,7 +405,8 @@ module MiniGL
|
|
394
405
|
# Updates the mouse position and the state of all buttons.
|
395
406
|
def update
|
396
407
|
@prev_down = @down.clone
|
397
|
-
@down.
|
408
|
+
@down = @next_down.clone
|
409
|
+
@next_down.delete_if { |_, v| v.zero? }
|
398
410
|
@dbl_click.clear
|
399
411
|
|
400
412
|
if @click
|
@@ -403,19 +415,19 @@ module MiniGL
|
|
403
415
|
end
|
404
416
|
|
405
417
|
@dbl_click_timer.each do |k, v|
|
406
|
-
if v < G.double_click_delay
|
407
|
-
|
418
|
+
if v < G.double_click_delay
|
419
|
+
@dbl_click_timer[k] += 1
|
420
|
+
else
|
421
|
+
@dbl_click_timer.delete(k)
|
422
|
+
end
|
408
423
|
end
|
409
424
|
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
@
|
416
|
-
@dbl_click_timer.delete k2[i]
|
417
|
-
elsif @prev_down[k2[i]]
|
418
|
-
@dbl_click_timer[k2[i]] = 0
|
425
|
+
%i[left middle right].each do |key|
|
426
|
+
if @down[key]
|
427
|
+
@dbl_click[key] = true if @dbl_click_timer[key]
|
428
|
+
@dbl_click_timer.delete(key)
|
429
|
+
elsif @prev_down[key]
|
430
|
+
@dbl_click_timer[key] = 0
|
419
431
|
end
|
420
432
|
end
|
421
433
|
|
@@ -486,6 +498,31 @@ module MiniGL
|
|
486
498
|
|
487
499
|
@click = { z_index: z_index, action: action }
|
488
500
|
end
|
501
|
+
|
502
|
+
# :nodoc:
|
503
|
+
def register_button_down(id)
|
504
|
+
key = key_from_id(id)
|
505
|
+
@next_down[key] = 1 if key
|
506
|
+
end
|
507
|
+
|
508
|
+
# :nodoc:
|
509
|
+
def register_button_up(id)
|
510
|
+
key = key_from_id(id)
|
511
|
+
@next_down[key] = 0 if key && @next_down[key]
|
512
|
+
end
|
513
|
+
|
514
|
+
private
|
515
|
+
|
516
|
+
def key_from_id(id)
|
517
|
+
case id
|
518
|
+
when Gosu::MS_LEFT
|
519
|
+
:left
|
520
|
+
when Gosu::MS_RIGHT
|
521
|
+
:right
|
522
|
+
when Gosu::MS_MIDDLE
|
523
|
+
:middle
|
524
|
+
end
|
525
|
+
end
|
489
526
|
end
|
490
527
|
end
|
491
528
|
|
data/test/game.rb
CHANGED
@@ -19,7 +19,7 @@ class MyGame < GameWindow
|
|
19
19
|
@font2 = Res.font :font1, 50
|
20
20
|
@writer1 = TextHelper.new @font1, 5
|
21
21
|
@writer2 = TextHelper.new @font2, 5
|
22
|
-
@btn = Button.new(10, 560, @font1, 'Test', :btn, 0x008000, 0x808080, 0xffffff, 0xff9980, true,
|
22
|
+
@btn = Button.new(10, 560, @font1, 'Test', :btn, 0x008000, 0x808080, 0xffffff, 0xff9980, true, false, -10, 4, 0, 0, 'friends', nil, 2, 2) { |x| puts "hello #{x}" }
|
23
23
|
@btn.enabled = false
|
24
24
|
@chk =
|
25
25
|
ToggleButton.new(x: 0, y: 30, font: @font1, text: 'Click me', img: :check, center_x: false, margin_x: 36, params: 'friends', anchor: :south) { |c, x|
|
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.3.
|
4
|
+
version: 2.3.9
|
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: 2022-03-
|
11
|
+
date: 2022-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|