glimmer-dsl-opal 0.25.4 → 0.26.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -1
  3. data/README.md +40 -5
  4. data/VERSION +1 -1
  5. data/lib/glimmer/dsl/opal/menu_expression.rb +0 -3
  6. data/lib/glimmer/swt/combo_proxy.rb +0 -39
  7. data/lib/glimmer/swt/control_editor.rb +2 -2
  8. data/lib/glimmer/swt/date_time_proxy.rb +0 -37
  9. data/lib/glimmer/swt/dialog_proxy.rb +11 -4
  10. data/lib/glimmer/swt/display_proxy.rb +1 -83
  11. data/lib/glimmer/swt/shell_proxy.rb +28 -1
  12. data/lib/glimmer/swt/spinner_proxy.rb +0 -39
  13. data/lib/glimmer/swt/table_item_proxy.rb +0 -20
  14. data/lib/glimmer/swt/table_proxy.rb +4 -0
  15. data/lib/glimmer/swt/text_proxy.rb +1 -39
  16. data/lib/glimmer/swt/widget_proxy.rb +177 -58
  17. data/lib/glimmer/ui/custom_shell.rb +2 -0
  18. data/lib/glimmer/ui/custom_widget.rb +2 -0
  19. data/lib/glimmer-dsl-opal/samples/elaborate/tetris/model/block.rb +48 -0
  20. data/lib/glimmer-dsl-opal/samples/elaborate/tetris/model/game.rb +275 -0
  21. data/lib/glimmer-dsl-opal/samples/elaborate/tetris/model/past_game.rb +39 -0
  22. data/lib/glimmer-dsl-opal/samples/elaborate/tetris/model/tetromino.rb +329 -0
  23. data/lib/glimmer-dsl-opal/samples/elaborate/tetris/view/block.rb +36 -0
  24. data/lib/glimmer-dsl-opal/samples/elaborate/tetris/view/high_score_dialog.rb +122 -0
  25. data/lib/glimmer-dsl-opal/samples/elaborate/tetris/view/playfield.rb +56 -0
  26. data/lib/glimmer-dsl-opal/samples/elaborate/tetris/view/score_lane.rb +83 -0
  27. data/lib/glimmer-dsl-opal/samples/elaborate/tetris/view/tetris_menu_bar.rb +136 -0
  28. data/lib/glimmer-dsl-opal/samples/elaborate/tetris.rb +155 -0
  29. data/lib/glimmer-dsl-opal.rb +1 -0
  30. metadata +12 -2
@@ -0,0 +1,36 @@
1
+ # Copyright (c) 2007-2021 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ class Tetris
23
+ module View
24
+ class Block
25
+ include Glimmer::UI::CustomWidget
26
+
27
+ options :game_playfield, :block_size, :row, :column
28
+
29
+ body {
30
+ canvas { |canvas_proxy|
31
+ background <= [game_playfield[row][column], :color]
32
+ }
33
+ }
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,122 @@
1
+ # Copyright (c) 2007-2021 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require_relative 'tetris_menu_bar'
23
+
24
+ class Tetris
25
+ module View
26
+ class HighScoreDialog
27
+ include Glimmer::UI::CustomShell
28
+
29
+ options :parent_shell, :game
30
+
31
+ after_body {
32
+ @game_over_observer = observe(game, :game_over) do |game_over|
33
+ close if !game_over
34
+ end
35
+ }
36
+
37
+ body {
38
+ dialog(parent_shell) {
39
+ row_layout {
40
+ type :vertical
41
+ center true
42
+ }
43
+ text 'Glimmer Tetris'
44
+
45
+ tetris_menu_bar(game: game)
46
+
47
+ label(:center) {
48
+ text <= [game, :game_over, on_read: ->(game_over) { game_over ? 'Game Over!' : 'High Scores' }]
49
+ font name: FONT_NAME, height: FONT_TITLE_HEIGHT, style: FONT_TITLE_STYLE
50
+ }
51
+ @high_score_table = table {
52
+ layout_data {
53
+ height 100
54
+ }
55
+
56
+ table_column {
57
+ text 'Name'
58
+ }
59
+ table_column {
60
+ text 'Score'
61
+ }
62
+ table_column {
63
+ text 'Lines'
64
+ }
65
+ table_column {
66
+ text 'Level'
67
+ }
68
+
69
+ items <=> [game, :high_scores, read_only_sort: true, column_properties: [:name, :score, :lines, :level]]
70
+ }
71
+ composite {
72
+ row_layout :horizontal
73
+
74
+ @play_close_button = button {
75
+ text <= [game, :game_over, on_read: ->(game_over) { game_over ? 'Play Again?' : 'Close'}]
76
+ focus true # initial focus
77
+
78
+ on_widget_selected {
79
+ close
80
+ game.paused = @game_paused
81
+ game.restart! if game.game_over?
82
+ }
83
+ }
84
+ }
85
+
86
+ on_swt_show {
87
+ @game_paused = game.paused?
88
+ game.paused = true
89
+ if game.game_over? && game.added_high_score?
90
+ game.added_high_score = false
91
+ @high_score_table.edit_table_item(
92
+ @high_score_table.items.first, # row item
93
+ 0, # column
94
+ write_on_cancel: true,
95
+ after_write: -> {
96
+ @play_close_button.set_focus
97
+ },
98
+ )
99
+ end
100
+ }
101
+
102
+ on_shell_closed {
103
+ # guard is needed because there is an observer in Tetris closing on
104
+ # game.show_high_scores change, which gets set below
105
+ unless @closing
106
+ @closing = true
107
+ @high_score_table.cancel_edit!
108
+ game.paused = @game_paused
109
+ game.show_high_scores = false
110
+ else
111
+ @closing = false
112
+ end
113
+ }
114
+
115
+ on_widget_disposed {
116
+ @game_over_observer.deregister
117
+ }
118
+ }
119
+ }
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,56 @@
1
+ # Copyright (c) 2007-2021 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require_relative 'block'
23
+
24
+ class Tetris
25
+ module View
26
+ class Playfield
27
+ include Glimmer::UI::CustomWidget
28
+
29
+ options :game_playfield, :playfield_width, :playfield_height, :block_size
30
+
31
+ body {
32
+ composite {
33
+ grid_layout {
34
+ num_columns playfield_width
35
+ make_columns_equal_width true
36
+ margin_width block_size
37
+ margin_height block_size
38
+ horizontal_spacing 0
39
+ vertical_spacing 0
40
+ }
41
+
42
+ playfield_height.times { |row|
43
+ playfield_width.times { |column|
44
+ block(game_playfield: game_playfield, block_size: block_size, row: row, column: column) {
45
+ layout_data {
46
+ width_hint block_size
47
+ height_hint block_size
48
+ }
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,83 @@
1
+ # Copyright (c) 2007-2021 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require_relative 'block'
23
+ require_relative 'playfield'
24
+
25
+ class Tetris
26
+ module View
27
+ class ScoreLane
28
+ include Glimmer::UI::CustomWidget
29
+
30
+ options :block_size, :game
31
+
32
+ before_body do
33
+ @font_name = FONT_NAME
34
+ @font_height = FONT_TITLE_HEIGHT
35
+ end
36
+
37
+ body {
38
+ composite {
39
+ row_layout {
40
+ type :vertical
41
+ center true
42
+ }
43
+ label(:center) {
44
+ text 'Next'
45
+ font name: @font_name, height: @font_height, style: FONT_TITLE_STYLE
46
+ }
47
+ playfield(game_playfield: game.preview_playfield, playfield_width: Model::Game::PREVIEW_PLAYFIELD_WIDTH, playfield_height: Model::Game::PREVIEW_PLAYFIELD_HEIGHT, block_size: block_size)
48
+
49
+ label(:center) {
50
+ text 'Score'
51
+ font name: @font_name, height: @font_height, style: FONT_TITLE_STYLE
52
+ }
53
+ label(:center) {
54
+ text <= [game, :score]
55
+ font height: @font_height
56
+ }
57
+
58
+ label # spacer
59
+
60
+ label(:center) {
61
+ text 'Lines'
62
+ font name: @font_name, height: @font_height, style: FONT_TITLE_STYLE
63
+ }
64
+ label(:center) {
65
+ text <= [game, :lines]
66
+ font height: @font_height
67
+ }
68
+
69
+ label # spacer
70
+
71
+ label(:center) {
72
+ text 'Level'
73
+ font name: @font_name, height: @font_height, style: FONT_TITLE_STYLE
74
+ }
75
+ label(:center) {
76
+ text <= [game, :level]
77
+ font height: @font_height
78
+ }
79
+ }
80
+ }
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,136 @@
1
+ # Copyright (c) 2007-2021 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ class Tetris
23
+ module View
24
+ class TetrisMenuBar
25
+ include Glimmer::UI::CustomWidget
26
+
27
+ COMMAND_KEY = OS.mac? ? :command : :ctrl
28
+
29
+ options :game
30
+
31
+ body {
32
+ menu_bar {
33
+ menu {
34
+ text '&Game'
35
+
36
+ menu_item {
37
+ text '&Start'
38
+ enabled <= [game, :game_over]
39
+ accelerator COMMAND_KEY, :s
40
+
41
+ on_widget_selected {
42
+ game.start!
43
+ }
44
+ }
45
+ menu_item(:check) {
46
+ text '&Pause'
47
+ accelerator COMMAND_KEY, :p
48
+ enabled <= [game, :game_over, on_read: ->(value) { !value && !game.show_high_scores }]
49
+ enabled <= [game, :show_high_scores, on_read: ->(value) { !value && !game.game_over }]
50
+ selection <=> [game, :paused]
51
+ }
52
+ menu_item {
53
+ text '&Restart'
54
+ accelerator COMMAND_KEY, :r
55
+
56
+ on_widget_selected {
57
+ game.restart!
58
+ }
59
+ }
60
+ menu_item(:separator)
61
+ menu_item {
62
+ text '&Exit'
63
+ accelerator COMMAND_KEY, :x
64
+
65
+ on_widget_selected {
66
+ parent_proxy.close
67
+ }
68
+ }
69
+ } # end of menu
70
+
71
+ menu {
72
+ text '&View'
73
+
74
+ menu {
75
+ text '&High Scores'
76
+ menu_item(:check) {
77
+ text '&Show'
78
+ accelerator COMMAND_KEY, :shift, :h
79
+ selection <=> [game, :show_high_scores]
80
+ }
81
+ menu_item {
82
+ text '&Clear'
83
+ accelerator COMMAND_KEY, :shift, :c
84
+
85
+ on_widget_selected {
86
+ game.clear_high_scores!
87
+ }
88
+ }
89
+ }
90
+ } # end of menu
91
+
92
+ menu {
93
+ text '&Options'
94
+ menu {
95
+ text 'Up Action'
96
+ menu_item(:radio) {
97
+ text '&Instant Down'
98
+ accelerator COMMAND_KEY, :shift, :i
99
+ selection <=> [game, :instant_down_on_up, computed_by: :up_arrow_action]
100
+ }
101
+ menu_item(:radio) {
102
+ text 'Rotate &Right'
103
+ accelerator COMMAND_KEY, :shift, :r
104
+ selection <=> [game, :rotate_right_on_up, computed_by: :up_arrow_action]
105
+ }
106
+ menu_item(:radio) {
107
+ text 'Rotate &Left'
108
+ accelerator COMMAND_KEY, :shift, :l
109
+ selection <=> [game, :rotate_left_on_up, computed_by: :up_arrow_action]
110
+ }
111
+ }
112
+ } # end of menu
113
+
114
+ menu {
115
+ text '&Help'
116
+
117
+ menu_item {
118
+ text '&About'
119
+ accelerator COMMAND_KEY, :shift, :a
120
+
121
+ on_widget_selected {
122
+ parent_custom_shell&.show_about_dialog
123
+ }
124
+ }
125
+ } # end of menu
126
+ }
127
+ }
128
+
129
+ def parent_custom_shell
130
+ # grab custom shell widget wrapping parent widget proxy (i.e. Tetris) and invoke method on it
131
+ the_parent_custom_shell = parent_proxy&.get_data('custom_shell')
132
+ the_parent_custom_shell if the_parent_custom_shell&.visible?
133
+ end
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,155 @@
1
+ # Copyright (c) 2007-2021 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require_relative 'tetris/model/game'
23
+
24
+ require_relative 'tetris/view/playfield'
25
+ require_relative 'tetris/view/score_lane'
26
+ require_relative 'tetris/view/high_score_dialog'
27
+ require_relative 'tetris/view/tetris_menu_bar'
28
+ class Event
29
+ def location
30
+ `#@native.location`
31
+ end
32
+ end
33
+ class Tetris
34
+ include Glimmer::UI::CustomShell
35
+
36
+ BLOCK_SIZE = 7
37
+ FONT_NAME = 'Menlo'
38
+ FONT_TITLE_HEIGHT = 32
39
+ FONT_TITLE_STYLE = :bold
40
+ BEVEL_CONSTANT = 20
41
+
42
+ option :playfield_width, default: Model::Game::PLAYFIELD_WIDTH
43
+ option :playfield_height, default: Model::Game::PLAYFIELD_HEIGHT
44
+
45
+ attr_reader :game
46
+
47
+ before_body do
48
+ @game = Model::Game.new(playfield_width, playfield_height)
49
+
50
+ Display.app_name = 'Glimmer Tetris'
51
+
52
+ display {
53
+ on_swt_keydown do |key_event|
54
+ case key_event.keyCode
55
+ when swt(:arrow_up), 'w'.bytes.first
56
+ case game.up_arrow_action
57
+ when :instant_down
58
+ game.down!(instant: true)
59
+ when :rotate_right
60
+ game.rotate!(:right)
61
+ when :rotate_left
62
+ game.rotate!(:left)
63
+ end
64
+ when swt(:arrow_down), 's'.bytes.first
65
+ game.down!
66
+ when swt(:arrow_left), 'a'.bytes.first
67
+ game.left!
68
+ when swt(:arrow_right), 'd'.bytes.first
69
+ game.right!
70
+ when 'q'.bytes.first
71
+ game.rotate!(:left)
72
+ when 'e'.bytes.first
73
+ game.rotate!(:right)
74
+ when swt(:shift), swt(:alt)
75
+ if key_event.keyLocation == swt(:right) # right key
76
+ game.rotate!(:right)
77
+ elsif key_event.keyLocation == swt(:left) # left key
78
+ game.rotate!(:left)
79
+ end
80
+ end
81
+
82
+ end
83
+ }
84
+ end
85
+
86
+ after_body do
87
+ observe(@game, :game_over) do |game_over|
88
+ if game_over
89
+ show_high_score_dialog
90
+ else
91
+ start_moving_tetrominos_down
92
+ end
93
+ end
94
+ observe(@game, :show_high_scores) do |show_high_scores|
95
+ if show_high_scores
96
+ show_high_score_dialog
97
+ else
98
+ @high_score_dialog.close unless @high_score_dialog.nil? || @high_score_dialog.disposed? || !@high_score_dialog.visible?
99
+ end
100
+ end
101
+ @game.start!
102
+ end
103
+
104
+ body {
105
+ shell(:no_resize) {
106
+ grid_layout {
107
+ num_columns 2
108
+ make_columns_equal_width false
109
+ margin_width 0
110
+ margin_height 0
111
+ horizontal_spacing 0
112
+ }
113
+
114
+ text 'Glimmer Tetris'
115
+ background rgb(236, 236, 236)
116
+
117
+ tetris_menu_bar(game: game)
118
+
119
+ playfield(game_playfield: game.playfield, playfield_width: playfield_width, playfield_height: playfield_height, block_size: BLOCK_SIZE) {
120
+ layout_data {
121
+ width_hint 370
122
+ }
123
+ }
124
+
125
+ score_lane(game: game, block_size: BLOCK_SIZE) {
126
+ layout_data(:fill, :fill, true, true)
127
+ }
128
+ }
129
+ }
130
+
131
+ def start_moving_tetrominos_down
132
+ Async::Task.new do
133
+ work = lambda do
134
+ @game.down!
135
+ Async::Task.new(delay: @game.delay * 1000.0, &work) unless @game.game_over? || body_root.disposed?
136
+ end
137
+ Async::Task.new(delay: @game.delay * 1000.0, &work)
138
+ end
139
+ end
140
+
141
+ def show_high_score_dialog
142
+ return if @high_score_dialog&.visible?
143
+ @high_score_dialog = high_score_dialog(parent_shell: body_root, game: @game) #if @high_score_dialog.nil? || @high_score_dialog.disposed?
144
+ @high_score_dialog.show
145
+ end
146
+
147
+ def show_about_dialog
148
+ message_box {
149
+ text 'Glimmer Tetris'
150
+ message "Glimmer Tetris\n\nGlimmer DSL for SWT Sample\n\nUse arrow keys for movement\nand right/left alt/shift keys for rotation\nAlternatively:\nLeft is A\nRight is D\nDown is S\nUp is W\nRotate Left is Q\nRotate Right is E\n\n for Left, Down, Right, Up\n\nCopyright (c) 2007-2021 Andy Maleh"
151
+ }.open
152
+ end
153
+ end
154
+
155
+ Tetris.launch