2016-09-19 11 views
0
set startpath=%cd% 
del mods.txt 
del mod.txt 
del prioritys.txt 
del desiredmodname.txt 
type NUL > prioritys.txt 
cls 
set /p w3folder=<w3folder.txt 
if not exist "%w3folder%\content\content0" (goto choosew3folder) else goto  askmodkitfolder 
:choosew3folder 
OpenFolderBox.exe C:\ "Appears only on first start or path edit - Please choose your The Witcher 3 Wild Hunt Directory" > w3folder.txt 
set /p w3folder=<w3folder.txt 
:askmodkitfolder 
set /p modkitfolder=<modkitfolder.txt 
if not exist "%modkitfolder%\bin\config\base" (goto choosemodkitfolder) else goto askbasefolder 
:choosemodkitfolder 
OpenFolderBox.exe C:\ "Appears only on first start or path edit - Please choose your Official ModKit Directory" > modkitfolder.txt 
set /p modkitfolder=<modkitfolder.txt 
:askbasefolder 
set /p w3basefolder=<w3basefolder.txt 
if not exist "%w3basefolder%\gameplay\community" (goto choosebasefolder) else goto :selectmods 
:choosebasefolder 
MessageBox.exe "In the next Window you have to select your uncooked base game folder - click on cancel if u dont have it or if u dont know what im talking about :D" "First start/Changed base folder" "OK" "Information" "Button1" "None" "30" 
OpenFolderBox.exe C:\ "choose game base folder-cancel to uncook base game" > w3basefolder.txt 
set /p w3basefolder=<w3basefolder.txt 
Call notEmpty.bat w3basefolder.txt 
If %errorlevel% EQU 0 (goto selectmods) Else (goto uncookbase) 
:uncookbase 
MKDIR "%startpath%\base" 
cd "%w3folder%\xTcTools\bin\x64\" 
call wcc_lite.exe uncook -indir="%w3folder%\content" -outdir="%startpath%\base" 
call wcc_lite.exe uncook -indir="%w3folder%\DLC" -outdir="%startpath%\base" 
set w3basefolder="%startpath%\base" 
:selectmods 
cd "%startpath%" 
del mod.txt 
del modname.txt 
type NUL > mod.txt 
type NUL > modname.txt 
call OpenFolderBox.exe "%w3folder%\mods" "Choose next mod - press cancel to uncook selected mods" >> mod.txt 
Call notEmpty.bat mod.txt 
If %errorlevel% EQU 0 (goto findrepl) Else (goto uncookmods) 
:findrepl 
set /p mod=< mod.txt 
call modname.bat "%mod%" 
cd "%startpath%" 
echo %modname% >> prioritys.txt 
timeout 1 
type "mod.txt"|findrepl /i /o:1:1 >>"mods.txt" 
goto selectmods 
:uncookmods 
set /p uncookmod=< mods.txt 
call modname.bat "%uncookmod%" 
cd "%modkitfolder%\bin\x64\" 
call wcc_lite.exe uncook -indir="%uncookmod%" -outdir="%startpath%\mods\%modname%" 
if not exist "%startpath%\%modname%" (goto quickbms) else goto askmod 
:quickbms 
cd "%startpath%" 
call quickbms.exe -d -o -Y "%startpath%\witcher3.bms" "%uncookmod%\content\blob0.bundle" "%startpath%\%modname%" 
call quickbms.exe -d -o -Y "%startpath%\witcher3.bms" "%uncookmod%\content\blob1.bundle" "%startpath%\%modname%" 
call quickbms.exe -d -o -Y "%startpath%\witcher3.bms" "%uncookmod%\content\blob2.bundle" "%startpath%\%modname%" 
call quickbms.exe -d -o -Y "%startpath%\witcher3.bms" "%uncookmod%\content\buffers0.bundle" "%startpath%\%modname%" 
call quickbms.exe -d -o -Y "%startpath%\witcher3.bms" "%uncookmod%\content\buffers1.bundle" "%startpath%\%modname%" 
call quickbms.exe -d -o -Y "%startpath%\witcher3.bms" "%uncookmod%\content\buffers2.bundle" "%startpath%\%modname%" 
Robocopy.exe /MOVE /S /E "%startpath%\%modname%\blob0.bundle" "%startpath%\mods\%modname%" 
Robocopy.exe /MOVE /S /E "%startpath%\%modname%\blob1.bundle" "%startpath%\mods\%modname%" 
Robocopy.exe /MOVE /S /E "%startpath%\%modname%\blob2.bundle" "%startpath%\mods\%modname%" 
Robocopy.exe /MOVE /S /E "%startpath%\%modname%\buffers0.bundle" "%startpath%\mods\%modname%" 
Robocopy.exe /MOVE /S /E "%startpath%\%modname%\buffers1.bundle" "%startpath%\mods\%modname%" 
Robocopy.exe /MOVE /S /E "%startpath%\%modname%\buffers2.bundle" "%startpath%\mods\%modname%" 
rd /s /q "%startpath%\%modname%" 
:askmod 
MKDIR "%w3folder%\mods\00_MergedMods" 
move "%uncookmod%" "%w3folder%\mods\00_MergedMods" 
cd "%startpath%" 
timeout 1 
type "mods.txt"|findrepl /v /o:1:1 >"mods.txt" 
Call notEmpty.bat mods.txt 
If %errorlevel% EQU 0 (goto uncookmods) Else (goto editfiles) 
:editfiles 
DROPDOWNBOX.exe "Edit Load Order;Edit Files;Build Mod" "What you like to do?" "Option" /RI /C:23 >NUL 
SET ReturnCode=%ErrorLevel% 
IF "%ReturnCode%"=="0" goto editfiles 
IF "%ReturnCode%"=="1" cmd /c "prioritys.txt" 
IF "%ReturnCode%"=="2" %SystemRoot%\explorer.exe "%startpath%\mods" 
IF "%ReturnCode%"=="3" goto robocopy 
goto editfiles 
:robocopy 
set /p modtocopy=< prioritys.txt 
echo %modtocopy% >> IncludedMods.txt 
Robocopy.exe /MOVE /S /E "%startpath%\mods\%modtocopy%" "%startpath%\uncook" 
timeout 1 
type "prioritys.txt"|findrepl /v /o:1:1 >"prioritys.txt" 
Call notEmpty.bat prioritys.txt 
If %errorlevel% EQU 0 (goto robocopy) Else (goto build) 
:build 
rd /s /q "%startpath%\mods" 
InputBox.exe "Enter Name to start building Mod" "Enter Name and Build Mod" "mod" > desiredmodname.txt 
set /p desiredmodname=< desiredmodname.txt 
MKDIR "%startpath%\%desiredmodname%\content" 
MKDIR "%startpath%\cooked" 
cd "%modkitfolder%\bin\x64\" 
call wcc_lite.exe cook -platform=pc -mod="%startpath%\uncook" -basedir="D:\Spiele\Witcher3Mods\Base" -outdir="%startpath%\cooked" 
call wcc_lite.exe buildcache textures -basedir="%startpath%\uncook" -platform=pc -db="%startpath%\cooked\cook.db" -out="%startpath%\%desiredmodname%\content\texture.cache" 
call wcc_lite.exe pack -dir="%startpath%\cooked" -outdir="%startpath%\%desiredmodname%\content" 
call wcc_lite.exe metadatastore -path="%startpath%\%desiredmodname%\content" 
cd "%startpath%" 
rd /s /q "%startpath%\cooked" 
rd /s /q "%startpath%\uncook" 
move "IncludedMods.txt" "%startpath%\%desiredmodname%" 
del mods.txt 
del mod.txt 
del modname.txt 
del prioritys.txt 
del desiredmodname.txt 
move "%startpath%\%desiredmodname%" "%w3folder%\mods" 
MessageBox.exe "All Done enjoy Witcher 3 Wild Hunt now!" "Mod Build Success" "OK" "Information" "Button1" "None" "10" 
exit 

これは私のコードです。すべてうまく動作します。今editlines部分で私はこのようになりますロード順のファイルを編集するための選択肢を与える:テキストファイルのバッチスクリプトの内容の読み込み順序が変更され、再度読み込まれる

modWEATHER 
modInventoryBackground 
modTest1 
modTest2 
modTest3 
modTest4 
modTest5 

私のような1,2,3を通常のprioritysをしたいので、(このファイルを逆にするバッチ内の方法があります、4,5,6,7などがありますが、スクリプトは後でそれを逆にする必要があります。なぜなら、最後にロードされたファイルが最初に読み込まれたファイルを置き換えることができるからです。このloadorder.txtファイルを元に戻して、ユーザーに何かを変えさせてからもう一度やり直す方法はありますか?

そして84行目で私はこのローダーを渡しますerファイルをユーザーに送っても、彼の標準的なテキストエディタで開くことができます。ユーザーがこのテキストファイルのロードオーダーを変更できるようにする小さなツールはありますか? ご理解いただければ幸いです。

+0

loadorderファイルには、スペースを含まない各行に1つの名前があります。それは上記のように見えます。 – xTcisloVe

答えて

1

sort指令に基づいて、他の方法:

@echo off 
setlocal 

set "n=2000000" 
for /F "usebackq tokens=1*" %%a in (` 
    (echo off ^& for /F "usebackq delims=" %%c in ("%~1"^) do (
    set /A "n-=1" ^& echo %%n%% %%c^)^) ^| sort`) do echo %%b 

以下修飾は空白行を含めることができます:

@echo off 
setlocal 

set "n=2000000" 
for /F "usebackq tokens=1* delims=:" %%a in (` 
    (echo off ^& for /F "delims=" %%c in ('findstr /N "^" "%~1"'^) do (
    set /A "n-=1" ^& echo %%n%% %%c^)^) ^| sort`) do echo(%%b 

出力ファイルを生成するだけで括弧内全体for /Fコマンドを囲ん出力をファイルにリダイレクトします。その後、元のファイルを出力に置き換えることができます。

(for /F "usebackq tokens=1*" %%a in (`... sort`) do echo %%b) > output.txt 
move /Y output.txt "%~1" 
+0

これは、先行するコロン ':'を削除するのではないかと心配です。とにかく、私はこのアプローチが好きです... – aschipfl

0

バッチファイルを書き込んでファイルを書き換えました。 これは、再帰や他のいくつかの醜いトリックを使用していますが、動作するようです:

ファイル:Reverse.bat

@echo off 
set LineCount=0 
for /F %%a in (%1) do (set /A LineCount+=1) 
call :ReverseFile %1 
exit /B 

:ReverseFile [%1|Filename] [%2|LineCount] 
    SetLocal 
    set /A LineCount-=1 
    if %LineCount%==-1 exit /B 
    set SKIP_CMD="skip=%LineCount%" 
    if %LineCount%==0 set SKIP_CMD= 
    for /F %SKIP_CMD% %%a in (%1) do (set Line=%%a & echo(%%a & call :ReverseFile %1 %LineCount% & exit /B) 
exit /B 

使用例

ファイル:TestData.txt

Four 
score 
and 
seven 
years 
ago 
our 
fathers 
brought 
forth 
on 
this 
continent 


C:\BatchFiles> Reverse TestData.txt 
continent 
this 
on 
forth 
brought 
fathers 
our 
ago 
years 
seven 
and 
score 
Four 
+0

それは私が何について話しているのですか:D両方のメソッドはうまくいきます。 ロードオーダー部分に。これは誰でも簡単にできるツールです。 cmdウィンドウでテキストファイルの行を表示し、矢印キーで行をスクロールし、+と - を使用して行を上下に移動できますか? – xTcisloVe

0

ここで第二に、最初のファイルを逆に、パラメータとして2つのファイル名を取ってサブルーチンです:

:reverse 
SETLOCAL ENABLEDELAYEDEXPANSION 
:: remove variables starting $ 
FOR /F "delims==" %%a In ('set $ 2^>Nul') DO SET "%%a=" 
SET /a line=9999 
FOR /F "usebackq delims=" %%a In ("%~1") DO SET "$!line!=%%a"&SET /a line-=1 
(
FOR /F "tokens=1*delims==" %%a In ('set $ 2^>Nul') DO ECHO(%%b 
)>"%~2" 
GOTO :eof 

それは変数にファイルの内容を構築することで動作します$9999,$9998などを入力し、新しいファイルにリストします。 lineの初期設定は、初期設定からファイル内の行数を減算しても値の桁数を変更しないほど十分に大きいことが不可欠です(ここでは4であるため、理論上8999行までは9999 -8999 = 1000; 1以上、999 = 3桁)

必要に応じて別のバッチとして設定できます。

Notepadファイルの編集に疑いの余地はありません。

notepad "newfilename" 

はメモ帳を呼び出し、ユーザーが変更を保存してから処理を続けるまで待機します。

関連する問題