User-defined folders containing pictures for use in-game

0 favourites
  • 10 posts
From the Asset Store
15 main themes, 15 in-game loops and 26 music stingers for casual games.
  • I'm struggling - in fact I'm totally stuck - trying to implement the following feature set:

    On Android;

    Allowing a user to specify an arbitrary local folder;

    Populating a struct with paths to each image file within (including subfolders);

    So that I can use the struct later to make 'load image' calls etc;

    And use the images in my game.

    I'm aware of the 'file chooser' object. This is fine for pointing at a single image, but I can't work out how to use it - or find/create an alternative - so that I can let a user point at a folder full of images. I can let the user select multiple files within a single folder, however this requires the user to actually select each file, file by file. The game is designed to incorporate hundreds of arbitrary/user-defined pictures, possibly from several disparate locations.

    My game stands or falls on my ability to implement this feature.

    Any help and all discussion appreciated.

  • See where it says load image from url?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi Newt. That's not the bit I'm having difficulty with.

    I can't find/create a feature by which a user can select whole sets of images at once by selecting a parent folder or being presented with some sort of 'select all' option.

    Imagine the user has 900 images in an arbitrary folder on their Android device. To use these images in my game the best I can do at the moment is let the user tick each image with the UI that the 'file chooser' object in multiple mode throws up. Thats a LOT of scrolling and tapping and ticking. It kills the game.

    I need to enable the user to select 'this folder full of images' or, if the file system is abstracted (which is a sad, regressive thing about phablet environments making people less computer literate than they were 10 years ago, in my opinion) enable them to select 'this set of images my phablet has wrapped up for me as a set'.

  • Its for security, the engine is for games rather than apps.

    Your best option is via the cloud.

  • Are you saying with certainty I can't achieve this and that you know this to be a wilful design limit of the platform?

    I would find that bizarre in the extreme. I am not swayed by the reason being "security" (in fact I wonder if you yet fully understand what I'm asking as an arbitrary file can be selected; just not an arbitary set of files). "Security" as a reason is doubly ridiculous if the official 'more secure' alternative involves hosting files in farm under, for example, US law. (I'm not your average bear on this subject; my day job is infsec consultancy for international banks).

    I paid £80 for a Construct 2 license so that I could publish to Android. It seems a reasonable expectation that I could have the users of my software use their pictures in their games. If this is not possible - by design or otherwise - then I'll be seeking a refund from Scirra. Even as I type this, I am hoping someone might be able to suggestion a means by which a user can point at a folder. I was doing that in platforms from coverdisks in 1992. I wonder if perhaps I have somehow misrepresented my question. I'll go over what I've written.

  • I wonder if this could be something that Android blocks. Are there any Android apps which can arbitrarily load all user photos?

  • Hi copilot. There are many 3rd party file system explorers, galleries, art packages and so on. 'Folder + contents' access is not an issue at the android level per se (though I don't doubt for a second that the tech used to build such software was something other than embedded browser+HMTL5+javascript).

    I have questioned if maybe the browser/HTML5 environment in Android is somehow walled-off to a greater degree or in a different way that cripples arbitrary, user-approved file system access. This is the case in some respects, however, it shouldn't be a factor for my specific issue as the underlying access - ie. reading user-defined arbitrary files - is demonstrably a working feature; I just can't empower the user to pick a folder of files. By the transitive law, there's no security benefit to ruling out folders when a user can pick n files within one, so I just don't understand where the hitch is.

    It's as if it's an oversight in the way the file chooser object works; rather than an Android block. I don't know enough to actually make a conclusion though.

    I only really know two things at this point: my game is screwed if users can't designate their photos en mass for use in the game; and that I can't see a sound reason for this to be an actively made limitation of either C2 or Chromium or the Android file system object that 'file chooser' makes use of. To me, this suggests that there's an oversight somewhere OR room for a better plugin.

    I'm hoping for a kindly expert to straighten me out. I am baffled. The best I can do at the moment is let my players pick images from their photos one at a time. Users just aren't going accept that.

  • [quote:3vfc404u]Allowing a user to specify an arbitrary local folder;

    Populating a struct with paths to each image file within (including subfolders);

    So that I can use the struct later to make 'load image' calls etc;

    And use the images in my game.

    You can do that with NWjs, I do it in my program. However have no clue how NWjs plugin work with android. But when that is said, Working with NWjs to do something like this is NOT designed to be easy. It is filled with bugs, functionalities that you would assume were compatible, but ain't. So the only way you can make it work, is if you create a *%kvy@# load of workarounds. Like parsing path to files, folders etc. and if you are not sure how many sub folders there are, it will be even harder.

    When that is said you write that the user might select 900 images for instant. Which will lead to the next problem, which is "Load image from url" if you plan on showing more than 1 image at the time in you app. You actually have to create the number of objects or frames in the object which you want to hold each image or it will not work, as it will overwrite your other images. So this gives you two problems.

    1. Either you say that there can be a maximum of images in your application. And just hope that is enough.

    2. Or you can let them only load one image at the time.

    So you are left screwed to be honest. Because If you use option 1, you actually have to create X amount of empty frames in you application for no reason. So if you want the user to be able to load lets say 100 images and preview them in the application. You have to add 100 empty frames to the object holding the images. Which of course means that your application will read all 100 empty frames into memory for no reason, which will probably not be good for your applications performance.

    And if you use option 2, you wont be able to do what you want.

    But should you decide to give it ago anyway. System.Tokencount and System.Tokenat are very useful, when parsing paths. Besides that I don't even know where to start giving you advice, because the way it works is just to weird and bugged that, you pretty much have to make up the workarounds as you run into them. But of course its a good idea to make sure if NWjs even works with Android.

  • Thanks very much for your effort and thoughts, Nimos, I will definitely look into your points about NWjs.

    Happily, the issue is not about the manipulation of the images once I have paths to them. All that stuff is solid, tested, and working. You see, while the game needs to know about large sets of images, it actually only uses a subset of them in the game. As it happens, I use an approach similar to one you suggested where I populate frames of a sprite with images from the user-picked files. All of this works 100% (notwithstanding another bug whereby Android doesn't render every type of jpg a person might have; only some - but that's a completely separate issue we can forget about for now).

    The issue at the moment is allowing the user to designate a folder full of pictures (a few taps on the screen); rather than having to pick every single image individually which might mean 900 taps.

    I can envisage a solution as a tweaked or expanded version of 'File Chooser'; or something done with javascript (perhaps presented to C2 as a plugin); or - and this is my hope - a solution that is essentially someone pointing out that I'm doing something wrong or perhaps directing me to an existing plugin or javascript module of some sort.

  • Is it doable?

    Yes.

    It will require some finagling with the os, but it will probably also require a separate plug to do so. I know of no third party plug designed to do that, and definitely no official plug for it.

    It is a security feature of the os that you have to jump though a few hoops to do that sort of thing. I can't say for 100% why its not included in C2, but again since this is for games its not that hard to imagine why it isn't.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)