using javascript for menus?

For AI and campaign script related discussions and questions
Post Reply
Originway
Trained
Trained
Posts: 412
Joined: 08 Aug 2012, 06:22

using javascript for menus?

Post by Originway »

is it possible to start using javascript to make new menus and other elements on the display?
we can't figure out how to make this happen for a custom map-mod to use a new menu screen
Originway
Trained
Trained
Posts: 412
Joined: 08 Aug 2012, 06:22

Re: using javascript for menus?

Post by Originway »

also we want to change the title music in our map-mod depending on what menu option these select, is that possible?
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: using javascript for menus?

Post by Per »

We would really want a new javascript-based GUI. However, this is a lot of work.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: using javascript for menus?

Post by aubergine »

What if initially a JS env is created for menus and some basic functions are exposed to it - then modders could start hacking away at it? I imagine it would quickly turn in to a larger project with dozens of new functions/globals being asked for, most if not all of which would be very specific to menus. Maybe a 3.2+ project?
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: using javascript for menus?

Post by Per »

You do not understand. The current GUI code does not operate like a retained "scene graph", like most modern GUI toolkits. Everything in the GUI is composed anew every graphical frame. Exposing this broken architecture to javascript would do nobody any good.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: using javascript for menus?

Post by aubergine »

OMG, no wonder the GUI doesn't get updated much! I took a look at some of the GUI code and realised it was somewhat evil, but I had no idea it was redrawing everything every frame. That explains my laptop temperature increase even while looking at the menus...
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
Duha
Trained
Trained
Posts: 287
Joined: 25 Mar 2012, 20:05
Location: SPb, Russia

Re: using javascript for menus?

Post by Duha »

Per wrote:We would really want a new javascript-based GUI. However, this is a lot of work.
You can add browoser inside and make html widgets.

Code: Select all

var widget = getWidget(path_to_template, position, [size])

template:
<div width='2%' height='3%'>
   <input type='button' style='wz_buttons' value='Write to console', onclick='console('hello')'>
<div>
widget.show()
http://addons.wz2100.net/ developer
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: using javascript for menus?

Post by aubergine »

@Duha is that using QT? If so, which version?
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
Lord Apocalypse
Regular
Regular
Posts: 678
Joined: 29 Jul 2009, 18:01

Re: using javascript for menus?

Post by Lord Apocalypse »

This sounds like the EVE or WoW gui systems only using JS rather than Python or LUA.

Rebuilding the GUI even in a more modern game is a difficult challenge at best. By the sound of it for WZ it would be a nightmare at best and impossible at worst. May end up having to build a new GUI from scratch.
Originway
Trained
Trained
Posts: 412
Joined: 08 Aug 2012, 06:22

Re: using javascript for menus?

Post by Originway »

Duha wrote:
Per wrote:We would really want a new javascript-based GUI. However, this is a lot of work.
You can add browoser inside and make html widgets.

Code: Select all

var widget = getWidget(path_to_template, position, [size])

template:
<div width='2%' height='3%'>
   <input type='button' style='wz_buttons' value='Write to console', onclick='console('hello')'>
<div>
widget.show()
where do you add this code?
User avatar
vexed
Inactive
Inactive
Posts: 2538
Joined: 27 Jul 2010, 02:07

Re: using javascript for menus?

Post by vexed »

The problem with WZ's GUI code is not that it is drawn on every frame, that is fine & normal.
The issue is, everything is hardcoded at compile time.
It doesn't (yet) have the ability to handle external events, so all the glue code hasn't even been written.

This could all be under script control at some point in the future, but, as with everything else, we just need someone to write it first. :stressed:
/facepalm ...Grinch stole Warzone🙈🙉🙊 contra principia negantem non est disputandum
Super busy, don't expect a timely reply back.
User avatar
Duha
Trained
Trained
Posts: 287
Joined: 25 Mar 2012, 20:05
Location: SPb, Russia

Re: using javascript for menus?

Post by Duha »

vexed wrote:The problem with WZ's GUI code is not that it is drawn on every frame, that is fine & normal.
The issue is, everything is hardcoded at compile time.
It doesn't (yet) have the ability to handle external events, so all the glue code hasn't even been written.

This could all be under script control at some point in the future, but, as with everything else, we just need someone to write it first. :stressed:
Is it possible add new graphic layer above standart GUI?

js function that calls browser frame that can have access to game js enviroment
http://addons.wz2100.net/ developer
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: using javascript for menus?

Post by Per »

Adding a new GUI as an additional graphics layer, which replaces the old GUI piece by piece, is probably the only sane way to do it.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: using javascript for menus?

Post by aubergine »

I've been through the front-end UI to try and work out what JS API features would be needed (in addition to some sort of browser environment within WZ) to replace current menus & game set-up with HTML/CSS/JS...

https://warzone.atlassian.net/wiki/disp ... R/Menus+UI

Things get particularly complex around map previews and mp game host/join. But a lot of the rest of the stuff looks relatively straightforward from a JS perspective.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
Post Reply