Created
May 17, 2026 13:42
-
-
Save EncodeTheCode/db5c3bf3d9941872b18192fe91566c2a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <GUIConstantsEx.au3> | |
| #include <WindowsConstants.au3> | |
| #include <GUIListView.au3> | |
| #include <File.au3> | |
| #include <GUITab.au3> | |
| #include <Array.au3> | |
| Global $C1 = "Game Title", $G = "Game", $L = " Library Loaded!", $C2 = $G & " ID", $C3 = "Serial", $C4 = "Release Date", $C5 = "Version" | |
| Global $Columns = String($C1 & "|" & $C2 & "|" & $C3 & "|" & $C4 & "|" & $C5) | |
| ; --- Toast settings --- | |
| Global $g_iToastWidth = 360 | |
| Global $g_iToastHeight = 92 | |
| Global $g_iToastRadius = 18 | |
| Global $g_iToastStayMs = 6000 | |
| Global $g_iToastFadeInMs = 440 | |
| Global $g_iToastFadeOutMs = 1350 | |
| Global $g_iToastEdgePad = 9 | |
| Global $g_bToastRunning = False | |
| Global $g_hToast = 0 | |
| ; --- CSV counts --- | |
| Global $iPALCount = 0, $iNTSCUCount = 0, $iNTSCJCount = 0 | |
| ; --- Create GUI --- | |
| Global $hAppT = "List View Manager" | |
| Global $hGUI = GUICreate("PlayStation One - Game Library - " & $hAppT, 850, 650) | |
| ; --- Buttons --- | |
| Global $btnLoadPAL = GUICtrlCreateButton("Load PAL CSV", 20, 12, 100, 19) | |
| Global $btnLoadNTSCU = GUICtrlCreateButton("Load NTSC-U CSV", 130, 12, 120, 19) | |
| Global $btnLoadNTSCJ = GUICtrlCreateButton("Load NTSC-J CSV", 260, 12, 120, 19) | |
| Global $btnDelete1 = GUICtrlCreateButton("Delete Items on Tab 1", 400, 12, 150, 19) | |
| Global $btnDelete2 = GUICtrlCreateButton("Delete Items on Tab 2", 555, 12, 150, 19) | |
| Global $btnDelete3 = GUICtrlCreateButton("Delete Items on Tab 3", 710, 12, 150, 19) | |
| ; --- Tabs --- | |
| Global $hTab = GUICtrlCreateTab(10, 40, 830, 580) | |
| Global $hTab1 = GUICtrlCreateTabItem("PAL") | |
| Global $hListView1 = GUICtrlCreateListView($Columns, 20, 70, 808, 550, $LVS_SHOWSELALWAYS) | |
| GUICtrlSetStyle($hListView1, $LVS_REPORT) | |
| GUICtrlCreateTabItem("NTSC-U (America)") | |
| Global $hListView2 = GUICtrlCreateListView($Columns, 20, 70, 808, 550, $LVS_SHOWSELALWAYS) | |
| GUICtrlSetStyle($hListView2, $LVS_REPORT) | |
| GUICtrlCreateTabItem("NTSC-J (Asia/Japan)") | |
| Global $hListView3 = GUICtrlCreateListView($Columns, 20, 70, 808, 550, $LVS_SHOWSELALWAYS) | |
| GUICtrlSetStyle($hListView3, $LVS_REPORT) | |
| GUICtrlCreateTabItem("") | |
| ; --- Status Label --- | |
| Global $lblStatus = GUICtrlCreateLabel("", 10, 620, 830, 20) | |
| ; --- Sorting state --- | |
| Global $g_aSortOrder[3][5] | |
| For $iLV = 0 To 2 | |
| For $iCol = 0 To 4 | |
| $g_aSortOrder[$iLV][$iCol] = 0 | |
| Next | |
| Next | |
| GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") | |
| GUISetState(@SW_SHOW, $hGUI) | |
| ; ========================= | |
| ; Functions | |
| ; ========================= | |
| Func _UpdateStatusLabel() | |
| GUICtrlSetData($lblStatus, "PAL: " & $iPALCount & " | NTSC-U: " & $iNTSCUCount & " | NTSC-J: " & $iNTSCJCount) | |
| EndFunc | |
| Func _ReadCSV($sFilePath, $hListView) | |
| Local $aLines = FileReadToArray($sFilePath) | |
| If @error Then Return False | |
| _GUICtrlListView_DeleteAllItems($hListView) | |
| For $iIndex = 0 To UBound($aLines) - 1 | |
| If StringStripWS($aLines[$iIndex], 3) = "" Then ContinueLoop | |
| Local $aFields = StringSplit($aLines[$iIndex], "|") | |
| If $aFields[0] < 1 Then ContinueLoop | |
| Local $iRow = _GUICtrlListView_AddItem($hListView, $aFields[1]) | |
| For $i = 2 To $aFields[0] | |
| _GUICtrlListView_AddSubItem($hListView, $iRow, $aFields[$i], $i - 1) | |
| Next | |
| Next | |
| ; Update counts correctly | |
| Switch $hListView | |
| Case $hListView1 | |
| $iPALCount = _GUICtrlListView_GetItemCount($hListView1) | |
| Case $hListView2 | |
| $iNTSCUCount = _GUICtrlListView_GetItemCount($hListView2) | |
| Case $hListView3 | |
| $iNTSCJCount = _GUICtrlListView_GetItemCount($hListView3) | |
| EndSwitch | |
| _UpdateStatusLabel() | |
| Return True | |
| EndFunc | |
| Func _GUICtrlListView_CreateArray($hListView) | |
| Local $iItemCount = _GUICtrlListView_GetItemCount($hListView) | |
| If $iItemCount <= 0 Then Return SetError(1,0,0) | |
| Local $aItems[$iItemCount][5] | |
| For $i = 0 To $iItemCount-1 | |
| $aItems[$i][0] = _GUICtrlListView_GetItemText($hListView, $i, 0) | |
| For $j = 1 To 4 | |
| $aItems[$i][$j] = _GUICtrlListView_GetItemText($hListView, $i, $j) | |
| Next | |
| Next | |
| Return $aItems | |
| EndFunc | |
| Func __SwapRows(ByRef $aData, $iA, $iB) | |
| Local $aTemp[5] | |
| For $i = 0 To 4 | |
| $aTemp[$i] = $aData[$iA][$i] | |
| $aData[$iA][$i] = $aData[$iB][$i] | |
| $aData[$iB][$i] = $aTemp[$i] | |
| Next | |
| EndFunc | |
| Func __QuickSort2D(ByRef $aData, $iLeft, $iRight, $iColumn, $bDescending) | |
| Local $i = $iLeft, $j = $iRight | |
| Local $sPivot = $aData[Int(($iLeft+$iRight)/2)][$iColumn] | |
| Local $bAsc = Not $bDescending | |
| While $i <= $j | |
| If $bAsc Then | |
| While StringCompare($aData[$i][$iColumn], $sPivot, 0) < 0 | |
| $i += 1 | |
| WEnd | |
| While StringCompare($aData[$j][$iColumn], $sPivot, 0) > 0 | |
| $j -= 1 | |
| WEnd | |
| Else | |
| While StringCompare($aData[$i][$iColumn], $sPivot, 0) > 0 | |
| $i += 1 | |
| WEnd | |
| While StringCompare($aData[$j][$iColumn], $sPivot, 0) < 0 | |
| $j -= 1 | |
| WEnd | |
| EndIf | |
| If $i <= $j Then | |
| If $i <> $j Then __SwapRows($aData, $i, $j) | |
| $i += 1 | |
| $j -= 1 | |
| EndIf | |
| WEnd | |
| If $iLeft < $j Then __QuickSort2D($aData, $iLeft, $j, $iColumn, $bDescending) | |
| If $i < $iRight Then __QuickSort2D($aData, $i, $iRight, $iColumn, $bDescending) | |
| EndFunc | |
| Func _SortListView($hListView, $iColumn, $bDescending) | |
| Local $aItems = _GUICtrlListView_CreateArray($hListView) | |
| If @error Then Return | |
| __QuickSort2D($aItems, 0, UBound($aItems)-1, $iColumn, $bDescending) | |
| _GUICtrlListView_DeleteAllItems($hListView) | |
| For $i = 0 To UBound($aItems)-1 | |
| Local $iRow = _GUICtrlListView_AddItem($hListView, $aItems[$i][0]) | |
| For $j = 1 To 4 | |
| _GUICtrlListView_AddSubItem($hListView, $iRow, $aItems[$i][$j], $j) | |
| Next | |
| Next | |
| EndFunc | |
| Func _GetWorkAreaRect() | |
| Local $tRect = DllStructCreate("long Left;long Top;long Right;long Bottom") | |
| DllCall("user32.dll", "bool", "SystemParametersInfoW", "uint", 0x0030, "uint", 0, "ptr", DllStructGetPtr($tRect), "uint", 0) | |
| Return $tRect | |
| EndFunc | |
| Func _SetRoundedCorners($hWnd, $iWidth, $iHeight, $iRadius) | |
| Local $aRgn = DllCall("gdi32.dll", "handle", "CreateRoundRectRgn", _ | |
| "int", 0, "int", 0, "int", $iWidth + 1, "int", $iHeight + 1, _ | |
| "int", $iRadius, "int", $iRadius) | |
| If Not @error Then | |
| DllCall("user32.dll", "int", "SetWindowRgn", "hwnd", $hWnd, "handle", $aRgn[0], "int", True) | |
| EndIf | |
| EndFunc | |
| Func _ToastFade($hWnd, $iFrom, $iTo, $iDuration) | |
| Local $iSteps = 20 | |
| Local $iDelay = Int($iDuration / $iSteps) | |
| For $i = 0 To $iSteps | |
| Local $iAlpha = Int($iFrom + (($iTo - $iFrom) * $i / $iSteps)) | |
| WinSetTrans($hWnd, "", $iAlpha) | |
| ; Allow exit | |
| If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit | |
| Sleep($iDelay) | |
| If Not WinExists($hWnd) Then ExitLoop | |
| Next | |
| EndFunc | |
| Func _ShowToast($sText) | |
| If $g_bToastRunning Then Return | |
| $g_bToastRunning = True | |
| Local $tWork = _GetWorkAreaRect() | |
| Local $iLeft = DllStructGetData($tWork, "Right") - $g_iToastWidth - $g_iToastEdgePad | |
| Local $iTop = DllStructGetData($tWork, "Bottom") - $g_iToastHeight - $g_iToastEdgePad | |
| $g_hToast = GUICreate("", $g_iToastWidth, $g_iToastHeight, $iLeft, $iTop, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW, $WS_EX_LAYERED)) | |
| GUISetBkColor(0x1E1E1E, $g_hToast) | |
| Local $idLabel = GUICtrlCreateLabel($sText, 16, 14, $g_iToastWidth - 32, $g_iToastHeight - 28) | |
| GUICtrlSetColor($idLabel, 0xFFFFFF) | |
| GUISetState(@SW_SHOW, $g_hToast) | |
| _SetRoundedCorners($g_hToast, $g_iToastWidth, $g_iToastHeight, $g_iToastRadius) | |
| WinSetTrans($g_hToast, "", 0) | |
| _ToastFade($g_hToast, 0, 255, $g_iToastFadeInMs) | |
| Local $tStart = TimerInit() | |
| While TimerDiff($tStart) < $g_iToastStayMs | |
| If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit | |
| If Not WinExists($g_hToast) Then ExitLoop | |
| Sleep(50) | |
| WEnd | |
| If WinExists($g_hToast) Then | |
| _ToastFade($g_hToast, 255, 0, $g_iToastFadeOutMs) | |
| GUIDelete($g_hToast) | |
| EndIf | |
| $g_bToastRunning = False | |
| EndFunc | |
| Func SetColumnWidth() | |
| Local $s = [25,50,85,100,125,150,175,200,225,250,275,300,325,350] | |
| ; Ensure we have enough indices | |
| Local $aColIndices = [10, 2, 8, 4, 3] | |
| For $i = 0 To 4 | |
| _GUICtrlListView_SetColumnWidth($hListView1, $i, $s[$aColIndices[$i]]) | |
| _GUICtrlListView_SetColumnWidth($hListView2, $i, $s[$aColIndices[$i]]) | |
| _GUICtrlListView_SetColumnWidth($hListView3, $i, $s[$aColIndices[$i]]) | |
| Next | |
| EndFunc | |
| SetColumnWidth() | |
| ; --- Automatically load CSVs at startup --- | |
| If _ReadCSV("PAL.csv", $hListView1) Then $iPALCount = _GUICtrlListView_GetItemCount($hListView1) | |
| If _ReadCSV("NTSC-U.csv", $hListView2) Then $iNTSCUCount = _GUICtrlListView_GetItemCount($hListView2) | |
| If _ReadCSV("NTSC-J.csv", $hListView3) Then $iNTSCJCount = _GUICtrlListView_GetItemCount($hListView3) | |
| _UpdateStatusLabel() | |
| ; --- Show toast with counts --- | |
| _ShowToast($G & $L & @CRLF & @CRLF & _ | |
| "PAL " & $G & "s: " & $iPALCount & @CRLF & _ | |
| "NTSC-U " & $G & "s: " & $iNTSCUCount & @CRLF & _ | |
| "NTSC-J " & $G & "s: " & $iNTSCJCount) | |
| ; ========================= | |
| ; WM_NOTIFY for column clicks | |
| ; ========================= | |
| Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) | |
| Local $tNMLV = DllStructCreate($tagNMLISTVIEW, $lParam) | |
| If @error Then Return $GUI_RUNDEFMSG | |
| If DllStructGetData($tNMLV, "Code") <> $LVN_COLUMNCLICK Then Return $GUI_RUNDEFMSG | |
| Local $hFrom = DllStructGetData($tNMLV, "hWndFrom") | |
| Local $iColumn = DllStructGetData($tNMLV, "SubItem") | |
| Local $iListIndex = -1 | |
| Switch $hFrom | |
| Case GUICtrlGetHandle($hListView1) | |
| $iListIndex = 0 | |
| Case GUICtrlGetHandle($hListView2) | |
| $iListIndex = 1 | |
| Case GUICtrlGetHandle($hListView3) | |
| $iListIndex = 2 | |
| EndSwitch | |
| If $iListIndex = -1 Then Return $GUI_RUNDEFMSG | |
| Local $bDesc = $g_aSortOrder[$iListIndex][$iColumn] | |
| _SortListView($hFrom, $iColumn, $bDesc) | |
| $g_aSortOrder[$iListIndex][$iColumn] = Not $bDesc | |
| Return $GUI_RUNDEFMSG | |
| EndFunc | |
| ; ========================= | |
| ; MAIN LOOP | |
| ; ========================= | |
| While 1 | |
| Local $msg = GUIGetMsg() | |
| Switch $msg | |
| Case $GUI_EVENT_CLOSE | |
| Exit | |
| Case $btnDelete1 | |
| _GUICtrlListView_DeleteAllItems($hListView1) | |
| $iPALCount = 0 | |
| _UpdateStatusLabel() | |
| Case $btnDelete2 | |
| _GUICtrlListView_DeleteAllItems($hListView2) | |
| $iNTSCUCount = 0 | |
| _UpdateStatusLabel() | |
| Case $btnDelete3 | |
| _GUICtrlListView_DeleteAllItems($hListView3) | |
| $iNTSCJCount = 0 | |
| _UpdateStatusLabel() | |
| Case $btnLoadPAL | |
| If _ReadCSV("PAL.csv", $hListView1) Then _ShowToast("PAL CSV loaded successfully") | |
| Case $btnLoadNTSCU | |
| If _ReadCSV("NTSC-U.csv", $hListView2) Then _ShowToast("NTSC-U CSV loaded successfully") | |
| Case $btnLoadNTSCJ | |
| If _ReadCSV("NTSC-J.csv", $hListView3) Then _ShowToast("NTSC-J CSV loaded successfully") | |
| EndSwitch | |
| WEnd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment