[REQUEST] Subdirectory for Export

Post » Fri Mar 31, 2017 11:52 am

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?
www.simbucket.com - HTML5 Science Simulations / https://www.airconsole.com/#!play=com.n ... obotrumble - Robot Rumble on AirConsole
B
51
S
16
G
25
Posts: 425
Reputation: 17,423

Post » Fri Mar 31, 2017 12:55 pm

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?
Scirra Founder
B
400
S
237
G
89
Posts: 24,550
Reputation: 195,527

Post » Fri Mar 31, 2017 1:10 pm

@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?
www.simbucket.com - HTML5 Science Simulations / https://www.airconsole.com/#!play=com.n ... obotrumble - Robot Rumble on AirConsole
B
51
S
16
G
25
Posts: 425
Reputation: 17,423

Post » Fri Mar 31, 2017 1:59 pm

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.
Scirra Founder
B
400
S
237
G
89
Posts: 24,550
Reputation: 195,527

Post » Fri Mar 31, 2017 3:09 pm

Ashley wrote: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?
www.simbucket.com - HTML5 Science Simulations / https://www.airconsole.com/#!play=com.n ... obotrumble - Robot Rumble on AirConsole
B
51
S
16
G
25
Posts: 425
Reputation: 17,423

Post » Fri Mar 31, 2017 3:32 pm

@cjbruce I think I've found a solution for this issue, I'll be posting it on my plugin thread in a while.
Banned User
B
17
S
7
G
24
Posts: 388
Reputation: 14,494

Post » Fri Mar 31, 2017 4:07 pm

X3M wrote:@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.
www.simbucket.com - HTML5 Science Simulations / https://www.airconsole.com/#!play=com.n ... obotrumble - Robot Rumble on AirConsole
B
51
S
16
G
25
Posts: 425
Reputation: 17,423

Post » Fri Mar 31, 2017 4:24 pm

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...
Banned User
B
17
S
7
G
24
Posts: 388
Reputation: 14,494

Post » Fri Apr 07, 2017 8:42 pm

X3M wrote: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
B
34
S
12
G
3
Posts: 233
Reputation: 4,490

Post » Sat Apr 08, 2017 5:28 pm

X3M wrote: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.
Scirra Founder
B
400
S
237
G
89
Posts: 24,550
Reputation: 195,527

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests