Class: Modsvaskr::Xedit
- Inherits:
-
Object
- Object
- Modsvaskr::Xedit
- Defined in:
- lib/modsvaskr/xedit.rb
Overview
Helper to use an instance of xEdit
Instance Attribute Summary collapse
-
#install_path ⇒ Object
readonly
String: Installation path.
Instance Method Summary collapse
-
#initialize(install_path, game_path) ⇒ Xedit
constructor
Constructor.
-
#parse_csv(csv) ⇒ Object
Parse a CSV that has been dumped by a previous run of xEdit.
-
#quick_auto_clean(esp) ⇒ Object
Run a QuickAutoClean of a given plugin.
-
#run_script(script, only_once: false) ⇒ Object
Run an xEdit script.
Methods included from RunCmd
Methods included from Logger
#log, #out, #wait_for_user_enter
Constructor Details
#initialize(install_path, game_path) ⇒ Xedit
Constructor
- Parameters
-
install_path (String): Installation path of xEdit
-
game_path (String): Installation path of the game to use xEdit on
22 23 24 25 26 27 |
# File 'lib/modsvaskr/xedit.rb', line 22 def initialize(install_path, game_path) @install_path = install_path @game_path = game_path # Set of scripts that have been run @runs = {} end |
Instance Attribute Details
#install_path ⇒ Object (readonly)
String: Installation path
15 16 17 |
# File 'lib/modsvaskr/xedit.rb', line 15 def install_path @install_path end |
Instance Method Details
#parse_csv(csv) ⇒ Object
Parse a CSV that has been dumped by a previous run of xEdit
- Parameters
-
csv (String): Name of the CSV file (from Edit Scripts), without .csv
-
Proc: Code called for each CSV row
- Parameters
-
row (Array<String>): CSV row
79 80 81 |
# File 'lib/modsvaskr/xedit.rb', line 79 def parse_csv(csv, &) CSV.parse(Encoding.to_utf_8(File.read("#{install_path}/Edit Scripts/#{csv}.csv", mode: 'rb'))).each(&) end |
#quick_auto_clean(esp) ⇒ Object
Run a QuickAutoClean of a given plugin
- Parameters
-
esp (String): Plugin to autoclean
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/modsvaskr/xedit.rb', line 58 def quick_auto_clean(esp) # TODO: Find a way to select the right esp automatically out "Please double-click on the following plugin: #{esp}" run_cmd( { dir: @install_path, exe: 'SSEEdit.exe' }, args: %w[ -quickautoclean ] ) end |
#run_script(script, only_once: false) ⇒ Object
Run an xEdit script
- Parameters
-
script (String): Script name, as defined in xedit_scripts (without the Modsvaskr_ prefix and .pas suffix)
-
only_once (Boolean): If true, then make sure this script is run only once by instance [default: false]
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/modsvaskr/xedit.rb', line 34 def run_script(script, only_once: false) return if only_once && @runs.key?(script) FileUtils.cp "#{__dir__}/../../xedit_scripts/Modsvaskr_#{script}.pas", "#{@install_path}/Edit Scripts/Modsvaskr_#{script}.pas" run_cmd( { dir: @install_path, exe: 'SSEEdit.exe' }, args: %W[ -IKnowWhatImDoing -AllowMasterFilesEdit -SSE -autoload -script:"Modsvaskr_#{script}.pas" ] ) @runs[script] = nil end |