[REQUEST] Subdirectory for Export

0 favourites
  • 11 posts
From the Asset Store
2D Tile Set
$2.99 USD
Tile map for your 2d platformer games, custom sets available on request
  • When doing work for both a private client and in creating a game for AirConsole, I needed to be able to create a different folder structure for the exported game root directory. In order to make things work, the only thing allowed in the root directory was the index.html file -- everything else had to be in a subfolder. Here is an example of what the root directory needed to look like:

    index.html

    [directory_of_game_files_where_I_could_specify_my_own_directory_name]/

    I spent a lot of time editing the exported project files to accommodate a different directory structure. This used to be much easier in Construct 2 before data.js and runtime.js were split into two separate files. In any case, it would have been so much easier if there was simply an export option to specify the name of a subfolder for the project.

    Would it be possible to add a field in the "Export Options" window where we could specify a subdirectory for export?

  • If you can't at least put sw.js next to index.html, then it will break offline support. I don't want to add official features that break offline support.

    If you can at least put sw.js next to index.html, presumably you can put a few other files there too?

  • Ashley,

    Thanks for the prompt response! Neither my client nor AirConsole want offline support, so removing sw.js is not an issue for them. Would this be a lot of work to do on your end?

  • Like I said, regardless of who it matters to, I don't want to add features that break other features.

    Why can't other files be hosted alongside index.html? This sounds like an arbitrary restriction that could potentially break other C2/C3 features as well, so it seems the best solution is to allow this.

  • Like I said, regardless of who it matters to, I don't want to add features that break other features.

    Why can't other files be hosted alongside index.html? This sounds like an arbitrary restriction that could potentially break other C2/C3 features as well, so it seems the best solution is to allow this.

    Ashley

    No worries. I totally get that you can't afford to break the existing system. I have found a workaround for my client to meet their requirements.

    As far as AirConsole goes, I wouldn't actually need to keep everything out of the root directory, I would just need to be able to merge two projects into the same directory:

    AirConsole needs both a screen.html and a controller.html in the root directory. Up until now I have coded a very simple controller.html by hand and done all of the heavy game logic in the screen.html using Construct 2. I would like to use Construct 3 for both the screen.html and the controller.html so that I can do full mini-games on the controller while the main game is running on the big screen. The problem is that if I want to make and test a change on the controller, I have to go through a lengthy process of exporting both projects and deconflicting them.

    The process currently works like this:

    1. Make a modification to the AirConsole controller project.

    2. Export the AirConsole controller project to a folder. This overwrites the existing c2runtime.js and data.js used by the screen.

    3. Run X3M's macro to rename index.html, c2runtime.js, data.js, and all associated references to something different.

    4. Export the AirConsole screen project to the same folder.

    5. Rename the the index.html to screen.html.

    6. Test the change on a server using the AirConsole API.

    On my machine with my existing project, testing a single change on the controller takes about 8 minutes. It really slows things down, and I have had to keep the controller really simple as a result.

    In order to make the workflow for AirConsole go faster, I would like to have a way to put the data.js, c2runtime.js, and potentially all of the graphics/sound assets in separate named folders: one folder called "controller/", and another called "screen/", and update all the references to and from these files in the project. All of the other files could stay as they are because it doesn't matter if they overwrite each other.

    Could we possibly do an "Export to AirConsole Controller" and an "Export to AirConsole Screen" button?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • cjbruce I think I've found a solution for this issue, I'll be posting it on my plugin thread in a while.

  • cjbruce I think I've found a solution for this issue, I'll be posting it on my plugin thread in a while.

    X3M

    Sweet! Thanks!

    After reading what I wrote, I just realized that we probably just need another macro to rename the screen files. With C3 currently exporting as .zip files anyway, it wouldn't be any extra work to make a macro that unzips the screen and renames the files, then unzips the controller and renames its files. Then just copy both of the resulting directories into a target directory on the server, and we would be all set.

  • That's exactly what I figured out, we create a subdirectory called "controller", and we rename its index.html to controller.html and we drag it into the root folder in which the screen.html file resides. And then we modify the controller.html by adding controller/ before each href=" an src=" except for those who contain static http: hrefs.

    So now you have two folders to export to, and you only need to run a cmd file which access the controller.html file and prepends controller/.

    I really don't know why I have never thought about this...

  • That's exactly what I figured out, we create a subdirectory called "controller", and we rename its index.html to controller.html and we drag it into the root folder in which the screen.html file resides. And then we modify the controller.html by adding controller/ before each href=" an src=" except for those who contain static http: hrefs.

    So now you have two folders to export to, and you only need to run a cmd file which access the controller.html file and prepends controller/.

    I really don't know why I have never thought about this...

    This is also how the demo project is made: https://github.com/AirConsole/airconsol ... jects/pong

  • And then we modify the controller.html by adding controller/ before each href=" an src=" except for those who contain static http: hrefs.

    Actually, there's one thing that could make this easier - if you add <base href="folder/"> in the <head> tag, all requests are automatically made relative to that. But this will still break offline.

  • > And then we modify the controller.html by adding controller/ before each href=" an src=" except for those who contain static http: hrefs.

    >

    Actually, there's one thing that could make this easier - if you add <base href="folder/"> in the <head> tag, all requests are automatically made relative to that. But this will still break offline.

    Ashley

    You are a genius. This works perfectly!

    As per X3M and Psychokiller1888 's suggestion, I did the following:

    1. Exported the controller into a subdirectory called controller/

    2. Renamed the index.html file to controller.html.

    3. Added the following line of code to the <head></head>:

    <base href="controller/">[/code:3aff88bp]
    
    4. Exported the screen into a subdirectory called screen/
    5. Renamed the index.html file to screen.html.
    3. Added the following line of code to the <head></head>: [code:3aff88bp]<base href="screen/">[/code:3aff88bp]
    
    With 2 instances of Construct 2 running, the whole process took about 30 seconds.  And I can now keep the controller and screen separate without worrying about deconflicting them every time I change them.
    
    Edit:
    
    I have been playing around with this for the past 30 minutes, and realized that the problems are completely solved with this approach.  Because screen.html and controller.html never change, and any index.html files that are produced in the export process are never actually used after the initial renaming, you can just export the screen project and the controller project to the appropriate subdirectory, and everything just works!  There is no need to rename anything!
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)