diff options
| author | Amir Rajan <[email protected]> | 2020-09-22 06:27:46 -0500 |
|---|---|---|
| committer | Amir Rajan <[email protected]> | 2020-09-22 06:27:46 -0500 |
| commit | 20d5b4057b44ffcf92478b2a8e9476ace2fdc0f5 (patch) | |
| tree | b4742e4f9acfd5400a04f314164812606a71df9f /samples/99_genre_dev_tools/add_buttons_to_console | |
| parent | 5b2311900072cfff9582bb0296140cfb354cb911 (diff) | |
| download | dragonruby-game-toolkit-contrib-20d5b4057b44ffcf92478b2a8e9476ace2fdc0f5.tar.gz dragonruby-game-toolkit-contrib-20d5b4057b44ffcf92478b2a8e9476ace2fdc0f5.zip | |
synced with 1.22
Diffstat (limited to 'samples/99_genre_dev_tools/add_buttons_to_console')
| -rw-r--r-- | samples/99_genre_dev_tools/add_buttons_to_console/app/main.rb | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/samples/99_genre_dev_tools/add_buttons_to_console/app/main.rb b/samples/99_genre_dev_tools/add_buttons_to_console/app/main.rb new file mode 100644 index 0000000..b580477 --- /dev/null +++ b/samples/99_genre_dev_tools/add_buttons_to_console/app/main.rb @@ -0,0 +1,58 @@ +# 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: :yay, + # row for button + row: 3, + # column for button + col: 10, + # text + text: "I AM CUSTOM", + # when clicked call the custom_button_clicked function + method: :custom_button_clicked), + + (button id: :yay, + # row for button + row: 3, + # column for button + col: 9, + # text + text: "CUSTOM ALSO", + # when clicked call the custom_button_also_clicked function + method: :custom_button_also_clicked) + ] + end + + # STEP 2: Define the function that should be called. + def custom_button_clicked + log "* INFO: I AM CUSTOM was clicked!" + end + + def custom_button_also_clicked + log "* INFO: Custom Button Clicked at #{Kernel.global_tick_count}!" + + all_buttons_as_string = $gtk.console.menu.buttons.map do |b| + <<-S.strip +** id: #{b[:id]} +:PROPERTIES: +:id: :#{b[:id]} +:method: :#{b[:method]} +:text: #{b[:text]} +:END: +S + end.join("\n") + + log <<-S +* INFO: Here are all the buttons: +#{all_buttons_as_string} +S + end +end + +def tick args + args.outputs.labels << [args.grid.center.x, args.grid.center.y, + "Open the DragonRuby Console to see the custom menu items.", + 0, 1] +end |
