Node Webkit - Open another hosted C2 game?

Get help using Construct 2

Post » Sun Aug 17, 2014 5:31 pm

I noticed that Node Webkit won't open another C2 game as a separate window (in node webkit, not the browser).

- Only happens for hosted C2 games.

Does anyone know why?
Last edited by Taurian on Mon Aug 18, 2014 4:01 am, edited 2 times in total.
B
34
S
10
G
5
Posts: 165
Reputation: 6,687

Post » Sun Aug 17, 2014 8:28 pm

I've narrowed it down to this: Uncaught ReferenceError: require is not defined

Code: Select all
      if (this.isNodeWebkit)
      {
         window["ondragover"] = function(e) { e.preventDefault(); return false; };
         window["ondrop"] = function(e) { e.preventDefault(); return false; };
         require("nw.gui")["App"]["clearCache"]();
      }
B
34
S
10
G
5
Posts: 165
Reputation: 6,687

Post » Sun Aug 17, 2014 9:12 pm

There are multiple ways you can create a window in node-webkit, because of security concerns (enabling newly open window access to require enables them access to multiple dangerous settings.) You are probably using the window.open from browser object?

Probably the newly open window has the 'node-enabled' set to false, to disable access to the node (more accurate, none of the parameters passed, so probably node is disabled by default, thus required not defined).

You can pass all of the parameters of the manifest format to the new windows:

Code: Select all
var win = gui.Window.open('https://github.com', {
  position: 'center',
  width: 901,
  height: 127
});


but mind that we're not doing the window.open, but rather gui.window.open.

I have managed to get multiple c2 projects together in a nw app, but i packed it manually, had custom manifest file, used custom plugin for opening new windows, and it was long time ago.

I would recommend to dive in window and security and manifest parts of the wiki for starters.

edit: sorry, i've written first, then opened your capx second -> i do not get any errors!
Be nice until it's time to not be nice
B
36
S
10
G
9
Posts: 293
Reputation: 6,712

Post » Sun Aug 17, 2014 10:39 pm

You're able to play the game when the window opens? (the capx)
B
34
S
10
G
5
Posts: 165
Reputation: 6,687

Post » Mon Aug 18, 2014 2:15 am

I updated to the latest beta and it works again (hate doing that).
B
34
S
10
G
5
Posts: 165
Reputation: 6,687


Return to How do I....?

Who is online

Users browsing this forum: dop2000, jatin1726, nahima and 4 guests