$COLOR32
CONST ImageDir$
= ".\Images\" CONST SoundDir$
= ".\Alphabet Sounds\" CONST TagDir$
= ".\Image Tags\" CONST WordSoundDir$
= ".\Word Sounds\"
'load our fonts
f1
= _LOADFONT("courbd.ttf", 48, "MONOSPACE")
'Load the alphabet sound library
temp$
= SoundDir$
+ CHR$(i
) + ".ogg" AlphaSound
(i
) = _SNDOPEN(temp$
, "VOL,SYNC,LEN,PAUSE")temp$ = WordSoundDir$ + "is how you spell.ogg"
IsHowYouSpell
= _SNDOPEN(temp$
, "VOL,SYNC,LEN,PAUSE")
_DELAY 1 'Give everything a moment to initialize and get started for us. WordList(0) = 3 'three times repeating the list, as default
ChangeSearchTags
ShowNext = -1
ControlVariable = 0
MB = mouseclick
IF Mx
>= 650 AND Mx
<= 750 THEN 'the mouse is in the correct X area for input temp$
= ChangeValue
(650, 171, STR$(LimitTag.Year
), -1) LimitTag.Year
= VAL(temp$
) ChangeSearchTags
ShowNext = -1
temp$
= ChangeValue
(650, 191, STR$(LimitTag.Week
), -1) LimitTag.Week
= VAL(temp$
) ChangeSearchTags
ShowNext = -1
temp$
= ChangeValue
(650, 211, LimitTag.
Sound, 0) ChangeSearchTags
ShowNext = -1
temp$ = ChangeValue(650, 231, LimitTag.Theme, 0)
LimitTag.Theme = temp$
ChangeSearchTags
ShowNext = -1
PhotoTag.Year
= VAL(ChangeValue
(650, 324, STR$(PhotoTag.Year
), -1)) ChangePhotoTags word$
ShowNext = -1: ControlVariable1 = -1
PhotoTag.Week
= VAL(ChangeValue
(650, 341, STR$(PhotoTag.Week
), -1)) ChangePhotoTags word$
ShowNext = -1: ControlVariable1 = -1
PhotoTag.
Sound = ChangeValue
(650, 361, PhotoTag.
Sound, 0) ChangePhotoTags word$
ShowNext = -1: ControlVariable1 = -1
PhotoTag.Theme = ChangeValue(650, 381, PhotoTag.Theme, 0)
ChangePhotoTags word$
ShowNext = -1: ControlVariable1 = -1
PhotoChosen = PhotoChosen - 1
ShowNext = -1
ShowNext = -1
PhotoChosen = PhotoChosen + 1
ShowNext = -1
CASE 575 TO 640 'Vol not yet implemented CASE 641 TO 705 'Stop now handled via the sound sub
CASE 32 'space for next picture PhotoChosen = PhotoChosen + 1
IF PhotoChosen
> WordList
(0) THEN PhotoChosen
= 1 ShowNext = -1
ShowNext = 0
temp$ = PhotoList(WordList(PhotoChosen))
tempimage
= _LOADIMAGE(temp$
, 32) 'get the new image
_FONT f1: CenterText
0, 0, 800, 50, "Spell It Aloud":
_FONT f
'program photo area is 500 x 450 pixels. So:
GetNewWH 500, 450, tempimage, nW, nH
_PUTIMAGE (300 - (nW
/ 2), 300 - (nH
/ 2) - 25)-STEP(nW
, nH
), tempimage
LoadPhotoTags word$
DisplayTags 575, 150, temp$, LimitTag
DisplayTags 575, 300, "Photo Tags", PhotoTag
DrawCommandBoxes
IF ControlVariable1
= 0 THEN PlayLetters word$
DrawNoMatches
ControlVariable1 = 0
s = SaveState
BoxTitle 575, 450, 640, 470, 2, BlueGray, Gold, "LAST"
BoxTitle 641, 450, 705, 470, 2, BlueGray, Gold, "PLAY"
BoxTitle 706, 450, 770, 470, 2, BlueGray, Gold, "NEXT"
BoxTitle 575, 471, 640, 490, 2, BlueGray, Gold, "VOL"
BoxTitle 641, 471, 705, 490, 2, BlueGray, Gold, "STOP"
BoxTitle 706, 471, 770, 490, 2, BlueGray, Gold, "QUIT"
RestoreState s
Box x1, y1, x2 - x1 + 1, y2 - y1 + 1, thick, fg, bg
CenterText x1, y1 + thick, x2, y2 + thick, title$
S = SaveState
Box 50, 50, 500, 500, 5, Silver, Gold
CenterText 0, 0, 800, 50, "Spell It Aloud"
CIRCLE (300, 300), 200 - i
, BrickRed
CenterText 50, 50, 550, 550, "No Matches"
PhotoTag.Year = 0
PhotoTag.Week = 0
PhotoTag.Theme = ""
DisplayTags 575, 150, "Search Tags (0)", LimitTag
DisplayTags 575, 300, "Photo Tags", PhotoTag
RestoreState S
'Put the letters to the screen one by one
ControlVariable1 = 0
pw
= _PRINTWIDTH(word$
): StartX
= (600 - pw
) \
2 'center position
a
= ASC(word$
, i
) AND NOT 32 'play lowercase letters as uppercase sounds _LIMIT 10 'play nice with CPU during wait temp$ = WordSoundDir$ + word$ + ".ogg"
_LIMIT 10 'play nice with CPU during wait
temp
= _SNDOPEN(temp$
, "VOL,SYNC,LEN,PAUSE") _LIMIT 10 'play nice with CPU during wait
a
= ASC(word$
, i
) AND NOT 32 'play lowercase letters as uppercase sounds _LIMIT 10 'play nice with CPU during wait
checkstop:
ControlVariable1 = -1 'Stop Command for playing the word
SUB ChangePhotoTags
(word$
) 'Get a listing of the files
file$ = TagDir$ + word$ + ".txt"
SUB LoadPhotoTags
(word$
) file$ = TagDir$ + word$ + ".txt"
PhotoTag.Year = 0
PhotoTag.Week = 0
PhotoTag.Theme = ""
IF word$
<> "" THEN ChangePhotoTags word$
'Get a listing of the files
PhotoList$ = ImageDir$ + "*.bmp " + ImageDir$ + "*.jpg " + ImageDir$ + "*.png " + ImageDir$ + "*.gif "
SHELL _HIDE "DIR " + PhotoList$
+ "/b /s /a-d >PhotoList.txt"
'Load those names into a file.
PhotoCount = 0
file$ = TagDir$ + word$ + ".txt"
good = -1
IF LimitTag.Year
<> 0 AND LimitTag.Year
<> PhotoTag.Year
THEN good
= 0 IF LimitTag.Week
<> 0 AND LimitTag.Week
<> PhotoTag.Week
THEN good
= 0
IF LimitTag.Theme
<> "" AND LimitTag.Theme
<> PhotoTag.Theme
THEN good
= 0 PhotoCount = PhotoCount + 1
PhotoList(PhotoCount) = fullpath$
MakeList
RepeatCount = WordList(0)
WordList(0) = RepeatCount
PhotoChosen = 1
PhotoChosen = 0
TempList(i) = i
SWAP TempList
(j
), TempList
(r
) Count = Count + 1
WordList(Count) = TempList(j)
FUNCTION ChangeValue$
(x
, y
, tword$
, limit
) S = SaveState
Box x, y, 100, 20, 1, Black, Gold
CenterText x, y, x + 100, y + 20, temp$
CASE 48 TO 57 'We'll always accept numeric input tword$
= tword$
+ CHR$(k
) CASE 65 TO 90, 97 TO 122 'A-Z (a-z) only when we're dealing with a string temp$
= tword$
+ CHR$(179) DisplayTags
575, 150, "Search Tags (" + _TRIM$(STR$(PhotoCount
)) + ")", LimitTag
DisplayTags 575, 300, "Photo Tags", PhotoTag
ChangeValue$ = tword$
RestoreState S
S = SaveState
W = 200: h = 106
Box x, y, W, h, 2, BlueGray, Gold
CenterText x, y + 2, x + 200, y + 20, Title
LINE (x
+ 1, y
+ 19)-STEP(W
- 2, 0), Gold
xs = x + 24: ys = y + 24 'x/y start after the box offset
bxs = xs + 50: bys = ys - 2 'x/y start for the display boxes
Box bxs, bys + i * 20, 100, 20, 1, Black, Gold
CenterValue bxs, bys, bxs + 100, bys + 20, DisplayTag.Year
CenterValue bxs, bys + 20, bxs + 100, bys + 40, DisplayTag.Week
CenterText bxs
, bys
+ 40, bxs
+ 100, bys
+ 60, DisplayTag.
Sound CenterText bxs, bys + 60, bxs + 100, bys + 80, DisplayTag.Theme
RestoreState S
LINE (x
+ i
, y
+ i
)-STEP(wide
- 2 * i
, high
- 2 * i
), Trim
, B
SUB CenterText
(x1
, y1
, x2
, y2
, text$
) xmax = x2 - x1: ymax = y2 - y1
xpos = (xmax - textlength) / 2
SUB CenterValue
(x1
, y1
, x2
, y2
, value
AS LONG) CenterText x1, y1, x2, y2, text$
DIM SS
AS SaveStateType
, Temp
AS SaveStateType
SaveMem
= _MEMNEW(LEN(SS
) * 255) 'Save up to 255 save states; More than 255 and we toss an error
'Data to Save
SS.InUse = -1
_MEMGET SaveMem
, SaveMem.OFFSET
+ o
, Temp
_MEMPUT SaveMem
, SaveMem.OFFSET
+ o
, SS
SaveState = i
_MEMPUT SaveMem
, SaveMem.OFFSET
+ NSS
* LEN(SS
), SS
NSS = NSS + 1
SaveState = NSS
_MEMGET SaveMem
, SaveMem.OFFSET
+ (WhichOne
- 1) * LEN(SS
), SS
SS.InUse = 0 'Let the routine know that we're no longer in use for this handle
_MEMPUT SaveMem
, SaveMem.OFFSET
+ (WhichOne
- 1) * LEN(SS
), SS
SUB GetNewWH
(destWidth
, destHeight
, handle
AS LONG, NewWidth
, NewHeight
) 'Sub return in variables NewWidth and NewHeight new image Width and image Height with the same ratio for optimal picture to set area width and height with [destWidth, destHeight] Pw = W / destWidth
Ph = H / destHeight
NewWidth = W / P
NewHeight = H / P
DO WHILE lb%
'check for leftbutton release mouseclick% = -1