Advertisement
IcarusLives

bget ui

Jul 21st, 2020
2,340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 13.59 KB | None | 0 0
  1. @ECHO OFF & setlocal enableDelayedExpansion & mode 120,55 & call :macros & call :init
  2.  
  3. :main
  4. TITLE BGET UI USER-INTERFACE
  5.  
  6. call :updateToggleButtons
  7. IF defined category (
  8.     SET "script[list]=!scriptInfo[%category%][list][%page%]!"
  9. ) else (
  10.     FOR /L %%G in (%dispMin%, 1, %dispMax%) DO (
  11.    
  12.         if /i "!searching!" equ "true" (
  13.             FOR /F "tokens=2,7 delims==" %%a in ("!scriptInfo[%%G]!") DO FOR %%X in ("%%~a" "%%~b") DO IF /I "!searchThis!" == "%%~X" set "script[list]=!script[list]! %%G"
  14.             IF "!script[list]!" == "" ECHO %esc%[%sbyp1%;%sbxp1%HNo results...
  15.             set /a "dispMin=1", "dispMax=20"
  16.         ) else SET "script[list]=!script[list]! %%G"
  17.  
  18.     )
  19. )
  20.  
  21. set "clickable=1"
  22. FOR %%# in (%script[list]%) DO (
  23.     set /a "clickable[!clickable!]=%%#", "clickable+=2"
  24.     SET "disp[line]=!disp[line]!!line[%%#]!%ESC%[2B"
  25. )
  26.  
  27. set "searching=false"
  28. set "catSearch=false"
  29. set "searchThis="
  30.  
  31. echo %esc%[1;1H%topl%%esc%[0m%esc%[3;0H%template%%botl%%esc%[0m%esc%[48;5;7m%esc%[38;5;16m%button[1]%%button[2]%%button[3]%%button[4]%%button[5]%%button[6]%%button[7]%%button[8]%%button[9]%%button[10]%%button[11]%%esc%[0m%toggleDisplay%%esc%[0m%searchBox%%esc%[2;1H³ ID  ³ Name             ³ Catagory      ³ Author               ³ Description              ³%ESC%[4;1H%disp[line]%
  32. SET "disp[line]="&SET "script[list]="
  33.  
  34. for /f "tokens=1-3" %%W in ('"bin\Mouse.exe"') do set /a "mouseC=%%W,mouseX=%%Y,mouseY=%%X"
  35.  
  36. %ifUserClicksButton[1]% ( IF defined category ( IF %page% NEQ 0 ( SET /A "page-=1" ) ) else IF %dispMin% NEQ 1 ( SET /A "dispMin-=20", "dispMax-=20" ) )
  37. %ifUserClicksButton[2]% ( IF defined category ( SET /A "page+=1" ) else ( SET /A "dispMin+=20", "dispMax+=20" ) )
  38. %ifUserClicksButton[3]% ( del /f /q "%~dp0\master.txt" & ( call :checkDownloadMethod "https://raw.githubusercontent.com/jahwi/bget-list/master/master.txt" "%~dp0\master.txt" ) )
  39. %ifUserClicksButton[4]% ( SET "page=1" & SET "category=game" & set "catSearch=true" )
  40. %ifUserClicksButton[5]% ( SET "page=1" & SET "category=utilities" & set "catSearch=true" )
  41. %ifUserClicksButton[6]% ( SET "page=1" & SET "category=example" & set "catSearch=true" )
  42. %ifUserClicksButton[7]% ( SET "page=1" & SET "category=tools" & set "catSearch=true" )
  43. %ifUserClicksButton[8]% ( SET "category=" & set "catSearch=false" )
  44. %ifUserClicksButton[9]% ( SET "page=1" & SET "category=library" & set "catSearch=true" )
  45. %ifUserClicksButton[10]% ( SET "page=1" & SET "category=graphics" & set "catSearch=true" )
  46. %ifUserClicksButton[11]% ( SET "page=1" & SET "category=devtools" & set "catSearch=true" )
  47.  
  48. %ifUserToggles[0]SET_TOGGLE%
  49. %ifUserToggles[1]SET_TOGGLE%
  50. %ifUserToggles[2]SET_TOGGLE%
  51. %ifUserToggles[3]SET_TOGGLE%
  52. %ifUserToggles[4]SET_TOGGLE%
  53.  
  54. %ifUserClicksSearchBar% ( set /a "dispMax=script_count" & set "searching=true" & set /p "searchThis=%esc%[%sbyp1%;%sbxp1%HSearch: " )
  55.  
  56. set /a "scriptButton=mouseY - 2"
  57. REM echo %esc%[48;1HIF %mouseX% LEQ 92 ( IF %mouseY% LEQ 43 (
  58. IF %mouseX% LEQ 92 ( IF %mouseY% LEQ 43 (
  59.    
  60.     echo !clickable[%scriptButton%]!
  61.         CALL :GET_INFO & ( IF %mouseC% EQU 1 ( CALL :GET_RECURSE ) else ( CALL :GET_DISP ) )
  62.     pause
  63.     REM )
  64.    
  65. ) )
  66. FOR %%# in (%script[list]%) DO set /a "clickable[!clickable!]="
  67. goto :main
  68.  
  69. :createSearchBar x y c
  70.     set "searchBox=%esc%[%~2;%~1H%esc%!!%~3mÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿%esc%[93D%esc%[B³                                                                                          ³%esc%[93D%esc%[BÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ%esc%[0m"
  71.     set /a "searchBox[Xmin]=%~1","searchBox[Xmax]=%~1 + 92","searchBox[Ymin]=%~2","searchBox[Ymax]=%~2 + 2", "sbxp1=%~1+1", "sbyp1=%~2+1"
  72.     set "ifUserClicksSearchBar=if ^!mouseY^! geq ^!searchBox[Ymin]^! if ^!mouseY^! leq ^!searchBox[Ymax]^! if ^!mouseX^! geq ^!searchBox[Xmin]^! if ^!mouseX^! leq ^!searchBox[Xmax]^!"
  73. goto :eof
  74.  
  75. :createToggle
  76.     if not defined toggleBoxTemplate set "toggleBoxTemplate=ÚÄÄÄ¿%esc%[B%esc%[5D³   ³%esc%[B%esc%[5DÀÄÄÄÙ%esc%[2A"
  77.     set /a "toggleArray=%~4 - 1", "togX=%~2", "togY=%~3", "oX=togX + 1", "oY=togY + 1", "up1=togY - 1", "ov1=oX", "togCol=%~5"
  78.     ( if "%~6" neq "" ( set /a "defaultToggle=%~6" ) else ( set /a "defaultToggle=0" )) & set /a "currentToggle=defaultToggle"
  79.     set "toggleBoxes=%esc%[%up1%;%ov1%H%~1%esc%[%togY%!!%togX%H" & set "toggleOverlay=%esc%[%oY%;%oX%H"
  80.    
  81.     for /l %%a in (0,1,%toggleArray%) do (
  82.         set "toggleBoxes=!toggleBoxes!%toggleBoxTemplate%"
  83.         if %currentToggle% equ %%a ( set "toggle[%%a]=%esc%[38;5;%~5mÛÛÛ" ) else set "toggle[%%a]=%esc%[38;5;16mÛÛÛ"
  84.         set "toggleOverlay=!toggleOverlay!!toggle[%%a]!%esc%[0m³³"
  85.         set /a "toggleX[%%a]=(%%a + 1) * 5 + %~2 - 6"
  86.     )
  87.     set /a "toggleX[%~4]=(%~4 + 1) * 5 + %~2 - 6"
  88.    
  89.     for /l %%a in (0,1,%toggleArray%) do (
  90.         set /a "n=%%a + 1"
  91.         for %%n in (!n!) do (
  92.             set "ifUserToggles[%%a]SET_TOGGLE=if ^!mouseY^! geq ^!toggleY[min]^! if ^!mouseY^! leq ^!toggleY[max]^! if ^!mouseX^! geq ^!toggleX[%%a]^! if ^!mouseX^! lss ^!toggleX[%%n]^! set currentToggle=%%a"
  93.         )
  94.     )
  95.  
  96.     set /a "toggleY[min]=%~3 - 1", "toggleY[max]=%~3 + 1"
  97.     set "toggleOverlay=!toggleOverlay:~0,-1!"
  98.     set "toggleDisplay=^!toggleBoxes^!^!toggleOverlay^!"
  99. goto :eof
  100.  
  101.  
  102. :updateToggleButtons
  103.     set "toggleOverlay=%esc%[%oY%;%oX%H"
  104.     for /l %%a in (0,1,%toggleArray%) do (
  105.         if !currentToggle! equ %%a ( set "toggle[%%a]=%esc%[38;5;%togCol%mÛÛÛ" ) else set "toggle[%%a]=%esc%[38;5;16mÛÛÛ"
  106.         set "toggleOverlay=!toggleOverlay!!toggle[%%a]!%esc%[0m³³"
  107.     )
  108.     set "toggleOverlay=%toggleOverlay:~0,-1%"
  109. goto :eof
  110.  
  111. :createButton
  112.     set /a "buttons+=1", "len=0"
  113.     set /a "button[X][%buttons%]=%~1", "button[Y][%buttons%]=%~2"
  114.     set "s=%~3#" & ( for %%P in (8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1) do ( if "!s:~%%P,1!" NEQ "" ( set /a "len+=%%P" & set "s=!s:~%%P!" ))) & set /a "len[%%e]=len" 2>nul
  115.     set /a "e=len&1", "len+=(((~(0-e)>>31)&1)&((~(e-0)>>31)&1))+1", "len+=(((~(1-e)>>31)&1)&((~(e-1)>>31)&1))", "back=len + 2"
  116.     set "buttonWidth=" & (for /l %%a in (1,1,%len%) do set "buttonWidth=!buttonWidth!Ä")
  117.     set "button[%buttons%]=%esc%[!button[Y][%buttons%]!;!button[X][%buttons%]!HÚ%buttonWidth%¿%esc%[%back%D%esc%[B³ %~3 ³%esc%[%back%D%esc%[BÀ%buttonWidth%Ù"
  118.     set /a "button[%buttons%][Xmin]=%~1-1","button[%buttons%][Xmax]=%~1 + len","button[%buttons%][Ymin]=%~2-1","button[%buttons%][Ymax]=%~2 + 1"
  119.     set "ifUserClicksButton[!buttons!]=if ^!mouseY^! geq ^!button[%buttons%][Ymin]^! if ^!mouseY^! leq ^!button[%buttons%][Ymax]^! if ^!mouseX^! geq ^!button[%buttons%][Xmin]^! if ^!mouseX^! leq ^!button[%buttons%][Xmax]^!"
  120. goto :eof
  121.  
  122. :checkDownloadMethod
  123.     if %currentToggle%==3 (
  124.         set /a rnd=%random% & ( bitsadmin /transfer BgetUI!rnd! /download /priority HIGH "%~1" "%~2" >nul ) & set rnd=
  125.     ) else if %currentToggle%==0 (
  126.         cscript //NoLogo //e:Jscript "%~dp0\bin\download.js" "%~1" "%~2"
  127.     ) else if %currentToggle%==4 (
  128.         "%~dp0\curl\curl.exe" -s "%~1" -o "%~2"
  129.     ) else if %currentToggle%==1 (
  130.         Powershell.exe -command "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;(New-Object System.Net.WebClient).DownloadFile('%~1','%~2')"
  131.     ) else if %currentToggle%==2 (
  132.         cscript //NoLogo //e:VBScript "%~dp0\bin\download.vbs" "%~1" "%~2"
  133.     )
  134. goto :eof
  135.  
  136. :GET_INFO
  137. FOR /F "tokens=1-9 delims==" %%a in ("!clickable[%scriptButton%]!") DO (
  138.     (
  139.         echo %%a
  140.         echo %%b
  141.         echo %%c
  142.         echo %%d
  143.         echo %%e
  144.         echo %%f
  145.         echo %%g
  146.         echo %%h
  147.         echo %%i
  148.     )>scriptInfo.txt
  149.     SET "scriptInfo[temp][fileName]=%%~e"
  150.     SET "scriptInfo[temp][name]=%%~b"
  151.     SET "scriptInfo[temp][scriptLocation]=%%~c"
  152.     SET "scriptInfo[temp][author]=%%~g"
  153.     SET "scriptInfo[temp][hash]=%%~f"
  154.     SET "scriptInfo[temp][description]=%%~d"
  155.     SET "scriptInfo[temp][Date]=%%~i"
  156. )
  157. GOTO :EOF
  158.  
  159. :GET_DISP
  160. FOR %%G in (Author Filename Date) DO (
  161.     SET "scriptInfo[disp]=!scriptInfo[disp]!%ESC%[3G%%G : class="re0">!scriptInfo[temp][%%G]!%ESC%[0K%ESC%[1B"
  162. )
  163. ECHO %ESC%[49d!scriptInfo[disp]!
  164. SET "scriptInfo[disp]="
  165. GOTO :EOF
  166.  
  167. :get_recurse
  168.     title Downloading %scriptInfo[temp][fileName]% by %scriptInfo[temp][author]%
  169.     if not exist %script_location%\%scriptInfo[temp][name]% ( md "%script_location%\%scriptInfo[temp][name]%" ) else goto :eof
  170.     call :checkDownloadMethod "%scriptInfo[temp][scriptLocation]%" "%script_location%\%scriptInfo[temp][name]%\%scriptInfo[temp][fileName]%"
  171.         FOR %%Q in (hash description author) DO (
  172.             ECHO !scriptInfo[temp][%%Q]!>%script_location%\%scriptInfo[temp][name]%\%%Q.txt"
  173.         )
  174.     if "%scriptInfo[temp][fileName]:~-4%"==".cab" (
  175.         echo Extracting...
  176.         call :cab "%script_location%\%scriptInfo[temp][name]%\%scriptInfo[temp][fileName]%" "%script_location%\%scriptInfo[temp][name]%"
  177.     ) else if "!scriptInfo[temp][fileName]:~-4!"==".zip" (
  178.         echo Extracting...
  179.         call :unzip "%script_location%\%scriptInfo[temp][name]%\%scriptInfo[temp][fileName]%" "%script_location%\%scriptInfo[temp][name]%"
  180.     )
  181. goto :eof
  182.  
  183. :unzip
  184.     set zip=%~1
  185.     set unzip_path=%~2
  186.     set zip=!zip:\\=\!
  187.     set /a ziprand=%random%
  188.     set unzip_path=!unzip_path:\\=\!
  189.  
  190.  
  191.     echo ZipFile="!zip!">"%~dp0\temp\unzip!ziprand!.vbs"
  192.     echo ExtractTo="!unzip_path!">>"%~dp0\temp\unzip!ziprand!.vbs"
  193.     echo set objShell = CreateObject^("Shell.Application"^)>>"%~dp0\temp\unzip!ziprand!.vbs"
  194.     echo set FilesInZip=objShell.NameSpace(ZipFile).items>>"%~dp0\temp\unzip!ziprand!.vbs"
  195.     echo objShell.NameSpace^(ExtractTo^).CopyHere^(FilesInZip^)>>"%~dp0\temp\unzip!ziprand!.vbs"
  196.     echo Set fso = Nothing>>"%~dp0\temp\unzip!ziprand!.vbs"
  197.     echo Set objShell = Nothing>>"%~dp0\temp\unzip!ziprand!.vbs"
  198.     cscript //NOLOGO "%~dp0\temp\unzip!ziprand!.vbs"
  199.     if exist "%~dp0\temp\unzip!ziprand!.vbs" del /f /q "%~dp0\temp\unzip!ziprand!.vbs"
  200.    
  201.     if not exist "!unzip_path!\package" md "!unzip_path!\package"
  202.     move /Y "!zip!" "!unzip_path!\package" 
  203.    
  204.     set ziprand=
  205.     set zip=
  206.     set unzip_path=
  207.     exit /b
  208.  
  209. :cab
  210.     set cab=%~1
  211.     set cab_path=%~2
  212.     set cab=!cab:\\=\!
  213.     set cab_path=!cab_path:\\=\!
  214.    
  215.     expand "!cab!" -F:* "!cab_path!" >nul
  216.     if not exist "!cab_path!\package" md "!cab_path!\package"
  217.     move /Y "!cab!" "!cab_path!\package"
  218.    
  219.     set cab=
  220.     set cab_path=
  221.     exit /b
  222.  
  223. :macros
  224. (set \n=^^^
  225. %= This creates an escaped Line Feed - DO NOT ALTER =%
  226. )
  227.  
  228. ( for /f %%a in ('echo prompt $E^| cmd') do set "esc=%%a" ) & <nul set /p "=!esc![?25l"
  229.  
  230. set "topl=ÚÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
  231. set "line=ÃÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´"
  232. set "botl=ÀÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
  233.  
  234. goto :eof
  235.  
  236. :init
  237.     SET /A "game[col]=9","utilities[col]=10","tools[col]=11","library[col]=12","graphics[col]=13","example[col]=5","devtools[col]=7"
  238.     if not exist %~dp0scripts md %~dp0scripts
  239.    
  240.     set "map=?=(c)+((d)-(c))*((v)-(a))/((b)-(a))"
  241.    
  242.     set "script_location=%~dp0scripts"
  243.     call :createButton 93 8 "Prev Page"
  244.     call :createButton 106 8 "Next Page"
  245.     call :createButton 93 12 "Update list"
  246.     CALL :CREATEBUTTON 93 24 "Games"
  247.     CALL :CREATEBUTTON 93 16 "Utilities"
  248.     CALL :CREATEBUTTON 93 20 "Examples"
  249.     CALL :CREATEBUTTON 93 28 "Tools"
  250.     CALL :CREATEBUTTON 112 12 "All"
  251.     CALL :CREATEBUTTON 93 36 "Libraries"
  252.     CALL :CREATEBUTTON 93 32 "Graphics"
  253.     CALL :CREATEBUTTON 93 40 "Dev-Tools"
  254.     call :createSearchBar 1 44 10
  255.     call :createToggle "JS   PS   VBS  BITS CURL" 93 3 5 12 3
  256.     IF not exist master.txt (
  257.         call :checkDownloadMethod "https://raw.githubusercontent.com/jahwi/bget-list/master/master.txt" "%~dp0\master.txt"
  258.     )
  259.     for /f "tokens=1-9 delims=," %%a in ('findstr /b /c:"[#]," "%~dp0master.txt"') do (
  260.         set /a "script_count+=1"
  261.         ECHO %ESC%[27;55H%ESC%[38;2;0;!script_count!;!script_count!mLoading !script_count!
  262.         REM ID name scriptLocation description fileName hash author category dateAdded
  263.         SET "scriptInfo[!script_count!]="%%~a"="%%~b"="%%~c"="%%~d"="%%~e"="%%~f"="%%~g"="%%~h"="%%~i""
  264.         IF not defined scriptInfo[%%~h][page] (
  265.             SET "scriptInfo[%%~h][page]=0"
  266.             SET "scriptInfo[Category][%%~h]=-1"
  267.         )
  268.         SET /A "scriptInfo[Category][%%~h]+=1","check=scriptInfo[Category][%%~h] %% 20"
  269.         IF !check! EQU 0  SET /A "scriptInfo[%%~h][page]+=1"
  270.                
  271.         FOR /F %%X in ("!scriptInfo[%%~h][page]!") DO SET "scriptInfo[%%~h][list][%%X]=!scriptInfo[%%~h][list][%%X]! !script_count!"
  272.                
  273.         FOR %%G in ("5=!script_count!=2" "17=%%~b=8" "14=%%~h=27" "21=%%~g=43" "25=%%~d=66") DO (
  274.             FOR /F "tokens=1-4 delims==" %%A in ("%%~G=!script_count!") DO (
  275.                 SET "temp[script]=%%B"
  276.                 IF defined %%B[col] SET "col[temp]=%ESC%[38;5;!%%B[col]!m"
  277.                 SET "line[%%D]=!line[%%D]!%ESC%[%%CG!col[temp]!!temp[script]:~0,%%A!%ESC%[0m"
  278.                 SET "col[temp]="
  279.             )
  280.         )
  281.     )
  282.     set /a "dispMin=1", "dispMax=20","page=1"
  283.     for /l %%a in (1,1,%dispMax%) do set "template=!template!ÃÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´%esc%[B%esc%[92D³     ³                  ³               ³                      ³                          ³%esc%[B%esc%[92D"
  284.  
  285.     echo %esc%[0m & CLS
  286. goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement