missing include for fluid
[blender.git] / source / gameengine / Ketsji / KX_CDActuator.cpp
1 /**
2  * KX_CDActuator.cpp
3  *
4  * $Id$
5  *
6  * ***** BEGIN GPL LICENSE BLOCK *****
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21  *
22  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23  * All rights reserved.
24  *
25  * The Original Code is: all of this file.
26  *
27  * Contributor(s): none yet.
28  *
29  * ***** END GPL LICENSE BLOCK *****
30  *
31  */
32
33 #include "KX_CDActuator.h"
34 #include "KX_GameObject.h"
35 #include <iostream>
36
37 #ifdef HAVE_CONFIG_H
38 #include <config.h>
39 #endif
40
41 /* ------------------------------------------------------------------------- */
42 /* Native functions                                                          */
43 /* ------------------------------------------------------------------------- */
44 KX_CDActuator::KX_CDActuator(SCA_IObject* gameobject,
45                                                          KX_CDACT_TYPE type,
46                                                          int track,
47                                                          short start,
48                                                          short end)
49                                                          : SCA_IActuator(gameobject)
50 {
51         m_type = type;
52         m_track = track;
53         m_lastEvent = true;
54         m_isplaying = false;
55         m_startFrame = start;
56         m_endFrame = end;
57 }
58
59
60
61 KX_CDActuator::~KX_CDActuator()
62 {
63 }
64
65
66 /* hmmm, do we want this? */
67 CValue* KX_CDActuator::GetReplica()
68 {
69         KX_CDActuator* replica = new KX_CDActuator(*this);
70         replica->ProcessReplica();
71         return replica;
72 };
73
74
75
76 bool KX_CDActuator::Update()
77 {
78         bool result = false;
79         bool bNegativeEvent = IsNegativeEvent();
80
81         RemoveAllEvents();
82
83         if (!bNegativeEvent)
84         {
85                 switch (m_type)
86                 {
87                 default:
88                         // implement me !!
89                         break;
90                 }
91         }
92         return result;
93 }
94
95
96
97 /* ------------------------------------------------------------------------- */
98 /* Python functions                                                          */
99 /* ------------------------------------------------------------------------- */
100
101
102
103 /* Integration hooks ------------------------------------------------------- */
104 PyTypeObject KX_CDActuator::Type = {
105         PyVarObject_HEAD_INIT(NULL, 0)
106         "KX_SoundActuator",
107         sizeof(PyObjectPlus_Proxy),
108         0,
109         py_base_dealloc,
110         0,
111         0,
112         0,
113         0,
114         py_base_repr,
115         0,0,0,0,0,0,0,0,0,
116         Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
117         0,0,0,0,0,0,0,
118         Methods,
119         0,
120         0,
121         &SCA_IActuator::Type,
122         0,0,0,0,0,0,
123         py_base_new
124 };
125
126 PyMethodDef KX_CDActuator::Methods[] = {
127         // Deprecated ----->
128         {"setGain",(PyCFunction) KX_CDActuator::sPySetGain,METH_VARARGS,NULL},
129         {"getGain",(PyCFunction) KX_CDActuator::sPyGetGain,METH_VARARGS,NULL},
130         // <-----
131         KX_PYMETHODTABLE_NOARGS(KX_CDActuator, startCD),
132         KX_PYMETHODTABLE_NOARGS(KX_CDActuator, pauseCD),
133         KX_PYMETHODTABLE_NOARGS(KX_CDActuator, resumeCD),
134         KX_PYMETHODTABLE_NOARGS(KX_CDActuator, stopCD),
135         KX_PYMETHODTABLE_NOARGS(KX_CDActuator, playAll),
136         KX_PYMETHODTABLE_O(KX_CDActuator, playTrack),
137         {NULL,NULL,NULL,NULL} //Sentinel
138 };
139
140 PyAttributeDef KX_CDActuator::Attributes[] = {
141         KX_PYATTRIBUTE_INT_RW("track", 1, 99, false, KX_CDActuator, m_track),
142         { NULL }        //Sentinel
143 };
144
145 int KX_CDActuator::pyattr_setGain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
146 {
147         KX_CDActuator* act = static_cast<KX_CDActuator*>(self);
148         return PY_SET_ATTR_SUCCESS;
149 }
150
151 KX_PYMETHODDEF_DOC_NOARGS(KX_CDActuator, startCD,
152 "startCD()\n"
153 "\tStarts the CD playing.\n")
154 {
155         Py_RETURN_NONE;
156 }
157
158
159 KX_PYMETHODDEF_DOC_NOARGS(KX_CDActuator, pauseCD,
160 "pauseCD()\n"
161 "\tPauses the CD playing.\n")
162 {
163         Py_RETURN_NONE;
164 }
165
166
167 KX_PYMETHODDEF_DOC_NOARGS(KX_CDActuator, resumeCD,
168 "resumeCD()\n"
169 "\tResumes the CD playing.\n")
170 {
171         Py_RETURN_NONE;
172 }
173
174
175 KX_PYMETHODDEF_DOC_NOARGS(KX_CDActuator, stopCD,
176 "stopCD()\n"
177 "\tStops the CD playing.\n")
178 {
179         Py_RETURN_NONE;
180 }
181
182
183 KX_PYMETHODDEF_DOC_O(KX_CDActuator, playTrack,
184 "playTrack(trackNumber)\n"
185 "\tPlays the track selected.\n")
186 {
187         if (PyLong_Check(value)) {
188                 int track = PyLong_AsSsize_t(value);
189         }
190         Py_RETURN_NONE;
191 }
192
193
194
195 KX_PYMETHODDEF_DOC_NOARGS(KX_CDActuator, playAll,
196 "playAll()\n"
197 "\tPlays the CD from the beginning.\n")
198 {
199         Py_RETURN_NONE;
200 }
201
202 // Deprecated ----->
203 PyObject* KX_CDActuator::PySetGain(PyObject* args)
204 {
205         float gain = 1.0;
206         ShowDeprecationWarning("setGain()", "the volume property");
207         if (!PyArg_ParseTuple(args, "f:setGain", &gain))
208                 return NULL;
209
210         Py_RETURN_NONE;
211 }
212
213
214
215 PyObject* KX_CDActuator::PyGetGain(PyObject* args)
216 {
217         float gain = 1.0;
218         ShowDeprecationWarning("getGain()", "the volume property");
219         PyObject* result = PyFloat_FromDouble(gain);
220
221         return result;
222 }
223 // <-----