Advertisement
Baoulettes

Classmith 2014 V1

Jul 20th, 2015
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #SingleInstance force
  2. ; 20th July 2014 by Baoulettes aka Joffrey Panisset
  3. ; Joffrey.panisset@hotmail.com
  4. ; Unauthorized use is forbidden.
  5. ; Here are my credit list :
  6. ; Autohotkey to allow such code stuff :)
  7. ; fabianosan for Rocksmith Custom Song Toolkit unpacker.
  8. ; Snakez for Rocksmith Custom Song Toolkit unpacker.
  9. ; Maveth for Rocksmith Custom Song Toolkit unpacker.
  10. ; Raynebc for Rocksmith Custom Song Toolkit unpacker.
  11. ; Dreddfoxx for Rocksmith Custom Song Toolkit unpacker.
  12. ; Alex360 (L0fka) for Rocksmith Custom Song Toolkit unpacker.
  13. ; Shrubbery (otaznik) for Rocksmith Custom Song Toolkit unpacker.
  14. ; Cozy1 for Rocksmith Custom Song Toolkit unpacker.
  15. ; Zephyrix for Rocksmith Custom Song Toolkit unpacker.
  16. ; Xavatar (PowerSlinky) for Rocksmith Custom Song Toolkit unpacker.
  17. ; Chlipouni for Rocksmith Custom Song Toolkit unpacker.
  18. ; Cgeorge for Rocksmith Custom Song Toolkit unpacker.
  19.  
  20. ;Variables Setting :
  21. Appname = Classmith 2014
  22. Appversion = V1.0.0
  23.  
  24. ;Creating Ressources Directory :
  25. fileCreateDir, %A_ScriptDir%\ressources\
  26. fileCreateDir, %A_ScriptDir%\ressources\packer
  27.  
  28. ;Installing required files :
  29. FileInstall, D:\RS2014SongClassifier\Ressources\packer\NDesk.Options.dll, %A_ScriptDir%\ressources\packer\NDesk.Options.dll
  30. FileInstall, D:\RS2014SongClassifier\Ressources\packer\packer.exe, %A_ScriptDir%\ressources\packer\packer.exe
  31. FileInstall, D:\RS2014SongClassifier\Ressources\packer\packer.pdb, %A_ScriptDir%\ressources\packer\packer.pdb
  32. FileInstall, D:\RS2014SongClassifier\Ressources\packer\RocksmithToolkitLib.dll, %A_ScriptDir%\ressources\packer\RocksmithToolkitLib.dll
  33. FileInstall, D:\RS2014SongClassifier\Ressources\packer\X360.dll, %A_ScriptDir%\ressources\packer\X360.dll
  34. FileInstall, D:\RS2014SongClassifier\Ressources\packer\ZLIB.dll, %A_ScriptDir%\ressources\packer\ZLIB.dll
  35. FileInstall, D:\RS2014SongClassifier\Ressources\packer\zlib.net.dll, %A_ScriptDir%\ressources\packer\zlib.net.dll
  36. FileInstall, D:\RS2014SongClassifier\Ressources\Baoulettes.png, %A_ScriptDir%\ressources\Baoulettes.png,1
  37. FileInstall, D:\RS2014SongClassifier\Ressources\Rocksmith-2014-Edition-Logo.png, %A_ScriptDir%\ressources\Rocksmith-2014-Edition-Logo.png,1
  38.  
  39. ; Reading various Variables
  40. IniRead, Languages, Options.ini, Options, Languages
  41. IniRead, SelectedRS2014Folder, Options.ini, Options, R2014dir
  42. IniRead, DLCWantingNameInput, Options.ini, Options, WantedPsarcName
  43. IniRead, Platform, Options.ini, Options, Platform
  44. IniRead, YesnoDL, Options.ini, Options, SeparateInFolderQS
  45. If SelectedRS2014Folder = ERROR
  46. {
  47. FileSelectFolder, SelectedRS2014Folder,, 3,Please choice Rocksmith 2014 directory.
  48. IniWrite, %SelectedRS2014Folder%, Options.ini, Options, R2014dir
  49. }
  50. If SelectedRS2014Folder =
  51. {
  52. FileSelectFolder, SelectedRS2014Folder,, 3,Please choice Rocksmith 2014 directory.
  53. IniWrite, %SelectedRS2014Folder%, Options.ini, Options, R2014dir
  54. }
  55. If Languages = ERROR
  56. {
  57. Languages=En
  58. }
  59. If Languages =
  60. {
  61. Languages=En
  62. }
  63. If YesnoDL = ERROR
  64. {
  65. YesnoDL = Yes||No
  66. }
  67. If YesnoDL =
  68. {
  69. YesnoDL = Yes||No
  70. }
  71. If YesnoDL = Yes
  72. {
  73. YesnoDL = Yes||No
  74. }
  75. If YesnoDL = No
  76. {
  77. YesnoDL = Yes|No||
  78. }
  79. If Platform = ERROR
  80. {
  81. Platform = PC||Mac
  82. }
  83. If Platform =
  84. {
  85. Platform = PC||Mac
  86. }
  87. If Platform = PC
  88. {
  89. Platform = PC||Mac
  90. }
  91. If Platform = Mac
  92. {
  93. Platform = PC|Mac||
  94. }
  95. If DLCWantingNameInput = ERROR
  96. {
  97. DLCWantingNameInput=`%A`%_`%SN`%_`%AN`%_V`%V`%
  98. }
  99. If DLCWantingNameInput =
  100. {
  101. DLCWantingNameInput=`%A`%_`%SN`%_`%AN`%_V`%V`%
  102. }
  103.  
  104. ;Variables for translation :
  105. ;Base - English :
  106. If Languages = EN
  107. {
  108. about = About
  109. choiceRSDir = Please choice Rocksmith 2014 directory.
  110. RS2014FSelectB = Browse
  111. DLCWantedName = Please set a name scheme. (More information about variables name at right)
  112. BasicInfoFileNaming = use `%A`% for Artist Name`n use `%SN`% for Song Name`n use `%AN`% for Album Name`n use `%V`% for Package Version (Recommended.)`nAll space will be replaced by underscores.
  113. SelectPFText = Target platform :
  114. SeparateInFolderQS = Would you like to sort song in a Artist folder inside DLC folder?
  115. AppsUsageText = 1st You have to select a Rocksmith 2014 directory (NOT dlc just root folder!)`n2nd Config the application as you wish.`n3rd Press "Let do it".`nCommon error possible :`nNo dlc in DLC folder so nothing to do`nAlready sorted .psarc (This application don't look in subfolder to prevent unwanted error)`nFolder isn't Rocksmith 2014 root.`nPlease becareful and make Backups if you're unsure !`nThe more CDLC/DLC you have the more time it will take so please be patient !`nIf you have Any problem contact me over: `nFacebook : Page: Baoulettes`nSkype : mysticia26
  116. StartProcess = Let do it !
  117. CreditText = This Application has been mady by Baoulettes. 2015
  118. AboutTextWindows = Credits List:`nAutohotkey`nBaoulettes`nRocksmith Custom Song Toolkit maker :`nfabianosan`nSnakez`nMaveth`nRaynebc`nDreddfoxx`nAlex360 (L0fka)`nShrubbery (otaznik)`nCozy1`nZephyrix`nXavatar`nChlipouni`nCgeorge
  119. }
  120.  
  121. ;Gui Making !
  122. Gui,1: Add, Button, x412 y5 w60 h20 gaboutwin, %about%
  123. Gui,1: Add, Text, x100 y29 w370 h30 BackGroundTrans +Center, %choiceRSDir%
  124. Gui,1: Add, Button, x412 y29 w60 h20 gSelRS2014Folder, %RS2014FSelectB%
  125. Gui,1: Add, Edit, x2 y59 w470 h30 vactualdir +Center, %SelectedRS2014Folder%
  126. Gui,1: Add, Text, x2 y95 w250 h30 +Center, %DLCWantedName%
  127. Gui,1: Add, Edit, x2 y129 w250 h40 vnameinput +Center, %DLCWantingNameInput%
  128. Gui,1: Add, Text, x262 y95 w210 h80 +Center, %BasicInfoFileNaming%
  129. Gui,1: Add, DropDownList, x362 y187 w100 h20 r2 vSelPlatform, %Platform%
  130. Gui,1: Add, Text, x262 y191 w100 h30 , %SelectPFText%
  131. Gui,1: Add, Text, x2 y185 w150 h30 , %SeparateInFolderQS%
  132. Gui,1: Add, DropDownList, x152 y187 w100 h21 r2 vFolderYesNo, %YesnoDL%
  133. Gui,1: Add, Text, x2 y223 w470 h160 +Center, %AppsUsageText%
  134. Gui,1: Add, Button, x12 y399 w450 h30 gGoforIt, %StartProcess%
  135. Gui,1: Add, Text, x2 y429 w470 h20 +Center, %CreditText%
  136. Gui,1: Add, Picture, x0 y0 w180 h60 BackGroundTrans, %A_ScriptDir%\ressources\Rocksmith-2014-Edition-Logo.png
  137. Gui,1: Show, h450 w476, %Appname% - %Appversion%
  138. Return
  139.  
  140. ; Creating Credit / About window
  141. aboutwin:
  142. Gui,1: Hide
  143. Gui,2: Add, Picture, x0 y0 w150 h150 , %A_ScriptDir%\ressources\Baoulettes.png
  144. Gui,2: Add, Text, x0 y149 w150 h230 +Center, %AboutTextWindows%
  145. Gui,2: Show, h381 w150, %Appname% - %Appversion%
  146. Return
  147.  
  148. ;Functions :
  149. ; Rocksmith Directory selection.
  150. SelRS2014Folder:
  151. FileSelectFolder, SelectedRS2014Folder,, 3,%choiceRSDir%
  152. GuiControl,1:,actualdir, %SelectedRS2014Folder%
  153. IniWrite, %SelectedRS2014Folder%, Options.ini, Options, R2014dir
  154. Return
  155.  
  156. ; Main Function to parse files & rename etc.
  157. GoforIt:
  158. Gui,1: Submit
  159. GuiControlGet, actualdir,1:,
  160. GuiControlGet, nameinput,1:,
  161. GuiControlGet, SelPlatform,1:,
  162. GuiControlGet, FolderYesNo,1:,
  163. DLCWantingNameInput = %nameinput%
  164. SelectedRS2014Folder = %actualdir%
  165. Platform = %SelPlatform%
  166. YesnoDL = %FolderYesNo%
  167. If SelectedRS2014Folder = ERROR
  168. {
  169. FileSelectFolder, SelectedRS2014Folder,, 3,%choiceRSDir%
  170. GuiControl,1:,actualdir, %SelectedRS2014Folder%
  171. IniWrite, %SelectedRS2014Folder%, Options.ini, Options, R2014dir
  172. Gui,1: Restore
  173. return
  174. }
  175. If SelectedRS2014Folder =
  176. {
  177. FileSelectFolder, SelectedRS2014Folder,, 3,%choiceRSDir%
  178. GuiControl,1:,actualdir, %SelectedRS2014Folder%
  179. IniWrite, %SelectedRS2014Folder%, Options.ini, Options, R2014dir
  180. Gui,1: Restore
  181. return
  182. }
  183. If DLCWantingNameInput = ERROR
  184. {
  185. Msgbox, Please set a name other than Error... Use Variables too!
  186. Gui,1: Restore
  187. return
  188. }
  189. If DLCWantingNameInput =
  190. {
  191. Msgbox, Please set a name other than Error... Use Variables too!
  192. Gui,1: Restore
  193. return
  194. }
  195. If Platform = PC||Mac
  196. {
  197. Platform = PC
  198. }
  199. If Platform = PC|Mac||
  200. {
  201. Platform = Mac
  202. }
  203. If YesnoDL = Yes||No
  204. {
  205. YesnoDL = Yes
  206. }
  207. If YesnoDL = Yes|No||
  208. {
  209. YesnoDL = No
  210. }
  211. IniWrite, %Languages%, Options.ini, Options, Languages
  212. IniWrite, %SelectedRS2014Folder%, Options.ini, Options, R2014dir
  213. IniWrite, %DLCWantingNameInput%, Options.ini, Options, WantedPsarcName
  214. IniWrite, %Platform%, Options.ini, Options, Platform
  215. IniWrite, %YesnoDL%, Options.ini, Options, SeparateInFolderQS
  216. NameId=0
  217. If Platform = PC
  218. {
  219. endfilename = _p.psarc
  220. PT = _Pc
  221. FileCreateDir, %SelectedRS2014Folder%\dlc\01MacVersion
  222. FileMove, %SelectedRS2014Folder%\dlc\*_m.psarc, %SelectedRS2014Folder%\dlc\01MacVersion
  223. }
  224. If Platform = Mac
  225. {
  226. endfilename = _m.psarc
  227. FileCreateDir, %SelectedRS2014Folder%\dlc\01PcVersion
  228. FileMove, %SelectedRS2014Folder%\dlc\*_p.psarc, %SelectedRS2014Folder%\dlc\01PcVersion
  229. PT = _Mac
  230. }
  231. FileCreateDir, %A_ScriptDir%\tmp
  232. FileCreateDir, %A_ScriptDir%\tmp\ToRename
  233. Gui,3: Add, Text, x0 y0 w240 h90 vGui3Txt +Center, %Gui3Text%
  234. Gui,3: -SysMenu
  235. Gui,3: Show, h88 w244, Working . . .
  236.  
  237. Loop Files, %SelectedRS2014Folder%\dlc\*.psarc,
  238. {
  239. ;FileName = %A_LoopFileName%
  240. StringReplace, CutedName, A_LoopFileName, .psarc, , All
  241. UnpackFDName = %CutedName%%PT%
  242. FileCreateDir, %A_ScriptDir%\tmp\ToRename\Unpack
  243. FileMove, %SelectedRS2014Folder%\dlc\%A_LoopFileName%, %A_ScriptDir%\tmp\ToRename
  244. RunWait, %A_ScriptDir%\ressources\packer\packer.exe --unpack -i="%A_ScriptDir%\tmp\ToRename\%A_LoopFileName%" -o="%A_ScriptDir%\tmp\ToRename\Unpack",,Hide
  245. Loop Files, %A_ScriptDir%\tmp\ToRename\Unpack\%UnpackFDName%\*.nt,
  246. {
  247.     StringTrimRight, UniqueID, A_LoopFileName, 18
  248. }
  249. FileRead, VersionCheck, %A_ScriptDir%\tmp\ToRename\Unpack\%UnpackFDName%\toolkit.version
  250. if not ErrorLevel
  251. {
  252. Checkif = Package Version:
  253. IfInString, VersionCheck, %Checkif%
  254. FoundV := InStr(VersionCheck, Checkif)
  255. FoundV+=16
  256. StringTrimLeft, PVersion2Split, VersionCheck, %FoundV%
  257. StringLeft, PVersion, PVersion2Split, 2
  258. }
  259. else
  260. {
  261. PVersion =1
  262. }
  263. FileRead, HSANFile, %A_ScriptDir%\tmp\ToRename\Unpack\%UnpackFDName%\manifests\songs_dlc_%UniqueID%\songs_dlc_%UniqueID%.hsan
  264. Check4AN = `"AlbumName`": `"
  265. IfInString, HSANFile, %Check4AN%
  266. FoundAN := InStr(HSANFile, Check4AN)
  267. FoundAN+=13
  268. StringTrimLeft, AlbumName2Split, HSANFile, %FoundAN%
  269. CheckNameEnd = `",
  270. IfInString, AlbumName2Split, %CheckNameEnd%
  271. FoundANEnd := InStr(AlbumName2Split, CheckNameEnd)
  272. FoundANEnd-=1
  273. StringLeft, AlbumNameCuted, AlbumName2Split, %FoundANEnd%
  274. Gui3Text = Working on : %ArtistNameCuted% - %SongNameCuted%
  275. GuiControl,3:,Gui3Txt, %Gui3Text%
  276. Check4ArtN = `"ArtistName`": `"
  277. IfInString, HSANFile, %Check4ArtN%
  278. FoundArtN := InStr(HSANFile, Check4ArtN)
  279. FoundArtN+=14
  280. StringTrimLeft, ArtistName2Split, HSANFile, %FoundArtN%
  281. IfInString, ArtistName2Split, %CheckNameEnd%
  282. FoundArtNEnd := InStr(ArtistName2Split, CheckNameEnd)
  283. FoundArtNEnd-=1
  284. StringLeft, ArtistNameCuted, ArtistName2Split, %FoundArtNEnd%
  285. Gui3Text = Working on : %ArtistNameCuted% - %SongNameCuted%
  286. GuiControl,3:,Gui3Txt, %Gui3Text%
  287. Check4SN = `"SongName`": `"
  288. IfInString, HSANFile, %Check4SN%
  289. FoundSN := InStr(HSANFile, Check4SN)
  290. FoundSN+=12
  291. StringTrimLeft, SongName2Split, HSANFile, %FoundSN%
  292. IfInString, SongName2Split, %CheckNameEnd%
  293. FoundSNEnd := InStr(SongName2Split, CheckNameEnd)
  294. FoundSNEnd-=1
  295. StringLeft, SongNameCuted, SongName2Split, %FoundSNEnd%
  296. Gui3Text = Working on : %ArtistNameCuted% - %SongNameCuted%
  297. GuiControl,3:,Gui3Txt, %Gui3Text%
  298. StringReplace, AlbumName, AlbumNameCuted, %A_SPACE%, -, All
  299. StringReplace, ArtistName, ArtistNameCuted, %A_SPACE%, -, All
  300. StringReplace, SongName, SongNameCuted, %A_SPACE%, -, All
  301. StringReplace, PackVersion, PVersion, %A_SPACE%, ., All
  302. StringReplace, AlbumName, AlbumName, `%, %A_SPACE%, All
  303. StringReplace, ArtistName, ArtistName, `%, %A_SPACE%, All
  304. StringReplace, SongName, SongName, `%, %A_SPACE%, All
  305. StringReplace, PackVersion, PackVersion, `%, %A_SPACE%, All
  306. DLCWantingNameInputCorrect = %DLCWantingNameInput%
  307. StringReplace, DLCWantingNameInput, DLCWantingNameInput, `%A`%, %ArtistName%
  308. StringReplace, DLCWantingNameInput, DLCWantingNameInput, `%SN`%, %SongName%
  309. StringReplace, DLCWantingNameInput, DLCWantingNameInput, `%AN`%, %AlbumName%
  310. StringReplace, DLCWantingNameInput, DLCWantingNameInput, `%V`%, %PackVersion%
  311. StringReplace, DLCWantingNameInput, DLCWantingNameInput, `%, , All
  312. If YesnoDL = Yes
  313. {
  314. FileCreateDir, %SelectedRS2014Folder%\dlc\%ArtistName%
  315. FileMove, %A_ScriptDir%\tmp\ToRename\%A_LoopFileName%, %SelectedRS2014Folder%\dlc\%ArtistName%\%DLCWantingNameInput%%endfilename%
  316. if ErrorLevel
  317. {
  318. FileCreateDir, %SelectedRS2014Folder%\dlc\01CheckDuplicat
  319. FileMove, %A_ScriptDir%\tmp\ToRename\%A_LoopFileName%, %SelectedRS2014Folder%\dlc\01CheckDuplicat\%NameId%%DLCWantingNameInput%%endfilename%
  320. NameId++
  321. }
  322.  
  323. }
  324. If YesnoDL = No
  325. {
  326. FileMove, %A_ScriptDir%\tmp\ToRename\%A_LoopFileName%, %SelectedRS2014Folder%\dlc\%DLCWantingNameInput%%endfilename%
  327. if ErrorLevel
  328. {
  329. FileCreateDir, %SelectedRS2014Folder%\dlc\01CheckDuplicat
  330. FileMove, %A_ScriptDir%\tmp\ToRename\%A_LoopFileName%, %SelectedRS2014Folder%\dlc\01CheckDuplicat\%NameId%%DLCWantingNameInput%%endfilename%
  331. NameId++
  332. }
  333. }
  334. FileRemoveDir, %A_ScriptDir%\tmp\ToRename\Unpack, 1
  335. DLCWantingNameInput = %DLCWantingNameInputCorrect%
  336. }
  337. If YesnoDL = Yes
  338. {
  339. YesnoDL = Yes||No
  340. }
  341. If YesnoDL = No
  342. {
  343. YesnoDL = Yes|No||
  344. }
  345. If Platform = PC
  346. {
  347. Platform = PC||Mac
  348. Platform2 = Pc
  349. }
  350. If Platform = Mac
  351. {
  352. Platform = PC|Mac||
  353. Platform2 = Mac
  354. }
  355. GuiControl,1:,actualdir, %SelectedRS2014Folder%
  356. GuiControl,1:,nameinput, %DLCWantingNameInput%
  357. GuiControl,1:,SelPlatform, %Platform%
  358. GuiControl,1:,FolderYesNo, %YesnoDL%
  359. FileRemoveDir, %A_ScriptDir%\tmp, 1
  360. Gui,3: Destroy
  361. MsgBox, Work Done.`nYou can now play as you wish :)`nCheck DLC folder if there isn't a folder `"01CheckDuplicat`" If there all duplicate or outdated CLDC are there !`nDepending on the platform you choicen but the useless version as been put in folder dlc into `"01%Platform2%Version`"
  362. Gui,1: Restore
  363. return
  364.  
  365. ; Close all if main Gui is closed
  366. 1GuiClose:
  367. FileRemoveDir, %A_ScriptDir%\tmp, 1
  368. Gui,1: Destroy
  369. Gui,2: Destroy
  370. Gui,3: Destroy
  371. ExitApp
  372.  
  373. ; Restore Gui 1 if Gui 2 is closed.
  374. 2GuiClose:
  375. Gui,1: Restore
  376. Gui,2: Destroy
  377. Gui,3: Destroy
  378. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement