Baoulettes

Classmith 2014 V1

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