Class: GamesAndRpgParadise::GUI::Gtk::Solitaire
- Inherits:
-
Gtk::Box
- Object
- Gtk::Box
- GamesAndRpgParadise::GUI::Gtk::Solitaire
show all
- Includes:
- Gtk::BaseModule
- Defined in:
- lib/games_and_rpg_paradise/gui/gtk3/solitaire/solitaire.rb
Overview
GamesAndRpgParadise::GUI::Gtk::Solitaire
Constant Summary
collapse
- TITLE =
'Solitaire'
- WIDTH =
'85% or minimum 1200px'
- HEIGHT =
'15% or minimum 100px'
- LARGER_FONT =
:dejavu_condensed_20
- USE_THIS_FONT =
:dejavu_condensed_18
- SMALLER_FONT =
:dejavu_condensed_15
- DIRECTORY_TO_THE_SOLITAIRE_CARDS =
#
DIRECTORY_TO_THE_SOLITAIRE_CARDS
#
::GamesAndRpgParadise.project_base_directory?+
'images/solitaire/'
- ARRAY_AVAILABLE_CARD_IMAGES =
#
ARRAY_AVAILABLE_CARD_IMAGES
This array will initially contain all playable cards - thus excluding the blank/cover variant.
#
Dir[
DIRECTORY_TO_THE_SOLITAIRE_CARDS+'**/**.png'
].reject {|entry| entry.include? 'cover/' }
- FILE_BLANK_IMAGE_CARD =
#
FILE_BLANK_IMAGE_CARD
#
"#{DIRECTORY_TO_THE_SOLITAIRE_CARDS}cover/cover.png"
Class Method Summary
collapse
-
.run(i = ARGV) ⇒ Object
# === GamesAndRpgParadise::GUI::Gtk::Solitaire.run ========================================================================= #.
Instance Method Summary
collapse
Constructor Details
#initialize(commandline_arguments = ARGV, run_already = true) ⇒ Solitaire
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/solitaire/solitaire.rb', line 81
def initialize(
commandline_arguments = ARGV,
run_already = true
)
super(:vertical)
reset
set_commandline_arguments(
commandline_arguments
)
run if run_already
end
|
Class Method Details
.run(i = ARGV) ⇒ Object
#
GamesAndRpgParadise::GUI::Gtk::Solitaire.run
#
278
279
280
281
282
283
284
285
286
287
288
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/solitaire/solitaire.rb', line 278
def self.run(
i = ARGV
)
require 'gtk_paradise/run'
_ = ::GamesAndRpgParadise::GUI::Gtk::Solitaire.new(i)
r = ::Gtk.run
r << _
r.automatic_size_then_automatic_title
r.enable_quick_exit
r.top_left_then_run
end
|
Instance Method Details
#available_stacks? ⇒ Boolean
231
232
233
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/solitaire/solitaire.rb', line 231
def available_stacks?
@solitaire.stacks?
end
|
#border_size? ⇒ Boolean
129
130
131
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/solitaire/solitaire.rb', line 129
def border_size?
0
end
|
#connect_skeleton ⇒ Object
#
connect_skeleton (connect tag)
#
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/solitaire/solitaire.rb', line 170
def connect_skeleton
abort_on_exception
_ = label(' Solitaire Game ')
_.use_this_font = LARGER_FONT
_.hcenter
_.pad8px
_.use_this_colour = :darkblue
minimal(_, 2)
@grid = default_grid
@grid.spacing = 8
@grid.left(
blank_image_card
)
(n_stacks_are_available? - (4+1)).times {|n_iteration_run|
@grid.left(image)
}
@array_stack_positions = []
@array_stack_positions << return_blank_image_card
@array_stack_positions << return_blank_image_card
@array_stack_positions << return_blank_image_card
@array_stack_positions << return_blank_image_card
@grid.left(@array_stack_positions[0])
@grid.middle(@array_stack_positions[1])
@grid.middle(@array_stack_positions[2])
@grid.right(@array_stack_positions[3])
@grid.new_row
minimal(@grid, 25)
n_available_stacks?.times {|entry| entry += 1
text = 'Stack #'+entry.to_s
_ = button(text)
_.use_this_font = SMALLER_FONT
_.no_border
_.on_clicked {
file_path = @array_stacks[entry.to_i - 1]
e file_path
if File.exist? file_path
stack_number(
return_the_correct_stack_based_on_this_file_path(file_path)
).set_path(file_path)
end
}
@grid.append_this_widget(_)
}
@grid.new_row
available_stacks?.each {|array|
card = array.last
e ::Colours.tomato('Debug!!! info: ')+
::Colours.lightblue(card)
_ = return_random_image_card
@array_stacks << _.last
@grid.append_this_widget(_.first)
}
@grid.new_row
end
|
#create_skeleton ⇒ Object
#
create_skeleton (create tag, skeleton tag)
#
136
137
138
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/solitaire/solitaire.rb', line 136
def create_skeleton
end
|
#n_stacks_are_available? ⇒ Boolean
Also known as:
n_available_stacks?
#
n_stacks_are_available?
#
264
265
266
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/solitaire/solitaire.rb', line 264
def n_stacks_are_available?
available_stacks?.size
end
|
#padding? ⇒ Boolean
122
123
124
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/solitaire/solitaire.rb', line 122
def padding?
0
end
|
#reset ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/solitaire/solitaire.rb', line 96
def reset
reset_the_internal_variables
infer_the_namespace
@configuration = [true, __dir__, namespace?]
title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT)
use_gtk_paradise_project_css_file
infer_the_size_automatically
@solitaire = GamesAndRpgParadise::Solitaire::Solitaire.new
@array_stacks = []
end
|
#return_blank_image_card(_ = FILE_BLANK_IMAGE_CARD) ⇒ Object
Also known as:
blank_image_card
#
return_blank_image_card
#
143
144
145
146
147
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/solitaire/solitaire.rb', line 143
def return_blank_image_card(
_ = FILE_BLANK_IMAGE_CARD
)
image(_)
end
|
#return_random_image_card ⇒ Object
#
return_random_image_card
#
#return_the_correct_stack_based_on_this_file_path(file_path) ⇒ Object
#
return_the_correct_stack_based_on_this_file_path
This method must return a number such as 1, 2, 3 or 4, representing the stacks; or nil if no such match can be made.
The file path that this method may use could look like this:
/home/Programs/Ruby/3.1.2/lib/ruby/site_ruby/3.1.0/games_paradise/images/solitaire/diamonds/six.png
#
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/solitaire/solitaire.rb', line 246
def return_the_correct_stack_based_on_this_file_path(file_path)
case file_path
when /\/hearts\//
1
when /\/diamonds\//
2
when /\/clubs\//
3
when /\/spades\//
4
else
nil
end
end
|
#run ⇒ Object
271
272
273
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/solitaire/solitaire.rb', line 271
def run
super()
end
|
#stack_number(i = 1) ⇒ Object
#
stack_number
Stack number 1 is the most-left stack image.
#
163
164
165
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/solitaire/solitaire.rb', line 163
def stack_number(i = 1)
@array_stack_positions[i.to_i - 1]
end
|