Module: GamesParadise::GUI::Gtk::Mastermind::BlackWhiteBoxModule

Includes:
Gtk::BaseModule
Included in:
BlackWhiteBox
Defined in:
lib/games_paradise/mastermind/shared_code/black_white_box_module.rb

Constant Summary collapse

NAMESPACE =
#

NAMESPACE

#
inspect
TITLE =
#

TITLE

#
'Black White Box Module'
WIDTH =
#

WIDTH

#
1200
HEIGHT =
#

HEIGHT

#
1000

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.runObject

#

GamesParadise::GUI::Gtk::BlackWhiteBoxModule.run

#


135
136
137
138
139
140
141
142
# File 'lib/games_paradise/mastermind/shared_code/black_white_box_module.rb', line 135

def self.run
  require 'gtk_paradise/run'
  _ = ::GamesParadise::GUI::Gtk::BlackWhiteBox.new
  r = ::Gtk.run
  r << _
  r.set_size_request(_.width?, _.height?)
  r.top_left_then_run
end

Instance Method Details

#create_black_imgObject

#

create_black_img

#


93
94
95
# File 'lib/games_paradise/mastermind/shared_code/black_white_box_module.rb', line 93

def create_black_img
  gtk_image(DIRECTORY_TO_THE_IMAGES+'DOT_BLACK.png')
end

#create_blank_imgObject

#

create_blank_img

#


79
80
81
# File 'lib/games_paradise/mastermind/shared_code/black_white_box_module.rb', line 79

def create_blank_img
  gtk_image(DIRECTORY_TO_THE_IMAGES+'DOT_BLANK.png')
end

#create_white_imgObject

#

create_white_img

#


86
87
88
# File 'lib/games_paradise/mastermind/shared_code/black_white_box_module.rb', line 86

def create_white_img
  gtk_image(DIRECTORY_TO_THE_IMAGES+'DOT_GREY.png')
end

#initialize(reveal_or_dont_reveal = false) ⇒ Object

#

initialize

#


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/games_paradise/mastermind/shared_code/black_white_box_module.rb', line 48

def initialize(
    reveal_or_dont_reveal = false
  )
  super(:horizontal)
  reset
  show
  @array_boxes = []
  @array_boxes[0] = create_blank_img
  pack_maximal(@array_boxes[0],1)
  @array_boxes[1] = create_blank_img
  pack_maximal(@array_boxes[1],1)
  @array_boxes[2] = create_blank_img
  pack_maximal(@array_boxes[2],1)
  @array_boxes[3] = create_blank_img
  pack_maximal(@array_boxes[3],1)
end

#resetObject

#

reset

#


68
69
70
71
72
73
74
# File 'lib/games_paradise/mastermind/shared_code/black_white_box_module.rb', line 68

def reset
  reset_the_internal_variables
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, NAMESPACE]
end

#set_boxes(black = 1, white = 3) ⇒ Object

#

set_boxes

#


100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/games_paradise/mastermind/shared_code/black_white_box_module.rb', line 100

def set_boxes(black = 1, white = 3)
  # e "Black: "+black.to_s
  # e "White: "+white.to_s
  counter = 0
  black = black.to_i
  white = white.to_i
  black.times {
    if ::Gtk.use_gtk2?
      @array_boxes[counter].set("#{DIRECTORY_TO_THE_IMAGES}DOT_BLACK.png")
    else
      @array_boxes[counter].set_file("#{DIRECTORY_TO_THE_IMAGES}DOT_BLACK.png")
    end
    counter += 1
  }
  white.times {
    if ::Gtk.use_gtk2?
      @array_boxes[counter].set("#{DIRECTORY_TO_THE_IMAGES}DOT_GREY.png")
    else
      @array_boxes[counter].set_file("#{DIRECTORY_TO_THE_IMAGES}DOT_GREY.png")
    end
    counter += 1
  }
  (4-counter).times {
    if ::Gtk.use_gtk2?
      @array_boxes[counter].set("#{DIRECTORY_TO_THE_IMAGES}DOT_BLANK.png")
    else
      @array_boxes[counter].set_file("#{DIRECTORY_TO_THE_IMAGES}DOT_BLANK.png")
    end
    counter += 1
  }
end