Vegastrike 0.5.1 rc1
1.0
Original sources for Vegastrike Evolved
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
base.h
Go to the documentation of this file.
1
#ifndef __BASE_H__
2
#define __BASE_H__
3
#include <vector>
4
#include <string>
5
#include "
basecomputer.h
"
6
#include "
gfx/hud.h
"
7
#include "
gfx/sprite.h
"
8
#include <stdio.h>
9
#include "
gui/glut_support.h
"
10
11
#include "
audio/Types.h
"
12
#include "
audio/Source.h
"
13
14
//#define BASE_MAKER
15
//#define BASE_XML //in case you want to write out XML instead...
16
17
#define BASE_EXTENSION ".py"
18
19
void
RunPython
(
const
char
*filnam );
20
21
class
BaseInterface
22
{
23
int
curlinkindex;
24
int
lastmouseindex;
//Last link index to be under the mouse
25
MousePointerStyle
mousePointerStyle;
26
bool
enabledj;
27
bool
terminate_scheduled;
28
bool
midloop;
29
TextPlane
curtext;
30
public
:
31
class
Room
32
{
33
public
:
34
class
Link
35
{
36
public
:
37
enum
38
{
39
ClickEvent
=(1<<0),
40
DownEvent
=(1<<1),
41
UpEvent
=(1<<2),
42
MoveEvent
=(1<<3),
43
EnterEvent
=(1<<4),
44
LeaveEvent
=(1<<5)
45
};
46
47
std::string
pythonfile
;
48
float
x
,
y
,
wid
,
hei
,
alpha
;
49
std::string
text
;
50
const
std::string
index
;
51
unsigned
int
eventMask
;
52
int
clickbtn
;
53
54
virtual
void
Click
( ::
BaseInterface
*base,
float
x
,
float
y
,
int
button,
int
state );
55
virtual
void
MouseMove
( ::
BaseInterface
*base,
float
x
,
float
y
,
int
buttonmask );
56
virtual
void
MouseEnter
( ::
BaseInterface
*base,
float
x
,
float
y
,
int
buttonmask );
57
virtual
void
MouseLeave
( ::
BaseInterface
*base,
float
x
,
float
y
,
int
buttonmask );
58
59
void
setEventMask
(
unsigned
int
mask )
60
{
61
eventMask
= mask;
62
}
63
64
explicit
Link
(
const
std::string &ind,
const
std::string &pfile ) :
pythonfile
( pfile )
65
,
alpha
( 1.0
f
)
66
,
index
( ind )
67
,
eventMask
(
ClickEvent
)
68
,
clickbtn
( -1 ) {}
69
virtual
~Link
() {}
70
#ifdef BASE_MAKER
71
virtual
void
EndXML( FILE *fp );
72
#endif
73
virtual
void
Relink
(
const
std::string &pfile );
74
};
75
class
Goto
:
public
Link
76
{
77
public
:
78
int
index
;
79
virtual
void
Click
( ::
BaseInterface
*base,
float
x
,
float
y
,
int
button,
int
state );
80
virtual
~Goto
() {}
81
explicit
Goto
(
const
std::string &ind,
const
std::string &
pythonfile
) :
Link
( ind, pythonfile ) {}
82
#ifdef BASE_MAKER
83
virtual
void
EndXML( FILE *fp );
84
#endif
85
};
86
class
Comp
:
public
Link
87
{
88
public
:
89
vector< BaseComputer::DisplayMode >
modes
;
90
virtual
void
Click
( ::
BaseInterface
*base,
float
x
,
float
y
,
int
button,
int
state );
91
virtual
~Comp
() {}
92
explicit
Comp
(
const
std::string &ind,
const
std::string &
pythonfile
) :
Link
( ind, pythonfile ) {}
93
#ifdef BASE_MAKER
94
virtual
void
EndXML( FILE *fp );
95
#endif
96
};
97
class
Launch
:
public
Link
98
{
99
public
:
100
virtual
void
Click
( ::
BaseInterface
*base,
float
x
,
float
y
,
int
button,
int
state );
101
virtual
~Launch
() {}
102
explicit
Launch
(
const
std::string &ind,
const
std::string &
pythonfile
) :
Link
( ind, pythonfile ) {}
103
#ifdef BASE_MAKER
104
virtual
void
EndXML( FILE *fp );
105
#endif
106
};
107
class
Eject
:
public
Link
108
{
109
public
:
110
virtual
void
Click
( ::
BaseInterface
*base,
float
x
,
float
y
,
int
button,
int
state );
111
virtual
~Eject
() {}
112
explicit
Eject
(
const
std::string &ind,
const
std::string &
pythonfile
) :
Link
( ind, pythonfile ) {}
113
#ifdef BASE_MAKER
114
virtual
void
EndXML( FILE *fp );
115
#endif
116
};
117
class
Talk
:
public
Link
118
{
119
public
:
120
//At the moment, the BaseInterface::Room::Talk class is unused... but I may find a use for it later...
121
std::vector< std::string >
say
;
122
std::vector< std::string >
soundfiles
;
123
int
index
;
124
int
curroom
;
125
virtual
void
Click
( ::
BaseInterface
*base,
float
x
,
float
y
,
int
button,
int
state );
126
explicit
Talk
(
const
std::string &ind,
const
std::string &
pythonfile
);
127
virtual
~Talk
() {}
128
#ifdef BASE_MAKER
129
virtual
void
EndXML( FILE *fp );
130
#endif
131
};
132
class
Python
:
public
Link
133
{
134
public
:
135
Python
(
const
std::string &ind,
const
std::string &
pythonfile
) :
Link
( ind, pythonfile ) {}
136
virtual
~Python
() {}
137
#ifdef BASE_MAKER
138
virtual
void
EndXML( FILE *fp );
139
#endif
140
};
141
class
BaseObj
142
{
143
public
:
144
const
std::string
index
;
145
virtual
void
Draw
( ::
BaseInterface
*base );
146
#ifdef BASE_MAKER
147
virtual
void
EndXML( FILE *fp );
148
#endif
149
virtual
~BaseObj
() {}
150
explicit
BaseObj
(
const
std::string &ind ) :
index
( ind ) {}
151
};
152
class
BasePython
:
public
BaseObj
153
{
154
public
:
155
std::string
pythonfile
;
156
float
timeleft
;
157
float
maxtime
;
158
virtual
void
Draw
( ::
BaseInterface
*base );
159
#ifdef BASE_MAKER
160
virtual
void
EndXML( FILE *fp );
161
#endif
162
virtual
~BasePython
() {}
163
BasePython
(
const
std::string &ind,
const
std::string &python,
float
time ) :
BaseObj
( ind )
164
,
pythonfile
( python )
165
,
timeleft
( 0 )
166
,
maxtime
( time ) {}
167
virtual
void
Relink
(
const
std::string &python );
168
};
169
class
BaseText
:
public
BaseObj
170
{
171
public
:
172
TextPlane
text
;
173
virtual
void
Draw
( ::
BaseInterface
*base );
174
#ifdef BASE_MAKER
175
virtual
void
EndXML( FILE *fp );
176
#endif
177
virtual
~BaseText
() {}
178
BaseText
(
const
std::string &texts,
179
float
posx,
180
float
posy,
181
float
wid,
182
float
hei,
183
float
charsizemult,
184
GFXColor
backcol,
185
GFXColor
forecol,
186
const
std::string &ind ) :
BaseObj
( ind )
187
,
text
( forecol, backcol )
188
{
189
text
.
SetPos
( posx, posy );
190
text
.
SetSize
( wid, hei );
191
float
cx = 0, cy = 0;
192
text
.
GetCharSize
( cx, cy );
193
cx *= charsizemult;
194
cy *= charsizemult;
195
text
.
SetCharSize
( cx, cy );
196
text
.
SetText
( texts );
197
}
198
void
SetText
(
const
std::string &newtext )
199
{
200
text
.
SetText
( newtext );
201
}
202
void
SetPos
(
float
posx,
float
posy )
203
{
204
text
.
SetPos
( posx, posy );
205
}
206
void
SetSize
(
float
wid,
float
hei )
207
{
208
text
.
SetSize
( wid, hei );
209
}
210
};
211
class
BaseShip
:
public
BaseObj
212
{
213
public
:
214
virtual
void
Draw
( ::
BaseInterface
*base );
215
Matrix
mat
;
216
virtual
~BaseShip
() {}
217
#ifdef BASE_MAKER
218
virtual
void
EndXML( FILE *fp );
219
#endif
220
explicit
BaseShip
(
const
std::string &ind ) :
BaseObj
( ind ) {}
221
BaseShip
(
float
r0,
222
float
r1,
223
float
r2,
224
float
r3,
225
float
r4,
226
float
r5,
227
float
r6,
228
float
r7,
229
float
r8,
230
QVector
pos,
231
const
std::string &ind ) :
232
BaseObj
( ind )
233
,
mat
( r0, r1, r2, r3, r4, r5, r6, r7, r8,
QVector
( pos.
i
/2, pos.
j
/2, pos.
k
) ) {}
234
};
235
class
BaseVSSprite
:
public
BaseObj
236
{
237
public
:
238
virtual
void
Draw
( ::
BaseInterface
*base );
239
VSSprite
spr
;
240
SharedPtr<Audio::Source>
soundsource
;
241
std::string
soundscene
;
242
243
#ifdef BASE_MAKER
244
std::string texfile;
245
virtual
void
EndXML( FILE *fp );
246
#endif
247
virtual
~BaseVSSprite
();
248
BaseVSSprite
(
const
std::string &spritefile,
const
std::string &ind );
249
void
SetSprite
(
const
std::string &spritefile );
250
void
SetPos
(
float
posx,
float
posy )
251
{
252
spr
.
SetPosition
( posx, posy );
253
}
254
void
SetSize
(
float
wid,
float
hei )
255
{
256
spr
.
SetSize
( wid, hei );
257
}
258
void
SetTime
(
float
t )
259
{
260
spr
.
SetTime
( t );
261
}
262
bool
isPlaying
()
const
;
263
264
protected
:
BaseVSSprite
(
const
std::string &ind,
const
VSSprite
&sprite ) :
BaseObj
( ind )
265
,
spr
( sprite ) {}
266
};
267
268
class
BaseVSMovie
:
public
BaseVSSprite
269
{
270
std::string callback;
271
bool
playing;
272
bool
hidePointer;
273
double
hidePointerTime;
274
275
public
:
276
virtual
~BaseVSMovie
() {}
277
BaseVSMovie
(
const
std::string &moviefile,
const
std::string &ind );
278
void
SetMovie
(
const
std::string &moviefile );
279
280
float
GetTime
()
const
;
281
void
SetTime
(
float
t );
282
283
bool
GetHidePointer
()
const
{
return
hidePointer; };
284
void
SetHidePointer
(
bool
hide );
285
286
const
std::string&
getCallback
()
const
{
return
callback; }
287
void
setCallback
(
const
std::string &callback) { this->callback = callback; }
288
289
virtual
void
Draw
( ::
BaseInterface
*base );
290
};
291
292
class
BaseTalk
:
public
BaseObj
293
{
294
public
:
295
static
bool
hastalked
;
296
virtual
void
Draw
( ::
BaseInterface
*base );
297
//Talk * caller;
298
unsigned
int
curchar
;
299
float
curtime
;
300
virtual
~BaseTalk
() {}
301
std::string
message
;
302
BaseTalk
(
const
std::string &msg,
const
std::string &ind,
bool
only_one_talk );
303
#ifdef BASE_MAKER
304
virtual
void
EndXML( FILE *fp ) {}
305
#endif
306
};
307
std::string
soundfile
;
308
std::string
deftext
;
309
std::vector< Link* >
links
;
310
std::vector< BaseObj* >
objs
;
311
#ifdef BASE_MAKER
312
void
EndXML( FILE *fp );
313
#endif
314
void
Draw
( ::
BaseInterface
*base );
315
void
Click
( ::
BaseInterface
*base,
float
x
,
float
y
,
int
button,
int
state );
316
int
MouseOver
( ::
BaseInterface
*base,
float
x
,
float
y
);
317
Room
();
318
~Room
();
319
};
320
friend
class
Room
;
321
friend
class
Room::BaseTalk
;
322
int
curroom
;
323
std::vector< Room* >
rooms
;
324
TextPlane
othtext
;
325
static
BaseInterface
*
CurrentBase
;
326
bool
CallComp
;
327
UnitContainer
caller
;
328
UnitContainer
baseun
;
329
330
std::string
python_kbhandler
;
331
332
#ifdef BASE_MAKER
333
void
EndXML( FILE *fp );
334
#endif
335
void
Terminate
();
336
void
GotoLink
(
int
linknum );
337
void
InitCallbacks
();
338
void
CallCommonLinks
(
const
std::string &name,
const
std::string &value );
339
void
Load
(
const
char
*filename,
const
char
*time_of_day,
const
char
*
faction
);
340
static
void
ClickWin
(
int
x
,
int
y
,
int
button,
int
state );
341
void
Click
(
int
x
,
int
y
,
int
button,
int
state );
342
void
Key
(
unsigned
int
ch,
unsigned
int
mod,
bool
release,
int
x
,
int
y
);
343
static
void
PassiveMouseOverWin
(
int
x
,
int
y
);
344
static
void
ActiveMouseOverWin
(
int
x
,
int
y
);
345
static
void
ProcessKeyboardBuffer
();
346
void
MouseOver
(
int
x
,
int
y
);
347
BaseInterface
(
const
char
*basefile,
Unit
*base,
Unit
*un );
348
~BaseInterface
();
349
void
Draw
();
350
351
void
setDJEnabled
(
bool
enabled);
352
bool
isDJEnabled
()
const
{
return
enabledj; }
353
};
354
355
#endif
356
src
cmd
base.h
Generated on Fri May 29 2015 23:07:09 for Vegastrike 0.5.1 rc1 by
1.8.4