#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Version=beta
#AutoIt3Wrapper_icon=..Logo.ico
#AutoIt3Wrapper_outfile=Spayrosam Multi App Nand part.exe
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Comment=Spayrosam Multi App Nand part
#AutoIt3Wrapper_Res_Description=Spayrosam Multi App Nand part
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_ProductVersion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=Copyright © 2009 - © 2012 Spayrosam (Samir.L)
#AutoIt3Wrapper_Res_Field=CompanyName|Spayrosam
#AutoIt3Wrapper_Res_Field=ProductName|Spayrosam Multi App Nand part
#AutoIt3Wrapper_Res_Field=ProductVersion|1.1.0.0
#AutoIt3Wrapper_Res_Field=Spayrosam Multi App Nand part|1.1.0.0
#AutoIt3Wrapper_Run_AU3Check=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>
#include <GuiListView.au3>
#include <StaticConstants.au3>
Local $DataDir = @ScriptDir
$GUI = GUICreate("List Nand titles", 680, 465, -1, -1)
GUICtrlCreateGroup("", 5, 0, 500, 40)
$NandFolder = GUICtrlCreateButton("Nand folder", 10, 10, 80, 25)
$NandFolderinput = GUICtrlCreateInput("", 97, 10, 300, 25)
$loadnand = GUICtrlCreateButton("Load Nand", 400, 10, 100, 25)
GUICtrlCreateGroup("", 510, 0, 163, 40)
GUICtrlCreateLabel("Language:", 511, 10, 100, 25, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 600)
$NandLangBox = GUICtrlCreateCombo("", 605, 13, 60, 25)
GUICtrlSetData(-1, "EN|FR|DE|ES|IT|NL|PT|US|JA|KO|ZH", "EN")
$NandListView = GUICtrlCreateListView("", 10, 45, 660, 350, -1, BitOR($LVS_SORTASCENDING, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_REGIONAL, $LVS_EX_CHECKBOXES))
$NandListViewHandle = GUICtrlGetHandle($NandListView)
_GUICtrlListView_AddColumn($NandListView, "Folder Name", 80)
_GUICtrlListView_AddColumn($NandListView, "ID", 70)
_GUICtrlListView_AddColumn($NandListView, "Name", 200)
_GUICtrlListView_AddColumn($NandListView, "Type", 100)
_GUICtrlListView_AddColumn($NandListView, "Region", 100)
_GUICtrlListView_AddColumn($NandListView, "Title size (Kb)", 100)
_GUICtrlListView_AddColumn($NandListView, "", 0)
_GUICtrlListView_AddColumn($NandListView, "", 0)
_GUICtrlListView_AddColumn($NandListView, "", 0)
_GUICtrlListView_AddColumn($NandListView, "", 0)
_GUICtrlListView_AddColumn($NandListView, "", 0)
$NandState = GUICtrlCreateLabel("State", 10, 400, 660, 25, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$NandProgress = GUICtrlCreateProgress(10, 430, 660, 20)
GUISetState(@SW_SHOW)
Do
Switch GUIGetMsg()
Case -3
Exit
Case $NandFolder
Local $path = FileSelectFolder("Choose a folder. (Nand)", @DesktopDir, 1, "", $GUI)
If @[member='Error 917']<> 1 Then
If StringRegExpReplace($path, "^.*(.*)$", "$1") = "Nand" Then
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($NandListView))
GUICtrlSetData($NandFolderinput, $path)
Else
MsgBox(48, "Wrong folder!", "Navigate to 'Nand' folder (USBnand)", -1, $GUI)
EndIf
Else
MsgBox(48, "Wrong folder!", "Navigate to 'Nand' folder (USBnand)", -1, $GUI)
EndIf
Case $loadnand
If GUICtrlRead($NandFolderinput) <> "" Then
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($NandListView))
$_Nand_List = _LoadNand(GUICtrlRead($NandFolderinput) & "title")
If $_Nand_List <> "0" Then MsgBox(16, "Error", $_Nand_List, Default, $GUI)
EndIf
EndSwitch
Until 0
Func _LoadNand($path)
Local $_NFolder_found, $_iNMain, $_iN, $NewNumber = 0
Global $FileListNandGameID[1][7]
Local $_iNObj = ObjCreate('Scripting.FileSystemObject')
If @[member='Error 917']Or Not IsObj($_iNObj) Then
Return "Failed Creating Scripting.FileSystemObject"
EndIf
If Not $_iNObj.FolderExists($path) Then
Return "Path not found or invalid"
EndIf
If StringRight($path, 1) <> '' Then $path &= ''
$_NFolder_found = $_iNObj.GetFolder($path)
For $_iNMain In $_NFolder_found.SubFolders
If StringLeft($_iNMain.Name, 4) = "0001" Then
Local $_NFolder_found
$_NFolder_found = $_iNObj.GetFolder($path & $_iNMain.Name & '')
For $_iN In $_NFolder_found.SubFolders
If StringRegExp($_iN.Name, "(?i).*") Then
Local $_iNTiCK = StringReplace($path, "title", "ticket") & $_iNMain.Name & "" & $_iN.Name & ".tik"
Local $_iTest_AppFile = $path & $_iNMain.Name & "" & $_iN.Name & "content*.app"
If FileExists($_iNTiCK) = 1 And FileGetSize($_iNTiCK) > 0 And FileExists($_iTest_AppFile) = 1 Then
$NewNumber += 1
ReDim $FileListNandGameID[$NewNumber + 1][7]
$FileListNandGameID[$NewNumber][0] = $_iN.Name
$FileListNandGameID[$NewNumber][1] = StringUpper(BinaryToString("0x" & $_iN.Name))
$FileListNandGameID[$NewNumber][3] = _GetGameType($FileListNandGameID[$NewNumber][1])
$FileListNandGameID[$NewNumber][4] = _GetRegion($FileListNandGameID[$NewNumber][1])
$FileListNandGameID[$NewNumber][5] = Round((DirGetSize($path & $_iNMain.Name & "" & $_iN.Name) + FileGetSize($_iNTiCK)) / 1024, 2)
$FileListNandGameID[$NewNumber][6] = $_iNMain.Name
EndIf
EndIf
Next
EndIf
Next
;Set title
For $iSet = 1 To UBound($FileListNandGameID) - 1
GUICtrlSetData($NandState, "File N' " & $iSet & " / " & UBound($FileListNandGameID) - 1 & " | " & "Load: '" & $FileListNandGameID[$iSet][0] & " : " & $FileListNandGameID[$iSet][1] & "'")
Local $iPercent = Round($iSet / (UBound($FileListNandGameID) - 1) * 100, 1)
GUICtrlSetData($NandProgress, $iPercent)
If FileExists($DataDir & "title_" & GUICtrlRead($NandLangBox) & ".ini.") <> 0 Then
Local $hFile = FileOpen($DataDir & "title_" & GUICtrlRead($NandLangBox) & ".ini.", 0)
If $hFile <> -1 Then
While True
$searchItem = FileReadLine($hFile)
If @[member='Error 917']Then ExitLoop
If StringInStr($searchItem, "=") Then
Local $ID_To_search = StringSplit($searchItem, "=", 0)
If StringInStr($ID_To_search[1], $FileListNandGameID[$iSet][1]) Then
If StringLeft($ID_To_search[2], 1) = " " Then $ID_To_search[2] = StringTrimLeft($ID_To_search[2], 1)
If StringRight($ID_To_search[1], 1) = " " Then $ID_To_search[1] = StringTrimRight($ID_To_search[1], 1)
$FileListNandGameID[$iSet][2] = $ID_To_search[2]
$FileListNandGameID[$iSet][1] = $ID_To_search[1]
ConsoleWrite($ID_To_search[2] & @CR)
EndIf
EndIf
WEnd
EndIf
FileClose($hFile)
EndIf
$item_count = _GUICtrlListView_GetItemCount($NandListView)
_GUICtrlListView_AddItem($NandListView, $FileListNandGameID[$iSet][0], $item_count)
_GUICtrlListView_AddSubItem($NandListView, $item_count, $FileListNandGameID[$iSet][1], 1, 1)
_GUICtrlListView_AddSubItem($NandListView, $item_count, $FileListNandGameID[$iSet][2], 2, 1)
_GUICtrlListView_AddSubItem($NandListView, $item_count, $FileListNandGameID[$iSet][3], 3, 1)
_GUICtrlListView_AddSubItem($NandListView, $item_count, $FileListNandGameID[$iSet][4], 4, 1)
_GUICtrlListView_AddSubItem($NandListView, $item_count, $FileListNandGameID[$iSet][5], 5, 1)
_GUICtrlListView_AddSubItem($NandListView, $item_count, "" & $FileListNandGameID[$iSet][6], 10, 1)
Next
;_ArrayDisplay($FileListNandGameID, "Title Found")
GUICtrlSetData($NandState, (UBound($FileListNandGameID) - 1) & " Title successfully loaded")
Return 0
EndFunc ;==>_LoadNand
Func _GetGameType($IDFound)
Local $SetGameType = ""
$GetGameType = StringLeft($IDFound, 1)
If $GetGameType = "W" Then
$SetGameType = "WiiWare"
ElseIf $GetGameType = "N" Then
$SetGameType = "Nintendo64"
ElseIf $GetGameType = "J" Then
$SetGameType = "SNES"
ElseIf $GetGameType = "F" Then
$SetGameType = "NES"
ElseIf $GetGameType = "A" Then
$GetGameType_A = StringLeft($IDFound, 2)
If $GetGameType_A = "A6" Then
$SetGameType = "Arcade"
ElseIf $GetGameType_A = "A7" Then
$SetGameType = "Arcade-Namco"
Else
$SetGameType = "custom"
EndIf
ElseIf $GetGameType = "P" Then
$SetGameType = "TurboGrafx16"
ElseIf $GetGameType = "Q" Then
$SetGameType = "TurboGrafxCD"
ElseIf $GetGameType = "C" Then
$SetGameType = "Commodore"
ElseIf $GetGameType = "E" Then ;EA
$SetGameType = "NeoGeo"
ElseIf $GetGameType = "M" Then
$SetGameType = "SegaMegaDrive"
ElseIf $GetGameType = "L" Then
$SetGameType = "SegaMasterSystem"
ElseIf $GetGameType = "R" Or $GetGameType = "S" Or $GetGameType = "A" Then
$SetGameType = "Wii"
ElseIf $GetGameType = "G" Or $GetGameType = "D" Then
$SetGameType = "GameCube"
ElseIf $GetGameType = "H" Then
$SetGameType = "General Channel"
ElseIf $GetGameType = "X" Then
$SetGameType = "WiiWare - Demos "
Else
$SetGameType = "custom"
EndIf
Return $SetGameType
EndFunc ;==>_GetGameType
Func _GetRegion($IDFound)
Global $UserSearchRegion = "Unknow"
If StringRight(StringLeft($IDFound, 4), 1) = "A" Then
$UserSearchRegion = "All regions"
ElseIf StringRight(StringLeft($IDFound, 4), 1) = "D" Then
$UserSearchRegion = "German-speaking regions"
ElseIf StringRight(StringLeft($IDFound, 4), 1) = "E" Then
$UserSearchRegion = "USA"
ElseIf StringRight(StringLeft($IDFound, 4), 1) = "F" Then
$UserSearchRegion = "French-speaking regions"
ElseIf StringRight(StringLeft($IDFound, 4), 1) = "I" Then
$UserSearchRegion = "Italian-speaking regions"
ElseIf StringRight(StringLeft($IDFound, 4), 1) = "J" Then
$UserSearchRegion = "Japan"
ElseIf StringRight(StringLeft($IDFound, 4), 1) = "K" Then
$UserSearchRegion = "Korea"
ElseIf StringRight(StringLeft($IDFound, 4), 1) = "L" Then
$UserSearchRegion = "Japanese Import to Europe"
ElseIf StringRight(StringLeft($IDFound, 4), 1) = "M" Then
$UserSearchRegion = "American Import to Europe"
ElseIf StringRight(StringLeft($IDFound, 4), 1) = "N" Then
$UserSearchRegion = "Japanese Import to USA"
ElseIf StringRight(StringLeft($IDFound, 4), 1) = "P" Then
$UserSearchRegion = "Europe"
ElseIf StringRight(StringLeft($IDFound, 4), 1) = "S" Then
$UserSearchRegion = "Spanish-speaking regions"
ElseIf StringRight(StringLeft($IDFound, 4), 1) = "Q" Then
$UserSearchRegion = "Korea with Japanese language"
ElseIf StringRight(StringLeft($IDFound, 4), 1) = "T" Then
$UserSearchRegion = "Korea with English language"
ElseIf StringRight(StringLeft($IDFound, 4), 1) = "X" Then
$UserSearchRegion = "Not a real region code"
EndIf
Return $UserSearchRegion
EndFunc ;==>_GetRegion