Class: GamesParadise::RepackageBaldursGateMods
- Inherits:
-
Base
- Object
- Base
- GamesParadise::RepackageBaldursGateMods
show all
- Defined in:
- lib/games_paradise/baldurs_gate/repackage_baldurs_gate_mods.rb
Overview
GamesParadise::RepackageBaldursGateMods
Constant Summary
collapse
- FILE_MOD_INSTALLATION_ORDER =
#
FILE_MOD_INSTALLATION_ORDER
#
GamesParadise.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 inherited
from Base
Base::CONTROL_C_CODE, Base::N
Class Method Summary
collapse
-
.[](i = ARGV) ⇒ Object
# === RepackageBaldursGateMods[] ========================================================================= #.
Instance Method Summary
collapse
Methods inherited from Base
#cat, #commandline_arguments?, #efancy, #eparse, #first_argument?, #forestgreen, #gold, #lightblue, #lightgreen, #mediumorchid, #mediumslateblue, #opnn, #peru, #register_sigint, #rev, #royalblue, #set_commandline_arguments, #sfile, #steelblue, #teal, #tomato, #yellow
Methods included from BaseModule
#cliner, #commandline_arguments?, #first_argument?, #infer_the_namespace, #namespace?, #rename_file, #reset_the_internal_hash, #return_pwd, #set_commandline_arguments
Constructor Details
#initialize(commandline_arguments = nil, run_already = true) ⇒ RepackageBaldursGateMods
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/games_paradise/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
#
RepackageBaldursGateMods[]
#
135
136
137
|
# File 'lib/games_paradise/baldurs_gate/repackage_baldurs_gate_mods.rb', line 135
def self.[](i = ARGV)
new(i)
end
|
Instance Method Details
#reset ⇒ Object
56
57
58
59
60
|
# File 'lib/games_paradise/baldurs_gate/repackage_baldurs_gate_mods.rb', line 56
def reset
super()
infer_the_namespace
reset_the_internal_hash
end
|
#run ⇒ Object
122
123
124
125
126
127
128
129
130
|
# File 'lib/games_paradise/baldurs_gate/repackage_baldurs_gate_mods.rb', line 122
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
|
# File 'lib/games_paradise/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."
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
}
if array_these_have_to_be_repackaged.empty?
e 'Nothing was found to be repackaged.'
else
e array_these_have_to_be_repackaged.size.to_s+' mods were found.'
e
array_these_have_to_be_repackaged.each_with_index {|entry_to_be_changed, index| index += 1
expanded_index_name = ('%02d' % index)+'_'
dirname = File.dirname(entry_to_be_changed)
basename = File.basename(entry_to_be_changed)
new_basename = basename.sub(/\d{2}_/, expanded_index_name)
new_filename = dirname+'/'+new_basename
e lightgreen(expanded_index_name.tr('_',') '))+
' Going to ensure that '+sfile(new_filename)+' exists:'
if File.exist? new_filename
e 'No need to change '+sfile(new_filename)
e 'as it already has the final name.'
else
e 'Renaming '+sfile(entry_to_be_changed)+' '+sfile(new_filename)+'.'
rename_file(entry_to_be_changed, new_filename)
end
}
end
end
|