Colobot
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
script
script.h
Go to the documentation of this file.
1
/*
2
* This file is part of the Colobot: Gold Edition source code
3
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
4
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
5
*
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
* See the GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see http://gnu.org/licenses
18
*/
19
25
#pragma once
26
27
#include "
CBot/CBotDll.h
"
28
29
#include <memory>
30
#include <string>
31
#include <boost/optional.hpp>
32
33
34
class
COldObject
;
35
class
CTaskExecutorObject
;
36
class
CRobotMain
;
37
class
CScriptFunctions
;
38
39
namespace
Ui
40
{
41
class
CEdit;
42
class
CInterface;
43
class
CList;
44
}
/* Ui */
45
46
namespace
Gfx
47
{
48
class
CEngine;
49
class
CTerrain;
50
class
CWater;
51
}
/* Gfx */
52
53
54
const
int
ERM_CONT = 0;
// if error -> continue
55
const
int
ERM_STOP = 1;
// if error -> stop
56
57
58
class
CScript
59
{
60
friend
class
CScriptFunctions
;
61
public
:
62
CScript
(
COldObject
*
object
);
63
~
CScript
();
64
65
void
PutScript(
Ui::CEdit
* edit,
const
char
* name);
66
bool
GetScript(
Ui::CEdit
* edit);
67
bool
GetCompile();
68
69
void
GetTitle(
char
* buffer);
70
71
void
SetStepMode(
bool
bStep);
72
bool
GetStepMode();
73
bool
Run();
74
bool
Continue();
75
bool
Step();
76
void
Stop();
77
bool
IsRunning();
78
bool
IsContinue();
79
bool
GetCursor(
int
&cursor1,
int
&cursor2);
80
void
UpdateList(
Ui::CList
* list);
81
static
void
ColorizeScript(
Ui::CEdit
* edit,
int
rangeStart = 0,
int
rangeEnd = std::numeric_limits<int>::max());
82
bool
IntroduceVirus();
83
84
int
GetError();
85
void
GetError(std::string& error);
86
87
void
New(
Ui::CEdit
* edit,
const
char
* name);
88
bool
SendScript(
const
char
* text);
89
bool
ReadScript(
const
char
* filename);
90
bool
WriteScript(
const
char
* filename);
91
bool
ReadStack(FILE *file);
92
bool
WriteStack(FILE *file);
93
bool
Compare(
CScript
* other);
94
95
void
SetFilename(
char
*filename);
96
char
* GetFilename();
97
98
protected
:
99
bool
IsEmpty();
100
bool
CheckToken();
101
bool
Compile();
102
103
protected
:
104
COldObject
* m_object =
nullptr
;
105
CTaskExecutorObject
* m_taskExecutor =
nullptr
;
106
107
Gfx::CEngine
* m_engine =
nullptr
;
108
Ui::CInterface
* m_interface =
nullptr
;
109
std::unique_ptr<CBotProgram> m_botProg;
110
CRobotMain
* m_main =
nullptr
;
111
Gfx::CTerrain
* m_terrain =
nullptr
;
112
Gfx::CWater
* m_water =
nullptr
;
113
114
int
m_ipf = 0;
// number of instructions/second
115
int
m_errMode = 0;
// what to do in case of error
116
int
m_len = 0;
// length of the script (without <0>)
117
std::unique_ptr<char[]> m_script;
// script ends with <0>
118
bool
m_bRun =
false
;
// program during execution?
119
bool
m_bStepMode =
false
;
// step by step
120
bool
m_bContinue =
false
;
// external function to continue
121
bool
m_bCompile =
false
;
// compilation ok?
122
char
m_title[50] = {};
// script title
123
char
m_mainFunction[50] = {};
124
char
m_filename[50] = {};
// file name
125
char
m_token[50] = {};
// missing instruction
126
int
m_error = 0;
// error (0=ok)
127
int
m_cursor1 = 0;
128
int
m_cursor2 = 0;
129
boost::optional<float> m_returnValue = boost::none;
130
};
Ui
Definition:
robotmain.h:107
CBotDll.h
Library for interpretation of CBOT language.
CTaskExecutorObject
Interface for objects that can execute tasks.
Definition:
task_executor_object.h:38
Ui::CList
Definition:
list.h:44
COldObject
Definition:
old_object.h:77
CRobotMain
Definition:
robotmain.h:151
Gfx::CTerrain
Terrain loader/generator and manager.
Definition:
terrain.h:145
Gfx
Namespace for (new) graphics code.
Definition:
app.h:49
Gfx::CEngine
The graphics engine.
Definition:
engine.h:620
CScriptFunctions
Definition:
scriptfunc.h:40
CScript
Definition:
script.h:58
Gfx::CWater
Water manager/renderer.
Definition:
water.h:74
Ui::CEdit
Definition:
edit.h:112
Ui::CInterface
Definition:
interface.h:58
Generated by
1.8.9.1