Hi folks!
In response to a few little bumps I've run into whilst familiarizing myself with AppGameKit I've created a simple utility that helps you test your image files on whatever platforms you have available.
The program works like this: simply put your images in the media directory or a subdirectory of the media directory and broadcast the app to your device(s). Then sit back and watch the images be displayed. You can tap/click the screen to pause on any image so you have a chance to write down the file name.
This program also includes a nice Pause() function that I had to work out. Apparently the Sleep() function really interferes with user input (obvious once you know it...) so I had to write my own little delay routine in this too. It simply measures the time differential in a loop while checking for the Pause() input. It might be helpful to some. If someone has a more elegant solution, I'd love to see it as I'm not necessarily a sophisticated coder
I have plans to either expand this to test audio files as well or write out a separate utility for it. Though I probably won't unless motivated by issues like this.
At any rate I hope this is helpful to others in the community.
Cheers!
// Media Image Tester v1
//
// Created 2013-01-10 by Sean Mann (Naphier of Napland Games)
// Contact: naplandgames@gmail.com
//
// Community use is welcome and encouraged!
//
// This program is used to check compatability of your images
// with devices and should be used via broadcast to the AGK Player.
//
// Simply place all of your files to be tested into the media/ folder
// they can be in a subfolder, but only one level of subfolders is currently
// supported (i.e media/myfolder works while media/myfolder/secondlevelfolder
// does not work. If desired please let me know and I'd be happy to include it.
//
// IMPORTANT!
// IF you'd like the folders on your Android device to be removed after
// they've been examined then set
// cleanup_android_folders = 1
// I make no guarantee that this won't delete your Windows / iOS folders.
// So use with extreme caution (i.e. only place copies of your images
// in the media/ folder for this test).
// ----------------------------------- INITIALIZE VARIABLES ------------------------------------------------------
// first grab the name of the folder we're starting in. This should be the media/ folder
global folder$ = GetFolder()
cleanup_android_folders = 0 // CAUTION set to 1 with extreme care SEE ABOVE NOTES
folder_count = 1 // start folder count at 1 since we know there is at least the media/ root folder
fileschecked = 0 // we've not checked any files until the Imagetester() function runs
new_folder = 1 // this flags the occurance of a new folder - start at 1 since media/ is a new folder
display_time = 3000 // alter this variable to increase/decrease the amount of time the images are displayed for
// ---------------------------------------------------------------------------------------------------------------
// ========================================= MAIN ================================================================
// display user instructions and pause to wait for user
CreateText(1,"This program will check the media/ directory and all subdirectories for image files then proceed to test them. Press/click the screen anytime to pause/resume.")
SetTextMaxWidth(1,100)
Pause(1)
DeleteText(1)
// main loop
repeat
// iterate through file names
repeat
if new_folder = 1
filename$ = GetFirstFile()
new_folder = 0
else
filename$ = GetNextFile()
endif
if filename$ <> ""
// if the file is an image then load and display it with
// ImageTester(file$, fileschecked, display_time) function [returns an increase to file_count if the file is an image]
fileschecked = ImageTester(filename$, fileschecked, display_time)
endif
until filename$ = ""
// iterate through folder names
if folder_count = 1
folder$ = GetFirstFolder()
else
if cleanup_android_folders = 1
deletefolder(folder$)
endif
SetFolder("")
SetFolder("media")
folder$ = GetFirstFolder()
for i = 2 to folder_count
folder$ = GetNextFolder()
next i
endif
if folder$ <> ""
inc folder_count
SetFolder(folder$)
new_folder = 1
endif
until folder$ = ""
// display a summary of the results and wait for user to escape program
CreateText(2,"Examined "+str(folder_count)+" folders and "+str(fileschecked)+" files. Press ESC or BACK to exit")
SetTextMaxWidth(2,100)
Sync()
repeat
until GetRawKeyPressed(27) = 1
END
//========================================== END MAIN ===========================================================
//========================================== FUNCTIONS ==========================================================
//---------------------------------------------------------------------------------------------------------------
// ImageTester function loads file$, keeps count of the numbers of fileschecked, and must be told a length
// of time to display the images on screen (display_time). Returns an increase to fileschecked if the file
// is JPG, JPEG, BMP, or PNG.
function ImageTester(file$, fileschecked, display_time)
// check for the correct extension (JPG, JPEG, BMP, or PNG)
file_extension$ = lower(GetStringToken(file$,".",2))
if file_extension$ = "bmp" or file_extension$ = "png" or file_extension$ = "jpg" or file_extension$ = "jpeg"
inc fileschecked
LoadImage(fileschecked,file$)
CreateSprite(fileschecked,fileschecked)
SetSpriteSize(fileschecked,100,-1)
SetSpritePosition(fileschecked,0,5)
if Right(folder$,1) <> "/"
CreateText(1,folder$+"/"+file$)
SetTextMaxWidth(1,100)
else
CreateText(2,folder$+file$)
SetTextMaxWidth(2,100)
endif
// this is used in place of the sleep() function since sleep() interferes with getting input
time0 = GetMilliseconds()
repeat
Sync()
Pause(0)
time1 = GetMilliseconds()
times_up = time1 - time0
until times_up >= display_time
//Cleanup
DeleteSprite(fileschecked)
DeleteImage(fileschecked)
DeleteText(1)
DeleteText(2)
Sync()
endif
endfunction fileschecked
//----------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------
// Pause function pauses the program and overlays "PAUSED" on the screen when the user clicks or
// touches the screen. Set force_pause parameter to 1 to start the pause when called. Otherwise
// set force_pause to 0 to wait for the user to click/touch before pausing.
// Do not use Sleep() near this as it prevents input from being grabbed while Sleep()-ing...
function Pause(force_pause)
pause_text = CreateText("PAUSED")
SetTextVisible(pause_text,0)
SetTextColor(pause_text,255,255,255,255)
SetTextSize(pause_text,6)
SetTextDepth(pause_text,1)
SetTextAlignment(pause_text,1)
SetTextPosition(pause_text,50,50)
if force_pause <> 1 then force_pause = 0
select force_pause
case 0:
if GetPointerPressed() = 1
IsPaused = 1
SetTextVisible(pause_text,1)
Sync()
endif
if IsPaused = 1
repeat
if GetPointerPressed() = 1 then IsPaused = 0
Sync()
until IsPaused = 0
SetTextVisible(pause_text,0)
endif
endcase
case 1:
IsPaused = 1
SetTextVisible(pause_text,1)
repeat
if GetPointerPressed() = 1 then IsPaused = 0
Sync()
until IsPaused = 0
SetTextVisible(pause_text,0)
endcase
case default:
Print("Big fat error in Pause Select-Case")
Sync()
Sleep(5000)
exit
endcase
endselect
deletetext(pause_text)
endfunction
//============================================ END FUNCTIONS ==========================================
//================================================ EOF ================================================
Nexus 7 (Jelly Bean 4.1.2) -- HTC Droid Incredible 2 (Gingerbread 2.3.?) -- Motorola Droid X (Gingerbread 2.3.4)
Willing to test for you!