@echo off
if "%1"=="whatis" echo ASCII image viewer&goto :eof
if exist log_os\LogOS_is_running goto asvi
goto error
:error
Echo.
Echo This application can only be run inside Log OS.
Echo.
pause
exit
:asvi
setlocal EnableDelayedExpansion EnableExtensions
set "bg="
set "filename="
set "answer="
if exist Return_to_start del Return_to_start&goto start
cls
color %rndcolor%
Echo.
Echo.    oo       ooooooo   ooooooo  oooooo  oooooo
Echo.  oo  oo    oo        o           oo      oo
Echo. oo    oo  oo         o           oo      oo
Echo. oo    oo   ooooooo   o           oo      oo
Echo. oooooooo         oo  o           oo      oo
Echo. oo    oo        oo   o           oo      oo
Echo. oo    oo  ooooooo     ooooooo  oooooo  oooooo
Echo.
Echo.                   viewer
Echo.
Echo. 1. Load image with autodetected settings
Echo. 2. Load image with colors
Echo. 3. Load plain image without colors
Echo. 4. List my pictures
Echo. 5. List public pictures
Echo. 6. Exit
Echo.
set /p answer=Your selection:
if "%answer%"=="1" goto detectasvi
if "%answer%"=="2" goto colorasvi
if "%answer%"=="3" goto playasvi
if "%answer%"=="4" (
	cls
	echo My pictures:
	echo.
	for /f "delims=" %%a in ('dir /b specific_user\%user%\picture') do (
		
		set /p test=<"specific_user\%user%\picture\%%a"
		set "color=yes"
		if not "!test:~0,8!"=="bg print" set "color=no"
		if "!color!"=="yes" (
			bg print 07 "%%a ["&&bg print 0a "color"&echo ]
		) else (
			bg print 07 "%%a ["&&bg print 0c "plain"&echo ]
		)
	)
	echo.
	pause
)
if "%answer%"=="5" (
	cls
	echo Public pictures:
	echo.
	for /f "delims=" %%a in ('dir /b specific_os\share\picture') do (
		
		set /p test=<"specific_os\share\picture\%%a"
		set "color=yes"
		if not "!test:~0,8!"=="bg print" set "color=no"
		if "!color!"=="yes" (
			bg print 07 "%%a ["&&bg print 0a "color"&echo ]
		) else (
			bg print 07 "%%a ["&&bg print 0c "plain"&echo ]
		)
	)
	echo.
	pause
)
if "%answer%"=="6" cls&endlocal&exit
set "color="
goto asvi

:detectasvi
cls
Echo.
Echo.    oo       ooooooo   ooooooo  oooooo  oooooo
Echo.  oo  oo    oo        o           oo      oo
Echo. oo    oo  oo         o           oo      oo
Echo. oo    oo   ooooooo   o           oo      oo
Echo. oooooooo         oo  o           oo      oo
Echo. oo    oo        oo   o           oo      oo
Echo. oo    oo  ooooooo     ooooooo  oooooo  oooooo
Echo.
Echo.                   viewer
Echo.
set /p filename=Enter file name:
set "filename=%filename:\=%"
if exist "%cd%\specific_user\%user%\picture\%filename%" set "filename=%cd%\specific_user\%user%\picture\%filename%"
if exist "%cd%\specific_user\%user%\picture\%filename%.ascii" set "filename=%cd%\specific_user\%user%\picture\%filename%.ascii"
if exist "%cd%\specific_os\share\picture\%filename%" set "filename=%cd%\specific_os\share\picture\%filename%"
if exist "%cd%\specific_os\share\picture\%filename%.ascii" set "filename=%cd%\specific_os\share\picture\%filename%.ascii"
set "filename=%filename:..=%"
set "filename=%filename:.bat=%"
set "filename=%filename:.cmd=%"
set /p test=<"%filename%"
set "color=yes"
if not "!test:~0,8!"=="bg print" set "color=no"
if "%color%"=="yes" goto trygray
if "%color%"=="no" goto playasvi
goto asvi
:playasvi
cls
Echo.
Echo.    oo       ooooooo   ooooooo  oooooo  oooooo
Echo.  oo  oo    oo        o           oo      oo
Echo. oo    oo  oo         o           oo      oo
Echo. oo    oo   ooooooo   o           oo      oo
Echo. oooooooo         oo  o           oo      oo
Echo. oo    oo        oo   o           oo      oo
Echo. oo    oo  ooooooo     ooooooo  oooooo  oooooo
Echo.
Echo.                   viewer
Echo.
Echo. Select background color
Echo.
Echo. 1. White background, black text
Echo. 2. Black background, white text
Echo. 3. Black background, green text
Echo. 4. Black background, blue text
Echo. 5. Black background, gray text
Echo. 6. White background, gray text
Echo. 7. Black background, yellow text
Echo. 8. Black background, red text
Echo. 9. Black background, purple text
Echo.
set /p answer=Your selection:
if "%answer%"=="1" set bg=F0&goto asvfres
if "%answer%"=="2" set bg=0F&goto asvfres
if "%answer%"=="3" set bg=0A&goto asvfres
if "%answer%"=="4" set bg=09&goto asvfres
if "%answer%"=="5" set bg=08&goto asvfres
if "%answer%"=="6" set bg=F8&goto asvfres
if "%answer%"=="7" set bg=0E&goto asvfres
if "%answer%"=="8" set bg=0C&goto asvfres
if "%answer%"=="9" set bg=0D&goto asvfres
goto playasvi
:asvfres
if "%resolutiony%"=="" set resolutiony=90
if "%resolutionx%"=="" set resolutionx=300
if not "%color%"=="" set "color="&goto viewtheascii
:asvfname
cls
Echo.
Echo.    oo       ooooooo   ooooooo  oooooo  oooooo
Echo.  oo  oo    oo        o           oo      oo
Echo. oo    oo  oo         o           oo      oo
Echo. oo    oo   ooooooo   o           oo      oo
Echo. oooooooo         oo  o           oo      oo
Echo. oo    oo        oo   o           oo      oo
Echo. oo    oo  ooooooo     ooooooo  oooooo  oooooo
Echo.
Echo.                   viewer
Echo.
set /p filename=Enter file name:
set "filename=%filename:\=%"
if exist "%cd%\specific_user\%user%\picture\%filename%" set "filename=%cd%\specific_user\%user%\picture\%filename%"
if exist "%cd%\specific_user\%user%\picture\%filename%.ascii" set "filename=%cd%\specific_user\%user%\picture\%filename%.ascii"
if exist "%cd%\specific_os\share\picture\%filename%" set "filename=%cd%\specific_os\share\picture\%filename%"
if exist "%cd%\specific_os\share\picture\%filename%.ascii" set "filename=%cd%\specific_os\share\picture\%filename%.ascii"
set "filename=%filename:..=%"
set "filename=%filename:.bat=%"
set "filename=%filename:.cmd=%"
:viewtheascii
set /p test=<"%filename%"
if "%test:~0,8%"=="bg print" goto trygray
if not exist "%filename%" goto asvierr
cls
bg font 0
mode %resolutionx%,%resolutiony%
color %bg%
type "%filename%"
Pause >nul
mode 150,45
bg font 6
goto asvi

:viewtheimage
@echo.>Return_to_start
set filename=%answer%
goto viewtheascii

:typerror
cls
Echo.
Echo.    oo       ooooooo   ooooooo  oooooo  oooooo
Echo.  oo  oo    oo        o           oo      oo
Echo. oo    oo  oo         o           oo      oo
Echo. oo    oo   ooooooo   o           oo      oo
Echo. oooooooo         oo  o           oo      oo
Echo. oo    oo        oo   o           oo      oo
Echo. oo    oo  ooooooo     ooooooo  oooooo  oooooo
Echo.
Echo.                   viewer
Echo.
Echo This is a color image and must be viewed as a color
Echo image.
Echo.
Pause
goto asvi

:typerror2
cls
Echo.
Echo.    oo       ooooooo   ooooooo  oooooo  oooooo
Echo.  oo  oo    oo        o           oo      oo
Echo. oo    oo  oo         o           oo      oo
Echo. oo    oo   ooooooo   o           oo      oo
Echo. oooooooo         oo  o           oo      oo
Echo. oo    oo        oo   o           oo      oo
Echo. oo    oo  ooooooo     ooooooo  oooooo  oooooo
Echo.
Echo.                   viewer
Echo.
Echo This is not a color image and cannot be viewed as
Echo a color image.
Echo.
Pause
goto asvi

:colorasvi
cls
Echo.
Echo.    oo       ooooooo   ooooooo  oooooo  oooooo
Echo.  oo  oo    oo        o           oo      oo
Echo. oo    oo  oo         o           oo      oo
Echo. oo    oo   ooooooo   o           oo      oo
Echo. oooooooo         oo  o           oo      oo
Echo. oo    oo        oo   o           oo      oo
Echo. oo    oo  ooooooo     ooooooo  oooooo  oooooo
Echo.
Echo.                   viewer
Echo.
Echo. Enter file name:
set /p filename=
set "filename=%filename:\=%"
if exist "%cd%\specific_user\%user%\picture\%filename%" set "filename=specific_user\%user%\picture\%filename%"
if exist "%cd%\specific_user\%user%\picture\%filename%.ascii" set "filename=specific_user\%user%\picture\%filename%.ascii"
if exist "%cd%\specific_os\share\picture\%filename%" set "filename=%cd%\specific_os\share\picture\%filename%"
if exist "%cd%\specific_os\share\picture\%filename%.ascii" set "filename=%cd%\specific_os\share\picture\%filename%.ascii"
set "filename=%filename:..=%"
set "filename=%filename:.bat=%"
set "filename=%filename:.cmd=%"
set /p test=<"%filename%"
:trygray
::if not "%test:~0,8%"=="bg print" goto typerror2
if not exist "%filename%" goto asvierr
cls
bg font 0
mode 300,90
color 0F
copy "%filename%" "ascii.bat" /Y >nul
title Processing color ASCII image...
call ascii.bat
title Welcome %user% to %OSname%
del ascii.bat
pause >nul
mode %screen_w%,%screen_h%
bg font 6
color %rndcolor%
goto asvi

:asvierr
cls
Echo.
Echo.    oo       ooooooo   ooooooo  oooooo  oooooo
Echo.  oo  oo    oo        o           oo      oo
Echo. oo    oo  oo         o           oo      oo
Echo. oo    oo   ooooooo   o           oo      oo
Echo. oooooooo         oo  o           oo      oo
Echo. oo    oo        oo   o           oo      oo
Echo. oo    oo  ooooooo     ooooooo  oooooo  oooooo
Echo.
Echo.                   viewer
Echo.
Echo. File does not exist.
Echo.
Pause
goto asvi

