'/title Animations (version 2) using thumbs
'/type utility
'========================================================
' Controls while playing animation
'..................................................
'          - = decrease animation speed
'         + = increase animation speed
'       TAB = change playback direction (forward/reverse)
' Backspace = back to selection screen
'========================================================
 
_TITLE "Animations (version 2) using thumbs"  
DIM SHARED UserWarned
, newdelay%
, newdelay!
, t#
, path$
, DelayFile$
 DIM SHARED MenuIconsPath$
, reload
, BGrd
, BGgr
, BGbl
 DelayFile$ = path$ + "\delay.dat"
MenuIconsPath$ = path$ + "\AniFrames"
wallpaperPath$ = path$ + "\AniPlayer2wallpapers\"
DIM SHARED catX
(10), catY
(10), catW
(10), catH
(10) GetCatagories
DIM SHARED iconX
(50), iconY
(50), iconW
(50), iconH
(50), icon#
, icons
 DIM SHARED FrameName$
(MaxFrames
), frames
, direction$
, AniDelay
  
' value of 'MaxSlowDelay' is the largest value allowed to slow down
' an animation. Could really be any number wanted.
 
GetLabelValue "Animation2.ini", "CountPerSec", "", CountPerSec
 
configfile$ = "Animation2.ini"
GetLabelValue configfile$, "BGrd", "", BGrd
GetLabelValue configfile$, "BGgr", "", BGgr
GetLabelValue configfile$, "BGbl", "", BGbl
 
SetTheScreen:
 
GetLabelValue configfile$, "ScrnWidth", "", ScrnWidth
GetLabelValue configfile$, "ScrnHeight", "", ScrnHeight
 
GetLabelValue configfile$, "wallpaper", wallpaper$, n
wallpaper$ = wallpaperPath$ + wallpaper$
CheckForFile wallpaper$, found
        PRINT "warning!   following wallpaper image not found..."         UserWarned = 1
    wallpaper$ = ""
    GetLabelValue configfile$, "ScrnWidth", "", ScrnWidth
    GetLabelValue configfile$, "ScrnHeight", "", ScrnHeight
    imgW% 
= _WIDTH(image&
) '  get image width    imgH% 
= _HEIGHT(image&
) ' get image height    ScrnWidth = imgW%
    ScrnHeight = imgH%
 
 
    BGrd = 10
    BGgr = 100
    BGbl = 20
    fill = 1
    DrawBox 0, 0, ScrnWidth, ScrnHeight, BGrd, BGgr, BGbl, fill
 
ShowCatagories
LoadIcons
DrawIconBoxes
 
reload = 0
 
 
    RightClick% 
= _MOUSEBUTTON(2) '                retrieve right button status 
            TestClickPos mx, my
            clkd = 1
        clkd = 0
 
 
 
 
SUB TestClickPos 
(mx
, my
) '################################################  
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'-- clicked on a icon?
 
 
    x = iconX(i)
    y = iconY(i)
    w = iconW(i)
    h = iconH(i)
 
                LoadAnimationFrames i
                reload = 1
            icon# = i
            DrawIconBoxes
 
 
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'--clicked on a catagory label ?
 
 
    x = catX(i)
    y = catY(i)
    w = catW(i)
    h = catH(i)
 
                Cat# = i
                reload = 1
                ShowCatagories
 
 
SUB DrawIconBoxes 
'########################################################  
 
    x = iconX(i)
    y = iconY(i)
    w = iconW(i)
    h = iconH(i)
 
        clr& 
= _RGB32(BGrd
, BGgr
, BGbl
) 
    LINE (x 
- 2, y 
- 2)-(x 
+ w 
+ 1, y 
+ h 
+ 1), clr&
, B
     LINE (x 
- 3, y 
- 3)-(x 
+ w 
+ 2, y 
+ h 
+ 2), clr&
, B
  
 
 
SUB DrawBox 
(x
, y
, w
, h
, Rd
, Gr
, Bl
, fill
) '###########################################     LINE (x
, y
)-(x 
+ w 
- 1, y 
+ h 
- 1), clr&
, BF
     LINE (x
, y
)-(x 
+ w 
- 1, y 
+ h 
- 1), clr&
, B
  
SUB ShowCatagories 
'######################################################  
x = 10
y = 10
h = 40
 
w = ScrnWidth / catagories
 
    img$ = MenuIconsPath$ + "\" + Catagory$(c) + ".png"
    w% 
= _WIDTH(image&
) '                                get image width    h% 
= _HEIGHT(image&
) '                              get image height    clr = 0
    DrawBox x - 3, y - 3, w% + 6, h% + 6, clr, clr, clr, 1
 
    catX(c) = x
    catY(c) = y
    catW(c) = w%
    catH(c) = h%
 
 
    x = x + w% + 10
 
 
SUB GetCatagories 
'######################################################  
tf$ = "~cats.tmp"
cmd$ = "dir " + q$ + MenuIconsPath$ + q$ + " /b >" + tf$
 
''SHELL _DONTWAIT "notepad ~cats.tmp": END
 
 
 
        i = i + 1
        Catagory$(i) = cat$
 
 
 
catagories = i
Cat# = 1
 
 
SUB LoadIcons 
'##########################################################  
tf$ = "~SubCat.tmp"
path$ = MenuIconsPath$ + "\" + Catagory$(Cat#) + "\"
cmd$ = "dir " + q$ + path$ + "*" + q$ + " /b >" + tf$
''SHELL "notepad.exe " + tf$: END
 
IconSqr = 50
y = 60
x1 = 5
x = x1
 
 
 
 
 
        img$ = path$ + fldr$ + "\$tn.jpg"
        ''PRINT img$; "<": END
        w% 
= _WIDTH(image&
) '                                get image width        h% 
= _HEIGHT(image&
) '                              get image height        IF h% 
> tallest 
THEN tallest 
= h%
         i = i + 1
        iconX(i) = x
        iconY(i) = y
        iconW(i) = w%
        iconH(i) = h%
        IconName$
(i
) = LEFT$(img$
, LEN(img$
) - 4) 'trim off .XXX 
        x = x + w% + 10
        IF x 
+ IconSqr 
>= ScrnWidth 
THEN             y = y + tallest + 10
            x = x1
            tallest = 0
 
 
 
icon# = 1
icons = i
 
 
SUB GetLabelValue 
(lblfile$
, lbl$
, v$
, n
) '##################################  
 
SUB LoadAnimationFrames 
(i
) '######################################################### ''CLS: PRINT IconName$(i): END
path$ 
= LEFT$(IconName$
(i
), p 
- 1)'--------------------------------------------------------------
'---------------------------------------------------------------
'' CLS: PRINT folder$; "<": END
 
_TITLE "Animation : " + folder$
  
''path$ = StartPath$ + "\" + Catagory$(Cat#) + "\" + folder$(i)
tf$ = "~~animates.tmp"
cmd$ = "dir " + q$ + path$ + q$ + " /b >" + tf$
 
'' SHELL "notepad.exe " + tf$: END
 
CheckForFile DelayFile$, found
'AniDelay is a percent of CountPerSec
 
    newdelay! = newdelay% / 1000
    AniDelay = 1
 
 
 
i = 0
 
 
 
        f$ = "" 'this is a thumbnail image
 
 
 
        CASE ".jpg", ".png", ".bmp"             i = i + 1
            FrameName$(i) = path$ + "\" + f$
            'CLS :
            PRINT i; FrameName$
(i
); 
"<"             'EXIT DO
 
 
 
 
frames = i
 
ScrnWidth = 600
ScrnHeight = 500
ScreenMode = 32
 
 
img$ = FrameName$(1)
ScrnWidth = w%
ScrnHeight = h% + 15
direction$ = "F"
 
    PlayTheAnimation k$
 
 
 
 
SUB CheckForFile 
(f$
, found
) '############################################## found = 0
 
SUB PlayTheAnimation 
(k$
) '################################################ ForStart = 1
ForStop = frames
ForStep = 1
 
    ForStart = frames
    ForStop = 1
    ForStep = -1
 
 
    img$ = FrameName$(i)
 
    ShowDelayBar
 
 
                ' Update delay file.
                ' Update delay file.
                IF newdelay% 
< MaxSlowDelay 
THEN                     newdelay% = newdelay% + 1
                    newdelay! = newdelay% / 1000
                IF AniDelay 
< MaxSlowDelay 
THEN                     AniDelay = AniDelay + 1
                AniDelay = AniDelay - 1
                IF AniDelay 
< 1 THEN AniDelay 
= 1                     newdelay% = newdelay% - 1
                    newdelay! = newdelay% / 1000
                    direction$ = "R"
                    direction$ = "F"
 
        ' Three delay options.
        ''_DELAY newdelay% / 5000
        ''IF ABS(TIMER - t#) > newdelay! THEN EXIT DO ' (Can be Substituted for the call sub below if a midnite delay is not a big deal.)
 
 
    per = i / frames
    ln = ScrnWidth * per
 
    x = 0
    y = ScrnHeight - 13
    h = 5
    fill = 1
 
    w = ScrnWidth
    Rd = 0 ' 255
    Gr = 0 ' 255
    Bl = 0 '' 255
    'black out the progress bar
    DrawBox x, y, w, h, Rd, Gr, Bl, fill
 
    w = ln
    Rd = 255
    Gr = 255
    Bl = 255
    'draw the progress bar
    DrawBox x, y, w, h, Rd, Gr, Bl, fill
 
 
 
SUB ShowDelayBar 
'##########################################################  
x = 0
y = ScrnHeight - 5
h = 5
fill = 1
 
w = ScrnWidth
Rd = 0 ' 255
Gr = 0 ' 255
Bl = 0 '' 255
'black out the delay value bar
DrawBox x, y, w, h, Rd, Gr, Bl, fill
 
per = (AniDelay / MaxSlowDelay) * 100
    Rd = 0: Gr = 255: Bl = 0
    Rd = 255: Gr = 255: Bl = 0
    Rd = 255: Gr = 0: Bl = 0
 
per = per / 100
w = ScrnWidth * per
'draw the delay value bar
DrawBox x, y, w, h, Rd, Gr, Bl, fill
 
 
 
 
    t# = t# - 86400 'Midnite adjustment