From 9bbe8a78b6adea37828a6043913d211f83f7f33c Mon Sep 17 00:00:00 2001 From: david Date: Sat, 11 Jan 2003 16:30:32 +0000 Subject: [PATCH] Added simple proof-of-concept support for running PSL scripts from input bindings. They will work only with the latest CVS; otherwise, ./configure will disable them. There is a new command, 'script', which takes a single argument, also called 'script', containing PSL code (currently PSL requires a main() function). Erik Hofman has written some more elaborate code for triggering PSL code from drop-down menus and scheduling events; I will look at integrating that next. --- configure.ac | 37 ++++++++- src/Main/Makefile.am | 3 +- src/Main/fg_commands.cxx | 14 ++++ src/Main/fg_init.cxx | 10 +++ src/Makefile.am | 1 + src/Scripting/.cvsignore | 3 + src/Scripting/Makefile.am | 5 ++ src/Scripting/scriptmgr.cxx | 155 ++++++++++++++++++++++++++++++++++++ src/Scripting/scriptmgr.hxx | 78 ++++++++++++++++++ 9 files changed, 301 insertions(+), 5 deletions(-) create mode 100644 src/Scripting/.cvsignore create mode 100644 src/Scripting/Makefile.am create mode 100644 src/Scripting/scriptmgr.cxx create mode 100644 src/Scripting/scriptmgr.hxx diff --git a/configure.ac b/configure.ac index 083aab144..56c7987be 100644 --- a/configure.ac +++ b/configure.ac @@ -340,8 +340,29 @@ int main() { dnl If we get here then plib is available, so force use of plib dnl joystick lib AC_DEFINE([ENABLE_PLIB_JOYSTICK], 1, [Define to enable plib joystick support]) -AC_DEFINE([FG_PLIB_JOYSTICK_GETNAME], 1, - [Define to enable plib joystick name support]) + + +dnl Compiling an in-memory PSL script is available only in the CVS +dnl version of plib, so check for it. +AC_MSG_CHECKING([for plib PSL in-memory script compilation support]) +AC_COMPILE_IFELSE([ +#include + +int main() { + // not for running... + pslProgram program((pslExtension *)0); + program.compile("int main () {}", ""); + return 0; +} +], + [AC_MSG_RESULT(yes); + fg_psl_string_compile=yes], + AC_MSG_RESULT(no) +) +if test "x$fg_psl_string_compile" = "xyes"; then + AC_DEFINE([FG_PSL_STRING_COMPILE], 1, + [Support for compiling PSL scripts from an in-memory string.]) +fi dnl Check for MetaKit AC_CHECK_HEADER(mk4.h) @@ -546,6 +567,7 @@ AC_CONFIG_FILES([ \ src/NetworkOLK/Makefile \ src/Objects/Makefile \ src/Scenery/Makefile \ + src/Scripting/Makefile \ src/Sound/Makefile \ src/Systems/Makefile \ src/Time/Makefile \ @@ -564,6 +586,15 @@ echo "=================" echo "Prefix: $prefix" +if test "x$fg_psl_string_compile" = "xyes"; then + echo "Scripts for input bindings: yes" +else + echo "Scripts for input bindings: $fg_psl_string_compile" + echo " PSL scripts attached to input bindings will not" + echo " work. Download the latest CVS version of plib" + echo " if you would like to enable them." +fi + if test "x$with_logging" != "x"; then echo "Debug messages: $with_logging" else @@ -573,8 +604,6 @@ fi echo -n "Automake version: " automake --version | head -1 -echo "New plib joystick name support: $plib_js_has_getname" - if test "x$with_weathercm" != "x"; then echo "WeatherCM instead of FGEnvironment: $with_weathercm" else diff --git a/src/Main/Makefile.am b/src/Main/Makefile.am index fb8060b00..184fff0df 100644 --- a/src/Main/Makefile.am +++ b/src/Main/Makefile.am @@ -66,6 +66,7 @@ fgfs_LDADD = \ $(top_builddir)/src/Model/libModel.a \ $(top_builddir)/src/Navaids/libNavaids.a \ $(top_builddir)/src/Scenery/libScenery.a \ + $(top_builddir)/src/Scripting/libScripting.a \ $(top_builddir)/src/Sound/libSound.a \ $(top_builddir)/src/Airports/libAirports.a \ $(NETWORK_LIBS) \ @@ -77,7 +78,7 @@ fgfs_LDADD = \ -lsgmath -lsgbucket -lsgdebug -lsgmagvar -lsgmisc -lsgxml \ -lsgserial \ $(THREAD_LIBS) \ - -lplibpu -lplibfnt -lplibjs -lplibnet -lplibssg -lplibsg -lplibul \ + -lplibpu -lplibfnt -lplibjs -lplibnet -lplibssg -lplibsg -lplibul -lplibpsl \ -lmk4 -lz \ $(opengl_LIBS) \ $(audio_LIBS) diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index 82e7f47c9..d12fc57f5 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include