xoreos
0.0.5
src
engines
jade
script
functions_event.cpp
Go to the documentation of this file.
1
/* xoreos - A reimplementation of BioWare's Aurora engine
2
*
3
* xoreos is the legal property of its developers, whose names
4
* can be found in the AUTHORS file distributed with this source
5
* distribution.
6
*
7
* xoreos 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 3
10
* of the License, or (at your option) any later version.
11
*
12
* xoreos 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 xoreos. If not, see <http://www.gnu.org/licenses/>.
19
*/
20
25
#include "
src/common/util.h
"
26
#include "
src/common/error.h
"
27
28
#include "
src/aurora/nwscript/enginetype.h
"
29
#include "
src/aurora/nwscript/functioncontext.h
"
30
#include "
src/aurora/nwscript/types.h
"
31
#include "
src/aurora/nwscript/variablecontainer.h
"
32
33
#include "
src/engines/jade/event.h
"
34
#include "
src/engines/jade/object.h
"
35
#include "
src/engines/jade/objectcontainer.h
"
36
37
#include "
src/engines/jade/script/functions.h
"
38
39
namespace
Engines
{
40
41
namespace
Jade {
42
43
void
Functions::eventUserDefined
(
Aurora::NWScript::FunctionContext
&ctx) {
44
int32
eventNumber = ctx.
getParams
()[0].getInt();
45
46
ctx.
getReturn
() =
Event
(
kScriptOnUserdefined
, eventNumber);
47
}
48
49
void
Functions::signalEvent
(
Aurora::NWScript::FunctionContext
&ctx) {
50
Aurora::NWScript::VariableContainer
*env = ctx.
getCurrentEnvironment
();
51
if
(!env)
52
return
;
53
54
Object
*
object
=
Jade::ObjectContainer::toObject
(
getParamObject
(ctx, 0));
55
const
Event
*
event
=
Jade::ObjectContainer::toEvent
(ctx.
getParams
()[1].getEngineType());
56
57
if
(event->getScript() ==
kScriptOnUserdefined
)
58
env->
setVariable
(
"EVENT_USER_DEFINED_"
+ object->
getTag
(),
event
->getEventNumber());
59
object
->runScript(event->getScript(), object, object);
60
}
61
62
void
Functions::getUserDefinedEventNumber
(
Aurora::NWScript::FunctionContext
&ctx) {
63
ctx.
getReturn
() = (
int32
) 0;
64
65
Object
*
object
=
Jade::ObjectContainer::toObject
(ctx.
getCaller
());
66
67
Aurora::NWScript::VariableContainer
*env = ctx.
getCurrentEnvironment
();
68
if
(!env || !env->hasVariable(
"EVENT_USER_DEFINED_"
+ object->
getTag
()))
69
return
;
70
71
ctx.
getReturn
() = env->getVariable(
"EVENT_USER_DEFINED_"
+ object->
getTag
()).getInt();
72
}
73
74
void
Functions::setUserDefinedEventNumber
(
Aurora::NWScript::FunctionContext
&ctx) {
75
ctx.
getReturn
() =
Aurora::NWScript::kTypeVoid
;
76
77
Aurora::NWScript::VariableContainer
*env = ctx.
getCurrentEnvironment
();
78
if
(!env)
79
return
;
80
81
Object
*
object
=
Jade::ObjectContainer::toObject
(
getParamObject
(ctx, 0));
82
int32
eventNumber = ctx.
getParams
()[1].getInt();
83
84
env->
setVariable
(
"EVENT_USER_DEFINED_"
+ object->
getTag
(), eventNumber);
85
}
86
87
}
// End of namespace Jade
88
89
}
// End of namespace Engines
object.h
An object within a Jade Empire area.
Engines::Jade::Functions::signalEvent
void signalEvent(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_event.cpp:49
event.h
A scripting event.
Engines::Jade::Functions::eventUserDefined
void eventUserDefined(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_event.cpp:43
functioncontext.h
Context of an NWScript function.
functions.h
Jade Empire engine functions.
Aurora::NWScript::FunctionContext::getCaller
Object * getCaller() const
Definition:
functioncontext.cpp:119
Engines::Jade::Functions::getParamObject
static Aurora::NWScript::Object * getParamObject(const Aurora::NWScript::FunctionContext &ctx, size_t n)
Definition:
functions.cpp:118
Engines::Jade::ObjectContainer::toEvent
static Event * toEvent(Aurora::NWScript::EngineType *engineType)
Definition:
objectcontainer.cpp:157
Events::Event
SDL_Event Event
Definition:
types.h:42
Aurora::NWScript::Object::getTag
const Common::UString & getTag() const
Definition:
object.h:49
Aurora::NWScript::FunctionContext
Definition:
functioncontext.h:42
objectcontainer.h
A container of Jade Empire objects.
Engines::Jade::Functions::setUserDefinedEventNumber
void setUserDefinedEventNumber(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_event.cpp:74
enginetype.h
An NWScript engine type.
error.h
Basic exceptions to throw.
Engines::Jade::ObjectContainer::toObject
static Jade::Object * toObject(::Aurora::NWScript::Object *object)
Definition:
objectcontainer.cpp:125
util.h
Utility templates and functions.
Engines
Definition:
console.cpp:69
Aurora::NWScript::FunctionContext::getCurrentEnvironment
VariableContainer * getCurrentEnvironment() const
Definition:
functioncontext.cpp:167
Aurora::NWScript::VariableContainer
Definition:
variablecontainer.h:38
variablecontainer.h
An NWScript variable container.
Aurora::NWScript::FunctionContext::getParams
Parameters & getParams()
Definition:
functioncontext.cpp:151
Engines::Jade::Object
An object within a Jade area.
Definition:
object.h:53
Engines::Jade::Event
Definition:
event.h:44
Aurora::NWScript::FunctionContext::getReturn
Variable & getReturn()
Definition:
functioncontext.cpp:143
Aurora::NWScript::VariableContainer::setVariable
void setVariable(const Common::UString &var, const Variable &value)
Definition:
variablecontainer.cpp:64
types.h
NWScript types.
Engines::Jade::kScriptOnUserdefined
Definition:
types.h:56
Aurora::NWScript::kTypeVoid
Definition:
types.h:37
Engines::Jade::Functions::getUserDefinedEventNumber
void getUserDefinedEventNumber(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_event.cpp:62
int32
int32_t int32
Definition:
types.h:203
Generated on Sun Nov 18 2018 15:13:39 for xoreos by
1.8.14