Asset - Extension Folder Loader, Install folders on Android device!

W

Wraithious

Guest


Folder Pick, an Extension for Android via GameMaker: Studio. for only 99 cents!!

Brought to you by Roadhammer Gaming!

This extension is designed for your Android game and app releases made with GameMaker Studio and will allow you to make up to 4 folders (each additional folder inside the previous folder) that you can name in the main storage
area of the users Android device and return the address of the folders to your game. You can then use this address to save pictures or text created either by you or the user through your code.

Easy to use, check out the video! EDIT: Updated the video so you can actually read and see it haha


How to use:

You must use GameMaker: Studio or Early Access and have the Android export module to use this extension.

There is no need to use an async event in your project! Just use a script, or a code in an alarm/
mouse pressed/ key pressed event etc, and simply call getDire1("Your_main_folder"); to make
1 folder, getDire2("Your_main_folder", "Your sub folder"); to make 2 folders,
getDire3("Your_main_folder", "Your sub folder 1", "Your sub folder2"); to make 3 folders, and
if you need 4 folders getDire4("Your_main_folder", "Your sub folder 1", "Your sub folder2", "Your sub folder3");
from GameMaker: Studio Then you can use the result variable(s) in any operations you wish.
Example:

//step event example
if(mouse_check_button_released(mb_left))
{
global.files = getDire2("Company name", "Game name");// Name your folders here
screen_save(global.files+"/Screenshot.png");// Put a FORWARD slash before your save name,
//and the filetype after (.png, .txt). Also you don't need to use working_directory+
}
And you can actually create as many folders inside whichever folder(s) you want, say you have an online game that has a thousand players, or more!, just use the repeat statement with a number incrementing variable like so:

Code:
var players = 1000;
var numbers = 0
var folders[players]="";
Repeat(players)
{
Folders[players]=getDire3("My company", "My game", "Player"+string(numbers));
numbers +=1;
}


Now you will have 1000 player folders in the folder My game.
Download the Folder Pick extension Here on the Marketplace
Here is an example game, import the project as a .gmz, You must then add the extension to the project to use!
Folder Loader GMZ
 
Last edited by a moderator:

DukeSoft

Member
Why specifically 4 folders? Why not make it an unlimited amount of folders and let me identify them as the game boots?
 
W

Wraithious

Guest
Why specifically 4 folders? Why not make it an unlimited amount of folders and let me identify them as the game boots?
I figure anyone would need maybe 4, one for the company, 1 for your game, one for the player, and one for his assets, you can actually make as many different folders as you want to as you can set up in your code to either have the user name the folders or if your game makes them just incriment the file name with an additional string using the function, like getDire1("my game"+ string(global.numbers));
You can find the folders with if_file_esists( fname+string(global.numbers))
So the answer is yes, you can make as many folders as you want, and put 3 folders in each one, you may even be able to nest the functions and put as many as you lime inside by finding the last folder and putting more folders inside it

With my extension i have given you the power to make folders that don't say Gm studio
We are GML programmer, can do anything hahah

But let me allaborate on that question for a minuite, say you have an online game that has a thousand players, or more!, just use the repeat statement with a number incrementing variable like so:

Code:
var players = 1000;
var numbers = 0
var folders[players]="";
Repeat(players)
{
Folders[players]=getDire3("My company", "My game", "Player"+string(numbers));
numbers +=1;
}
Now you will have 1000 player folders in the folder My game.
 
Last edited by a moderator:

DukeSoft

Member
But.... Why then make 4 functions?

Code:
var Folders;
for (i = 0; i <= 3; i++) {
Folders[i]=getDire("My company", "My game", "Player" + string(i));
}
Now i have 4 folders as well. But using 1 function.

EDIT:

Ooooh wow. You're using the getDire# for different depths?!

Why not split the string on a directory separator (/ or \) and cast that to the depth? Then we can just use it like so;

Code:
var Folders;
var companyFolder = getDire("My company");
var gameFolder = getDire("My company/My game");
for (i = 0; i <= 3; i++) {
Folders[i]=getDire("My company/My game/Player" + string(i));
}
 
W

Wraithious

Guest
yep, @DukeSoft My goal was to make my extension as flexible as possible for the beginner level programmer all the way up to the expert level programmer to use these functions, if the user's goal is only to create his own single folder and get the address to it for immediate or later use it can be done simply with the first function getDire1, if the user wants to make 4 folders but get the address to each one they can use the functions successivley and store each address for future use without the beginner/ intermediate level programmer having to use string splitters to find folders 1,2 and 3 later on. Expert programmers can do all sorts of crazy operations by combining these functions, I was playing around and added working_directory+"my company","mygame","player","stats" to the getdire4 function to see what would happen, and the result folders created was this: Gm studio>folder with no name>storage>emulated>0>my company>my game>player>player stats hahahahah theres absolutly no need for that and is why i warn not to use working directory+, but as crazy as it seems someone might actually want that for something. so the flexibility is there, and as you've shown you can do things easilly through your own code manipulations, I could of set it up as you sugest with the / or \ but I just wanted it to be easy to use for all levels
 

DukeSoft

Member
I think using the directory setup as every OS uses it is easier to grasp than using 4 different functions for specific depth.
 
H

hoyakim

Guest
hello~! Wraithious! I have a problem.
Saving the png file outside using your extension succeeded.
However, the saved png file can not be read directly from the Android gallery.
I can move or copy files to my computer, but I can not read them on Android.
The file can be read after rebooting Android, Is there a way to read it, immediately?:confused:

I tried searching with my short skill...it seems to be a media scanning problem.
If this problem can not be solved, it's just a half-way feature for me...:(
 
W

Wraithious

Guest
I believe there might be a way to update it, the file is immediatly there tho, you can search for the file immediatly after creating it and load it in your app and display it, as for the android device itself ive noticed some photo apps need to be restarted before they scan for new photos.


EDIT:
@ hoyakim
Have you tried using it to put your picture in the Android graphics folder? just use getDire1("Pictures"); and then put your photo in there? I just tested it and it works, and you can get the picture back immediatly in your game. this is exactly what I did and reskinned a button with the new image:

Code:
///Find or Create Folder
if(mouse_check_button_released(mb_left)&& oktoclick=1)
{
oktoclick=0;
image_single=1;
alarm[0]=4;
alarm[1]=20;
files = getDire1("Pictures");//Get the Pictures gallery folder address

MyFile=file_text_open_write(files+"/Folder Address.txt");file_text_write_string(MyFile,files);file_text_close(MyFile);//saves address as a text file

sur=surface_create(72,29);//draw a new skin for our button with 2 sub images
surface_set_target(sur);
draw_clear_alpha(-1,1);
draw_set_color(c_lime);
draw_rectangle(0,0,36,29,0);
draw_set_color(c_black);
draw_text(-1,0,"New#Skin!");
draw_set_color(c_red);
draw_rectangle(36,0,72,29,0);
draw_set_color(c_black);
draw_text(35,8,"Click");
surface_reset_target();
surface_save(sur,files+"\newButtonSkin.png");//Save our new button skin to the Pictures gallery folder

if surface_exists(sur)surface_free(sur);
global.pic1=sprite_add(files+"\newButtonSkin.png",2,0,0,0,0);//Get the new picture we just saved and use it as our buttons new skin
sprite_index=global.pic1;
}
 
Last edited by a moderator:
H

hoyakim

Guest
I believe there might be a way to update it, the file is immediatly there tho, you can search for the file immediatly after creating it and load it in your app and display it, as for the android device itself ive noticed some photo apps need to be restarted before they scan for new photos.


EDIT:
@ hoyakim
Have you tried using it to put your picture in the Android graphics folder? just use getDire1("Pictures"); and then put your photo in there? I just tested it and it works, and you can get the picture back immediatly in your game. this is exactly what I did and reskinned a button with the new image:

Code:
///Find or Create Folder
if(mouse_check_button_released(mb_left)&& oktoclick=1)
{
oktoclick=0;
image_single=1;
alarm[0]=4;
alarm[1]=20;
files = getDire1("Pictures");//Get the Pictures gallery folder address

MyFile=file_text_open_write(files+"/Folder Address.txt");file_text_write_string(MyFile,files);file_text_close(MyFile);//saves address as a text file

sur=surface_create(72,29);//draw a new skin for our button with 2 sub images
surface_set_target(sur);
draw_clear_alpha(-1,1);
draw_set_color(c_lime);
draw_rectangle(0,0,36,29,0);
draw_set_color(c_black);
draw_text(-1,0,"New#Skin!");
draw_set_color(c_red);
draw_rectangle(36,0,72,29,0);
draw_set_color(c_black);
draw_text(35,8,"Click");
surface_reset_target();
surface_save(sur,files+"\newButtonSkin.png");//Save our new button skin to the Pictures gallery folder

if surface_exists(sur)surface_free(sur);
global.pic1=sprite_add(files+"\newButtonSkin.png",2,0,0,0,0);//Get the new picture we just saved and use it as our buttons new skin
sprite_index=global.pic1;
}
Hello! Thank you for your quick reply.;)
Sadly, I tried you an answer before you suggested. That method works well in my phone...of course.
On some Android phones, I found that a file was created and that it was media scanning after a while.
I can use the Gallery app or the MediaScanning app separately. But most people who use my app will not be doing that annoying thing.:(

I've searched to solve this problem and I found a way to scan individual files, this page.
https://developer.android.com/reference/android/media/MediaScannerConnection.html
But I was not a programmer so I do not know is the correct answer or how to apply it....:(

And I have something else ask...
My Android phone is a lollipop and file generation is good. But my friend's Android phone is marshmallow and no file was created.
When I thought about the reason, I suddenly wondered if the permission was wrong.
It seems like asking permission to generate a file from Android marshmallow or above?
There is a Galaxy Note 4, which is used for testing, and it seems that the window asking for such permission does not pop up on the smartphone.
 
Last edited by a moderator:
W

Wraithious

Guest
I've searched to solve this problem and I found a way to scan individual files, this page.
https://developer.android.com/reference/android/media/MediaScannerConnection.html
And I have something else ask... I suddenly wondered if the permission was wrong.
It seems like asking permission to generate a file from Android marshmallow or above?

Yep I've been working on that the last several hours since you mentioned it, trying to get it to work now, hopefully it will be done soon and I can update it, it will be a seperate function that you can call tho because that problem is not related to making folders. it can be used at any time (even immediatly) after saving the picture.

The permissions issue is most likley if you are on android 6.0 and up, I wrote a permissions extension (it's on the marketplace for free) to handle that, but in the new updates to all my extensions (and apps and games) I have been / will be adding it in there
 
H

hoyakim

Guest
Yep I've been working on that the last several hours since you mentioned it, trying to get it to work now, hopefully it will be done soon and I can update it, it will be a seperate function that you can call tho because that problem is not related to making folders. it can be used at any time (even immediatly) after saving the picture.

The permissions issue is most likley if you are on android 6.0 and up, I wrote a permissions extension (it's on the marketplace for free) to handle that, but in the new updates to all my extensions (and apps and games) I have been / will be adding it in there
The permissions issue has been resolved! Thank you!!
 
W

Wraithious

Guest
You're welcome, im still working on the recognition update, i have questions posted here and on S.O. and am trying something that was sugested on here in a few minuites
 
W

Wraithious

Guest
@ hoyakim hi, I updated the extension with a new function called osNotice("YourMediafileName.media_extension"); and there's a .gmz file in the included files if you want to try it out, I tested on 4.x and 6.0.1 and it works, check out the code in the step event in the object obj_controller to see how it works
 
Last edited by a moderator:
H

hoyakim

Guest
@ hoyakim hi, I updated the extension with a new function called onNotice("YourMediafileName.media_extension"); and there's a .gmz file in the included files if you want to try it out, I tested on 4.x and 6.0.1 and it works, check out the code in the step event in the object obj_controller to see how it works
Hi Wraithious. osNotice is good working. This update seems to have solved everything. I am so grateful to you.
Thanks for making a good extension.
 
W

Wraithious

Guest
Hi Wraithious. osNotice is good working. This update seems to have solved everything. I am so grateful to you.
Thanks for making a good extension.
You're welcome I'm glad it worked! happy devving
 
Top