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 / AppGameKit read/write/raw folders ... too restrictive on PC ...

Author
Message
Freddix
AGK Developer
22
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 4th Apr 2020 20:16
Hi,

I understand that on platform like Android or iOS, the principle of read folder (project) and write folder (datas) is good ... but on PC, it's a shame.

On PC :
In my PluginKIT System, I precalculate 2D virtual lighting system with normal mapping (emulation) + shadow casting.
is I "save image" generated to avoid to get them being regenerated at each launch of the app, it save them in "C:\Users\myUsers\AppData\Local\AgkApps\MyApp\"
that is a shame.
I have no way to makes them being saved directly in the "Media" directory of the project to win launch time when lights are already precalculated and saved.
More to this, I cannot use Raw directory because there are no AppGameKit commands to know the absolute path of the running application (the getCurrentFolder() does only return "media/").

It's a shame.

Regards,
Freddix
XANAX 2B
21
Years of Service
User Offline
Joined: 20th Jun 2003
Location: Corsica (France)
Posted: 4th Apr 2020 20:29 Edited at: 4th Apr 2020 20:31
Hi,

I remember in the passed, i've used "SetRawWritePath" to set the write path directly to "media/".
Now, it's deprecated... i don't know if it will works anymore.

EDIT: https://forum.thegamecreators.com/thread/220870
Emotional High Potential
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 4th Apr 2020 20:34
not sure why you cant use raw commands

to select a load directory
ret$=ChooseRawFile("*.jpg;*.png",1)

an example of saving an object to the same directory
if ret$<>""
SaveObject("raw:"+left(ret$,len(ret$)-4)+".obj","raw:"+left(ret$,len(ret$)-4)+".mtl"
endif

fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 4th Apr 2020 20:54 Edited at: 4th Apr 2020 21:00
Quote: "To write a file outside the normal write folder you can use "raw:" followed by an absolute path for the current platform, for example "raw:C:\MyFolder\MyFile.txt" on Windows or "raw:/sdcard/Documents/MyFile.txt" on Android. If any folders in your chosen path do not exist they will be created."


OpenToWrite

Edit
SaveImage

SetFolder

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 5th Apr 2020 00:00
Use "GetReadPath( )" this will return (on Windows / Mac) the Absolute Folder to your App (or where it's currently being run from)
What I typically do is:

#Constant PATH "Raw:" + GetReadPath( )

Remember that #Constant will basically just replace every instance of your declaration (in this case PATH) with everything after it, and as I recall this includes Comments, so be careful with that.
With this said... keep in mind that Program Files and Program Files (x86) are "Protected" Paths., so what you might want to do as part of an Installer... is when you make the Directory be sure to update the Folder Settings to allow Read & Write, by Default these are always Read Only for Users.
AppGameKit won't automatically trigger UAC / Permissions... instead it'll just Fail the Operation.
Loktofeit
AGK Developer
15
Years of Service
User Offline
Joined: 21st Jan 2009
Location: Sarasota, FL
Posted: 5th Apr 2020 06:30 Edited at: 6th Apr 2020 06:36
I don't know why so many people accept this weird system of putting things in
C:\Users\[username]\AppData\Local\AgkApps\MyApp\ ,

It is a folder and subfolders that are hidden by default
and were never meant for users to regularly access.
And, YES, if you are developing an AGKS program that
saves files, you are regularly accessing it.

To be clear, I am not saying that apps don't write to AppData folders,
I am saying they do not write files they expect users to access in
those folders as the whole reason for that tree is to protect
data and settings from any unwanted change or deletion.

So weird that when this comes up more people aren't bothered by it.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 5th Apr 2020 07:03
Theres also a dll floating around the forums with an extensive list of commands for doing just that

fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
SFSW
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 5th Apr 2020 07:06
It is an unfortunate side effect of the changes made internally to Windows since the implementation of UAC dating all the way back to Windows Vista in 2007. It has kind of been the new normal since then, so it's not that unusual for programs/apps to automatically route to the default 'authorized' folder location specified by the Windows ecosystem. It's easy enough to change and reroute though as long as AGK/S continues to offer the 'raw:' prefix option.

As indicated above by others, it's good practice to prefix all of your app's read/write operations with a string that contains the folder destination you want to store and retrieve data from. This also helps your app be better prepared for future potential changes as well as differences between different operating systems and platforms.
Freddix
AGK Developer
22
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 5th Apr 2020 10:33
@All : Thank you for your answer ... I must admit that the amount of commands to read/write makes me a bit confused about which one will fit my needs.

Ok, so according to Raven, the getReadPath() works for me, it gives the default executable path (for Windows). It's required to created the path with a constant like you said :
#Constant PATH "Raw:" + GetReadPath( ) + "media/"

Great.
Now, if I'm not wrong, when I save file, I Just have to add the PATH constant at the beginning of the file name and it will be saved inside the Media folder.

Concerning protected path, my works is NEVER in the C: hard drive.
It's on a 2nd one that have no writing restrictions ... So it will works perfectly for me. But I will have to thinkg about user that install their projects in another path to ask them to check writing permissions...

Thank you all.
Now I can continue what I'm working on ... PluginKIT is far from release ... I just have to fix 1 bug I have in the 2D Lighting system, complete the HTML doc for the available commands, and I will release it on my gitHub (licence principle is ready too).
AliceSim1
6
Years of Service
User Offline
Joined: 15th Oct 2018
Location: Barcelona
Posted: 5th Apr 2020 11:24 Edited at: 5th Apr 2020 11:25
Loktofeit wrote: "I don't know why so many people accept this weird system of putting things in
C:\Users\[username]\AppData\Local\AgkApps\MyApp\ ,

It is a folder and subfolders that are hidden by default
and were never meant for users to be regularly access.
And, YES, if you are developing an AGKS program that
saves files, you are regularly accessing it.

So weird that when this comes up more people aren't bothered by it."

I prefer to use: GetDocumentsPath()
https://www.appgamekit.com/documentation/Reference/File/GetDocumentsPath.htm



It is very visible and easy to locate for any user, and to be able to customize created game files (options, saved games, additional graphics and music ...)
There are commercial games that use it, such as The Sims, The Witcher 3 ... etc.

Freddix
AGK Developer
22
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 5th Apr 2020 14:18 Edited at: 5th Apr 2020 14:22
@AliceSim1 :
I understand your idea but it does not fit my needs. Here is why.

1. PluginKIT can precalulcate 2D light systems for tiles/layer using software shadow casting / Light mapping own system.
2. When the program run, it must detect in the media/ folder if lights precalculations are available for each light. if yes, it load the light.
3. If no light precalculation is available, it calculate them and save the final image to avoid further calculation (excepted if flag to force refresh is set to TRUE).
4. The obejctive is that devel on PC and run tests on PC. Once donc, you just have to compile to APK (Android) ou IPA (iOS) and everything will be available in the media directory to avoid light mapping calculation when the game starts
That's why I need the files to be outputted inside the media directory

Here is a capture of the WIP :

The 2D Light system is now running best, the precalculation images are saved where I want.
I just have now to save the lights params to enable an auto-optimisation system that will update precalculation only if : 1. Light data file is not available or 2. Light data informations have changed until the last save..

Thank you all.

Attachments

Login to view attachments
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 6th Apr 2020 05:38 Edited at: 6th Apr 2020 05:39
As FubarPk said, why not just write them to media folder?
If the device doesn't allow, the do a try/load sequence..

if in location x then load else..
if in location y then load..

It is apparently deprecated, but SetRawWritePath(GetReadPath()) works for me?
If I write out a file, it goes in the /media dir.
Freddix
AGK Developer
22
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 6th Apr 2020 07:54 Edited at: 6th Apr 2020 07:56
nz0, you don't understand.

The objective is to avoid developer to have to makes copy'n'paste.
During game development developer create levels, add lights ... When he run they are precalculated and saved with all other medias required for the game to run.
Once it's done, he can compiles to .APK ou .IPA and then, as the precalculation images are available in the media folder, when the game run on Android/iOS, it automatocally load the precalculated images and does not precalculate them again.
IT's the best solution.
I just have to add a checking that ensure that if the game run on Android or iOS without the light precalculated, it does not try to save precalculation images (somewhere than in the default app writing folder) ... But I do not recommand this because as calculation take times ...it's battery consumption ... So it's better to precalculate on PC ...

Now it works perfectly.

Login to post a reply

Server time is: 2024-11-22 04:07:29
Your offset time is: 2024-11-22 04:07:29