Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / SetRawWritePath alters buttons? (V2, Tier 1, Alpha 8)

Author
Message
drackbolt
10
Years of Service
User Offline
Joined: 3rd Nov 2014
Location: Northwest Indiana
Posted: 3rd Nov 2014 03:24
Very strange... I was having issues getting OpenToWrite working in any capacity. It wasn't even writing to the My Documents folder (although it did create the AGK\app\Media folder), so I decided to try SetRawWritePath to force it to write somewhere else. This worked for the debug stuff I was trying to output... but then my virtual buttons didn't show graphics anymore! The text is still there and they still function, but no button boxes.


What's even stranger is this only happens if I call SetRawWritePath BEFORE I set up the buttons, as I did above. Move that code to after it and the buttons have no problems. Now I'm nervous to keep this command in the code.

Anyone else see this?
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 3rd Nov 2014 04:19 Edited at: 3rd Nov 2014 04:35
yeah i have been struggling with the new commands too and i will break it down for ya now that paul has shown me how it works.
agk is setup to read from 2 areas by default. it checks the write path for the file and also checks the read path for the file.

SetRawWritePath( GetDocumentsPath())
setfolder("")

using that will put you into that main folder for writing and reading

how do you get it back for reading from your main install media folder... just type setfolder("media")

this does 2 things. it sets your write path now to documents/media/ which you probably dont want but it also sets your read path back to the original media folder aswell.

to return back to your documents folder for writing and reading on the same path just type setfolder("").

a perfect example is to do this:
at start of your code write this:

now the folder does not get made until a file is actualy saved.
so bare with it

next type this

this will allow your code to find the original files in your media folder for reading

now if you want to save a file type this first

that will put you back into the directory you created for writing

..write the file and save it

before you return back to your main code type this again

this way it finds all files needed for your project

hope that helps

SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 3rd Nov 2014 04:31 Edited at: 3rd Nov 2014 04:31
oh fyi

putting a series of
setfolder("media")
setfolder("media")

is not good

ends up looking here media/media etc...
it may be also bad having multiple "" in a row but i have not tested that.

xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 3rd Nov 2014 07:00
You can take a shortcut to set a custom folder within the Documents directory for writing, by doing the following:



This will create the "MyApp" directory if it doesn't exist and then set that as the active write folder. The key is to put the forward slash before the name so the folder is created from the root of the Documents path.

If you load all the internal media and create your virtual buttons etc. before changing the raw write path then you shouldn't need to revert back to the original write folder as everything will be in memory--but obviously this isn't possible in all apps.

I feel the whole read/write system of AppGameKit is still very complex to wrap one's head around, even as a very experienced user!
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 3rd Nov 2014 09:34
The reason it's so complex is because of sandboxing on Android and iOS. Those platforms will scream if you try to write outside the sandbox.

-- Jim - When is there going to be a release?
drackbolt
10
Years of Service
User Offline
Joined: 3rd Nov 2014
Location: Northwest Indiana
Posted: 4th Nov 2014 00:51
Thanks a lot for the replies everyone. Since it's only debug info, just using SetRawWritePath the way I am should work fine for me. My bigger concern is, why are the button graphics failing afterward, and what else could randomly fail as a result of using that command?
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 4th Nov 2014 22:17
Images for virtual buttons and joysticks are saved to the original write path, so when you try and create a virtual button or joystick the first time it looks for the image. If you have changed the path between starting the program and creating the first button or joystick then this will fail, creating the button or joystick first and then changing the path will work as once the image is loaded it stays loaded even if all buttons or joysticks are deleted.

The other images that might be affected by this are the Arial.png font, if you want to load this do it before changing the path, and the red missing image cross that replaces images that couldn't be found.
drackbolt
10
Years of Service
User Offline
Joined: 3rd Nov 2014
Location: Northwest Indiana
Posted: 5th Nov 2014 20:04
Ok, thanks for the explanation. Easy enough to work around once I know, and it gives me some idea what to expect. I hope that's in the final documentation.

Login to post a reply

Server time is: 2024-11-25 11:41:37
Your offset time is: 2024-11-25 11:41:37