Module: GamesParadise::GUI::Gtk::FourInARowModule
- Includes:
- Gtk::BaseModule
- Included in:
- FourInARow
- Defined in:
- lib/games_paradise/gui/shared_code/four_in_a_row/four_in_a_row_module.rb
Constant Summary collapse
- NAMESPACE =
#
NAMESPACE
#
inspect
- TITLE =
#
TITLE
#
'Four in a row'
- WIDTH =
#
WIDTH
#
1400
- HEIGHT =
#
HEIGHT
#
580
- USE_THIS_FONT =
#
USE_THIS_FONT
#
:hack_20
Class Method Summary collapse
-
.run(i = ARGV) ⇒ Object
# === GamesParadise::GUI::Gtk::FourInARowModule.run ========================================================================= #.
Instance Method Summary collapse
-
#border_size? ⇒ Boolean
# === border_size? ========================================================================= #.
-
#check_for_win_condition ⇒ Object
# === check_for_win_condition.
-
#connect_skeleton ⇒ Object
# === connect_skeleton (connect tag) ========================================================================= #.
-
#create_skeleton ⇒ Object
# === create_skeleton (create tag) ========================================================================= #.
-
#do_change_the_status_of_this_button(button) ⇒ Object
# === do_change_the_status_of_this_button ========================================================================= #.
-
#initialize(commandline_arguments = ARGV, run_already = true) ⇒ Object
# === initialize ========================================================================= #.
-
#n_columns? ⇒ Boolean
# === n_columns? ========================================================================= #.
-
#n_rows? ⇒ Boolean
# === n_rows? ========================================================================= #.
-
#padding? ⇒ Boolean
# === padding? ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#reset_game_state_variables ⇒ Object
# === reset_game_state_variables ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
Class Method Details
.run(i = ARGV) ⇒ Object
#
GamesParadise::GUI::Gtk::FourInARowModule.run
#
195 196 197 198 199 200 201 202 203 204 |
# File 'lib/games_paradise/gui/shared_code/four_in_a_row/four_in_a_row_module.rb', line 195 def self.run( i = ARGV ) require 'gtk_paradise/run' _ = ::GamesParadise::GUI::Gtk::FourInARow.new(i) r = ::Gtk.run r << _ r.automatic_size_and_automatic_title r.top_left_then_run end |
Instance Method Details
#border_size? ⇒ Boolean
#
border_size?
#
136 137 138 |
# File 'lib/games_paradise/gui/shared_code/four_in_a_row/four_in_a_row_module.rb', line 136 def border_size? 2 end |
#check_for_win_condition ⇒ Object
#
check_for_win_condition
This method is called to check whether the win-condition has been met.
#
221 222 |
# File 'lib/games_paradise/gui/shared_code/four_in_a_row/four_in_a_row_module.rb', line 221 def check_for_win_condition end |
#connect_skeleton ⇒ Object
#
connect_skeleton (connect tag)
#
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/games_paradise/gui/shared_code/four_in_a_row/four_in_a_row_module.rb', line 149 def connect_skeleton abort_on_exception ::Gtk::Grid.reset_the_grid_top_position @counter = 0 @grid = gtk_grid @grid.bblack1 @grid.no_column_spacing @grid.no_row_spacing # @grid.width_height(800, 400) @grid.set_border_width(25) @array_game_map = Array.new(n_rows?) { Array.new(n_columns?) } # ======================================================================= # # Populate it next. # ======================================================================= # n_rows?.times {|row_index| n_columns?.times {|inner_column_index| # button = gtk_button(' ') # (@counter + 1).to_s.rjust(2,' ') = GamesParadise::GUI::Gtk::GameButton.new .on_clicked { () } .no_relief .css_class('pad0px') @array_game_map[row_index][inner_column_index] = @grid.left(, inner_column_index) @counter += 1 } @grid.new_row } minimal(gtk_left_aligned_label('Four in a row game')) hbox = gtk_hbox hbox.minimal(@grid, 5) hbox.minimal(text('Here shall come player-data')) add(hbox) end |
#create_skeleton ⇒ Object
#
create_skeleton (create tag)
#
143 144 |
# File 'lib/games_paradise/gui/shared_code/four_in_a_row/four_in_a_row_module.rb', line 143 def create_skeleton end |
#do_change_the_status_of_this_button(button) ⇒ Object
#
do_change_the_status_of_this_button
#
209 210 211 212 213 214 |
# File 'lib/games_paradise/gui/shared_code/four_in_a_row/four_in_a_row_module.rb', line 209 def () .set_text('OK') .add_css_class('BG_yellow') check_for_win_condition # remove_class('BG_yellow') end |
#initialize(commandline_arguments = ARGV, run_already = true) ⇒ Object
#
initialize
#
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/games_paradise/gui/shared_code/four_in_a_row/four_in_a_row_module.rb', line 51 def initialize( commandline_arguments = ARGV, run_already = true ) super(:vertical) reset set_commandline_arguments( commandline_arguments ) run if run_already end |
#n_columns? ⇒ Boolean
#
n_columns?
#
122 123 124 |
# File 'lib/games_paradise/gui/shared_code/four_in_a_row/four_in_a_row_module.rb', line 122 def n_columns? @n_columns end |
#n_rows? ⇒ Boolean
#
n_rows?
#
115 116 117 |
# File 'lib/games_paradise/gui/shared_code/four_in_a_row/four_in_a_row_module.rb', line 115 def n_rows? @n_rows end |
#padding? ⇒ Boolean
#
padding?
#
129 130 131 |
# File 'lib/games_paradise/gui/shared_code/four_in_a_row/four_in_a_row_module.rb', line 129 def padding? 2 end |
#reset ⇒ Object
#
reset (reset tag)
#
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/games_paradise/gui/shared_code/four_in_a_row/four_in_a_row_module.rb', line 66 def reset reset_the_internal_variables # ======================================================================= # # === @configuration # ======================================================================= # @configuration = [true, __dir__, NAMESPACE] # ======================================================================= # # === @title # ======================================================================= # @title = TITLE # ======================================================================= # # === @width # ======================================================================= # set_width(WIDTH) # ======================================================================= # # === @height # ======================================================================= # set_height(HEIGHT) set_use_this_font(USE_THIS_FONT) use_gtk_paradise_project_css_file # or use use_project_css_file infer_the_size_automatically reset_game_state_variables end |
#reset_game_state_variables ⇒ Object
#
reset_game_state_variables
#
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/games_paradise/gui/shared_code/four_in_a_row/four_in_a_row_module.rb', line 93 def reset_game_state_variables # ======================================================================= # # === @game_over # ======================================================================= # @game_over = false # ======================================================================= # # === @array_game_map # ======================================================================= # @array_game_map = [] # ======================================================================= # # === @n_rows # ======================================================================= # @n_rows = 5 # ======================================================================= # # === @n_columns # ======================================================================= # @n_columns = 10 end |
#run ⇒ Object
#
run (run tag)
#
188 189 190 |
# File 'lib/games_paradise/gui/shared_code/four_in_a_row/four_in_a_row_module.rb', line 188 def run create_skeleton_then_connect_skeleton end |