-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathengine.rb
62 lines (55 loc) · 1.52 KB
/
engine.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# frozen_string_literal: true
# Engine Methods
def keyboard
$gtk.args.inputs.keyboard
end
def randr(min, max)
rand(max - min + 1) + min
end
# You can customize the buttons that show up in the Console.
class GTK::Console::Menu
# STEP 1: Override the custom_buttons function.
def custom_buttons
[
(button id: :reset_game,
# row for button
row: 4,
# column for button
col: 10,
# text
text: 'Reset $game',
# when clicked call the custom_button_clicked function
method: :reset_game_clicked),
(button id: :rubocop,
# row for button
row: 4,
# column for button
col: 9,
# text
text: 'rubocop -a',
# when clicked call the custom_button_clicked function
method: :rubocop_button_clicked),
(button id: :clear_console,
# row for button
row: 4,
# column for button
col: 8,
# text
text: 'Clear Console',
# when clicked call the custom_button_clicked function
method: :clear_console_button_clicked)
]
end
# STEP 2: Define the function that should be called.
def reset_game_clicked
$game = nil
$gtk.reset
end
def rubocop_button_clicked
puts 'Starting rubocop...'
$gtk.args.gtk.system 'rubocop -a'
end
def clear_console_button_clicked
$gtk.console.clear
end
end