1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
|
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * 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, see http://www.gnu.org/licenses/.
// robotmain.h
#pragma once
#include <stdio.h>
#include "common/misc.h"
#include "old/d3dengine.h"
#include "object/object.h"
#include "object/mainmovie.h"
#include "old/camera.h"
#include "old/particule.h"
enum Phase
{
PHASE_INIT,
PHASE_TERM,
PHASE_NAME,
PHASE_PERSO,
PHASE_TRAINER,
PHASE_DEFI,
PHASE_MISSION,
PHASE_FREE,
PHASE_TEEN,
PHASE_USER,
PHASE_PROTO,
PHASE_LOADING,
PHASE_SIMUL,
PHASE_MODEL,
PHASE_SETUPd,
PHASE_SETUPg,
PHASE_SETUPp,
PHASE_SETUPc,
PHASE_SETUPs,
PHASE_SETUPds,
PHASE_SETUPgs,
PHASE_SETUPps,
PHASE_SETUPcs,
PHASE_SETUPss,
PHASE_WRITE,
PHASE_READ,
PHASE_WRITEs,
PHASE_READs,
PHASE_WIN,
PHASE_LOST,
PHASE_WELCOME1,
PHASE_WELCOME2,
PHASE_WELCOME3,
PHASE_GENERIC,
};
class CInstanceManager;
class CMainDialog;
class CMainShort;
class CMainMap;
class CEvent;
class CD3DEngine;
class CLight;
class CWater;
class CCloud;
class CBlitz;
class CPlanet;
class CTerrain;
class CModel;
class CInterface;
class CWindow;
class CControl;
class CDisplayText;
class CDisplayInfo;
class CSound;
struct EndTake
{
Math::Vector pos;
float dist;
ObjectType type;
int min; // wins if>
int max; // wins if <
int lost; // lost if <=
bool bImmediat;
char message[100];
};
const int MAXNEWSCRIPTNAME = 20;
struct NewScriptName
{
bool bUsed;
ObjectType type;
char name[40];
};
const int MAXSHOWLIMIT = 5;
const int MAXSHOWPARTI = 200;
const float SHOWLIMITTIME = 20.0f;
struct ShowLimit
{
bool bUsed;
Math::Vector pos;
float radius;
int total;
int parti[MAXSHOWPARTI];
CObject* link;
float duration;
float time;
};
const int SATCOM_HUSTON = 0;
const int SATCOM_SAT = 1;
const int SATCOM_OBJECT = 2;
const int SATCOM_LOADING = 3;
const int SATCOM_PROG = 4;
const int SATCOM_SOLUCE = 5;
const int SATCOM_MAX = 6;
class CRobotMain
{
public:
CRobotMain(CInstanceManager* iMan);
~CRobotMain();
void CreateIni();
void ChangePhase(Phase phase);
bool EventProcess(const Event &event);
bool CreateShortcuts();
void ScenePerso();
void SetMovieLock(bool bLock);
bool RetMovieLock();
bool RetInfoLock();
void SetSatComLock(bool bLock);
bool RetSatComLock();
void SetEditLock(bool bLock, bool bEdit);
bool RetEditLock();
void SetEditFull(bool bFull);
bool RetEditFull();
bool RetFreePhoto();
void SetFriendAim(bool bFriend);
bool RetFriendAim();
void SetTracePrecision(float factor);
float RetTracePrecision();
void ChangePause(bool bPause);
void SetSpeed(float speed);
float RetSpeed();
void UpdateShortcuts();
void SelectHuman();
CObject* SearchHuman();
CObject* SearchToto();
CObject* SearchNearest(Math::Vector pos, CObject* pExclu);
bool SelectObject(CObject* pObj, bool bDisplayError=true);
CObject* RetSelectObject();
CObject* DeselectAll();
bool DeleteObject();
void ResetObject();
void ResetCreate();
Error CheckEndMission(bool bFrame);
void CheckEndMessage(char *message);
int RetObligatoryToken();
char* RetObligatoryToken(int i);
int IsObligatoryToken(char *token);
bool IsProhibitedToken(char *token);
void UpdateMap();
bool RetShowMap();
MainMovieType RetMainMovie();
void FlushDisplayInfo();
void StartDisplayInfo(int index, bool bMovie);
void StartDisplayInfo(char *filename, int index);
void StopDisplayInfo();
char* RetDisplayInfoName(int index);
int RetDisplayInfoPosition(int index);
void SetDisplayInfoPosition(int index, int pos);
void StartSuspend();
void StopSuspend();
float RetGameTime();
void SetFontSize(float size);
float RetFontSize();
void SetWindowPos(Math::Point pos);
Math::Point RetWindowPos();
void SetWindowDim(Math::Point dim);
Math::Point RetWindowDim();
void SetIOPublic(bool bMode);
bool RetIOPublic();
void SetIOPos(Math::Point pos);
Math::Point RetIOPos();
void SetIODim(Math::Point dim);
Math::Point RetIODim();
char* RetTitle();
char* RetResume();
char* RetScriptName();
char* RetScriptFile();
bool RetTrainerPilot();
bool RetFixScene();
bool RetGlint();
bool RetSoluce4();
bool RetMovies();
bool RetNiceReset();
bool RetHimselfDamage();
bool RetShowSoluce();
bool RetSceneSoluce();
bool RetShowAll();
bool RetCheatRadar();
char* RetSavegameDir();
char* RetPublicDir();
char* RetFilesDir();
void SetGamerName(char *name);
char* RetGamerName();
int RetGamerFace();
int RetGamerGlasses();
bool RetGamerOnlyHead();
float RetPersoAngle();
void StartMusic();
void ClearInterface();
void ChangeColor();
float SearchNearestObject(Math::Vector center, CObject *exclu);
bool FreeSpace(Math::Vector ¢er, float minRadius, float maxRadius, float space, CObject *exclu);
float RetFlatZoneRadius(Math::Vector center, float maxRadius, CObject *exclu);
void HideDropZone(CObject* metal);
void ShowDropZone(CObject* metal, CObject* truck);
void FlushShowLimit(int i);
void SetShowLimit(int i, ParticuleType parti, CObject *pObj, Math::Vector pos, float radius, float duration=SHOWLIMITTIME);
void AdjustShowLimit(int i, Math::Vector pos);
void StartShowLimit();
void FrameShowLimit(float rTime);
void CompileScript(bool bSoluce);
void LoadOneScript(CObject *pObj, int &nbError);
void LoadFileScript(CObject *pObj, char* filename, int objRank, int &nbError);
void SaveAllScript();
void SaveOneScript(CObject *pObj);
void SaveFileScript(CObject *pObj, char* filename, int objRank);
bool SaveFileStack(CObject *pObj, FILE *file, int objRank);
bool ReadFileStack(CObject *pObj, FILE *file, int objRank);
bool FlushNewScriptName();
bool AddNewScriptName(ObjectType type, char *name);
char* RetNewScriptName(ObjectType type, int rank);
void WriteFreeParam();
void ReadFreeParam();
bool IsBusy();
bool IOWriteScene(char *filename, char *filecbot, char *info);
CObject* IOReadScene(char *filename, char *filecbot);
void IOWriteObject(FILE *file, CObject* pObj, char *cmd);
CObject* IOReadObject(char *line, char* filename, int objRank);
int CreateSpot(Math::Vector pos, D3DCOLORVALUE color);
protected:
bool EventFrame(const Event &event);
bool EventObject(const Event &event);
void InitEye();
void Convert();
void CreateScene(bool bSoluce, bool bFixScene, bool bResetObject);
void CreateModel();
Math::Vector LookatPoint( Math::Vector eye, float angleH, float angleV, float length );
CObject* CreateObject(Math::Vector pos, float angle, float zoom, float height, ObjectType type, float power=1.0f, bool bTrainer=false, bool bToy=false, int option=0);
int CreateLight(Math::Vector direction, D3DCOLORVALUE color);
void HiliteClear();
void HiliteObject(Math::Point pos);
void HiliteFrame(float rTime);
void CreateTooltip(Math::Point pos, char* text);
void ClearTooltip();
CObject* DetectObject(Math::Point pos);
void ChangeCamera();
void RemoteCamera(float pan, float zoom, float rTime);
void KeyCamera(EventMsg event, long param);
void AbortMovie();
bool IsSelectable(CObject* pObj);
void SelectOneObject(CObject* pObj, bool bDisplayError=true);
void HelpObject();
bool DeselectObject();
void DeleteAllObjects();
void UpdateInfoText();
CObject* SearchObject(ObjectType type);
CObject* RetSelect();
void StartDisplayVisit(EventMsg event);
void FrameVisit(float rTime);
void StopDisplayVisit();
void ExecuteCmd(char *cmd);
bool TestGadgetQuantity(int rank);
protected:
CInstanceManager* m_iMan;
CMainMovie* m_movie;
CMainDialog* m_dialog;
CMainShort* m_short;
CMainMap* m_map;
CEvent* m_event;
CD3DEngine* m_engine;
CParticule* m_particule;
CWater* m_water;
CCloud* m_cloud;
CBlitz* m_blitz;
CPlanet* m_planet;
CLight* m_light;
CTerrain* m_terrain;
CModel* m_model;
CInterface* m_interface;
CCamera* m_camera;
CDisplayText* m_displayText;
CDisplayInfo* m_displayInfo;
CSound* m_sound;
float m_time;
float m_gameTime;
float m_checkEndTime;
float m_winDelay;
float m_lostDelay;
bool m_bFixScene; // scene fixed, no interraction
bool m_bBase; // OBJECT_BASE exists in mission
Math::Point m_lastMousePos;
CObject* m_selectObject;
Phase m_phase;
int m_cameraRank;
D3DCOLORVALUE m_color;
bool m_bFreePhoto;
bool m_bCmdEdit;
bool m_bShowPos;
bool m_bSelectInsect;
bool m_bShowSoluce;
bool m_bShowAll;
bool m_bCheatRadar;
bool m_bAudioRepeat;
bool m_bShortCut;
int m_audioTrack;
int m_delayWriteMessage;
int m_movieInfoIndex;
bool m_bImmediatSatCom; // SatCom immediately?
bool m_bBeginSatCom; // messages SatCom poster?
bool m_bMovieLock; // movie in progress?
bool m_bSatComLock; // call of SatCom is possible?
bool m_bEditLock; // edition in progress?
bool m_bEditFull; // edition in full screen?
bool m_bPause; // simulation paused
bool m_bHilite;
bool m_bTrainerPilot; // remote trainer?
bool m_bSuspend;
bool m_bFriendAim;
bool m_bResetCreate;
bool m_bMapShow;
bool m_bMapImage;
char m_mapFilename[100];
Math::Point m_tooltipPos;
char m_tooltipName[100];
float m_tooltipTime;
char m_infoFilename[SATCOM_MAX][100]; // names of text files
CObject* m_infoObject;
int m_infoIndex;
int m_infoPos[SATCOM_MAX];
int m_infoUsed;
char m_title[100];
char m_resume[500];
char m_scriptName[100];
char m_scriptFile[100];
int m_endingWinRank;
int m_endingLostRank;
bool m_bWinTerminate;
float m_fontSize;
Math::Point m_windowPos;
Math::Point m_windowDim;
bool m_IOPublic;
Math::Point m_IOPos;
Math::Point m_IODim;
NewScriptName m_newScriptName[MAXNEWSCRIPTNAME];
float m_cameraPan;
float m_cameraZoom;
EventMsg m_visitLast;
CObject* m_visitObject;
CObject* m_visitArrow;
float m_visitTime;
float m_visitParticule;
Math::Vector m_visitPos;
Math::Vector m_visitPosArrow;
int m_endTakeTotal;
EndTake m_endTake[10];
long m_endTakeResearch;
float m_endTakeWinDelay;
float m_endTakeLostDelay;
int m_obligatoryTotal;
char m_obligatoryToken[100][20];
int m_prohibitedTotal;
char m_prohibitedToken[100][20];
char m_gamerName[100];
long m_freeBuild; // constructible buildings
long m_freeResearch; // researches possible
ShowLimit m_showLimit[MAXSHOWLIMIT];
D3DCOLORVALUE m_colorRefBot;
D3DCOLORVALUE m_colorNewBot;
D3DCOLORVALUE m_colorRefAlien;
D3DCOLORVALUE m_colorNewAlien;
D3DCOLORVALUE m_colorRefGreen;
D3DCOLORVALUE m_colorNewGreen;
D3DCOLORVALUE m_colorRefWater;
D3DCOLORVALUE m_colorNewWater;
float m_colorShiftWater;
};
|