Cleaned up a bit
This commit is contained in:
parent
1db3d7bfd2
commit
e96cf33cf5
@ -1,3 +1,20 @@
|
|||||||
|
//
|
||||||
|
// SuperTuxKart - a fun racing game with go-kart
|
||||||
|
// Copyright (C) 2014 SuperTuxKart Team
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU General Public License
|
||||||
|
// as published by the Free Software Foundation; either version 3
|
||||||
|
// of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include <iostream> // cout
|
#include <iostream> // cout
|
||||||
#include <assert.h> // assert()
|
#include <assert.h> // assert()
|
||||||
@ -14,10 +31,12 @@
|
|||||||
using namespace irr;
|
using namespace irr;
|
||||||
|
|
||||||
|
|
||||||
asIScriptEngine *m_engine;
|
|
||||||
// Function prototypes for binding. TODO:put these in their right place
|
|
||||||
void configureEngine(asIScriptEngine *engine);
|
// Function prototypes for binding.
|
||||||
int compileScript(asIScriptEngine *engine,std::string scriptName);
|
void displayMessage(asIScriptGeneric *gen);
|
||||||
|
void disableAnimation(asIScriptGeneric *gen);
|
||||||
|
void squashKart(asIScriptGeneric *gen);
|
||||||
|
|
||||||
ScriptEngine::ScriptEngine(){
|
ScriptEngine::ScriptEngine(){
|
||||||
// Create the script engine
|
// Create the script engine
|
||||||
@ -36,6 +55,8 @@ ScriptEngine::~ScriptEngine(){
|
|||||||
// Release the engine
|
// Release the engine
|
||||||
m_engine->Release();
|
m_engine->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Displays the message specified in displayMessage( string message ) within the script
|
// Displays the message specified in displayMessage( string message ) within the script
|
||||||
void displayMessage(asIScriptGeneric *gen){
|
void displayMessage(asIScriptGeneric *gen){
|
||||||
std::string *input = (std::string*)gen->GetArgAddress(0);
|
std::string *input = (std::string*)gen->GetArgAddress(0);
|
||||||
@ -148,7 +169,11 @@ void ScriptEngine::runScript(std::string scriptName)
|
|||||||
ctx->Release();
|
ctx->Release();
|
||||||
|
|
||||||
}
|
}
|
||||||
void configureEngine(asIScriptEngine *engine)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ScriptEngine::configureEngine(asIScriptEngine *engine)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -167,14 +192,18 @@ void configureEngine(asIScriptEngine *engine)
|
|||||||
// without having to recompile all the scripts.
|
// without having to recompile all the scripts.
|
||||||
}
|
}
|
||||||
|
|
||||||
int compileScript(asIScriptEngine *engine, std::string scriptName)
|
|
||||||
|
|
||||||
|
|
||||||
|
int ScriptEngine::compileScript(asIScriptEngine *engine, std::string scriptName)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
// For now we will load the script directtly from a file on the disk.
|
// For now we will load the script directtly from a file on the disk.
|
||||||
//TODO use filemanager to do this.
|
//TODO use filemanager to do this.
|
||||||
//std::string load_dir = "D:\\Github\\stk\\stk-code\\src\\scriptengine\\";
|
//std::string load_dir = "D:\\Github\\stk\\stk-code\\src\\scriptengine\\";
|
||||||
std::string load_dir = "//media//New Volume//Github//stk//stk-code//src//scriptengine//";
|
//std::string load_dir = "//media//New Volume//Github//stk//stk-code//src//scriptengine//";
|
||||||
|
std::string load_dir = "..//..//src//scriptengine//";
|
||||||
load_dir += scriptName + ".as";
|
load_dir += scriptName + ".as";
|
||||||
FILE *f = fopen(load_dir.c_str(), "rb");
|
FILE *f = fopen(load_dir.c_str(), "rb");
|
||||||
if( f == 0 )
|
if( f == 0 )
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
//
|
//
|
||||||
// SuperTuxKart - a fun racing game with go-kart
|
// SuperTuxKart - a fun racing game with go-kart
|
||||||
// Copyright (C) 2009-2013 Joerg Henrichs
|
// Copyright (C) 2014 SuperTuxKart Team
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU General Public License
|
// modify it under the terms of the GNU General Public License
|
||||||
@ -20,7 +19,8 @@
|
|||||||
#ifndef HEADER_SCRIPT_ENGINE_HPP
|
#ifndef HEADER_SCRIPT_ENGINE_HPP
|
||||||
#define HEADER_SCRIPT_ENGINE_HPP
|
#define HEADER_SCRIPT_ENGINE_HPP
|
||||||
|
|
||||||
#include<string>
|
#include <string>
|
||||||
|
#include <angelscript.h>
|
||||||
|
|
||||||
class TrackObjectPresentation;
|
class TrackObjectPresentation;
|
||||||
|
|
||||||
@ -31,7 +31,13 @@ public:
|
|||||||
ScriptEngine();
|
ScriptEngine();
|
||||||
~ScriptEngine();
|
~ScriptEngine();
|
||||||
|
|
||||||
void runScript(std::string scriptName);
|
void runScript(std::string scriptName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
asIScriptEngine *m_engine;
|
||||||
|
|
||||||
|
void configureEngine(asIScriptEngine *engine);
|
||||||
|
int compileScript(asIScriptEngine *engine,std::string scriptName);
|
||||||
|
|
||||||
}; // class ScriptEngine
|
}; // class ScriptEngine
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user