Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/jfxr sound effects #716

Merged
merged 28 commits into from
Nov 3, 2018
Merged

Feature/jfxr sound effects #716

merged 28 commits into from
Nov 3, 2018

Conversation

blurymind
Copy link
Contributor

@blurymind blurymind commented Oct 23, 2018

This pull removes jsfx and replaces it with jfxr.

It also addresses some bugs with the path editor and the modalWindow

Jfxr yields better results and has a better interface
@blurymind
Copy link
Contributor Author

blurymind commented Oct 23, 2018

I noticed a bug in gdevelop with this, not yet sure whats causing it.
Basically if you create and save a resource with the name 'jump.wav' and playtest- it will work.
However if you then open it again and save it under a subfolder ('player')- resulting in the resource with name being the relative plath 'player\jump.wav' and playtest - gdevelop will fail to play the sound.

If you go in the resource manager and remove the first resource 'jump.wav', when playtest - 'player\jump.wav' will start to work!

alternatively renaming 'player\jump.wav' to 'player\jump2.wav' also fixes it

why is 'player\jump.wav' being affected by 'jump.wav'? and the other way around?

Something with the way resourcesmanager loads new ones or the way I am using it in this particular case?

Copy link
Owner

@4ian 4ian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a few comments but this looks generally good :)
Thanks for your work on this, that was super fast ;)

I still have a concern about having the code of jfxr included in the repository of GDevelop. Note that it's a big deal, but I wonder if we should not go the Piskel way and have a script to import it from an archive (I can host it on GitHub).
It's almost the same but as the code is not part of the codebase we keep a better separation of what is GDevelop vs what are the 3rd party editors.
Also can be in a way more respectful of the author as we don't commit the files of his editor directly in GDevelop (so stats/lines of code are not affected).
Lastly having a separate archive means that we can add it to the .gitignore, which also mean that most text editors won't show jfxr sources when doing search on all the folders - which saves time and is less frustrating than when you're trying to move around files by typing a name and that you end up with the files of a 3rd party project :)

newIDE/app/public/external/utils/path-editor.js Outdated Show resolved Hide resolved
newIDE/app/src/ResourcesList/LocalJfxrBridge.js Outdated Show resolved Hide resolved
newIDE/electron-app/app/ModalWindow.js Show resolved Hide resolved
@4ian
Copy link
Owner

4ian commented Oct 23, 2018

I'll be traveling at React Conf until Saturday to present a talk about GDevelop. I might be less available but will still try to continue reviewing.
Let me know if you need help for the script or something else.

@blurymind
Copy link
Contributor Author

I'll be traveling at React Conf until Saturday to present a talk about GDevelop. I might be less available but will still try to continue reviewing.
Let me know if you need help for the script or something else.

Thank you for reviewing :) I still have a few things to figure out before this is ready, so this gives me some time. Hope you have a nice trip and React Conf goes well.

Silly question: with piskel's implementation - where do you keep the zip file that contains piskel? It's not here:
https://github.com/4ian/GDevelop/tree/master/newIDE/app/public/external/piskel
I am wondering how to make jfxr be handled in the same way

@4ian
Copy link
Owner

4ian commented Oct 24, 2018

where do you keep the zip file that contains piskel? It's not here:

It's on GitHub. See https://github.com/4ian/GDevelop/blob/master/newIDE/app/scripts/import-piskel-editor.js#L26

If you attach here the link to a zip file containing jfxr, we can do the same - I'll give you the link :) The advantage of having it on GDevelop GitHub is that we're sure it will always work as long as GDevelop github is up.

Basically if you create and save a resource with the name 'jump.wav' and playtest- it will work.
However if you then open it again and save it under a subfolder ('player')- resulting in the resource with name being the relative plath 'player\jump.wav' and playtest - gdevelop will fail to play the sound.

I think it's because when you call addResource, if the resource already exists with the same name it won't be updated (the old resource will stay untouched).
Potential solution would be to test that a resource exists, if yes remove it and then add the new resource. Or I should modify addResource so that it erases the existing resource if it already exists.

@blurymind
Copy link
Contributor Author

blurymind commented Oct 24, 2018

Ah I see, it's getting it from the releases page. Clever 😄
In that case, once I get everything working, I will add a script to do that and delete the jfxr folder in public

On the resource - I will give this a try. Perhaps in the future we could make a generalized function to add/replace resources that does that? I wonder if piskel is affected by this too. I am getting a strange deja vu from when I worked a bit on the resource manager - with the scan for new resources function

@blurymind
Copy link
Contributor Author

blurymind commented Oct 24, 2018

I think this is an issue with the game engine, it still happens with audio resources if I add the resources by opening them rather than using the editor.

To replicate:

  1. add a resource jump.wav, resulting in name 'jump.wav'
    playtest (it works)
  2. add a resource in subfolder player/jump.wav resulting in name 'player/jump.wav'
    playtest (sound doesn't play at all)
  3. go to the resource manager and remove jump.wav
    playtest (player/jump.wav starts working)

btw in the past I made a commit that makes it use relative paths as names, see here:
7c17874

I can try to tackle it here if its something with the editor - or try in another pull and file a separate issue

I tried replacing the '\' with '-' in the name: it doesn't resolve the issue. Also if you swap the order of adding resources (starting with player/jump.wav on step 1, you will get the same effect. jump.wav on step 2 will not play)

My guess is that it is something that has to do with resource.setFile(path.relative(projectPath, resourcePath));

- fixes on path editor 
- moved some of the code from jfxr bridge as a step to make some of it reusable with piskel later on
- changed metadata storage approach to a url query string instead of object - simpler to save/load and also uses less data
from jfxr author 
- fix on sound autoplay ttencate/jfxr#37
- fix on url loading of data ttencate/jfxr#36
.. so we can later also use it for jfxr, once jfxr is zipped and released at github.
Update readmes
newIDE/app/package.json Outdated Show resolved Hide resolved
@4ian
Copy link
Owner

4ian commented Oct 26, 2018

Can you attach here the zip file? Will be faster for me to upload as I have little time right now :)

For the issue, is there any error in the console while previewing/exporting?
I think it's because the same filename is used and only one file could be copied. Would help if you can also send me a game with this so that I can take a look :)

@blurymind
Copy link
Contributor Author

blurymind commented Oct 26, 2018

Can you attach here the zip file? Will be faster for me to upload as I have little time right now :)

For the issue, is there any error in the console while previewing/exporting?
I think it's because the same filename is used and only one file could be copied. Would help if you can also send me a game with this so that I can take a look :)

No Problem :) I am attaching it to here
jfxr-editor.zip
This is the vanilla version, as compiled from its official git (link in the readme in this commit)

On the resource issue:
It seems to not be related to this pull, as it is in master. I can open an issue for it and attach a zipped project that demonstrates it.
The file names have the same names, while the resource names dont (resource names are relative paths). The two files exist with the same name in two different folders (root and root/subfolder)
Some times the issue doesnt happen for some reason -we need to isolate it

Edit: I opened an issue here #720

Getting back to this pull, there is still a problem with this with the .onload event not triggering by the iframe some times on the built electron version - I need to figure out why that happens and a way around it

@blurymind
Copy link
Contributor Author

blurymind commented Oct 26, 2018

I dont know why exactly, but it works ok when in the development environment, but when I build an electron release and run that- the path editor or the jfxr data is some times taking absolute ages to load when you run it , other times - it loads immediately. in general jfxr seems really slow at loading on the build, and ok at loading in dev environment, im trying to find out whats causing it

@4ian
Copy link
Owner

4ian commented Oct 27, 2018

I've uploaded the zipped editor here: https://github.com/4ian/GDevelop/releases/download/v5.0.0-beta55/jfxr-editor.zip

Getting back to this pull, there is still a problem with this with the .onload event not triggering by the iframe some times on the built electron version - I need to figure out why that happens and a way around it

I also observed this before with jsfx which is why I refactored to use "load" rather than DOMContentLoaded. I think there is a "race" condition, like code running before the page is fully loaded. I'm not sure why. Does jfxr have a function that we could use to be notified when the editor is ready? Would be more robust than relying on DOM events.

Thanks for opening the other issue. Don't have time to look at it now but I'll try to see what's going on in the next days

use link provided by @4ian to download jfxr
@blurymind
Copy link
Contributor Author

@4ian I updated the script in order to fetch jfxr as well, however I couldn't fix the loading problem on the build. I have no idea why it gets detected as loaded so late some times and immediately other times.

It works consistently well when in development mode though - so perhaps it has something to do with the release version of electron?

@4ian
Copy link
Owner

4ian commented Oct 28, 2018

Release version should work pretty similar... Is it loading though or sometimes stuck without showing anything?

@blurymind
Copy link
Contributor Author

blurymind commented Oct 30, 2018

yes indeed google will not get personal data, yet the author of jfxr can at least know how many gd users are using his tool :)
In any case as @4ian noted earlier this will not share any cookies or personal data to google

@blurymind
Copy link
Contributor Author

blurymind commented Oct 30, 2018

@4ian actually I wonder if running it from electron would give him any stats whatsoever. If it fails to connect and doesnt work, is there any point of even having it? I guess the only way to find out if it works is from him :)

@4ian
Copy link
Owner

4ian commented Oct 31, 2018

@blurymind With the configuration that you've added, ad specific features will be disabled but I believe basic stats (notably the number of users) will still be there. Electron is based on Chromium so this will work (and in his stats, he will actually see the browser being reported as "Electron" if I'm not mistaken).

I think it's fair to keep this as basic analytics will be useful for Jfxr author while avoiding any personal data to leak, both because we're in Electron so outside the user browser and because AdFeatures were disallowed.

If there are no other concerns I'll merge this later tomorrow (when I finally get a bit of time!)

@blurymind
Copy link
Contributor Author

blurymind commented Oct 31, 2018 via email

@zatsme
Copy link
Contributor

zatsme commented Oct 31, 2018

There are some analytics in GD (but not using Google Analytics) for this purpose: knowing how many people are using GD and what are the main features they are using.

As noted before the analytics script doesbt really affect the app, it just delays the onload iframe signal.

Neither of these bother me but I was wondering if either of these might require extra app permissions in android or ios which might cause some devs problems with moaning users?!

@Wend1go
Copy link
Contributor

Wend1go commented Oct 31, 2018

As far as I understood the analytics scripts are only present in the IDE. The games you create shouldn't contain any analytics code.
But when the IDE gets ported to mobile devices in the future this might become an issue.

@4ian
Copy link
Owner

4ian commented Oct 31, 2018

The games you create shouldn't contain any analytics code.

This is correct, games are not concerned by Analytics so no extra permission is required. ;)

But when the IDE gets ported to mobile devices in the future this might become an issue.

Analytics are just an API that is called to report usage of features, so the only "permission" needed is an internet connection :) There is no reading of anything from the device. It's also optional so if internet connection is not working, it does not affect the rest of the app.

@blurymind
Copy link
Contributor Author

blurymind commented Oct 31, 2018

I gave this a try via the signal jfxr author added, it doesnt work as well as the timer yet. Half the time it fails to receive the signal.
Here is the newest build of jfxr-editor btw
jfxr-editor.zip

I think it would be better to merge this with the timer approach- as that works 100% of the time both in dev and in release - to the end user that is all that matters- they will not care how we do it, only how well it works.

Once we have a signal approach that is also as solid- replace it in another pull

The timer may look a bit hacky, but it seems to do the job more reliably than any signals. I am actually starting to think of using it on piskel too. In some rare cases piskel has the same problem of a signal not being fired at the right time when initiated btw.

The string methods are not the right approach
It seems to work solidly with no workarounds now! Much thanks to @ttencate for the awesome help in getting this to be easier to embed
@blurymind
Copy link
Contributor Author

@4ian I am attaching the latest version of jfxr here:
jfxr-editor.zip
You will need to update it on the release

@ttencate I disabled the jfxr button and the twitter buttons - as they were causing the iframe embedding to break

@@ -1,7 +1,7 @@
This folder contains sources to embed Piskel editor (https://www.piskelapp.com/) so that it can
be used directly from GDevelop to edit images.

Piskel sources are downloaded by `import-piskel-editor.js` script. They are raw, unchanged sources
of the Piskel editor. Sources will be stored in `piskel-editor` folder.
Piskel sources are downloaded by `import-zipped-editor.js` script. They are raw, unchanged sources
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating this :)

initialResourcePath.length
),
projectBasePath: projectPath,
folderPath: path.dirname(initialResourcePath),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 😍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for catching this btw

@4ian
Copy link
Owner

4ian commented Nov 3, 2018

I am attaching the latest version of jfxr here:

I've updated it :)

Looks like we are very close! It's great that loading is now always successful, I think the approach is very clean (1) register the event listener, 2) Trigger the loading).

My only concern is, can you check by building GDevelop if all of this is still working? I don't see a reason why it would not but let's double check.

Look at my comments and if the editor loading is bullet proof, let's merge this :)

@blurymind
Copy link
Contributor Author

blurymind commented Nov 3, 2018

@4ian its rock solid now. Built and tested 😸👍
This pull should also fix
#726

@4ian
Copy link
Owner

4ian commented Nov 3, 2018

I've tested it and it works well :) Also found the root cause of #720, see my comment here (it's not related so do not prevent this from being merged).

Thanks a lot for working on this integration! Will definitely be a good improvement to GDevelop. Thanks @ttencate for making this amazing editor too! :) We should update the website to mention that Jfxr is embedded in next version 😄

@4ian 4ian merged commit 82f92d3 into 4ian:master Nov 3, 2018
@ttencate
Copy link

ttencate commented Nov 4, 2018 via email

@blurymind
Copy link
Contributor Author

blurymind commented Nov 5, 2018

@ttencate It works really well. Thank you for providing the signal and the fixes in jfxr :)
@4ian thank you for looking into that bug. I can update the showreel to include jfxr when I have some time :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants