was hoping to use GetFirst/NextFile() to make our own PickImage but that doesn't seem to work in HTML either (i'm working in Classic):
// Project: PickImgHTML
// Created: 2020-07-03
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "PickImgHTML" )
SetWindowSize( 1080, 720, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1080, 720 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
ChooseButton = 1
AddVirtualButton(ChooseButton,100,100,64)
SetVirtualButtonText(ChooseButton, "Select" + CHR(10) + "Image")
TYPE ThumbData
IMG as Integer
SPR as Integer
EndType
GLOBAL Thumbs as ThumbData []
do
If GetVirtualButtonReleased(ChooseButton)
PreLoad()
EndIf
Print(Thumbs.Length)
Sync()
loop
Function PreLoad()
If Thumbs.Length > -1
for x = Thumbs.Length to 0
ThisSpr = Thumbs[x].SPR
ThisImg = Thumbs[x].IMG
If GetSpriteExists(ThisSpr) then DeleteSprite(ThisSpr)
If GetImageExists(ThisImg) then DeleteImage(ThisImg)
Thumbs.Remove(x)
next x
EndIf
ThisFile$ = GetFirstFile()
Repeat
If Right(ThisFile$,3) = "png"
ThisImgSize = GetImageSizeFromFile( ThisFile$ )
ImgWidth = ThisImgSize >> 16
ImgHeight = ThisImgSize && 0xFFFF
ThisScale# = 64.0/ImgWidth
ThisThumb as ThumbData
ThisThumb.IMG = LoadImageResized(ThisFile$,ThisScale#,ThisScale#,0)
ThisThumb.SPR = CreateSprite(ThisThumb.IMG)
Thumbs.Insert(ThisThumb)
Endif
ThisFile$ = GetNextFile()
Until ThisFile$ = ""
If Thumbs.Length > -1 then ShowThumbs()
EndFunction
Function ShowThumbs()
ThisX = 0 : ThisY = 0
for x = 0 to Thumbs.Length
ThisX = ThisX + 64 : if ThisX > 768 then ThisX = 0
if ThisX = 0 then ThisY = ThisY + 128
SetSpritePosition(Thumbs[x].SPR, ThisX, ThisY)
next x
EndFunction
something wrong in there, otherwise, where it's not erasing previous Thumbs[ ]
If Thumbs.Length > -1
for x = Thumbs.Length to 0
ThisSpr = Thumbs[x].SPR
ThisImg = Thumbs[x].IMG
If GetSpriteExists(ThisSpr) then DeleteSprite(ThisSpr)
If GetImageExists(ThisImg) then DeleteImage(ThisImg)
Thumbs.Remove(x)
next x
EndIf
?
stopped working on it (adding actual image selection) when "nothing" happened when
testing in HTML.