Module: GamesAndRpgParadise::GUI::MagicTheGathering::CardCollectionModule

Includes:
Base::Extensions
Included in:
Gtk::CardCollection, Gtk::InformationWidget, LibUI::CardCollection
Defined in:
lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb

Constant Summary collapse

LOG_DIR =
#

LOG_DIR

#
::GamesAndRpgParadise::MagicTheGathering.log_dir?
TITLE =
#

TITLE

#
'Card Collection'
WIDTH =
#

WIDTH

#
'78% or minimum 480px'
HEIGHT =
#

HEIGHT

#
'55% or minimum 320px'
COLOUR_FOR_THE_LABEL_SHOWING_THE_CORRECT_DATE =
#

COLOUR_FOR_THE_LABEL_SHOWING_THE_CORRECT_DATE

#
:midnightblue
USE_THIS_FONT =
#

USE_THIS_FONT

#
:dejavu_condensed_20
SMALLER_FONT =
#

SMALLER_FONT

#
:dejavu_condensed_19
SMALLEST_FONT =
#

SMALLEST_FONT

#
:dejavu_condensed_17
SUPER_SMALL_FONT =
#

SUPER_SMALL_FONT

#
:dejavu_condensed_12
ARRAY_CONTAINING_INFORMATION_ABOUT_ALL_CARDS =
#

ARRAY_CONTAINING_INFORMATION_ABOUT_ALL_CARDS

#
GamesAndRpgParadise::MagicTheGathering::ARRAY_CHECKED_CARD_TYPES
BLANK_IMAGE =
#

BLANK_IMAGE

#
DIRECTORY_TO_THE_IMAGES_OF_THE_THEME_SYMBOLS+
'blank_image.png'
ARRAY_RARITY =
#

ARRAY_RARITY

#
%w( rare uncommon common )
DIRECTORY_CONTAINING_THE_INDIVIDUAL_CARDS_BELONGING_TO_A_THEME =
#

DIRECTORY_CONTAINING_THE_INDIVIDUAL_CARDS_BELONGING_TO_A_THEME

#
::GamesAndRpgParadise.project_base_directory?+
'yaml/magic_the_gathering/theme/'

Constants included from CommonExtensions

CommonExtensions::CONTROL_C_CODE, CommonExtensions::N

Instance Method Summary collapse

Methods included from Base::Extensions::CommandlineArguments

#commandline_arguments?, #filter_away_commandline_arguments, #first_argument?, #first_non_hyphened_argument?, #set_commandline_arguments

Methods included from CommonExtensions

#cat, #cd, #cliner, #copy_file, #delete, #dirname_but_retains_the_trailing_slash, #disable_colours, #ensure_that_the_log_directory_exists, #esystem, #get_user_input, #infer_the_namespace, #is_on_roebe?, #log_dir?, #mkdir, #mkdir_then_cd_into_it, #mv, #namespace?, #opne, #opnn, #project_base_directory?, #project_image_directory?, #project_yaml_directory?, #rds, #register_sigint, #remove_this_directory, #rename_file, #reset, #reset_the_internal_hash, #return_pwd, #return_today, #touch_file, #wrap, #write_what_into

Instance Method Details

#base_dir?Boolean

#

base_dir?

#

Returns:

  • (Boolean)


756
757
758
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 756

def base_dir?
  File.dirname(yaml_file?)+'/'
end

#border_size?Boolean

#

border_size?

#

Returns:

  • (Boolean)


132
133
134
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 132

def border_size?
  6
end

#cost?Boolean

#

cost?

This will return a Float. You need to use .to_s if you need a String.

#

Returns:

  • (Boolean)


318
319
320
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 318

def cost?
  entry_for_the_cost?.text?.to_f
end

#create_the_buttonsObject

#

create_the_buttons (buttons tag, button tag)

#


1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 1280

def create_the_buttons
  # ======================================================================= #
  # === @button_save_the_information
  # ======================================================================= #
  @button_save_the_information = button('_Save')
  @button_save_the_information.clear_background
  @button_save_the_information.on_hover(:lightblue)
  @button_save_the_information.pad8px
  @button_save_the_information.bblack2
  @button_save_the_information.width_height(150, 40)
  @button_save_the_information.hint = 'Click this button '\
    'to save the dataset entered into a local yaml '\
    '(<b>.yml</b>) file.'
  @button_save_the_information.on_clicked {
    do_save_the_information
  }
end

#create_the_combo_boxObject

#

create_the_combo_box

#


619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 619

def create_the_combo_box
  # ======================================================================= #
  # It is better to keep the array sorted alphabetically.
  # ======================================================================= #
  sorted_array = GamesAndRpgParadise::MagicTheGathering.available_themes?.sort
  # ======================================================================= #
  # Next we will remove the theme "Planechase" since it is a special
  # format - I was unable to find proper card lists easily for that
  # format.
  # ======================================================================= #
  sorted_array -= %w( Planechase )
  # ======================================================================= #
  # === @combo_box_containing_the_themes
  # ======================================================================= #
  @combo_box_containing_the_themes = combo_box_entry(
    sorted_array
  )
  @combo_box_containing_the_themes.use_this_font = smaller_font?
  @combo_box_containing_the_themes.bblack1
  @combo_box_containing_the_themes.the_first_entry_is_active
end

#create_the_labelsObject

#

create_the_labels (labels tag, label tag)

#


1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 1264

def create_the_labels
  # ======================================================================= #
  # === @label_for_the_correct_date_entry_aka_the_year
  # ======================================================================= #
  @label_for_the_correct_date_entry_aka_the_year = label
  @label_for_the_correct_date_entry_aka_the_year.use_this_font = smallest_font?
  @label_for_the_correct_date_entry_aka_the_year.hint = 'This text '\
    'indicates when the given theme was released first.'
  @label_for_the_correct_date_entry_aka_the_year.css_class(
    COLOUR_FOR_THE_LABEL_SHOWING_THE_CORRECT_DATE
  )
end

#create_the_small_spinnerObject

#

create_the_small_spinner

#


352
353
354
355
356
357
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 352

def create_the_small_spinner
  # ======================================================================= #
  # === @small_spinner
  # ======================================================================= #
  @small_spinner = return_the_up_and_down_spinner
end

#current_theme?Boolean Also known as: combobox_text?

#

current_theme?

#

Returns:

  • (Boolean)


881
882
883
884
885
886
887
888
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 881

def current_theme?
  _ = ''.dup # This will be our default result.
  if @combo_box_containing_the_themes and
     @combo_box_containing_the_themes.text?
    _ << @combo_box_containing_the_themes.text?.to_s
  end
  return _
end

#delay_show_the_guessed_imageObject

#

delay_show_the_guessed_image

#


675
676
677
678
679
680
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 675

def delay_show_the_guessed_image
  Thread.new {
    sleep 0.04
    do_display_the_appropriate_card
   }
end

#determine_the_rarity_based_on_this_mouse_movement(movement_type = :up) ⇒ Object

#

determine_the_rarity_based_on_this_mouse_movement

#


717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 717

def determine_the_rarity_based_on_this_mouse_movement(
    movement_type = :up
  )
  new_rarity = ''
  current_rarity_value = @entry4.text?
  if current_rarity_value.empty?
    case movement_type
    when :up
      new_rarity = 'common'
    end
  else # else we have an old entry
    case current_rarity_value
    when 'common'
      new_rarity = 'uncommon' if movement_type == :up
    when 'uncommon'
      case movement_type
      when :up
        new_rarity = 'rare'
      when :down
        new_rarity = 'common'
      end
    # ===================================================================== #
    # === rare
    # ===================================================================== #
    when 'rare'
      case movement_type
      when :up
        new_rarity = 'rare'
      when :down
        new_rarity = 'uncommon'
      end
    end
  end
  @entry4.set_text(new_rarity)
end

#determine_whether_the_current_theme_is_available_locally_or_notObject

#

determine_whether_the_current_theme_is_available_locally_or_not

#


847
848
849
850
851
852
853
854
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 847

def determine_whether_the_current_theme_is_available_locally_or_not
  _ = return_the_assumed_local_path_to_the_directory_containing_the_images
  if File.directory? _
    return the_current_theme_is_available_locally_as_well
  else
    return the_current_theme_is_not_available_locally
  end
end

#do_all_actions_associated_with_the_main_combo_box_containing_the_themesObject Also known as: sync_the_combo_box_onto_its_corresponding_entry

#

do_all_actions_associated_with_the_main_combo_box_containing_the_themes

#


1251
1252
1253
1254
1255
1256
1257
1258
1259
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 1251

def do_all_actions_associated_with_the_main_combo_box_containing_the_themes
  @entry2.set_text(current_theme?.downcase)
  do_update_the_correct_date_entry
  try_to_show_the_correct_theme_icon
  do_set_the_correct_completion_model_for_entry1
  determine_whether_the_current_theme_is_available_locally_or_not
  update_the_tooltip_belonging_to_the_image_containing_the_graphical_checkbox_for_determining_local_images_availability
  update_the_n_local_cards_text_label
end

#do_change_to_use_another_model_for_the_main_entry(use_this_theme = 'Avacyn_Restored') ⇒ Object

#

do_change_to_use_another_model_for_the_main_entry

This method will only work if @entry1 has been defined.

#


646
647
648
649
650
651
652
653
654
655
656
657
658
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 646

def do_change_to_use_another_model_for_the_main_entry(
    use_this_theme = 'Avacyn_Restored'
  )
  this_file = return_all_cards_belonging_to_this_theme(use_this_theme)
  if File.exist? this_file
    array = YAML.load_file(this_file)
    if array and array.is_a?(Array)
      @entry1.simple_completion(array)
    end
  else
    e "No file could be found at `#{sfile(this_file)}`."
  end
end

#do_delete_the_yaml_datasetObject

#

do_delete_the_yaml_dataset

#


300
301
302
303
304
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 300

def do_delete_the_yaml_dataset
  do_save_this_dataset_into_the_yaml_file(
    YAML.dump({})
  )
end

#do_open_the_remote_profileObject

#

do_open_the_remote_profile

#


1188
1189
1190
1191
1192
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 1188

def do_open_the_remote_profile
  remote_URL = BeautifulUrl[:profile_at_magic_shop]
  e 'Trying to open the remote URL at '+remote_URL+' next.'
  Open.in_browser(remote_URL)
end

#do_open_the_remote_webpage_for_the_current_cardObject

#

do_open_the_remote_webpage_for_the_current_card

#


1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 1219

def do_open_the_remote_webpage_for_the_current_card
  remote_URL = return_the_URL_for_cardmarket_based_on_the_entries.to_s.dup
  if remote_URL.include? "'"
    remote_URL.tr!("'",'-')
  end
  e "Trying to open the remote URL at #{remote_URL} next."
  Open.in_browser(remote_URL) {{
    use_this_browser: @entry_use_this_browser.text?.to_s
  }} 
end

#do_save_the_informationObject Also known as: do_save_the_dataset

#

do_save_the_information (save tag)

This is the method that will store our dataset into the .yml file.

Whenever it is called we will first check whether an old .yml file exists. If so then the content is loaded before any modification is done.

#


546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 546

def do_save_the_information
  # ======================================================================= #
  # First we do a little bit sanitizing.
  # ======================================================================= #
  sanitize_the_entry_for_the_name_of_the_card
  sanitize_the_entry_for_the_cost # Do a little bit sanitizing stuff here.
  sanitize_the_entry_for_the_rarity_of_the_card
  # ======================================================================= #
  # First build our hash.
  # ======================================================================= #
  hash = {}
  # ======================================================================= #
  # Load an existing .yml file next:
  # ======================================================================= #
  _ = yaml_file?
  if _ and File.exist?(_)
    hash.merge!(YAML.load_file(_))
  end
  new_hash = {}
  new_hash[:name_of_the_card] = name_of_the_card?
  new_hash[:theme]   = theme?
  new_hash[:rarity]  = rarity?
  new_hash[:cost]    = cost?
  new_hash[:n_cards] = n_cards?
  new_hash[:is_foil] = foil_yes_or_no?
  hash[name_of_the_card?] = new_hash
  what = YAML.dump(hash)
  do_save_this_dataset_into_the_yaml_file(
    what, @yaml_file, original_hash = hash
  )
  @information_widget.update_the_label_n_cards_registered
end

#do_save_this_dataset_into_the_yaml_file(what, into = @yaml_file, optional_original_hash = {}) ⇒ Object

#

do_save_this_dataset_into_the_yaml_file

This is the “raw” save-into-yaml-file functionality.

#


443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 443

def do_save_this_dataset_into_the_yaml_file(
    what, into = @yaml_file, optional_original_hash = {}
  )
  # ======================================================================= #
  # First we will try to create the directory if it does not exist yet.
  # ======================================================================= #
  unless File.directory? base_dir?
    mkdir(base_dir?)
  end
  if File.directory? base_dir?
    e "Storing into `#{into}` next."
    SaveFile.write_what_into(what, into)
    if is_on_roebe?
      SaveFile.write_what_into(what, '/tmp/'+File.basename(into))
      # =================================================================== #
      # Some debug information for me. Disabled as of 30.10.2021 - who
      # knows if we still need it. If not then perhaps it should be
      # removed next year.
      # =================================================================== #
      # e 'Debug information for me:'; pp what
      # We will also store into a .json file, so that we can re-use the
      # dataset via JavaScript eventually.
      # =================================================================== #
      json_format = optional_original_hash.to_json
      into = @yaml_file.delete_suffix(File.extname(@yaml_file))+'.json'
      e "Storing into `#{into}` next."
      SaveFile.write_what_into(json_format, into)
      SaveFile.write_what_into(what, '/tmp/'+File.basename(into))
    end
  else
    e "No directory exists at `#{base_dir}`."
  end
end

#do_set_the_correct_completion_model_for_entry1(i = combobox_text? ) ⇒ Object

#

do_set_the_correct_completion_model_for_entry1

#


405
406
407
408
409
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 405

def do_set_the_correct_completion_model_for_entry1(
    i = combobox_text?
  ) 
  do_change_to_use_another_model_for_the_main_entry(i)
end

#do_show_the_modal_popover_containing_all_local_images_belonging_to_the_current_themeObject

#

do_show_the_modal_popover_containing_all_local_images_belonging_to_the_current_theme

#


781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 781

def do_show_the_modal_popover_containing_all_local_images_belonging_to_the_current_theme

  dialog = gtk_dialog
  dialog.set_size_request(800, 900)
  dialog.pad8px
  dialog.add_button(::Gtk::Stock::CLOSE, :close)

  image_viewer = ::Gtk::ImageViewer.new
  image_viewer.show_all
  image_viewer.set_work_on_this_directory(
    return_the_assumed_local_path_to_the_directory_containing_the_images
  )
  image_viewer.do_populate_with_all_discovered_images

  label = text('Available images: '+image_viewer.n_images?.to_s)
  label.use_this_font = main_font?
  label.show
  dialog.child.pack_start(label)

  dialog.child.pack_end(image_viewer)
  dialog.child.show_all

  response = dialog.run

  case response
  when ::Gtk::ResponseType::YES
    e 'The user selected yes.'
  when ::Gtk::ResponseType::NO
    e 'The user selected no.'
  when ::Gtk::ResponseType::CLOSE
    dialog.destroy
  else
    e 'The user selected something else.'
  end

end
#

This method will do startup-related tasks, such as showing the current icon based on the combobox.

#


1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 1021

def do_startup_related_tasks
  sync_the_combo_box_onto_the_current_theme_icon
  sync_the_combo_box_onto_its_corresponding_entry
  entry1?.completion.signal_connect(:match_selected) {|widget, event|
    delay_show_the_guessed_image
    false
  }
  the_current_theme_is_NOT_available_locally
  determine_whether_the_current_theme_is_available_locally_or_not
  update_the_n_local_cards_text_label
end

#do_update_the_correct_date_entry(use_this_entry = @entry2) ⇒ Object

#

do_update_the_correct_date_entry

#


1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 1043

def do_update_the_correct_date_entry(
    use_this_entry = @entry2
  )
  pointer = use_this_entry.text? # This will be e. g. "Zendikar Rising".
  matches = ARRAY_CONTAINING_INFORMATION_ABOUT_ALL_CARDS.select {|inner_array|
    inner_array.first.downcase == pointer.downcase
  }
  # ======================================================================= #
  # Now we have the correct matches. We pick the first entry.
  # ======================================================================= #
  if matches
    first = matches.first
    if first
      _ = first[1]
      if _
        if _.include?(',') or _.include?(' ')
          # =============================================================== #
          # Determine which split-token to use.
          # =============================================================== #
          use_this_split_token = ','
          unless _.include? ','
            use_this_split_token = ' '
          end
          splitted = _.split(use_this_split_token)
          splitted[-1] = '<b>'+splitted[-1]+'</b>'
          _ = splitted.join(use_this_split_token)
        end
        # ================================================================= #
        # We could pad it, but this did not seem to be necessary really.
        # ================================================================= #
        @label_for_the_correct_date_entry_aka_the_year.set_markup_text(_)
      else
        e 'No match was found.'
      end
    else
      e 'No matches were found for '+pointer.to_s+' in the '\
        'method '+__method__.to_s
    end
  else
    e 'No matches were found for '+pointer.to_s+
      ' in the method '+__method__.to_s
  end
end

#does_the_yaml_file_exist?Boolean

#

does_the_yaml_file_exist?

#

Returns:

  • (Boolean)


165
166
167
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 165

def does_the_yaml_file_exist?
  File.exist?(yaml_file?)
end

#entry1?Boolean

#

entry1?

#

Returns:

  • (Boolean)


309
310
311
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 309

def entry1?
  @entry1
end

#entry4?Boolean

#

entry4?

#

Returns:

  • (Boolean)


332
333
334
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 332

def entry4?
  @entry4
end

#entry_for_the_cost?Boolean Also known as: entry5?

#

entry_for_the_cost?

#

Returns:

  • (Boolean)


325
326
327
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 325

def entry_for_the_cost?
  @entry5
end

#entry_for_the_theme?Boolean Also known as: entry2?

#

entry_for_the_theme?

#

Returns:

  • (Boolean)


526
527
528
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 526

def entry_for_the_theme?
  @entry2
end

#foil_yes_or_no?Boolean

#

foil_yes_or_no?

#

Returns:

  • (Boolean)


259
260
261
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 259

def foil_yes_or_no? 
  @checkbox_to_foil_or_not_to_foil.active?
end

#handle_the_action_of_the_event_box_containing_the_image_with_the_graphical_checkbox_for_determining_local_images_availabilityObject

#

handle_the_action_of_the_event_box_containing_the_image_with_the_graphical_checkbox_for_determining_local_images_availability

#


763
764
765
766
767
768
769
770
771
772
773
774
775
776
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 763

def handle_the_action_of_the_event_box_containing_the_image_with_the_graphical_checkbox_for_determining_local_images_availability
  _ = @event_box_containing_the_image_with_the_graphical_checkbox_for_determining_local_images_availability
  _.on_clicked {
    # ===================================================================== #
    # We must distinguish between the situation of where we have local
    # images, and where we don't.
    # ===================================================================== #
    result = determine_whether_the_current_theme_is_available_locally_or_not
    if result
      do_show_the_modal_popover_containing_all_local_images_belonging_to_the_current_theme
    else # else do nothing
    end
  }
end

#handle_the_combo_box_on_changed_eventObject

#

handle_the_combo_box_on_changed_event

#


1090
1091
1092
1093
1094
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 1090

def handle_the_combo_box_on_changed_event
  @combo_box_containing_the_themes.on_changed {
    do_all_actions_associated_with_the_main_combo_box_containing_the_themes
  }
end

#how_many_images_are_available_locally_in_the_current_theme?(work_on_this_entry = entry2? ) ⇒ Boolean

#

how_many_images_are_available_locally_in_the_current_theme?

#

Returns:

  • (Boolean)


995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 995

def how_many_images_are_available_locally_in_the_current_theme?(
    work_on_this_entry = entry2?
  )
  if work_on_this_entry and work_on_this_entry.text?
    name_of_the_theme = work_on_this_entry.text?.downcase.tr(' ','_')
  else
    name_of_the_theme = ''
  end
  name_of_the_theme.delete!(':') if name_of_the_theme.include? ':'
  target = LOG_DIR+name_of_the_theme+'/'
  return Dir[target+'*png'].size
end

#largest_font?Boolean

#

largest_font?

#

Returns:

  • (Boolean)


1113
1114
1115
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 1113

def largest_font?
  USE_THIS_FONT
end

#main_combobox?Boolean Also known as: main_combo_box?

#

main_combobox?

#

Returns:

  • (Boolean)


600
601
602
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 600

def main_combobox?
  @combo_box_containing_the_themes
end

#main_font?Boolean

#

main_font?

#

Returns:

  • (Boolean)


821
822
823
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 821

def main_font?
  USE_THIS_FONT
end

#n_cards?Boolean

#

n_cards?

#

Returns:

  • (Boolean)


391
392
393
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 391

def n_cards?
  @entry3.text?.to_i
end

#n_cards_registered?(use_this_yaml_file = yaml_file? ) ⇒ Boolean

#

n_cards_registered?

#

Returns:

  • (Boolean)


382
383
384
385
386
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 382

def n_cards_registered?(
    use_this_yaml_file = yaml_file?
  )
  return ::GamesAndRpgParadise.n_cards_are_registered_in_the_local_magic_collection?(use_this_yaml_file)
end

#n_cards_registered_in_total?Boolean

#

n_cards_registered_in_total?

#

Returns:

  • (Boolean)


414
415
416
417
418
419
420
421
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 414

def n_cards_registered_in_total?
  _ = 0
  return_all_yaml_theme_files.each {|yaml_file|
    array = YAML.load_file(yaml_file)
    _ += array.size
  }
  return _
end

#name_of_the_card?Boolean

#

name_of_the_card?

#

Returns:

  • (Boolean)


533
534
535
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 533

def name_of_the_card?
  @entry1.text?
end

#padding?Boolean

#

padding?

#

Returns:

  • (Boolean)


125
126
127
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 125

def padding?
  10
end

#rarity?Boolean

#

rarity?

#

Returns:

  • (Boolean)


398
399
400
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 398

def rarity?
  @entry4.text?.downcase
end

#reset_the_shared_moduleObject

#

reset_the_shared_module

#


139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 139

def reset_the_shared_module
  # ======================================================================= #
  # === @title
  # ======================================================================= #
  set_title(TITLE)
  # ======================================================================= #
  # === @width
  # ======================================================================= #
  set_width(WIDTH)
  # ======================================================================= #
  # === @height
  # ======================================================================= #
  set_height(HEIGHT)
  # ======================================================================= #
  # === @yaml_file
  #
  # This is our yaml "database".
  # ======================================================================= #    
  @yaml_file =
    ::GamesAndRpgParadise::MagicTheGathering::
    YAML_FILE_CONTAINING_THE_LOCAL_CARD_COLLECTION_FOR_MAGIC_THE_GATHERING
end

#return_all_cards_belonging_to_this_theme(i = 'Battle_for_Zendikar') ⇒ Object

#

return_all_cards_belonging_to_this_theme

#


508
509
510
511
512
513
514
515
516
517
518
519
520
521
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 508

def return_all_cards_belonging_to_this_theme(
    i = 'Battle_for_Zendikar'
  )
  i = i.dup if i.frozen?
  if i.include? ' '
    i.tr!(' ','_')
  end
  if i.include? "'"
    i.delete!("'")
  end
  i << '.yml' unless i.end_with? '.yml'
  return DIRECTORY_CONTAINING_THE_INDIVIDUAL_CARDS_BELONGING_TO_A_THEME+
         i
end

#return_all_themes?Boolean

#

return_all_themes?

This variant is similar to return_all_yaml_theme_files, but it will return only the names, not other parts.

#

Returns:

  • (Boolean)


986
987
988
989
990
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 986

def return_all_themes?
  return_all_yaml_theme_files.map {|entry|
    File.basename(entry).delete_suffix('.yml')
  }
end

#return_all_yaml_theme_filesObject

#

return_all_yaml_theme_files

#


974
975
976
977
978
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 974

def return_all_yaml_theme_files
  target = "#{::GamesAndRpgParadise.project_directory?}yaml/"\
           "magic_the_gathering/theme/*.yml"
  return Dir[target]
end

#return_amount_of_the_cardObject

#

return_amount_of_the_card

#


234
235
236
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 234

def return_amount_of_the_card
  return left_aligned_text('Amount:')
end

#return_cost_of_the_cardObject

#

return_cost_of_the_card

#


205
206
207
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 205

def return_cost_of_the_card
  return left_aligned_text('Cost:')
end

#return_entry_for_the_amount_of_the_cardObject

#

return_entry_for_the_amount_of_the_card

#


685
686
687
688
689
690
691
692
693
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 685

def return_entry_for_the_amount_of_the_card
  _ = entry('1') # This is the default.'
  _.bblack2
  _.yellowish_background
  _.width_height(300, 25)
  _.shadow_hint = 'Amount ... '
  _.on_enter { do_save_the_dataset }
  return _
end

#return_entry_for_the_cost_of_the_cardObject

#

return_entry_for_the_cost_of_the_card

#


222
223
224
225
226
227
228
229
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 222

def return_entry_for_the_cost_of_the_card
  _ = entry
  _.bblack2
  _.yellowish_background
  _.width_height(300, 25)
  _.shadow_hint = 'Cost ... '
  return _
end

#return_entry_for_the_name_of_the_cardObject

#

return_entry_for_the_name_of_the_card

This entry will include the “Name of the card:” text.

#


1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 1122

def return_entry_for_the_name_of_the_card
  _ = entry
  _.bblack2
  _.yellowish_background
  _.width_height(420, 25)
  _.shadow_hint = 'Name ... '
  this_file = return_all_cards_belonging_to_this_theme(
    GamesAndRpgParadise::MagicTheGathering.most_recent_magic_theme?
  )
  _.respond_to_enter_event
  _.on_enter {
    try_to_match_the_entry_onto_the_main_image_that_is_shown
  }
  if File.exist? this_file
    # ===================================================================== #
    # Set up the initial completion next.
    # ===================================================================== #
    array = YAML.load_file(this_file)
    _.simple_completion(array)
  else
    e 'No file could be found at `'+sfile(this_file)+'`.'
  end
  _.set_scroll_event
  # ======================================================================= #
  # The mouse-scrollwheel can be used to change between different cards.
  # ======================================================================= #
  _.signal_connect(:scroll_event) {|widget, event|
    if scroll_up?(event)
      log_dir = ::GamesAndRpgParadise::MagicTheGathering.log_dir?
      name_of_the_theme = entry2?.text?.downcase.tr(' ','_')
      target = log_dir+name_of_the_theme.delete("':")+'/'
      sample = Dir[target+'*png'].sample
      if sample
        new_name = File.basename(sample).
                   gsub(/_s_/,"'s_").
                   tr('_',' ').squeeze(' ').
                   delete_suffix(File.extname(sample)) 
        entry1?.set_text(new_name)
        use_this_image_as_the_new_card_image(sample)
      else
        e 'No local image was found at '+target.to_s+'.'
        e 'Is the path correct?'
      end
    elsif scroll_down?(event)
      log_dir = ::GamesAndRpgParadise::MagicTheGathering.log_dir?
      name_of_the_theme = entry2?.text?.downcase.tr(' ','_')
      target = log_dir+name_of_the_theme.delete("':")+'/'
      sample = Dir[target+'*png'].sample
      if sample # Must protect against nil-values here.
        new_name = File.basename(sample).gsub(/_s_/,"'s_").
                   tr('_',' ').squeeze(' ').
                   delete_suffix(File.extname(sample)) 
        entry1?.set_text(new_name)
        use_this_image_as_the_new_card_image(sample)
      else
        e 'No local image was found at '+target.to_s+'.'
        e 'Is the path correct?'
      end
    end
  }
  return _
end

#return_entry_for_the_rarity_of_the_cardObject

#

return_entry_for_the_rarity_of_the_card

#


487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 487

def return_entry_for_the_rarity_of_the_card
  _ = entry
  _.bblack2
  _.yellowish_background
  _.width_height(300, 25)
  _.shadow_hint = 'Rarity ... '
  _.simple_completion(ARRAY_RARITY)
  _.enable_scroll_events
  _.signal_connect(:scroll_event) {|widget, event|
    if scroll_up?(event)
      determine_the_rarity_based_on_this_mouse_movement(:up)
    elsif scroll_down?(event)
      determine_the_rarity_based_on_this_mouse_movement(:down)
    end
  }
  return _
end

#return_entry_for_the_theme_of_the_cardObject

#

return_entry_for_the_theme_of_the_card

#


582
583
584
585
586
587
588
589
590
591
592
593
594
595
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 582

def return_entry_for_the_theme_of_the_card
  _ = entry
  _.bblack2
  _.yellowish_background
  _.width_height(350, 25)
  _.shadow_hint = 'Theme ... '
  _.is_read_only
  _.hint =
    'This entry can only be modified via the '\
    'combo-box to its right side. Select the proper theme for '\
    'the magic card. This is mandatory because we need to store '\
    'only correct information into the local .yml file.'
  return _
end

#return_euro_symbolObject

#

return_euro_symbol

#


212
213
214
215
216
217
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 212

def return_euro_symbol
  _ = bold_text('')
  _.hint = 'The default assumption for the cost is in <b>Euro</b>.'
  _.do_markify
  return _
end

#return_name_of_the_cardObject

#

return_name_of_the_card

#


480
481
482
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 480

def return_name_of_the_card
  return left_aligned_text('Name of the card:')
end

#return_rarity_of_the_cardObject

#

return_rarity_of_the_card

#


241
242
243
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 241

def return_rarity_of_the_card
  return left_aligned_text('Rarity:')
end

#return_string_n_cards_registered_in_totalObject

#

return_string_n_cards_registered_in_total

This method will return how many cards are registered in total. This will be based on the .yml files that are distributed by the rpg_paradise gem.

#


430
431
432
433
434
435
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 430

def return_string_n_cards_registered_in_total
  return 'n cards registered in total: '\
         '<b>'+n_cards_registered_in_total?.to_s+'</b>, from <b>'+
         return_all_yaml_theme_files.size.to_s+
         '</b> different themes.'
end

#return_the_assumed_local_path_to_the_directory_containing_the_images(log_dir = ::GamesAndRpgParadise::MagicTheGathering.log_dir?, name_of_the_theme = entry2? ) ⇒ Object

#

return_the_assumed_local_path_to_the_directory_containing_the_images

Consistently use this method if you wish to determine the local directory containing all the various images.

#


934
935
936
937
938
939
940
941
942
943
944
945
946
947
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 934

def return_the_assumed_local_path_to_the_directory_containing_the_images(
    log_dir           = ::GamesAndRpgParadise::MagicTheGathering.log_dir?,
    name_of_the_theme = entry2?
  )
  name_of_the_theme = name_of_the_theme.text?.downcase.
                      tr(' ','_').
                      tr('-','_').
                      delete("'") # Dragon's Tarkir is one reason for this line.
  name_of_the_theme.delete!(':') if name_of_the_theme.include? ':'
  target = log_dir+
           name_of_the_theme+
           '/'
  return target
end

#return_the_assumed_local_path_to_the_image(log_dir = ::GamesAndRpgParadise::MagicTheGathering.log_dir?, name_of_the_theme = entry2?, , card_name = entry1? ) ⇒ Object

#

return_the_assumed_local_path_to_the_image

#


828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 828

def return_the_assumed_local_path_to_the_image(
    log_dir           = ::GamesAndRpgParadise::MagicTheGathering.log_dir?,
    name_of_the_theme = entry2?,
    card_name         = entry1?
  )
  name_of_the_theme = name_of_the_theme.text?.downcase.
                      tr(' ','_').tr('-','_')
  card_name = card_name.text?.tr(' ','_')
  card_name.tr!("'",'_') if card_name.include?("'")
  target = log_dir+
           name_of_the_theme+
           '/'+
           card_name+'.png'
  return target
end

#return_the_checkbox_to_foil_or_not_to_foilObject

#

return_the_checkbox_to_foil_or_not_to_foil

#


248
249
250
251
252
253
254
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 248

def return_the_checkbox_to_foil_or_not_to_foil
  _ = gtk_checkbox
  _.is_inactive
  _.hint = 'Select this to indicate a foil card.'
  _.pad4px
  return _
end

#return_the_dynamic_tooltip_for_the_image_containing_the_graphical_checkbox_for_determining_local_images_availabilityObject

#

return_the_dynamic_tooltip_for_the_image_containing_the_graphical_checkbox_for_determining_local_images_availability

#


1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 1233

def return_the_dynamic_tooltip_for_the_image_containing_the_graphical_checkbox_for_determining_local_images_availability
  _ = ''.dup
  _ << "This icon indicates whether the currently selected theme is available "\
       "locally as well. In other words, if the graphical checkbox is displayed "\
       "as active then it means that the currently selected theme is available "\
       "locally too.\n\n"\
       "Note that if images are available locally then you can click on "\
       "the icon here, and a widget will pop up showing all images in that "\
       "directory.\n\n"
  _ << "The currently active theme is <b>#{current_theme?}</b>."
  n_images_are_available = how_many_images_are_available_locally_in_the_current_theme?
  _ << " <b>#{n_images_are_available}</b> cards were found to be locally available."
  return _
end

#return_the_fifth_rowObject

#

return_the_fifth_row

#


288
289
290
291
292
293
294
295
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 288

def return_the_fifth_row
  hbox5, _text5, @entry5 = text_then_entry('Amount:', padding: 10)
  # ======================================================================= #
  # Add the small spinner, to simplify counting how many cards we have.
  # ======================================================================= #
  hbox5.minimal(@small_spinner)
  return [hbox5, _text5, @entry5]
end

#return_the_foil_card_textObject

#

return_the_foil_card_text

#


266
267
268
269
270
271
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 266

def return_the_foil_card_text
  _ = left_aligned_text('Foil card:')
  _.hint = 'Select the checkbox on the right side to this text, in order '\
           'to indicate that this is a <b>foil</b>(ed) card.'
  return _
end

#return_the_icon_showing_the_theme_symbolsObject

#

return_the_icon_showing_the_theme_symbols

#


193
194
195
196
197
198
199
200
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 193

def return_the_icon_showing_the_theme_symbols
  _ = gtk_image
  # ======================================================================= #
  # Load up the "blank" image next.
  # ======================================================================= #
  _.set_path(BLANK_IMAGE) if File.exist?(BLANK_IMAGE)
  return _
end

#return_the_sixth_rowObject

#

return_the_sixth_row

#


276
277
278
279
280
281
282
283
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 276

def return_the_sixth_row
  hbox = gtk_hbox
  _ = return_the_foil_card_text
  hbox << _
  @checkbox_to_foil_or_not_to_foil = return_the_checkbox_to_foil_or_not_to_foil
  hbox.minimal(@checkbox_to_foil_or_not_to_foil, 8)
  return hbox
end

#return_the_up_and_down_spinnerObject

#

return_the_up_and_down_spinner

#


369
370
371
372
373
374
375
376
377
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 369

def return_the_up_and_down_spinner
  _ = up_and_down_counter
  _.start_position = 1
  _.on_value_changed {
    new_value = @small_spinner.text?
    @entry3.set_text(new_value.to_s)
  }
  return _
end

#return_the_URL_for_cardmarket_based_on_the_entriesObject

#

return_the_URL_for_cardmarket_based_on_the_entries

This method should return a String such as:

https://www.cardmarket.com/en/Magic/Products/Singles/Aether-Revolt/Caught-in-the-Brights
#


1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 1202

def return_the_URL_for_cardmarket_based_on_the_entries
  use_this_theme = @entry2.text?.to_s
  use_this_theme[0,1] = use_this_theme[0,1].upcase
  result = 'https://www.cardmarket.com/en/Magic/Products/Singles/'+
           use_this_theme.delete("'").
           # gsub(/ /,"%20")+ # We must replace ' ' with the proper encoding.
           gsub(/ /,"-")+ # Or rather this variant.
           '/'+
           @entry1.text?.to_s.
           delete(',').
           tr(' ','-')
  return result.to_s
end

#return_theme_of_the_cardObject

#

return_theme_of_the_card

#


1036
1037
1038
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 1036

def return_theme_of_the_card
  return left_aligned_text('Theme:')
end

#return_up_and_down_arrows_for_the_rarity_entryObject

#

return_up_and_down_arrows_for_the_rarity_entry

#


952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 952

def return_up_and_down_arrows_for_the_rarity_entry
  tiny_vbox = gtk_vbox
  event_box1 = gtk_event_box(arrow_up)
  event_box1.hint = 'Clicking on this arrow will increment the rarity '\
                    'of the card by +1, if possible.'
  event_box2 = gtk_event_box(arrow_down)
  event_box2.hint = 'Clicking on this arrow will decrement the rarity '\
                    'of the card by -1, if possible.'
  event_box1.on_clicked {
    determine_the_rarity_based_on_this_mouse_movement(:up)
  }
  event_box2.on_clicked {
    determine_the_rarity_based_on_this_mouse_movement(:down)
  }
  tiny_vbox.minimal(event_box1)
  tiny_vbox.minimal(event_box2)
  return tiny_vbox
end

#sanitize_the_entry_for_the_cost(use_this_entry = entry_for_the_cost? ) ⇒ Object

#

sanitize_the_entry_for_the_cost

#


172
173
174
175
176
177
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 172

def sanitize_the_entry_for_the_cost(
    use_this_entry = entry_for_the_cost?
  )
  _ = use_this_entry.text?.tr(',','.') # We need '.' not ','.
  use_this_entry.set_text(_.to_s)
end

#sanitize_the_entry_for_the_name_of_the_cardObject

#

sanitize_the_entry_for_the_name_of_the_card

#


182
183
184
185
186
187
188
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 182

def sanitize_the_entry_for_the_name_of_the_card
  _ = @entry1.text?
  unless _.empty?
    _[0, 1] = _[0, 1].upcase
    @entry1.set_text(_)
  end
end

#sanitize_the_entry_for_the_rarity_of_the_cardObject

#

sanitize_the_entry_for_the_rarity_of_the_card

This method exists so that we can consistently save the dataset as “uncommon” rather than “Uncommon”.

#


342
343
344
345
346
347
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 342

def sanitize_the_entry_for_the_rarity_of_the_card
  _ = @entry4.text?
  unless _.empty?
    @entry4.set_text(_.downcase)
  end
end

#small_spinner?Boolean

#

small_spinner?

#

Returns:

  • (Boolean)


362
363
364
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 362

def small_spinner?
  @small_spinner
end

#smaller_font?Boolean

#

smaller_font?

#

Returns:

  • (Boolean)


1099
1100
1101
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 1099

def smaller_font?
  SMALLER_FONT
end

#smallest_font?Boolean

#

smallest_font?

#

Returns:

  • (Boolean)


1106
1107
1108
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 1106

def smallest_font?
  SMALLEST_FONT
end

#super_small_font?Boolean

#

super_small_font?

#

Returns:

  • (Boolean)


1011
1012
1013
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 1011

def super_small_font?
  SUPER_SMALL_FONT
end

#the_current_theme_is_available_locally_as_wellObject

#

the_current_theme_is_available_locally_as_well

#


859
860
861
862
863
864
865
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 859

def the_current_theme_is_available_locally_as_well
  _ = @image_containing_the_graphical_checkbox_for_determining_local_images_availability
  _.from_pixbuf = return_pixbuf_based_on_the_default_icon_theme(
    'checkbox-checked-symbolic.symbolic'
  )
  return true
end

#the_current_theme_is_not_available_locallyObject Also known as: the_current_theme_is_NOT_available_locally

#

the_current_theme_is_not_available_locally

#


870
871
872
873
874
875
876
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 870

def the_current_theme_is_not_available_locally
  _ = @image_containing_the_graphical_checkbox_for_determining_local_images_availability
  _.from_pixbuf = return_pixbuf_based_on_the_default_icon_theme(
    'checkbox-symbolic.symbolic'
  )
  return false
end

#theme?Boolean

#

theme?

This will always be downcased - makes it simpler to keep track of the correct themes.

Since as of November 2021 this is no longer downcased.

#

Returns:

  • (Boolean)


612
613
614
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 612

def theme?
  @entry2.text?.downcase
end

#try_to_match_the_entry_onto_the_main_image_that_is_shown(log_dir = ::GamesAndRpgParadise::MagicTheGathering.log_dir?, name_of_the_theme = entry2?, , card_name = entry1?.text?.tr(' ','_')) ⇒ Object Also known as: do_display_the_appropriate_card

#

try_to_match_the_entry_onto_the_main_image_that_is_shown

This method will try to take the text in the main gtk-entry, and then assign it as the new file path to the image at hand.

#


701
702
703
704
705
706
707
708
709
710
711
712
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 701

def try_to_match_the_entry_onto_the_main_image_that_is_shown(
    log_dir           = ::GamesAndRpgParadise::MagicTheGathering.log_dir?,
    name_of_the_theme = entry2?,
    card_name         = entry1?.text?.tr(' ','_')
  )
  target = return_the_assumed_local_path_to_the_image(log_dir, name_of_the_theme, card_name) 
  if File.exist? target
    use_this_image_as_the_new_card_image(target)
  else
    e "No file exists at `#{target}`."
  end
end

#try_to_show_the_correct_theme_icon(current_theme = current_theme?.tr(' ','_').delete("'"), modify_this_image = @image_containing_the_theme_symbols) ⇒ Object Also known as: sync_the_combo_box_onto_the_current_theme_icon

#

try_to_show_the_correct_theme_icon

This method will try to show the associated theme-icon for the magic theme at hand.

Note that the image files will be saved without them containing any “‘” character. So, for instance, the card name for a card belonging to the theme called “Dragon’s Maze” would be stored via “Dragons_Maze”, respectively with a trailing .png extension.

#


901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 901

def try_to_show_the_correct_theme_icon(
    current_theme     = current_theme?.tr(' ','_').delete("'"),
    modify_this_image = @image_containing_the_theme_symbols
  )
  available_images = Dir[
    DIRECTORY_TO_THE_IMAGES_OF_THE_THEME_SYMBOLS+'*.png'
  ]
  available_images = GamesAndRpgParadise.return_array_available_magic_theme_icons
  shortname_available_images = available_images.map {|entry|
    File.basename(entry)
  }.uniq # We only need unique entries past this point.
  possible_matches = shortname_available_images.select {|entry|
    entry.start_with?(current_theme)
  }
  if possible_matches and !possible_matches.empty?
    first = possible_matches.first
    # ===================================================================== #
    # Now we must find out the path:
    # ===================================================================== #
    use_this_path = DIRECTORY_TO_THE_IMAGES_OF_THE_THEME_SYMBOLS+first
    modify_this_image.set_path(use_this_path)
  else # In this case we have not found a match.
    # e 'NO MATCH! Please add an image.'
    modify_this_image.set_path(BLANK_IMAGE)
  end
end

#use_this_image_as_the_new_card_image(i = :infer) ⇒ Object

#

use_this_image_as_the_new_card_image

#


663
664
665
666
667
668
669
670
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 663

def use_this_image_as_the_new_card_image(
    i = :infer
  )
  case i
  when :infer
  end
  @view_card_widget.set_path(i)
end

#yaml_file?Boolean Also known as: location_to_the_yaml_file?

#

yaml_file?

#

Returns:

  • (Boolean)


118
119
120
# File 'lib/games_and_rpg_paradise/gui/shared_code/magic_the_gathering/card_collection/card_collection_module.rb', line 118

def yaml_file?
  @yaml_file
end