glimmer-dsl-libui 0.2.22 → 0.2.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +81 -15
- data/VERSION +1 -1
- data/examples/area_gallery.rb +1 -1
- data/examples/area_gallery2.rb +1 -1
- data/examples/area_gallery3.rb +1 -1
- data/examples/area_gallery4.rb +1 -1
- data/examples/snake/model/game.rb +0 -1
- data/examples/tetris.rb +23 -3
- data/examples/tic_tac_toe.rb +1 -1
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui.rb +5 -5
- 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: 3e33c97761bce7909c5a48df2689cb8bd0a4745ac68a24c814c4938c36eb08e0
|
4
|
+
data.tar.gz: 604b2d6439ed510f6e30bae8f431c09fcd348f14afa71fa4707a3de0d71cae33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66603e770e6135e08ea785ef46ac9158c6f14b1c3966175c7116f9a81cc3dbbfcc2ee495f16d367976174b2f8f0d9013640731713db3c9be65dd5b973dba12b5
|
7
|
+
data.tar.gz: 94ca555082c61042dd24ba0a36b75b5b401b8c63ef0c0f5acff6b3fcb2f822dd37e61ab3cd3660b5e657896a8209afe09760cf8c7fc9a092d00a6666d43a1c96
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.2.23
|
4
|
+
|
5
|
+
- Improve examples/tetris.rb by having high score dialog pause the game if running and resume after closed
|
6
|
+
- Adjust Area Gallery example text size to 11 in Windows/Linux
|
7
|
+
- Fix `Glimmer::LibUI::timer {}` behavior so that the block return value will not affect repetition outcome if it is `Integer` (only Booleans affect it)
|
8
|
+
- Fix Tetris down button for Windows (it was going too fast before making tetrominos invisible before they hit the bottom)
|
9
|
+
- Fix Tetris double-downs (or multiple downs) happening after game over (it was firing an additional down timer after game over by mistake before)
|
10
|
+
- Fix Tetris by prechecking Turn Left on Up radio menu item since it is the one selected upon launch of the game
|
11
|
+
- Fix Tic-Tac-Toe text-size for Windows/Linux
|
12
|
+
|
3
13
|
## 0.2.22
|
4
14
|
|
5
15
|
- examples/snake.rb implemented test-first
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for LibUI 0.2.
|
1
|
+
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for LibUI 0.2.23
|
2
2
|
## Prerequisite-Free Ruby Desktop Development GUI Library
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-libui.svg)](http://badge.fury.io/rb/glimmer-dsl-libui)
|
4
4
|
[![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
@@ -143,7 +143,7 @@ window('Area Gallery', 400, 400) {
|
|
143
143
|
}
|
144
144
|
text(161, 40, 100) { # x, y, width
|
145
145
|
string('Area Gallery') {
|
146
|
-
font family: 'Arial', size: 14
|
146
|
+
font family: 'Arial', size: (OS.mac? ? 14 : 11)
|
147
147
|
color :black
|
148
148
|
}
|
149
149
|
}
|
@@ -219,7 +219,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
219
219
|
- [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
|
220
220
|
- [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)
|
221
221
|
- [glimmer-dsl-tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (MRI Ruby Desktop Development GUI Library)
|
222
|
-
- [glimmer-dsl-gtk](https://github.com/AndyObtiva/glimmer-dsl-gtk): Ruby-GNOME Desktop Development GUI Library
|
222
|
+
- [glimmer-dsl-gtk](https://github.com/AndyObtiva/glimmer-dsl-gtk): Glimmer DSL for GTK (Ruby-GNOME Desktop Development GUI Library)
|
223
223
|
- [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
|
224
224
|
- [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS
|
225
225
|
|
@@ -373,7 +373,7 @@ gem install glimmer-dsl-libui
|
|
373
373
|
Or install via Bundler `Gemfile`:
|
374
374
|
|
375
375
|
```ruby
|
376
|
-
gem 'glimmer-dsl-libui', '~> 0.2.
|
376
|
+
gem 'glimmer-dsl-libui', '~> 0.2.23'
|
377
377
|
```
|
378
378
|
|
379
379
|
Add `require 'glimmer-dsl-libui'` at the top, and then `include Glimmer` into the top-level main object for testing or into an actual class for serious usage.
|
@@ -1760,11 +1760,11 @@ class TinyMidiPlayer
|
|
1760
1760
|
|
1761
1761
|
UI.new_horizontal_box.tap do |hbox|
|
1762
1762
|
UI.new_vertical_box.tap do |vbox|
|
1763
|
-
UI.new_button('
|
1763
|
+
UI.new_button('â–¶').tap do |button1|
|
1764
1764
|
UI.button_on_clicked(button1) { play_midi }
|
1765
1765
|
UI.box_append(vbox, button1, 1)
|
1766
1766
|
end
|
1767
|
-
UI.new_button('
|
1767
|
+
UI.new_button('â– ').tap do |button2|
|
1768
1768
|
UI.button_on_clicked(button2) { stop_midi }
|
1769
1769
|
UI.box_append(vbox, button2, 1)
|
1770
1770
|
end
|
@@ -1858,12 +1858,12 @@ class TinyMidiPlayer
|
|
1858
1858
|
vertical_box {
|
1859
1859
|
stretchy false
|
1860
1860
|
|
1861
|
-
button('
|
1861
|
+
button('â–¶') {
|
1862
1862
|
on_clicked do
|
1863
1863
|
play_midi
|
1864
1864
|
end
|
1865
1865
|
}
|
1866
|
-
button('
|
1866
|
+
button('â– ') {
|
1867
1867
|
on_clicked do
|
1868
1868
|
stop_midi
|
1869
1869
|
end
|
@@ -4129,7 +4129,7 @@ window('Area Gallery', 400, 400) {
|
|
4129
4129
|
}
|
4130
4130
|
text(161, 40, 100) { # x, y, width
|
4131
4131
|
string('Area Gallery') {
|
4132
|
-
font family: 'Arial', size: 14
|
4132
|
+
font family: 'Arial', size: (OS.mac? ? 14 : 11)
|
4133
4133
|
color :black
|
4134
4134
|
}
|
4135
4135
|
}
|
@@ -4339,7 +4339,7 @@ window('Area Gallery', 400, 400) {
|
|
4339
4339
|
width 100
|
4340
4340
|
|
4341
4341
|
string {
|
4342
|
-
font family: 'Arial', size: 14
|
4342
|
+
font family: 'Arial', size: (OS.mac? ? 14 : 11)
|
4343
4343
|
color :black
|
4344
4344
|
|
4345
4345
|
'Area Gallery'
|
@@ -4452,7 +4452,7 @@ window('Area Gallery', 400, 400) {
|
|
4452
4452
|
}
|
4453
4453
|
text(161, 40, 100) { # x, y, width
|
4454
4454
|
string('Area Gallery') {
|
4455
|
-
font family: 'Arial', size: 14
|
4455
|
+
font family: 'Arial', size: (OS.mac? ? 14 : 11)
|
4456
4456
|
color :black
|
4457
4457
|
}
|
4458
4458
|
}
|
@@ -4664,7 +4664,7 @@ window('Area Gallery', 400, 400) {
|
|
4664
4664
|
width 100
|
4665
4665
|
|
4666
4666
|
string {
|
4667
|
-
font family: 'Arial', size: 14
|
4667
|
+
font family: 'Arial', size: (OS.mac? ? 14 : 11)
|
4668
4668
|
color :black
|
4669
4669
|
|
4670
4670
|
'Area Gallery'
|
@@ -6292,6 +6292,22 @@ Mac
|
|
6292
6292
|
|
6293
6293
|
![glimmer-dsl-libui-mac-tetris-high-scores.png](images/glimmer-dsl-libui-mac-tetris-high-scores.png)
|
6294
6294
|
|
6295
|
+
Windows
|
6296
|
+
|
6297
|
+
![glimmer-dsl-libui-windows-tetris.png](images/glimmer-dsl-libui-windows-tetris.png)
|
6298
|
+
|
6299
|
+
![glimmer-dsl-libui-windows-tetris-game-over.png](images/glimmer-dsl-libui-windows-tetris-game-over.png)
|
6300
|
+
|
6301
|
+
![glimmer-dsl-libui-windows-tetris-high-scores.png](images/glimmer-dsl-libui-windows-tetris-high-scores.png)
|
6302
|
+
|
6303
|
+
Linux
|
6304
|
+
|
6305
|
+
![glimmer-dsl-libui-linux-tetris.png](images/glimmer-dsl-libui-linux-tetris.png)
|
6306
|
+
|
6307
|
+
![glimmer-dsl-libui-linux-tetris-game-over.png](images/glimmer-dsl-libui-linux-tetris-game-over.png)
|
6308
|
+
|
6309
|
+
![glimmer-dsl-libui-linux-tetris-high-scores.png](images/glimmer-dsl-libui-linux-tetris-high-scores.png)
|
6310
|
+
|
6295
6311
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
6296
6312
|
|
6297
6313
|
```ruby
|
@@ -6532,7 +6548,19 @@ class Tetris
|
|
6532
6548
|
on_key_down do |key_event|
|
6533
6549
|
case key_event
|
6534
6550
|
in ext_key: :down
|
6535
|
-
|
6551
|
+
if OS.windows?
|
6552
|
+
# rate limit downs in Windows as they go too fast when key is held
|
6553
|
+
@queued_downs ||= 0
|
6554
|
+
if @queued_downs < 2
|
6555
|
+
@queued_downs += 1
|
6556
|
+
Glimmer::LibUI.timer(0.01, repeat: false) do
|
6557
|
+
@game.down! if @queued_downs < 2
|
6558
|
+
@queued_downs -= 1
|
6559
|
+
end
|
6560
|
+
end
|
6561
|
+
else
|
6562
|
+
@game.down!
|
6563
|
+
end
|
6536
6564
|
in key: ' '
|
6537
6565
|
@game.down!(instant: true)
|
6538
6566
|
in ext_key: :up
|
@@ -6616,8 +6644,11 @@ class Tetris
|
|
6616
6644
|
end
|
6617
6645
|
|
6618
6646
|
def start_moving_tetrominos_down
|
6619
|
-
|
6620
|
-
@
|
6647
|
+
unless @tetrominos_start_moving_down
|
6648
|
+
@tetrominos_start_moving_down = true
|
6649
|
+
Glimmer::LibUI.timer(@game.delay) do
|
6650
|
+
@game.down! if !@game.game_over? && !@game.paused?
|
6651
|
+
end
|
6621
6652
|
end
|
6622
6653
|
end
|
6623
6654
|
|
@@ -6630,6 +6661,8 @@ class Tetris
|
|
6630
6661
|
|
6631
6662
|
def show_high_scores
|
6632
6663
|
Glimmer::LibUI.queue_main do
|
6664
|
+
game_paused = !!@game.paused
|
6665
|
+
@game.paused = true
|
6633
6666
|
if @game.high_scores.empty?
|
6634
6667
|
high_scores_string = "No games have been scored yet."
|
6635
6668
|
else
|
@@ -6638,6 +6671,7 @@ class Tetris
|
|
6638
6671
|
end.join("\n")
|
6639
6672
|
end
|
6640
6673
|
msg_box('High Scores', high_scores_string)
|
6674
|
+
@game.paused = game_paused
|
6641
6675
|
end
|
6642
6676
|
end
|
6643
6677
|
|
@@ -6677,6 +6711,26 @@ Mac
|
|
6677
6711
|
|
6678
6712
|
![glimmer-dsl-libui-mac-tic-tac-toe-draw.png](images/glimmer-dsl-libui-mac-tic-tac-toe-draw.png)
|
6679
6713
|
|
6714
|
+
Windows
|
6715
|
+
|
6716
|
+
![glimmer-dsl-libui-windows-tic-tac-toe.png](images/glimmer-dsl-libui-windows-tic-tac-toe.png)
|
6717
|
+
|
6718
|
+
![glimmer-dsl-libui-windows-tic-tac-toe-player-o-wins.png](images/glimmer-dsl-libui-windows-tic-tac-toe-player-o-wins.png)
|
6719
|
+
|
6720
|
+
![glimmer-dsl-libui-windows-tic-tac-toe-player-x-wins.png](images/glimmer-dsl-libui-windows-tic-tac-toe-player-x-wins.png)
|
6721
|
+
|
6722
|
+
![glimmer-dsl-libui-windows-tic-tac-toe-draw.png](images/glimmer-dsl-libui-windows-tic-tac-toe-draw.png)
|
6723
|
+
|
6724
|
+
Linux
|
6725
|
+
|
6726
|
+
![glimmer-dsl-libui-linux-tic-tac-toe.png](images/glimmer-dsl-libui-linux-tic-tac-toe.png)
|
6727
|
+
|
6728
|
+
![glimmer-dsl-libui-linux-tic-tac-toe-player-o-wins.png](images/glimmer-dsl-libui-linux-tic-tac-toe-player-o-wins.png)
|
6729
|
+
|
6730
|
+
![glimmer-dsl-libui-linux-tic-tac-toe-player-x-wins.png](images/glimmer-dsl-libui-linux-tic-tac-toe-player-x-wins.png)
|
6731
|
+
|
6732
|
+
![glimmer-dsl-libui-linux-tic-tac-toe-draw.png](images/glimmer-dsl-libui-linux-tic-tac-toe-draw.png)
|
6733
|
+
|
6680
6734
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
6681
6735
|
|
6682
6736
|
```ruby
|
@@ -6791,6 +6845,18 @@ Mac
|
|
6791
6845
|
|
6792
6846
|
![glimmer-dsl-libui-mac-snake-game-over.png](images/glimmer-dsl-libui-mac-snake-game-over.png)
|
6793
6847
|
|
6848
|
+
Windows
|
6849
|
+
|
6850
|
+
![glimmer-dsl-libui-windows-snake.png](images/glimmer-dsl-libui-windows-snake.png)
|
6851
|
+
|
6852
|
+
![glimmer-dsl-libui-windows-snake-game-over.png](images/glimmer-dsl-libui-windows-snake-game-over.png)
|
6853
|
+
|
6854
|
+
Linux
|
6855
|
+
|
6856
|
+
![glimmer-dsl-libui-linux-snake.png](images/glimmer-dsl-libui-linux-snake.png)
|
6857
|
+
|
6858
|
+
![glimmer-dsl-libui-linux-snake-game-over.png](images/glimmer-dsl-libui-linux-snake-game-over.png)
|
6859
|
+
|
6794
6860
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
6795
6861
|
|
6796
6862
|
```ruby
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.23
|
data/examples/area_gallery.rb
CHANGED
data/examples/area_gallery2.rb
CHANGED
data/examples/area_gallery3.rb
CHANGED
data/examples/area_gallery4.rb
CHANGED
data/examples/tetris.rb
CHANGED
@@ -153,6 +153,8 @@ class Tetris
|
|
153
153
|
end
|
154
154
|
}
|
155
155
|
radio_menu_item('Rotate Left on Up Arrow') {
|
156
|
+
checked true
|
157
|
+
|
156
158
|
on_clicked do
|
157
159
|
@game.rotate_left_on_up = true
|
158
160
|
end
|
@@ -235,7 +237,19 @@ class Tetris
|
|
235
237
|
on_key_down do |key_event|
|
236
238
|
case key_event
|
237
239
|
in ext_key: :down
|
238
|
-
|
240
|
+
if OS.windows?
|
241
|
+
# rate limit downs in Windows as they go too fast when key is held
|
242
|
+
@queued_downs ||= 0
|
243
|
+
if @queued_downs < 2
|
244
|
+
@queued_downs += 1
|
245
|
+
Glimmer::LibUI.timer(0.01, repeat: false) do
|
246
|
+
@game.down! if @queued_downs < 2
|
247
|
+
@queued_downs -= 1
|
248
|
+
end
|
249
|
+
end
|
250
|
+
else
|
251
|
+
@game.down!
|
252
|
+
end
|
239
253
|
in key: ' '
|
240
254
|
@game.down!(instant: true)
|
241
255
|
in ext_key: :up
|
@@ -319,8 +333,11 @@ class Tetris
|
|
319
333
|
end
|
320
334
|
|
321
335
|
def start_moving_tetrominos_down
|
322
|
-
|
323
|
-
@
|
336
|
+
unless @tetrominos_start_moving_down
|
337
|
+
@tetrominos_start_moving_down = true
|
338
|
+
Glimmer::LibUI.timer(@game.delay) do
|
339
|
+
@game.down! if !@game.game_over? && !@game.paused?
|
340
|
+
end
|
324
341
|
end
|
325
342
|
end
|
326
343
|
|
@@ -333,6 +350,8 @@ class Tetris
|
|
333
350
|
|
334
351
|
def show_high_scores
|
335
352
|
Glimmer::LibUI.queue_main do
|
353
|
+
game_paused = !!@game.paused
|
354
|
+
@game.paused = true
|
336
355
|
if @game.high_scores.empty?
|
337
356
|
high_scores_string = "No games have been scored yet."
|
338
357
|
else
|
@@ -341,6 +360,7 @@ class Tetris
|
|
341
360
|
end.join("\n")
|
342
361
|
end
|
343
362
|
msg_box('High Scores', high_scores_string)
|
363
|
+
@game.paused = game_paused
|
344
364
|
end
|
345
365
|
end
|
346
366
|
|
data/examples/tic_tac_toe.rb
CHANGED
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
data/lib/glimmer/libui.rb
CHANGED
@@ -26,12 +26,12 @@ module Glimmer
|
|
26
26
|
class << self
|
27
27
|
include Glimmer::FiddleConsumer
|
28
28
|
|
29
|
-
def integer_to_boolean(int, allow_nil: true)
|
30
|
-
int.nil? ? (allow_nil ? nil : false) : ((int.is_a?(TrueClass) || int.is_a?(FalseClass)) ? int : (int.is_a?(Integer) ? int == 1 : (allow_nil ? nil : false)))
|
29
|
+
def integer_to_boolean(int, allow_nil: true, allow_boolean: true)
|
30
|
+
int.nil? ? (allow_nil ? nil : false) : (allow_boolean && (int.is_a?(TrueClass) || int.is_a?(FalseClass)) ? int : (int.is_a?(Integer) ? int == 1 : (allow_nil ? nil : false)))
|
31
31
|
end
|
32
32
|
|
33
|
-
def boolean_to_integer(bool, allow_nil: true)
|
34
|
-
bool.nil? ? (allow_nil ? nil : 0) : (bool.is_a?(Integer) ? bool : (bool.is_a?(TrueClass) || bool.is_a?(FalseClass) ? (bool == true ? 1 : 0) : (allow_nil ? nil : 0)))
|
33
|
+
def boolean_to_integer(bool, allow_nil: true, allow_integer: true)
|
34
|
+
bool.nil? ? (allow_nil ? nil : 0) : (allow_integer && bool.is_a?(Integer) ? bool : (bool.is_a?(TrueClass) || bool.is_a?(FalseClass) ? (bool == true ? 1 : 0) : (allow_nil ? nil : 0)))
|
35
35
|
end
|
36
36
|
|
37
37
|
def degrees_to_radians(degrees)
|
@@ -173,7 +173,7 @@ module Glimmer
|
|
173
173
|
# If block returns true at any point, the timer continues for another repetition regardless of `repeat:` keyword arg value
|
174
174
|
def timer(time_in_seconds = 0.1, repeat: true, &block)
|
175
175
|
closure = fiddle_closure_block_caller(4, [0]) do
|
176
|
-
result = boolean_to_integer(block.call)
|
176
|
+
result = boolean_to_integer(block.call, allow_integer: false)
|
177
177
|
repeat -= 1 if repeat.is_a?(Integer)
|
178
178
|
if result.nil?
|
179
179
|
if (repeat == true || (repeat.is_a?(Integer) && repeat > 0))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-libui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|