Class: GamesAndRpgParadise::RepackageBaldursGateMods
- Defined in:
- lib/games_and_rpg_paradise/games/baldurs_gate/repackage_baldurs_gate_mods.rb
Overview
GamesAndRpgParadise::RepackageBaldursGateMods
Constant Summary collapse
- FILE_MOD_INSTALLATION_ORDER =
#
FILE_MOD_INSTALLATION_ORDER
#
GamesAndRpgParadise.project_dir?+ 'yaml/games/baldurs_gate_2/mod_installation_order.yml'
- DIRECTORY_CONTAINING_THE_BALDURS_GATE_MODS =
#
DIRECTORY_CONTAINING_THE_BALDURS_GATE_MODS
You should replace the constant here with where you keep all mods.
#
'/Depot/Games/Baldurs_Gate_1_and_2/Baldurs_Gate2_Enhanced_Edition/'\ 'mods_and_NPCs/'
Constants included from Base::Extensions::Colours
Base::Extensions::Colours::ARRAY_AVAILABLE_KONSOLE_COLOURS
Constants included from CommonExtensions
CommonExtensions::CONTROL_C_CODE, CommonExtensions::N
Class Method Summary collapse
-
.[](i = ARGV) ⇒ Object
# === GamesAndRpgParadise::RepackageBaldursGateMods[] ========================================================================= #.
Instance Method Summary collapse
-
#initialize(commandline_arguments = nil, run_already = true) ⇒ RepackageBaldursGateMods
constructor
# === initialize ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
-
#verbose_do_start_the_repackaging_process ⇒ Object
# === verbose_do_start_the_repackaging_process ========================================================================= #.
Methods included from Base::Extensions::Colours
ecomment, #efancy, #eparse, #forestgreen, #gold, #grey, #lightblue, #mediumseagreen, #mediumslateblue, #peru, #rev, sdir, sfancy, #sfile, simp, #teal, #yellow
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_the_internal_hash, #return_pwd, #return_today, #touch_file, #wrap, #write_what_into
Constructor Details
#initialize(commandline_arguments = nil, run_already = true) ⇒ RepackageBaldursGateMods
#
initialize
#
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/games_and_rpg_paradise/games/baldurs_gate/repackage_baldurs_gate_mods.rb', line 42 def initialize( commandline_arguments = nil, run_already = true ) reset set_commandline_arguments( commandline_arguments ) run if run_already end |
Class Method Details
.[](i = ARGV) ⇒ Object
#
GamesAndRpgParadise::RepackageBaldursGateMods[]
#
142 143 144 |
# File 'lib/games_and_rpg_paradise/games/baldurs_gate/repackage_baldurs_gate_mods.rb', line 142 def self.[](i = ARGV) new(i) end |
Instance Method Details
#reset ⇒ Object
#
reset (reset tag)
#
56 57 58 59 60 |
# File 'lib/games_and_rpg_paradise/games/baldurs_gate/repackage_baldurs_gate_mods.rb', line 56 def reset super() infer_the_namespace reset_the_internal_hash end |
#run ⇒ Object
#
run (run tag)
#
129 130 131 132 133 134 135 136 137 |
# File 'lib/games_and_rpg_paradise/games/baldurs_gate/repackage_baldurs_gate_mods.rb', line 129 def run _ = FILE_MOD_INSTALLATION_ORDER if File.exist? _ @internal_hash[:dataset] = YAML.load_file(_) verbose_do_start_the_repackaging_process else e 'No file exists at '+sfile(_)+'.' end end |
#verbose_do_start_the_repackaging_process ⇒ Object
#
verbose_do_start_the_repackaging_process
#
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 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 |
# File 'lib/games_and_rpg_paradise/games/baldurs_gate/repackage_baldurs_gate_mods.rb', line 65 def verbose_do_start_the_repackaging_process e "#{rev}Now starting to repackage all Baldur's Gate 2 mods." # ======================================================================= # # 1) first we must find the proper directory # ======================================================================= # e 'First, we must find all directories or files that have to be '\ 're-packaged, as-is.' e _ = @internal_hash[:dataset] all_local_directories = Dir[DIRECTORY_CONTAINING_THE_BALDURS_GATE_MODS+'*'].select {|entry| File.directory?(entry) or File.file?(entry) } array_these_have_to_be_repackaged = [] _.each {|shortcut_name_of_the_mod_at_hand| selection = all_local_directories.select {|entry| entry.downcase.include?(shortcut_name_of_the_mod_at_hand.downcase) } unless selection.empty? array_these_have_to_be_repackaged << selection.first end } # ======================================================================= # # 2) Ok we can now repackage things. # ======================================================================= # if array_these_have_to_be_repackaged.empty? e 'Nothing was found to be repackaged.' else e steelblue(array_these_have_to_be_repackaged.size.to_s)+ olive(' mods were found.') e array_these_have_to_be_repackaged.each_with_index {|entry_to_be_changed, index| index += 1 # =================================================================== # # The first variable here can look like this: # # "/Depot/Games/Baldurs_Gate_1_and_2/Baldurs_Gate2_Enhanced_Edition/mods_and_NPCs/07_Tower_of_Deception_v4.0.6-16.08.2023" # # =================================================================== # = ('%02d' % index)+'_' dirname = File.dirname(entry_to_be_changed) basename = File.basename(entry_to_be_changed) new_basename = basename.sub(/\d{2}_/, ) new_filename = "#{dirname}/#{new_basename}" e lightgreen(.tr('_',') '))+ rev+' Going to ensure that '+sfile(new_filename)+rev+' exists:' e if File.exist? new_filename e rev+'No need to change '+sfile(new_filename) e rev+'as it already has the final name.' else e rev+steelblue('Renaming ')+sfile(entry_to_be_changed)+' '+sfile(new_filename)+rev+'.' e rev+'The new filename is:' e e sfile(" #{new_filename}") e rename_file(entry_to_be_changed, new_filename) end e } end end |