ElectronMV

Discussion in 'Useful Development Tools' started by Quxios, Dec 2, 2016.

  1. Quxios

    Quxios Veteran Veteran

    Messages:
    1,055
    Likes Received:
    772
    First Language:
    English
    Primarily Uses:
    RMMV
    ElectronMV v1.1.X ( Electron only works for windows 7 and newer )
    Electron wrapper for RPG Maker MV. Wrapping MV with Electron gives a handful of benefits. One of the main benefits includes in this wrapper is being able to remember the window position, size and if it was full screened the next time it's opened. See example here:


    Other benefits including; being able to create an updater for your game, creating a launcher, and more.

    Installing
    https://github.com/quxios/ElectronMV#installing



    Running
    https://github.com/quxios/ElectronMV#running-project-with-electron


    Building
    https://github.com/quxios/ElectronMV#building-your-game


    Configuring
    https://github.com/quxios/ElectronMV#configuring


    Advanced
    This section for for js devs or programmers.

    1st, this uses the 2 package method. The package.json in the main directory is used during development, while the one inside the app/ is for production. So don't forget to add any dependencies you add to the development package into the production one as well. Don't add any dev dependencies into the production one since there's no point.

    /package.json - Dev dependencies

    babel-cli - To compile babel scripts when deploying or converting for vanilla MV
    babel-preset-electron - Adds missing es2015 plugins and stage-0 to electron
    babel-preset-es2015 && babel-preset-stage-0 - for compiling es2016 plugins for vanilla MV
    electron-builder - To build the game
    electron-prebuilt - electron

    Creating plugins that can use dependencies
    Plugins in MV are loaded through a script tag. So if you were to try some babel transformation, for example jsx, you will get an error even if you have the preset installed. So to fix this just end the file name with:

    -req.js

    And that plugin will be added with require instead of a script tag. Now you can go ahead and write that plugin as you would like. Just don't forget to compile it before building the game or you'll get errors.

    * Note that plugins need to have the extension .js or the plugin manager in RPG Maker MV editor will not find it.

    * Notes
    - Some plugins may not work with this if they use any nw.js.
    - Electron only works on windows 7 and newer. So if you use this your windows os requirement should be windows 7+
     
    Last edited: Feb 5, 2017
    #1
    Roguedeus, Mistral, Dr.Yami and 9 others like this.
  2. taarna23

    taarna23 Marshmallow Princess Global Mod

    Messages:
    2,349
    Likes Received:
    4,623
    Location:
    Saskatoon, SK, Canada
    First Language:
    English
    I looked at this at one point - seems interesting. Nice job!


    I can say for sure it won't work with my plugin that relocates the safe file to appdata folders - it uses nw.js.
     
    #2
  3. Quxios

    Quxios Veteran Veteran

    Messages:
    1,055
    Likes Received:
    772
    First Language:
    English
    Primarily Uses:
    RMMV
    Thanks!

    And you can also patch it. If you're using nw.js to find the appdata path you can use electron's app.getPath('appData') to find it.
     
    #3
    taarna23 likes this.
  4. taarna23

    taarna23 Marshmallow Princess Global Mod

    Messages:
    2,349
    Likes Received:
    4,623
    Location:
    Saskatoon, SK, Canada
    First Language:
    English
    I totally forgot I replied here. So I could theoretically have it check which framework it's running under and have it get the path the appropriate way. That's pretty cool.
     
    #4
  5. Quxios

    Quxios Veteran Veteran

    Messages:
    1,055
    Likes Received:
    772
    First Language:
    English
    Primarily Uses:
    RMMV
    @taarna23 Yup



    An easy way to check if it's running with electron is to check for:


    Imported.QElectron


    or

    Code:
    process.versions.electron
     
    Last edited by a moderator: Dec 14, 2016
    #5
  6. Quxios

    Quxios Veteran Veteran

    Messages:
    1,055
    Likes Received:
    772
    First Language:
    English
    Primarily Uses:
    RMMV
    Just updated to 1.1.0


    https://github.com/quxios/ElectronMV/

    • Edited index.html to run with Electron if running with nw.js. This means that you can play test ElectronMV Projects with the play test button in the MV Editor.
    • Added 2 new .bat files; deploy.bat, nwjsToEMV.bat
      - Use deploy.bat to deploy / build your game for production. The nwjsToEMV.bat just runs the play.bat in a new cmd instance.
    • Included a sample -req.js plugin for js devs
     
    Last edited by a moderator: Dec 28, 2016
    #6
  7. Quxios

    Quxios Veteran Veteran

    Messages:
    1,055
    Likes Received:
    772
    First Language:
    English
    Primarily Uses:
    RMMV
    Update 1.1.1
    https://github.com/quxios/ElectronMV/
    • Fixed re-sizable always returning true
    Added a video on installing it:

    Will probably remake later on with a voice over instead of having text.

    Update 1.1.2
    • Changed to run electron locally
     
    Last edited: Feb 5, 2017
    #7
  8. Nefiron

    Nefiron Warper Member

    Messages:
    2
    Likes Received:
    1
    First Language:
    Danish
    This is amazing. I've had the same thoughts for long but never got around to do it.
    This will also give people the opportunity to make a wrapped environment if they want to do server request and extended features for their game.

    There's a ton of application potentials with this solution.

    Well done!
     
    #8
    Quxios likes this.
  9. Quxios

    Quxios Veteran Veteran

    Messages:
    1,055
    Likes Received:
    772
    First Language:
    English
    Primarily Uses:
    RMMV
    Exactly! And thanks
     
    #9
  10. Quxios

    Quxios Veteran Veteran

    Messages:
    1,055
    Likes Received:
    772
    First Language:
    English
    Primarily Uses:
    RMMV
    Update 1.1.3
    • Changed up some of the coding style ( added semicolons ) to make RMMV style a bit more.
    • Changed a few code in the rendererMain.js
    • Fixed a bug where the window wouldn't move to save position if the x/y was 0
    For more details, you can see the commits

    To update, you only need to replace electronMain.js and electronRenderer.js
     
    #10
  11. Krimer

    Krimer Veteran Veteran

    Messages:
    126
    Likes Received:
    89
    Location:
    Kiev, Ukraine
    First Language:
    Ukrainian
    Interesting tool, thanks for your work.

    Tried with new version of MV(1.5.0) playtest from play.bat works fine.
    But then i tried deploy.bat. After deploying i have this error when game startup.
    [​IMG]
    Then i tried old MV version 1.4.1. Playtest works fine but after deploying and click somewhere on game map with mouse got this error
    [​IMG]
    This tests I was doing with clear new projects of each MV versions. Maybe I miss something?
     
    Last edited: Jun 9, 2017
    #11
  12. Quxios

    Quxios Veteran Veteran

    Messages:
    1,055
    Likes Received:
    772
    First Language:
    English
    Primarily Uses:
    RMMV
    @Krimer Yeah I was going to patch for 1.5.0 today. And it worked on previous versions so you previous error shouldn't be due to this, but an error with a plugin that you are using (either an error with the plugin itself or an incompatibly with the plugin and electronMV). So you'll need to figure out which plugin is causing that error.

    Update 1.1.4
    • Fix for MV 1.5.0 by adding the missing lib to the index file
    For this update, you only need to grab the new index.html file, other files are basically the same besides a few numbers changed in them. Also remember, when updating your Electron MV project due to an MV update, NEVER replace the index.html file, electron MV requires a custom index.html file. Most of the time when MV updates say to replace the index.html you don't have to because that file hardly ever changes with the updates, only time you have to update it is if they added a new file in the lib folder. If there ever is a change to it, I'll update the electron index.html to work with the latest MV version.
     
    #12
  13. Krimer

    Krimer Veteran Veteran

    Messages:
    126
    Likes Received:
    89
    Location:
    Kiev, Ukraine
    First Language:
    Ukrainian
    I know about new lib and add it manually to your index before. But after your update I don't change anything, use only your files.
    And i still have the same error for 1.5.0.
    Playtest(play.bat) works fine but deployed project doesn't(getting error "WebAudio.initialize not a function")
    Test project is clean new project without any plugins.
    [​IMG]

    Did you test deployed project? Maybe i just miss something, but I've done all steps in your readme file.
    I think something goes wrong in deployment. Because if I copy files from folder "compiled" and paste them to "app" folder - even playtest(who works before) will stop working with the same errors.

    upd:
    I've done some investigations and i can say - deployment corrupt game files, at least for me. Some round brackets just disappear in game files after deployment. They disappear selectively not all.

    Here is examples
    [​IMG]
    [​IMG]
    It's only some of them.
    Can you check it? Maybe i'm not alone :)
     
    Last edited: Jun 11, 2017
    #13
  14. Quxios

    Quxios Veteran Veteran

    Messages:
    1,055
    Likes Received:
    772
    First Language:
    English
    Primarily Uses:
    RMMV
    I just tested and it's not corrupting it, but "cleaning" it. You can fix that error by removing the babel compiling in the package.json. So grab the new package.json:
    https://github.com/quxios/ElectronMV/blob/master/package.json

    If you are using any babel in any of your plugins, then you'll need to manually compile them yourself now.
     
    #14
    Krimer likes this.
  15. Krimer

    Krimer Veteran Veteran

    Messages:
    126
    Likes Received:
    89
    Location:
    Kiev, Ukraine
    First Language:
    Ukrainian
    Nice, thanks. Without "cleaning" thing all works with no problem. But anyway will test it more.
     
    #15
  16. EduHdz404

    EduHdz404 Warper Member

    Messages:
    1
    Likes Received:
    0
    First Language:
    English
    Primarily Uses:
    RMXP
    Would this work with Rpg Maker XP?
     
    #16
  17. Kes

    Kes Global Moderators Global Mod

    Messages:
    19,162
    Likes Received:
    9,823
    First Language:
    English
    Primarily Uses:
    RMVXA
    #17
  18. Quxios

    Quxios Veteran Veteran

    Messages:
    1,055
    Likes Received:
    772
    First Language:
    English
    Primarily Uses:
    RMMV
    @EduHdz404 Nope, only works with MV since it's written with JS and is basically a webpage.
     
    #18
  19. Zarsla

    Zarsla Veteran Veteran

    Messages:
    673
    Likes Received:
    190
    First Language:
    English
    Will the electron wrapper work on Mac or Linux. Ie if I do the wrapper with my deployed MV game, can I send this to my friend with a mac book and they can run it? Or can I copy all of it and put it in my Linux VM and run it? Or is it windows only?
     
    #19
  20. Quxios

    Quxios Veteran Veteran

    Messages:
    1,055
    Likes Received:
    772
    First Language:
    English
    Primarily Uses:
    RMMV
    @Zarsla It should though you would need to change the build commands in the package.json to work for mac/linux. Also none of the bat files will work on mac/linux so you would need to use the cmd prompt. And because the bat files dont work, that means you won't be able to use my hook (hitting play from the editor makes the batch file run), so you need to manually run your game every time like a normal electron app or edit the hook to not use the batch.
     
    #20

Share This Page