Script (java)
Script (java) - lets you enter Java-based code. To see how this works, enable
"Save generated script" in the program options. The following files
are then created in the __SCRIPTS subfolder of the project folder when you compile the project:
- script.show - the main script body;
- script_Manager.java - the list of the functions used;
- script_Inactivity.java - the Inactivity and EverySecondAction commands;
- script_MediaListener.java - the EndAction (onMediaEnd) and Chapter (onMarkReached) commands.
Another way to see how this works is to select any action (for example Jump menu or Play movie) and then select
"Script (java)" instead: the Java code is generated automatically.
Types
The following types are used:
- void - used for functions; it means that nothing is returned.
- double - the standard Java double type.
- float - the standard Java float type. Use the "f" suffix for float values, for example
"1.1f".
- int - the standard Java integer type.
- long - the standard Java long type. Use the "L" suffix for long values, for example
"1234L".
- boolean - the standard Java boolean type (the logical values true/false).
- String - string values (java.lang.String); they must be enclosed in double quotes. Do not confuse String with
the type #string (see below).
- #int - integer values used for logical chapter numbers, equal to int + 1. All #int values must
start with #. If a function requires an int value, the first chapter (the start of the movie) is 0. If a
function requires an #int, the first chapter (the start of the movie) is #1. See "Available functions"
below.
- #string - string values for the preprocessor; they must be enclosed in single quotes. They are used to convert
movie and menu names into playlist IDs.
Constants
- long duration - the duration of the current movie/playlist in nanoseconds.
- int CC[type]_[name] - the number of chapters in the specified movie or playlist. [type] is MV for a movie
or PL for a playlist. [name] is the movie/playlist name in upper case with all spaces replaced by underscores.
For example, for the movie "Main movie" the chapter count constant is CCMV_MAIN_MOVIE.
- int currentJAR - the number of the current JAR.
Name conversion
When you refer to any object of the program by name (item, movie, menu), the following rules apply:
- in all names, spaces are replaced with underscores;
- the names of all menus and movies get a prefix:
- "MM_" - main menu;
- "PM_" - popup menu;
- "MV_" - movie;
- "PL_" - playlist.
- when a menu is called, the prefix "S:" is added at the beginning of the menu name;
- when the handler of a menu button is called, the prefix "H:" is added at the beginning of the menu
name and the suffix ".Handler" is added at its end;
- the name of a menu assembly starts with "F:" and ends with ".assembly";
- when jumping to a menu, the suffix ".show_menu" is added at the end of the menu name;
- when jumping to a menu for the first time, together with the start of the video, the suffix
".show_menu.first_run" is added at the end of the menu name;
- when jumping to a menu with an enter animation, the suffix ".animate" followed by the number of the
animation is added at the end of the menu name;
- all movies use the same segment to open the popup menu - S:Movie;
- user-defined parameters get the prefix "UDV_" before their names;
- all features (object states) start with "F:", followed by the menu name, a dot ".", the
object name and, for buttons, another dot "." and the state name
(Normal/Selected/Activated/Current); for example:
F:MM_main.Play.Normal, F:PM_scenes.background.
- the storage keys used are:
- resume_(number) - the resume time of playlist (number)
- audio_(number) - the active audio track of playlist (number)
- subtitle_(number) - the active subtitle track of playlist (number)
- sub_on_(number) - the subtitles on/off state of playlist (number)
- chapter_(number) - the current chapter of playlist (number)
- playlist - the last played playlist
- segment - the last active segment
- assembly - the last active assembly
- feature - the last active feature
- mode_3d - the 2D/3D mode
- mode_sfx - the SFX on/off state
- handlers - the number of handlers
- handler_(number) - the name of handler (number)
- handlerstate_(number) - the state of handler (number)
Example - jump to the main menu "Main Sound" and select the "SndMusic" button:
manager.activateSegment("S:MM_Main_Sound.show_menu");
manager.activateButton("H:MM_Main_Sound.Handler", "SndMusic");
Example - play the movie "Movie":
manager.setStartPlayMark(#1);
manager.activateSegment("S:MV_Movie.play_movie");
Dynamic load notes
In Dynamic load mode, "Jump menu" commands are translated into transitions that preload the graphic
segments. Therefore all "activate segment" commands have to lead to the corresponding transition segments.
To generate these transitions, the engine needs to know the target segments, so you have to add special comments to
tell it:
//TRANSITION:[transition_segment_name]:[target_segment_name]:[source_segment_name]:[target_menu_prefix:target
menu name]
For example:
-
//TRANSITION:[S:MM_Main_ent_anim.show_menu.MM_Main.show_menu]:[S:MM_Main.show_menu]:[S:MM_Main_ent_anim.show_menu]:[M:Main]
- for a jump from the main menu "Main ent anim" to "Main" without an enter animation;
- //TRANSITION:[S:EMPTY.PM_Main_ent_anim.animate1]:[S:PM_Main_ent_anim.animate1]:[]:[P:Main ent anim] - for the
popup menu "Main ent anim" entered through enter animation 1.
You can see how these comments are generated automatically by selecting "Script (Java)" for any command
while "Dynamic load" is enabled.
Note that the scripts generated with and without "Dynamic load" are different.
If Safe is selected, the following internal names are replaced:
_anim_segment_done_ → _sd
QueueTimer → QT
_ActivatedPause_ → _AP
DummyAnm → DA
Dummy → Y
Everything → ET
Loading → LD
AnimList → _L
Anim → _A
animgroup → ag
animall → aa
obj_btm → _b
obj_top → _t
If All is selected, the following names are replaced in addition to those replaced by Safe:
animate → _a
ClosePopup → CP
Normal → N
Selected → S
Activated → A
Current → C
show_menu → sm
first_run → fr
play_movie → pm
Handler → H
Listener → U
assembly → as
activated → ac
Press → P
Enter → E
Select → T
Left → L
Right → R
Down → D
Green → G
Yellow → Y
Blue → B
PopupMenu → PM
NextTrack → NT
PrevTrack → PT
FastForward → FF
Rewind → W
Available functions (methods)
Described here.
Hotkeys
- Ctrl+Enter - saves the script and closes the window.
- Ctrl+Space - shows the list of available functions.
- Ctrl+T - shows the list of additional types and language constructs.
- Ctrl+Z - undo.
- Ctrl+Shift+Z - redo.
- Ctrl+Shift+0..Ctrl+Shift+9 - add a bookmark.
- Ctrl+0..Ctrl+9 - jump to a bookmark.
- Ctrl+F - find.
- Ctrl+H - replace.
- F3 - find next.
- Ctrl+Click - opens the code of the function.