1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 /* 24 * This code is based on Broken Sword 2.5 engine 25 * 26 * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer 27 * 28 * Licensed under GNU GPL v2 29 * 30 */ 31 32 #ifndef SWORD25_SCRIPT_H 33 #define SWORD25_SCRIPT_H 34 35 #include "common/array.h" 36 #include "common/str.h" 37 #include "sword25/kernel/common.h" 38 #include "sword25/kernel/service.h" 39 #include "sword25/kernel/persistable.h" 40 41 namespace Sword25 { 42 43 class Kernel; 44 class OutputPersistenceBlock; 45 class BS_InputPersistenceBlock; 46 47 class ScriptEngine : public Service, public Persistable { 48 public: ScriptEngine(Kernel * KernelPtr)49 ScriptEngine(Kernel *KernelPtr) : Service(KernelPtr) {} ~ScriptEngine()50 virtual ~ScriptEngine() {} 51 52 // ----------------------------------------------------------------------------- 53 // This method must be implemented by the script engine 54 // ----------------------------------------------------------------------------- 55 56 /** 57 * Initializes the scrip tengine. Returns true if successful, false otherwise. 58 */ 59 virtual bool init() = 0; 60 61 /** 62 * Loads a script file and executes it. 63 * @param FileName The script filename 64 */ 65 virtual bool executeFile(const Common::String &fileName) = 0; 66 67 /** 68 * Executes a specified script fragment 69 * @param Code String of script code 70 */ 71 virtual bool executeString(const Common::String &code) = 0; 72 73 /** 74 * Returns a pointer to the main object of the script engine 75 * Note: Using this method breaks the encapsulation of the language from the rest of the engine. 76 */ 77 virtual void *getScriptObject() = 0; 78 79 /** 80 * Makes the command line parameters for the script environment available 81 * Note: How the command line parameters will be used by scripts is dependant on the 82 * particular implementation. 83 * @param CommandLineParameters List containing the command line parameters 84 */ 85 virtual void setCommandLine(const Common::Array<Common::String> &commandLineParameters) = 0; 86 87 virtual bool persist(OutputPersistenceBlock &writer) = 0; 88 virtual bool unpersist(InputPersistenceBlock &reader) = 0; 89 }; 90 91 } // End of namespace Sword25 92 93 #endif 94