Module: GamesAndRpgParadise::GUI::Gtk::Mastermind::CircleModule
- Includes:
- Gtk::BaseModule
- Included in:
- Circle
- Defined in:
- lib/games_and_rpg_paradise/games/mastermind/shared_code/circle_module.rb
Constant Summary collapse
- TITLE =
#
TITLE
#
'Mastermind Circle Module'
- WIDTH =
#
WIDTH
#
1200
- HEIGHT =
#
HEIGHT
#
1000
Class Method Summary collapse
-
.run(i = ARGV) ⇒ Object
# === GamesAndRpgParadise::GUI::Gtk::Mastermind::CircleModule.run ========================================================================= #.
Instance Method Summary collapse
-
#attach_image(this_colour = 'rand') ⇒ Object
(also: #change_image)
# === attach_image.
-
#border_size? ⇒ Boolean
# === border_size? ========================================================================= #.
-
#colour? ⇒ Boolean
(also: #colour)
# === colour? ========================================================================= #.
-
#initialize(colour = '', parent_widget = nil, sensitive_mode = false) ⇒ Object
# === initialize ========================================================================= #.
-
#next?(colour) ⇒ Boolean
# === next? ========================================================================= #.
-
#padding? ⇒ Boolean
# === padding? ========================================================================= #.
-
#previous?(colour) ⇒ Boolean
# === previous? ========================================================================= #.
-
#remove_image ⇒ Object
# === remove_image ==================================================================== #.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#set_blank ⇒ Object
# === set_blank.
-
#set_parent_widget(i) ⇒ Object
# === set_parent_widget ========================================================================= #.
-
#use_this_colour=(i) ⇒ Object
# === use_this_colour? ==================================================================== #.
Class Method Details
.run(i = ARGV) ⇒ Object
#
GamesAndRpgParadise::GUI::Gtk::Mastermind::CircleModule.run
#
223 224 225 226 227 228 229 230 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/circle_module.rb', line 223 def self.run(i = ARGV) require 'gtk_paradise/run' _ = ::GamesAndRpgParadise::GUI::Gtk::Mastermind::CircleRange.new(i) r = ::Gtk.run r << _ r.set_size_request(_.width?, _.height?) r.top_left_then_run end |
Instance Method Details
#attach_image(this_colour = 'rand') ⇒ Object Also known as: change_image
#
attach_image
Also removes the image before we continue.
#
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/circle_module.rb', line 162 def attach_image( this_colour = 'rand' ) remove_image this_colour = ARRAY_COLOURS.sample if this_colour == 'rand' @colour = this_colour case this_colour when 'red' then _ = ::GamesAndRpgParadise::GUI::Gtk::Mastermind::CIRCLE_RED when 'blue' then _ = ::GamesAndRpgParadise::GUI::Gtk::Mastermind::CIRCLE_BLUE when 'green' then _ = ::GamesAndRpgParadise::GUI::Gtk::Mastermind::CIRCLE_GREEN when 'yellow' then _ = ::GamesAndRpgParadise::GUI::Gtk::Mastermind::CIRCLE_YELLOW when 'orange' then _ = ::GamesAndRpgParadise::GUI::Gtk::Mastermind::CIRCLE_ORANGE when 'violet' then _ = ::GamesAndRpgParadise::GUI::Gtk::Mastermind::CIRCLE_VIOLET when 'blank','' then _ = ::GamesAndRpgParadise::GUI::Gtk::Mastermind::CIRCLE_BLANK else puts 'BUG... this_colour seems to not exist:' puts this_colour end @pic = create_image(DIRECTORY_TO_THE_IMAGES+'games/misc/'+_) set_image(@pic) if @pic end |
#border_size? ⇒ Boolean
#
border_size?
#
112 113 114 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/circle_module.rb', line 112 def border_size? 2 end |
#colour? ⇒ Boolean Also known as: colour
#
colour?
#
216 217 218 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/circle_module.rb', line 216 def colour? @colour end |
#initialize(colour = '', parent_widget = nil, sensitive_mode = false) ⇒ Object
#
initialize
#
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/circle_module.rb', line 49 def initialize( colour = '', = nil, sensitive_mode = false ) super() reset () @colour = colour set_sensitive(sensitive_mode) attach_image(@colour) set_size_request(26,26) { |, event| if ::Gtk.use_gtk2? use_this_event = Gdk::Event::BUTTON_PRESS else use_this_event = :button_press end if event.event_type == use_this_event if event. == 1 # linke maustaste change_image(next?(@colour)) elsif event. == 3 # rechte maustaste change_image(previous?(@colour)) end end } no_relief end |
#next?(colour) ⇒ Boolean
#
next?
#
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/circle_module.rb', line 136 def next?(colour) case colour when 'blank','rand','',nil @colour = ARRAY_COLOURS[0] when 'violet' @colour = 'blank' when 'red' @colour = ARRAY_COLOURS[1] when 'blue' @colour = ARRAY_COLOURS[2] when 'green' @colour = ARRAY_COLOURS[3] when 'yellow' @colour = ARRAY_COLOURS[4] when 'orange' @colour = ARRAY_COLOURS[5] else e ::Colours.swarn('ERROR: not found colour: '+colour.to_s) end end |
#padding? ⇒ Boolean
#
padding?
#
105 106 107 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/circle_module.rb', line 105 def padding? 2 end |
#previous?(colour) ⇒ Boolean
#
previous?
#
119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/circle_module.rb', line 119 def previous?(colour) case colour when 'red' then @colour = 'blank' when 'blue' then @colour = ARRAY_COLOURS[0] when 'green' then @colour = ARRAY_COLOURS[1] when 'yellow' then @colour = ARRAY_COLOURS[2] when 'orange' then @colour = ARRAY_COLOURS[3] when 'violet' then @colour = ARRAY_COLOURS[4] when 'blank','rand' then @colour = ARRAY_COLOURS[5] else e swarn('ERROR!!!') end end |
#remove_image ⇒ Object
#
remove_image
#
204 205 206 207 208 209 210 211 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/circle_module.rb', line 204 def remove_image unless @flag_image_blank == true set_image( gtk_image(DIRECTORY_TO_THE_IMAGES+'games/misc/'+CIRCLE_BLANK) ) @flag_image_blank = true end end |
#reset ⇒ Object
#
reset
#
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/circle_module.rb', line 82 def reset reset_the_internal_variables infer_the_namespace # ======================================================================= # # === @configuration # ======================================================================= # @configuration = [true, __dir__, namespace?] title_width_height(TITLE, WIDTH, HEIGHT) @flag_image_blank = false # flag is false at beginning set_use_this_font(:dejavu_condensed_25) use_project_css_file end |
#set_blank ⇒ Object
#
set_blank
Blanks out our image again.
#
197 198 199 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/circle_module.rb', line 197 def set_blank attach_image('blank') end |
#set_parent_widget(i) ⇒ Object
#
set_parent_widget
#
98 99 100 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/circle_module.rb', line 98 def (i) @parent_widget = i end |
#use_this_colour=(i) ⇒ Object
#
use_this_colour?
#
187 188 189 190 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/circle_module.rb', line 187 def use_this_colour=(i) @colour = i attach_image(@colour) end |